From 4d615dba0e913d807b38e893ec51e2bf6ea40287 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 17 Jun 2018 18:05:11 +0200 Subject: [PATCH 0001/1566] Initial commit --- .gitignore | 3 + Cargo.lock | 147 +++++++++++++++++++++ Cargo.toml | 10 ++ build.sh | 3 + example.rs | 44 +++++++ rust-toolchain | 1 + src/base.rs | 349 +++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 176 +++++++++++++++++++++++++ 8 files changed, 733 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100755 build.sh create mode 100644 example.rs create mode 100644 rust-toolchain create mode 100644 src/base.rs create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000..02ca9dcf64f2a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +**/*.rs.bk +*.rlib diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000000..e215ad0343124 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,147 @@ +[[package]] +name = "cretonne" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-frontend 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cretonne-codegen" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-entity 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cretonne-entity" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cretonne-frontend" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "dtoa" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "failure" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "failure_derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "itoa" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc_codegen_cretonne" +version = "0.1.0" +dependencies = [ + "cretonne 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde_json" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "synstructure" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "target-lexicon" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum cretonne 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83e1f8d40914cb726d41a49df9554f200b47f36a03c46e5d6044e9dc8a8a47cd" +"checksum cretonne-codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "312ba69a70bebc54789bd0e28414987b5bcd1173263f6afbd0ee8519b84da4ac" +"checksum cretonne-entity 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0be57790fb6db92704951e37981f5e0121e7bfa077c7b48177317bf63795ba4" +"checksum cretonne-frontend 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "14b0fe88b2bc5b71df2ce460761063da21731926e6b554c84d8b937de6640875" +"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" +"checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" +"checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" +"checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" +"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" +"checksum serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a2d9a9ac5120e0f768801ca2b58ad6eec929dc9d1d616c162f208869c2ce95" +"checksum serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "fc97cccc2959f39984524026d760c08ef0dd5f0f5948c8d31797dbfae458c875" +"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" +"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" +"checksum target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71b0a95ba4eff593189d912039fba46ce6ca1876ea6c16830e15340919d0a250" +"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000000..72859b0d7ccf4 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "rustc_codegen_cretonne" +version = "0.1.0" +authors = ["bjorn3 "] + +[lib] +crate-type = ["dylib"] + +[dependencies] +cretonne = "0.11.0" diff --git a/build.sh b/build.sh new file mode 100755 index 0000000000000..5193ef20a1158 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +cargo build || exit 1 + +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.dylib example.rs --crate-type lib diff --git a/example.rs b/example.rs new file mode 100644 index 0000000000000..0962f15063537 --- /dev/null +++ b/example.rs @@ -0,0 +1,44 @@ +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized {} + +#[lang="copy"] +trait Copy {} + +#[lang="freeze"] +trait Freeze {} + +#[lang="mul"] +trait Mul { + type Output; + + #[must_use] + fn mul(self, rhs: RHS) -> Self::Output; +} + +impl Mul for u8 { + type Output = u8; + + fn mul(self, rhs: u8) -> u8 { + self * rhs + } +} + +#[lang="panic"] +fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { + loop {} +} + +fn abc(a: u8) -> u8 { + a * 2 +} + +fn bcd(b: bool, a: u8) -> u8 { + if b { + a * 2 + } else { + a * 3 + } +} \ No newline at end of file diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 0000000000000..bf867e0ae5b6c --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +nightly diff --git a/src/base.rs b/src/base.rs new file mode 100644 index 0000000000000..e8356d89f79f7 --- /dev/null +++ b/src/base.rs @@ -0,0 +1,349 @@ +use syntax::ast::{IntTy, UintTy}; +use rustc_mir::monomorphize::MonoItem; + +use cretonne::prelude::*; +use cretonne::codegen::ir::{ + ExternalName, + function::Function, +}; + +use std::any::Any; +use std::collections::HashMap; + +use prelude::*; + +pub struct Translated { + f: Function, +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +struct Variable(Local); + +impl EntityRef for Variable { + fn new(u: usize) -> Self { + Variable(Local::new(u)) + } + + fn index(self) -> usize { + self.0.index() + } +} + +enum CValue { + ByRef(Value), + ByVal(Value), +} + +impl CValue { + fn force_stack<'a, 'tcx: 'a>(self, ccx: &mut CodegenCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Value { + match self { + CValue::ByRef(value) => value, + CValue::ByVal(value) => { + let layout = ccx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let stack_slot = ccx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + ccx.bcx.ins().stack_store(value, stack_slot, 0); + ccx.bcx.ins().stack_addr(types::I64, stack_slot, 0) + } + } + } + + fn load_value<'a, 'tcx: 'a>(self, ccx: &mut CodegenCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Value { + match self { + CValue::ByRef(value) => { + let cton_ty = cton_type_from_ty(ty); + ccx.bcx.ins().load(cton_ty, MemFlags::new(), value, 0) + } + CValue::ByVal(value) => value, + } + } +} + +pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { + let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); + let metadata = tcx.encode_metadata(&link_meta); + + let mut translated_mono_items = Vec::new(); + + for mono_item in + collector::collect_crate_mono_items( + tcx, + collector::MonoItemCollectionMode::Eager + ).0 { + match mono_item { + MonoItem::Fn(Instance { + def: InstanceDef::Item(def_id), + substs, + }) => { + let sig = tcx.fn_sig(def_id); + let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); + let mut f = Function::with_name_signature(ext_name_from_did(def_id), cton_sig_from_fn_sig(sig.skip_binder())); + + trans_fn(tcx, &mut f, def_id, substs); + + let mut mir = ::std::io::Cursor::new(Vec::new()); + ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); + let mut cton = String::new(); + ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); + tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton)); + + translated_mono_items.push(Translated { + f, + }); + } + _ => {} + } + } + + Box::new(::OngoingCodegen { + metadata: metadata, + translated_mono_items, + crate_name: tcx.crate_name(LOCAL_CRATE), + }) +} + +struct CodegenCtxt<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + bcx: FunctionBuilder<'a, Variable>, + mir: &'tcx Mir<'tcx>, + ebb_map: HashMap, + args_map: HashMap, +} + +impl<'f, 'tcx> CodegenCtxt<'f, 'tcx> { + fn get_ebb(&self, bb: BasicBlock) -> Ebb { + *self.ebb_map.get(&bb).unwrap() + } + + fn get_local(&mut self, local: Local) -> Value { + match self.mir.local_kind(local) { + LocalKind::Arg => *self.args_map.get(&local).unwrap(), + LocalKind::ReturnPointer => *self.args_map.get(&RETURN_PLACE).unwrap(), + LocalKind::Temp | LocalKind::Var => self.bcx.use_var(Variable(local)), + } + } +} + +fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: DefId, substs: &Substs) { + let mir = tcx.optimized_mir(def_id); + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); + + let start_ebb = bcx.create_ebb(); + bcx.switch_to_block(start_ebb); + let mut ebb_map: HashMap = HashMap::new(); + for (bb, _bb_data) in mir.basic_blocks().iter_enumerated() { + ebb_map.insert(bb, bcx.create_ebb()); + } + + let mut args_map: HashMap = HashMap::new(); + for arg in Some(RETURN_PLACE).into_iter().chain(mir.args_iter()) { + let ty = types::I64; + args_map.insert(arg, bcx.append_ebb_param(start_ebb, ty)); + } + + for local in mir.vars_and_temps_iter() { + let layout = tcx.layout_of(ParamEnv::reveal_all().and(mir.local_decls[local].ty)).unwrap(); + let stack_slot = bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let ty = types::I64; + bcx.declare_var(Variable(local), ty); + let val = bcx.ins().stack_addr(ty, stack_slot, 0); + bcx.def_var(Variable(local), val); + } + bcx.ins().jump(*ebb_map.get(&START_BLOCK).unwrap(), &[]); + + let mut ccx = CodegenCtxt { + tcx, + bcx, + mir, + ebb_map, + args_map, + }; + let ccx = &mut ccx; + + for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { + let ebb = ccx.get_ebb(bb); + ccx.bcx.switch_to_block(ebb); + + for stmt in &bb_data.statements { + trans_stmt(ccx, stmt); + } + + match &bb_data.terminator().kind { + TerminatorKind::Goto { target } => { + let ebb = ccx.get_ebb(*target); + ccx.bcx.ins().jump(ebb, &[]); + } + TerminatorKind::Return => { + ccx.bcx.ins().return_(&[]); + } + TerminatorKind::Assert { cond, expected, msg, target, cleanup } => { + let cond_ty = cond.ty(&ccx.mir.local_decls, ccx.tcx); + let cond = trans_operand(ccx, cond).load_value(ccx, cond_ty); + let target = ccx.get_ebb(*target); + if *expected { + ccx.bcx.ins().brz(cond, target, &[]); + } else { + ccx.bcx.ins().brnz(cond, target, &[]); + } + ccx.bcx.ins().trap(TrapCode::User(!0)); + } + + TerminatorKind::SwitchInt { discr, switch_ty, values, targets } => { + let discr_ty = discr.ty(&ccx.mir.local_decls, ccx.tcx); + let discr = trans_operand(ccx, discr).load_value(ccx, discr_ty); + let mut jt_data = JumpTableData::new(); + for (i, value) in values.iter().enumerate() { + let ebb = ccx.get_ebb(targets[i]); + jt_data.set_entry(*value as usize, ebb); + } + let mut jump_table = ccx.bcx.create_jump_table(jt_data); + ccx.bcx.ins().br_table(discr, jump_table); + let otherwise_ebb = ccx.get_ebb(targets[targets.len() - 1]); + ccx.bcx.ins().jump(otherwise_ebb, &[]); + } + _ => { + unimplemented!(); + } + } + } + + ccx.bcx.seal_all_blocks(); + ccx.bcx.finalize(); +} + +fn trans_stmt<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, stmt: &Statement<'tcx>) { + match &stmt.kind { + StatementKind::Assign(place, rval) => { + let ty = place.ty(&ccx.mir.local_decls, ccx.tcx); + let lval = trans_place(ccx, place); + let rval = trans_rval(ccx, rval); + do_memcpy(ccx, lval, ty); + } + StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => {} + _ => unimplemented!("stmt {:?}", stmt), + } +} + +fn trans_place<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, place: &Place<'tcx>) -> Value { + match place { + Place::Local(local) => ccx.get_local(*local), + Place::Projection(projection) => { + let base = trans_place(ccx, &projection.base); + match projection.elem { + ProjectionElem::Field(field, ty) => { + let layout = ccx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + ccx.bcx.ins().iconst(types::I64, 0) // unimplemented ===================================================== + } + _ => unimplemented!("projection {:?}", projection), + } + } + place => unimplemented!("place {:?}", place), + } +} + +fn trans_rval<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, rval: &Rvalue<'tcx>) -> Value { + match rval { + Rvalue::Use(operand) => { + let operand_ty = operand.ty(&ccx.mir.local_decls, ccx.tcx); + trans_operand(ccx, operand).force_stack(ccx, operand_ty) + }, + Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { + match bin_op { + BinOp::Mul => { + let ty = lhs.ty(&ccx.mir.local_decls, ccx.tcx); + let lhs_ty = lhs.ty(&ccx.mir.local_decls, ccx.tcx); + let lhs = trans_operand(ccx, lhs).load_value(ccx, lhs_ty); + let rhs_ty = rhs.ty(&ccx.mir.local_decls, ccx.tcx); + let rhs = trans_operand(ccx, rhs).load_value(ccx, rhs_ty); + match ty.sty { + TypeVariants::TyUint(_) => { + ccx.bcx.ins().imul(lhs, rhs) + } + _ => unimplemented!(), + } + } + bin_op => unimplemented!("checked bin op {:?} {:?} {:?}", bin_op, lhs, rhs), + } + } + rval => unimplemented!("{:?}", rval), + } +} + +fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue { + match operand { + Operand::Move(place) => CValue::ByRef(trans_place(ccx, place)), + Operand::Constant(const_) => { + match const_.literal { + Literal::Value { value } => { + let layout = ccx.tcx.layout_of(ParamEnv::empty().and(const_.ty)).unwrap(); + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + match const_.ty.sty { + TypeVariants::TyUint(_) => { + let iconst = ccx.bcx.ins().iconst(cton_type_from_ty(const_.ty), bits as u64 as i64); + CValue::ByVal(iconst) + } + _ => unimplemented!(), + } + } + _ => unimplemented!() + } + } + operand => unimplemented!("operand {:?}", operand), + } +} + +fn ext_name_from_did(def_id: DefId) -> ExternalName { + ExternalName::user(def_id.krate.as_u32(), def_id.index.as_raw_u32()) +} + +fn cton_sig_from_fn_sig(sig: &FnSig) -> Signature { + let inputs = sig.inputs(); + let output = sig.output(); + assert!(!sig.variadic, "Variadic function are not yet supported"); + let call_conv = match sig.abi { + _ => CallConv::SystemV, + }; + Signature { + params: Some(types::I64).into_iter() // First param is palce to put return val + .chain(inputs.into_iter().map(|_| types::I64)) + .map(AbiParam::new).collect(), + returns: vec![], + call_conv, + argument_bytes: None, + } +} + +fn cton_type_from_ty(ty: Ty) -> types::Type { + match ty.sty { + TypeVariants::TyBool => types::B1, + TypeVariants::TyUint(size) => { + match size { + UintTy::U8 => types::I8, + UintTy::U16 => types::I16, + UintTy::U32 => types::I32, + UintTy::U64 => types::I64, + UintTy::U128 => unimplemented!(), + UintTy::Usize => unimplemented!(), + } + } + TypeVariants::TyInt(size) => { + match size { + IntTy::I8 => types::I8, + IntTy::I16 => types::I16, + IntTy::I32 => types::I32, + IntTy::I64 => types::I64, + IntTy::I128 => unimplemented!(), + IntTy::Isize => unimplemented!(), + } + } + _ => unimplemented!("Cton type from {:?}", ty), + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000000000..5389c0b9ec997 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,176 @@ +#![feature(rustc_private)] + +extern crate syntax; +extern crate rustc; +extern crate rustc_mir; +extern crate rustc_codegen_utils; +extern crate rustc_incremental; +extern crate rustc_data_structures; + +extern crate cretonne; + +use syntax::symbol::Symbol; +use rustc::session::{ + CompileIncomplete, + config::{ + CrateType, + OutputFilenames, + }, +}; +use rustc::middle::cstore::{MetadataLoader, EncodedMetadata}; +use rustc::dep_graph::DepGraph; +use rustc::ty::maps::Providers; +use rustc_codegen_utils::codegen_backend::{CodegenBackend, NoLlvmMetadataLoader}; +use rustc_codegen_utils::link::{out_filename, build_link_meta}; + +use std::any::Any; +use std::sync::{mpsc, Arc}; +use std::fs::File; +use std::io::Write; + +mod base; + +mod prelude { + pub use rustc::session::Session; + pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; + pub use rustc::ty::{TyCtxt, Ty, TypeVariants, Instance, InstanceDef, ParamEnv, FnSig, subst::Substs}; + pub use rustc::mir::*; + pub use rustc_mir::monomorphize::collector; + pub use rustc_data_structures::{ + sync::Lrc, + indexed_vec::Idx, + }; +} + +use prelude::*; + +struct CretonneCodegenBackend(()); + +struct OngoingCodegen { + metadata: EncodedMetadata, + translated_mono_items: Vec, + crate_name: Symbol, +} + +impl CretonneCodegenBackend { + fn new() -> Box { + Box::new(CretonneCodegenBackend(())) + } +} + +impl CodegenBackend for CretonneCodegenBackend { + fn init(&self, sess: &Session) { + for cty in sess.opts.crate_types.iter() { + match *cty { + CrateType::CrateTypeRlib | CrateType::CrateTypeDylib | + CrateType::CrateTypeExecutable => {}, + _ => { + sess.parse_sess.span_diagnostic.warn( + &format!("LLVM unsupported, so output type {} is not supported", cty) + ); + }, + } + } + } + + fn metadata_loader(&self) -> Box { + Box::new(NoLlvmMetadataLoader) + } + + fn provide(&self, providers: &mut Providers) { + rustc_codegen_utils::symbol_names::provide(providers); + + providers.target_features_whitelist = |_tcx, _cnum| { + /*Lrc::new(rustc_codegen_utils::llvm_target_features::all_known_features() + .map(|(a, b)| (a.to_string(), b.map(|s| s.to_string()))) + .collect())*/ + Lrc::new(Default::default()) + }; + providers.is_reachable_non_generic = |_tcx, _defid| true; + providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); + providers.wasm_custom_sections = |_tcx, _crate| Lrc::new(Vec::new()); + } + fn provide_extern(&self, providers: &mut Providers) { + providers.is_reachable_non_generic = |_tcx, _defid| true; + } + + fn codegen_crate<'a, 'tcx>( + &self, + tcx: TyCtxt<'a, 'tcx, 'tcx>, + _rx: mpsc::Receiver> + ) -> Box { + use rustc_mir::monomorphize::item::MonoItem; + + rustc_codegen_utils::check_for_rustc_errors_attr(tcx); + rustc_codegen_utils::symbol_names_test::report_symbol_names(tcx); + rustc_incremental::assert_dep_graph(tcx); + rustc_incremental::assert_module_sources::assert_module_sources(tcx); + rustc_mir::monomorphize::assert_symbols_are_distinct(tcx, + collector::collect_crate_mono_items( + tcx, + collector::MonoItemCollectionMode::Eager + ).0.iter() + ); + //::rustc::middle::dependency_format::calculate(tcx); + let _ = tcx.link_args(LOCAL_CRATE); + let _ = tcx.native_libraries(LOCAL_CRATE); + for mono_item in + collector::collect_crate_mono_items( + tcx, + collector::MonoItemCollectionMode::Eager + ).0 { + match mono_item { + MonoItem::Fn(inst) => { + let def_id = inst.def_id(); + if def_id.is_local() { + let _ = inst.def.is_inline(tcx); + let _ = tcx.codegen_fn_attrs(def_id); + } + } + _ => {} + } + } + tcx.sess.abort_if_errors(); + + base::trans_crate(tcx) + } + + fn join_codegen_and_link( + &self, + ongoing_codegen: Box, + sess: &Session, + _dep_graph: &DepGraph, + outputs: &OutputFilenames, + ) -> Result<(), CompileIncomplete> { + if true { + unimplemented!(); + } + + let ongoing_codegen = ongoing_codegen.downcast::() + .expect("Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box"); + for &crate_type in sess.opts.crate_types.iter() { + if crate_type != CrateType::CrateTypeRlib && crate_type != CrateType::CrateTypeDylib { + continue; + } + let output_name = + out_filename(sess, crate_type, &outputs, &ongoing_codegen.crate_name.as_str()); + let metadata = &ongoing_codegen.metadata.raw_data; + let mut file = File::create(&output_name).unwrap(); + file.write_all(metadata).unwrap(); + } + + sess.abort_if_errors(); + if !sess.opts.crate_types.contains(&CrateType::CrateTypeRlib) + && !sess.opts.crate_types.contains(&CrateType::CrateTypeDylib) + { + sess.fatal("Executables are not supported by the metadata-only backend."); + } + Ok(()) + } +} + +/// This is the entrypoint for a hot plugged rustc_codegen_cretonne +#[no_mangle] +pub fn __rustc_codegen_backend() -> Box { + CretonneCodegenBackend::new() +} \ No newline at end of file From 653c67cb6dc03478fad581ed7b55ea58ab2d13a3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 17 Jun 2018 18:46:11 +0200 Subject: [PATCH 0002/1566] Use verifier, perform assignment and field projection, fix branching --- build.sh | 2 +- src/base.rs | 39 +++++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/build.sh b/build.sh index 5193ef20a1158..548bd7368f3bb 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ cargo build || exit 1 -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.dylib example.rs --crate-type lib +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.so example.rs --crate-type lib diff --git a/src/base.rs b/src/base.rs index e8356d89f79f7..ecee0aa31d0f7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -54,7 +54,7 @@ impl CValue { fn load_value<'a, 'tcx: 'a>(self, ccx: &mut CodegenCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Value { match self { CValue::ByRef(value) => { - let cton_ty = cton_type_from_ty(ty); + let cton_ty = cton_type_from_ty(ty).unwrap(); ccx.bcx.ins().load(cton_ty, MemFlags::new(), value, 0) } CValue::ByVal(value) => value, @@ -84,11 +84,16 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { trans_fn(tcx, &mut f, def_id, substs); + let flags = settings::Flags::new(settings::builder()); + let verify_error: String = ::cretonne::codegen::verify_function(&f, &flags) + .map(|_| String::new()) + .unwrap_or_else(|err| format!("\n\ncretonne error: {}", err)); + let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); let mut cton = String::new(); ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton)); + tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton, verify_error)); translated_mono_items.push(Translated { f, @@ -222,10 +227,10 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: fn trans_stmt<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, stmt: &Statement<'tcx>) { match &stmt.kind { StatementKind::Assign(place, rval) => { - let ty = place.ty(&ccx.mir.local_decls, ccx.tcx); + let ty = place.ty(&ccx.mir.local_decls, ccx.tcx).to_ty(ccx.tcx); let lval = trans_place(ccx, place); let rval = trans_rval(ccx, rval); - do_memcpy(ccx, lval, ty); + do_memcpy(ccx, lval, rval, ty); } StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => {} _ => unimplemented!("stmt {:?}", stmt), @@ -240,7 +245,9 @@ fn trans_place<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, place: &Place<'tcx match projection.elem { ProjectionElem::Field(field, ty) => { let layout = ccx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); - ccx.bcx.ins().iconst(types::I64, 0) // unimplemented ===================================================== + let field_offset = layout.fields.offset(field.index()); + let field_offset = ccx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); + ccx.bcx.ins().iadd(base, field_offset) } _ => unimplemented!("projection {:?}", projection), } @@ -287,7 +294,7 @@ fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'t let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); match const_.ty.sty { TypeVariants::TyUint(_) => { - let iconst = ccx.bcx.ins().iconst(cton_type_from_ty(const_.ty), bits as u64 as i64); + let iconst = ccx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as u64 as i64); CValue::ByVal(iconst) } _ => unimplemented!(), @@ -300,6 +307,14 @@ fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'t } } +fn do_memcpy<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, to: Value, from: Value, ty: Ty<'tcx>) { + let layout = ccx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + for i in 0..(layout.size.bytes() as i32) { + let byte = ccx.bcx.ins().load_complex(types::I8, MemFlags::new(), &[from], i); + ccx.bcx.ins().store_complex(MemFlags::new(), byte, &[to], i); + } +} + fn ext_name_from_did(def_id: DefId) -> ExternalName { ExternalName::user(def_id.krate.as_u32(), def_id.index.as_raw_u32()) } @@ -321,9 +336,9 @@ fn cton_sig_from_fn_sig(sig: &FnSig) -> Signature { } } -fn cton_type_from_ty(ty: Ty) -> types::Type { - match ty.sty { - TypeVariants::TyBool => types::B1, +fn cton_type_from_ty(ty: Ty) -> Option { + Some(match ty.sty { + TypeVariants::TyBool => types::I8, TypeVariants::TyUint(size) => { match size { UintTy::U8 => types::I8, @@ -344,6 +359,6 @@ fn cton_type_from_ty(ty: Ty) -> types::Type { IntTy::Isize => unimplemented!(), } } - _ => unimplemented!("Cton type from {:?}", ty), - } -} \ No newline at end of file + _ => return None, + }) +} From 7680a5cdde552c8353bff1ee6e1e08f4ea68afdd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 17 Jun 2018 19:10:00 +0200 Subject: [PATCH 0003/1566] Implement direct calls --- example.rs | 8 +++++-- src/base.rs | 67 +++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/example.rs b/example.rs index 0962f15063537..484b97b6c186e 100644 --- a/example.rs +++ b/example.rs @@ -35,10 +35,14 @@ fn abc(a: u8) -> u8 { a * 2 } -fn bcd(b: bool, a: u8) -> u8 { +/*fn bcd(b: bool, a: u8) -> u8 { if b { a * 2 } else { a * 3 } -} \ No newline at end of file +}*/ + +fn call() { + abc(42); +} diff --git a/src/base.rs b/src/base.rs index ecee0aa31d0f7..03f900318cbfb 100644 --- a/src/base.rs +++ b/src/base.rs @@ -4,6 +4,7 @@ use rustc_mir::monomorphize::MonoItem; use cretonne::prelude::*; use cretonne::codegen::ir::{ ExternalName, + FuncRef, function::Function, }; @@ -32,6 +33,7 @@ impl EntityRef for Variable { enum CValue { ByRef(Value), ByVal(Value), + Func(FuncRef), } impl CValue { @@ -48,6 +50,10 @@ impl CValue { ccx.bcx.ins().stack_store(value, stack_slot, 0); ccx.bcx.ins().stack_addr(types::I64, stack_slot, 0) } + CValue::Func(func) => { + let func = ccx.bcx.ins().func_addr(types::I64, func); + CValue::ByVal(func).force_stack(ccx, ty) + } } } @@ -58,6 +64,9 @@ impl CValue { ccx.bcx.ins().load(cton_ty, MemFlags::new(), value, 0) } CValue::ByVal(value) => value, + CValue::Func(func) => { + ccx.bcx.ins().func_addr(types::I64, func) + } } } } @@ -189,7 +198,7 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: TerminatorKind::Return => { ccx.bcx.ins().return_(&[]); } - TerminatorKind::Assert { cond, expected, msg, target, cleanup } => { + TerminatorKind::Assert { cond, expected, msg, target, cleanup: _ } => { let cond_ty = cond.ty(&ccx.mir.local_decls, ccx.tcx); let cond = trans_operand(ccx, cond).load_value(ccx, cond_ty); let target = ccx.get_ebb(*target); @@ -214,9 +223,41 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: let otherwise_ebb = ccx.get_ebb(targets[targets.len() - 1]); ccx.bcx.ins().jump(otherwise_ebb, &[]); } - _ => { - unimplemented!(); + TerminatorKind::Call { func, args, destination, cleanup: _ } => { + let func = trans_operand(ccx, func); + let return_place = if let Some((place, _)) = destination { + trans_place(ccx, place) + } else { + ccx.bcx.ins().iconst(types::I64, 0) + }; + let args = Some(return_place) + .into_iter() + .chain( + args + .into_iter() + .map(|arg| { + let ty = arg.ty(&ccx.mir.local_decls, ccx.tcx); + let arg = trans_operand(ccx, arg); + arg.force_stack(ccx, ty) + }) + ).collect::>(); + match func { + CValue::Func(func) => { + ccx.bcx.ins().call(func, &args); + } + _ => unimplemented!("indirect call"), + } + if let Some((_, dest)) = *destination { + let ret_ebb = ccx.get_ebb(dest); + ccx.bcx.ins().jump(ret_ebb, &[]); + } else { + ccx.bcx.ins().trap(TrapCode::User(!0)); + } } + TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { + ccx.bcx.ins().trap(TrapCode::User(!0)); + } + terminator => unimplemented!("terminator {:?}", terminator), } } @@ -291,13 +332,29 @@ fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'t match const_.literal { Literal::Value { value } => { let layout = ccx.tcx.layout_of(ParamEnv::empty().and(const_.ty)).unwrap(); - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); match const_.ty.sty { TypeVariants::TyUint(_) => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); let iconst = ccx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as u64 as i64); CValue::ByVal(iconst) } - _ => unimplemented!(), + TypeVariants::TyInt(_) => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + let iconst = ccx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as i128 as i64); + CValue::ByVal(iconst) + } + TypeVariants::TyFnDef(def_id, substs) => { + let ext_name = ext_name_from_did(def_id); + let sig = ccx.tcx.fn_sig(def_id); + let sig = ccx.tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); + let sig = ccx.bcx.import_signature(cton_sig_from_fn_sig(sig.skip_binder())); + CValue::Func(ccx.bcx.import_function(ExtFuncData { + name: ext_name, + signature: sig, + colocated: false, + })) + } + _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), } } _ => unimplemented!() From 9f4f9eb1d79da33a1d3b767dbf40b2b26c5a6f00 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Jun 2018 18:39:07 +0200 Subject: [PATCH 0004/1566] Implement indirect calls --- example.rs | 5 +++++ src/base.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++--------- src/lib.rs | 3 ++- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/example.rs b/example.rs index 484b97b6c186e..b826470971991 100644 --- a/example.rs +++ b/example.rs @@ -46,3 +46,8 @@ fn abc(a: u8) -> u8 { fn call() { abc(42); } + +fn indirect_call() { + let f: fn() = call; + f(); +} diff --git a/src/base.rs b/src/base.rs index 03f900318cbfb..e68af8f43b4b2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -141,7 +141,7 @@ impl<'f, 'tcx> CodegenCtxt<'f, 'tcx> { } } -fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: DefId, substs: &Substs) { +fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: DefId, substs: &Substs<'tcx>) { let mir = tcx.optimized_mir(def_id); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -198,7 +198,7 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: TerminatorKind::Return => { ccx.bcx.ins().return_(&[]); } - TerminatorKind::Assert { cond, expected, msg, target, cleanup: _ } => { + TerminatorKind::Assert { cond, expected, msg: _, target, cleanup: _ } => { let cond_ty = cond.ty(&ccx.mir.local_decls, ccx.tcx); let cond = trans_operand(ccx, cond).load_value(ccx, cond_ty); let target = ccx.get_ebb(*target); @@ -224,6 +224,7 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: ccx.bcx.ins().jump(otherwise_ebb, &[]); } TerminatorKind::Call { func, args, destination, cleanup: _ } => { + let func_ty = func.ty(&ccx.mir.local_decls, ccx.tcx); let func = trans_operand(ccx, func); let return_place = if let Some((place, _)) = destination { trans_place(ccx, place) @@ -245,7 +246,17 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: CValue::Func(func) => { ccx.bcx.ins().call(func, &args); } - _ => unimplemented!("indirect call"), + func => { + let func = func.load_value(ccx, func_ty); + let sig = match func_ty.sty { + TypeVariants::TyFnDef(def_id, _substs) => ccx.tcx.fn_sig(def_id), + TypeVariants::TyFnPtr(fn_sig) => fn_sig, + _ => bug!("Calling non function type {:?}", func_ty), + }; + let sig = ccx.tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); + let sig = ccx.bcx.import_signature(cton_sig_from_fn_sig(sig.skip_binder())); + ccx.bcx.ins().call_indirect(sig, func, &args); + } } if let Some((_, dest)) = *destination { let ret_ebb = ccx.get_ebb(dest); @@ -257,7 +268,14 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { ccx.bcx.ins().trap(TrapCode::User(!0)); } - terminator => unimplemented!("terminator {:?}", terminator), + TerminatorKind::Yield { .. } | + TerminatorKind::FalseEdges { .. } | + TerminatorKind::FalseUnwind { .. } => { + bug!("shouldn't exist at trans {:?}", bb_data.terminator()); + } + TerminatorKind::Drop { .. } | TerminatorKind::DropAndReplace { .. } | TerminatorKind::GeneratorDrop { .. } => { + unimplemented!("terminator {:?}", bb_data.terminator()); + } } } @@ -321,13 +339,21 @@ fn trans_rval<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, rval: &Rvalue<'tcx> bin_op => unimplemented!("checked bin op {:?} {:?} {:?}", bin_op, lhs, rhs), } } - rval => unimplemented!("{:?}", rval), + Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { + let operand = trans_operand(ccx, operand); + operand.force_stack(ccx, ty) + } + Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { + trans_operand(ccx, operand).force_stack(ccx, ty) + } + rval => unimplemented!("rval {:?}", rval), } } fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue { match operand { - Operand::Move(place) => CValue::ByRef(trans_place(ccx, place)), + Operand::Move(place) | + Operand::Copy(place) => CValue::ByRef(trans_place(ccx, place)), Operand::Constant(const_) => { match const_.literal { Literal::Value { value } => { @@ -366,9 +392,21 @@ fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'t fn do_memcpy<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, to: Value, from: Value, ty: Ty<'tcx>) { let layout = ccx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); - for i in 0..(layout.size.bytes() as i32) { - let byte = ccx.bcx.ins().load_complex(types::I8, MemFlags::new(), &[from], i); - ccx.bcx.ins().store_complex(MemFlags::new(), byte, &[to], i); + let size = layout.size.bytes() as i32; + let ty = match size { + 2 => Some(types::I16), + 4 => Some(types::I32), + 8 => Some(types::I64), + _ => None, + }; + if let Some(ty) = ty { + let data = ccx.bcx.ins().load(ty, MemFlags::new(), from, 0); + ccx.bcx.ins().store(MemFlags::new(), data, to, 0); + } else { + for i in 0..size { + let byte = ccx.bcx.ins().load(types::I8, MemFlags::new(), from, i); + ccx.bcx.ins().store(MemFlags::new(), byte, to, i); + } } } @@ -416,6 +454,7 @@ fn cton_type_from_ty(ty: Ty) -> Option { IntTy::Isize => unimplemented!(), } } + TypeVariants::TyFnPtr(_) => types::I64, _ => return None, }) } diff --git a/src/lib.rs b/src/lib.rs index 5389c0b9ec997..31ec965c2a38a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![feature(rustc_private)] extern crate syntax; +#[macro_use] extern crate rustc; extern crate rustc_mir; extern crate rustc_codegen_utils; @@ -173,4 +174,4 @@ impl CodegenBackend for CretonneCodegenBackend { #[no_mangle] pub fn __rustc_codegen_backend() -> Box { CretonneCodegenBackend::new() -} \ No newline at end of file +} From 9d40131d81a23acd20df37011c9ba9601876becf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 19 Jun 2018 19:51:29 +0200 Subject: [PATCH 0005/1566] Add cretonne_module --- Cargo.lock | 620 ++++++++++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 5 +- src/base.rs | 322 +++++++++++++++------------ src/lib.rs | 7 +- 4 files changed, 804 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e215ad0343124..ac4d0c22320bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,18 +1,99 @@ [[package]] -name = "cretonne" +name = "aho-corasick" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-frontend 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bitflags" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cc" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "clap" +version = "2.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cretonne" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-frontend 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cretonne-codegen" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-entity 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-entity 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -20,15 +101,63 @@ dependencies = [ [[package]] name = "cretonne-entity" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "cretonne-faerie" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cretonne-frontend" -version = "0.11.0" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cretonne-module" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-entity 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cretonne-native" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cretonne-simplejit" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-native 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -36,11 +165,51 @@ name = "dtoa" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "env_logger" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "errno" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "faerie" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "failure" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -54,21 +223,229 @@ dependencies = [ "synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "goblin" +version = "0.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "goblin" +version = "0.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "humantime" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "indexmap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "itoa" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lazy_static" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.42" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "log" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "mach" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memchr" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quick-error" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "quote" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "raw-cpuid" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "region" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "rustc_codegen_cretonne" version = "0.1.0" dependencies = [ - "cretonne 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cretonne-simplejit 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scroll" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scroll_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scroll" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scroll_derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scroll_derive" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -86,6 +463,38 @@ dependencies = [ "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "string-interner" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "strsim" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "structopt" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "structopt-derive" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syn" version = "0.11.11" @@ -96,6 +505,16 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synom" version = "0.11.3" @@ -123,25 +542,200 @@ dependencies = [ "serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "termcolor" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "textwrap" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ucd-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-width" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "utf8-ranges" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wincolor" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] -"checksum cretonne 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83e1f8d40914cb726d41a49df9554f200b47f36a03c46e5d6044e9dc8a8a47cd" -"checksum cretonne-codegen 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "312ba69a70bebc54789bd0e28414987b5bcd1173263f6afbd0ee8519b84da4ac" -"checksum cretonne-entity 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0be57790fb6db92704951e37981f5e0121e7bfa077c7b48177317bf63795ba4" -"checksum cretonne-frontend 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "14b0fe88b2bc5b71df2ce460761063da21731926e6b554c84d8b937de6640875" +"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" +"checksum backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbdd17cd962b570302f5297aea8648d5923e22e555c2ed2d8b2e34eca646bf6d" +"checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" +"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" +"checksum cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "49ec142f5768efb5b7622aebc3fdbdbb8950a4b9ba996393cb76ef7466e8747d" +"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" +"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536" +"checksum cretonne 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03610d69c786a211347d0be3f7da59cb03b025ef2cd83f66ea98103728f42ecc" +"checksum cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e7e43ab7952e998ea8da4bcda3b53d398396b9b691df44a040be5486a4935ef" +"checksum cretonne-entity 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4109dcfc0c7b8e11ad92a702d3f5df435d2782012118aa75566d2d0db586da3a" +"checksum cretonne-faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e8d665b4ac93c254f79e861696db5a1297133c8c8603e5cd06b26250568a9cb0" +"checksum cretonne-frontend 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e0238865d537393f73598542a906dadfe85fcf070c293cdf882ece170d197455" +"checksum cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "232354804f19cb12bf2ac6f715d26df81a7242b3693a1a6cd2774ff89311e283" +"checksum cretonne-native 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66d768de850f29bbb2cda9eeed168369c66263bee9068ca1b9af28000216116c" +"checksum cretonne-simplejit 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54d9e73a7f5bb0529be747a86a164e087c96edfd89e30b6d6f92653b70fc9943" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" +"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" +"checksum errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c858c42ac0b88532f48fca88b0ed947cad4f1f64d904bcd6c9f138f7b95d70" +"checksum faerie 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ffaaaa682748ec082a384edbf1d468ce10ad1b39dcfa3a8c3c0dbc5e6cff754c" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" +"checksum goblin 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2a5fea7ad351be7398e08003ea92a16bbba9a23c2a0c95d4e37d178276508217" +"checksum goblin 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "5e3ba9fec4dc9a09553388bff2724d3bf06bd64013539f2d3e1e3838eefb310a" +"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" +"checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" "checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" +"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" +"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" +"checksum log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fddaa003a65722a7fb9e26b0ce95921fe4ba590542ced664d8ce2fa26f9f3ac" +"checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" +"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" +"checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +"checksum proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "effdb53b25cdad54f8f48843d67398f7ef2e14f12c1b4cb4effc549a6462a4d6" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" +"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" +"checksum raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "233ec1847057cf4d4591a0d76908aa12812140b11ea7d7d05b4c38cadb069c31" +"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3" +"checksum regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05b06a75f5217880fc5e905952a42750bf44787e56a6c6d6852ed0992f5e1d54" +"checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" +"checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" +"checksum scroll 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b13864e1e0b3ed661d7206d512b8d1c4970f7fd9de23ae4e9b4331f0c25559e8" +"checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" +"checksum scroll_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a67086db2a44e94311fc4c02ec3f4751bda0fca9d87fd4e1bfe1cef55e9411d" +"checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" "checksum serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a2d9a9ac5120e0f768801ca2b58ad6eec929dc9d1d616c162f208869c2ce95" "checksum serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "fc97cccc2959f39984524026d760c08ef0dd5f0f5948c8d31797dbfae458c875" +"checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" +"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +"checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" +"checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +"checksum syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c67da57e61ebc7b7b6fff56bb34440ca3a83db037320b0507af4c10368deda7d" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" "checksum target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71b0a95ba4eff593189d912039fba46ce6ca1876ea6c16830e15340919d0a250" +"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" +"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" +"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" +"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" diff --git a/Cargo.toml b/Cargo.toml index 72859b0d7ccf4..d1acda9c43032 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,7 @@ authors = ["bjorn3 "] crate-type = ["dylib"] [dependencies] -cretonne = "0.11.0" +cretonne = "0.12.0" +cretonne-module = "0.12.0" +cretonne-simplejit = "0.12.0" +cretonne-faerie = "0.12.0" diff --git a/src/base.rs b/src/base.rs index e68af8f43b4b2..fd5629c8be12e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -2,24 +2,26 @@ use syntax::ast::{IntTy, UintTy}; use rustc_mir::monomorphize::MonoItem; use cretonne::prelude::*; +//use cretonne::codegen::Context; use cretonne::codegen::ir::{ ExternalName, FuncRef, function::Function, }; +use cretonne_module::{Module, Backend, FuncId, Linkage}; +use cretonne_simplejit::{SimpleJITBuilder, SimpleJITBackend}; + use std::any::Any; use std::collections::HashMap; use prelude::*; -pub struct Translated { - f: Function, -} - #[derive(Debug, Copy, Clone, Eq, PartialEq)] struct Variable(Local); +type CurrentBackend = SimpleJITBackend; + impl EntityRef for Variable { fn new(u: usize) -> Self { Variable(Local::new(u)) @@ -37,35 +39,35 @@ enum CValue { } impl CValue { - fn force_stack<'a, 'tcx: 'a>(self, ccx: &mut CodegenCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Value { + fn force_stack<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { match self { CValue::ByRef(value) => value, CValue::ByVal(value) => { - let layout = ccx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); - let stack_slot = ccx.bcx.create_stack_slot(StackSlotData { + let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, offset: None, }); - ccx.bcx.ins().stack_store(value, stack_slot, 0); - ccx.bcx.ins().stack_addr(types::I64, stack_slot, 0) + fx.bcx.ins().stack_store(value, stack_slot, 0); + fx.bcx.ins().stack_addr(types::I64, stack_slot, 0) } CValue::Func(func) => { - let func = ccx.bcx.ins().func_addr(types::I64, func); - CValue::ByVal(func).force_stack(ccx, ty) + let func = fx.bcx.ins().func_addr(types::I64, func); + CValue::ByVal(func).force_stack(fx, ty) } } } - fn load_value<'a, 'tcx: 'a>(self, ccx: &mut CodegenCtxt<'a, 'tcx>, ty: Ty<'tcx>) -> Value { + fn load_value<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { match self { CValue::ByRef(value) => { let cton_ty = cton_type_from_ty(ty).unwrap(); - ccx.bcx.ins().load(cton_ty, MemFlags::new(), value, 0) + fx.bcx.ins().load(cton_ty, MemFlags::new(), value, 0) } CValue::ByVal(value) => value, CValue::Func(func) => { - ccx.bcx.ins().func_addr(types::I64, func) + fx.bcx.ins().func_addr(types::I64, func) } } } @@ -75,7 +77,15 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); let metadata = tcx.encode_metadata(&link_meta); - let mut translated_mono_items = Vec::new(); + let module: Module = Module::new(SimpleJITBuilder::new()); + //let mut context = Context::new(); + + let mut cx = CodegenCx { + tcx, + module, + def_id_fn_id_map: HashMap::new(), + }; + let cx = &mut cx; for mono_item in collector::collect_crate_mono_items( @@ -83,51 +93,72 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { collector::MonoItemCollectionMode::Eager ).0 { match mono_item { - MonoItem::Fn(Instance { - def: InstanceDef::Item(def_id), - substs, - }) => { - let sig = tcx.fn_sig(def_id); - let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); - let mut f = Function::with_name_signature(ext_name_from_did(def_id), cton_sig_from_fn_sig(sig.skip_binder())); - - trans_fn(tcx, &mut f, def_id, substs); - - let flags = settings::Flags::new(settings::builder()); - let verify_error: String = ::cretonne::codegen::verify_function(&f, &flags) - .map(|_| String::new()) - .unwrap_or_else(|err| format!("\n\ncretonne error: {}", err)); - - let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); - let mut cton = String::new(); - ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton, verify_error)); - - translated_mono_items.push(Translated { - f, - }); + MonoItem::Fn(inst) => match inst { + Instance { + def: InstanceDef::Item(def_id), + substs, + } => { + let sig = tcx.fn_sig(def_id); + let sig = cton_sig_from_fn_sig(tcx, sig, substs); + let func_id = { + let module = &mut cx.module; + *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { + module.declare_function(&tcx.absolute_item_path_str(def_id), Linkage::Local, &sig).unwrap() + }) + }; + + let mut f = Function::with_name_signature(ext_name_from_did(def_id), sig); + + trans_fn(cx, &mut f, def_id, substs); + + let flags = settings::Flags::new(settings::builder()); + let verify_error: String = ::cretonne::codegen::verify_function(&f, &flags) + .map(|_| String::new()) + .unwrap_or_else(|err| format!("\n\ncretonne error: {}", err)); + + let mut mir = ::std::io::Cursor::new(Vec::new()); + ::rustc_mir::util::write_mir_pretty(cx.tcx, Some(def_id), &mut mir).unwrap(); + let mut cton = String::new(); + ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); + tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton, verify_error)); + + //context.func = f; + //cx.module.define_function(func_id, &mut context).unwrap(); + //context.clear(); + } + _ => {} } _ => {} } } + //cx.module.finalize_all(); + //cx.module.finish(); + Box::new(::OngoingCodegen { metadata: metadata, - translated_mono_items, + //translated_module: Module::new(::cretonne_faerie::FaerieBuilder::new(, crate_name: tcx.crate_name(LOCAL_CRATE), }) } -struct CodegenCtxt<'a, 'tcx: 'a> { +struct CodegenCx<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: Module, + def_id_fn_id_map: HashMap, FuncId>, +} + +struct FunctionCx<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &'a mut Module, + def_id_fn_id_map: &'a mut HashMap, FuncId>, bcx: FunctionBuilder<'a, Variable>, mir: &'tcx Mir<'tcx>, ebb_map: HashMap, args_map: HashMap, } -impl<'f, 'tcx> CodegenCtxt<'f, 'tcx> { +impl<'f, 'tcx> FunctionCx<'f, 'tcx> { fn get_ebb(&self, bb: BasicBlock) -> Ebb { *self.ebb_map.get(&bb).unwrap() } @@ -139,10 +170,20 @@ impl<'f, 'tcx> CodegenCtxt<'f, 'tcx> { LocalKind::Temp | LocalKind::Var => self.bcx.use_var(Variable(local)), } } + + fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { + let tcx = self.tcx; + let module = &mut self.module; + let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { + let sig = cton_sig_from_instance(tcx, inst); + module.declare_function(&tcx.absolute_item_path_str(inst.def_id()), Linkage::Local, &sig).unwrap() + }); + module.declare_func_in_func(func_id, &mut self.bcx.func) + } } -fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: DefId, substs: &Substs<'tcx>) { - let mir = tcx.optimized_mir(def_id); +fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, f: &mut Function, def_id: DefId, substs: &Substs<'tcx>) { + let mir = cx.tcx.optimized_mir(def_id); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -160,7 +201,7 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: } for local in mir.vars_and_temps_iter() { - let layout = tcx.layout_of(ParamEnv::reveal_all().and(mir.local_decls[local].ty)).unwrap(); + let layout = cx.tcx.layout_of(ParamEnv::reveal_all().and(mir.local_decls[local].ty)).unwrap(); let stack_slot = bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -173,63 +214,65 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: } bcx.ins().jump(*ebb_map.get(&START_BLOCK).unwrap(), &[]); - let mut ccx = CodegenCtxt { - tcx, + let mut fx = FunctionCx { + tcx: cx.tcx, + module: &mut cx.module, + def_id_fn_id_map: &mut cx.def_id_fn_id_map, bcx, mir, ebb_map, args_map, }; - let ccx = &mut ccx; + let fx = &mut fx; for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { - let ebb = ccx.get_ebb(bb); - ccx.bcx.switch_to_block(ebb); + let ebb = fx.get_ebb(bb); + fx.bcx.switch_to_block(ebb); for stmt in &bb_data.statements { - trans_stmt(ccx, stmt); + trans_stmt(fx, stmt); } match &bb_data.terminator().kind { TerminatorKind::Goto { target } => { - let ebb = ccx.get_ebb(*target); - ccx.bcx.ins().jump(ebb, &[]); + let ebb = fx.get_ebb(*target); + fx.bcx.ins().jump(ebb, &[]); } TerminatorKind::Return => { - ccx.bcx.ins().return_(&[]); + fx.bcx.ins().return_(&[]); } TerminatorKind::Assert { cond, expected, msg: _, target, cleanup: _ } => { - let cond_ty = cond.ty(&ccx.mir.local_decls, ccx.tcx); - let cond = trans_operand(ccx, cond).load_value(ccx, cond_ty); - let target = ccx.get_ebb(*target); + let cond_ty = cond.ty(&fx.mir.local_decls, fx.tcx); + let cond = trans_operand(fx, cond).load_value(fx, cond_ty); + let target = fx.get_ebb(*target); if *expected { - ccx.bcx.ins().brz(cond, target, &[]); + fx.bcx.ins().brz(cond, target, &[]); } else { - ccx.bcx.ins().brnz(cond, target, &[]); + fx.bcx.ins().brnz(cond, target, &[]); } - ccx.bcx.ins().trap(TrapCode::User(!0)); + fx.bcx.ins().trap(TrapCode::User(!0)); } TerminatorKind::SwitchInt { discr, switch_ty, values, targets } => { - let discr_ty = discr.ty(&ccx.mir.local_decls, ccx.tcx); - let discr = trans_operand(ccx, discr).load_value(ccx, discr_ty); + let discr_ty = discr.ty(&fx.mir.local_decls, fx.tcx); + let discr = trans_operand(fx, discr).load_value(fx, discr_ty); let mut jt_data = JumpTableData::new(); for (i, value) in values.iter().enumerate() { - let ebb = ccx.get_ebb(targets[i]); + let ebb = fx.get_ebb(targets[i]); jt_data.set_entry(*value as usize, ebb); } - let mut jump_table = ccx.bcx.create_jump_table(jt_data); - ccx.bcx.ins().br_table(discr, jump_table); - let otherwise_ebb = ccx.get_ebb(targets[targets.len() - 1]); - ccx.bcx.ins().jump(otherwise_ebb, &[]); + let mut jump_table = fx.bcx.create_jump_table(jt_data); + fx.bcx.ins().br_table(discr, jump_table); + let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); + fx.bcx.ins().jump(otherwise_ebb, &[]); } TerminatorKind::Call { func, args, destination, cleanup: _ } => { - let func_ty = func.ty(&ccx.mir.local_decls, ccx.tcx); - let func = trans_operand(ccx, func); + let func_ty = func.ty(&fx.mir.local_decls, fx.tcx); + let func = trans_operand(fx, func); let return_place = if let Some((place, _)) = destination { - trans_place(ccx, place) + trans_place(fx, place) } else { - ccx.bcx.ins().iconst(types::I64, 0) + fx.bcx.ins().iconst(types::I64, 0) }; let args = Some(return_place) .into_iter() @@ -237,36 +280,35 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: args .into_iter() .map(|arg| { - let ty = arg.ty(&ccx.mir.local_decls, ccx.tcx); - let arg = trans_operand(ccx, arg); - arg.force_stack(ccx, ty) + let ty = arg.ty(&fx.mir.local_decls, fx.tcx); + let arg = trans_operand(fx, arg); + arg.force_stack(fx, ty) }) ).collect::>(); match func { CValue::Func(func) => { - ccx.bcx.ins().call(func, &args); + fx.bcx.ins().call(func, &args); } func => { - let func = func.load_value(ccx, func_ty); + let func = func.load_value(fx, func_ty); let sig = match func_ty.sty { - TypeVariants::TyFnDef(def_id, _substs) => ccx.tcx.fn_sig(def_id), + TypeVariants::TyFnDef(def_id, _substs) => fx.tcx.fn_sig(def_id), TypeVariants::TyFnPtr(fn_sig) => fn_sig, _ => bug!("Calling non function type {:?}", func_ty), }; - let sig = ccx.tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); - let sig = ccx.bcx.import_signature(cton_sig_from_fn_sig(sig.skip_binder())); - ccx.bcx.ins().call_indirect(sig, func, &args); + let sig = fx.bcx.import_signature(cton_sig_from_fn_sig(fx.tcx, sig, substs)); + fx.bcx.ins().call_indirect(sig, func, &args); } } if let Some((_, dest)) = *destination { - let ret_ebb = ccx.get_ebb(dest); - ccx.bcx.ins().jump(ret_ebb, &[]); + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); } else { - ccx.bcx.ins().trap(TrapCode::User(!0)); + fx.bcx.ins().trap(TrapCode::User(!0)); } } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { - ccx.bcx.ins().trap(TrapCode::User(!0)); + fx.bcx.ins().trap(TrapCode::User(!0)); } TerminatorKind::Yield { .. } | TerminatorKind::FalseEdges { .. } | @@ -279,34 +321,34 @@ fn trans_fn<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &mut Function, def_id: } } - ccx.bcx.seal_all_blocks(); - ccx.bcx.finalize(); + fx.bcx.seal_all_blocks(); + fx.bcx.finalize(); } -fn trans_stmt<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, stmt: &Statement<'tcx>) { +fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { match &stmt.kind { StatementKind::Assign(place, rval) => { - let ty = place.ty(&ccx.mir.local_decls, ccx.tcx).to_ty(ccx.tcx); - let lval = trans_place(ccx, place); - let rval = trans_rval(ccx, rval); - do_memcpy(ccx, lval, rval, ty); + let ty = place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); + let lval = trans_place(fx, place); + let rval = trans_rval(fx, rval); + do_memcpy(fx, lval, rval, ty); } StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => {} _ => unimplemented!("stmt {:?}", stmt), } } -fn trans_place<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, place: &Place<'tcx>) -> Value { +fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> Value { match place { - Place::Local(local) => ccx.get_local(*local), + Place::Local(local) => fx.get_local(*local), Place::Projection(projection) => { - let base = trans_place(ccx, &projection.base); + let base = trans_place(fx, &projection.base); match projection.elem { ProjectionElem::Field(field, ty) => { - let layout = ccx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); let field_offset = layout.fields.offset(field.index()); - let field_offset = ccx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); - ccx.bcx.ins().iadd(base, field_offset) + let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); + fx.bcx.ins().iadd(base, field_offset) } _ => unimplemented!("projection {:?}", projection), } @@ -315,70 +357,71 @@ fn trans_place<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, place: &Place<'tcx } } -fn trans_rval<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, rval: &Rvalue<'tcx>) -> Value { +fn trans_rval<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, rval: &Rvalue<'tcx>) -> Value { match rval { Rvalue::Use(operand) => { - let operand_ty = operand.ty(&ccx.mir.local_decls, ccx.tcx); - trans_operand(ccx, operand).force_stack(ccx, operand_ty) + let operand_ty = operand.ty(&fx.mir.local_decls, fx.tcx); + trans_operand(fx, operand).force_stack(fx, operand_ty) }, Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { match bin_op { BinOp::Mul => { - let ty = lhs.ty(&ccx.mir.local_decls, ccx.tcx); - let lhs_ty = lhs.ty(&ccx.mir.local_decls, ccx.tcx); - let lhs = trans_operand(ccx, lhs).load_value(ccx, lhs_ty); - let rhs_ty = rhs.ty(&ccx.mir.local_decls, ccx.tcx); - let rhs = trans_operand(ccx, rhs).load_value(ccx, rhs_ty); - match ty.sty { + let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let lhs_ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); + let rhs_ty = rhs.ty(&fx.mir.local_decls, fx.tcx); + let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); + let res = match ty.sty { TypeVariants::TyUint(_) => { - ccx.bcx.ins().imul(lhs, rhs) + fx.bcx.ins().imul(lhs, rhs) } _ => unimplemented!(), - } + }; + let layout = fx.tcx.layout_of(ParamEnv::empty().and(rval.ty(&fx.mir.local_decls, fx.tcx))).unwrap(); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + fx.bcx.ins().stack_store(res, stack_slot, 1); + fx.bcx.ins().stack_addr(types::I64, stack_slot, 1) } bin_op => unimplemented!("checked bin op {:?} {:?} {:?}", bin_op, lhs, rhs), } } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { - let operand = trans_operand(ccx, operand); - operand.force_stack(ccx, ty) + let operand = trans_operand(fx, operand); + operand.force_stack(fx, ty) } Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { - trans_operand(ccx, operand).force_stack(ccx, ty) + trans_operand(fx, operand).force_stack(fx, ty) } rval => unimplemented!("rval {:?}", rval), } } -fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue { +fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue { match operand { Operand::Move(place) | - Operand::Copy(place) => CValue::ByRef(trans_place(ccx, place)), + Operand::Copy(place) => CValue::ByRef(trans_place(fx, place)), Operand::Constant(const_) => { match const_.literal { Literal::Value { value } => { - let layout = ccx.tcx.layout_of(ParamEnv::empty().and(const_.ty)).unwrap(); + let layout = fx.tcx.layout_of(ParamEnv::empty().and(const_.ty)).unwrap(); match const_.ty.sty { TypeVariants::TyUint(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - let iconst = ccx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as u64 as i64); + let iconst = fx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as u64 as i64); CValue::ByVal(iconst) } TypeVariants::TyInt(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - let iconst = ccx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as i128 as i64); + let iconst = fx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as i128 as i64); CValue::ByVal(iconst) } TypeVariants::TyFnDef(def_id, substs) => { - let ext_name = ext_name_from_did(def_id); - let sig = ccx.tcx.fn_sig(def_id); - let sig = ccx.tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); - let sig = ccx.bcx.import_signature(cton_sig_from_fn_sig(sig.skip_binder())); - CValue::Func(ccx.bcx.import_function(ExtFuncData { - name: ext_name, - signature: sig, - colocated: false, - })) + let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); + CValue::Func(func_ref) } _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), } @@ -386,12 +429,11 @@ fn trans_operand<'a, 'tcx>(ccx: &mut CodegenCtxt<'a, 'tcx>, operand: &Operand<'t _ => unimplemented!() } } - operand => unimplemented!("operand {:?}", operand), } } -fn do_memcpy<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, to: Value, from: Value, ty: Ty<'tcx>) { - let layout = ccx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); +fn do_memcpy<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, to: Value, from: Value, ty: Ty<'tcx>) { + let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); let size = layout.size.bytes() as i32; let ty = match size { 2 => Some(types::I16), @@ -400,12 +442,12 @@ fn do_memcpy<'a, 'tcx: 'a>(ccx: &mut CodegenCtxt<'a, 'tcx>, to: Value, from: Val _ => None, }; if let Some(ty) = ty { - let data = ccx.bcx.ins().load(ty, MemFlags::new(), from, 0); - ccx.bcx.ins().store(MemFlags::new(), data, to, 0); + let data = fx.bcx.ins().load(ty, MemFlags::new(), from, 0); + fx.bcx.ins().store(MemFlags::new(), data, to, 0); } else { for i in 0..size { - let byte = ccx.bcx.ins().load(types::I8, MemFlags::new(), from, i); - ccx.bcx.ins().store(MemFlags::new(), byte, to, i); + let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from, i); + fx.bcx.ins().store(MemFlags::new(), byte, to, i); } } } @@ -414,9 +456,21 @@ fn ext_name_from_did(def_id: DefId) -> ExternalName { ExternalName::user(def_id.krate.as_u32(), def_id.index.as_raw_u32()) } -fn cton_sig_from_fn_sig(sig: &FnSig) -> Signature { +fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { + let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); + cton_sig_from_mono_fn_sig(sig) +} + +fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>) -> Signature { + let fn_ty = inst.ty(tcx); + let sig = fn_ty.fn_sig(tcx); + cton_sig_from_mono_fn_sig(sig) +} + +fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signature { + let sig = sig.skip_binder(); let inputs = sig.inputs(); - let output = sig.output(); + let _output = sig.output(); assert!(!sig.variadic, "Variadic function are not yet supported"); let call_conv = match sig.abi { _ => CallConv::SystemV, diff --git a/src/lib.rs b/src/lib.rs index 31ec965c2a38a..a0aec6c311697 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,9 @@ extern crate rustc_incremental; extern crate rustc_data_structures; extern crate cretonne; +extern crate cretonne_module; +extern crate cretonne_simplejit; +extern crate cretonne_faerie; use syntax::symbol::Symbol; use rustc::session::{ @@ -34,7 +37,7 @@ mod base; mod prelude { pub use rustc::session::Session; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; - pub use rustc::ty::{TyCtxt, Ty, TypeVariants, Instance, InstanceDef, ParamEnv, FnSig, subst::Substs}; + pub use rustc::ty::{TyCtxt, Ty, TypeVariants, Instance, InstanceDef, ParamEnv, FnSig, PolyFnSig, subst::Substs}; pub use rustc::mir::*; pub use rustc_mir::monomorphize::collector; pub use rustc_data_structures::{ @@ -49,7 +52,7 @@ struct CretonneCodegenBackend(()); struct OngoingCodegen { metadata: EncodedMetadata, - translated_mono_items: Vec, + //translated_module: Module, crate_name: Symbol, } From 4adba2553bb747cc120307293377d49a8bb9a924 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 20 Jun 2018 15:15:28 +0200 Subject: [PATCH 0006/1566] Use pass by value fro simple simple types --- example.rs | 4 +- src/base.rs | 186 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 130 insertions(+), 60 deletions(-) diff --git a/example.rs b/example.rs index b826470971991..39dbe2cb4115d 100644 --- a/example.rs +++ b/example.rs @@ -35,13 +35,13 @@ fn abc(a: u8) -> u8 { a * 2 } -/*fn bcd(b: bool, a: u8) -> u8 { +fn bcd(b: bool, a: u8) -> u8 { if b { a * 2 } else { a * 3 } -}*/ +} fn call() { abc(42); diff --git a/src/base.rs b/src/base.rs index fd5629c8be12e..dfa6c2beee0b7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -6,6 +6,7 @@ use cretonne::prelude::*; use cretonne::codegen::ir::{ ExternalName, FuncRef, + StackSlot, function::Function, }; @@ -32,6 +33,7 @@ impl EntityRef for Variable { } } +#[derive(Copy, Clone)] enum CValue { ByRef(Value), ByVal(Value), @@ -71,6 +73,36 @@ impl CValue { } } } + + fn expect_byref(self) -> Value { + match self { + CValue::ByRef(value) => value, + CValue::ByVal(_) => unimplemented!("Expected CValue::ByRef, found CValue::ByVal"), + CValue::Func(_) => unimplemented!("Expected CValue::ByRef, found CValue::Func"), + } + } +} + +#[derive(Copy, Clone)] +enum CPlace { + Var(Variable), + Addr(Value), +} + +impl CPlace { + fn to_cvalue<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue { + match self { + CPlace::Var(var) => CValue::ByVal(fx.bcx.use_var(var)), + CPlace::Addr(addr) => CValue::ByRef(addr), + } + } + + fn expect_addr(self) -> Value { + match self { + CPlace::Addr(addr) => addr, + CPlace::Var(_) => unreachable!("Expected CPlace::Addr, found CPlace::Var"), + } + } } pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { @@ -111,16 +143,19 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { trans_fn(cx, &mut f, def_id, substs); - let flags = settings::Flags::new(settings::builder()); - let verify_error: String = ::cretonne::codegen::verify_function(&f, &flags) - .map(|_| String::new()) - .unwrap_or_else(|err| format!("\n\ncretonne error: {}", err)); - let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(cx.tcx, Some(def_id), &mut mir).unwrap(); let mut cton = String::new(); ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton, verify_error)); + tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton)); + + let flags = settings::Flags::new(settings::builder()); + match ::cretonne::codegen::verify_function(&f, &flags) { + Ok(_) => {} + Err(err) => { + tcx.sess.fatal(&format!("cretonne verify error: {}", err)); + } + } //context.func = f; //cx.module.define_function(func_id, &mut context).unwrap(); @@ -135,6 +170,8 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { //cx.module.finalize_all(); //cx.module.finish(); + tcx.sess.fatal("unimplemented"); + Box::new(::OngoingCodegen { metadata: metadata, //translated_module: Module::new(::cretonne_faerie::FaerieBuilder::new(, @@ -155,7 +192,7 @@ struct FunctionCx<'a, 'tcx: 'a> { bcx: FunctionBuilder<'a, Variable>, mir: &'tcx Mir<'tcx>, ebb_map: HashMap, - args_map: HashMap, + local_map: HashMap, } impl<'f, 'tcx> FunctionCx<'f, 'tcx> { @@ -163,12 +200,8 @@ impl<'f, 'tcx> FunctionCx<'f, 'tcx> { *self.ebb_map.get(&bb).unwrap() } - fn get_local(&mut self, local: Local) -> Value { - match self.mir.local_kind(local) { - LocalKind::Arg => *self.args_map.get(&local).unwrap(), - LocalKind::ReturnPointer => *self.args_map.get(&RETURN_PLACE).unwrap(), - LocalKind::Temp | LocalKind::Var => self.bcx.use_var(Variable(local)), - } + fn get_local_place(&mut self, local: Local) -> CPlace { + *self.local_map.get(&local).unwrap() } fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { @@ -194,36 +227,59 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, f: &mut Function, def_id ebb_map.insert(bb, bcx.create_ebb()); } - let mut args_map: HashMap = HashMap::new(); - for arg in Some(RETURN_PLACE).into_iter().chain(mir.args_iter()) { - let ty = types::I64; - args_map.insert(arg, bcx.append_ebb_param(start_ebb, ty)); + let mut fx = FunctionCx { + tcx: cx.tcx, + module: &mut cx.module, + def_id_fn_id_map: &mut cx.def_id_fn_id_map, + bcx, + mir, + ebb_map, + local_map: HashMap::new(), + }; + let fx = &mut fx; + + let ret_param = fx.bcx.append_ebb_param(start_ebb, types::I64); + let _ = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: 0, + offset: None, + }); // Dummy stack slot for debugging + + let func_params = mir.args_iter().map(|local| { + let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(mir.local_decls[local].ty)).unwrap(); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let ty = cton_type_from_ty(mir.local_decls[local].ty); + (local, fx.bcx.append_ebb_param(start_ebb, ty.unwrap_or(types::I64)), ty, stack_slot) + }).collect::, StackSlot)>>(); + + fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param)); + + for (local, ebb_param, ty, stack_slot) in func_params { + let addr = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); + if ty.is_some() { + fx.bcx.ins().stack_store(ebb_param, stack_slot, 0); + } else { + do_memcpy(fx, CPlace::Addr(addr), CValue::ByRef(ebb_param), mir.local_decls[local].ty); + } + fx.local_map.insert(local, CPlace::Addr(addr)); } for local in mir.vars_and_temps_iter() { let layout = cx.tcx.layout_of(ParamEnv::reveal_all().and(mir.local_decls[local].ty)).unwrap(); - let stack_slot = bcx.create_stack_slot(StackSlotData { + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, offset: None, }); - let ty = types::I64; - bcx.declare_var(Variable(local), ty); - let val = bcx.ins().stack_addr(ty, stack_slot, 0); - bcx.def_var(Variable(local), val); + let addr = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); + fx.local_map.insert(local, CPlace::Addr(addr)); } - bcx.ins().jump(*ebb_map.get(&START_BLOCK).unwrap(), &[]); - let mut fx = FunctionCx { - tcx: cx.tcx, - module: &mut cx.module, - def_id_fn_id_map: &mut cx.def_id_fn_id_map, - bcx, - mir, - ebb_map, - args_map, - }; - let fx = &mut fx; + fx.bcx.ins().jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { let ebb = fx.get_ebb(bb); @@ -270,7 +326,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, f: &mut Function, def_id let func_ty = func.ty(&fx.mir.local_decls, fx.tcx); let func = trans_operand(fx, func); let return_place = if let Some((place, _)) = destination { - trans_place(fx, place) + trans_place(fx, place).expect_addr() } else { fx.bcx.ins().iconst(types::I64, 0) }; @@ -282,7 +338,11 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, f: &mut Function, def_id .map(|arg| { let ty = arg.ty(&fx.mir.local_decls, fx.tcx); let arg = trans_operand(fx, arg); - arg.force_stack(fx, ty) + if let Some(_) = cton_type_from_ty(ty) { + arg.load_value(fx, ty) + } else { + arg.force_stack(fx, ty) + } }) ).collect::>(); match func { @@ -331,24 +391,28 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let ty = place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); let lval = trans_place(fx, place); let rval = trans_rval(fx, rval); - do_memcpy(fx, lval, rval, ty); + do_memcpy(fx, lval, CValue::ByRef(rval), ty); } StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => {} _ => unimplemented!("stmt {:?}", stmt), } } -fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> Value { +fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace { match place { - Place::Local(local) => fx.get_local(*local), + Place::Local(local) => fx.get_local_place(*local), Place::Projection(projection) => { - let base = trans_place(fx, &projection.base); + let base = trans_place(fx, &projection.base).expect_addr(); match projection.elem { ProjectionElem::Field(field, ty) => { let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); let field_offset = layout.fields.offset(field.index()); - let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); - fx.bcx.ins().iadd(base, field_offset) + if field_offset.bytes() > 0 { + let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); + CPlace::Addr(fx.bcx.ins().iadd(base, field_offset)) + } else { + CPlace::Addr(base) + } } _ => unimplemented!("projection {:?}", projection), } @@ -403,7 +467,10 @@ fn trans_rval<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, rval: &Rvalue<'tcx>) fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue { match operand { Operand::Move(place) | - Operand::Copy(place) => CValue::ByRef(trans_place(fx, place)), + Operand::Copy(place) => { + let cplace = trans_place(fx, place); + cplace.to_cvalue(fx) + }, Operand::Constant(const_) => { match const_.literal { Literal::Value { value } => { @@ -432,22 +499,25 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx } } -fn do_memcpy<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, to: Value, from: Value, ty: Ty<'tcx>) { +fn do_memcpy<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, to: CPlace, from: CValue, ty: Ty<'tcx>) { let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); let size = layout.size.bytes() as i32; - let ty = match size { - 2 => Some(types::I16), - 4 => Some(types::I32), - 8 => Some(types::I64), - _ => None, - }; - if let Some(ty) = ty { - let data = fx.bcx.ins().load(ty, MemFlags::new(), from, 0); - fx.bcx.ins().store(MemFlags::new(), data, to, 0); - } else { - for i in 0..size { - let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from, i); - fx.bcx.ins().store(MemFlags::new(), byte, to, i); + match to { + CPlace::Var(var) => { + let data = from.load_value(fx, ty); + fx.bcx.def_var(var, data) + }, + CPlace::Addr(addr) => { + if cton_type_from_ty(ty).is_some() { + let data = from.load_value(fx, ty); + fx.bcx.ins().store(MemFlags::new(), data, addr, 0); + } else { + for i in 0..size { + let from = from.expect_byref(); + let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from, i); + fx.bcx.ins().store(MemFlags::new(), byte, addr, i); + } + } } } } @@ -476,8 +546,8 @@ fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signature { _ => CallConv::SystemV, }; Signature { - params: Some(types::I64).into_iter() // First param is palce to put return val - .chain(inputs.into_iter().map(|_| types::I64)) + params: Some(types::I64).into_iter() // First param is place to put return val + .chain(inputs.into_iter().map(|ty| cton_type_from_ty(ty).unwrap_or(types::I64))) .map(AbiParam::new).collect(), returns: vec![], call_conv, From 08d17c9ece01a9a6bd7915869dbd27f7bcef73fc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 20 Jun 2018 15:29:50 +0200 Subject: [PATCH 0007/1566] Better rvalue handling --- src/base.rs | 81 ++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/src/base.rs b/src/base.rs index dfa6c2beee0b7..1e0e0550e4371 100644 --- a/src/base.rs +++ b/src/base.rs @@ -390,8 +390,42 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx StatementKind::Assign(place, rval) => { let ty = place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); let lval = trans_place(fx, place); - let rval = trans_rval(fx, rval); - do_memcpy(fx, lval, CValue::ByRef(rval), ty); + match rval { + Rvalue::Use(operand) => { + let val = trans_operand(fx, operand); + do_memcpy(fx, lval, val, ty); + }, + Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { + let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let lhs_ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); + let rhs_ty = rhs.ty(&fx.mir.local_decls, fx.tcx); + let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); + + let res = match ty.sty { + TypeVariants::TyUint(_) => { + match bin_op { + BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), + BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), + BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), + BinOp::Div => fx.bcx.ins().udiv(lhs, rhs), + bin_op => unimplemented!("checked uint bin op {:?} {:?} {:?}", bin_op, lhs, rhs), + } + } + _ => unimplemented!(), + }; + do_memcpy(fx, lval, CValue::ByVal(res), ty); + } + Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { + let operand = trans_operand(fx, operand); + do_memcpy(fx, lval, operand, ty); + } + Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { + let operand = trans_operand(fx, operand); + do_memcpy(fx, lval, operand, ty); + } + rval => unimplemented!("rval {:?}", rval), + } } StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => {} _ => unimplemented!("stmt {:?}", stmt), @@ -421,49 +455,6 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) } } -fn trans_rval<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, rval: &Rvalue<'tcx>) -> Value { - match rval { - Rvalue::Use(operand) => { - let operand_ty = operand.ty(&fx.mir.local_decls, fx.tcx); - trans_operand(fx, operand).force_stack(fx, operand_ty) - }, - Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { - match bin_op { - BinOp::Mul => { - let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); - let lhs_ty = lhs.ty(&fx.mir.local_decls, fx.tcx); - let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); - let rhs_ty = rhs.ty(&fx.mir.local_decls, fx.tcx); - let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); - let res = match ty.sty { - TypeVariants::TyUint(_) => { - fx.bcx.ins().imul(lhs, rhs) - } - _ => unimplemented!(), - }; - let layout = fx.tcx.layout_of(ParamEnv::empty().and(rval.ty(&fx.mir.local_decls, fx.tcx))).unwrap(); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - fx.bcx.ins().stack_store(res, stack_slot, 1); - fx.bcx.ins().stack_addr(types::I64, stack_slot, 1) - } - bin_op => unimplemented!("checked bin op {:?} {:?} {:?}", bin_op, lhs, rhs), - } - } - Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { - let operand = trans_operand(fx, operand); - operand.force_stack(fx, ty) - } - Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { - trans_operand(fx, operand).force_stack(fx, ty) - } - rval => unimplemented!("rval {:?}", rval), - } -} - fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue { match operand { Operand::Move(place) | From c0dce914e397d7dd0b655805c936c8692766c371 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 22 Jun 2018 19:08:59 +0200 Subject: [PATCH 0008/1566] Mostly fix it --- src/base.rs | 219 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 130 insertions(+), 89 deletions(-) diff --git a/src/base.rs b/src/base.rs index 1e0e0550e4371..7d18ad985724e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -2,7 +2,7 @@ use syntax::ast::{IntTy, UintTy}; use rustc_mir::monomorphize::MonoItem; use cretonne::prelude::*; -//use cretonne::codegen::Context; +use cretonne::codegen::Context; use cretonne::codegen::ir::{ ExternalName, FuncRef, @@ -33,6 +33,28 @@ impl EntityRef for Variable { } } +// FIXME(cretonne) fix load.i8 +fn load_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, offset: i32) -> Value { + use cretonne::codegen::ir::types::*; + match ty { + I8 => fx.bcx.ins().uload8(I32, MemFlags::new(), addr, offset), + I16 => fx.bcx.ins().uload16(I32, MemFlags::new(), addr, offset), + // I32 and I64 work + _ => fx.bcx.ins().load(ty, MemFlags::new(), addr, offset), + } +} + +// FIXME(cretonne) fix store.i8 +fn store_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, val: Value, offset: i32) { + use cretonne::codegen::ir::types::*; + match ty { + I8 => fx.bcx.ins().istore8(MemFlags::new(), val, addr, offset), + I16 => fx.bcx.ins().istore16(MemFlags::new(), val, addr, offset), + // I32 and I64 work + _ => fx.bcx.ins().store(MemFlags::new(), val, addr, offset), + }; +} + #[derive(Copy, Clone)] enum CValue { ByRef(Value), @@ -65,7 +87,7 @@ impl CValue { match self { CValue::ByRef(value) => { let cton_ty = cton_type_from_ty(ty).unwrap(); - fx.bcx.ins().load(cton_ty, MemFlags::new(), value, 0) + load_workaround(fx, cton_ty, value, 0) } CValue::ByVal(value) => value, CValue::Func(func) => { @@ -77,8 +99,8 @@ impl CValue { fn expect_byref(self) -> Value { match self { CValue::ByRef(value) => value, - CValue::ByVal(_) => unimplemented!("Expected CValue::ByRef, found CValue::ByVal"), - CValue::Func(_) => unimplemented!("Expected CValue::ByRef, found CValue::Func"), + CValue::ByVal(_) => bug!("Expected CValue::ByRef, found CValue::ByVal"), + CValue::Func(_) => bug!("Expected CValue::ByRef, found CValue::Func"), } } } @@ -89,8 +111,12 @@ enum CPlace { Addr(Value), } -impl CPlace { - fn to_cvalue<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue { +impl<'a, 'tcx: 'a> CPlace { + fn from_stack_slot(fx: &mut FunctionCx<'a, 'tcx>, stack_slot: StackSlot) -> CPlace { + CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0)) + } + + fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue { match self { CPlace::Var(var) => CValue::ByVal(fx.bcx.use_var(var)), CPlace::Addr(addr) => CValue::ByRef(addr), @@ -100,7 +126,30 @@ impl CPlace { fn expect_addr(self) -> Value { match self { CPlace::Addr(addr) => addr, - CPlace::Var(_) => unreachable!("Expected CPlace::Addr, found CPlace::Var"), + CPlace::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), + } + } + + fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue, ty: Ty<'tcx>) { + let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + let size = layout.size.bytes() as i32; + match self { + CPlace::Var(var) => { + let data = from.load_value(fx, ty); + fx.bcx.def_var(var, data) + }, + CPlace::Addr(addr) => { + if let Some(cton_ty) = cton_type_from_ty(ty) { + let data = from.load_value(fx, ty); + store_workaround(fx, cton_ty, addr, data, 0); + } else { + for i in 0..size { + let from = from.expect_byref(); + let byte = load_workaround(fx, types::I8, from, i); + store_workaround(fx, types::I8, addr, byte, i); + } + } + } } } } @@ -109,66 +158,81 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); let metadata = tcx.encode_metadata(&link_meta); - let module: Module = Module::new(SimpleJITBuilder::new()); - //let mut context = Context::new(); - - let mut cx = CodegenCx { - tcx, - module, - def_id_fn_id_map: HashMap::new(), - }; - let cx = &mut cx; + let mut module: Module = Module::new(SimpleJITBuilder::new()); + let mut context = Context::new(); + let mut def_id_fn_id_map = HashMap::new(); - for mono_item in - collector::collect_crate_mono_items( + { + let mut cx = CodegenCx { tcx, - collector::MonoItemCollectionMode::Eager - ).0 { - match mono_item { - MonoItem::Fn(inst) => match inst { - Instance { - def: InstanceDef::Item(def_id), - substs, - } => { - let sig = tcx.fn_sig(def_id); - let sig = cton_sig_from_fn_sig(tcx, sig, substs); - let func_id = { - let module = &mut cx.module; - *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { - module.declare_function(&tcx.absolute_item_path_str(def_id), Linkage::Local, &sig).unwrap() - }) - }; + module: &mut module, + def_id_fn_id_map: &mut def_id_fn_id_map, + }; + let cx = &mut cx; + + for mono_item in + collector::collect_crate_mono_items( + tcx, + collector::MonoItemCollectionMode::Eager + ).0 { + match mono_item { + MonoItem::Fn(inst) => match inst { + Instance { + def: InstanceDef::Item(def_id), + substs, + } => { + let sig = tcx.fn_sig(def_id); + let sig = cton_sig_from_fn_sig(tcx, sig, substs); + let func_id = { + let module = &mut cx.module; + *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { + module.declare_function(&tcx.absolute_item_path_str(def_id), Linkage::Local, &sig).unwrap() + }) + }; - let mut f = Function::with_name_signature(ext_name_from_did(def_id), sig); + let mut f = Function::with_name_signature(ext_name_from_did(def_id), sig); - trans_fn(cx, &mut f, def_id, substs); + trans_fn(cx, &mut f, def_id, substs); - let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(cx.tcx, Some(def_id), &mut mir).unwrap(); - let mut cton = String::new(); - ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton)); + let mut mir = ::std::io::Cursor::new(Vec::new()); + ::rustc_mir::util::write_mir_pretty(cx.tcx, Some(def_id), &mut mir).unwrap(); + let mut cton = String::new(); + ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); + tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton)); - let flags = settings::Flags::new(settings::builder()); - match ::cretonne::codegen::verify_function(&f, &flags) { - Ok(_) => {} - Err(err) => { - tcx.sess.fatal(&format!("cretonne verify error: {}", err)); + let flags = settings::Flags::new(settings::builder()); + match ::cretonne::codegen::verify_function(&f, &flags) { + Ok(_) => {} + Err(err) => { + tcx.sess.fatal(&format!("cretonne verify error: {}", err)); + } } - } - //context.func = f; - //cx.module.define_function(func_id, &mut context).unwrap(); - //context.clear(); + context.func = f; + cx.module.define_function(func_id, &mut context).unwrap(); + context.clear(); + } + _ => {} } _ => {} } - _ => {} } } - //cx.module.finalize_all(); - //cx.module.finish(); + module.finalize_all(); + + for (inst, func_id) in def_id_fn_id_map.iter() { + if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { + continue; + } + let finalized_function: *const u8 = module.finalize_function(*func_id); + let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = 0u32; + f(&mut res); + tcx.sess.warn(&format!("ret_42 returned {}", res)); + } + + module.finish(); tcx.sess.fatal("unimplemented"); @@ -179,10 +243,10 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { }) } -struct CodegenCx<'a, 'tcx: 'a> { +struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: Module, - def_id_fn_id_map: HashMap, FuncId>, + module: &'a mut Module, + def_id_fn_id_map: &'a mut HashMap, FuncId>, } struct FunctionCx<'a, 'tcx: 'a> { @@ -215,7 +279,7 @@ impl<'f, 'tcx> FunctionCx<'f, 'tcx> { } } -fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, f: &mut Function, def_id: DefId, substs: &Substs<'tcx>) { +fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, def_id: DefId, substs: &Substs<'tcx>) { let mir = cx.tcx.optimized_mir(def_id); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -259,13 +323,13 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, f: &mut Function, def_id fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param)); for (local, ebb_param, ty, stack_slot) in func_params { - let addr = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); + let place = CPlace::from_stack_slot(fx, stack_slot); if ty.is_some() { fx.bcx.ins().stack_store(ebb_param, stack_slot, 0); } else { - do_memcpy(fx, CPlace::Addr(addr), CValue::ByRef(ebb_param), mir.local_decls[local].ty); + place.write_cvalue(fx, CValue::ByRef(ebb_param), mir.local_decls[local].ty); } - fx.local_map.insert(local, CPlace::Addr(addr)); + fx.local_map.insert(local, place); } for local in mir.vars_and_temps_iter() { @@ -275,8 +339,8 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, f: &mut Function, def_id size: layout.size.bytes() as u32, offset: None, }); - let addr = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); - fx.local_map.insert(local, CPlace::Addr(addr)); + let place = CPlace::from_stack_slot(fx, stack_slot); + fx.local_map.insert(local, place); } fx.bcx.ins().jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); @@ -393,7 +457,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx match rval { Rvalue::Use(operand) => { let val = trans_operand(fx, operand); - do_memcpy(fx, lval, val, ty); + lval.write_cvalue(fx, val, ty); }, Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); @@ -414,15 +478,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } _ => unimplemented!(), }; - do_memcpy(fx, lval, CValue::ByVal(res), ty); + lval.write_cvalue(fx, CValue::ByVal(res), ty); } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - do_memcpy(fx, lval, operand, ty); + lval.write_cvalue(fx, operand, ty); } Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - do_memcpy(fx, lval, operand, ty); + lval.write_cvalue(fx, operand, ty); } rval => unimplemented!("rval {:?}", rval), } @@ -490,29 +554,6 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx } } -fn do_memcpy<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, to: CPlace, from: CValue, ty: Ty<'tcx>) { - let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); - let size = layout.size.bytes() as i32; - match to { - CPlace::Var(var) => { - let data = from.load_value(fx, ty); - fx.bcx.def_var(var, data) - }, - CPlace::Addr(addr) => { - if cton_type_from_ty(ty).is_some() { - let data = from.load_value(fx, ty); - fx.bcx.ins().store(MemFlags::new(), data, addr, 0); - } else { - for i in 0..size { - let from = from.expect_byref(); - let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from, i); - fx.bcx.ins().store(MemFlags::new(), byte, addr, i); - } - } - } - } -} - fn ext_name_from_did(def_id: DefId) -> ExternalName { ExternalName::user(def_id.krate.as_u32(), def_id.index.as_raw_u32()) } From c7e7e1fe0fa8468b3cd8bc7db7d0332d7257b74e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 22 Jun 2018 19:18:53 +0200 Subject: [PATCH 0009/1566] Split common utils out of base.rs --- src/base.rs | 237 -------------------------------------------------- src/common.rs | 232 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 16 ++++ 3 files changed, 248 insertions(+), 237 deletions(-) create mode 100644 src/common.rs diff --git a/src/base.rs b/src/base.rs index 7d18ad985724e..0b9f1253c912e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,15 +1,5 @@ -use syntax::ast::{IntTy, UintTy}; use rustc_mir::monomorphize::MonoItem; -use cretonne::prelude::*; -use cretonne::codegen::Context; -use cretonne::codegen::ir::{ - ExternalName, - FuncRef, - StackSlot, - function::Function, -}; - use cretonne_module::{Module, Backend, FuncId, Linkage}; use cretonne_simplejit::{SimpleJITBuilder, SimpleJITBackend}; @@ -18,142 +8,6 @@ use std::collections::HashMap; use prelude::*; -#[derive(Debug, Copy, Clone, Eq, PartialEq)] -struct Variable(Local); - -type CurrentBackend = SimpleJITBackend; - -impl EntityRef for Variable { - fn new(u: usize) -> Self { - Variable(Local::new(u)) - } - - fn index(self) -> usize { - self.0.index() - } -} - -// FIXME(cretonne) fix load.i8 -fn load_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, offset: i32) -> Value { - use cretonne::codegen::ir::types::*; - match ty { - I8 => fx.bcx.ins().uload8(I32, MemFlags::new(), addr, offset), - I16 => fx.bcx.ins().uload16(I32, MemFlags::new(), addr, offset), - // I32 and I64 work - _ => fx.bcx.ins().load(ty, MemFlags::new(), addr, offset), - } -} - -// FIXME(cretonne) fix store.i8 -fn store_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, val: Value, offset: i32) { - use cretonne::codegen::ir::types::*; - match ty { - I8 => fx.bcx.ins().istore8(MemFlags::new(), val, addr, offset), - I16 => fx.bcx.ins().istore16(MemFlags::new(), val, addr, offset), - // I32 and I64 work - _ => fx.bcx.ins().store(MemFlags::new(), val, addr, offset), - }; -} - -#[derive(Copy, Clone)] -enum CValue { - ByRef(Value), - ByVal(Value), - Func(FuncRef), -} - -impl CValue { - fn force_stack<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { - match self { - CValue::ByRef(value) => value, - CValue::ByVal(value) => { - let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - fx.bcx.ins().stack_store(value, stack_slot, 0); - fx.bcx.ins().stack_addr(types::I64, stack_slot, 0) - } - CValue::Func(func) => { - let func = fx.bcx.ins().func_addr(types::I64, func); - CValue::ByVal(func).force_stack(fx, ty) - } - } - } - - fn load_value<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { - match self { - CValue::ByRef(value) => { - let cton_ty = cton_type_from_ty(ty).unwrap(); - load_workaround(fx, cton_ty, value, 0) - } - CValue::ByVal(value) => value, - CValue::Func(func) => { - fx.bcx.ins().func_addr(types::I64, func) - } - } - } - - fn expect_byref(self) -> Value { - match self { - CValue::ByRef(value) => value, - CValue::ByVal(_) => bug!("Expected CValue::ByRef, found CValue::ByVal"), - CValue::Func(_) => bug!("Expected CValue::ByRef, found CValue::Func"), - } - } -} - -#[derive(Copy, Clone)] -enum CPlace { - Var(Variable), - Addr(Value), -} - -impl<'a, 'tcx: 'a> CPlace { - fn from_stack_slot(fx: &mut FunctionCx<'a, 'tcx>, stack_slot: StackSlot) -> CPlace { - CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0)) - } - - fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue { - match self { - CPlace::Var(var) => CValue::ByVal(fx.bcx.use_var(var)), - CPlace::Addr(addr) => CValue::ByRef(addr), - } - } - - fn expect_addr(self) -> Value { - match self { - CPlace::Addr(addr) => addr, - CPlace::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), - } - } - - fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue, ty: Ty<'tcx>) { - let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); - let size = layout.size.bytes() as i32; - match self { - CPlace::Var(var) => { - let data = from.load_value(fx, ty); - fx.bcx.def_var(var, data) - }, - CPlace::Addr(addr) => { - if let Some(cton_ty) = cton_type_from_ty(ty) { - let data = from.load_value(fx, ty); - store_workaround(fx, cton_ty, addr, data, 0); - } else { - for i in 0..size { - let from = from.expect_byref(); - let byte = load_workaround(fx, types::I8, from, i); - store_workaround(fx, types::I8, addr, byte, i); - } - } - } - } - } -} - pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); let metadata = tcx.encode_metadata(&link_meta); @@ -249,36 +103,6 @@ struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { def_id_fn_id_map: &'a mut HashMap, FuncId>, } -struct FunctionCx<'a, 'tcx: 'a> { - tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &'a mut Module, - def_id_fn_id_map: &'a mut HashMap, FuncId>, - bcx: FunctionBuilder<'a, Variable>, - mir: &'tcx Mir<'tcx>, - ebb_map: HashMap, - local_map: HashMap, -} - -impl<'f, 'tcx> FunctionCx<'f, 'tcx> { - fn get_ebb(&self, bb: BasicBlock) -> Ebb { - *self.ebb_map.get(&bb).unwrap() - } - - fn get_local_place(&mut self, local: Local) -> CPlace { - *self.local_map.get(&local).unwrap() - } - - fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let tcx = self.tcx; - let module = &mut self.module; - let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { - let sig = cton_sig_from_instance(tcx, inst); - module.declare_function(&tcx.absolute_item_path_str(inst.def_id()), Linkage::Local, &sig).unwrap() - }); - module.declare_func_in_func(func_id, &mut self.bcx.func) - } -} - fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, def_id: DefId, substs: &Substs<'tcx>) { let mir = cx.tcx.optimized_mir(def_id); let mut func_ctx = FunctionBuilderContext::new(); @@ -553,64 +377,3 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx } } } - -fn ext_name_from_did(def_id: DefId) -> ExternalName { - ExternalName::user(def_id.krate.as_u32(), def_id.index.as_raw_u32()) -} - -fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { - let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); - cton_sig_from_mono_fn_sig(sig) -} - -fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>) -> Signature { - let fn_ty = inst.ty(tcx); - let sig = fn_ty.fn_sig(tcx); - cton_sig_from_mono_fn_sig(sig) -} - -fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signature { - let sig = sig.skip_binder(); - let inputs = sig.inputs(); - let _output = sig.output(); - assert!(!sig.variadic, "Variadic function are not yet supported"); - let call_conv = match sig.abi { - _ => CallConv::SystemV, - }; - Signature { - params: Some(types::I64).into_iter() // First param is place to put return val - .chain(inputs.into_iter().map(|ty| cton_type_from_ty(ty).unwrap_or(types::I64))) - .map(AbiParam::new).collect(), - returns: vec![], - call_conv, - argument_bytes: None, - } -} - -fn cton_type_from_ty(ty: Ty) -> Option { - Some(match ty.sty { - TypeVariants::TyBool => types::I8, - TypeVariants::TyUint(size) => { - match size { - UintTy::U8 => types::I8, - UintTy::U16 => types::I16, - UintTy::U32 => types::I32, - UintTy::U64 => types::I64, - UintTy::U128 => unimplemented!(), - UintTy::Usize => unimplemented!(), - } - } - TypeVariants::TyInt(size) => { - match size { - IntTy::I8 => types::I8, - IntTy::I16 => types::I16, - IntTy::I32 => types::I32, - IntTy::I64 => types::I64, - IntTy::I128 => unimplemented!(), - IntTy::Isize => unimplemented!(), - } - } - TypeVariants::TyFnPtr(_) => types::I64, - _ => return None, - }) -} diff --git a/src/common.rs b/src/common.rs new file mode 100644 index 0000000000000..34196c6fc5965 --- /dev/null +++ b/src/common.rs @@ -0,0 +1,232 @@ +use syntax::ast::{IntTy, UintTy}; + +use cretonne_module::{Module, Linkage, FuncId}; + +use prelude::*; + +pub type CurrentBackend = ::cretonne_simplejit::SimpleJITBackend; + +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub struct Variable(Local); + +impl EntityRef for Variable { + fn new(u: usize) -> Self { + Variable(Local::new(u)) + } + + fn index(self) -> usize { + self.0.index() + } +} + +pub fn cton_type_from_ty(ty: Ty) -> Option { + Some(match ty.sty { + TypeVariants::TyBool => types::I8, + TypeVariants::TyUint(size) => { + match size { + UintTy::U8 => types::I8, + UintTy::U16 => types::I16, + UintTy::U32 => types::I32, + UintTy::U64 => types::I64, + UintTy::U128 => unimplemented!(), + UintTy::Usize => unimplemented!(), + } + } + TypeVariants::TyInt(size) => { + match size { + IntTy::I8 => types::I8, + IntTy::I16 => types::I16, + IntTy::I32 => types::I32, + IntTy::I64 => types::I64, + IntTy::I128 => unimplemented!(), + IntTy::Isize => unimplemented!(), + } + } + TypeVariants::TyFnPtr(_) => types::I64, + _ => return None, + }) +} + +// FIXME(cretonne) fix load.i8 +fn load_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, offset: i32) -> Value { + use cretonne::codegen::ir::types::*; + match ty { + I8 => fx.bcx.ins().uload8(I32, MemFlags::new(), addr, offset), + I16 => fx.bcx.ins().uload16(I32, MemFlags::new(), addr, offset), + // I32 and I64 work + _ => fx.bcx.ins().load(ty, MemFlags::new(), addr, offset), + } +} + +// FIXME(cretonne) fix store.i8 +fn store_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, val: Value, offset: i32) { + use cretonne::codegen::ir::types::*; + match ty { + I8 => fx.bcx.ins().istore8(MemFlags::new(), val, addr, offset), + I16 => fx.bcx.ins().istore16(MemFlags::new(), val, addr, offset), + // I32 and I64 work + _ => fx.bcx.ins().store(MemFlags::new(), val, addr, offset), + }; +} + +#[derive(Copy, Clone)] +pub enum CValue { + ByRef(Value), + ByVal(Value), + Func(FuncRef), +} + +impl CValue { + pub fn force_stack<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { + match self { + CValue::ByRef(value) => value, + CValue::ByVal(value) => { + let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + fx.bcx.ins().stack_store(value, stack_slot, 0); + fx.bcx.ins().stack_addr(types::I64, stack_slot, 0) + } + CValue::Func(func) => { + let func = fx.bcx.ins().func_addr(types::I64, func); + CValue::ByVal(func).force_stack(fx, ty) + } + } + } + + pub fn load_value<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { + match self { + CValue::ByRef(value) => { + let cton_ty = cton_type_from_ty(ty).unwrap(); + load_workaround(fx, cton_ty, value, 0) + } + CValue::ByVal(value) => value, + CValue::Func(func) => { + fx.bcx.ins().func_addr(types::I64, func) + } + } + } + + pub fn expect_byref(self) -> Value { + match self { + CValue::ByRef(value) => value, + CValue::ByVal(_) => bug!("Expected CValue::ByRef, found CValue::ByVal"), + CValue::Func(_) => bug!("Expected CValue::ByRef, found CValue::Func"), + } + } +} + +#[derive(Copy, Clone)] +pub enum CPlace { + Var(Variable), + Addr(Value), +} + +impl<'a, 'tcx: 'a> CPlace { + pub fn from_stack_slot(fx: &mut FunctionCx<'a, 'tcx>, stack_slot: StackSlot) -> CPlace { + CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0)) + } + + pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue { + match self { + CPlace::Var(var) => CValue::ByVal(fx.bcx.use_var(var)), + CPlace::Addr(addr) => CValue::ByRef(addr), + } + } + + pub fn expect_addr(self) -> Value { + match self { + CPlace::Addr(addr) => addr, + CPlace::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), + } + } + + pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue, ty: Ty<'tcx>) { + let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + let size = layout.size.bytes() as i32; + match self { + CPlace::Var(var) => { + let data = from.load_value(fx, ty); + fx.bcx.def_var(var, data) + }, + CPlace::Addr(addr) => { + if let Some(cton_ty) = cton_type_from_ty(ty) { + let data = from.load_value(fx, ty); + store_workaround(fx, cton_ty, addr, data, 0); + } else { + for i in 0..size { + let from = from.expect_byref(); + let byte = load_workaround(fx, types::I8, from, i); + store_workaround(fx, types::I8, addr, byte, i); + } + } + } + } + } +} + +pub fn ext_name_from_did(def_id: DefId) -> ExternalName { + ExternalName::user(def_id.krate.as_u32(), def_id.index.as_raw_u32()) +} + +pub fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { + let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); + cton_sig_from_mono_fn_sig(sig) +} + +pub fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>) -> Signature { + let fn_ty = inst.ty(tcx); + let sig = fn_ty.fn_sig(tcx); + cton_sig_from_mono_fn_sig(sig) +} + +pub fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signature { + let sig = sig.skip_binder(); + let inputs = sig.inputs(); + let _output = sig.output(); + assert!(!sig.variadic, "Variadic function are not yet supported"); + let call_conv = match sig.abi { + _ => CallConv::SystemV, + }; + Signature { + params: Some(types::I64).into_iter() // First param is place to put return val + .chain(inputs.into_iter().map(|ty| cton_type_from_ty(ty).unwrap_or(types::I64))) + .map(AbiParam::new).collect(), + returns: vec![], + call_conv, + argument_bytes: None, + } +} + +pub struct FunctionCx<'a, 'tcx: 'a> { + pub tcx: TyCtxt<'a, 'tcx, 'tcx>, + pub module: &'a mut Module, + pub def_id_fn_id_map: &'a mut HashMap, FuncId>, + pub bcx: FunctionBuilder<'a, Variable>, + pub mir: &'tcx Mir<'tcx>, + pub ebb_map: HashMap, + pub local_map: HashMap, +} + +impl<'f, 'tcx> FunctionCx<'f, 'tcx> { + pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { + *self.ebb_map.get(&bb).unwrap() + } + + pub fn get_local_place(&mut self, local: Local) -> CPlace { + *self.local_map.get(&local).unwrap() + } + + pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { + let tcx = self.tcx; + let module = &mut self.module; + let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { + let sig = cton_sig_from_instance(tcx, inst); + module.declare_function(&tcx.absolute_item_path_str(inst.def_id()), Linkage::Local, &sig).unwrap() + }); + module.declare_func_in_func(func_id, &mut self.bcx.func) + } +} diff --git a/src/lib.rs b/src/lib.rs index a0aec6c311697..039fdbd8e6171 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,8 +33,11 @@ use std::fs::File; use std::io::Write; mod base; +mod common; mod prelude { + pub use std::collections::HashMap; + pub use rustc::session::Session; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; pub use rustc::ty::{TyCtxt, Ty, TypeVariants, Instance, InstanceDef, ParamEnv, FnSig, PolyFnSig, subst::Substs}; @@ -44,6 +47,19 @@ mod prelude { sync::Lrc, indexed_vec::Idx, }; + + pub use cretonne::prelude::*; + pub use cretonne::codegen::Context; + pub use cretonne::codegen::ir::{ + ExternalName, + FuncRef, + StackSlot, + function::Function, + }; + + + pub use common::*; + pub use common::Variable; } use prelude::*; From 312297fe00810c4aed0d4f3240a5005c3c784e9e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 22 Jun 2018 19:33:35 +0200 Subject: [PATCH 0010/1566] Create LICENSE-APACHE --- LICENSE-APACHE | 201 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 LICENSE-APACHE diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000000000..261eeb9e9f8b2 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From b0463690408aedb7eeeb0ff0b62cd1e289473247 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 22 Jun 2018 19:34:27 +0200 Subject: [PATCH 0011/1566] Add LICENSE-MIT --- LICENSE-MIT | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 LICENSE-MIT diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000000000..31aa79387f27e --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. From 6de95c89d9d21d36d3dd18dcfb6e42513e2a52d1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Jun 2018 18:26:54 +0200 Subject: [PATCH 0012/1566] Implement enums --- example.rs | 37 ++++++++++--- src/base.rs | 144 ++++++++++++++++++++++++++++++++++++++++++-------- src/common.rs | 74 +++++++++++++++++++++++--- src/lib.rs | 5 +- 4 files changed, 223 insertions(+), 37 deletions(-) diff --git a/example.rs b/example.rs index 39dbe2cb4115d..dc78a6b10800a 100644 --- a/example.rs +++ b/example.rs @@ -18,10 +18,10 @@ trait Mul { fn mul(self, rhs: RHS) -> Self::Output; } -impl Mul for u8 { - type Output = u8; +impl Mul for u32 { + type Output = u32; - fn mul(self, rhs: u8) -> u8 { + fn mul(self, rhs: u32) -> u32 { self * rhs } } @@ -31,11 +31,19 @@ fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { loop {} } -fn abc(a: u8) -> u8 { +#[lang = "drop_in_place"] +#[allow(unconditional_recursion)] +unsafe fn drop_in_place(to_drop: *mut T) { + // Code here does not matter - this is replaced by the + // real drop glue by the compiler. + drop_in_place(to_drop); +} + +fn abc(a: u32) -> u32 { a * 2 } -fn bcd(b: bool, a: u8) -> u8 { +fn bcd(b: bool, a: u32) -> u32 { if b { a * 2 } else { @@ -43,11 +51,28 @@ fn bcd(b: bool, a: u8) -> u8 { } } -fn call() { +// FIXME make calls work +/*fn call() { abc(42); } fn indirect_call() { let f: fn() = call; f(); +}*/ + +enum BoolOption { + Some(bool), + None, +} + +fn option_unwrap_or(o: BoolOption, d: bool) -> bool { + match o { + BoolOption::Some(b) => b, + BoolOption::None => d, + } +} + +fn ret_42() -> u32 { + 42 } diff --git a/src/base.rs b/src/base.rs index 0b9f1253c912e..1786b732abe4f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -44,15 +44,17 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { }) }; - let mut f = Function::with_name_signature(ext_name_from_did(def_id), sig); - - trans_fn(cx, &mut f, def_id, substs); + let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(cx.tcx, Some(def_id), &mut mir).unwrap(); + tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); + + trans_fn(cx, &mut f, def_id, substs); + let mut cton = String::new(); ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()), cton)); + tcx.sess.warn(&cton); let flags = settings::Flags::new(settings::builder()); match ::cretonne::codegen::verify_function(&f, &flags) { @@ -73,17 +75,26 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { } } + tcx.sess.warn("Compiled everything"); + module.finalize_all(); + tcx.sess.warn("Finalized everything"); + for (inst, func_id) in def_id_fn_id_map.iter() { - if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { + //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { + if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" { continue; } let finalized_function: *const u8 = module.finalize_function(*func_id); - let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; + /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; let mut res = 0u32; f(&mut res); - tcx.sess.warn(&format!("ret_42 returned {}", res)); + tcx.sess.warn(&format!("ret_42 returned {}", res));*/ + let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = false; + f(&mut res, &3, false); + tcx.sess.warn(&format!("option_unwrap_or returned {}", res)); } module.finish(); @@ -149,7 +160,10 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut for (local, ebb_param, ty, stack_slot) in func_params { let place = CPlace::from_stack_slot(fx, stack_slot); if ty.is_some() { - fx.bcx.ins().stack_store(ebb_param, stack_slot, 0); + // FIXME(cretonne) support i16 and smaller + let ebb_param = extend_val(fx, ebb_param, mir.local_decls[local].ty); + CPlace::from_stack_slot(fx, stack_slot).write_cvalue(fx, CValue::ByVal(ebb_param), mir.local_decls[local].ty); + //fx.bcx.ins().stack_store(ebb_param, stack_slot, 0); } else { place.write_cvalue(fx, CValue::ByRef(ebb_param), mir.local_decls[local].ty); } @@ -275,15 +289,38 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { match &stmt.kind { - StatementKind::Assign(place, rval) => { - let ty = place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); - let lval = trans_place(fx, place); + StatementKind::Assign(to_place, rval) => { + let dest_ty = to_place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); + let lval = trans_place(fx, to_place); match rval { Rvalue::Use(operand) => { let val = trans_operand(fx, operand); - lval.write_cvalue(fx, val, ty); + lval.write_cvalue(fx, val, dest_ty); }, + Rvalue::BinaryOp(bin_op, lhs, rhs) => { + let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let lhs_ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); + let rhs_ty = rhs.ty(&fx.mir.local_decls, fx.tcx); + let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); + + let res = match ty.sty { + TypeVariants::TyUint(_) => { + match bin_op { + BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), + BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), + BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), + BinOp::Div => fx.bcx.ins().udiv(lhs, rhs), + bin_op => unimplemented!("checked uint bin op {:?} {:?} {:?}", bin_op, lhs, rhs), + } + } + _ => unimplemented!(), + }; + lval.write_cvalue(fx, CValue::ByVal(res), ty); + } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { + // TODO correctly write output tuple + let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); let lhs_ty = lhs.ty(&fx.mir.local_decls, fx.tcx); let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); @@ -303,14 +340,79 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx _ => unimplemented!(), }; lval.write_cvalue(fx, CValue::ByVal(res), ty); + unimplemented!("checked bin op {:?}", bin_op); } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - lval.write_cvalue(fx, operand, ty); + lval.write_cvalue(fx, operand, dest_ty); } Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - lval.write_cvalue(fx, operand, ty); + lval.write_cvalue(fx, operand, dest_ty); + } + Rvalue::Discriminant(place) => { + let place_ty = place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); + let cton_place_ty = cton_type_from_ty(place_ty); + let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(place_ty)).unwrap(); + + if layout.abi == layout::Abi::Uninhabited { + fx.bcx.ins().trap(TrapCode::User(!0)); + } + match layout.variants { + layout::Variants::Single { index } => { + let discr_val = layout.ty.ty_adt_def().map_or( + index as u128, + |def| def.discriminant_for_variant(fx.tcx, index).val); + let val = CValue::const_val(fx, dest_ty, discr_val as u64 as i64); + lval.write_cvalue(fx, val, dest_ty); + } + layout::Variants::Tagged { .. } | + layout::Variants::NicheFilling { .. } => {}, + } + + let discr = lval.to_cvalue(fx).value_field(fx, mir::Field::new(0), place_ty); + let discr_ty = layout.field(layout::LayoutCx { + tcx: fx.tcx, + param_env: ParamEnv::reveal_all() + }, 0).unwrap().ty; + let lldiscr = discr.load_value(fx, discr_ty); + match layout.variants { + layout::Variants::Single { .. } => bug!(), + layout::Variants::Tagged { ref tag, .. } => { + let signed = match tag.value { + layout::Int(_, signed) => signed, + _ => false + }; + let val = cton_intcast(fx, lldiscr, discr_ty, dest_ty, signed); + lval.write_cvalue(fx, CValue::ByVal(val), dest_ty); + } + layout::Variants::NicheFilling { + dataful_variant, + ref niche_variants, + niche_start, + .. + } => { + let niche_llty = cton_type_from_ty(discr_ty).unwrap(); + if niche_variants.start() == niche_variants.end() { + let b = fx.bcx.ins().icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); + let if_true = fx.bcx.ins().iconst(cton_type_from_ty(dest_ty).unwrap(), *niche_variants.start() as u64 as i64); + let if_false = fx.bcx.ins().iconst(cton_type_from_ty(dest_ty).unwrap(), dataful_variant as u64 as i64); + let val = fx.bcx.ins().select(b, if_true, if_false); + lval.write_cvalue(fx, CValue::ByVal(val), dest_ty); + } else { + // Rebase from niche values to discriminant values. + let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); + let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); + let lldiscr = fx.bcx.ins().isub(lldiscr, delta); + let lldiscr_max = fx.bcx.ins().iconst(niche_llty, *niche_variants.end() as u64 as i64); + let b = fx.bcx.ins().icmp_imm(IntCC::UnsignedLessThanOrEqual, lldiscr, *niche_variants.end() as u64 as i64); + let if_true = cton_intcast(fx, lldiscr, discr_ty, dest_ty, false); + let if_false = fx.bcx.ins().iconst(niche_llty, dataful_variant as u64 as i64); + let val = fx.bcx.ins().select(b, if_true, if_false); + lval.write_cvalue(fx, CValue::ByVal(val), dest_ty); + } + } + } } rval => unimplemented!("rval {:?}", rval), } @@ -324,17 +426,13 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) match place { Place::Local(local) => fx.get_local_place(*local), Place::Projection(projection) => { - let base = trans_place(fx, &projection.base).expect_addr(); + let base = trans_place(fx, &projection.base); match projection.elem { ProjectionElem::Field(field, ty) => { - let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); - let field_offset = layout.fields.offset(field.index()); - if field_offset.bytes() > 0 { - let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); - CPlace::Addr(fx.bcx.ins().iadd(base, field_offset)) - } else { - CPlace::Addr(base) - } + base.place_field(fx, field, ty).0 + } + ProjectionElem::Downcast(_ty, _field) => { + base } _ => unimplemented!("projection {:?}", projection), } diff --git a/src/common.rs b/src/common.rs index 34196c6fc5965..44140c2897a12 100644 --- a/src/common.rs +++ b/src/common.rs @@ -29,7 +29,7 @@ pub fn cton_type_from_ty(ty: Ty) -> Option { UintTy::U32 => types::I32, UintTy::U64 => types::I64, UintTy::U128 => unimplemented!(), - UintTy::Usize => unimplemented!(), + UintTy::Usize => types::I64, } } TypeVariants::TyInt(size) => { @@ -39,7 +39,7 @@ pub fn cton_type_from_ty(ty: Ty) -> Option { IntTy::I32 => types::I32, IntTy::I64 => types::I64, IntTy::I128 => unimplemented!(), - IntTy::Isize => unimplemented!(), + IntTy::Isize => types::I64, } } TypeVariants::TyFnPtr(_) => types::I64, @@ -47,6 +47,22 @@ pub fn cton_type_from_ty(ty: Ty) -> Option { }) } +pub fn extend_val<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, ty: Ty) -> Value { + let cton_ty = cton_type_from_ty(ty).unwrap(); + let to_ty = match cton_ty { + types::I64 => return val, + types::I32 => return val, + _ => types::I32, + }; + match ty.sty { + TypeVariants::TyBool => fx.bcx.ins().uextend(to_ty, val), + TypeVariants::TyUint(_) => fx.bcx.ins().uextend(to_ty, val), + TypeVariants::TyInt(_) => fx.bcx.ins().sextend(to_ty, val), + TypeVariants::TyFnPtr(_) => val, + _ => unimplemented!(), + } +} + // FIXME(cretonne) fix load.i8 fn load_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, offset: i32) -> Value { use cretonne::codegen::ir::types::*; @@ -69,7 +85,7 @@ fn store_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, val: Value, offs }; } -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub enum CValue { ByRef(Value), ByVal(Value), @@ -117,9 +133,28 @@ impl CValue { CValue::Func(_) => bug!("Expected CValue::ByRef, found CValue::Func"), } } + + pub fn value_field<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field, ty: Ty<'tcx>) -> CValue { + let base = match self { + CValue::ByRef(addr) => addr, + _ => bug!("place_field for {:?}", self), + }; + let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let field_offset = layout.fields.offset(field.index()); + if field_offset.bytes() > 0 { + let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); + CValue::ByRef(fx.bcx.ins().iadd(base, field_offset)) + } else { + CValue::ByRef(base) + } + } + + pub fn const_val<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue { + CValue::ByVal(fx.bcx.ins().iconst(cton_type_from_ty(ty).unwrap(), const_val)) + } } -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub enum CPlace { Var(Variable), Addr(Value), @@ -166,10 +201,18 @@ impl<'a, 'tcx: 'a> CPlace { } } } -} -pub fn ext_name_from_did(def_id: DefId) -> ExternalName { - ExternalName::user(def_id.krate.as_u32(), def_id.index.as_raw_u32()) + pub fn place_field(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field, ty: Ty<'tcx>) -> (CPlace, layout::TyLayout<'tcx>) { + let base = self.expect_addr(); + let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let field_offset = layout.fields.offset(field.index()); + if field_offset.bytes() > 0 { + let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); + (CPlace::Addr(fx.bcx.ins().iadd(base, field_offset)), layout) + } else { + (CPlace::Addr(base), layout) + } + } } pub fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { @@ -201,6 +244,23 @@ pub fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signatur } } +pub fn cton_intcast<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, from: Ty<'tcx>, to: Ty<'tcx>, signed: bool) -> Value { + let from = cton_type_from_ty(from).unwrap(); + let to = cton_type_from_ty(to).unwrap(); + if from == to { + return val; + } + if from.wider_or_equal(to) { + if signed { + fx.bcx.ins().sextend(to, val) + } else { + fx.bcx.ins().uextend(to, val) + } + } else { + fx.bcx.ins().ireduce(to, val) + } +} + pub struct FunctionCx<'a, 'tcx: 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, diff --git a/src/lib.rs b/src/lib.rs index 039fdbd8e6171..100c7bbb1201d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ use rustc::session::{ }; use rustc::middle::cstore::{MetadataLoader, EncodedMetadata}; use rustc::dep_graph::DepGraph; -use rustc::ty::maps::Providers; +use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::{CodegenBackend, NoLlvmMetadataLoader}; use rustc_codegen_utils::link::{out_filename, build_link_meta}; @@ -41,6 +41,8 @@ mod prelude { pub use rustc::session::Session; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; pub use rustc::ty::{TyCtxt, Ty, TypeVariants, Instance, InstanceDef, ParamEnv, FnSig, PolyFnSig, subst::Substs}; + pub use rustc::ty::layout; + pub use rustc::mir; pub use rustc::mir::*; pub use rustc_mir::monomorphize::collector; pub use rustc_data_structures::{ @@ -55,6 +57,7 @@ mod prelude { FuncRef, StackSlot, function::Function, + condcodes::IntCC, }; From 0479604be1a0ded845b8bb038318db0e92b0d11b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Jun 2018 18:54:15 +0200 Subject: [PATCH 0013/1566] Implement some more things --- src/base.rs | 127 ++++++++++++++++++++++++++++++++++++++------------ src/common.rs | 36 +++++++++++--- src/lib.rs | 27 +++++------ 3 files changed, 138 insertions(+), 52 deletions(-) diff --git a/src/base.rs b/src/base.rs index 1786b732abe4f..25f630bbc629e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -50,7 +50,7 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { ::rustc_mir::util::write_mir_pretty(cx.tcx, Some(def_id), &mut mir).unwrap(); tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); - trans_fn(cx, &mut f, def_id, substs); + trans_fn(cx, &mut f, inst); let mut cton = String::new(); ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); @@ -114,8 +114,8 @@ struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { def_id_fn_id_map: &'a mut HashMap, FuncId>, } -fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, def_id: DefId, substs: &Substs<'tcx>) { - let mir = cx.tcx.optimized_mir(def_id); +fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) { + let mir = cx.tcx.optimized_mir(instance.def_id()); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -130,8 +130,13 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut tcx: cx.tcx, module: &mut cx.module, def_id_fn_id_map: &mut cx.def_id_fn_id_map, - bcx, + instance, mir, + bcx, + param_substs: { + assert!(!instance.substs.needs_infer()); + instance.substs + }, ebb_map, local_map: HashMap::new(), }; @@ -145,7 +150,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut }); // Dummy stack slot for debugging let func_params = mir.args_iter().map(|local| { - let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(mir.local_decls[local].ty)).unwrap(); + let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(fx.monomorphize(&mir.local_decls[local].ty))).unwrap(); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -160,8 +165,6 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut for (local, ebb_param, ty, stack_slot) in func_params { let place = CPlace::from_stack_slot(fx, stack_slot); if ty.is_some() { - // FIXME(cretonne) support i16 and smaller - let ebb_param = extend_val(fx, ebb_param, mir.local_decls[local].ty); CPlace::from_stack_slot(fx, stack_slot).write_cvalue(fx, CValue::ByVal(ebb_param), mir.local_decls[local].ty); //fx.bcx.ins().stack_store(ebb_param, stack_slot, 0); } else { @@ -258,7 +261,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut TypeVariants::TyFnPtr(fn_sig) => fn_sig, _ => bug!("Calling non function type {:?}", func_ty), }; - let sig = fx.bcx.import_signature(cton_sig_from_fn_sig(fx.tcx, sig, substs)); + let sig = fx.bcx.import_signature(cton_sig_from_fn_sig(fx.tcx, sig, fx.param_substs)); fx.bcx.ins().call_indirect(sig, func, &args); } } @@ -289,19 +292,72 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { match &stmt.kind { + /*StatementKind::SetDiscriminant { place, variant_index } => { + if self.layout.for_variant(bx.cx, variant_index).abi == layout::Abi::Uninhabited { + return; + } + match self.layout.variants { + layout::Variants::Single { index } => { + assert_eq!(index, variant_index); + } + layout::Variants::Tagged { .. } => { + let ptr = self.project_field(bx, 0); + let to = self.layout.ty.ty_adt_def().unwrap() + .discriminant_for_variant(bx.tcx(), variant_index) + .val; + bx.store( + C_uint_big(ptr.layout.llvm_type(bx.cx), to), + ptr.llval, + ptr.align); + } + layout::Variants::NicheFilling { + dataful_variant, + ref niche_variants, + niche_start, + .. + } => { + if variant_index != dataful_variant { + if bx.sess().target.target.arch == "arm" || + bx.sess().target.target.arch == "aarch64" { + // Issue #34427: As workaround for LLVM bug on ARM, + // use memset of 0 before assigning niche value. + let llptr = bx.pointercast(self.llval, Type::i8(bx.cx).ptr_to()); + let fill_byte = C_u8(bx.cx, 0); + let (size, align) = self.layout.size_and_align(); + let size = C_usize(bx.cx, size.bytes()); + let align = C_u32(bx.cx, align.abi() as u32); + base::call_memset(bx, llptr, fill_byte, size, align, false); + } + + let niche = self.project_field(bx, 0); + let niche_llty = niche.layout.immediate_llvm_type(bx.cx); + let niche_value = ((variant_index - *niche_variants.start()) as u128) + .wrapping_add(niche_start); + // FIXME(eddyb) Check the actual primitive type here. + let niche_llval = if niche_value == 0 { + // HACK(eddyb) Using `C_null` as it works on all types. + C_null(niche_llty) + } else { + C_uint_big(niche_llty, niche_value) + }; + OperandValue::Immediate(niche_llval).store(bx, niche); + } + } + } + }*/ StatementKind::Assign(to_place, rval) => { - let dest_ty = to_place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); + let dest_ty = fx.monomorphize(&to_place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); let lval = trans_place(fx, to_place); match rval { Rvalue::Use(operand) => { let val = trans_operand(fx, operand); - lval.write_cvalue(fx, val, dest_ty); + lval.write_cvalue(fx, val, &dest_ty); }, Rvalue::BinaryOp(bin_op, lhs, rhs) => { - let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); - let lhs_ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); + let lhs_ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); - let rhs_ty = rhs.ty(&fx.mir.local_decls, fx.tcx); + let rhs_ty = fx.monomorphize(&rhs.ty(&fx.mir.local_decls, fx.tcx)); let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); let res = match ty.sty { @@ -314,6 +370,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx bin_op => unimplemented!("checked uint bin op {:?} {:?} {:?}", bin_op, lhs, rhs), } } + TypeVariants::TyInt(_) => { + match bin_op { + BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), + BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), + BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), + BinOp::Div => fx.bcx.ins().sdiv(lhs, rhs), + bin_op => unimplemented!("checked int bin op {:?} {:?} {:?}", bin_op, lhs, rhs), + } + } _ => unimplemented!(), }; lval.write_cvalue(fx, CValue::ByVal(res), ty); @@ -321,10 +386,10 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { // TODO correctly write output tuple - let ty = lhs.ty(&fx.mir.local_decls, fx.tcx); - let lhs_ty = lhs.ty(&fx.mir.local_decls, fx.tcx); + let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); + let lhs_ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); - let rhs_ty = rhs.ty(&fx.mir.local_decls, fx.tcx); + let rhs_ty = fx.monomorphize(&rhs.ty(&fx.mir.local_decls, fx.tcx)); let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); let res = match ty.sty { @@ -344,15 +409,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - lval.write_cvalue(fx, operand, dest_ty); + lval.write_cvalue(fx, operand, &dest_ty); } Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - lval.write_cvalue(fx, operand, dest_ty); + lval.write_cvalue(fx, operand, &dest_ty); } Rvalue::Discriminant(place) => { - let place_ty = place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx); - let cton_place_ty = cton_type_from_ty(place_ty); + let place_ty = fx.monomorphize(&place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); + let cton_place_ty = cton_type_from_ty(&place_ty); let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(place_ty)).unwrap(); if layout.abi == layout::Abi::Uninhabited { @@ -363,8 +428,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let discr_val = layout.ty.ty_adt_def().map_or( index as u128, |def| def.discriminant_for_variant(fx.tcx, index).val); - let val = CValue::const_val(fx, dest_ty, discr_val as u64 as i64); - lval.write_cvalue(fx, val, dest_ty); + let val = CValue::const_val(fx, &dest_ty, discr_val as u64 as i64); + lval.write_cvalue(fx, val, &dest_ty); } layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {}, @@ -383,8 +448,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx layout::Int(_, signed) => signed, _ => false }; - let val = cton_intcast(fx, lldiscr, discr_ty, dest_ty, signed); - lval.write_cvalue(fx, CValue::ByVal(val), dest_ty); + let val = cton_intcast(fx, lldiscr, discr_ty, &dest_ty, signed); + lval.write_cvalue(fx, CValue::ByVal(val), &dest_ty); } layout::Variants::NicheFilling { dataful_variant, @@ -395,10 +460,10 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let niche_llty = cton_type_from_ty(discr_ty).unwrap(); if niche_variants.start() == niche_variants.end() { let b = fx.bcx.ins().icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); - let if_true = fx.bcx.ins().iconst(cton_type_from_ty(dest_ty).unwrap(), *niche_variants.start() as u64 as i64); - let if_false = fx.bcx.ins().iconst(cton_type_from_ty(dest_ty).unwrap(), dataful_variant as u64 as i64); + let if_true = fx.bcx.ins().iconst(cton_type_from_ty(&dest_ty).unwrap(), *niche_variants.start() as u64 as i64); + let if_false = fx.bcx.ins().iconst(cton_type_from_ty(&dest_ty).unwrap(), dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); - lval.write_cvalue(fx, CValue::ByVal(val), dest_ty); + lval.write_cvalue(fx, CValue::ByVal(val), &dest_ty); } else { // Rebase from niche values to discriminant values. let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); @@ -406,10 +471,10 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let lldiscr = fx.bcx.ins().isub(lldiscr, delta); let lldiscr_max = fx.bcx.ins().iconst(niche_llty, *niche_variants.end() as u64 as i64); let b = fx.bcx.ins().icmp_imm(IntCC::UnsignedLessThanOrEqual, lldiscr, *niche_variants.end() as u64 as i64); - let if_true = cton_intcast(fx, lldiscr, discr_ty, dest_ty, false); + let if_true = cton_intcast(fx, lldiscr, discr_ty, &dest_ty, false); let if_false = fx.bcx.ins().iconst(niche_llty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); - lval.write_cvalue(fx, CValue::ByVal(val), dest_ty); + lval.write_cvalue(fx, CValue::ByVal(val), &dest_ty); } } } @@ -427,7 +492,11 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) Place::Local(local) => fx.get_local_place(*local), Place::Projection(projection) => { let base = trans_place(fx, &projection.base); + let place_ty = fx.monomorphize(&place.ty(&*fx.mir, fx.tcx)).to_ty(fx.tcx); match projection.elem { + ProjectionElem::Deref => { + CPlace::Addr(base.to_cvalue(fx).load_value(fx, place_ty)) + } ProjectionElem::Field(field, ty) => { base.place_field(fx, field, ty).0 } diff --git a/src/common.rs b/src/common.rs index 44140c2897a12..a86dc0c5f53b4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -28,7 +28,7 @@ pub fn cton_type_from_ty(ty: Ty) -> Option { UintTy::U16 => types::I16, UintTy::U32 => types::I32, UintTy::U64 => types::I64, - UintTy::U128 => unimplemented!(), + UintTy::U128 => types::I64X2, UintTy::Usize => types::I64, } } @@ -38,15 +38,24 @@ pub fn cton_type_from_ty(ty: Ty) -> Option { IntTy::I16 => types::I16, IntTy::I32 => types::I32, IntTy::I64 => types::I64, - IntTy::I128 => unimplemented!(), + IntTy::I128 => types::I64X2, IntTy::Isize => types::I64, } } TypeVariants::TyFnPtr(_) => types::I64, + TypeVariants::TyRef(..) | TypeVariants::TyRawPtr(..) => types::I64, _ => return None, }) } +// FIXME(cretonne) fix types smaller than I32 +pub fn fixup_cton_ty(ty: Type) -> Type { + match ty { + types::I64X2 | types::I64 | types::I32 => ty, + _ => types::I32, + } +} + pub fn extend_val<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, ty: Ty) -> Value { let cton_ty = cton_type_from_ty(ty).unwrap(); let to_ty = match cton_ty { @@ -116,7 +125,7 @@ impl CValue { pub fn load_value<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { match self { CValue::ByRef(value) => { - let cton_ty = cton_type_from_ty(ty).unwrap(); + let cton_ty = cton_type_from_ty(fx.monomorphize(&ty)).expect(&format!("{:?}", ty)); load_workaround(fx, cton_ty, value, 0) } CValue::ByVal(value) => value, @@ -139,7 +148,7 @@ impl CValue { CValue::ByRef(addr) => addr, _ => bug!("place_field for {:?}", self), }; - let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let layout = fx.tcx.layout_of(ParamEnv::empty().and(fx.monomorphize(&ty))).unwrap(); let field_offset = layout.fields.offset(field.index()); if field_offset.bytes() > 0 { let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); @@ -150,6 +159,7 @@ impl CValue { } pub fn const_val<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue { + let ty = fx.monomorphize(&ty); CValue::ByVal(fx.bcx.ins().iconst(cton_type_from_ty(ty).unwrap(), const_val)) } } @@ -180,7 +190,7 @@ impl<'a, 'tcx: 'a> CPlace { } pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue, ty: Ty<'tcx>) { - let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(fx.monomorphize(&ty))).unwrap(); let size = layout.size.bytes() as i32; match self { CPlace::Var(var) => { @@ -236,7 +246,7 @@ pub fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signatur }; Signature { params: Some(types::I64).into_iter() // First param is place to put return val - .chain(inputs.into_iter().map(|ty| cton_type_from_ty(ty).unwrap_or(types::I64))) + .chain(inputs.into_iter().map(|ty| fixup_cton_ty(cton_type_from_ty(ty).unwrap_or(types::I64)))) .map(AbiParam::new).collect(), returns: vec![], call_conv, @@ -265,13 +275,25 @@ pub struct FunctionCx<'a, 'tcx: 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, pub def_id_fn_id_map: &'a mut HashMap, FuncId>, - pub bcx: FunctionBuilder<'a, Variable>, + pub instance: Instance<'tcx>, pub mir: &'tcx Mir<'tcx>, + pub param_substs: &'tcx Substs<'tcx>, + pub bcx: FunctionBuilder<'a, Variable>, pub ebb_map: HashMap, pub local_map: HashMap, } impl<'f, 'tcx> FunctionCx<'f, 'tcx> { + pub fn monomorphize(&self, value: &T) -> T + where T: TypeFoldable<'tcx> + { + self.tcx.subst_and_normalize_erasing_regions( + self.param_substs, + ty::ParamEnv::reveal_all(), + value, + ) + } + pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { *self.ebb_map.get(&bb).unwrap() } diff --git a/src/lib.rs b/src/lib.rs index 100c7bbb1201d..2327400e4f64e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,31 +38,26 @@ mod common; mod prelude { pub use std::collections::HashMap; - pub use rustc::session::Session; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; - pub use rustc::ty::{TyCtxt, Ty, TypeVariants, Instance, InstanceDef, ParamEnv, FnSig, PolyFnSig, subst::Substs}; - pub use rustc::ty::layout; pub use rustc::mir; pub use rustc::mir::*; - pub use rustc_mir::monomorphize::collector; - pub use rustc_data_structures::{ - sync::Lrc, - indexed_vec::Idx, + pub use rustc::session::Session; + pub use rustc::ty::layout; + pub use rustc::ty::{ + self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, + TypeFoldable, TypeVariants, }; + pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc}; + pub use rustc_mir::monomorphize::collector; - pub use cretonne::prelude::*; - pub use cretonne::codegen::Context; pub use cretonne::codegen::ir::{ - ExternalName, - FuncRef, - StackSlot, - function::Function, - condcodes::IntCC, + condcodes::IntCC, function::Function, ExternalName, FuncRef, StackSlot, }; + pub use cretonne::codegen::Context; + pub use cretonne::prelude::*; - - pub use common::*; pub use common::Variable; + pub use common::*; } use prelude::*; From f62381865f3b05fcc53e064ecebae29c714eeac1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Jun 2018 14:01:41 +0200 Subject: [PATCH 0014/1566] Better monomorphization --- src/base.rs | 27 ++++++++++++++------------ src/common.rs | 52 +++++++++++++++++++++++++-------------------------- src/lib.rs | 2 +- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/base.rs b/src/base.rs index 25f630bbc629e..51c715a2d1e4b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -150,13 +150,13 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut }); // Dummy stack slot for debugging let func_params = mir.args_iter().map(|local| { - let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(fx.monomorphize(&mir.local_decls[local].ty))).unwrap(); + let layout = fx.layout_of(mir.local_decls[local].ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, offset: None, }); - let ty = cton_type_from_ty(mir.local_decls[local].ty); + let ty = fx.cton_type(mir.local_decls[local].ty); (local, fx.bcx.append_ebb_param(start_ebb, ty.unwrap_or(types::I64)), ty, stack_slot) }).collect::, StackSlot)>>(); @@ -174,7 +174,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut } for local in mir.vars_and_temps_iter() { - let layout = cx.tcx.layout_of(ParamEnv::reveal_all().and(mir.local_decls[local].ty)).unwrap(); + let layout = fx.layout_of(mir.local_decls[local].ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -243,7 +243,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut .map(|arg| { let ty = arg.ty(&fx.mir.local_decls, fx.tcx); let arg = trans_operand(fx, arg); - if let Some(_) = cton_type_from_ty(ty) { + if let Some(_) = fx.cton_type(ty) { arg.load_value(fx, ty) } else { arg.force_stack(fx, ty) @@ -416,9 +416,10 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx lval.write_cvalue(fx, operand, &dest_ty); } Rvalue::Discriminant(place) => { + let dest_cton_ty = fx.cton_type(&dest_ty).unwrap(); let place_ty = fx.monomorphize(&place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); - let cton_place_ty = cton_type_from_ty(&place_ty); - let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(place_ty)).unwrap(); + let cton_place_ty = fx.cton_type(&place_ty); + let layout = fx.layout_of(place_ty); if layout.abi == layout::Abi::Uninhabited { fx.bcx.ins().trap(TrapCode::User(!0)); @@ -457,11 +458,11 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx niche_start, .. } => { - let niche_llty = cton_type_from_ty(discr_ty).unwrap(); + let niche_llty = fx.cton_type(discr_ty).unwrap(); if niche_variants.start() == niche_variants.end() { let b = fx.bcx.ins().icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); - let if_true = fx.bcx.ins().iconst(cton_type_from_ty(&dest_ty).unwrap(), *niche_variants.start() as u64 as i64); - let if_false = fx.bcx.ins().iconst(cton_type_from_ty(&dest_ty).unwrap(), dataful_variant as u64 as i64); + let if_true = fx.bcx.ins().iconst(dest_cton_ty, *niche_variants.start() as u64 as i64); + let if_false = fx.bcx.ins().iconst(dest_cton_ty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); lval.write_cvalue(fx, CValue::ByVal(val), &dest_ty); } else { @@ -520,16 +521,18 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx Operand::Constant(const_) => { match const_.literal { Literal::Value { value } => { - let layout = fx.tcx.layout_of(ParamEnv::empty().and(const_.ty)).unwrap(); + let layout = fx.layout_of(const_.ty); match const_.ty.sty { TypeVariants::TyUint(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - let iconst = fx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as u64 as i64); + let cton_ty = fx.cton_type(const_.ty).unwrap(); + let iconst = fx.bcx.ins().iconst(cton_ty, bits as u64 as i64); CValue::ByVal(iconst) } TypeVariants::TyInt(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - let iconst = fx.bcx.ins().iconst(cton_type_from_ty(const_.ty).unwrap(), bits as i128 as i64); + let cton_ty = fx.cton_type(const_.ty).unwrap(); + let iconst = fx.bcx.ins().iconst(cton_ty, bits as i128 as i64); CValue::ByVal(iconst) } TypeVariants::TyFnDef(def_id, substs) => { diff --git a/src/common.rs b/src/common.rs index a86dc0c5f53b4..d753255bfa9b7 100644 --- a/src/common.rs +++ b/src/common.rs @@ -19,7 +19,7 @@ impl EntityRef for Variable { } } -pub fn cton_type_from_ty(ty: Ty) -> Option { +fn cton_type_from_ty(ty: Ty) -> Option { Some(match ty.sty { TypeVariants::TyBool => types::I8, TypeVariants::TyUint(size) => { @@ -56,22 +56,6 @@ pub fn fixup_cton_ty(ty: Type) -> Type { } } -pub fn extend_val<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, ty: Ty) -> Value { - let cton_ty = cton_type_from_ty(ty).unwrap(); - let to_ty = match cton_ty { - types::I64 => return val, - types::I32 => return val, - _ => types::I32, - }; - match ty.sty { - TypeVariants::TyBool => fx.bcx.ins().uextend(to_ty, val), - TypeVariants::TyUint(_) => fx.bcx.ins().uextend(to_ty, val), - TypeVariants::TyInt(_) => fx.bcx.ins().sextend(to_ty, val), - TypeVariants::TyFnPtr(_) => val, - _ => unimplemented!(), - } -} - // FIXME(cretonne) fix load.i8 fn load_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, offset: i32) -> Value { use cretonne::codegen::ir::types::*; @@ -106,7 +90,7 @@ impl CValue { match self { CValue::ByRef(value) => value, CValue::ByVal(value) => { - let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let layout = fx.layout_of(ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -125,7 +109,7 @@ impl CValue { pub fn load_value<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { match self { CValue::ByRef(value) => { - let cton_ty = cton_type_from_ty(fx.monomorphize(&ty)).expect(&format!("{:?}", ty)); + let cton_ty = fx.cton_type(ty).expect(&format!("{:?}", ty)); load_workaround(fx, cton_ty, value, 0) } CValue::ByVal(value) => value, @@ -148,7 +132,7 @@ impl CValue { CValue::ByRef(addr) => addr, _ => bug!("place_field for {:?}", self), }; - let layout = fx.tcx.layout_of(ParamEnv::empty().and(fx.monomorphize(&ty))).unwrap(); + let layout = fx.layout_of(ty); let field_offset = layout.fields.offset(field.index()); if field_offset.bytes() > 0 { let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); @@ -159,8 +143,8 @@ impl CValue { } pub fn const_val<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue { - let ty = fx.monomorphize(&ty); - CValue::ByVal(fx.bcx.ins().iconst(cton_type_from_ty(ty).unwrap(), const_val)) + let ty = fx.cton_type(ty).unwrap(); + CValue::ByVal(fx.bcx.ins().iconst(ty, const_val)) } } @@ -190,7 +174,7 @@ impl<'a, 'tcx: 'a> CPlace { } pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue, ty: Ty<'tcx>) { - let layout = fx.tcx.layout_of(ParamEnv::reveal_all().and(fx.monomorphize(&ty))).unwrap(); + let layout = fx.layout_of(ty); let size = layout.size.bytes() as i32; match self { CPlace::Var(var) => { @@ -198,7 +182,7 @@ impl<'a, 'tcx: 'a> CPlace { fx.bcx.def_var(var, data) }, CPlace::Addr(addr) => { - if let Some(cton_ty) = cton_type_from_ty(ty) { + if let Some(cton_ty) = fx.cton_type(ty) { let data = from.load_value(fx, ty); store_workaround(fx, cton_ty, addr, data, 0); } else { @@ -214,7 +198,7 @@ impl<'a, 'tcx: 'a> CPlace { pub fn place_field(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field, ty: Ty<'tcx>) -> (CPlace, layout::TyLayout<'tcx>) { let base = self.expect_addr(); - let layout = fx.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + let layout = fx.layout_of(ty); let field_offset = layout.fields.offset(field.index()); if field_offset.bytes() > 0 { let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); @@ -255,8 +239,8 @@ pub fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signatur } pub fn cton_intcast<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, from: Ty<'tcx>, to: Ty<'tcx>, signed: bool) -> Value { - let from = cton_type_from_ty(from).unwrap(); - let to = cton_type_from_ty(to).unwrap(); + let from = fx.cton_type(from).unwrap(); + let to = fx.cton_type(to).unwrap(); if from == to { return val; } @@ -283,6 +267,16 @@ pub struct FunctionCx<'a, 'tcx: 'a> { pub local_map: HashMap, } +impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> { + type Ty = Ty<'tcx>; + type TyLayout = TyLayout<'tcx>; + + fn layout_of(self, ty: Ty<'tcx>) -> TyLayout<'tcx> { + let ty = self.monomorphize(&ty); + self.tcx.layout_of(ParamEnv::reveal_all().and(&ty)).unwrap() + } +} + impl<'f, 'tcx> FunctionCx<'f, 'tcx> { pub fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx> @@ -294,6 +288,10 @@ impl<'f, 'tcx> FunctionCx<'f, 'tcx> { ) } + pub fn cton_type(&self, ty: Ty<'tcx>) -> Option { + cton_type_from_ty(self.monomorphize(&ty)) + } + pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { *self.ebb_map.get(&bb).unwrap() } diff --git a/src/lib.rs b/src/lib.rs index 2327400e4f64e..39e7a8d82f578 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,7 @@ mod prelude { pub use rustc::mir; pub use rustc::mir::*; pub use rustc::session::Session; - pub use rustc::ty::layout; + pub use rustc::ty::layout::{self, LayoutOf, TyLayout}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeFoldable, TypeVariants, From c53d58f92395b2168dbc94b45bc472430a20ee26 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Jun 2018 14:25:29 +0200 Subject: [PATCH 0015/1566] Implement some traits for FunctionCx --- src/common.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/common.rs b/src/common.rs index d753255bfa9b7..8a8e29bbda5f0 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,4 +1,7 @@ +extern crate rustc_target; + use syntax::ast::{IntTy, UintTy}; +use self::rustc_target::spec::{HasTargetSpec, Target}; use cretonne_module::{Module, Linkage, FuncId}; @@ -277,6 +280,24 @@ impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> { } } +impl<'a, 'tcx> layout::HasTyCtxt<'tcx> for &'a FunctionCx<'a, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { + self.tcx + } +} + +impl<'a, 'tcx> layout::HasDataLayout for &'a FunctionCx<'a, 'tcx> { + fn data_layout(&self) -> &layout::TargetDataLayout { + &self.tcx.data_layout + } +} + +impl<'a, 'tcx> HasTargetSpec for &'a FunctionCx<'a, 'tcx> { + fn target_spec(&self) -> &Target { + &self.tcx.sess.target.target + } +} + impl<'f, 'tcx> FunctionCx<'f, 'tcx> { pub fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx> From bdad2d427d097fd778b41fa8891a561d756ea373 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Jun 2018 14:29:56 +0200 Subject: [PATCH 0016/1566] Implement SetDiscriminant --- src/base.rs | 63 +++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/base.rs b/src/base.rs index 51c715a2d1e4b..6aa67721256b6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -292,23 +292,24 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { match &stmt.kind { - /*StatementKind::SetDiscriminant { place, variant_index } => { - if self.layout.for_variant(bx.cx, variant_index).abi == layout::Abi::Uninhabited { + StatementKind::SetDiscriminant { place, variant_index } => { + let place_ty = fx.monomorphize(&place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); + let place = trans_place(fx, place); + let layout = fx.layout_of(place_ty); + if layout.for_variant(&*fx, *variant_index).abi == layout::Abi::Uninhabited { return; } - match self.layout.variants { + match layout.variants { layout::Variants::Single { index } => { - assert_eq!(index, variant_index); + assert_eq!(index, *variant_index); } layout::Variants::Tagged { .. } => { - let ptr = self.project_field(bx, 0); - let to = self.layout.ty.ty_adt_def().unwrap() - .discriminant_for_variant(bx.tcx(), variant_index) + let ptr = place.place_field(fx, mir::Field::new(0), place_ty); + let to = layout.ty.ty_adt_def().unwrap() + .discriminant_for_variant(fx.tcx, *variant_index) .val; - bx.store( - C_uint_big(ptr.layout.llvm_type(bx.cx), to), - ptr.llval, - ptr.align); + let discr = CValue::const_val(fx, ptr.1.ty, to as u64 as i64); + ptr.0.write_cvalue(fx, discr, ptr.1.ty); } layout::Variants::NicheFilling { dataful_variant, @@ -316,35 +317,22 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx niche_start, .. } => { - if variant_index != dataful_variant { - if bx.sess().target.target.arch == "arm" || - bx.sess().target.target.arch == "aarch64" { - // Issue #34427: As workaround for LLVM bug on ARM, - // use memset of 0 before assigning niche value. - let llptr = bx.pointercast(self.llval, Type::i8(bx.cx).ptr_to()); - let fill_byte = C_u8(bx.cx, 0); - let (size, align) = self.layout.size_and_align(); - let size = C_usize(bx.cx, size.bytes()); - let align = C_u32(bx.cx, align.abi() as u32); - base::call_memset(bx, llptr, fill_byte, size, align, false); - } - - let niche = self.project_field(bx, 0); - let niche_llty = niche.layout.immediate_llvm_type(bx.cx); + if *variant_index != dataful_variant { + let niche = place.place_field(fx, mir::Field::new(0), place_ty); + //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); let niche_value = ((variant_index - *niche_variants.start()) as u128) .wrapping_add(niche_start); // FIXME(eddyb) Check the actual primitive type here. let niche_llval = if niche_value == 0 { - // HACK(eddyb) Using `C_null` as it works on all types. - C_null(niche_llty) + CValue::const_val(fx, niche.1.ty, 0) } else { - C_uint_big(niche_llty, niche_value) + CValue::const_val(fx, niche.1.ty, niche_value as u64 as i64) }; - OperandValue::Immediate(niche_llval).store(bx, niche); + niche.0.write_cvalue(fx, niche_llval, niche.1.ty); } } } - }*/ + } StatementKind::Assign(to_place, rval) => { let dest_ty = fx.monomorphize(&to_place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); let lval = trans_place(fx, to_place); @@ -402,6 +390,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx bin_op => unimplemented!("checked uint bin op {:?} {:?} {:?}", bin_op, lhs, rhs), } } + TypeVariants::TyInt(_) => { + match bin_op { + BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), + BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), + BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), + BinOp::Div => fx.bcx.ins().sdiv(lhs, rhs), + bin_op => unimplemented!("checked int bin op {:?} {:?} {:?}", bin_op, lhs, rhs), + } + } _ => unimplemented!(), }; lval.write_cvalue(fx, CValue::ByVal(res), ty); @@ -493,10 +490,10 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) Place::Local(local) => fx.get_local_place(*local), Place::Projection(projection) => { let base = trans_place(fx, &projection.base); - let place_ty = fx.monomorphize(&place.ty(&*fx.mir, fx.tcx)).to_ty(fx.tcx); + let base_ty = projection.base.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx); match projection.elem { ProjectionElem::Deref => { - CPlace::Addr(base.to_cvalue(fx).load_value(fx, place_ty)) + CPlace::Addr(base.to_cvalue(fx).load_value(fx, base_ty)) } ProjectionElem::Field(field, ty) => { base.place_field(fx, field, ty).0 From a7e674006c7125fb47ce2909616ba5d59dce62aa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Jun 2018 19:44:19 +0200 Subject: [PATCH 0017/1566] Store TyLayout inside CValue and CPlace --- build.sh | 2 +- src/base.rs | 137 ++++++++++++++++++++---------------------- src/common.rs | 162 +++++++++++++++++++++++++++++++++----------------- 3 files changed, 170 insertions(+), 131 deletions(-) diff --git a/build.sh b/build.sh index 548bd7368f3bb..6cbc04f60e164 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ cargo build || exit 1 -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.so example.rs --crate-type lib +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.so example.rs --crate-type lib -Og diff --git a/src/base.rs b/src/base.rs index 6aa67721256b6..a1052bbec488f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -156,31 +156,33 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut size: layout.size.bytes() as u32, offset: None, }); - let ty = fx.cton_type(mir.local_decls[local].ty); - (local, fx.bcx.append_ebb_param(start_ebb, ty.unwrap_or(types::I64)), ty, stack_slot) - }).collect::, StackSlot)>>(); + let ty = mir.local_decls[local].ty; + let cton_type = fx.cton_type(ty).unwrap_or(types::I64); + (local, fx.bcx.append_ebb_param(start_ebb, cton_type), ty, stack_slot) + }).collect::>(); - fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param)); + let ret_layout = fx.layout_of(fx.instance.ty(fx.tcx).fn_sig(fx.tcx).skip_binder().output()); + fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); for (local, ebb_param, ty, stack_slot) in func_params { - let place = CPlace::from_stack_slot(fx, stack_slot); - if ty.is_some() { - CPlace::from_stack_slot(fx, stack_slot).write_cvalue(fx, CValue::ByVal(ebb_param), mir.local_decls[local].ty); - //fx.bcx.ins().stack_store(ebb_param, stack_slot, 0); + let place = CPlace::from_stack_slot(fx, stack_slot, ty); + if fx.cton_type(ty).is_some() { + place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())); } else { - place.write_cvalue(fx, CValue::ByRef(ebb_param), mir.local_decls[local].ty); + place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())); } fx.local_map.insert(local, place); } for local in mir.vars_and_temps_iter() { - let layout = fx.layout_of(mir.local_decls[local].ty); + let ty = mir.local_decls[local].ty; + let layout = fx.layout_of(ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, offset: None, }); - let place = CPlace::from_stack_slot(fx, stack_slot); + let place = CPlace::from_stack_slot(fx, stack_slot, ty); fx.local_map.insert(local, place); } @@ -203,8 +205,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut fx.bcx.ins().return_(&[]); } TerminatorKind::Assert { cond, expected, msg: _, target, cleanup: _ } => { - let cond_ty = cond.ty(&fx.mir.local_decls, fx.tcx); - let cond = trans_operand(fx, cond).load_value(fx, cond_ty); + let cond = trans_operand(fx, cond).load_value(fx); let target = fx.get_ebb(*target); if *expected { fx.bcx.ins().brz(cond, target, &[]); @@ -215,8 +216,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut } TerminatorKind::SwitchInt { discr, switch_ty, values, targets } => { - let discr_ty = discr.ty(&fx.mir.local_decls, fx.tcx); - let discr = trans_operand(fx, discr).load_value(fx, discr_ty); + let discr = trans_operand(fx, discr).load_value(fx); let mut jt_data = JumpTableData::new(); for (i, value) in values.iter().enumerate() { let ebb = fx.get_ebb(targets[i]); @@ -244,18 +244,18 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut let ty = arg.ty(&fx.mir.local_decls, fx.tcx); let arg = trans_operand(fx, arg); if let Some(_) = fx.cton_type(ty) { - arg.load_value(fx, ty) + arg.load_value(fx) } else { - arg.force_stack(fx, ty) + arg.force_stack(fx) } }) ).collect::>(); match func { - CValue::Func(func) => { + CValue::Func(func, _) => { fx.bcx.ins().call(func, &args); } func => { - let func = func.load_value(fx, func_ty); + let func = func.load_value(fx); let sig = match func_ty.sty { TypeVariants::TyFnDef(def_id, _substs) => fx.tcx.fn_sig(def_id), TypeVariants::TyFnPtr(fn_sig) => fn_sig, @@ -293,9 +293,8 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { match &stmt.kind { StatementKind::SetDiscriminant { place, variant_index } => { - let place_ty = fx.monomorphize(&place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); let place = trans_place(fx, place); - let layout = fx.layout_of(place_ty); + let layout = place.layout(); if layout.for_variant(&*fx, *variant_index).abi == layout::Abi::Uninhabited { return; } @@ -304,12 +303,12 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx assert_eq!(index, *variant_index); } layout::Variants::Tagged { .. } => { - let ptr = place.place_field(fx, mir::Field::new(0), place_ty); + let ptr = place.place_field(fx, mir::Field::new(0)); let to = layout.ty.ty_adt_def().unwrap() .discriminant_for_variant(fx.tcx, *variant_index) .val; - let discr = CValue::const_val(fx, ptr.1.ty, to as u64 as i64); - ptr.0.write_cvalue(fx, discr, ptr.1.ty); + let discr = CValue::const_val(fx, ptr.layout().ty, to as u64 as i64); + ptr.write_cvalue(fx, discr); } layout::Variants::NicheFilling { dataful_variant, @@ -318,35 +317,34 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx .. } => { if *variant_index != dataful_variant { - let niche = place.place_field(fx, mir::Field::new(0), place_ty); + let niche = place.place_field(fx, mir::Field::new(0)); //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); let niche_value = ((variant_index - *niche_variants.start()) as u128) .wrapping_add(niche_start); // FIXME(eddyb) Check the actual primitive type here. let niche_llval = if niche_value == 0 { - CValue::const_val(fx, niche.1.ty, 0) + CValue::const_val(fx, niche.layout().ty, 0) } else { - CValue::const_val(fx, niche.1.ty, niche_value as u64 as i64) + CValue::const_val(fx, niche.layout().ty, niche_value as u64 as i64) }; - niche.0.write_cvalue(fx, niche_llval, niche.1.ty); + niche.write_cvalue(fx, niche_llval); } } } } StatementKind::Assign(to_place, rval) => { - let dest_ty = fx.monomorphize(&to_place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); let lval = trans_place(fx, to_place); + let dest_layout = lval.layout(); match rval { Rvalue::Use(operand) => { let val = trans_operand(fx, operand); - lval.write_cvalue(fx, val, &dest_ty); + lval.write_cvalue(fx, val); }, Rvalue::BinaryOp(bin_op, lhs, rhs) => { let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let lhs_ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); - let rhs_ty = fx.monomorphize(&rhs.ty(&fx.mir.local_decls, fx.tcx)); - let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); + let layout = fx.layout_of(ty); + let lhs = trans_operand(fx, lhs).load_value(fx); + let rhs = trans_operand(fx, rhs).load_value(fx); let res = match ty.sty { TypeVariants::TyUint(_) => { @@ -369,16 +367,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } _ => unimplemented!(), }; - lval.write_cvalue(fx, CValue::ByVal(res), ty); + lval.write_cvalue(fx, CValue::ByVal(res, layout)); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { // TODO correctly write output tuple let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let lhs_ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let lhs = trans_operand(fx, lhs).load_value(fx, lhs_ty); - let rhs_ty = fx.monomorphize(&rhs.ty(&fx.mir.local_decls, fx.tcx)); - let rhs = trans_operand(fx, rhs).load_value(fx, rhs_ty); + let layout = fx.layout_of(ty); + let lhs = trans_operand(fx, lhs).load_value(fx); + let rhs = trans_operand(fx, rhs).load_value(fx); let res = match ty.sty { TypeVariants::TyUint(_) => { @@ -401,22 +398,22 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } _ => unimplemented!(), }; - lval.write_cvalue(fx, CValue::ByVal(res), ty); + lval.write_cvalue(fx, CValue::ByVal(res, layout)); unimplemented!("checked bin op {:?}", bin_op); } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - lval.write_cvalue(fx, operand, &dest_ty); + let layout = fx.layout_of(ty); + lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); } Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); - lval.write_cvalue(fx, operand, &dest_ty); + let layout = fx.layout_of(ty); + lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); } Rvalue::Discriminant(place) => { - let dest_cton_ty = fx.cton_type(&dest_ty).unwrap(); - let place_ty = fx.monomorphize(&place.ty(&fx.mir.local_decls, fx.tcx).to_ty(fx.tcx)); - let cton_place_ty = fx.cton_type(&place_ty); - let layout = fx.layout_of(place_ty); + let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); + let layout = lval.layout(); if layout.abi == layout::Abi::Uninhabited { fx.bcx.ins().trap(TrapCode::User(!0)); @@ -426,19 +423,17 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let discr_val = layout.ty.ty_adt_def().map_or( index as u128, |def| def.discriminant_for_variant(fx.tcx, index).val); - let val = CValue::const_val(fx, &dest_ty, discr_val as u64 as i64); - lval.write_cvalue(fx, val, &dest_ty); + let val = CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); + lval.write_cvalue(fx, val); + return; } layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {}, } - let discr = lval.to_cvalue(fx).value_field(fx, mir::Field::new(0), place_ty); - let discr_ty = layout.field(layout::LayoutCx { - tcx: fx.tcx, - param_env: ParamEnv::reveal_all() - }, 0).unwrap().ty; - let lldiscr = discr.load_value(fx, discr_ty); + let discr = lval.to_cvalue(fx).value_field(fx, mir::Field::new(0)); + let discr_ty = lval.layout().ty; + let lldiscr = discr.load_value(fx); match layout.variants { layout::Variants::Single { .. } => bug!(), layout::Variants::Tagged { ref tag, .. } => { @@ -446,8 +441,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx layout::Int(_, signed) => signed, _ => false }; - let val = cton_intcast(fx, lldiscr, discr_ty, &dest_ty, signed); - lval.write_cvalue(fx, CValue::ByVal(val), &dest_ty); + let val = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, signed); + lval.write_cvalue(fx, CValue::ByVal(val, dest_layout)); } layout::Variants::NicheFilling { dataful_variant, @@ -461,18 +456,17 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let if_true = fx.bcx.ins().iconst(dest_cton_ty, *niche_variants.start() as u64 as i64); let if_false = fx.bcx.ins().iconst(dest_cton_ty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); - lval.write_cvalue(fx, CValue::ByVal(val), &dest_ty); + lval.write_cvalue(fx, CValue::ByVal(val, dest_layout)); } else { // Rebase from niche values to discriminant values. let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); let lldiscr = fx.bcx.ins().isub(lldiscr, delta); - let lldiscr_max = fx.bcx.ins().iconst(niche_llty, *niche_variants.end() as u64 as i64); let b = fx.bcx.ins().icmp_imm(IntCC::UnsignedLessThanOrEqual, lldiscr, *niche_variants.end() as u64 as i64); - let if_true = cton_intcast(fx, lldiscr, discr_ty, &dest_ty, false); + let if_true = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, false); let if_false = fx.bcx.ins().iconst(niche_llty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); - lval.write_cvalue(fx, CValue::ByVal(val), &dest_ty); + lval.write_cvalue(fx, CValue::ByVal(val, dest_layout)); } } } @@ -485,21 +479,20 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } } -fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace { +fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { match place { Place::Local(local) => fx.get_local_place(*local), Place::Projection(projection) => { let base = trans_place(fx, &projection.base); - let base_ty = projection.base.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx); match projection.elem { ProjectionElem::Deref => { - CPlace::Addr(base.to_cvalue(fx).load_value(fx, base_ty)) + CPlace::Addr(base.to_cvalue(fx).load_value(fx), fx.layout_of(place.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx))) } ProjectionElem::Field(field, ty) => { - base.place_field(fx, field, ty).0 + base.place_field(fx, field) } - ProjectionElem::Downcast(_ty, _field) => { - base + ProjectionElem::Downcast(adt_def, variant) => { + base.downcast_variant(fx, variant) } _ => unimplemented!("projection {:?}", projection), } @@ -508,7 +501,7 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) } } -fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue { +fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue<'tcx> { match operand { Operand::Move(place) | Operand::Copy(place) => { @@ -522,19 +515,15 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx match const_.ty.sty { TypeVariants::TyUint(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - let cton_ty = fx.cton_type(const_.ty).unwrap(); - let iconst = fx.bcx.ins().iconst(cton_ty, bits as u64 as i64); - CValue::ByVal(iconst) + CValue::const_val(fx, const_.ty, bits as u64 as i64) } TypeVariants::TyInt(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - let cton_ty = fx.cton_type(const_.ty).unwrap(); - let iconst = fx.bcx.ins().iconst(cton_ty, bits as i128 as i64); - CValue::ByVal(iconst) + CValue::const_val(fx, const_.ty, bits as i128 as i64) } TypeVariants::TyFnDef(def_id, substs) => { let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); - CValue::Func(func_ref) + CValue::Func(func_ref, fx.layout_of(const_.ty)) } _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), } diff --git a/src/common.rs b/src/common.rs index 8a8e29bbda5f0..89ee2666f03b3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -82,18 +82,25 @@ fn store_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, val: Value, offs } #[derive(Debug, Copy, Clone)] -pub enum CValue { - ByRef(Value), - ByVal(Value), - Func(FuncRef), +pub enum CValue<'tcx> { + ByRef(Value, TyLayout<'tcx>), + ByVal(Value, TyLayout<'tcx>), + Func(FuncRef, TyLayout<'tcx>), } -impl CValue { - pub fn force_stack<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { +impl<'tcx> CValue<'tcx> { + pub fn layout(&self) -> TyLayout<'tcx> { + match *self { + CValue::ByRef(_, layout) | + CValue::ByVal(_, layout) | + CValue::Func(_, layout) => layout + } + } + + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value where 'tcx: 'a { match self { - CValue::ByRef(value) => value, - CValue::ByVal(value) => { - let layout = fx.layout_of(ty); + CValue::ByRef(value, _layout) => value, + CValue::ByVal(value, layout) => { let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -102,96 +109,126 @@ impl CValue { fx.bcx.ins().stack_store(value, stack_slot, 0); fx.bcx.ins().stack_addr(types::I64, stack_slot, 0) } - CValue::Func(func) => { + CValue::Func(func, ty) => { let func = fx.bcx.ins().func_addr(types::I64, func); - CValue::ByVal(func).force_stack(fx, ty) + CValue::ByVal(func, ty).force_stack(fx) } } } - pub fn load_value<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> Value { + pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value where 'tcx: 'a{ match self { - CValue::ByRef(value) => { - let cton_ty = fx.cton_type(ty).expect(&format!("{:?}", ty)); + CValue::ByRef(value, layout) => { + let cton_ty = fx.cton_type(layout.ty).expect(&format!("{:?}", layout.ty)); load_workaround(fx, cton_ty, value, 0) } - CValue::ByVal(value) => value, - CValue::Func(func) => { + CValue::ByVal(value, _layout) => value, + CValue::Func(func, _layout) => { fx.bcx.ins().func_addr(types::I64, func) } } } - pub fn expect_byref(self) -> Value { + pub fn expect_byref(self) -> (Value, TyLayout<'tcx>) { match self { - CValue::ByRef(value) => value, - CValue::ByVal(_) => bug!("Expected CValue::ByRef, found CValue::ByVal"), - CValue::Func(_) => bug!("Expected CValue::ByRef, found CValue::Func"), + CValue::ByRef(value, layout) => (value, layout), + CValue::ByVal(_, _) => bug!("Expected CValue::ByRef, found CValue::ByVal"), + CValue::Func(_, _) => bug!("Expected CValue::ByRef, found CValue::Func"), } } - pub fn value_field<'a, 'tcx: 'a>(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field, ty: Ty<'tcx>) -> CValue { - let base = match self { - CValue::ByRef(addr) => addr, + pub fn value_field<'a>(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CValue<'tcx> where 'tcx: 'a { + use rustc::ty::util::IntTypeExt; + + let (base, layout) = match self { + CValue::ByRef(addr, layout) => (addr, layout), _ => bug!("place_field for {:?}", self), }; - let layout = fx.layout_of(ty); let field_offset = layout.fields.offset(field.index()); + let field_layout = if field.index() == 0 { + fx.layout_of(if let ty::TyAdt(adt_def, _) = layout.ty.sty { + adt_def.repr.discr_type().to_ty(fx.tcx) + } else { + // This can only be `0`, for now, so `u8` will suffice. + fx.tcx.types.u8 + }) + } else { + layout.field(&*fx, field.index()) + }; if field_offset.bytes() > 0 { let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); - CValue::ByRef(fx.bcx.ins().iadd(base, field_offset)) + CValue::ByRef(fx.bcx.ins().iadd(base, field_offset), field_layout) } else { - CValue::ByRef(base) + CValue::ByRef(base, field_layout) } } - pub fn const_val<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue { - let ty = fx.cton_type(ty).unwrap(); - CValue::ByVal(fx.bcx.ins().iconst(ty, const_val)) + pub fn const_val<'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue<'tcx> where 'tcx: 'a { + let cton_ty = fx.cton_type(ty).unwrap(); + let layout = fx.layout_of(ty); + CValue::ByVal(fx.bcx.ins().iconst(cton_ty, const_val), layout) + } + + pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + match self { + CValue::ByRef(addr, _) => CValue::ByRef(addr, layout), + CValue::ByVal(val, _) => CValue::ByVal(val, layout), + CValue::Func(fun, _) => CValue::Func(fun, layout), + } } } #[derive(Debug, Copy, Clone)] -pub enum CPlace { - Var(Variable), - Addr(Value), +pub enum CPlace<'tcx> { + Var(Variable, TyLayout<'tcx>), + Addr(Value, TyLayout<'tcx>), } -impl<'a, 'tcx: 'a> CPlace { - pub fn from_stack_slot(fx: &mut FunctionCx<'a, 'tcx>, stack_slot: StackSlot) -> CPlace { - CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0)) +impl<'a, 'tcx: 'a> CPlace<'tcx> { + pub fn layout(&self) -> TyLayout<'tcx> { + match *self { + CPlace::Var(_, layout) | + CPlace::Addr(_, layout) => layout + } + } + + pub fn from_stack_slot(fx: &mut FunctionCx<'a, 'tcx>, stack_slot: StackSlot, ty: Ty<'tcx>) -> CPlace<'tcx> { + let layout = fx.layout_of(ty); + CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0), layout) } - pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue { + pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue<'tcx> { match self { - CPlace::Var(var) => CValue::ByVal(fx.bcx.use_var(var)), - CPlace::Addr(addr) => CValue::ByRef(addr), + CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(var), layout), + CPlace::Addr(addr, layout) => CValue::ByRef(addr, layout), } } pub fn expect_addr(self) -> Value { match self { - CPlace::Addr(addr) => addr, - CPlace::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), + CPlace::Addr(addr, _layout) => addr, + CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } - pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue, ty: Ty<'tcx>) { - let layout = fx.layout_of(ty); - let size = layout.size.bytes() as i32; + 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"); + match self { - CPlace::Var(var) => { - let data = from.load_value(fx, ty); + CPlace::Var(var, _) => { + let data = from.load_value(fx); fx.bcx.def_var(var, data) }, - CPlace::Addr(addr) => { - if let Some(cton_ty) = fx.cton_type(ty) { - let data = from.load_value(fx, ty); + CPlace::Addr(addr, layout) => { + let size = layout.size.bytes() as i32; + + if let Some(cton_ty) = fx.cton_type(layout.ty) { + let data = from.load_value(fx); store_workaround(fx, cton_ty, addr, data, 0); } else { for i in 0..size { let from = from.expect_byref(); - let byte = load_workaround(fx, types::I8, from, i); + let byte = load_workaround(fx, types::I8, from.0, i); store_workaround(fx, types::I8, addr, byte, i); } } @@ -199,17 +236,30 @@ impl<'a, 'tcx: 'a> CPlace { } } - pub fn place_field(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field, ty: Ty<'tcx>) -> (CPlace, layout::TyLayout<'tcx>) { + pub fn place_field(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CPlace<'tcx> { let base = self.expect_addr(); - let layout = fx.layout_of(ty); + let layout = self.layout(); let field_offset = layout.fields.offset(field.index()); + let field_ty = layout.field(&*fx, field.index()); if field_offset.bytes() > 0 { let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); - (CPlace::Addr(fx.bcx.ins().iadd(base, field_offset)), layout) + CPlace::Addr(fx.bcx.ins().iadd(base, field_offset), field_ty) } else { - (CPlace::Addr(base), layout) + CPlace::Addr(base, field_ty) } } + + pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + match self { + CPlace::Var(var, _) => CPlace::Var(var, layout), + CPlace::Addr(addr, _) => CPlace::Addr(addr, layout), + } + } + + pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx>, variant: usize) -> Self { + let layout = self.layout().for_variant(fx, variant); + self.unchecked_cast_to(layout) + } } pub fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { @@ -267,7 +317,7 @@ pub struct FunctionCx<'a, 'tcx: 'a> { pub param_substs: &'tcx Substs<'tcx>, pub bcx: FunctionBuilder<'a, Variable>, pub ebb_map: HashMap, - pub local_map: HashMap, + pub local_map: HashMap>, } impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> { @@ -298,7 +348,7 @@ impl<'a, 'tcx> HasTargetSpec for &'a FunctionCx<'a, 'tcx> { } } -impl<'f, 'tcx> FunctionCx<'f, 'tcx> { +impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { pub fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx> { @@ -317,7 +367,7 @@ impl<'f, 'tcx> FunctionCx<'f, 'tcx> { *self.ebb_map.get(&bb).unwrap() } - pub fn get_local_place(&mut self, local: Local) -> CPlace { + pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { *self.local_map.get(&local).unwrap() } From aee975e0e29e3a652844a7cda152a4e613588cc4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Jun 2018 20:29:32 +0200 Subject: [PATCH 0018/1566] Fix some bugs --- src/base.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/base.rs b/src/base.rs index a1052bbec488f..696c0b9dfde58 100644 --- a/src/base.rs +++ b/src/base.rs @@ -157,7 +157,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut offset: None, }); let ty = mir.local_decls[local].ty; - let cton_type = fx.cton_type(ty).unwrap_or(types::I64); + let cton_type = ::common::fixup_cton_ty(fx.cton_type(ty).unwrap_or(types::I64)); (local, fx.bcx.append_ebb_param(start_ebb, cton_type), ty, stack_slot) }).collect::>(); @@ -412,6 +412,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); } Rvalue::Discriminant(place) => { + let place = trans_place(fx, place); let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); let layout = lval.layout(); @@ -431,8 +432,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx layout::Variants::NicheFilling { .. } => {}, } - let discr = lval.to_cvalue(fx).value_field(fx, mir::Field::new(0)); - let discr_ty = lval.layout().ty; + let discr = place.to_cvalue(fx).value_field(fx, mir::Field::new(0)); + let discr_ty = discr.layout().ty; let lldiscr = discr.load_value(fx); match layout.variants { layout::Variants::Single { .. } => bug!(), From 75430b22e323f0f8a47bc0e5e3e2a6618c71ad95 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Jun 2018 20:30:47 +0200 Subject: [PATCH 0019/1566] Be honnest about {u/i}128 support --- src/common.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.rs b/src/common.rs index 89ee2666f03b3..09a8e2da0487a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -31,7 +31,7 @@ fn cton_type_from_ty(ty: Ty) -> Option { UintTy::U16 => types::I16, UintTy::U32 => types::I32, UintTy::U64 => types::I64, - UintTy::U128 => types::I64X2, + UintTy::U128 => unimplemented!(), UintTy::Usize => types::I64, } } @@ -41,7 +41,7 @@ fn cton_type_from_ty(ty: Ty) -> Option { IntTy::I16 => types::I16, IntTy::I32 => types::I32, IntTy::I64 => types::I64, - IntTy::I128 => types::I64X2, + IntTy::I128 => unimplemented!(), IntTy::Isize => types::I64, } } From 5508d44e2be18441db6bd596d5b9f63202b6b61b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Jun 2018 15:23:40 +0200 Subject: [PATCH 0020/1566] Support bool constants and fix a u8 const error --- example.rs | 12 ++++++------ src/base.rs | 4 ++++ src/common.rs | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/example.rs b/example.rs index dc78a6b10800a..399130be4de82 100644 --- a/example.rs +++ b/example.rs @@ -18,10 +18,10 @@ trait Mul { fn mul(self, rhs: RHS) -> Self::Output; } -impl Mul for u32 { - type Output = u32; +impl Mul for u8 { + type Output = Self; - fn mul(self, rhs: u32) -> u32 { + fn mul(self, rhs: Self) -> Self { self * rhs } } @@ -39,11 +39,11 @@ unsafe fn drop_in_place(to_drop: *mut T) { drop_in_place(to_drop); } -fn abc(a: u32) -> u32 { +fn abc(a: u8) -> u8 { a * 2 } -fn bcd(b: bool, a: u32) -> u32 { +fn bcd(b: bool, a: u8) -> u8 { if b { a * 2 } else { @@ -73,6 +73,6 @@ fn option_unwrap_or(o: BoolOption, d: bool) -> bool { } } -fn ret_42() -> u32 { +fn ret_42() -> u8 { 42 } diff --git a/src/base.rs b/src/base.rs index 696c0b9dfde58..5f1d7670f9bcb 100644 --- a/src/base.rs +++ b/src/base.rs @@ -514,6 +514,10 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx Literal::Value { value } => { let layout = fx.layout_of(const_.ty); match const_.ty.sty { + TypeVariants::TyBool => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + CValue::const_val(fx, const_.ty, bits as u64 as i64) + } TypeVariants::TyUint(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); CValue::const_val(fx, const_.ty, bits as u64 as i64) diff --git a/src/common.rs b/src/common.rs index 09a8e2da0487a..df6c88a2270eb 100644 --- a/src/common.rs +++ b/src/common.rs @@ -165,6 +165,7 @@ impl<'tcx> CValue<'tcx> { pub fn const_val<'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue<'tcx> where 'tcx: 'a { let cton_ty = fx.cton_type(ty).unwrap(); + let cton_ty = fixup_cton_ty(cton_ty); let layout = fx.layout_of(ty); CValue::ByVal(fx.bcx.ins().iconst(cton_ty, const_val), layout) } From 518aa42b496f2ac75b327fc406414b3ddb2e4932 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Jun 2018 15:47:58 +0200 Subject: [PATCH 0021/1566] Implement all binops for integers --- build.sh | 1 + src/base.rs | 69 ++++++++++++++++++++++++++++------------------------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/build.sh b/build.sh index 6cbc04f60e164..b4b58afbafe13 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,4 @@ cargo build || exit 1 rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.so example.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.so ../rust/src/libcore/lib.rs --crate-type lib -Og diff --git a/src/base.rs b/src/base.rs index 5f1d7670f9bcb..acedf51acf9e3 100644 --- a/src/base.rs +++ b/src/base.rs @@ -342,63 +342,37 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx }, Rvalue::BinaryOp(bin_op, lhs, rhs) => { let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let layout = fx.layout_of(ty); let lhs = trans_operand(fx, lhs).load_value(fx); let rhs = trans_operand(fx, rhs).load_value(fx); let res = match ty.sty { TypeVariants::TyUint(_) => { - match bin_op { - BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), - BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), - BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), - BinOp::Div => fx.bcx.ins().udiv(lhs, rhs), - bin_op => unimplemented!("checked uint bin op {:?} {:?} {:?}", bin_op, lhs, rhs), - } + trans_int_binop(fx, *bin_op, lhs, rhs, ty, false, false) } TypeVariants::TyInt(_) => { - match bin_op { - BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), - BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), - BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), - BinOp::Div => fx.bcx.ins().sdiv(lhs, rhs), - bin_op => unimplemented!("checked int bin op {:?} {:?} {:?}", bin_op, lhs, rhs), - } + trans_int_binop(fx, *bin_op, lhs, rhs, ty, true, false) } _ => unimplemented!(), }; - lval.write_cvalue(fx, CValue::ByVal(res, layout)); + lval.write_cvalue(fx, res); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { // TODO correctly write output tuple let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let layout = fx.layout_of(ty); let lhs = trans_operand(fx, lhs).load_value(fx); let rhs = trans_operand(fx, rhs).load_value(fx); let res = match ty.sty { TypeVariants::TyUint(_) => { - match bin_op { - BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), - BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), - BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), - BinOp::Div => fx.bcx.ins().udiv(lhs, rhs), - bin_op => unimplemented!("checked uint bin op {:?} {:?} {:?}", bin_op, lhs, rhs), - } + trans_int_binop(fx, *bin_op, lhs, rhs, ty, false, true) } TypeVariants::TyInt(_) => { - match bin_op { - BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), - BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), - BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), - BinOp::Div => fx.bcx.ins().sdiv(lhs, rhs), - bin_op => unimplemented!("checked int bin op {:?} {:?} {:?}", bin_op, lhs, rhs), - } + trans_int_binop(fx, *bin_op, lhs, rhs, ty, true, true) } _ => unimplemented!(), }; - lval.write_cvalue(fx, CValue::ByVal(res, layout)); + lval.write_cvalue(fx, res); unimplemented!("checked bin op {:?}", bin_op); } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { @@ -480,6 +454,37 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } } +fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, checked: bool) -> CValue<'tcx> { + let res = match (bin_op, signed) { + (BinOp::Add, _) => fx.bcx.ins().iadd(lhs, rhs), + (BinOp::Sub, _) => fx.bcx.ins().isub(lhs, rhs), + (BinOp::Mul, _) => fx.bcx.ins().imul(lhs, rhs), + (BinOp::Div, false) => fx.bcx.ins().udiv(lhs, rhs), + (BinOp::Div, true) => fx.bcx.ins().sdiv(lhs, rhs), + (BinOp::Rem, false) => fx.bcx.ins().urem(lhs, rhs), + (BinOp::Rem, true) => fx.bcx.ins().srem(lhs, rhs), + (BinOp::BitXor, _) => fx.bcx.ins().bxor(lhs, rhs), + (BinOp::BitAnd, _) => fx.bcx.ins().band(lhs, rhs), + (BinOp::BitOr, _) => fx.bcx.ins().bor(lhs, rhs), + (BinOp::Shl, _) => fx.bcx.ins().ishl(lhs, rhs), + (BinOp::Shr, false) => fx.bcx.ins().ushr(lhs, rhs), + (BinOp::Shr, true) => fx.bcx.ins().sshr(lhs, rhs), + (BinOp::Eq, _) => fx.bcx.ins().icmp(IntCC::Equal , lhs, rhs), + (BinOp::Lt, false) => fx.bcx.ins().icmp(IntCC::UnsignedLessThan , lhs, rhs), + (BinOp::Lt, true) => fx.bcx.ins().icmp(IntCC::SignedLessThan , lhs, rhs), + (BinOp::Le, false) => fx.bcx.ins().icmp(IntCC::UnsignedLessThanOrEqual , lhs, rhs), + (BinOp::Le, true) => fx.bcx.ins().icmp(IntCC::SignedLessThanOrEqual , lhs, rhs), + (BinOp::Ne, _) => fx.bcx.ins().icmp(IntCC::NotEqual , lhs, rhs), + (BinOp::Ge, false) => fx.bcx.ins().icmp(IntCC::UnsignedGreaterThanOrEqual , lhs, rhs), + (BinOp::Ge, true) => fx.bcx.ins().icmp(IntCC::SignedGreaterThanOrEqual , lhs, rhs), + (BinOp::Gt, false) => fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan , lhs, rhs), + (BinOp::Gt, true) => fx.bcx.ins().icmp(IntCC::SignedGreaterThan , lhs, rhs), + (BinOp::Offset, _) => bug!("bin op Offset on non ptr lhs: {:?} rhs: {:?}", lhs, rhs), + }; + // TODO: return correct value for checked binops + CValue::ByVal(res, fx.layout_of(ty)) +} + fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { match place { Place::Local(local) => fx.get_local_place(*local), From e42ab29517971d91d40da401da0bdff088d64d13 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Jun 2018 15:57:52 +0200 Subject: [PATCH 0022/1566] Implement some UnOp's --- src/base.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index acedf51acf9e3..af486ad013c5d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -352,13 +352,11 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx TypeVariants::TyInt(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, ty, true, false) } - _ => unimplemented!(), + _ => unimplemented!("bin op {:?} for {:?}", bin_op, ty), }; lval.write_cvalue(fx, res); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { - // TODO correctly write output tuple - let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); let lhs = trans_operand(fx, lhs).load_value(fx); let rhs = trans_operand(fx, rhs).load_value(fx); @@ -370,11 +368,24 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx TypeVariants::TyInt(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, ty, true, true) } - _ => unimplemented!(), + _ => unimplemented!("checked bin op {:?} for {:?}", bin_op, ty), }; lval.write_cvalue(fx, res); unimplemented!("checked bin op {:?}", bin_op); } + Rvalue::UnaryOp(un_op, operand) => { + let ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)); + let layout = fx.layout_of(ty); + let val = trans_operand(fx, operand).load_value(fx); + let res = match un_op { + UnOp::Not => fx.bcx.ins().bnot(val), + UnOp::Neg => match ty.sty { + TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val), + ref ty => unimplemented!("un op Neg for {:?}", ty), + } + }; + lval.write_cvalue(fx, CValue::ByVal(res, layout)); + } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); let layout = fx.layout_of(ty); From e7a68901404daac3111b3db4b815a1205e6563aa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Jun 2018 16:01:30 +0200 Subject: [PATCH 0023/1566] Implement Rvalue::Ref --- src/base.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index af486ad013c5d..e49bb4ba8c54a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -339,7 +339,12 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx Rvalue::Use(operand) => { let val = trans_operand(fx, operand); lval.write_cvalue(fx, val); - }, + } + Rvalue::Ref(_, _, place) => { + let place = trans_place(fx, place); + let addr = place.expect_addr(); + lval.write_cvalue(fx, CValue::ByVal(addr, dest_layout)); + } Rvalue::BinaryOp(bin_op, lhs, rhs) => { let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); let lhs = trans_operand(fx, lhs).load_value(fx); @@ -381,7 +386,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx UnOp::Not => fx.bcx.ins().bnot(val), UnOp::Neg => match ty.sty { TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val), - ref ty => unimplemented!("un op Neg for {:?}", ty), + _ => unimplemented!("un op Neg for {:?}", ty), } }; lval.write_cvalue(fx, CValue::ByVal(res, layout)); From d8c5152f309abe6dc220ea36744ac3698d4187e0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Jun 2018 20:13:51 +0200 Subject: [PATCH 0024/1566] Nicer verifier errors --- src/base.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index e49bb4ba8c54a..4546d23225e89 100644 --- a/src/base.rs +++ b/src/base.rs @@ -60,7 +60,8 @@ pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { match ::cretonne::codegen::verify_function(&f, &flags) { Ok(_) => {} Err(err) => { - tcx.sess.fatal(&format!("cretonne verify error: {}", err)); + let pretty_error = ::cretonne::codegen::print_errors::pretty_verifier_error(&f, None, &err); + tcx.sess.fatal(&format!("cretonne verify error:\n{}", pretty_error)); } } @@ -375,8 +376,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } _ => unimplemented!("checked bin op {:?} for {:?}", bin_op, ty), }; - lval.write_cvalue(fx, res); unimplemented!("checked bin op {:?}", bin_op); + lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, operand) => { let ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)); From 4bff31e36d5fcc67275cfc420adc8c6018b817a0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Jun 2018 20:27:43 +0200 Subject: [PATCH 0025/1566] Add drop shim --- src/base.rs | 10 ++++++++-- src/common.rs | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/base.rs b/src/base.rs index 4546d23225e89..5e6fa126c3132 100644 --- a/src/base.rs +++ b/src/base.rs @@ -281,8 +281,14 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut TerminatorKind::FalseUnwind { .. } => { bug!("shouldn't exist at trans {:?}", bb_data.terminator()); } - TerminatorKind::Drop { .. } | TerminatorKind::DropAndReplace { .. } | TerminatorKind::GeneratorDrop { .. } => { - unimplemented!("terminator {:?}", bb_data.terminator()); + TerminatorKind::Drop { target, .. } | TerminatorKind::DropAndReplace { target, .. } => { + // TODO call drop impl + // unimplemented!("terminator {:?}", bb_data.terminator()); + let target_ebb = fx.get_ebb(*target); + fx.bcx.ins().jump(target_ebb, &[]); + } + TerminatorKind::GeneratorDrop => { + unimplemented!("terminator GeneratorDrop"); } } } diff --git a/src/common.rs b/src/common.rs index df6c88a2270eb..157e3000bd835 100644 --- a/src/common.rs +++ b/src/common.rs @@ -31,7 +31,7 @@ fn cton_type_from_ty(ty: Ty) -> Option { UintTy::U16 => types::I16, UintTy::U32 => types::I32, UintTy::U64 => types::I64, - UintTy::U128 => unimplemented!(), + UintTy::U128 => unimplemented!("u128"), UintTy::Usize => types::I64, } } @@ -41,7 +41,7 @@ fn cton_type_from_ty(ty: Ty) -> Option { IntTy::I16 => types::I16, IntTy::I32 => types::I32, IntTy::I64 => types::I64, - IntTy::I128 => unimplemented!(), + IntTy::I128 => unimplemented!("i128"), IntTy::Isize => types::I64, } } @@ -213,7 +213,11 @@ 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"); + 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 + ); match self { CPlace::Var(var, _) => { From 7ca1f256cc936f2957d0685937ea6d6e8dd5cfec Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Jun 2018 16:27:11 +0200 Subject: [PATCH 0026/1566] Remove some cretonne bug workarounds and add ir comments --- 0001-Disable-stdsimd-in-libcore.patch | 29 ++++++++++++++++ src/base.rs | 49 +++++++++++++++++---------- src/common.rs | 43 ++++------------------- src/lib.rs | 1 + 4 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 0001-Disable-stdsimd-in-libcore.patch diff --git a/0001-Disable-stdsimd-in-libcore.patch b/0001-Disable-stdsimd-in-libcore.patch new file mode 100644 index 0000000000000..5521bea925b70 --- /dev/null +++ b/0001-Disable-stdsimd-in-libcore.patch @@ -0,0 +1,29 @@ +From cc175e6a3f59c7fe1523fd441214e0303f8fee80 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 30 Jun 2018 12:30:30 +0200 +Subject: [PATCH] Disable stdsimd in libcore + +--- + src/libcore/lib.rs | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs +index 40caee8554..f038d155a1 100644 +--- a/src/libcore/lib.rs ++++ b/src/libcore/lib.rs +@@ -240,6 +240,7 @@ macro_rules! test_v256 { ($item:item) => {}; } + macro_rules! test_v512 { ($item:item) => {}; } + #[allow(unused_macros)] + macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } } ++/* + #[path = "../stdsimd/coresimd/mod.rs"] + #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)] + #[unstable(feature = "stdsimd", issue = "48556")] +@@ -252,3 +253,4 @@ pub use coresimd::simd; + #[stable(feature = "simd_arch", since = "1.27.0")] + #[cfg(not(stage0))] + pub use coresimd::arch; ++*/ +-- +2.15.2 (Apple Git-101.1) + diff --git a/src/base.rs b/src/base.rs index 5e6fa126c3132..a044620fd74b2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -158,7 +158,7 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut offset: None, }); let ty = mir.local_decls[local].ty; - let cton_type = ::common::fixup_cton_ty(fx.cton_type(ty).unwrap_or(types::I64)); + let cton_type = fx.cton_type(ty).unwrap_or(types::I64); (local, fx.bcx.append_ebb_param(start_ebb, cton_type), ty, stack_slot) }).collect::>(); @@ -197,23 +197,24 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut trans_stmt(fx, stmt); } - match &bb_data.terminator().kind { + let inst = match &bb_data.terminator().kind { TerminatorKind::Goto { target } => { let ebb = fx.get_ebb(*target); - fx.bcx.ins().jump(ebb, &[]); + fx.bcx.ins().jump(ebb, &[]) } TerminatorKind::Return => { - fx.bcx.ins().return_(&[]); + fx.bcx.ins().return_(&[]) } TerminatorKind::Assert { cond, expected, msg: _, target, cleanup: _ } => { let cond = trans_operand(fx, cond).load_value(fx); let target = fx.get_ebb(*target); - if *expected { - fx.bcx.ins().brz(cond, target, &[]); + let inst = if *expected { + fx.bcx.ins().brz(cond, target, &[]) } else { - fx.bcx.ins().brnz(cond, target, &[]); - } + fx.bcx.ins().brnz(cond, target, &[]) + }; fx.bcx.ins().trap(TrapCode::User(!0)); + inst } TerminatorKind::SwitchInt { discr, switch_ty, values, targets } => { @@ -224,9 +225,10 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut jt_data.set_entry(*value as usize, ebb); } let mut jump_table = fx.bcx.create_jump_table(jt_data); - fx.bcx.ins().br_table(discr, jump_table); + let inst = fx.bcx.ins().br_table(discr, jump_table); let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); fx.bcx.ins().jump(otherwise_ebb, &[]); + inst } TerminatorKind::Call { func, args, destination, cleanup: _ } => { let func_ty = func.ty(&fx.mir.local_decls, fx.tcx); @@ -251,9 +253,9 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut } }) ).collect::>(); - match func { + let inst = match func { CValue::Func(func, _) => { - fx.bcx.ins().call(func, &args); + fx.bcx.ins().call(func, &args) } func => { let func = func.load_value(fx); @@ -263,18 +265,19 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut _ => bug!("Calling non function type {:?}", func_ty), }; let sig = fx.bcx.import_signature(cton_sig_from_fn_sig(fx.tcx, sig, fx.param_substs)); - fx.bcx.ins().call_indirect(sig, func, &args); + fx.bcx.ins().call_indirect(sig, func, &args) } - } + }; if let Some((_, dest)) = *destination { let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { fx.bcx.ins().trap(TrapCode::User(!0)); } + inst } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { - fx.bcx.ins().trap(TrapCode::User(!0)); + fx.bcx.ins().trap(TrapCode::User(!0)) } TerminatorKind::Yield { .. } | TerminatorKind::FalseEdges { .. } | @@ -285,12 +288,16 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut // TODO call drop impl // unimplemented!("terminator {:?}", bb_data.terminator()); let target_ebb = fx.get_ebb(*target); - fx.bcx.ins().jump(target_ebb, &[]); + fx.bcx.ins().jump(target_ebb, &[]) } TerminatorKind::GeneratorDrop => { unimplemented!("terminator GeneratorDrop"); } - } + }; + + let mut terminator_head = "\n".to_string(); + bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap(); + fx.bcx.func.comments[inst] = terminator_head; } fx.bcx.seal_all_blocks(); @@ -298,6 +305,8 @@ fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut } fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { + let nop_inst = fx.bcx.ins().nop(); + match &stmt.kind { StatementKind::SetDiscriminant { place, variant_index } => { let place = trans_place(fx, place); @@ -472,9 +481,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx rval => unimplemented!("rval {:?}", rval), } } - StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => {} + StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => { + fx.bcx.ins().nop(); + } _ => unimplemented!("stmt {:?}", stmt), } + + let inst = fx.bcx.func.layout.next_inst(nop_inst).unwrap(); + fx.bcx.func.layout.remove_inst(nop_inst); + fx.bcx.func.comments[inst] = format!("{:?}", stmt); } fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, checked: bool) -> CValue<'tcx> { diff --git a/src/common.rs b/src/common.rs index 157e3000bd835..35e3b9d365789 100644 --- a/src/common.rs +++ b/src/common.rs @@ -51,36 +51,6 @@ fn cton_type_from_ty(ty: Ty) -> Option { }) } -// FIXME(cretonne) fix types smaller than I32 -pub fn fixup_cton_ty(ty: Type) -> Type { - match ty { - types::I64X2 | types::I64 | types::I32 => ty, - _ => types::I32, - } -} - -// FIXME(cretonne) fix load.i8 -fn load_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, offset: i32) -> Value { - use cretonne::codegen::ir::types::*; - match ty { - I8 => fx.bcx.ins().uload8(I32, MemFlags::new(), addr, offset), - I16 => fx.bcx.ins().uload16(I32, MemFlags::new(), addr, offset), - // I32 and I64 work - _ => fx.bcx.ins().load(ty, MemFlags::new(), addr, offset), - } -} - -// FIXME(cretonne) fix store.i8 -fn store_workaround(fx: &mut FunctionCx, ty: Type, addr: Value, val: Value, offset: i32) { - use cretonne::codegen::ir::types::*; - match ty { - I8 => fx.bcx.ins().istore8(MemFlags::new(), val, addr, offset), - I16 => fx.bcx.ins().istore16(MemFlags::new(), val, addr, offset), - // I32 and I64 work - _ => fx.bcx.ins().store(MemFlags::new(), val, addr, offset), - }; -} - #[derive(Debug, Copy, Clone)] pub enum CValue<'tcx> { ByRef(Value, TyLayout<'tcx>), @@ -118,9 +88,9 @@ impl<'tcx> CValue<'tcx> { pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value where 'tcx: 'a{ match self { - CValue::ByRef(value, layout) => { + CValue::ByRef(addr, layout) => { let cton_ty = fx.cton_type(layout.ty).expect(&format!("{:?}", layout.ty)); - load_workaround(fx, cton_ty, value, 0) + fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, CValue::Func(func, _layout) => { @@ -165,7 +135,6 @@ impl<'tcx> CValue<'tcx> { pub fn const_val<'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue<'tcx> where 'tcx: 'a { let cton_ty = fx.cton_type(ty).unwrap(); - let cton_ty = fixup_cton_ty(cton_ty); let layout = fx.layout_of(ty); CValue::ByVal(fx.bcx.ins().iconst(cton_ty, const_val), layout) } @@ -229,12 +198,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { if let Some(cton_ty) = fx.cton_type(layout.ty) { let data = from.load_value(fx); - store_workaround(fx, cton_ty, addr, data, 0); + fx.bcx.ins().store(MemFlags::new(), data, addr, 0); } else { for i in 0..size { let from = from.expect_byref(); - let byte = load_workaround(fx, types::I8, from.0, i); - store_workaround(fx, types::I8, addr, byte, i); + let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from.0, i); + fx.bcx.ins().store(MemFlags::new(), byte, addr, i); } } } @@ -288,7 +257,7 @@ pub fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signatur }; Signature { params: Some(types::I64).into_iter() // First param is place to put return val - .chain(inputs.into_iter().map(|ty| fixup_cton_ty(cton_type_from_ty(ty).unwrap_or(types::I64)))) + .chain(inputs.into_iter().map(|ty| cton_type_from_ty(ty).unwrap_or(types::I64))) .map(AbiParam::new).collect(), returns: vec![], call_conv, diff --git a/src/lib.rs b/src/lib.rs index 39e7a8d82f578..5cd275b94db93 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![feature(rustc_private)] +#![allow(intra_doc_link_resolution_failure)] extern crate syntax; #[macro_use] From bb017326bef9e0a7af87043d6e7ce7a62a52da75 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Jun 2018 16:37:02 +0200 Subject: [PATCH 0027/1566] Move some code around --- src/base.rs | 142 ++++++++++++++-------------------------------------- src/lib.rs | 68 ++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 106 deletions(-) diff --git a/src/base.rs b/src/base.rs index a044620fd74b2..f077e8f9e4a52 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,121 +1,55 @@ -use rustc_mir::monomorphize::MonoItem; - -use cretonne_module::{Module, Backend, FuncId, Linkage}; -use cretonne_simplejit::{SimpleJITBuilder, SimpleJITBackend}; - -use std::any::Any; -use std::collections::HashMap; - use prelude::*; -pub fn trans_crate<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Box { - let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); - let metadata = tcx.encode_metadata(&link_meta); - - let mut module: Module = Module::new(SimpleJITBuilder::new()); - let mut context = Context::new(); - let mut def_id_fn_id_map = HashMap::new(); - - { - let mut cx = CodegenCx { - tcx, - module: &mut module, - def_id_fn_id_map: &mut def_id_fn_id_map, - }; - let cx = &mut cx; - - for mono_item in - collector::collect_crate_mono_items( - tcx, - collector::MonoItemCollectionMode::Eager - ).0 { - match mono_item { - MonoItem::Fn(inst) => match inst { - Instance { - def: InstanceDef::Item(def_id), - substs, - } => { - let sig = tcx.fn_sig(def_id); - let sig = cton_sig_from_fn_sig(tcx, sig, substs); - let func_id = { - let module = &mut cx.module; - *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { - module.declare_function(&tcx.absolute_item_path_str(def_id), Linkage::Local, &sig).unwrap() - }) - }; - - let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); +pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, context: &mut Context, mono_item: MonoItem<'tcx>) { + let tcx = cx.tcx; + + match mono_item { + MonoItem::Fn(inst) => match inst { + Instance { + def: InstanceDef::Item(def_id), + substs, + } => { + let sig = tcx.fn_sig(def_id); + let sig = cton_sig_from_fn_sig(tcx, sig, substs); + let func_id = { + let module = &mut cx.module; + *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { + module.declare_function(&tcx.absolute_item_path_str(def_id), Linkage::Local, &sig).unwrap() + }) + }; - let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(cx.tcx, Some(def_id), &mut mir).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); + let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); - trans_fn(cx, &mut f, inst); + let mut mir = ::std::io::Cursor::new(Vec::new()); + ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); + tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); - let mut cton = String::new(); - ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); - tcx.sess.warn(&cton); + ::base::trans_fn(cx, &mut f, inst); - let flags = settings::Flags::new(settings::builder()); - match ::cretonne::codegen::verify_function(&f, &flags) { - Ok(_) => {} - Err(err) => { - let pretty_error = ::cretonne::codegen::print_errors::pretty_verifier_error(&f, None, &err); - tcx.sess.fatal(&format!("cretonne verify error:\n{}", pretty_error)); - } - } + let mut cton = String::new(); + ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); + tcx.sess.warn(&cton); - context.func = f; - cx.module.define_function(func_id, &mut context).unwrap(); - context.clear(); + let flags = settings::Flags::new(settings::builder()); + match ::cretonne::codegen::verify_function(&f, &flags) { + Ok(_) => {} + Err(err) => { + let pretty_error = ::cretonne::codegen::print_errors::pretty_verifier_error(&f, None, &err); + tcx.sess.fatal(&format!("cretonne verify error:\n{}", pretty_error)); } - _ => {} } - _ => {} - } - } - } - - tcx.sess.warn("Compiled everything"); - - module.finalize_all(); - - tcx.sess.warn("Finalized everything"); - for (inst, func_id) in def_id_fn_id_map.iter() { - //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { - if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" { - continue; + context.func = f; + cx.module.define_function(func_id, context).unwrap(); + context.clear(); + } + _ => {} } - let finalized_function: *const u8 = module.finalize_function(*func_id); - /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = 0u32; - f(&mut res); - tcx.sess.warn(&format!("ret_42 returned {}", res));*/ - let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = false; - f(&mut res, &3, false); - tcx.sess.warn(&format!("option_unwrap_or returned {}", res)); + _ => {} } - - module.finish(); - - tcx.sess.fatal("unimplemented"); - - Box::new(::OngoingCodegen { - metadata: metadata, - //translated_module: Module::new(::cretonne_faerie::FaerieBuilder::new(, - crate_name: tcx.crate_name(LOCAL_CRATE), - }) -} - -struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { - tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &'a mut Module, - def_id_fn_id_map: &'a mut HashMap, FuncId>, } -fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) { +pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) { let mir = cx.tcx.optimized_mir(instance.def_id()); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); diff --git a/src/lib.rs b/src/lib.rs index 5cd275b94db93..d37352b89e869 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,7 @@ mod base; mod common; mod prelude { + pub use std::any::Any; pub use std::collections::HashMap; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; @@ -49,20 +50,30 @@ mod prelude { TypeFoldable, TypeVariants, }; pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc}; - pub use rustc_mir::monomorphize::collector; + pub use rustc_mir::monomorphize::{MonoItem, collector}; pub use cretonne::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, StackSlot, }; pub use cretonne::codegen::Context; pub use cretonne::prelude::*; + pub use cretonne_module::{Module, Backend, FuncId, Linkage}; + pub use cretonne_simplejit::{SimpleJITBuilder, SimpleJITBackend}; pub use common::Variable; pub use common::*; + + pub use CodegenCx; } use prelude::*; +pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { + pub tcx: TyCtxt<'a, 'tcx, 'tcx>, + pub module: &'a mut Module, + pub def_id_fn_id_map: &'a mut HashMap, FuncId>, +} + struct CretonneCodegenBackend(()); struct OngoingCodegen { @@ -151,7 +162,60 @@ impl CodegenBackend for CretonneCodegenBackend { } tcx.sess.abort_if_errors(); - base::trans_crate(tcx) + let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); + let metadata = tcx.encode_metadata(&link_meta); + + let mut module: Module = Module::new(SimpleJITBuilder::new()); + let mut context = Context::new(); + let mut def_id_fn_id_map = HashMap::new(); + + { + let mut cx = CodegenCx { + tcx, + module: &mut module, + def_id_fn_id_map: &mut def_id_fn_id_map, + }; + + for mono_item in + collector::collect_crate_mono_items( + tcx, + collector::MonoItemCollectionMode::Eager + ).0 { + base::trans_mono_item(&mut cx, &mut context, mono_item) + } + } + + tcx.sess.warn("Compiled everything"); + + module.finalize_all(); + + tcx.sess.warn("Finalized everything"); + + for (inst, func_id) in def_id_fn_id_map.iter() { + //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { + if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" { + continue; + } + let finalized_function: *const u8 = module.finalize_function(*func_id); + /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = 0u32; + f(&mut res); + tcx.sess.warn(&format!("ret_42 returned {}", res));*/ + let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = false; + f(&mut res, &3, false); + tcx.sess.warn(&format!("option_unwrap_or returned {}", res)); + } + + module.finish(); + + tcx.sess.fatal("unimplemented"); + + Box::new(::OngoingCodegen { + metadata: metadata, + //translated_module: Module::new(::cretonne_faerie::FaerieBuilder::new(, + crate_name: tcx.crate_name(LOCAL_CRATE), + }) } fn join_codegen_and_link( From 24e2eb25d485a654afd6b20fed8266c822c4f8ff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Jun 2018 16:38:49 +0200 Subject: [PATCH 0028/1566] Fix some warnings --- src/base.rs | 8 ++++---- src/common.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/base.rs b/src/base.rs index f077e8f9e4a52..27e3506ece3bd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -151,7 +151,7 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & inst } - TerminatorKind::SwitchInt { discr, switch_ty, values, targets } => { + TerminatorKind::SwitchInt { discr, switch_ty: _, values, targets } => { let discr = trans_operand(fx, discr).load_value(fx); let mut jt_data = JumpTableData::new(); for (i, value) in values.iter().enumerate() { @@ -426,7 +426,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx fx.bcx.func.comments[inst] = format!("{:?}", stmt); } -fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, checked: bool) -> CValue<'tcx> { +fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { let res = match (bin_op, signed) { (BinOp::Add, _) => fx.bcx.ins().iadd(lhs, rhs), (BinOp::Sub, _) => fx.bcx.ins().isub(lhs, rhs), @@ -466,10 +466,10 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) ProjectionElem::Deref => { CPlace::Addr(base.to_cvalue(fx).load_value(fx), fx.layout_of(place.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx))) } - ProjectionElem::Field(field, ty) => { + ProjectionElem::Field(field, _ty) => { base.place_field(fx, field) } - ProjectionElem::Downcast(adt_def, variant) => { + ProjectionElem::Downcast(_adt_def, variant) => { base.downcast_variant(fx, variant) } _ => unimplemented!("projection {:?}", projection), diff --git a/src/common.rs b/src/common.rs index 35e3b9d365789..eedd81d2efc6f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -196,7 +196,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(addr, layout) => { let size = layout.size.bytes() as i32; - if let Some(cton_ty) = fx.cton_type(layout.ty) { + if let Some(_) = fx.cton_type(layout.ty) { let data = from.load_value(fx); fx.bcx.ins().store(MemFlags::new(), data, addr, 0); } else { From 4beb9316410177b7d0e0dd3a40b437519131c786 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Jun 2018 18:22:20 +0200 Subject: [PATCH 0029/1566] Use DefPathBasedNames --- src/base.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 27e3506ece3bd..8c19aba1404af 100644 --- a/src/base.rs +++ b/src/base.rs @@ -14,7 +14,10 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let func_id = { let module = &mut cx.module; *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { - module.declare_function(&tcx.absolute_item_path_str(def_id), Linkage::Local, &sig).unwrap() + let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); + let mut name = String::new(); + def_path_based_names.push_instance_as_string(inst, &mut name); + module.declare_function(&name, Linkage::Local, &sig).unwrap() }) }; From aee8d7505792d1caa877664bdc4dc23f0ce9a3f2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Jun 2018 18:54:08 +0200 Subject: [PATCH 0030/1566] =?UTF-8?q?Bug=20on=20TyParam=20in=20cton=5Ftype?= =?UTF-8?q?=5Ffrom=5Fty=20and=20print=20mir=20before=20creating=20function?= =?UTF-8?q?=C2=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base.rs | 8 ++++---- src/common.rs | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index 8c19aba1404af..5b0aea73a6340 100644 --- a/src/base.rs +++ b/src/base.rs @@ -9,6 +9,10 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend def: InstanceDef::Item(def_id), substs, } => { + let mut mir = ::std::io::Cursor::new(Vec::new()); + ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); + tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); + let sig = tcx.fn_sig(def_id); let sig = cton_sig_from_fn_sig(tcx, sig, substs); let func_id = { @@ -23,10 +27,6 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); - let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); - ::base::trans_fn(cx, &mut f, inst); let mut cton = String::new(); diff --git a/src/common.rs b/src/common.rs index eedd81d2efc6f..2be8bf8375117 100644 --- a/src/common.rs +++ b/src/common.rs @@ -47,6 +47,7 @@ fn cton_type_from_ty(ty: Ty) -> Option { } TypeVariants::TyFnPtr(_) => types::I64, TypeVariants::TyRef(..) | TypeVariants::TyRawPtr(..) => types::I64, + TypeVariants::TyParam(_) => bug!("{:?}", ty), _ => return None, }) } From 92b14263a48ede02690e5a508d2c5ca171682b52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Jul 2018 11:59:42 +0200 Subject: [PATCH 0031/1566] Update to cranelift 0.14 --- Cargo.lock | 521 ++++++++------------------------------------- Cargo.toml | 10 +- build.sh | 4 +- src/base.rs | 18 +- src/common.rs | 20 +- src/lib.rs | 38 ++-- src/pretty_clif.rs | 34 +++ 7 files changed, 177 insertions(+), 468 deletions(-) create mode 100644 src/pretty_clif.rs diff --git a/Cargo.lock b/Cargo.lock index ac4d0c22320bf..d14ac70b2db87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,36 +1,10 @@ -[[package]] -name = "aho-corasick" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "atty" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "backtrace" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -45,11 +19,6 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "bitflags" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "1.0.3" @@ -62,98 +31,71 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "clap" -version = "2.31.2" +name = "cranelift" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-frontend 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "cretonne" -version = "0.12.0" +name = "cranelift-codegen" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-frontend 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cretonne-codegen" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cretonne-entity 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "cretonne-entity" -version = "0.12.0" +name = "cranelift-entity" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "cretonne-faerie" -version = "0.12.0" +name = "cranelift-frontend" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "faerie 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "cretonne-frontend" -version = "0.12.0" +name = "cranelift-module" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cretonne-module" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-entity 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "cretonne-native" -version = "0.12.0" +name = "cranelift-native" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "cretonne-simplejit" -version = "0.12.0" +name = "cranelift-simplejit" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-native 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-module 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-native 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,43 +107,23 @@ name = "dtoa" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "env_logger" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "errno" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "faerie" -version = "0.4.2" +name = "errno-dragonfly" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -209,7 +131,7 @@ name = "failure" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -224,36 +146,8 @@ dependencies = [ ] [[package]] -name = "goblin" -version = "0.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "goblin" -version = "0.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "humantime" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "indexmap" -version = "1.0.1" +name = "gcc" +version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -261,41 +155,11 @@ name = "itoa" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "lazy_static" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.42" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "log" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mach" version = "0.1.2" @@ -304,19 +168,6 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "memchr" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "proc-macro2" version = "0.4.6" @@ -325,11 +176,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "quick-error" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "quote" version = "0.3.15" @@ -345,44 +191,14 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "3.1.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "redox_syscall" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -391,7 +207,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -404,95 +220,58 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "rustc_codegen_cretonne" +name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "cretonne 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cretonne-simplejit 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-module 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-simplejit 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "scroll" -version = "0.8.0" +name = "rustc_version" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "scroll_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "scroll" +name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "scroll_derive" -version = "0.8.0" +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] -name = "scroll_derive" -version = "0.9.4" +name = "serde_derive" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "serde" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "serde_json" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "string-interner" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "strsim" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "structopt" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "structopt-derive" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -507,7 +286,7 @@ dependencies = [ [[package]] name = "syn" -version = "0.14.2" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -539,54 +318,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "termcolor" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termion" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "textwrap" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ucd-util" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-width" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicode-xid" version = "0.0.4" @@ -597,34 +331,6 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "utf8-ranges" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "vec_map" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.5" @@ -634,11 +340,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -649,93 +350,47 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "wincolor" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [metadata] -"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" -"checksum backtrace 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbdd17cd962b570302f5297aea8648d5923e22e555c2ed2d8b2e34eca646bf6d" +"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" -"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "49ec142f5768efb5b7622aebc3fdbdbb8950a4b9ba996393cb76ef7466e8747d" -"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18" -"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536" -"checksum cretonne 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03610d69c786a211347d0be3f7da59cb03b025ef2cd83f66ea98103728f42ecc" -"checksum cretonne-codegen 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e7e43ab7952e998ea8da4bcda3b53d398396b9b691df44a040be5486a4935ef" -"checksum cretonne-entity 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4109dcfc0c7b8e11ad92a702d3f5df435d2782012118aa75566d2d0db586da3a" -"checksum cretonne-faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e8d665b4ac93c254f79e861696db5a1297133c8c8603e5cd06b26250568a9cb0" -"checksum cretonne-frontend 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e0238865d537393f73598542a906dadfe85fcf070c293cdf882ece170d197455" -"checksum cretonne-module 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "232354804f19cb12bf2ac6f715d26df81a7242b3693a1a6cd2774ff89311e283" -"checksum cretonne-native 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66d768de850f29bbb2cda9eeed168369c66263bee9068ca1b9af28000216116c" -"checksum cretonne-simplejit 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54d9e73a7f5bb0529be747a86a164e087c96edfd89e30b6d6f92653b70fc9943" +"checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" +"checksum cranelift 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8bd8d55e2609a5b03377e1fb0919d57e8eda4f7c29dc55b665d4c2f17e9f109" +"checksum cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01eb8fe68d2c0b98fef2ec1f618eaa6d73e691b0451a1b42d9f822924ebb7848" +"checksum cranelift-entity 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae4f5796a9618786ddc8e8ec2c879a0e43e611b924657dc0929f475bf7efd6d4" +"checksum cranelift-frontend 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1ef7683f7517b08df0d0c90b615cb9be361bc394f03b6117d51f7be83db21c2" +"checksum cranelift-module 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05ac4232a9fac77aa7d29ae713ae7817e3efa730f007c0f528a279cd68a6824d" +"checksum cranelift-native 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb9bfdcca2c05a260408ca018846cd4b8ad87c5eea1623627f97d34cf82c2b31" +"checksum cranelift-simplejit 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1587398fde1c2970a1da7fe9ac687bdcad39bb398bea9ae08276153390c55" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" -"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" -"checksum errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c858c42ac0b88532f48fca88b0ed947cad4f1f64d904bcd6c9f138f7b95d70" -"checksum faerie 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ffaaaa682748ec082a384edbf1d468ce10ad1b39dcfa3a8c3c0dbc5e6cff754c" +"checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" +"checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" -"checksum goblin 0.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2a5fea7ad351be7398e08003ea92a16bbba9a23c2a0c95d4e37d178276508217" -"checksum goblin 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "5e3ba9fec4dc9a09553388bff2724d3bf06bd64013539f2d3e1e3838eefb310a" -"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" -"checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" +"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" "checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fddaa003a65722a7fb9e26b0ce95921fe4ba590542ced664d8ce2fa26f9f3ac" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" -"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" -"checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "effdb53b25cdad54f8f48843d67398f7ef2e14f12c1b4cb4effc549a6462a4d6" -"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" -"checksum raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "233ec1847057cf4d4591a0d76908aa12812140b11ea7d7d05b4c38cadb069c31" -"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3" -"checksum regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05b06a75f5217880fc5e905952a42750bf44787e56a6c6d6852ed0992f5e1d54" +"checksum raw-cpuid 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90e0d3209fac374e168cef2d8806dde7b31ef0ee82a965bcc0bec562c078a6f5" "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" "checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" -"checksum scroll 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b13864e1e0b3ed661d7206d512b8d1c4970f7fd9de23ae4e9b4331f0c25559e8" -"checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" -"checksum scroll_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a67086db2a44e94311fc4c02ec3f4751bda0fca9d87fd4e1bfe1cef55e9411d" -"checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" -"checksum serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a2d9a9ac5120e0f768801ca2b58ad6eec929dc9d1d616c162f208869c2ce95" -"checksum serde_json 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "fc97cccc2959f39984524026d760c08ef0dd5f0f5948c8d31797dbfae458c875" -"checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" -"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" -"checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" +"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum serde 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)" = "429fcc4efa8a11341b5422c2ace724daba276c1748467e869478f53c0ba4562e" +"checksum serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3525a779832b08693031b8ecfb0de81cd71cfd3812088fafe9a7496789572124" +"checksum serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "84b8035cabe9b35878adec8ac5fe03d5f6bc97ff6edd7ccb96b44c1276ba390e" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c67da57e61ebc7b7b6fff56bb34440ca3a83db037320b0507af4c10368deda7d" +"checksum syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2beff8ebc3658f07512a413866875adddd20f4fd47b2a4e6c9da65cd281baaea" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" "checksum target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71b0a95ba4eff593189d912039fba46ce6ca1876ea6c16830e15340919d0a250" -"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" -"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" -"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" -"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" diff --git a/Cargo.toml b/Cargo.toml index d1acda9c43032..b2c212baedfdb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rustc_codegen_cretonne" +name = "rustc_codegen_cranelift" version = "0.1.0" authors = ["bjorn3 "] @@ -7,7 +7,7 @@ authors = ["bjorn3 "] crate-type = ["dylib"] [dependencies] -cretonne = "0.12.0" -cretonne-module = "0.12.0" -cretonne-simplejit = "0.12.0" -cretonne-faerie = "0.12.0" +cranelift = "0.14.0" +cranelift-module = "0.14.0" +cranelift-simplejit = "0.14.0" +#cranelift-faerie = "0.14.0" diff --git a/build.sh b/build.sh index b4b58afbafe13..8795292097ee0 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ cargo build || exit 1 -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.so example.rs --crate-type lib -Og -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cretonne.so ../rust/src/libcore/lib.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.dylib example.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.dylib ../rust_fork/src/libcore/lib.rs --crate-type lib -Og diff --git a/src/base.rs b/src/base.rs index 5b0aea73a6340..29ec4c14d2c3f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -27,17 +27,18 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); - ::base::trans_fn(cx, &mut f, inst); + let comments = ::base::trans_fn(cx, &mut f, inst); let mut cton = String::new(); - ::cretonne::codegen::write_function(&mut cton, &f, None).unwrap(); + ::cranelift::codegen::write_function(&mut cton, &f, None).unwrap(); tcx.sess.warn(&cton); let flags = settings::Flags::new(settings::builder()); - match ::cretonne::codegen::verify_function(&f, &flags) { + match ::cranelift::codegen::verify_function(&f, &flags) { Ok(_) => {} Err(err) => { - let pretty_error = ::cretonne::codegen::print_errors::pretty_verifier_error(&f, None, &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)); } } @@ -52,7 +53,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } } -pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) { +pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) -> HashMap { let mir = cx.tcx.optimized_mir(instance.def_id()); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -77,6 +78,7 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & }, ebb_map, local_map: HashMap::new(), + comments: HashMap::new(), }; let fx = &mut fx; @@ -234,11 +236,13 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & let mut terminator_head = "\n".to_string(); bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap(); - fx.bcx.func.comments[inst] = terminator_head; + fx.add_comment(inst, terminator_head); } fx.bcx.seal_all_blocks(); fx.bcx.finalize(); + + fx.comments.clone() } fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { @@ -426,7 +430,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let inst = fx.bcx.func.layout.next_inst(nop_inst).unwrap(); fx.bcx.func.layout.remove_inst(nop_inst); - fx.bcx.func.comments[inst] = format!("{:?}", stmt); + fx.add_comment(inst, format!("{:?}", stmt)); } fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { diff --git a/src/common.rs b/src/common.rs index 2be8bf8375117..ba922d16d3063 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,13 +1,15 @@ extern crate rustc_target; +use std::borrow::Cow; + use syntax::ast::{IntTy, UintTy}; use self::rustc_target::spec::{HasTargetSpec, Target}; -use cretonne_module::{Module, Linkage, FuncId}; +use cranelift_module::{Module, Linkage, FuncId}; use prelude::*; -pub type CurrentBackend = ::cretonne_simplejit::SimpleJITBackend; +pub type CurrentBackend = ::cranelift_simplejit::SimpleJITBackend; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct Variable(Local); @@ -293,6 +295,7 @@ pub struct FunctionCx<'a, 'tcx: 'a> { pub bcx: FunctionBuilder<'a, Variable>, pub ebb_map: HashMap, pub local_map: HashMap>, + pub comments: HashMap, } impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> { @@ -355,4 +358,17 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { }); module.declare_func_in_func(func_id, &mut self.bcx.func) } + + pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { + use std::collections::hash_map::Entry; + match self.comments.entry(inst) { + Entry::Occupied(mut occ) => { + occ.get_mut().push('\n'); + occ.get_mut().push_str(comment.into().as_ref()); + } + Entry::Vacant(vac) => { + vac.insert(comment.into().into_owned()); + } + } + } } diff --git a/src/lib.rs b/src/lib.rs index d37352b89e869..f1c47ddb7cfd5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,10 +9,10 @@ extern crate rustc_codegen_utils; extern crate rustc_incremental; extern crate rustc_data_structures; -extern crate cretonne; -extern crate cretonne_module; -extern crate cretonne_simplejit; -extern crate cretonne_faerie; +extern crate cranelift; +extern crate cranelift_module; +extern crate cranelift_simplejit; +//extern crate cranelift_faerie; use syntax::symbol::Symbol; use rustc::session::{ @@ -35,6 +35,7 @@ use std::io::Write; mod base; mod common; +mod pretty_clif; mod prelude { pub use std::any::Any; @@ -52,13 +53,13 @@ mod prelude { pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc}; pub use rustc_mir::monomorphize::{MonoItem, collector}; - pub use cretonne::codegen::ir::{ - condcodes::IntCC, function::Function, ExternalName, FuncRef, StackSlot, + pub use cranelift::codegen::ir::{ + condcodes::IntCC, function::Function, ExternalName, FuncRef, StackSlot, Inst }; - pub use cretonne::codegen::Context; - pub use cretonne::prelude::*; - pub use cretonne_module::{Module, Backend, FuncId, Linkage}; - pub use cretonne_simplejit::{SimpleJITBuilder, SimpleJITBackend}; + pub use cranelift::codegen::Context; + pub use cranelift::prelude::*; + pub use cranelift_module::{Module, Backend, FuncId, Linkage}; + pub use cranelift_simplejit::{SimpleJITBuilder, SimpleJITBackend}; pub use common::Variable; pub use common::*; @@ -74,21 +75,21 @@ pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub def_id_fn_id_map: &'a mut HashMap, FuncId>, } -struct CretonneCodegenBackend(()); +struct CraneliftCodegenBackend(()); struct OngoingCodegen { metadata: EncodedMetadata, - //translated_module: Module, + //translated_module: Module, crate_name: Symbol, } -impl CretonneCodegenBackend { +impl CraneliftCodegenBackend { fn new() -> Box { - Box::new(CretonneCodegenBackend(())) + Box::new(CraneliftCodegenBackend(())) } } -impl CodegenBackend for CretonneCodegenBackend { +impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { for cty in sess.opts.crate_types.iter() { match *cty { @@ -118,7 +119,6 @@ impl CodegenBackend for CretonneCodegenBackend { }; providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); - providers.wasm_custom_sections = |_tcx, _crate| Lrc::new(Vec::new()); } fn provide_extern(&self, providers: &mut Providers) { providers.is_reachable_non_generic = |_tcx, _defid| true; @@ -213,7 +213,7 @@ impl CodegenBackend for CretonneCodegenBackend { Box::new(::OngoingCodegen { metadata: metadata, - //translated_module: Module::new(::cretonne_faerie::FaerieBuilder::new(, + //translated_module: Module::new(::cranelift_faerie::FaerieBuilder::new(, crate_name: tcx.crate_name(LOCAL_CRATE), }) } @@ -252,8 +252,8 @@ impl CodegenBackend for CretonneCodegenBackend { } } -/// This is the entrypoint for a hot plugged rustc_codegen_cretonne +/// This is the entrypoint for a hot plugged rustc_codegen_cranelift #[no_mangle] pub fn __rustc_codegen_backend() -> Box { - CretonneCodegenBackend::new() + CraneliftCodegenBackend::new() } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs new file mode 100644 index 0000000000000..a3eb848f91af2 --- /dev/null +++ b/src/pretty_clif.rs @@ -0,0 +1,34 @@ +use std::collections::HashMap; +use std::fmt; + +use cranelift::codegen::{ + ir::{Function, Inst}, + FuncWriter, + PlainWriter, +}; +use cranelift::prelude::*; + +pub struct CommentWriter(pub HashMap); + +impl FuncWriter for CommentWriter { + fn write_instruction( + &mut self, + w: &mut dyn fmt::Write, + func: &Function, + isa: Option<&dyn isa::TargetIsa>, + inst: Inst, + indent: usize, + ) -> fmt::Result { + + PlainWriter.write_instruction(w, func, isa, inst, indent) + } + + fn write_preamble( + &mut self, + w: &mut dyn fmt::Write, + func: &Function, + reg_info: Option<&isa::RegInfo>, + ) -> Result { + PlainWriter.write_preamble(w, func, reg_info) + } +} From 0c592a6bb11a3cc2e1537c5771807347c5b814a3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Jun 2018 18:56:29 +0200 Subject: [PATCH 0032/1566] Add some warnings --- src/base.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 29ec4c14d2c3f..41ff8ec5d2447 100644 --- a/src/base.rs +++ b/src/base.rs @@ -47,9 +47,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend cx.module.define_function(func_id, context).unwrap(); context.clear(); } - _ => {} + inst => cx.tcx.sess.warn(&format!("Unimplemented instance {:?}", inst)), } - _ => {} + mono_item => cx.tcx.sess.warn(&format!("Unimplemented mono item {:?}", mono_item)), } } From 25fef301861969093aac50ea68207c34cddbb88d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Jul 2018 12:21:45 +0200 Subject: [PATCH 0033/1566] More debugging output --- src/base.rs | 4 ++-- src/common.rs | 24 ++++++++++++++++++++++-- src/pretty_clif.rs | 7 ++++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/base.rs b/src/base.rs index 41ff8ec5d2447..b07fddb0ef810 100644 --- a/src/base.rs +++ b/src/base.rs @@ -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)); } diff --git a/src/common.rs b/src/common.rs index ba922d16d3063..feb3857b86cd3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -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, } +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>; diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index a3eb848f91af2..d1194660080bd 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -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) } From a95a6729b1c5d8b0cf6c43a35824462a330082e8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Jul 2018 16:39:49 +0200 Subject: [PATCH 0034/1566] Implement some more stuff and ignore some unimplemented stuff instead of panicking --- example.rs | 8 +++++ src/base.rs | 84 +++++++++++++++++++++++++++++++-------------------- src/common.rs | 42 +++++++++++++++++++------- src/lib.rs | 5 +-- 4 files changed, 93 insertions(+), 46 deletions(-) diff --git a/example.rs b/example.rs index 399130be4de82..94215a50fc1b0 100644 --- a/example.rs +++ b/example.rs @@ -76,3 +76,11 @@ fn option_unwrap_or(o: BoolOption, d: bool) -> bool { fn ret_42() -> u8 { 42 } + +fn return_str() -> &'static str { + "hello world" +} + +fn promoted_val() -> &'static u8 { + &(1 * 2) +} diff --git a/src/base.rs b/src/base.rs index b07fddb0ef810..c523c3979213b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -27,7 +27,13 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); - let comments = ::base::trans_fn(cx, &mut f, inst); + let comments = match ::base::trans_fn(cx, &mut f, inst){ + Ok(comments) => comments, + Err(err) => { + tcx.sess.err(&err); + return; + } + }; let mut writer = ::pretty_clif::CommentWriter(comments); let mut cton = String::new(); @@ -53,7 +59,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } } -pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) -> HashMap { +pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) -> Result, String> { let mir = cx.tcx.optimized_mir(instance.def_id()); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -133,7 +139,7 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & fx.bcx.switch_to_block(ebb); for stmt in &bb_data.statements { - trans_stmt(fx, stmt); + trans_stmt(fx, stmt)?; } let inst = match &bb_data.terminator().kind { @@ -242,10 +248,12 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & fx.bcx.seal_all_blocks(); fx.bcx.finalize(); - fx.comments.clone() + Ok(fx.comments.clone()) } -fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) { +fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) -> Result<(), String> { + fx.tcx.sess.warn(&format!("stmt {:?}", stmt)); + let nop_inst = fx.bcx.ins().nop(); match &stmt.kind { @@ -253,7 +261,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let place = trans_place(fx, place); let layout = place.layout(); if layout.for_variant(&*fx, *variant_index).abi == layout::Abi::Uninhabited { - return; + return Ok(()); } match layout.variants { layout::Variants::Single { index } => { @@ -309,10 +317,10 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let res = match ty.sty { TypeVariants::TyUint(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, ty, false, false) + trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false, false) } TypeVariants::TyInt(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, ty, true, false) + trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true, false) } _ => unimplemented!("bin op {:?} for {:?}", bin_op, ty), }; @@ -332,7 +340,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } _ => unimplemented!("checked bin op {:?} for {:?}", bin_op, ty), }; - unimplemented!("checked bin op {:?}", bin_op); + return Err(format!("checked bin op {:?}", bin_op)); lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, operand) => { @@ -373,7 +381,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx |def| def.discriminant_for_variant(fx.tcx, index).val); let val = CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); lval.write_cvalue(fx, val); - return; + return Ok(()); } layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {}, @@ -431,6 +439,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let inst = fx.bcx.func.layout.next_inst(nop_inst).unwrap(); fx.bcx.func.layout.remove_inst(nop_inst); fx.add_comment(inst, format!("{:?}", stmt)); + + Ok(()) } fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { @@ -487,6 +497,8 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) } fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue<'tcx> { + use rustc::mir::interpret::{Scalar, ConstValue, GlobalId}; + match operand { Operand::Move(place) | Operand::Copy(place) => { @@ -494,30 +506,36 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx cplace.to_cvalue(fx) }, Operand::Constant(const_) => { - match const_.literal { - Literal::Value { value } => { - let layout = fx.layout_of(const_.ty); - match const_.ty.sty { - TypeVariants::TyBool => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as u64 as i64) - } - TypeVariants::TyUint(_) => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as u64 as i64) - } - TypeVariants::TyInt(_) => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as i128 as i64) - } - TypeVariants::TyFnDef(def_id, substs) => { - let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); - CValue::Func(func_ref, fx.layout_of(const_.ty)) - } - _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), - } + let value = match const_.literal { + Literal::Value { value } => value, + Literal::Promoted { index } => fx + .tcx + .const_eval(ParamEnv::reveal_all().and(GlobalId { + instance: fx.instance, + promoted: Some(index), + })) + .unwrap(), + }; + + let layout = fx.layout_of(const_.ty); + match const_.ty.sty { + TypeVariants::TyBool => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + CValue::const_val(fx, const_.ty, bits as u64 as i64) + } + TypeVariants::TyUint(_) => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + CValue::const_val(fx, const_.ty, bits as u64 as i64) + } + TypeVariants::TyInt(_) => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + CValue::const_val(fx, const_.ty, bits as i128 as i64) + } + TypeVariants::TyFnDef(def_id, substs) => { + let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); + CValue::Func(func_ref, fx.layout_of(const_.ty)) } - _ => unimplemented!() + _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), } } } diff --git a/src/common.rs b/src/common.rs index feb3857b86cd3..cf08ddc281a7b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -25,7 +25,7 @@ impl EntityRef for Variable { } } -fn cton_type_from_ty(ty: Ty) -> Option { +fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> Option { Some(match ty.sty { TypeVariants::TyBool => types::I8, TypeVariants::TyUint(size) => { @@ -49,7 +49,13 @@ fn cton_type_from_ty(ty: Ty) -> Option { } } TypeVariants::TyFnPtr(_) => types::I64, - TypeVariants::TyRef(..) | TypeVariants::TyRawPtr(..) => types::I64, + TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) | TypeVariants::TyRef(_, ty, _) => { + if ty.is_sized(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { + types::I64 + } else { + return None; + } + } TypeVariants::TyParam(_) => bug!("{:?}", ty), _ => return None, }) @@ -205,10 +211,22 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let data = from.load_value(fx); fx.bcx.ins().store(MemFlags::new(), data, addr, 0); } else { - for i in 0..size { - let from = from.expect_byref(); - let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from.0, i); - fx.bcx.ins().store(MemFlags::new(), byte, addr, i); + let from = from.expect_byref(); + let mut offset = 0; + while size - offset >= 8 { + let byte = fx.bcx.ins().load(types::I64, MemFlags::new(), from.0, offset); + fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); + offset += 8; + } + while size - offset >= 4 { + let byte = fx.bcx.ins().load(types::I32, MemFlags::new(), from.0, offset); + fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); + offset += 4; + } + while offset < size { + let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from.0, offset); + fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); + offset += 1; } } } @@ -243,16 +261,18 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); - cton_sig_from_mono_fn_sig(sig) + cton_sig_from_mono_fn_sig(tcx, sig) } pub fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>) -> Signature { let fn_ty = inst.ty(tcx); let sig = fn_ty.fn_sig(tcx); - cton_sig_from_mono_fn_sig(sig) + cton_sig_from_mono_fn_sig(tcx, sig) } -pub fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signature { +pub fn cton_sig_from_mono_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>) -> Signature { + // TODO: monomorphize signature + let sig = sig.skip_binder(); let inputs = sig.inputs(); let _output = sig.output(); @@ -262,7 +282,7 @@ pub fn cton_sig_from_mono_fn_sig<'a ,'tcx: 'a>(sig: PolyFnSig<'tcx>) -> Signatur }; Signature { params: Some(types::I64).into_iter() // First param is place to put return val - .chain(inputs.into_iter().map(|ty| cton_type_from_ty(ty).unwrap_or(types::I64))) + .chain(inputs.into_iter().map(|ty| cton_type_from_ty(tcx, ty).unwrap_or(types::I64))) .map(AbiParam::new).collect(), returns: vec![], call_conv, @@ -358,7 +378,7 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { } pub fn cton_type(&self, ty: Ty<'tcx>) -> Option { - cton_type_from_ty(self.monomorphize(&ty)) + cton_type_from_ty(self.tcx, self.monomorphize(&ty)) } pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { diff --git a/src/lib.rs b/src/lib.rs index f1c47ddb7cfd5..40ffaa5e0a0f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,14 +41,15 @@ mod prelude { pub use std::any::Any; pub use std::collections::HashMap; + pub use syntax::codemap::DUMMY_SP; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; pub use rustc::mir; pub use rustc::mir::*; pub use rustc::session::Session; - pub use rustc::ty::layout::{self, LayoutOf, TyLayout}; + pub use rustc::ty::layout::{self, LayoutOf, TyLayout, Size}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, - TypeFoldable, TypeVariants, + TypeFoldable, TypeVariants, TypeAndMut, }; pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc}; pub use rustc_mir::monomorphize::{MonoItem, collector}; From 4694fa4f3dc0044451764b6afa170a68f0125a57 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Jul 2018 16:45:20 +0200 Subject: [PATCH 0035/1566] Move const val handling to constant.rs --- src/base.rs | 34 +--------------------------------- src/constant.rs | 37 +++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 3 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 src/constant.rs diff --git a/src/base.rs b/src/base.rs index c523c3979213b..c7f07542b0e84 100644 --- a/src/base.rs +++ b/src/base.rs @@ -497,8 +497,6 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) } fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue<'tcx> { - use rustc::mir::interpret::{Scalar, ConstValue, GlobalId}; - match operand { Operand::Move(place) | Operand::Copy(place) => { @@ -506,37 +504,7 @@ fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx cplace.to_cvalue(fx) }, Operand::Constant(const_) => { - let value = match const_.literal { - Literal::Value { value } => value, - Literal::Promoted { index } => fx - .tcx - .const_eval(ParamEnv::reveal_all().and(GlobalId { - instance: fx.instance, - promoted: Some(index), - })) - .unwrap(), - }; - - let layout = fx.layout_of(const_.ty); - match const_.ty.sty { - TypeVariants::TyBool => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as u64 as i64) - } - TypeVariants::TyUint(_) => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as u64 as i64) - } - TypeVariants::TyInt(_) => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as i128 as i64) - } - TypeVariants::TyFnDef(def_id, substs) => { - let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); - CValue::Func(func_ref, fx.layout_of(const_.ty)) - } - _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), - } + ::constant::trans_constant(fx, const_) } } } diff --git a/src/constant.rs b/src/constant.rs new file mode 100644 index 0000000000000..ab3e4376a820f --- /dev/null +++ b/src/constant.rs @@ -0,0 +1,37 @@ +use prelude::*; + +pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Constant<'tcx>) -> CValue<'tcx> { + use rustc::mir::interpret::{Scalar, ConstValue, GlobalId}; + + let value = match const_.literal { + Literal::Value { value } => value, + Literal::Promoted { index } => fx + .tcx + .const_eval(ParamEnv::reveal_all().and(GlobalId { + instance: fx.instance, + promoted: Some(index), + })) + .unwrap(), + }; + + let layout = fx.layout_of(const_.ty); + match const_.ty.sty { + TypeVariants::TyBool => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + CValue::const_val(fx, const_.ty, bits as u64 as i64) + } + TypeVariants::TyUint(_) => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + CValue::const_val(fx, const_.ty, bits as u64 as i64) + } + TypeVariants::TyInt(_) => { + let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + CValue::const_val(fx, const_.ty, bits as i128 as i64) + } + TypeVariants::TyFnDef(def_id, substs) => { + let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); + CValue::Func(func_ref, fx.layout_of(const_.ty)) + } + _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), + } +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 40ffaa5e0a0f4..e8cab41d81074 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,7 @@ use std::fs::File; use std::io::Write; mod base; +mod constant; mod common; mod pretty_clif; From 42ea584b8e22361ff6c5a0b23bad812c6e1aae47 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 29 Jun 2018 18:57:59 +0200 Subject: [PATCH 0036/1566] Better handling of ref types equality in write_cvalue --- src/common.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/common.rs b/src/common.rs index cf08ddc281a7b..83f992380c0c5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -192,12 +192,28 @@ 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 {:?} {:?}\n\n{:#?}", - self.layout().ty.sty, from.layout().ty.sty, - fx, - ); + match (&self.layout().ty.sty, &from.layout().ty.sty) { + (TypeVariants::TyRef(_, t, dest_mut), TypeVariants::TyRef(_, u, src_mut)) if ( + if *dest_mut != ::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { + false + } else if t != u { + false + } else { + true + } + ) => { + // &mut T -> &T is allowed + // &'a T -> &'b T is allowed + } + _ => { + assert_eq!( + self.layout().ty, from.layout().ty, + "Can't write value of incompatible type to place {:?} {:?}\n\n{:#?}", + self.layout().ty.sty, from.layout().ty.sty, + fx, + ); + } + } match self { CPlace::Var(var, _) => { From ee45f7d6bc938feeeebb66166d87d18ba3e280e5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 15 Jul 2018 20:30:03 +0200 Subject: [PATCH 0037/1566] Add cranelift submodule --- .gitmodules | 3 ++ Cargo.lock | 137 +++++++++++----------------------------------------- Cargo.toml | 11 +++-- build.sh | 4 +- cranelift | 1 + 5 files changed, 42 insertions(+), 114 deletions(-) create mode 100644 .gitmodules create mode 160000 cranelift diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000..d875e5a4ccf53 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cranelift"] + path = cranelift + url = https://github.com/CraneStation/cranelift.git diff --git a/Cargo.lock b/Cargo.lock index d14ac70b2db87..2c8b07329b07f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,6 +19,11 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bitflags" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bitflags" version = "1.0.3" @@ -37,68 +42,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-frontend 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0", + "cranelift-frontend 0.14.0", ] [[package]] name = "cranelift-codegen" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-entity 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-entity 0.14.0", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-entity" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-frontend" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0", ] [[package]] name = "cranelift-module" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-entity 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0", + "cranelift-entity 0.14.0", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0", + "raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-module 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-native 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.14.0", + "cranelift-module 0.14.0", + "cranelift-native 0.14.0", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -168,37 +166,18 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "proc-macro2" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "quote" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "quote" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "raw-cpuid" -version = "4.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -223,47 +202,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "cranelift 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-module 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-simplejit 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift 0.14.0", + "cranelift-module 0.14.0", + "cranelift-simplejit 0.14.0", ] -[[package]] -name = "rustc_version" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "serde" version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "serde_derive" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "serde_json" version = "1.0.22" @@ -284,16 +232,6 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syn" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "synom" version = "0.11.3" @@ -313,7 +251,7 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.0.2" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -326,11 +264,6 @@ name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.5" @@ -353,16 +286,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" +"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "49ec142f5768efb5b7622aebc3fdbdbb8950a4b9ba996393cb76ef7466e8747d" "checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" -"checksum cranelift 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8bd8d55e2609a5b03377e1fb0919d57e8eda4f7c29dc55b665d4c2f17e9f109" -"checksum cranelift-codegen 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01eb8fe68d2c0b98fef2ec1f618eaa6d73e691b0451a1b42d9f822924ebb7848" -"checksum cranelift-entity 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ae4f5796a9618786ddc8e8ec2c879a0e43e611b924657dc0929f475bf7efd6d4" -"checksum cranelift-frontend 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1ef7683f7517b08df0d0c90b615cb9be361bc394f03b6117d51f7be83db21c2" -"checksum cranelift-module 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05ac4232a9fac77aa7d29ae713ae7817e3efa730f007c0f528a279cd68a6824d" -"checksum cranelift-native 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb9bfdcca2c05a260408ca018846cd4b8ad87c5eea1623627f97d34cf82c2b31" -"checksum cranelift-simplejit 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1587398fde1c2970a1da7fe9ac687bdcad39bb398bea9ae08276153390c55" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" @@ -372,25 +299,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" "checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" -"checksum proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "effdb53b25cdad54f8f48843d67398f7ef2e14f12c1b4cb4effc549a6462a4d6" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" -"checksum raw-cpuid 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90e0d3209fac374e168cef2d8806dde7b31ef0ee82a965bcc0bec562c078a6f5" +"checksum raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "233ec1847057cf4d4591a0d76908aa12812140b11ea7d7d05b4c38cadb069c31" "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" "checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" -"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)" = "429fcc4efa8a11341b5422c2ace724daba276c1748467e869478f53c0ba4562e" -"checksum serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3525a779832b08693031b8ecfb0de81cd71cfd3812088fafe9a7496789572124" "checksum serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "84b8035cabe9b35878adec8ac5fe03d5f6bc97ff6edd7ccb96b44c1276ba390e" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2beff8ebc3658f07512a413866875adddd20f4fd47b2a4e6c9da65cd281baaea" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" -"checksum target-lexicon 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "71b0a95ba4eff593189d912039fba46ce6ca1876ea6c16830e15340919d0a250" +"checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index b2c212baedfdb..908fcc72fcc4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,12 @@ authors = ["bjorn3 "] crate-type = ["dylib"] [dependencies] -cranelift = "0.14.0" -cranelift-module = "0.14.0" -cranelift-simplejit = "0.14.0" +#cranelift = "0.14.0" +#cranelift-module = "0.14.0" +#cranelift-simplejit = "0.14.0" #cranelift-faerie = "0.14.0" + +cranelift = { path = "./cranelift/lib/umbrella" } +cranelift-module = { path = "./cranelift/lib/module" } +cranelift-simplejit = { path = "./cranelift/lib/simplejit" } +#cranelift-faerie = { path = "./cranelift/lib/faerie" } diff --git a/build.sh b/build.sh index 8795292097ee0..300a12606b14b 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ cargo build || exit 1 -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.dylib example.rs --crate-type lib -Og -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.dylib ../rust_fork/src/libcore/lib.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so example.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ../rust/src/libcore/lib.rs --crate-type lib -Og diff --git a/cranelift b/cranelift new file mode 160000 index 0000000000000..1c3601789df0a --- /dev/null +++ b/cranelift @@ -0,0 +1 @@ +Subproject commit 1c3601789df0ad52880feebc2e641848838b7c14 From af3234cfd746a1b6c16293baef5535b1f33ed99b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Jul 2018 15:13:37 +0200 Subject: [PATCH 0038/1566] [WIP] Add arbitrary constant support --- src/base.rs | 4 +++ src/common.rs | 6 ++-- src/constant.rs | 77 ++++++++++++++++++++++++++++++++++++++++++++++--- src/lib.rs | 7 +++-- 4 files changed, 86 insertions(+), 8 deletions(-) diff --git a/src/base.rs b/src/base.rs index c7f07542b0e84..5301656cf2418 100644 --- a/src/base.rs +++ b/src/base.rs @@ -85,6 +85,7 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & ebb_map, local_map: HashMap::new(), comments: HashMap::new(), + constants: &mut cx.constants, }; let fx = &mut fx; @@ -458,6 +459,8 @@ fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l (BinOp::Shl, _) => fx.bcx.ins().ishl(lhs, rhs), (BinOp::Shr, false) => fx.bcx.ins().ushr(lhs, rhs), (BinOp::Shr, true) => fx.bcx.ins().sshr(lhs, rhs), + + // TODO: cast b1 to u8 (BinOp::Eq, _) => fx.bcx.ins().icmp(IntCC::Equal , lhs, rhs), (BinOp::Lt, false) => fx.bcx.ins().icmp(IntCC::UnsignedLessThan , lhs, rhs), (BinOp::Lt, true) => fx.bcx.ins().icmp(IntCC::SignedLessThan , lhs, rhs), @@ -468,6 +471,7 @@ fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l (BinOp::Ge, true) => fx.bcx.ins().icmp(IntCC::SignedGreaterThanOrEqual , lhs, rhs), (BinOp::Gt, false) => fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan , lhs, rhs), (BinOp::Gt, true) => fx.bcx.ins().icmp(IntCC::SignedGreaterThan , lhs, rhs), + (BinOp::Offset, _) => bug!("bin op Offset on non ptr lhs: {:?} rhs: {:?}", lhs, rhs), }; // TODO: return correct value for checked binops diff --git a/src/common.rs b/src/common.rs index 83f992380c0c5..5e3433410ee2d 100644 --- a/src/common.rs +++ b/src/common.rs @@ -6,7 +6,7 @@ use std::fmt; use syntax::ast::{IntTy, UintTy}; use self::rustc_target::spec::{HasTargetSpec, Target}; -use cranelift_module::{Module, Linkage, FuncId}; +use cranelift_module::{Module, Linkage, FuncId, DataId}; use prelude::*; @@ -56,7 +56,7 @@ fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> return None; } } - TypeVariants::TyParam(_) => bug!("{:?}", ty), + TypeVariants::TyParam(_) => bug!("{:?}: {:?}", ty, ty.sty), _ => return None, }) } @@ -288,6 +288,7 @@ pub fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: I pub fn cton_sig_from_mono_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>) -> Signature { // TODO: monomorphize signature + // TODO: this should likely not use skip_binder() let sig = sig.skip_binder(); let inputs = sig.inputs(); @@ -334,6 +335,7 @@ pub struct FunctionCx<'a, 'tcx: 'a> { pub ebb_map: HashMap, pub local_map: HashMap>, pub comments: HashMap, + pub constants: &'a mut HashMap, } impl<'a, 'tcx: 'a> fmt::Debug for FunctionCx<'a, 'tcx> { diff --git a/src/constant.rs b/src/constant.rs index ab3e4376a820f..a4f5032fb322f 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,8 +1,9 @@ use prelude::*; +use rustc::mir::interpret::{GlobalId, AllocId, read_target_uint}; +use rustc_mir::interpret::{CompileTimeEvaluator, Memory, MemoryKind}; +use cranelift_module::*; pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Constant<'tcx>) -> CValue<'tcx> { - use rustc::mir::interpret::{Scalar, ConstValue, GlobalId}; - let value = match const_.literal { Literal::Value { value } => value, Literal::Promoted { index } => fx @@ -32,6 +33,74 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); CValue::Func(func_ref, fx.layout_of(const_.ty)) } - _ => unimplemented!("value {:?} ty {:?}", value, const_.ty), + _ => { + let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); + let alloc = fx.tcx.const_value_to_allocation(value); + //println!("const value: {:?} allocation: {:?}", value, alloc); + let alloc_id = memory.allocate_value(alloc.clone(), MemoryKind::Stack).unwrap(); + let data_id = get_global_for_alloc_id(fx, &memory, alloc_id); + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + // TODO: does global_value return a ptr of a val? + let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); + CValue::ByRef(global_ptr, layout) + } + } +} + +// If ret.1 is true, then the global didn't exist before +fn define_global_for_alloc_id(fx: &mut FunctionCx, alloc_id: AllocId, todo: &mut HashMap) -> (DataId, bool) { + use std::collections::hash_map::Entry; + match fx.constants.entry(alloc_id) { + Entry::Occupied(mut occ) => { + (*occ.get_mut(), false) + } + Entry::Vacant(vac) => { + let data_id = fx.module.declare_data(&alloc_id.0.to_string(), Linkage::Local, false).unwrap(); + todo.insert(alloc_id, data_id); + vac.insert(data_id); + (data_id, true) + } + } +} + +fn get_global_for_alloc_id(fx: &mut FunctionCx, memory: &Memory, alloc_id: AllocId) -> DataId { + if let Some(data_id) = fx.constants.get(&alloc_id) { + return *data_id; + } + + let mut todo = HashMap::new(); + let mut done = HashSet::new(); + define_global_for_alloc_id(fx, alloc_id, &mut todo); + + while let Some((alloc_id, data_id)) = { let next = todo.drain().next(); next } { + println!("cur: {:?}:{:?} todo: {:?} done: {:?}", alloc_id, data_id, todo, done); + + let alloc = memory.get(alloc_id).unwrap(); + let mut data_ctx = DataContext::new(); + + data_ctx.define(alloc.bytes.to_vec().into_boxed_slice(), Writability::Readonly); + + for &(offset, reloc) in alloc.relocations.iter() { + let data_id = define_global_for_alloc_id(fx, reloc, &mut todo).0; + + let reloc_offset = { + let endianness = memory.endianness(); + let offset = offset.bytes() as usize; + let ptr_size = fx.tcx.data_layout.pointer_size; + let bytes = &alloc.bytes[offset..offset + ptr_size.bytes() as usize]; + read_target_uint(endianness, bytes).unwrap() + }; + + // TODO: is this a correct usage of the api + let global_value = fx.module.declare_data_in_data(data_id, &mut data_ctx); + data_ctx.write_data_addr(reloc_offset as u32, global_value, 0); + } + + fx.module.define_data(data_id, &data_ctx).unwrap(); + done.insert(data_id); + } + for data_id in done.drain() { + fx.module.finalize_data(data_id); } -} \ No newline at end of file + *fx.constants.get(&alloc_id).unwrap() +} diff --git a/src/lib.rs b/src/lib.rs index e8cab41d81074..dc640838b6b84 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,12 +40,13 @@ mod pretty_clif; mod prelude { pub use std::any::Any; - pub use std::collections::HashMap; + pub use std::collections::{HashMap, HashSet}; pub use syntax::codemap::DUMMY_SP; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; pub use rustc::mir; pub use rustc::mir::*; + pub use rustc::mir::interpret::AllocId; pub use rustc::session::Session; pub use rustc::ty::layout::{self, LayoutOf, TyLayout, Size}; pub use rustc::ty::{ @@ -60,7 +61,7 @@ mod prelude { }; pub use cranelift::codegen::Context; pub use cranelift::prelude::*; - pub use cranelift_module::{Module, Backend, FuncId, Linkage}; + pub use cranelift_module::{Module, Backend, FuncId, DataId, Linkage}; pub use cranelift_simplejit::{SimpleJITBuilder, SimpleJITBackend}; pub use common::Variable; @@ -75,6 +76,7 @@ pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, pub def_id_fn_id_map: &'a mut HashMap, FuncId>, + pub constants: HashMap, } struct CraneliftCodegenBackend(()); @@ -176,6 +178,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx, module: &mut module, def_id_fn_id_map: &mut def_id_fn_id_map, + constants: HashMap::new(), }; for mono_item in From d0ef7f455cbbd0a0d8ac706f8e0ccbd30f15b0ec Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 11:55:32 +0200 Subject: [PATCH 0039/1566] Add docs and expand some wildcard patterns --- Readme.md | 38 ++++++++++++++++++++++++++++++++++++++ src/base.rs | 24 ++++++++++++++++++------ src/common.rs | 2 ++ 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000000000..40ddd2478a6de --- /dev/null +++ b/Readme.md @@ -0,0 +1,38 @@ +# Work in progress cranelift codegen backend for rust + +> ⚠⚠⚠ This doesn't do anything useful yet ⚠⚠⚠ + +## Building + +```bash +$ git clone https://github.com/bjorn3/rustc_codegen_cranelift +$ cd rustc_codegen_cranelift +$ git submodule update --init +$ cargo build +``` + +## Usage + +```bash +$ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_crate.rs --crate-type lib -Og +``` + +> You must compile with `-Og`, because checked binops are not yet supported. + +## Not yet supported + +* [ ] Checked binops +* [ ] Statics +* [ ] Drop glue +* [ ] Ints cast + +* [ ] Building libraries +* [ ] Other call abi's +* [ ] Unsized types +* [ ] Slice indexing +* [ ] Sub slice +* [ ] Closures +* [ ] Some rvalue's + +* [ ] Inline assembly +* [ ] Custom sections \ No newline at end of file diff --git a/src/base.rs b/src/base.rs index 5301656cf2418..6f72fadf48726 100644 --- a/src/base.rs +++ b/src/base.rs @@ -55,7 +55,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } inst => cx.tcx.sess.warn(&format!("Unimplemented instance {:?}", inst)), } - mono_item => cx.tcx.sess.warn(&format!("Unimplemented mono item {:?}", mono_item)), + MonoItem::Static(def_id) => cx.tcx.sess.err(&format!("Unimplemented static mono item {:?}", def_id)), + MonoItem::GlobalAsm(node_id) => cx.tcx.sess.err(&format!("Unimplemented global asm mono item {:?}", node_id)), + MonoItem::CustomSection(def_id) => cx.tcx.sess.err(&format!("Unimplemented custom section mono item {:?}", def_id)), } } @@ -367,6 +369,9 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let layout = fx.layout_of(ty); lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); } + Rvalue::Cast(CastKind::Misc, operand, ty) => unimplemented!("rval misc {:?} {:?}", operand, ty), + Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty), + Rvalue::Cast(CastKind::Unsize, operand, ty) => unimplemented!("rval unsize {:?} {:?}", operand, ty), Rvalue::Discriminant(place) => { let place = trans_place(fx, place); let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); @@ -428,13 +433,17 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } } } - rval => unimplemented!("rval {:?}", rval), + Rvalue::Repeat(operand, times) => unimplemented!("rval repeat {:?} {:?}", operand, times), + Rvalue::Len(lval) => unimplemented!("rval len {:?}", lval), + Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), + Rvalue::NullaryOp(NullOp::SizeOf, ty) => unimplemented!("rval size_of {:?}", ty), + Rvalue::Aggregate(_, _) => bug!("shouldn't exist at trans {:?}", rval), } } - StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop => { + StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop | StatementKind::ReadForMatch(_) | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) | StatementKind::UserAssertTy(_, _) => { fx.bcx.ins().nop(); } - _ => unimplemented!("stmt {:?}", stmt), + StatementKind::InlineAsm { .. } => fx.tcx.sess.fatal("Inline assembly is not supported"), } let inst = fx.bcx.func.layout.next_inst(nop_inst).unwrap(); @@ -481,6 +490,7 @@ fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { match place { Place::Local(local) => fx.get_local_place(*local), + Place::Static(static_) => unimplemented!("static place {:?} ty {:?}", static_.def_id, static_.ty), Place::Projection(projection) => { let base = trans_place(fx, &projection.base); match projection.elem { @@ -490,13 +500,15 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) ProjectionElem::Field(field, _ty) => { base.place_field(fx, field) } + ProjectionElem::Index(local) => unimplemented!("projection index {:?} {:?}", projection.base, local), + ProjectionElem::ConstantIndex { offset, min_length: _, from_end: false } => unimplemented!("projection const index {:?} offset {:?} not from end", projection.base, offset), + ProjectionElem::ConstantIndex { offset, min_length: _, from_end: true } => unimplemented!("projection const index {:?} offset {:?} from end", projection.base, offset), + ProjectionElem::Subslice { from, to } => unimplemented!("projection subslice {:?} from {} to {}", projection.base, from, to), ProjectionElem::Downcast(_adt_def, variant) => { base.downcast_variant(fx, variant) } - _ => unimplemented!("projection {:?}", projection), } } - place => unimplemented!("place {:?}", place), } } diff --git a/src/common.rs b/src/common.rs index 5e3433410ee2d..5a47c9e7ad0a6 100644 --- a/src/common.rs +++ b/src/common.rs @@ -61,6 +61,7 @@ fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> }) } +/// A read-only value #[derive(Debug, Copy, Clone)] pub enum CValue<'tcx> { ByRef(Value, TyLayout<'tcx>), @@ -158,6 +159,7 @@ impl<'tcx> CValue<'tcx> { } } +/// A place where you can write a value to or read a value from #[derive(Debug, Copy, Clone)] pub enum CPlace<'tcx> { Var(Variable, TyLayout<'tcx>), From 425b527dc31c4d88ed2099bcc91af96cebf8a463 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 12:25:01 +0200 Subject: [PATCH 0040/1566] Add patch to disable u128 and i128 --- 0002-Disable-u128-and-i128-in-libcore.patch | 1095 +++++++++++++++++++ 1 file changed, 1095 insertions(+) create mode 100644 0002-Disable-u128-and-i128-in-libcore.patch diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch new file mode 100644 index 0000000000000..429b946bb7fa7 --- /dev/null +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -0,0 +1,1095 @@ +From 865d6486d85985d65ccb850695c25579b98ca14c Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Wed, 18 Jul 2018 12:21:43 +0200 +Subject: [PATCH] Disable u128 and i128 in libcore + +--- + src/libcore/clone.rs | 4 ++-- + src/libcore/cmp.rs | 6 ++--- + src/libcore/default.rs | 2 -- + src/libcore/fmt/num.rs | 6 +---- + src/libcore/hash/mod.rs | 20 ---------------- + src/libcore/iter/range.rs | 12 ++++------ + src/libcore/iter/traits.rs | 2 +- + src/libcore/lib.rs | 2 -- + src/libcore/marker.rs | 4 ++-- + src/libcore/mem.rs | 2 -- + src/libcore/num/i128.rs | 17 -------------- + src/libcore/num/mod.rs | 54 +++++++++----------------------------------- + src/libcore/num/u128.rs | 16 ------------- + src/libcore/num/wrapping.rs | 14 ++++-------- + src/libcore/ops/arith.rs | 22 +++++++++--------- + src/libcore/ops/bit.rs | 30 +++++++++--------------- + src/libcore/tests/iter.rs | 15 ------------ + src/libcore/tests/num/mod.rs | 47 -------------------------------------- + src/libcore/time.rs | 51 ----------------------------------------- + 19 files changed, 52 insertions(+), 274 deletions(-) + delete mode 100644 src/libcore/num/i128.rs + delete mode 100644 src/libcore/num/u128.rs + +diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs +index 3b15ba2b4a..de08ce0289 100644 +--- a/src/libcore/clone.rs ++++ b/src/libcore/clone.rs +@@ -172,8 +172,8 @@ mod impls { + } + + impl_clone! { +- usize u8 u16 u32 u64 u128 +- isize i8 i16 i32 i64 i128 ++ usize u8 u16 u32 u64 ++ isize i8 i16 i32 i64 + f32 f64 + bool char + } +diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs +index 3626a266ad..4106432a41 100644 +--- a/src/libcore/cmp.rs ++++ b/src/libcore/cmp.rs +@@ -798,7 +798,7 @@ mod impls { + } + + partial_eq_impl! { +- bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 ++ bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 + } + + macro_rules! eq_impl { +@@ -808,7 +808,7 @@ mod impls { + )*) + } + +- eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++ eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + macro_rules! partial_ord_impl { + ($($t:ty)*) => ($( +@@ -897,7 +897,7 @@ mod impls { + } + } + +- ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++ ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + #[unstable(feature = "never_type", issue = "35121")] + impl PartialEq for ! { +diff --git a/src/libcore/default.rs b/src/libcore/default.rs +index ab36e29b1e..1926719657 100644 +--- a/src/libcore/default.rs ++++ b/src/libcore/default.rs +@@ -145,14 +145,12 @@ default_impl! { u8, 0, "Returns the default value of `0`" } + default_impl! { u16, 0, "Returns the default value of `0`" } + default_impl! { u32, 0, "Returns the default value of `0`" } + default_impl! { u64, 0, "Returns the default value of `0`" } +-default_impl! { u128, 0, "Returns the default value of `0`" } + + default_impl! { isize, 0, "Returns the default value of `0`" } + default_impl! { i8, 0, "Returns the default value of `0`" } + default_impl! { i16, 0, "Returns the default value of `0`" } + default_impl! { i32, 0, "Returns the default value of `0`" } + default_impl! { i64, 0, "Returns the default value of `0`" } +-default_impl! { i128, 0, "Returns the default value of `0`" } + + default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } + default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } +diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs +index 51391fa50d..140255ea7e 100644 +--- a/src/libcore/fmt/num.rs ++++ b/src/libcore/fmt/num.rs +@@ -29,7 +29,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + + fn to_u16(&self) -> u16; + fn to_u32(&self) -> u32; + fn to_u64(&self) -> u64; +- fn to_u128(&self) -> u128; + } + + macro_rules! doit { +@@ -40,10 +39,9 @@ macro_rules! doit { + fn to_u16(&self) -> u16 { *self as u16 } + fn to_u32(&self) -> u32 { *self as u32 } + fn to_u64(&self) -> u64 { *self as u64 } +- fn to_u128(&self) -> u128 { *self as u128 } + })*) + } +-doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } ++doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } + + /// A type that represents a specific radix + #[doc(hidden)] +@@ -184,7 +182,6 @@ integer! { i8, u8 } + integer! { i16, u16 } + integer! { i32, u32 } + integer! { i64, u64 } +-integer! { i128, u128 } + + const DEC_DIGITS_LUT: &'static[u8] = + b"0001020304050607080910111213141516171819\ +@@ -260,7 +257,6 @@ macro_rules! impl_Display { + + impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); + impl_Display!(i64, u64: to_u64); +-impl_Display!(i128, u128: to_u128); + #[cfg(target_pointer_width = "16")] + impl_Display!(isize, usize: to_u16); + #[cfg(target_pointer_width = "32")] +diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs +index e6f8dfffd6..2670d55537 100644 +--- a/src/libcore/hash/mod.rs ++++ b/src/libcore/hash/mod.rs +@@ -306,12 +306,6 @@ pub trait Hasher { + fn write_u64(&mut self, i: u64) { + self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) }) + } +- /// Writes a single `u128` into this hasher. +- #[inline] +- #[stable(feature = "i128", since = "1.26.0")] +- fn write_u128(&mut self, i: u128) { +- self.write(&unsafe { mem::transmute::<_, [u8; 16]>(i) }) +- } + /// Writes a single `usize` into this hasher. + #[inline] + #[stable(feature = "hasher_write", since = "1.3.0")] +@@ -346,12 +340,6 @@ pub trait Hasher { + fn write_i64(&mut self, i: i64) { + self.write_u64(i as u64) + } +- /// Writes a single `i128` into this hasher. +- #[inline] +- #[stable(feature = "i128", since = "1.26.0")] +- fn write_i128(&mut self, i: i128) { +- self.write_u128(i as u128) +- } + /// Writes a single `isize` into this hasher. + #[inline] + #[stable(feature = "hasher_write", since = "1.3.0")] +@@ -380,9 +368,6 @@ impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { + fn write_u64(&mut self, i: u64) { + (**self).write_u64(i) + } +- fn write_u128(&mut self, i: u128) { +- (**self).write_u128(i) +- } + fn write_usize(&mut self, i: usize) { + (**self).write_usize(i) + } +@@ -398,9 +383,6 @@ impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { + fn write_i64(&mut self, i: i64) { + (**self).write_i64(i) + } +- fn write_i128(&mut self, i: i128) { +- (**self).write_i128(i) +- } + fn write_isize(&mut self, i: isize) { + (**self).write_isize(i) + } +@@ -577,8 +559,6 @@ mod impls { + (i32, write_i32), + (i64, write_i64), + (isize, write_isize), +- (u128, write_u128), +- (i128, write_i128), + } + + #[stable(feature = "rust1", since = "1.0.0")] +diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs +index 5896322f11..67809897f5 100644 +--- a/src/libcore/iter/range.rs ++++ b/src/libcore/iter/range.rs +@@ -175,7 +175,6 @@ step_impl_signed!([i64: u64]); + // assume here that it is less than 64-bits. + #[cfg(not(target_pointer_width = "64"))] + step_impl_no_between!(u64 i64); +-step_impl_no_between!(u128 i128); + + macro_rules! range_exact_iter_impl { + ($($t:ty)*) => ($( +@@ -509,8 +508,8 @@ macro_rules! try_from_upper_bounded { + mod ptr_try_from_impls { + use super::PrivateTryFromUsize; + +- try_from_unbounded!(u16, u32, u64, u128); +- try_from_unbounded!(i32, i64, i128); ++ try_from_unbounded!(u16, u32, u64); ++ try_from_unbounded!(i32, i64); + } + + #[cfg(target_pointer_width = "32")] +@@ -518,9 +517,9 @@ mod ptr_try_from_impls { + use super::PrivateTryFromUsize; + + try_from_upper_bounded!(u16); +- try_from_unbounded!(u32, u64, u128); ++ try_from_unbounded!(u32, u64); + try_from_upper_bounded!(i32); +- try_from_unbounded!(i64, i128); ++ try_from_unbounded!(i64); + } + + #[cfg(target_pointer_width = "64")] +@@ -528,7 +527,6 @@ mod ptr_try_from_impls { + use super::PrivateTryFromUsize; + + try_from_upper_bounded!(u16, u32); +- try_from_unbounded!(u64, u128); ++ try_from_unbounded!(u64); + try_from_upper_bounded!(i32, i64); +- try_from_unbounded!(i128); + } +diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs +index 4b2c1aa551..ec3991fa01 100644 +--- a/src/libcore/iter/traits.rs ++++ b/src/libcore/iter/traits.rs +@@ -843,7 +843,7 @@ macro_rules! float_sum_product { + )*) + } + +-integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } ++integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } + float_sum_product! { f32 f64 } + + /// An iterator adapter that produces output as long as the underlying +diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs +index f038d155a1..31e4223730 100644 +--- a/src/libcore/lib.rs ++++ b/src/libcore/lib.rs +@@ -148,14 +148,12 @@ mod uint_macros; + #[path = "num/i16.rs"] pub mod i16; + #[path = "num/i32.rs"] pub mod i32; + #[path = "num/i64.rs"] pub mod i64; +-#[path = "num/i128.rs"] pub mod i128; + + #[path = "num/usize.rs"] pub mod usize; + #[path = "num/u8.rs"] pub mod u8; + #[path = "num/u16.rs"] pub mod u16; + #[path = "num/u32.rs"] pub mod u32; + #[path = "num/u64.rs"] pub mod u64; +-#[path = "num/u128.rs"] pub mod u128; + + #[path = "num/f32.rs"] pub mod f32; + #[path = "num/f64.rs"] pub mod f64; +diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs +index 5db5d88d4a..d7d6b45015 100644 +--- a/src/libcore/marker.rs ++++ b/src/libcore/marker.rs +@@ -643,8 +643,8 @@ mod copy_impls { + } + + impl_copy! { +- usize u8 u16 u32 u64 u128 +- isize i8 i16 i32 i64 i128 ++ usize u8 u16 u32 u64 ++ isize i8 i16 i32 i64 + f32 f64 + bool char + } +diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs +index 08bd9289ab..aca522e445 100644 +--- a/src/libcore/mem.rs ++++ b/src/libcore/mem.rs +@@ -194,12 +194,10 @@ pub fn forget(t: T) { + /// u16 | 2 + /// u32 | 4 + /// u64 | 8 +-/// u128 | 16 + /// i8 | 1 + /// i16 | 2 + /// i32 | 4 + /// i64 | 8 +-/// i128 | 16 + /// f32 | 4 + /// f64 | 8 + /// char | 4 +diff --git a/src/libcore/num/i128.rs b/src/libcore/num/i128.rs +deleted file mode 100644 +index 989376d1ac..0000000000 +--- a/src/libcore/num/i128.rs ++++ /dev/null +@@ -1,17 +0,0 @@ +-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +-// file at the top-level directory of this distribution and at +-// http://rust-lang.org/COPYRIGHT. +-// +-// Licensed under the Apache License, Version 2.0 or the MIT license +-// , at your +-// option. This file may not be copied, modified, or distributed +-// except according to those terms. +- +-//! The 128-bit signed integer type. +-//! +-//! *[See also the `i128` primitive type](../../std/primitive.i128.html).* +- +-#![stable(feature = "i128", since = "1.26.0")] +- +-int_module! { i128, #[stable(feature = "i128", since="1.26.0")] } +diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs +index 7e2dd304d7..b01c843ad7 100644 +--- a/src/libcore/num/mod.rs ++++ b/src/libcore/num/mod.rs +@@ -94,7 +94,6 @@ nonzero_integers! { + NonZeroU16(u16); + NonZeroU32(u32); + NonZeroU64(u64); +- NonZeroU128(u128); + NonZeroUsize(usize); + } + +@@ -2047,12 +2046,6 @@ impl i64 { + int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" } + } + +-#[lang = "i128"] +-impl i128 { +- int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, +- 170141183460469231731687303715884105727, "", "" } +-} +- + #[cfg(target_pointer_width = "16")] + #[lang = "isize"] + impl isize { +@@ -4290,11 +4283,6 @@ impl u64 { + uint_impl! { u64, u64, 64, 18446744073709551615, "", "" } + } + +-#[lang = "u128"] +-impl u128 { +- uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" } +-} +- + #[cfg(target_pointer_width = "16")] + #[lang = "usize"] + impl usize { +@@ -4373,7 +4361,7 @@ macro_rules! from_str_radix_int_impl { + } + )*} + } +-from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } ++from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } + + /// The error type returned when a checked integral type conversion fails. + #[unstable(feature = "try_from", issue = "33417")] +@@ -4474,30 +4462,25 @@ macro_rules! rev { + try_from_upper_bounded!(u16, u8); + try_from_upper_bounded!(u32, u16, u8); + try_from_upper_bounded!(u64, u32, u16, u8); +-try_from_upper_bounded!(u128, u64, u32, u16, u8); + + try_from_both_bounded!(i16, i8); + try_from_both_bounded!(i32, i16, i8); + try_from_both_bounded!(i64, i32, i16, i8); +-try_from_both_bounded!(i128, i64, i32, i16, i8); + + // unsigned-to-signed + try_from_upper_bounded!(u8, i8); + try_from_upper_bounded!(u16, i8, i16); + try_from_upper_bounded!(u32, i8, i16, i32); + try_from_upper_bounded!(u64, i8, i16, i32, i64); +-try_from_upper_bounded!(u128, i8, i16, i32, i64, i128); + + // signed-to-unsigned +-try_from_lower_bounded!(i8, u8, u16, u32, u64, u128); +-try_from_lower_bounded!(i16, u16, u32, u64, u128); +-try_from_lower_bounded!(i32, u32, u64, u128); +-try_from_lower_bounded!(i64, u64, u128); +-try_from_lower_bounded!(i128, u128); ++try_from_lower_bounded!(i8, u8, u16, u32, u64); ++try_from_lower_bounded!(i16, u16, u32, u64); ++try_from_lower_bounded!(i32, u32, u64); ++try_from_lower_bounded!(i64, u64); + try_from_both_bounded!(i16, u8); + try_from_both_bounded!(i32, u16, u8); + try_from_both_bounded!(i64, u32, u16, u8); +-try_from_both_bounded!(i128, u64, u32, u16, u8); + + // usize/isize + try_from_upper_bounded!(usize, isize); +@@ -4514,9 +4497,9 @@ mod ptr_try_from_impls { + use convert::TryFrom; + + // Fallible across platfoms, only implementation differs +- try_from_lower_bounded!(isize, u16, u32, u64, u128); ++ try_from_lower_bounded!(isize, u16, u32, u64); + rev!(try_from_lower_bounded, usize, i8, i16); +- rev!(try_from_both_bounded, usize, i32, i64, i128); ++ rev!(try_from_both_bounded, usize, i32, i64); + } + + #[cfg(target_pointer_width = "32")] +@@ -4526,9 +4509,9 @@ mod ptr_try_from_impls { + + // Fallible across platfoms, only implementation differs + try_from_both_bounded!(isize, u16); +- try_from_lower_bounded!(isize, u32, u64, u128); ++ try_from_lower_bounded!(isize, u32, u64); + rev!(try_from_lower_bounded, usize, i8, i16, i32); +- rev!(try_from_both_bounded, usize, i64, i128); ++ rev!(try_from_both_bounded, usize, i64); + } + + #[cfg(target_pointer_width = "64")] +@@ -4538,9 +4521,8 @@ mod ptr_try_from_impls { + + // Fallible across platfoms, only implementation differs + try_from_both_bounded!(isize, u16, u32); +- try_from_lower_bounded!(isize, u64, u128); ++ try_from_lower_bounded!(isize, u64); + rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); +- rev!(try_from_both_bounded, usize, i128); + } + + #[doc(hidden)] +@@ -4575,7 +4557,7 @@ macro_rules! doit { + } + })*) + } +-doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } ++doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } + + fn from_str_radix(src: &str, radix: u32) -> Result { + use self::IntErrorKind::*; +@@ -4743,52 +4725,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } +-impl_from_bool! { u128, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { usize, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { i8, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { i16, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { i32, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { i64, #[stable(feature = "from_bool", since = "1.28.0")] } +-impl_from_bool! { i128, #[stable(feature = "from_bool", since = "1.28.0")] } + impl_from_bool! { isize, #[stable(feature = "from_bool", since = "1.28.0")] } + + // Unsigned -> Unsigned + impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { u8, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { u8, u128, #[stable(feature = "i128", since = "1.26.0")] } + impl_from! { u8, usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { u16, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { u16, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { u16, u128, #[stable(feature = "i128", since = "1.26.0")] } + impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] } +-impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] } + + // Signed -> Signed + impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { i8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { i8, i128, #[stable(feature = "i128", since = "1.26.0")] } + impl_from! { i8, isize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { i16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { i16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { i16, i128, #[stable(feature = "i128", since = "1.26.0")] } + impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] } +-impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] } + + // Unsigned -> Signed + impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { u8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { u8, i128, #[stable(feature = "i128", since = "1.26.0")] } + impl_from! { u16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } + impl_from! { u16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { u16, i128, #[stable(feature = "i128", since = "1.26.0")] } + impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } +-impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] } +-impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] } + + // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX + // which imply that pointer-sized integers must be at least 16 bits: +diff --git a/src/libcore/num/u128.rs b/src/libcore/num/u128.rs +deleted file mode 100644 +index e8c783a1bb..0000000000 +--- a/src/libcore/num/u128.rs ++++ /dev/null +@@ -1,16 +0,0 @@ +-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +-// file at the top-level directory of this distribution and at +-// http://rust-lang.org/COPYRIGHT. +-// +-// Licensed under the Apache License, Version 2.0 or the MIT license +-// , at your +-// option. This file may not be copied, modified, or distributed +-// except according to those terms. +- +-//! The 128-bit unsigned integer type. +-//! +-//! *[See also the `u128` primitive type](../../std/primitive.u128.html).* +- +-#![stable(feature = "i128", since = "1.26.0")] +-uint_module! { u128, #[stable(feature = "i128", since="1.26.0")] } +diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs +index d7f87d37f5..666658a66b 100644 +--- a/src/libcore/num/wrapping.rs ++++ b/src/libcore/num/wrapping.rs +@@ -112,19 +112,17 @@ macro_rules! sh_impl_all { + //sh_impl_unsigned! { $t, u16 } + //sh_impl_unsigned! { $t, u32 } + //sh_impl_unsigned! { $t, u64 } +- //sh_impl_unsigned! { $t, u128 } + sh_impl_unsigned! { $t, usize } + + //sh_impl_signed! { $t, i8 } + //sh_impl_signed! { $t, i16 } + //sh_impl_signed! { $t, i32 } + //sh_impl_signed! { $t, i64 } +- //sh_impl_signed! { $t, i128 } + //sh_impl_signed! { $t, isize } + )*) + } + +-sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } ++sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + + // FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping + macro_rules! wrapping_impl { +@@ -323,7 +321,7 @@ macro_rules! wrapping_impl { + )*) + } + +-wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + macro_rules! wrapping_int_impl { + ($($t:ty)*) => ($( +@@ -686,7 +684,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); + )*) + } + +-wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++wrapping_int_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + macro_rules! wrapping_int_impl_signed { + ($($t:ty)*) => ($( +@@ -815,7 +813,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); + )*) + } + +-wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 } ++wrapping_int_impl_signed! { isize i8 i16 i32 i64 } + + macro_rules! wrapping_int_impl_unsigned { + ($($t:ty)*) => ($( +@@ -892,7 +890,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); + )*) + } + +-wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 u128 } ++wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 } + + mod shift_max { + #![allow(non_upper_case_globals)] +@@ -919,13 +917,11 @@ mod shift_max { + pub const i16: u32 = (1 << 4) - 1; + pub const i32: u32 = (1 << 5) - 1; + pub const i64: u32 = (1 << 6) - 1; +- pub const i128: u32 = (1 << 7) - 1; + pub use self::platform::isize; + + pub const u8: u32 = i8; + pub const u16: u32 = i16; + pub const u32: u32 = i32; + pub const u64: u32 = i64; +- pub const u128: u32 = i128; + pub use self::platform::usize; + } +diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs +index a1bc5463f7..38742be1ce 100644 +--- a/src/libcore/ops/arith.rs ++++ b/src/libcore/ops/arith.rs +@@ -114,7 +114,7 @@ macro_rules! add_impl { + )*) + } + +-add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + + /// The subtraction operator `-`. + /// +@@ -212,7 +212,7 @@ macro_rules! sub_impl { + )*) + } + +-sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + + /// The multiplication operator `*`. + /// +@@ -332,7 +332,7 @@ macro_rules! mul_impl { + )*) + } + +-mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + + /// The division operator `/`. + /// +@@ -457,7 +457,7 @@ macro_rules! div_impl_integer { + )*) + } + +-div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + macro_rules! div_impl_float { + ($($t:ty)*) => ($( +@@ -542,7 +542,7 @@ macro_rules! rem_impl_integer { + )*) + } + +-rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + + macro_rules! rem_impl_float { +@@ -641,7 +641,7 @@ macro_rules! neg_impl_unsigned { + } + + // neg_impl_unsigned! { usize u8 u16 u32 u64 } +-neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } ++neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } + + /// The addition assignment operator `+=`. + /// +@@ -697,7 +697,7 @@ macro_rules! add_assign_impl { + )+) + } + +-add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + + /// The subtraction assignment operator `-=`. + /// +@@ -753,7 +753,7 @@ macro_rules! sub_assign_impl { + )+) + } + +-sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + + /// The multiplication assignment operator `*=`. + /// +@@ -800,7 +800,7 @@ macro_rules! mul_assign_impl { + )+) + } + +-mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + + /// The division assignment operator `/=`. + /// +@@ -846,7 +846,7 @@ macro_rules! div_assign_impl { + )+) + } + +-div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } + + /// The remainder assignment operator `%=`. + /// +@@ -896,4 +896,4 @@ macro_rules! rem_assign_impl { + )+) + } + +-rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } ++rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } +diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs +index 3900f365b0..66b7980a43 100644 +--- a/src/libcore/ops/bit.rs ++++ b/src/libcore/ops/bit.rs +@@ -65,7 +65,7 @@ macro_rules! not_impl { + )*) + } + +-not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + /// The bitwise AND operator `&`. + /// +@@ -149,7 +149,7 @@ macro_rules! bitand_impl { + )*) + } + +-bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + /// The bitwise OR operator `|`. + /// +@@ -233,7 +233,7 @@ macro_rules! bitor_impl { + )*) + } + +-bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + /// The bitwise XOR operator `^`. + /// +@@ -320,7 +320,7 @@ macro_rules! bitxor_impl { + )*) + } + +-bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + /// The left shift operator `<<`. Note that because this trait is implemented + /// for all integer types with multiple right-hand-side types, Rust's type +@@ -417,19 +417,17 @@ macro_rules! shl_impl_all { + shl_impl! { $t, u16 } + shl_impl! { $t, u32 } + shl_impl! { $t, u64 } +- shl_impl! { $t, u128 } + shl_impl! { $t, usize } + + shl_impl! { $t, i8 } + shl_impl! { $t, i16 } + shl_impl! { $t, i32 } + shl_impl! { $t, i64 } +- shl_impl! { $t, i128 } + shl_impl! { $t, isize } + )*) + } + +-shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } ++shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + + /// The right shift operator `>>`. Note that because this trait is implemented + /// for all integer types with multiple right-hand-side types, Rust's type +@@ -526,19 +524,17 @@ macro_rules! shr_impl_all { + shr_impl! { $t, u16 } + shr_impl! { $t, u32 } + shr_impl! { $t, u64 } +- shr_impl! { $t, u128 } + shr_impl! { $t, usize } + + shr_impl! { $t, i8 } + shr_impl! { $t, i16 } + shr_impl! { $t, i32 } + shr_impl! { $t, i64 } +- shr_impl! { $t, i128 } + shr_impl! { $t, isize } + )*) + } + +-shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } ++shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + + /// The bitwise AND assignment operator `&=`. + /// +@@ -626,7 +622,7 @@ macro_rules! bitand_assign_impl { + )+) + } + +-bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + /// The bitwise OR assignment operator `|=`. + /// +@@ -675,7 +671,7 @@ macro_rules! bitor_assign_impl { + )+) + } + +-bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + /// The bitwise XOR assignment operator `^=`. + /// +@@ -724,7 +720,7 @@ macro_rules! bitxor_assign_impl { + )+) + } + +-bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } ++bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + + /// The left shift assignment operator `<<=`. + /// +@@ -780,19 +776,17 @@ macro_rules! shl_assign_impl_all { + shl_assign_impl! { $t, u16 } + shl_assign_impl! { $t, u32 } + shl_assign_impl! { $t, u64 } +- shl_assign_impl! { $t, u128 } + shl_assign_impl! { $t, usize } + + shl_assign_impl! { $t, i8 } + shl_assign_impl! { $t, i16 } + shl_assign_impl! { $t, i32 } + shl_assign_impl! { $t, i64 } +- shl_assign_impl! { $t, i128 } + shl_assign_impl! { $t, isize } + )*) + } + +-shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } ++shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } + + /// The right shift assignment operator `>>=`. + /// +@@ -848,16 +842,14 @@ macro_rules! shr_assign_impl_all { + shr_assign_impl! { $t, u16 } + shr_assign_impl! { $t, u32 } + shr_assign_impl! { $t, u64 } +- shr_assign_impl! { $t, u128 } + shr_assign_impl! { $t, usize } + + shr_assign_impl! { $t, i8 } + shr_assign_impl! { $t, i16 } + shr_assign_impl! { $t, i32 } + shr_assign_impl! { $t, i64 } +- shr_assign_impl! { $t, i128 } + shr_assign_impl! { $t, isize } + )*) + } + +-shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } ++shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } +diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs +index 72b115f8b5..d542e10bb0 100644 +--- a/src/libcore/tests/iter.rs ++++ b/src/libcore/tests/iter.rs +@@ -224,8 +224,6 @@ fn test_iterator_step_by_nth_overflow() { + type Bigger = u32; + #[cfg(target_pointer_width = "32")] + type Bigger = u64; +- #[cfg(target_pointer_width = "64")] +- type Bigger = u128; + + #[derive(Clone)] + struct Test(Bigger); +@@ -1877,19 +1875,6 @@ fn test_step_replace_signed() { + assert_eq!(y, 5); + } + +-#[test] +-fn test_step_replace_no_between() { +- let mut x = 4u128; +- let y = x.replace_zero(); +- assert_eq!(x, 0); +- assert_eq!(y, 4); +- +- x = 5; +- let y = x.replace_one(); +- assert_eq!(x, 1); +- assert_eq!(y, 5); +-} +- + #[test] + fn test_rev_try_folds() { + let f = &|acc, x| i32::checked_add(2*acc, x); +diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs +index 24fe96a2b8..ccb2f0f990 100644 +--- a/src/libcore/tests/num/mod.rs ++++ b/src/libcore/tests/num/mod.rs +@@ -187,12 +187,10 @@ test_impl_from! { test_boolu8, bool, u8 } + test_impl_from! { test_boolu16, bool, u16 } + test_impl_from! { test_boolu32, bool, u32 } + test_impl_from! { test_boolu64, bool, u64 } +-test_impl_from! { test_boolu128, bool, u128 } + test_impl_from! { test_booli8, bool, i8 } + test_impl_from! { test_booli16, bool, i16 } + test_impl_from! { test_booli32, bool, i32 } + test_impl_from! { test_booli64, bool, i64 } +-test_impl_from! { test_booli128, bool, i128 } + + // Signed -> Float + test_impl_from! { test_i8f32, i8, f32 } +@@ -274,51 +272,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } + test_impl_try_from_always_ok! { test_try_u8u16, u8, u16 } + test_impl_try_from_always_ok! { test_try_u8u32, u8, u32 } + test_impl_try_from_always_ok! { test_try_u8u64, u8, u64 } +-test_impl_try_from_always_ok! { test_try_u8u128, u8, u128 } + test_impl_try_from_always_ok! { test_try_u8i16, u8, i16 } + test_impl_try_from_always_ok! { test_try_u8i32, u8, i32 } + test_impl_try_from_always_ok! { test_try_u8i64, u8, i64 } +-test_impl_try_from_always_ok! { test_try_u8i128, u8, i128 } + + test_impl_try_from_always_ok! { test_try_u16u16, u16, u16 } + test_impl_try_from_always_ok! { test_try_u16u32, u16, u32 } + test_impl_try_from_always_ok! { test_try_u16u64, u16, u64 } +-test_impl_try_from_always_ok! { test_try_u16u128, u16, u128 } + test_impl_try_from_always_ok! { test_try_u16i32, u16, i32 } + test_impl_try_from_always_ok! { test_try_u16i64, u16, i64 } +-test_impl_try_from_always_ok! { test_try_u16i128, u16, i128 } + + test_impl_try_from_always_ok! { test_try_u32u32, u32, u32 } + test_impl_try_from_always_ok! { test_try_u32u64, u32, u64 } +-test_impl_try_from_always_ok! { test_try_u32u128, u32, u128 } + test_impl_try_from_always_ok! { test_try_u32i64, u32, i64 } +-test_impl_try_from_always_ok! { test_try_u32i128, u32, i128 } + + test_impl_try_from_always_ok! { test_try_u64u64, u64, u64 } +-test_impl_try_from_always_ok! { test_try_u64u128, u64, u128 } +-test_impl_try_from_always_ok! { test_try_u64i128, u64, i128 } +- +-test_impl_try_from_always_ok! { test_try_u128u128, u128, u128 } + + test_impl_try_from_always_ok! { test_try_i8i8, i8, i8 } + test_impl_try_from_always_ok! { test_try_i8i16, i8, i16 } + test_impl_try_from_always_ok! { test_try_i8i32, i8, i32 } + test_impl_try_from_always_ok! { test_try_i8i64, i8, i64 } +-test_impl_try_from_always_ok! { test_try_i8i128, i8, i128 } + + test_impl_try_from_always_ok! { test_try_i16i16, i16, i16 } + test_impl_try_from_always_ok! { test_try_i16i32, i16, i32 } + test_impl_try_from_always_ok! { test_try_i16i64, i16, i64 } +-test_impl_try_from_always_ok! { test_try_i16i128, i16, i128 } + + test_impl_try_from_always_ok! { test_try_i32i32, i32, i32 } + test_impl_try_from_always_ok! { test_try_i32i64, i32, i64 } +-test_impl_try_from_always_ok! { test_try_i32i128, i32, i128 } + + test_impl_try_from_always_ok! { test_try_i64i64, i64, i64 } +-test_impl_try_from_always_ok! { test_try_i64i128, i64, i128 } +- +-test_impl_try_from_always_ok! { test_try_i128i128, i128, i128 } + + test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } + test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } +@@ -355,28 +337,21 @@ test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u8, i8, u8 } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u16, i8, u16 } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u32, i8, u32 } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u64, i8, u64 } +-test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u128, i8, u128 } + + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u16, i16, u16 } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u32, i16, u32 } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u64, i16, u64 } +-test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u128, i16, u128 } + + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i32u32, i32, u32 } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i32u64, i32, u64 } +-test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i32u128, i32, u128 } + + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i64u64, i64, u64 } +-test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i64u128, i64, u128 } +- +-test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i128u128, i128, u128 } + + assume_usize_width! { + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8usize, i8, usize } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16usize, i16, usize } + + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_isizeu64, isize, u64 } +- test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_isizeu128, isize, u128 } + test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_isizeusize, isize, usize } + } + +@@ -412,12 +387,6 @@ test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u64i16, u64, i16 } + test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u64i32, u64, i32 } + test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u64i64, u64, i64 } + +-test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i8, u128, i8 } +-test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i16, u128, i16 } +-test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i32, u128, i32 } +-test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i64, u128, i64 } +-test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i128, u128, i128 } +- + assume_usize_width! { + test_impl_try_from_unsigned_to_signed_upper_err! { test_try_usizei8, usize, i8 } + test_impl_try_from_unsigned_to_signed_upper_err! { test_try_usizei16, usize, i16 } +@@ -459,11 +428,6 @@ test_impl_try_from_same_sign_err! { test_try_u64u8, u64, u8 } + test_impl_try_from_same_sign_err! { test_try_u64u16, u64, u16 } + test_impl_try_from_same_sign_err! { test_try_u64u32, u64, u32 } + +-test_impl_try_from_same_sign_err! { test_try_u128u8, u128, u8 } +-test_impl_try_from_same_sign_err! { test_try_u128u16, u128, u16 } +-test_impl_try_from_same_sign_err! { test_try_u128u32, u128, u32 } +-test_impl_try_from_same_sign_err! { test_try_u128u64, u128, u64 } +- + test_impl_try_from_same_sign_err! { test_try_i16i8, i16, i8 } + test_impl_try_from_same_sign_err! { test_try_isizei8, isize, i8 } + +@@ -474,11 +438,6 @@ test_impl_try_from_same_sign_err! { test_try_i64i8, i64, i8 } + test_impl_try_from_same_sign_err! { test_try_i64i16, i64, i16 } + test_impl_try_from_same_sign_err! { test_try_i64i32, i64, i32 } + +-test_impl_try_from_same_sign_err! { test_try_i128i8, i128, i8 } +-test_impl_try_from_same_sign_err! { test_try_i128i16, i128, i16 } +-test_impl_try_from_same_sign_err! { test_try_i128i32, i128, i32 } +-test_impl_try_from_same_sign_err! { test_try_i128i64, i128, i64 } +- + assume_usize_width! { + test_impl_try_from_same_sign_err! { test_try_usizeu8, usize, u8 } + } +@@ -517,14 +476,8 @@ test_impl_try_from_signed_to_unsigned_err! { test_try_i64u8, i64, u8 } + test_impl_try_from_signed_to_unsigned_err! { test_try_i64u16, i64, u16 } + test_impl_try_from_signed_to_unsigned_err! { test_try_i64u32, i64, u32 } + +-test_impl_try_from_signed_to_unsigned_err! { test_try_i128u8, i128, u8 } +-test_impl_try_from_signed_to_unsigned_err! { test_try_i128u16, i128, u16 } +-test_impl_try_from_signed_to_unsigned_err! { test_try_i128u32, i128, u32 } +-test_impl_try_from_signed_to_unsigned_err! { test_try_i128u64, i128, u64 } +- + assume_usize_width! { + test_impl_try_from_signed_to_unsigned_err! { test_try_isizeu8, isize, u8 } +- test_impl_try_from_signed_to_unsigned_err! { test_try_i128usize, i128, usize } + } + + macro_rules! test_float { +diff --git a/src/libcore/time.rs b/src/libcore/time.rs +index 25721b7fce..2588ae442f 100644 +--- a/src/libcore/time.rs ++++ b/src/libcore/time.rs +@@ -268,57 +268,6 @@ impl Duration { + #[inline] + pub const fn subsec_nanos(&self) -> u32 { self.nanos } + +- /// Returns the total number of milliseconds contained by this `Duration`. +- /// +- /// # Examples +- /// +- /// ``` +- /// # #![feature(duration_as_u128)] +- /// use std::time::Duration; +- /// +- /// let duration = Duration::new(5, 730023852); +- /// assert_eq!(duration.as_millis(), 5730); +- /// ``` +- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[inline] +- pub fn as_millis(&self) -> u128 { +- self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 +- } +- +- /// Returns the total number of microseconds contained by this `Duration`. +- /// +- /// # Examples +- /// +- /// ``` +- /// # #![feature(duration_as_u128)] +- /// use std::time::Duration; +- /// +- /// let duration = Duration::new(5, 730023852); +- /// assert_eq!(duration.as_micros(), 5730023); +- /// ``` +- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[inline] +- pub fn as_micros(&self) -> u128 { +- self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128 +- } +- +- /// Returns the total number of nanoseconds contained by this `Duration`. +- /// +- /// # Examples +- /// +- /// ``` +- /// # #![feature(duration_as_u128)] +- /// use std::time::Duration; +- /// +- /// let duration = Duration::new(5, 730023852); +- /// assert_eq!(duration.as_nanos(), 5730023852); +- /// ``` +- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[inline] +- pub fn as_nanos(&self) -> u128 { +- self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128 +- } +- + /// Checked `Duration` addition. Computes `self + other`, returning [`None`] + /// if overflow occurred. + /// +-- +2.15.2 (Apple Git-101.1) + From 9615f3a1372e715772815292cfab23a456932f63 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 13:35:03 +0200 Subject: [PATCH 0041/1566] Add instructions to build libcore --- Readme.md | 15 ++++++++++++++- build.sh | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 40ddd2478a6de..64e178f9133d1 100644 --- a/Readme.md +++ b/Readme.md @@ -5,7 +5,7 @@ ## Building ```bash -$ git clone https://github.com/bjorn3/rustc_codegen_cranelift +$ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift $ git submodule update --init $ cargo build @@ -19,6 +19,19 @@ $ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_c > You must compile with `-Og`, because checked binops are not yet supported. +## Building libcore + +```bash +$ git clone https://github.com/rust-lang/rust.git +$ cd rust +$ git apply ../0001-Disable-stdsimd-in-libcore.patch +$ git apply ../0002-Disable-u128-and-i128-in-libcore.patch +$ cd ../ +$ ./build.sh +``` + +> ⚠⚠⚠ You will get a panic because of unimplemented stuff ⚠⚠⚠ + ## Not yet supported * [ ] Checked binops diff --git a/build.sh b/build.sh index 300a12606b14b..1990281fb306a 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ cargo build || exit 1 rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so example.rs --crate-type lib -Og -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ../rust/src/libcore/lib.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ./rust/src/libcore/lib.rs --crate-type lib -Og From 9a9054ad236a47c082e289ead24dec801084a66f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 13:43:17 +0200 Subject: [PATCH 0042/1566] Disable define_function to prevent crashing on things cranelift doesn't yet support --- example.rs | 5 +++-- src/base.rs | 4 +++- src/lib.rs | 40 +++++++++++++++++++++------------------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/example.rs b/example.rs index 94215a50fc1b0..7dc816aa7dc91 100644 --- a/example.rs +++ b/example.rs @@ -1,5 +1,6 @@ #![feature(no_core, lang_items)] #![no_core] +#![allow(dead_code)] #[lang="sized"] trait Sized {} @@ -52,14 +53,14 @@ fn bcd(b: bool, a: u8) -> u8 { } // FIXME make calls work -/*fn call() { +fn call() { abc(42); } fn indirect_call() { let f: fn() = call; f(); -}*/ +} enum BoolOption { Some(bool), diff --git a/src/base.rs b/src/base.rs index 6f72fadf48726..31eb6e462bfd9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -50,7 +50,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } context.func = f; - cx.module.define_function(func_id, context).unwrap(); + // TODO: cranelift doesn't yet support some of the things needed + // cx.module.define_function(func_id, context).unwrap(); + context.clear(); } inst => cx.tcx.sess.warn(&format!("Unimplemented instance {:?}", inst)), diff --git a/src/lib.rs b/src/lib.rs index dc640838b6b84..e02c431b21b6f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -192,27 +192,29 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Compiled everything"); - module.finalize_all(); - - tcx.sess.warn("Finalized everything"); - - for (inst, func_id) in def_id_fn_id_map.iter() { - //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { - if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" { - continue; + // TODO: this doesn't work most of the time + if false { + module.finalize_all(); + tcx.sess.warn("Finalized everything"); + + for (inst, func_id) in def_id_fn_id_map.iter() { + //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { + if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" { + continue; + } + let finalized_function: *const u8 = module.finalize_function(*func_id); + /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = 0u32; + f(&mut res); + tcx.sess.warn(&format!("ret_42 returned {}", res));*/ + let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = false; + f(&mut res, &3, false); + tcx.sess.warn(&format!("option_unwrap_or returned {}", res)); } - let finalized_function: *const u8 = module.finalize_function(*func_id); - /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = 0u32; - f(&mut res); - tcx.sess.warn(&format!("ret_42 returned {}", res));*/ - let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = false; - f(&mut res, &3, false); - tcx.sess.warn(&format!("option_unwrap_or returned {}", res)); - } - module.finish(); + module.finish(); + } tcx.sess.fatal("unimplemented"); From 9e45cc490f70ef64f90d46aa40442b8f43fd28a0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 13:46:56 +0200 Subject: [PATCH 0043/1566] Monomorphize type of constant --- src/constant.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index a4f5032fb322f..33f7e7443f02b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -15,23 +15,24 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons .unwrap(), }; - let layout = fx.layout_of(const_.ty); - match const_.ty.sty { + let ty = fx.monomorphize(&const_.ty); + let layout = fx.layout_of(ty); + match ty.sty { TypeVariants::TyBool => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as u64 as i64) + CValue::const_val(fx, ty, bits as u64 as i64) } TypeVariants::TyUint(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as u64 as i64) + CValue::const_val(fx, ty, bits as u64 as i64) } TypeVariants::TyInt(_) => { let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); - CValue::const_val(fx, const_.ty, bits as i128 as i64) + CValue::const_val(fx, ty, bits as i128 as i64) } TypeVariants::TyFnDef(def_id, substs) => { let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); - CValue::Func(func_ref, fx.layout_of(const_.ty)) + CValue::Func(func_ref, layout) } _ => { let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); From fdc625e18a38c3853218c096a632a6841b0d579f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 14:21:13 +0200 Subject: [PATCH 0044/1566] Implement casting between TyRef and TyRawPtr --- example.rs | 4 ++++ src/base.rs | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/example.rs b/example.rs index 7dc816aa7dc91..d7ef022445077 100644 --- a/example.rs +++ b/example.rs @@ -85,3 +85,7 @@ fn return_str() -> &'static str { fn promoted_val() -> &'static u8 { &(1 * 2) } + +fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 { + abc as *const u8 +} diff --git a/src/base.rs b/src/base.rs index 31eb6e462bfd9..c17e9d0240937 100644 --- a/src/base.rs +++ b/src/base.rs @@ -371,7 +371,19 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let layout = fx.layout_of(ty); lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); } - Rvalue::Cast(CastKind::Misc, operand, ty) => unimplemented!("rval misc {:?} {:?}", operand, ty), + Rvalue::Cast(CastKind::Misc, operand, ty) => { + let operand = trans_operand(fx, operand); + match (&operand.layout().ty.sty, &ty.sty) { + (TypeVariants::TyRef(..), TypeVariants::TyRef(..)) | + (TypeVariants::TyRef(..), TypeVariants::TyRawPtr(..)) | + (TypeVariants::TyRawPtr(..), TypeVariants::TyRef(..)) | + (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { + let layout = fx.layout_of(ty); + lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); + } + _ => unimplemented!("rval misc {:?} {:?}", operand, ty), + } + }, Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty), Rvalue::Cast(CastKind::Unsize, operand, ty) => unimplemented!("rval unsize {:?} {:?}", operand, ty), Rvalue::Discriminant(place) => { @@ -436,7 +448,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx } } Rvalue::Repeat(operand, times) => unimplemented!("rval repeat {:?} {:?}", operand, times), - Rvalue::Len(lval) => unimplemented!("rval len {:?}", lval), + Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), Rvalue::NullaryOp(NullOp::SizeOf, ty) => unimplemented!("rval size_of {:?}", ty), Rvalue::Aggregate(_, _) => bug!("shouldn't exist at trans {:?}", rval), From f52727b8e65ab15a8e12a3927ff3855e2922eda7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 15:17:22 +0200 Subject: [PATCH 0045/1566] Implement some binops for TyRawPtr --- example.rs | 26 +++++++++++- src/base.rs | 113 +++++++++++++++++++++++++++++++++++++++------------- src/lib.rs | 2 +- 3 files changed, 111 insertions(+), 30 deletions(-) diff --git a/example.rs b/example.rs index d7ef022445077..9f9d518f3907f 100644 --- a/example.rs +++ b/example.rs @@ -6,7 +6,11 @@ trait Sized {} #[lang="copy"] -trait Copy {} +unsafe trait Copy {} + +unsafe impl Copy for u8 {} +unsafe impl<'a, T: ?Sized> Copy for &'a T {} +unsafe impl Copy for *const T {} #[lang="freeze"] trait Freeze {} @@ -27,6 +31,22 @@ impl Mul for u8 { } } +#[lang = "eq"] +pub trait PartialEq { + fn eq(&self, other: &Rhs) -> bool; + fn ne(&self, other: &Rhs) -> bool; +} + +impl PartialEq for u8 { + fn eq(&self, other: &u8) -> bool { (*self) == (*other) } + fn ne(&self, other: &u8) -> bool { (*self) != (*other) } +} + +impl PartialEq for *const T { + fn eq(&self, other: &*const T) -> bool { *self == *other } + fn ne(&self, other: &*const T) -> bool { *self != *other } +} + #[lang="panic"] fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { loop {} @@ -89,3 +109,7 @@ fn promoted_val() -> &'static u8 { fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 { abc as *const u8 } + +fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { + a == b +} diff --git a/src/base.rs b/src/base.rs index c17e9d0240937..37f350b6500ae 100644 --- a/src/base.rs +++ b/src/base.rs @@ -327,6 +327,9 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx TypeVariants::TyInt(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true, false) } + TypeVariants::TyRawPtr(..) => { + trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) + } _ => unimplemented!("bin op {:?} for {:?}", bin_op, ty), }; lval.write_cvalue(fx, res); @@ -467,36 +470,90 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx Ok(()) } +macro_rules! binop_match { + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, bug) => { + bug!("bin op {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) + }; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, icmp($cc:ident)) => {{ + let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); + $fx.bcx.ins().bint(types::I8, b) + }}; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $name:ident) => { + $fx.bcx.ins().$name($lhs, $rhs) + }; + ( + $fx:expr, $bin_op:expr, $signed:expr, $lhs:expr, $rhs:expr, $bug_fmt:expr; + $( + $var:ident ($sign:pat) $name:tt $( ( $next:tt ) )? ; + )* + ) => { + match ($bin_op, $signed) { + $( + (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, $lhs, $rhs, $name $( ( $next ) )?), + )* + } + } +} + fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { - let res = match (bin_op, signed) { - (BinOp::Add, _) => fx.bcx.ins().iadd(lhs, rhs), - (BinOp::Sub, _) => fx.bcx.ins().isub(lhs, rhs), - (BinOp::Mul, _) => fx.bcx.ins().imul(lhs, rhs), - (BinOp::Div, false) => fx.bcx.ins().udiv(lhs, rhs), - (BinOp::Div, true) => fx.bcx.ins().sdiv(lhs, rhs), - (BinOp::Rem, false) => fx.bcx.ins().urem(lhs, rhs), - (BinOp::Rem, true) => fx.bcx.ins().srem(lhs, rhs), - (BinOp::BitXor, _) => fx.bcx.ins().bxor(lhs, rhs), - (BinOp::BitAnd, _) => fx.bcx.ins().band(lhs, rhs), - (BinOp::BitOr, _) => fx.bcx.ins().bor(lhs, rhs), - (BinOp::Shl, _) => fx.bcx.ins().ishl(lhs, rhs), - (BinOp::Shr, false) => fx.bcx.ins().ushr(lhs, rhs), - (BinOp::Shr, true) => fx.bcx.ins().sshr(lhs, rhs), - - // TODO: cast b1 to u8 - (BinOp::Eq, _) => fx.bcx.ins().icmp(IntCC::Equal , lhs, rhs), - (BinOp::Lt, false) => fx.bcx.ins().icmp(IntCC::UnsignedLessThan , lhs, rhs), - (BinOp::Lt, true) => fx.bcx.ins().icmp(IntCC::SignedLessThan , lhs, rhs), - (BinOp::Le, false) => fx.bcx.ins().icmp(IntCC::UnsignedLessThanOrEqual , lhs, rhs), - (BinOp::Le, true) => fx.bcx.ins().icmp(IntCC::SignedLessThanOrEqual , lhs, rhs), - (BinOp::Ne, _) => fx.bcx.ins().icmp(IntCC::NotEqual , lhs, rhs), - (BinOp::Ge, false) => fx.bcx.ins().icmp(IntCC::UnsignedGreaterThanOrEqual , lhs, rhs), - (BinOp::Ge, true) => fx.bcx.ins().icmp(IntCC::SignedGreaterThanOrEqual , lhs, rhs), - (BinOp::Gt, false) => fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan , lhs, rhs), - (BinOp::Gt, true) => fx.bcx.ins().icmp(IntCC::SignedGreaterThan , lhs, rhs), - - (BinOp::Offset, _) => bug!("bin op Offset on non ptr lhs: {:?} rhs: {:?}", lhs, rhs), + let res = binop_match! { + fx, bin_op, signed, lhs, rhs, "non ptr"; + Add (_) iadd; + Sub (_) isub; + Mul (_) imul; + Div (false) udiv; + Div (true) sdiv; + Rem (false) urem; + Rem (true) srem; + BitXor (_) bxor; + BitAnd (_) band; + BitOr (_) bor; + Shl (_) ishl; + Shr (false) ushr; + Shr (true) sshr; + + Eq (_) icmp(Equal); + Lt (false) icmp(UnsignedLessThan); + Lt (true) icmp(SignedLessThan); + Le (false) icmp(UnsignedLessThanOrEqual); + Le (true) icmp(SignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (false) icmp(UnsignedGreaterThanOrEqual); + Ge (true) icmp(SignedGreaterThanOrEqual); + Gt (false) icmp(UnsignedGreaterThan); + Gt (true) icmp(SignedGreaterThan); + + Offset (_) bug; }; + + // TODO: return correct value for checked binops + CValue::ByVal(res, fx.layout_of(ty)) +} + +fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, _checked: bool) -> CValue<'tcx> { + let res = binop_match! { + fx, bin_op, false, lhs, rhs, "ptr"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) iadd; + }; + // TODO: return correct value for checked binops CValue::ByVal(res, fx.layout_of(ty)) } diff --git a/src/lib.rs b/src/lib.rs index e02c431b21b6f..68d807d2b98ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private)] +#![feature(rustc_private, macro_at_most_once_rep)] #![allow(intra_doc_link_resolution_failure)] extern crate syntax; From 5951efb7489b3f44699a04905c9025a12d8b8ce3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 16:22:29 +0200 Subject: [PATCH 0046/1566] Implement int casts --- Readme.md | 1 - example.rs | 21 +++++++++++++++++++++ src/base.rs | 22 +++++++++++++++++----- src/common.rs | 2 +- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/Readme.md b/Readme.md index 64e178f9133d1..70ca09187699f 100644 --- a/Readme.md +++ b/Readme.md @@ -37,7 +37,6 @@ $ ./build.sh * [ ] Checked binops * [ ] Statics * [ ] Drop glue -* [ ] Ints cast * [ ] Building libraries * [ ] Other call abi's diff --git a/example.rs b/example.rs index 9f9d518f3907f..ba285d38bc9ce 100644 --- a/example.rs +++ b/example.rs @@ -9,6 +9,14 @@ trait Sized {} unsafe trait Copy {} unsafe impl Copy for u8 {} +unsafe impl Copy for u16 {} +unsafe impl Copy for u32 {} +unsafe impl Copy for u64 {} +unsafe impl Copy for usize {} +unsafe impl Copy for i8 {} +unsafe impl Copy for i16 {} +unsafe impl Copy for i32 {} +unsafe impl Copy for isize {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl Copy for *const T {} @@ -113,3 +121,16 @@ fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 { fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { a == b } + +fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize) { + ( + a as u8, + a as u16, + a as u32, + a as usize, + a as i8, + a as i16, + a as i32, + a as isize, + ) +} diff --git a/src/base.rs b/src/base.rs index 37f350b6500ae..33bb918a8a846 100644 --- a/src/base.rs +++ b/src/base.rs @@ -374,17 +374,29 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx let layout = fx.layout_of(ty); lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); } - Rvalue::Cast(CastKind::Misc, operand, ty) => { + Rvalue::Cast(CastKind::Misc, operand, to_ty) => { let operand = trans_operand(fx, operand); - match (&operand.layout().ty.sty, &ty.sty) { + let from_ty = operand.layout().ty; + match (&from_ty.sty, &to_ty.sty) { (TypeVariants::TyRef(..), TypeVariants::TyRef(..)) | (TypeVariants::TyRef(..), TypeVariants::TyRawPtr(..)) | (TypeVariants::TyRawPtr(..), TypeVariants::TyRef(..)) | (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { - let layout = fx.layout_of(ty); - lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); + lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - _ => unimplemented!("rval misc {:?} {:?}", operand, ty), + (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | + (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { + let from = operand.load_value(fx); + let res = ::common::cton_intcast(fx, from, from_ty, to_ty, false); + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } + (TypeVariants::TyInt(_), TypeVariants::TyInt(_)) | + (TypeVariants::TyInt(_), TypeVariants::TyUint(_)) => { + let from = operand.load_value(fx); + let res = ::common::cton_intcast(fx, from, from_ty, to_ty, true); + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } + _ => unimplemented!("rval misc {:?} {:?}", operand, to_ty), } }, Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty), diff --git a/src/common.rs b/src/common.rs index 5a47c9e7ad0a6..5e13ad4a434f5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -315,7 +315,7 @@ pub fn cton_intcast<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, fro if from == to { return val; } - if from.wider_or_equal(to) { + if to.wider_or_equal(from) { if signed { fx.bcx.ins().sextend(to, val) } else { From 5f57ac5725653a76a54f810abcb3a6f935c12065 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 16:29:40 +0200 Subject: [PATCH 0047/1566] Workaround a bug --- Readme.md | 8 +++++++- src/constant.rs | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 70ca09187699f..835b0e813b573 100644 --- a/Readme.md +++ b/Readme.md @@ -47,4 +47,10 @@ $ ./build.sh * [ ] Some rvalue's * [ ] Inline assembly -* [ ] Custom sections \ No newline at end of file +* [ ] Custom sections + +## Known errors + +* [ ] cranelift-module api seems to be used wrong, thus causing panic for some consts +* [ ] cranelift-codegen doesn't have encodings for some instructions for types smaller than I32 +* [ ] `thread 'main' panicked at 'assertion failed: !value.has_escaping_regions()', librustc/ty/sty.rs:754:9` in cton_sig_from_mono_fn_sig \ No newline at end of file diff --git a/src/constant.rs b/src/constant.rs index 33f7e7443f02b..2e17b318fcb50 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -35,6 +35,11 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons CValue::Func(func_ref, layout) } _ => { + if true { + // TODO: cranelift-module api seems to be used wrong, + // thus causing panics for some consts, so this disables it + return CValue::ByRef(fx.bcx.ins().iconst(types::I64, 0), layout); + } let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); let alloc = fx.tcx.const_value_to_allocation(value); //println!("const value: {:?} allocation: {:?}", value, alloc); From dabfac3df70c796525df4ba806ed1d3e9a57016a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Jul 2018 17:07:10 +0200 Subject: [PATCH 0048/1566] Fix a panic --- Readme.md | 1 - example.rs | 6 ++++++ src/common.rs | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 835b0e813b573..318ac226461f3 100644 --- a/Readme.md +++ b/Readme.md @@ -53,4 +53,3 @@ $ ./build.sh * [ ] cranelift-module api seems to be used wrong, thus causing panic for some consts * [ ] cranelift-codegen doesn't have encodings for some instructions for types smaller than I32 -* [ ] `thread 'main' panicked at 'assertion failed: !value.has_escaping_regions()', librustc/ty/sty.rs:754:9` in cton_sig_from_mono_fn_sig \ No newline at end of file diff --git a/example.rs b/example.rs index ba285d38bc9ce..884a15710261d 100644 --- a/example.rs +++ b/example.rs @@ -134,3 +134,9 @@ fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize) { a as isize, ) } + +struct DebugTuple(()); + +fn debug_tuple() -> DebugTuple { + DebugTuple(()) +} diff --git a/src/common.rs b/src/common.rs index 5e13ad4a434f5..73c13619b9794 100644 --- a/src/common.rs +++ b/src/common.rs @@ -260,6 +260,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); CPlace::Addr(fx.bcx.ins().iadd(base, field_offset), field_ty) } else { + fx.bcx.ins().nop(); CPlace::Addr(base, field_ty) } } @@ -290,9 +291,8 @@ pub fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: I pub fn cton_sig_from_mono_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>) -> Signature { // TODO: monomorphize signature - // TODO: this should likely not use skip_binder() - let sig = sig.skip_binder(); + let sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig); let inputs = sig.inputs(); let _output = sig.output(); assert!(!sig.variadic, "Variadic function are not yet supported"); From 75d8fefc18411785d61873c6602d17907e0574ff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 17:59:13 +0200 Subject: [PATCH 0049/1566] Mention needing a nightly compiler in readme --- Readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Readme.md b/Readme.md index 318ac226461f3..643611ce74f11 100644 --- a/Readme.md +++ b/Readme.md @@ -7,6 +7,7 @@ ```bash $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift +$ rustup override set nightly $ git submodule update --init $ cargo build ``` From 85eaa2c0c9ad71cdc4b52a41a7ab41884beb3a87 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 18:41:37 +0200 Subject: [PATCH 0050/1566] Better libcore building instructions and rustup --- 0001-Disable-stdsimd-in-libcore.patch | 14 +- 0002-Disable-u128-and-i128-in-libcore.patch | 512 +++++++++----------- Readme.md | 7 +- build.sh | 2 +- prepare_libcore.sh | 11 + src/base.rs | 1 - 6 files changed, 249 insertions(+), 298 deletions(-) create mode 100755 prepare_libcore.sh diff --git a/0001-Disable-stdsimd-in-libcore.patch b/0001-Disable-stdsimd-in-libcore.patch index 5521bea925b70..7db533929d8bc 100644 --- a/0001-Disable-stdsimd-in-libcore.patch +++ b/0001-Disable-stdsimd-in-libcore.patch @@ -1,6 +1,6 @@ -From cc175e6a3f59c7fe1523fd441214e0303f8fee80 Mon Sep 17 00:00:00 2001 +From a26747487d398af360dc16344b1f9d2b367720c9 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 30 Jun 2018 12:30:30 +0200 +Date: Thu, 19 Jul 2018 18:26:56 +0200 Subject: [PATCH] Disable stdsimd in libcore --- @@ -8,10 +8,10 @@ Subject: [PATCH] Disable stdsimd in libcore 1 file changed, 2 insertions(+) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 40caee8554..f038d155a1 100644 +index bbe6ae8619..bdeb6ce426 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -240,6 +240,7 @@ macro_rules! test_v256 { ($item:item) => {}; } +@@ -238,6 +238,7 @@ macro_rules! test_v256 { ($item:item) => {}; } macro_rules! test_v512 { ($item:item) => {}; } #[allow(unused_macros)] macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } } @@ -19,11 +19,11 @@ index 40caee8554..f038d155a1 100644 #[path = "../stdsimd/coresimd/mod.rs"] #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)] #[unstable(feature = "stdsimd", issue = "48556")] -@@ -252,3 +253,4 @@ pub use coresimd::simd; +@@ -250,3 +251,4 @@ pub use coresimd::simd; #[stable(feature = "simd_arch", since = "1.27.0")] #[cfg(not(stage0))] pub use coresimd::arch; +*/ --- -2.15.2 (Apple Git-101.1) +-- +2.11.0 diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch index 429b946bb7fa7..e4a1207fe20d6 100644 --- a/0002-Disable-u128-and-i128-in-libcore.patch +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,29 +1,29 @@ -From 865d6486d85985d65ccb850695c25579b98ca14c Mon Sep 17 00:00:00 2001 +From 601b4bf31350a620a9de8a50ad699852331fa17e Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Wed, 18 Jul 2018 12:21:43 +0200 +Date: Thu, 19 Jul 2018 18:34:03 +0200 Subject: [PATCH] Disable u128 and i128 in libcore --- - src/libcore/clone.rs | 4 ++-- - src/libcore/cmp.rs | 6 ++--- - src/libcore/default.rs | 2 -- - src/libcore/fmt/num.rs | 6 +---- - src/libcore/hash/mod.rs | 20 ---------------- - src/libcore/iter/range.rs | 12 ++++------ + src/libcore/clone.rs | 4 +- + src/libcore/cmp.rs | 6 +-- + src/libcore/default.rs | 2 - + src/libcore/fmt/num.rs | 6 +-- + src/libcore/hash/mod.rs | 20 ---------- + src/libcore/iter/range.rs | 1 - src/libcore/iter/traits.rs | 2 +- - src/libcore/lib.rs | 2 -- - src/libcore/marker.rs | 4 ++-- - src/libcore/mem.rs | 2 -- - src/libcore/num/i128.rs | 17 -------------- - src/libcore/num/mod.rs | 54 +++++++++----------------------------------- - src/libcore/num/u128.rs | 16 ------------- - src/libcore/num/wrapping.rs | 14 ++++-------- - src/libcore/ops/arith.rs | 22 +++++++++--------- - src/libcore/ops/bit.rs | 30 +++++++++--------------- - src/libcore/tests/iter.rs | 15 ------------ - src/libcore/tests/num/mod.rs | 47 -------------------------------------- - src/libcore/time.rs | 51 ----------------------------------------- - 19 files changed, 52 insertions(+), 274 deletions(-) + src/libcore/lib.rs | 2 - + src/libcore/marker.rs | 4 +- + src/libcore/mem.rs | 2 - + src/libcore/num/i128.rs | 17 --------- + src/libcore/num/mod.rs | 87 +++++++++++++------------------------------- + src/libcore/num/u128.rs | 16 -------- + src/libcore/num/wrapping.rs | 14 +++---- + src/libcore/ops/arith.rs | 22 +++++------ + src/libcore/ops/bit.rs | 30 ++++++--------- + src/libcore/tests/iter.rs | 15 -------- + src/libcore/tests/num/mod.rs | 18 --------- + src/libcore/time.rs | 51 -------------------------- + 19 files changed, 62 insertions(+), 257 deletions(-) delete mode 100644 src/libcore/num/i128.rs delete mode 100644 src/libcore/num/u128.rs @@ -33,7 +33,7 @@ index 3b15ba2b4a..de08ce0289 100644 +++ b/src/libcore/clone.rs @@ -172,8 +172,8 @@ mod impls { } - + impl_clone! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -48,29 +48,29 @@ index 3626a266ad..4106432a41 100644 +++ b/src/libcore/cmp.rs @@ -798,7 +798,7 @@ mod impls { } - + partial_eq_impl! { - bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 + bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + macro_rules! eq_impl { @@ -808,7 +808,7 @@ mod impls { )*) } - + - eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! partial_ord_impl { ($($t:ty)*) => ($( @@ -897,7 +897,7 @@ mod impls { } } - + - ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/src/libcore/default.rs b/src/libcore/default.rs @@ -82,14 +82,14 @@ index ab36e29b1e..1926719657 100644 default_impl! { u32, 0, "Returns the default value of `0`" } default_impl! { u64, 0, "Returns the default value of `0`" } -default_impl! { u128, 0, "Returns the default value of `0`" } - + default_impl! { isize, 0, "Returns the default value of `0`" } default_impl! { i8, 0, "Returns the default value of `0`" } default_impl! { i16, 0, "Returns the default value of `0`" } default_impl! { i32, 0, "Returns the default value of `0`" } default_impl! { i64, 0, "Returns the default value of `0`" } -default_impl! { i128, 0, "Returns the default value of `0`" } - + default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs @@ -102,7 +102,7 @@ index 51391fa50d..140255ea7e 100644 fn to_u64(&self) -> u64; - fn to_u128(&self) -> u128; } - + macro_rules! doit { @@ -40,10 +39,9 @@ macro_rules! doit { fn to_u16(&self) -> u16 { *self as u16 } @@ -113,7 +113,7 @@ index 51391fa50d..140255ea7e 100644 } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + /// A type that represents a specific radix #[doc(hidden)] @@ -184,7 +182,6 @@ integer! { i8, u8 } @@ -121,11 +121,11 @@ index 51391fa50d..140255ea7e 100644 integer! { i32, u32 } integer! { i64, u64 } -integer! { i128, u128 } - + const DEC_DIGITS_LUT: &'static[u8] = b"0001020304050607080910111213141516171819\ @@ -260,7 +257,6 @@ macro_rules! impl_Display { - + impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); impl_Display!(i64, u64: to_u64); -impl_Display!(i128, u128: to_u128); @@ -189,10 +189,10 @@ index e6f8dfffd6..2670d55537 100644 - (u128, write_u128), - (i128, write_i128), } - + #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index 5896322f11..67809897f5 100644 +index 651c7a35d4..3708b8ea95 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -175,7 +175,6 @@ step_impl_signed!([i64: u64]); @@ -200,41 +200,9 @@ index 5896322f11..67809897f5 100644 #[cfg(not(target_pointer_width = "64"))] step_impl_no_between!(u64 i64); -step_impl_no_between!(u128 i128); - + macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( -@@ -509,8 +508,8 @@ macro_rules! try_from_upper_bounded { - mod ptr_try_from_impls { - use super::PrivateTryFromUsize; - -- try_from_unbounded!(u16, u32, u64, u128); -- try_from_unbounded!(i32, i64, i128); -+ try_from_unbounded!(u16, u32, u64); -+ try_from_unbounded!(i32, i64); - } - - #[cfg(target_pointer_width = "32")] -@@ -518,9 +517,9 @@ mod ptr_try_from_impls { - use super::PrivateTryFromUsize; - - try_from_upper_bounded!(u16); -- try_from_unbounded!(u32, u64, u128); -+ try_from_unbounded!(u32, u64); - try_from_upper_bounded!(i32); -- try_from_unbounded!(i64, i128); -+ try_from_unbounded!(i64); - } - - #[cfg(target_pointer_width = "64")] -@@ -528,7 +527,6 @@ mod ptr_try_from_impls { - use super::PrivateTryFromUsize; - - try_from_upper_bounded!(u16, u32); -- try_from_unbounded!(u64, u128); -+ try_from_unbounded!(u64); - try_from_upper_bounded!(i32, i64); -- try_from_unbounded!(i128); - } diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index 4b2c1aa551..ec3991fa01 100644 --- a/src/libcore/iter/traits.rs @@ -242,38 +210,38 @@ index 4b2c1aa551..ec3991fa01 100644 @@ -843,7 +843,7 @@ macro_rules! float_sum_product { )*) } - + -integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } float_sum_product! { f32 f64 } - + /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index f038d155a1..31e4223730 100644 +index bdeb6ce426..3bec7a240c 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -148,14 +148,12 @@ mod uint_macros; +@@ -146,14 +146,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; -#[path = "num/i128.rs"] pub mod i128; - + #[path = "num/usize.rs"] pub mod usize; #[path = "num/u8.rs"] pub mod u8; #[path = "num/u16.rs"] pub mod u16; #[path = "num/u32.rs"] pub mod u32; #[path = "num/u64.rs"] pub mod u64; -#[path = "num/u128.rs"] pub mod u128; - + #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 5db5d88d4a..d7d6b45015 100644 +index 4f37b46258..2e8d514700 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs -@@ -643,8 +643,8 @@ mod copy_impls { +@@ -649,8 +649,8 @@ mod copy_impls { } - + impl_copy! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -283,10 +251,10 @@ index 5db5d88d4a..d7d6b45015 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 08bd9289ab..aca522e445 100644 +index 8fb4e0d6a0..e9621d723d 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs -@@ -194,12 +194,10 @@ pub fn forget(t: T) { +@@ -196,12 +196,10 @@ pub fn forget(t: T) { /// u16 | 2 /// u32 | 4 /// u64 | 8 @@ -323,21 +291,21 @@ index 989376d1ac..0000000000 - -int_module! { i128, #[stable(feature = "i128", since="1.26.0")] } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 7e2dd304d7..b01c843ad7 100644 +index 0b8f8f0703..584d24130e 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs -@@ -94,7 +94,6 @@ nonzero_integers! { +@@ -95,7 +95,6 @@ nonzero_integers! { NonZeroU16(u16); NonZeroU32(u32); NonZeroU64(u64); - NonZeroU128(u128); NonZeroUsize(usize); } - -@@ -2047,12 +2046,6 @@ impl i64 { + +@@ -1954,12 +1953,6 @@ impl i64 { int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" } } - + -#[lang = "i128"] -impl i128 { - int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, @@ -347,10 +315,10 @@ index 7e2dd304d7..b01c843ad7 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4290,11 +4283,6 @@ impl u64 { +@@ -4100,11 +4093,6 @@ impl u64 { uint_impl! { u64, u64, 64, 18446744073709551615, "", "" } } - + -#[lang = "u128"] -impl u128 { - uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" } @@ -359,33 +327,33 @@ index 7e2dd304d7..b01c843ad7 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4373,7 +4361,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4183,7 +4171,7 @@ macro_rules! from_str_radix_int_impl { } )*} } -from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } +from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } - + /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4474,30 +4462,25 @@ macro_rules! rev { +@@ -4299,30 +4287,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); -try_from_upper_bounded!(u128, u64, u32, u16, u8); - + try_from_both_bounded!(i16, i8); try_from_both_bounded!(i32, i16, i8); try_from_both_bounded!(i64, i32, i16, i8); -try_from_both_bounded!(i128, i64, i32, i16, i8); - + // unsigned-to-signed try_from_upper_bounded!(u8, i8); try_from_upper_bounded!(u16, i8, i16); try_from_upper_bounded!(u32, i8, i16, i32); try_from_upper_bounded!(u64, i8, i16, i32, i64); -try_from_upper_bounded!(u128, i8, i16, i32, i64, i128); - + // signed-to-unsigned -try_from_lower_bounded!(i8, u8, u16, u32, u64, u128); -try_from_lower_bounded!(i16, u16, u32, u64, u128); @@ -400,54 +368,111 @@ index 7e2dd304d7..b01c843ad7 100644 try_from_both_bounded!(i32, u16, u8); try_from_both_bounded!(i64, u32, u16, u8); -try_from_both_bounded!(i128, u64, u32, u16, u8); - + // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4514,9 +4497,9 @@ mod ptr_try_from_impls { +@@ -4334,21 +4317,21 @@ mod ptr_try_from_impls { use convert::TryFrom; - - // Fallible across platfoms, only implementation differs + + try_from_upper_bounded!(usize, u8); +- try_from_unbounded!(usize, u16, u32, u64, u128); ++ try_from_unbounded!(usize, u16, u32, u64); + try_from_upper_bounded!(usize, i8, i16); +- try_from_unbounded!(usize, i32, i64, i128); ++ try_from_unbounded!(usize, i32, i64); + + try_from_both_bounded!(isize, u8); - try_from_lower_bounded!(isize, u16, u32, u64, u128); + try_from_lower_bounded!(isize, u16, u32, u64); + try_from_both_bounded!(isize, i8); +- try_from_unbounded!(isize, i16, i32, i64, i128); ++ try_from_unbounded!(isize, i16, i32, i64); + +- rev!(try_from_upper_bounded, usize, u32, u64, u128); ++ rev!(try_from_upper_bounded, usize, u32, u64); rev!(try_from_lower_bounded, usize, i8, i16); - rev!(try_from_both_bounded, usize, i32, i64, i128); + rev!(try_from_both_bounded, usize, i32, i64); + +- rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); +- rev!(try_from_both_bounded, isize, i32, i64, i128); ++ rev!(try_from_upper_bounded, isize, u16, u32, u64); ++ rev!(try_from_both_bounded, isize, i32, i64); } - + #[cfg(target_pointer_width = "32")] -@@ -4526,9 +4509,9 @@ mod ptr_try_from_impls { - - // Fallible across platfoms, only implementation differs - try_from_both_bounded!(isize, u16); +@@ -4357,24 +4340,24 @@ mod ptr_try_from_impls { + use convert::TryFrom; + + try_from_upper_bounded!(usize, u8, u16); +- try_from_unbounded!(usize, u32, u64, u128); ++ try_from_unbounded!(usize, u32, u64); + try_from_upper_bounded!(usize, i8, i16, i32); +- try_from_unbounded!(usize, i64, i128); ++ try_from_unbounded!(usize, i64); + + try_from_both_bounded!(isize, u8, u16); - try_from_lower_bounded!(isize, u32, u64, u128); + try_from_lower_bounded!(isize, u32, u64); + try_from_both_bounded!(isize, i8, i16); +- try_from_unbounded!(isize, i32, i64, i128); ++ try_from_unbounded!(isize, i32, i64); + + rev!(try_from_unbounded, usize, u32); +- rev!(try_from_upper_bounded, usize, u64, u128); ++ rev!(try_from_upper_bounded, usize, u64); rev!(try_from_lower_bounded, usize, i8, i16, i32); - rev!(try_from_both_bounded, usize, i64, i128); + rev!(try_from_both_bounded, usize, i64); + + rev!(try_from_unbounded, isize, u16); +- rev!(try_from_upper_bounded, isize, u32, u64, u128); ++ rev!(try_from_upper_bounded, isize, u32, u64); + rev!(try_from_unbounded, isize, i32); +- rev!(try_from_both_bounded, isize, i64, i128); ++ rev!(try_from_both_bounded, isize, i64); } - + #[cfg(target_pointer_width = "64")] -@@ -4538,9 +4521,8 @@ mod ptr_try_from_impls { - - // Fallible across platfoms, only implementation differs - try_from_both_bounded!(isize, u16, u32); +@@ -4383,24 +4366,20 @@ mod ptr_try_from_impls { + use convert::TryFrom; + + try_from_upper_bounded!(usize, u8, u16, u32); +- try_from_unbounded!(usize, u64, u128); ++ try_from_unbounded!(usize, u64); + try_from_upper_bounded!(usize, i8, i16, i32, i64); +- try_from_unbounded!(usize, i128); + + try_from_both_bounded!(isize, u8, u16, u32); - try_from_lower_bounded!(isize, u64, u128); + try_from_lower_bounded!(isize, u64); + try_from_both_bounded!(isize, i8, i16, i32); +- try_from_unbounded!(isize, i64, i128); ++ try_from_unbounded!(isize, i64); + + rev!(try_from_unbounded, usize, u32, u64); +- rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); - rev!(try_from_both_bounded, usize, i128); + + rev!(try_from_unbounded, isize, u16, u32); +- rev!(try_from_upper_bounded, isize, u64, u128); ++ rev!(try_from_upper_bounded, isize, u64); + rev!(try_from_unbounded, isize, i32, i64); +- rev!(try_from_both_bounded, isize, i128); } - + #[doc(hidden)] -@@ -4575,7 +4557,7 @@ macro_rules! doit { +@@ -4435,7 +4414,7 @@ macro_rules! doit { } })*) } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4743,52 +4725,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4603,52 +4582,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -459,7 +484,7 @@ index 7e2dd304d7..b01c843ad7 100644 impl_from_bool! { i64, #[stable(feature = "from_bool", since = "1.28.0")] } -impl_from_bool! { i128, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { isize, #[stable(feature = "from_bool", since = "1.28.0")] } - + // Unsigned -> Unsigned impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -472,7 +497,7 @@ index 7e2dd304d7..b01c843ad7 100644 impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] } - + // Signed -> Signed impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -485,7 +510,7 @@ index 7e2dd304d7..b01c843ad7 100644 impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // Unsigned -> Signed impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -497,7 +522,7 @@ index 7e2dd304d7..b01c843ad7 100644 impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: diff --git a/src/libcore/num/u128.rs b/src/libcore/num/u128.rs @@ -523,7 +548,7 @@ index e8c783a1bb..0000000000 -#![stable(feature = "i128", since = "1.26.0")] -uint_module! { u128, #[stable(feature = "i128", since="1.26.0")] } diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs -index d7f87d37f5..666658a66b 100644 +index 1c826c2fa7..0779e31572 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -112,19 +112,17 @@ macro_rules! sh_impl_all { @@ -532,7 +557,7 @@ index d7f87d37f5..666658a66b 100644 //sh_impl_unsigned! { $t, u64 } - //sh_impl_unsigned! { $t, u128 } sh_impl_unsigned! { $t, usize } - + //sh_impl_signed! { $t, i8 } //sh_impl_signed! { $t, i16 } //sh_impl_signed! { $t, i32 } @@ -541,55 +566,55 @@ index d7f87d37f5..666658a66b 100644 //sh_impl_signed! { $t, isize } )*) } - + -sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + // FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping macro_rules! wrapping_impl { @@ -323,7 +321,7 @@ macro_rules! wrapping_impl { )*) } - + -wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl { ($($t:ty)*) => ($( -@@ -686,7 +684,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); +@@ -685,7 +683,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); )*) } - + -wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_int_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_signed { ($($t:ty)*) => ($( -@@ -815,7 +813,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); +@@ -814,7 +812,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); )*) } - + -wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 } +wrapping_int_impl_signed! { isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_unsigned { ($($t:ty)*) => ($( -@@ -892,7 +890,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); +@@ -891,7 +889,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); )*) } - + -wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 u128 } +wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 } - + mod shift_max { #![allow(non_upper_case_globals)] -@@ -919,13 +917,11 @@ mod shift_max { +@@ -918,13 +916,11 @@ mod shift_max { pub const i16: u32 = (1 << 4) - 1; pub const i32: u32 = (1 << 5) - 1; pub const i64: u32 = (1 << 6) - 1; - pub const i128: u32 = (1 << 7) - 1; pub use self::platform::isize; - + pub const u8: u32 = i8; pub const u16: u32 = i16; pub const u32: u32 = i32; @@ -604,97 +629,97 @@ index a1bc5463f7..38742be1ce 100644 @@ -114,7 +114,7 @@ macro_rules! add_impl { )*) } - + -add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction operator `-`. /// @@ -212,7 +212,7 @@ macro_rules! sub_impl { )*) } - + -sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication operator `*`. /// @@ -332,7 +332,7 @@ macro_rules! mul_impl { )*) } - + -mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division operator `/`. /// @@ -457,7 +457,7 @@ macro_rules! div_impl_integer { )*) } - + -div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! div_impl_float { ($($t:ty)*) => ($( @@ -542,7 +542,7 @@ macro_rules! rem_impl_integer { )*) } - + -rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - + + macro_rules! rem_impl_float { @@ -641,7 +641,7 @@ macro_rules! neg_impl_unsigned { } - + // neg_impl_unsigned! { usize u8 u16 u32 u64 } -neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } +neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } - + /// The addition assignment operator `+=`. /// @@ -697,7 +697,7 @@ macro_rules! add_assign_impl { )+) } - + -add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction assignment operator `-=`. /// @@ -753,7 +753,7 @@ macro_rules! sub_assign_impl { )+) } - + -sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication assignment operator `*=`. /// @@ -800,7 +800,7 @@ macro_rules! mul_assign_impl { )+) } - + -mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division assignment operator `/=`. /// @@ -846,7 +846,7 @@ macro_rules! div_assign_impl { )+) } - + -div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The remainder assignment operator `%=`. /// @@ -896,4 +896,4 @@ macro_rules! rem_assign_impl { )+) } - + -rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs @@ -704,37 +729,37 @@ index 3900f365b0..66b7980a43 100644 @@ -65,7 +65,7 @@ macro_rules! not_impl { )*) } - + -not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise AND operator `&`. /// @@ -149,7 +149,7 @@ macro_rules! bitand_impl { )*) } - + -bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR operator `|`. /// @@ -233,7 +233,7 @@ macro_rules! bitor_impl { )*) } - + -bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR operator `^`. /// @@ -320,7 +320,7 @@ macro_rules! bitxor_impl { )*) } - + -bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift operator `<<`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -417,19 +417,17 @@ macro_rules! shl_impl_all { @@ -743,7 +768,7 @@ index 3900f365b0..66b7980a43 100644 shl_impl! { $t, u64 } - shl_impl! { $t, u128 } shl_impl! { $t, usize } - + shl_impl! { $t, i8 } shl_impl! { $t, i16 } shl_impl! { $t, i32 } @@ -752,10 +777,10 @@ index 3900f365b0..66b7980a43 100644 shl_impl! { $t, isize } )*) } - + -shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } +shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift operator `>>`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -526,19 +524,17 @@ macro_rules! shr_impl_all { @@ -764,7 +789,7 @@ index 3900f365b0..66b7980a43 100644 shr_impl! { $t, u64 } - shr_impl! { $t, u128 } shr_impl! { $t, usize } - + shr_impl! { $t, i8 } shr_impl! { $t, i16 } shr_impl! { $t, i32 } @@ -773,37 +798,37 @@ index 3900f365b0..66b7980a43 100644 shr_impl! { $t, isize } )*) } - + -shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The bitwise AND assignment operator `&=`. /// @@ -626,7 +622,7 @@ macro_rules! bitand_assign_impl { )+) } - + -bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR assignment operator `|=`. /// @@ -675,7 +671,7 @@ macro_rules! bitor_assign_impl { )+) } - + -bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR assignment operator `^=`. /// @@ -724,7 +720,7 @@ macro_rules! bitxor_assign_impl { )+) } - + -bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift assignment operator `<<=`. /// @@ -780,19 +776,17 @@ macro_rules! shl_assign_impl_all { @@ -812,7 +837,7 @@ index 3900f365b0..66b7980a43 100644 shl_assign_impl! { $t, u64 } - shl_assign_impl! { $t, u128 } shl_assign_impl! { $t, usize } - + shl_assign_impl! { $t, i8 } shl_assign_impl! { $t, i16 } shl_assign_impl! { $t, i32 } @@ -821,10 +846,10 @@ index 3900f365b0..66b7980a43 100644 shl_assign_impl! { $t, isize } )*) } - + -shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift assignment operator `>>=`. /// @@ -848,16 +842,14 @@ macro_rules! shr_assign_impl_all { @@ -833,7 +858,7 @@ index 3900f365b0..66b7980a43 100644 shr_assign_impl! { $t, u64 } - shr_assign_impl! { $t, u128 } shr_assign_impl! { $t, usize } - + shr_assign_impl! { $t, i8 } shr_assign_impl! { $t, i16 } shr_assign_impl! { $t, i32 } @@ -842,7 +867,7 @@ index 3900f365b0..66b7980a43 100644 shr_assign_impl! { $t, isize } )*) } - + -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs @@ -855,14 +880,13 @@ index 72b115f8b5..d542e10bb0 100644 type Bigger = u64; - #[cfg(target_pointer_width = "64")] - type Bigger = u128; - + #[derive(Clone)] struct Test(Bigger); -@@ -1877,19 +1875,6 @@ fn test_step_replace_signed() { - assert_eq!(y, 5); +@@ -1878,19 +1876,6 @@ fn test_step_replace_signed() { } - --#[test] + + #[test] -fn test_step_replace_no_between() { - let mut x = 4u128; - let y = x.replace_zero(); @@ -875,14 +899,15 @@ index 72b115f8b5..d542e10bb0 100644 - assert_eq!(y, 5); -} - - #[test] +-#[test] fn test_rev_try_folds() { let f = &|acc, x| i32::checked_add(2*acc, x); + assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs -index 24fe96a2b8..ccb2f0f990 100644 +index ab96d3126b..bb5c1d06da 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs -@@ -187,12 +187,10 @@ test_impl_from! { test_boolu8, bool, u8 } +@@ -196,12 +196,10 @@ test_impl_from! { test_boolu8, bool, u8 } test_impl_from! { test_boolu16, bool, u16 } test_impl_from! { test_boolu32, bool, u32 } test_impl_from! { test_boolu64, bool, u64 } @@ -892,10 +917,10 @@ index 24fe96a2b8..ccb2f0f990 100644 test_impl_from! { test_booli32, bool, i32 } test_impl_from! { test_booli64, bool, i64 } -test_impl_from! { test_booli128, bool, i128 } - + // Signed -> Float test_impl_from! { test_i8f32, i8, f32 } -@@ -274,51 +272,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } +@@ -283,51 +281,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } test_impl_try_from_always_ok! { test_try_u8u16, u8, u16 } test_impl_try_from_always_ok! { test_try_u8u32, u8, u32 } test_impl_try_from_always_ok! { test_try_u8u64, u8, u64 } @@ -904,7 +929,7 @@ index 24fe96a2b8..ccb2f0f990 100644 test_impl_try_from_always_ok! { test_try_u8i32, u8, i32 } test_impl_try_from_always_ok! { test_try_u8i64, u8, i64 } -test_impl_try_from_always_ok! { test_try_u8i128, u8, i128 } - + test_impl_try_from_always_ok! { test_try_u16u16, u16, u16 } test_impl_try_from_always_ok! { test_try_u16u32, u16, u32 } test_impl_try_from_always_ok! { test_try_u16u64, u16, u64 } @@ -912,131 +937,50 @@ index 24fe96a2b8..ccb2f0f990 100644 test_impl_try_from_always_ok! { test_try_u16i32, u16, i32 } test_impl_try_from_always_ok! { test_try_u16i64, u16, i64 } -test_impl_try_from_always_ok! { test_try_u16i128, u16, i128 } - + test_impl_try_from_always_ok! { test_try_u32u32, u32, u32 } test_impl_try_from_always_ok! { test_try_u32u64, u32, u64 } -test_impl_try_from_always_ok! { test_try_u32u128, u32, u128 } test_impl_try_from_always_ok! { test_try_u32i64, u32, i64 } -test_impl_try_from_always_ok! { test_try_u32i128, u32, i128 } - + test_impl_try_from_always_ok! { test_try_u64u64, u64, u64 } -test_impl_try_from_always_ok! { test_try_u64u128, u64, u128 } -test_impl_try_from_always_ok! { test_try_u64i128, u64, i128 } - -test_impl_try_from_always_ok! { test_try_u128u128, u128, u128 } - + test_impl_try_from_always_ok! { test_try_i8i8, i8, i8 } test_impl_try_from_always_ok! { test_try_i8i16, i8, i16 } test_impl_try_from_always_ok! { test_try_i8i32, i8, i32 } test_impl_try_from_always_ok! { test_try_i8i64, i8, i64 } -test_impl_try_from_always_ok! { test_try_i8i128, i8, i128 } - + test_impl_try_from_always_ok! { test_try_i16i16, i16, i16 } test_impl_try_from_always_ok! { test_try_i16i32, i16, i32 } test_impl_try_from_always_ok! { test_try_i16i64, i16, i64 } -test_impl_try_from_always_ok! { test_try_i16i128, i16, i128 } - + test_impl_try_from_always_ok! { test_try_i32i32, i32, i32 } test_impl_try_from_always_ok! { test_try_i32i64, i32, i64 } -test_impl_try_from_always_ok! { test_try_i32i128, i32, i128 } - + test_impl_try_from_always_ok! { test_try_i64i64, i64, i64 } -test_impl_try_from_always_ok! { test_try_i64i128, i64, i128 } - -test_impl_try_from_always_ok! { test_try_i128i128, i128, i128 } - + test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } -@@ -355,28 +337,21 @@ test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u8, i8, u8 } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u16, i8, u16 } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u32, i8, u32 } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u64, i8, u64 } --test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8u128, i8, u128 } - - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u16, i16, u16 } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u32, i16, u32 } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u64, i16, u64 } --test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16u128, i16, u128 } - - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i32u32, i32, u32 } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i32u64, i32, u64 } --test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i32u128, i32, u128 } - - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i64u64, i64, u64 } --test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i64u128, i64, u128 } -- --test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i128u128, i128, u128 } - - assume_usize_width! { - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i8usize, i8, usize } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_i16usize, i16, usize } - - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_isizeu64, isize, u64 } -- test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_isizeu128, isize, u128 } - test_impl_try_from_signed_to_unsigned_upper_ok! { test_try_isizeusize, isize, usize } - } - -@@ -412,12 +387,6 @@ test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u64i16, u64, i16 } - test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u64i32, u64, i32 } - test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u64i64, u64, i64 } - --test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i8, u128, i8 } --test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i16, u128, i16 } --test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i32, u128, i32 } --test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i64, u128, i64 } --test_impl_try_from_unsigned_to_signed_upper_err! { test_try_u128i128, u128, i128 } -- - assume_usize_width! { - test_impl_try_from_unsigned_to_signed_upper_err! { test_try_usizei8, usize, i8 } - test_impl_try_from_unsigned_to_signed_upper_err! { test_try_usizei16, usize, i16 } -@@ -459,11 +428,6 @@ test_impl_try_from_same_sign_err! { test_try_u64u8, u64, u8 } - test_impl_try_from_same_sign_err! { test_try_u64u16, u64, u16 } - test_impl_try_from_same_sign_err! { test_try_u64u32, u64, u32 } - --test_impl_try_from_same_sign_err! { test_try_u128u8, u128, u8 } --test_impl_try_from_same_sign_err! { test_try_u128u16, u128, u16 } --test_impl_try_from_same_sign_err! { test_try_u128u32, u128, u32 } --test_impl_try_from_same_sign_err! { test_try_u128u64, u128, u64 } -- - test_impl_try_from_same_sign_err! { test_try_i16i8, i16, i8 } - test_impl_try_from_same_sign_err! { test_try_isizei8, isize, i8 } - -@@ -474,11 +438,6 @@ test_impl_try_from_same_sign_err! { test_try_i64i8, i64, i8 } - test_impl_try_from_same_sign_err! { test_try_i64i16, i64, i16 } - test_impl_try_from_same_sign_err! { test_try_i64i32, i64, i32 } - --test_impl_try_from_same_sign_err! { test_try_i128i8, i128, i8 } --test_impl_try_from_same_sign_err! { test_try_i128i16, i128, i16 } --test_impl_try_from_same_sign_err! { test_try_i128i32, i128, i32 } --test_impl_try_from_same_sign_err! { test_try_i128i64, i128, i64 } -- - assume_usize_width! { - test_impl_try_from_same_sign_err! { test_try_usizeu8, usize, u8 } - } -@@ -517,14 +476,8 @@ test_impl_try_from_signed_to_unsigned_err! { test_try_i64u8, i64, u8 } - test_impl_try_from_signed_to_unsigned_err! { test_try_i64u16, i64, u16 } - test_impl_try_from_signed_to_unsigned_err! { test_try_i64u32, i64, u32 } - --test_impl_try_from_signed_to_unsigned_err! { test_try_i128u8, i128, u8 } --test_impl_try_from_signed_to_unsigned_err! { test_try_i128u16, i128, u16 } --test_impl_try_from_signed_to_unsigned_err! { test_try_i128u32, i128, u32 } --test_impl_try_from_signed_to_unsigned_err! { test_try_i128u64, i128, u64 } -- - assume_usize_width! { - test_impl_try_from_signed_to_unsigned_err! { test_try_isizeu8, isize, u8 } -- test_impl_try_from_signed_to_unsigned_err! { test_try_i128usize, i128, usize } - } - - macro_rules! test_float { diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index 25721b7fce..2588ae442f 100644 +index 54973b7b77..1c07753e01 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -268,57 +268,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } - -- /// Returns the total number of milliseconds contained by this `Duration`. + +- /// Returns the total number of whole milliseconds contained by this `Duration`. - /// - /// # Examples - /// @@ -1053,7 +997,7 @@ index 25721b7fce..2588ae442f 100644 - self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 - } - -- /// Returns the total number of microseconds contained by this `Duration`. +- /// Returns the total number of whole microseconds contained by this `Duration`. - /// - /// # Examples - /// @@ -1090,6 +1034,6 @@ index 25721b7fce..2588ae442f 100644 /// Checked `Duration` addition. Computes `self + other`, returning [`None`] /// if overflow occurred. /// --- -2.15.2 (Apple Git-101.1) +-- +2.11.0 diff --git a/Readme.md b/Readme.md index 643611ce74f11..c06b75ea16181 100644 --- a/Readme.md +++ b/Readme.md @@ -23,11 +23,8 @@ $ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_c ## Building libcore ```bash -$ git clone https://github.com/rust-lang/rust.git -$ cd rust -$ git apply ../0001-Disable-stdsimd-in-libcore.patch -$ git apply ../0002-Disable-u128-and-i128-in-libcore.patch -$ cd ../ +$ rustup component add rust-src +$ ./prepare_libcore.sh $ ./build.sh ``` diff --git a/build.sh b/build.sh index 1990281fb306a..a202d30073636 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ cargo build || exit 1 rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so example.rs --crate-type lib -Og -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ./rust/src/libcore/lib.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ./target/libcore/src/libcore/lib.rs --crate-type lib -Og diff --git a/prepare_libcore.sh b/prepare_libcore.sh new file mode 100755 index 0000000000000..32e90144a25c7 --- /dev/null +++ b/prepare_libcore.sh @@ -0,0 +1,11 @@ +#!/bin/bash --verbose +SRC_DIR="target/libcore" +rm -rf $SRC_DIR && +mkdir -p $SRC_DIR/src && +cp -r $(dirname $(rustup which rustc))/../lib/rustlib/src/rust/src/libcore $SRC_DIR/src/libcore || (echo "Please install rust-src component"; exit 1) +cd $SRC_DIR || exit 1 +git init || exit 1 +git add . || exit 1 +git commit -m "Initial commit" -q || exit 1 +git apply ../../000*.patch || exit 1 +echo "Successfully prepared libcore for building" diff --git a/src/base.rs b/src/base.rs index 33bb918a8a846..24f8bc0bf0d29 100644 --- a/src/base.rs +++ b/src/base.rs @@ -59,7 +59,6 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } MonoItem::Static(def_id) => cx.tcx.sess.err(&format!("Unimplemented static mono item {:?}", def_id)), MonoItem::GlobalAsm(node_id) => cx.tcx.sess.err(&format!("Unimplemented global asm mono item {:?}", node_id)), - MonoItem::CustomSection(def_id) => cx.tcx.sess.err(&format!("Unimplemented custom section mono item {:?}", def_id)), } } From e89b062b76fd6e554f16f70d1dc4c6d1e21df797 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 18:52:13 +0200 Subject: [PATCH 0051/1566] Add .travis.yml --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000..58a82a4d90b64 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +sudo: false +language: rust +cache: cargo + +rust: + - nightly + +script: + - rustup component add rust-src + - ./prepare_libcore.sh + - ./build.sh + From c48beb652e2a95a324adf53f49fd4a0bd9af11a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 18:58:30 +0200 Subject: [PATCH 0052/1566] Add RUST_BACKTRACE=1 to .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 58a82a4d90b64..78ed95bb6a5d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,3 +10,5 @@ script: - ./prepare_libcore.sh - ./build.sh +env: + - RUST_BACKTRACE=1 From b454bc34fb0986947f9c46c69e67354d382aec1e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 19:08:37 +0200 Subject: [PATCH 0053/1566] Add a known panic case --- Readme.md | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/Readme.md b/Readme.md index c06b75ea16181..320ea0fa67f65 100644 --- a/Readme.md +++ b/Readme.md @@ -32,22 +32,40 @@ $ ./build.sh ## Not yet supported -* [ ] Checked binops -* [ ] Statics -* [ ] Drop glue +* Checked binops +* Statics +* Drop glue -* [ ] Building libraries -* [ ] Other call abi's -* [ ] Unsized types -* [ ] Slice indexing -* [ ] Sub slice -* [ ] Closures -* [ ] Some rvalue's +* Building libraries +* Other call abi's +* Unsized types +* Slice indexing +* Sub slice +* Closures +* Some rvalue's -* [ ] Inline assembly -* [ ] Custom sections +* Inline assembly +* Custom sections ## Known errors -* [ ] cranelift-module api seems to be used wrong, thus causing panic for some consts -* [ ] cranelift-codegen doesn't have encodings for some instructions for types smaller than I32 +* cranelift-module api seems to be used wrong, thus causing panic for some consts +* cranelift-codegen doesn't have encodings for some instructions for types smaller than I32 + +``` +[...] +warning: DefId(0/0:128 ~ lib[8787]::f64[0]::{{impl}}[0]::classify[0]): +fn f64::::classify(_1: f64) -> num::FpCategory{ +[...] +} +warning: stmt _3 = _1 +warning: stmt _5 = BitAnd(move _6, const Unevaluated(DefId(0/0:130 ~ lib[8787]::f64[0]::{{impl}}[0]::classify[0]::MAN_MASK[0]), []):u64) +thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:345:21 +stack backtrace: +[...] + 10: >::unwrap + at /checkout/src/libcore/macros.rs:20 + 11: rustc_codegen_cranelift::constant::trans_constant + at src/constant.rs:26 +[...] +``` From 1138d38d870e3915884e88df921588f1d1117644 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 19:33:42 +0200 Subject: [PATCH 0054/1566] Extract abi handling to abi.rs --- src/abi.rs | 142 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/base.rs | 93 ++------------------------------- src/common.rs | 45 +--------------- src/lib.rs | 2 + 4 files changed, 150 insertions(+), 132 deletions(-) create mode 100644 src/abi.rs diff --git a/src/abi.rs b/src/abi.rs new file mode 100644 index 0000000000000..69e33175c770a --- /dev/null +++ b/src/abi.rs @@ -0,0 +1,142 @@ +use prelude::*; + +pub fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { + let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); + cton_sig_from_mono_fn_sig(tcx, sig) +} + +pub fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>) -> Signature { + let fn_ty = inst.ty(tcx); + let sig = fn_ty.fn_sig(tcx); + cton_sig_from_mono_fn_sig(tcx, sig) +} + +pub fn cton_sig_from_mono_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>) -> Signature { + // TODO: monomorphize signature + + let sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig); + let inputs = sig.inputs(); + let _output = sig.output(); + assert!(!sig.variadic, "Variadic function are not yet supported"); + let call_conv = match sig.abi { + _ => CallConv::SystemV, + }; + Signature { + params: Some(types::I64).into_iter() // First param is place to put return val + .chain(inputs.into_iter().map(|ty| cton_type_from_ty(tcx, ty).unwrap_or(types::I64))) + .map(AbiParam::new).collect(), + returns: vec![], + call_conv, + argument_bytes: None, + } +} + +impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { + pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { + let tcx = self.tcx; + let module = &mut self.module; + let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { + let sig = cton_sig_from_instance(tcx, inst); + module.declare_function(&tcx.absolute_item_path_str(inst.def_id()), Linkage::Local, &sig).unwrap() + }); + module.declare_func_in_func(func_id, &mut self.bcx.func) + } +} + +pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb: Ebb) { + let ret_param = fx.bcx.append_ebb_param(start_ebb, types::I64); + let _ = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: 0, + offset: None, + }); // Dummy stack slot for debugging + + let func_params = fx.mir.args_iter().map(|local| { + let layout = fx.layout_of(fx.mir.local_decls[local].ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let ty = fx.mir.local_decls[local].ty; + let cton_type = fx.cton_type(ty).unwrap_or(types::I64); + (local, fx.bcx.append_ebb_param(start_ebb, cton_type), ty, stack_slot) + }).collect::>(); + + let ret_layout = fx.layout_of(fx.instance.ty(fx.tcx).fn_sig(fx.tcx).skip_binder().output()); + fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); + + for (local, ebb_param, ty, stack_slot) in func_params { + let place = CPlace::from_stack_slot(fx, stack_slot, ty); + if fx.cton_type(ty).is_some() { + place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())); + } else { + place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())); + } + fx.local_map.insert(local, place); + } + + for local in fx.mir.vars_and_temps_iter() { + let ty = fx.mir.local_decls[local].ty; + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let place = CPlace::from_stack_slot(fx, stack_slot, ty); + fx.local_map.insert(local, place); + } +} + +pub fn codegen_call<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + func: &Operand<'tcx>, + args: &[Operand<'tcx>], + destination: &Option<(Place<'tcx>, BasicBlock)>, +) -> Inst { + let func = ::base::trans_operand(fx, func); + let func_ty = func.layout().ty; + let return_place = if let Some((place, _)) = destination { + ::base::trans_place(fx, place).expect_addr() + } else { + fx.bcx.ins().iconst(types::I64, 0) + }; + let args = Some(return_place) + .into_iter() + .chain( + args + .into_iter() + .map(|arg| { + let ty = arg.ty(&fx.mir.local_decls, fx.tcx); + let arg = ::base::trans_operand(fx, arg); + if let Some(_) = fx.cton_type(ty) { + arg.load_value(fx) + } else { + arg.force_stack(fx) + } + }) + ).collect::>(); + let inst = match func { + CValue::Func(func, _) => { + fx.bcx.ins().call(func, &args) + } + func => { + let func = func.load_value(fx); + let sig = match func_ty.sty { + TypeVariants::TyFnDef(def_id, _substs) => fx.tcx.fn_sig(def_id), + TypeVariants::TyFnPtr(fn_sig) => fn_sig, + _ => bug!("Calling non function type {:?}", func_ty), + }; + let sig = fx.bcx.import_signature(cton_sig_from_fn_sig(fx.tcx, sig, fx.param_substs)); + fx.bcx.ins().call_indirect(sig, func, &args) + } + }; + if let Some((_, dest)) = *destination { + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + } else { + fx.bcx.ins().trap(TrapCode::User(!0)); + } + inst +} diff --git a/src/base.rs b/src/base.rs index 24f8bc0bf0d29..aebac3713ae73 100644 --- a/src/base.rs +++ b/src/base.rs @@ -92,49 +92,7 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & }; let fx = &mut fx; - let ret_param = fx.bcx.append_ebb_param(start_ebb, types::I64); - let _ = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: 0, - offset: None, - }); // Dummy stack slot for debugging - - let func_params = mir.args_iter().map(|local| { - let layout = fx.layout_of(mir.local_decls[local].ty); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let ty = mir.local_decls[local].ty; - let cton_type = fx.cton_type(ty).unwrap_or(types::I64); - (local, fx.bcx.append_ebb_param(start_ebb, cton_type), ty, stack_slot) - }).collect::>(); - - let ret_layout = fx.layout_of(fx.instance.ty(fx.tcx).fn_sig(fx.tcx).skip_binder().output()); - fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); - - for (local, ebb_param, ty, stack_slot) in func_params { - let place = CPlace::from_stack_slot(fx, stack_slot, ty); - if fx.cton_type(ty).is_some() { - place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())); - } else { - place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())); - } - fx.local_map.insert(local, place); - } - - for local in mir.vars_and_temps_iter() { - let ty = mir.local_decls[local].ty; - let layout = fx.layout_of(ty); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let place = CPlace::from_stack_slot(fx, stack_slot, ty); - fx.local_map.insert(local, place); - } + ::abi::codegen_fn_prelude(fx, start_ebb); fx.bcx.ins().jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); @@ -180,50 +138,7 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & inst } TerminatorKind::Call { func, args, destination, cleanup: _ } => { - let func_ty = func.ty(&fx.mir.local_decls, fx.tcx); - let func = trans_operand(fx, func); - let return_place = if let Some((place, _)) = destination { - trans_place(fx, place).expect_addr() - } else { - fx.bcx.ins().iconst(types::I64, 0) - }; - let args = Some(return_place) - .into_iter() - .chain( - args - .into_iter() - .map(|arg| { - let ty = arg.ty(&fx.mir.local_decls, fx.tcx); - let arg = trans_operand(fx, arg); - if let Some(_) = fx.cton_type(ty) { - arg.load_value(fx) - } else { - arg.force_stack(fx) - } - }) - ).collect::>(); - let inst = match func { - CValue::Func(func, _) => { - fx.bcx.ins().call(func, &args) - } - func => { - let func = func.load_value(fx); - let sig = match func_ty.sty { - TypeVariants::TyFnDef(def_id, _substs) => fx.tcx.fn_sig(def_id), - TypeVariants::TyFnPtr(fn_sig) => fn_sig, - _ => bug!("Calling non function type {:?}", func_ty), - }; - let sig = fx.bcx.import_signature(cton_sig_from_fn_sig(fx.tcx, sig, fx.param_substs)); - fx.bcx.ins().call_indirect(sig, func, &args) - } - }; - if let Some((_, dest)) = *destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); - } else { - fx.bcx.ins().trap(TrapCode::User(!0)); - } - inst + ::abi::codegen_call(fx, func, args, destination) } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { fx.bcx.ins().trap(TrapCode::User(!0)) @@ -569,7 +484,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l CValue::ByVal(res, fx.layout_of(ty)) } -fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { +pub fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { match place { Place::Local(local) => fx.get_local_place(*local), Place::Static(static_) => unimplemented!("static place {:?} ty {:?}", static_.def_id, static_.ty), @@ -594,7 +509,7 @@ fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) } } -fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue<'tcx> { +pub fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue<'tcx> { match operand { Operand::Move(place) | Operand::Copy(place) => { diff --git a/src/common.rs b/src/common.rs index 73c13619b9794..c09d69c8fdffa 100644 --- a/src/common.rs +++ b/src/common.rs @@ -6,7 +6,7 @@ use std::fmt; use syntax::ast::{IntTy, UintTy}; use self::rustc_target::spec::{HasTargetSpec, Target}; -use cranelift_module::{Module, Linkage, FuncId, DataId}; +use cranelift_module::{Module, FuncId, DataId}; use prelude::*; @@ -25,7 +25,7 @@ impl EntityRef for Variable { } } -fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> Option { +pub fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> Option { Some(match ty.sty { TypeVariants::TyBool => types::I8, TypeVariants::TyUint(size) => { @@ -278,37 +278,6 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } -pub fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { - let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); - cton_sig_from_mono_fn_sig(tcx, sig) -} - -pub fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>) -> Signature { - let fn_ty = inst.ty(tcx); - let sig = fn_ty.fn_sig(tcx); - cton_sig_from_mono_fn_sig(tcx, sig) -} - -pub fn cton_sig_from_mono_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>) -> Signature { - // TODO: monomorphize signature - - let sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig); - let inputs = sig.inputs(); - let _output = sig.output(); - assert!(!sig.variadic, "Variadic function are not yet supported"); - let call_conv = match sig.abi { - _ => CallConv::SystemV, - }; - Signature { - params: Some(types::I64).into_iter() // First param is place to put return val - .chain(inputs.into_iter().map(|ty| cton_type_from_ty(tcx, ty).unwrap_or(types::I64))) - .map(AbiParam::new).collect(), - returns: vec![], - call_conv, - argument_bytes: None, - } -} - pub fn cton_intcast<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, from: Ty<'tcx>, to: Ty<'tcx>, signed: bool) -> Value { let from = fx.cton_type(from).unwrap(); let to = fx.cton_type(to).unwrap(); @@ -409,16 +378,6 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { *self.local_map.get(&local).unwrap() } - pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let tcx = self.tcx; - let module = &mut self.module; - let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { - let sig = cton_sig_from_instance(tcx, inst); - module.declare_function(&tcx.absolute_item_path_str(inst.def_id()), Linkage::Local, &sig).unwrap() - }); - module.declare_func_in_func(func_id, &mut self.bcx.func) - } - pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { use std::collections::hash_map::Entry; match self.comments.entry(inst) { diff --git a/src/lib.rs b/src/lib.rs index 68d807d2b98ed..046af45d0ad54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,6 +33,7 @@ use std::sync::{mpsc, Arc}; use std::fs::File; use std::io::Write; +mod abi; mod base; mod constant; mod common; @@ -64,6 +65,7 @@ mod prelude { pub use cranelift_module::{Module, Backend, FuncId, DataId, Linkage}; pub use cranelift_simplejit::{SimpleJITBuilder, SimpleJITBackend}; + pub use abi::*; pub use common::Variable; pub use common::*; From bf2c35f05dac421091cde5aae6c0a68fbfe7c3d1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 19:37:34 +0200 Subject: [PATCH 0055/1566] Implement char to uint cast --- example.rs | 4 ++++ src/base.rs | 1 + src/common.rs | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/example.rs b/example.rs index 884a15710261d..f0078c5a239cb 100644 --- a/example.rs +++ b/example.rs @@ -135,6 +135,10 @@ fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize) { ) } +fn char_cast(c: char) -> u8 { + c as u8 +} + struct DebugTuple(()); fn debug_tuple() -> DebugTuple { diff --git a/src/base.rs b/src/base.rs index aebac3713ae73..773ba27dc71fe 100644 --- a/src/base.rs +++ b/src/base.rs @@ -298,6 +298,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } + (TypeVariants::TyChar, TypeVariants::TyUint(_)) | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); diff --git a/src/common.rs b/src/common.rs index c09d69c8fdffa..7e471bf40a22c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -48,6 +48,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx> IntTy::Isize => types::I64, } } + TypeVariants::TyChar => types::I32, TypeVariants::TyFnPtr(_) => types::I64, TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) | TypeVariants::TyRef(_, ty, _) => { if ty.is_sized(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { @@ -100,7 +101,7 @@ impl<'tcx> CValue<'tcx> { pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value where 'tcx: 'a{ match self { CValue::ByRef(addr, layout) => { - let cton_ty = fx.cton_type(layout.ty).expect(&format!("{:?}", layout.ty)); + let cton_ty = fx.cton_type(layout.ty).expect(&format!("load_value of type {:?}", layout.ty)); fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, From 12e129579dec84add38d632652d75253e96cf75f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Jul 2018 19:42:07 +0200 Subject: [PATCH 0056/1566] Fix a bug --- src/abi.rs | 3 +-- src/base.rs | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 69e33175c770a..cd250d77c2fe9 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -108,9 +108,8 @@ pub fn codegen_call<'a, 'tcx: 'a>( args .into_iter() .map(|arg| { - let ty = arg.ty(&fx.mir.local_decls, fx.tcx); let arg = ::base::trans_operand(fx, arg); - if let Some(_) = fx.cton_type(ty) { + if let Some(_) = fx.cton_type(arg.layout().ty) { arg.load_value(fx) } else { arg.force_stack(fx) diff --git a/src/base.rs b/src/base.rs index 773ba27dc71fe..a12c785a1bf52 100644 --- a/src/base.rs +++ b/src/base.rs @@ -185,6 +185,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx match layout.variants { layout::Variants::Single { index } => { assert_eq!(index, *variant_index); + fx.bcx.ins().nop(); } layout::Variants::Tagged { .. } => { let ptr = place.place_field(fx, mir::Field::new(0)); @@ -212,6 +213,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx CValue::const_val(fx, niche.layout().ty, niche_value as u64 as i64) }; niche.write_cvalue(fx, niche_llval); + } else { + fx.bcx.ins().nop(); } } } From 2b5e55fb17de690559a7f1343ea3d2e9f91d2fd5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Jul 2018 13:36:53 +0200 Subject: [PATCH 0057/1566] Refactor fn sig handling in preparation for supporting closures --- src/abi.rs | 102 +++++++++++++++++++++++++++++++++++++------------- src/base.rs | 10 ++++- src/common.rs | 4 +- src/lib.rs | 1 + 4 files changed, 86 insertions(+), 31 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index cd250d77c2fe9..6f4c5e404a5b4 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -1,25 +1,21 @@ -use prelude::*; +use std::iter; -pub fn cton_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>, substs: &Substs<'tcx>) -> Signature { - let sig = tcx.subst_and_normalize_erasing_regions(substs, ParamEnv::reveal_all(), &sig); - cton_sig_from_mono_fn_sig(tcx, sig) -} +use rustc::hir; +use rustc_target::spec::abi::Abi; -pub fn cton_sig_from_instance<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>) -> Signature { - let fn_ty = inst.ty(tcx); - let sig = fn_ty.fn_sig(tcx); - cton_sig_from_mono_fn_sig(tcx, sig) -} - -pub fn cton_sig_from_mono_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: PolyFnSig<'tcx>) -> Signature { - // TODO: monomorphize signature +use prelude::*; +pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>) -> Signature { + let sig = ty_fn_sig(tcx, fn_ty); let sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig); - let inputs = sig.inputs(); - let _output = sig.output(); assert!(!sig.variadic, "Variadic function are not yet supported"); - let call_conv = match sig.abi { - _ => CallConv::SystemV, + let (call_conv, inputs, _output): (CallConv, Vec, Ty) = match sig.abi { + Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), + Abi::RustCall => { + unimplemented!(); + } + Abi::System => bug!("system abi should be selected elsewhere"), + _ => unimplemented!("unsupported abi {:?}", sig.abi), }; Signature { params: Some(types::I64).into_iter() // First param is place to put return val @@ -31,16 +27,75 @@ pub fn cton_sig_from_mono_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: } } +fn ty_fn_sig<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + ty: Ty<'tcx> +) -> ty::PolyFnSig<'tcx> { + match ty.sty { + ty::TyFnDef(..) | + // Shims currently have type TyFnPtr. Not sure this should remain. + ty::TyFnPtr(_) => ty.fn_sig(tcx), + ty::TyClosure(def_id, substs) => { + let sig = substs.closure_sig(def_id, tcx); + + let env_ty = tcx.closure_env_ty(def_id, substs).unwrap(); + sig.map_bound(|sig| tcx.mk_fn_sig( + iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), + sig.output(), + sig.variadic, + sig.unsafety, + sig.abi + )) + } + ty::TyGenerator(def_id, substs, _) => { + let sig = substs.poly_sig(def_id, tcx); + + let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); + let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty); + + sig.map_bound(|sig| { + let state_did = tcx.lang_items().gen_state().unwrap(); + let state_adt_ref = tcx.adt_def(state_did); + let state_substs = tcx.intern_substs(&[ + sig.yield_ty.into(), + sig.return_ty.into(), + ]); + let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); + + tcx.mk_fn_sig(iter::once(env_ty), + ret_ty, + false, + hir::Unsafety::Normal, + Abi::Rust + ) + }) + } + _ => bug!("unexpected type {:?} to ty_fn_sig", ty) + } +} + impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { + /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { + assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let tcx = self.tcx; let module = &mut self.module; let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { - let sig = cton_sig_from_instance(tcx, inst); + let fn_ty = inst.ty(tcx); + let sig = cton_sig_from_fn_ty(tcx, fn_ty); module.declare_function(&tcx.absolute_item_path_str(inst.def_id()), Linkage::Local, &sig).unwrap() }); module.declare_func_in_func(func_id, &mut self.bcx.func) } + + fn self_sig(&self) -> FnSig<'tcx> { + let sig = ty_fn_sig(self.tcx, self.instance.ty(self.tcx)); + self.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig) + } + + fn return_type(&self) -> Ty<'tcx> { + self.self_sig().output() + } } pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb: Ebb) { @@ -63,7 +118,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb (local, fx.bcx.append_ebb_param(start_ebb, cton_type), ty, stack_slot) }).collect::>(); - let ret_layout = fx.layout_of(fx.instance.ty(fx.tcx).fn_sig(fx.tcx).skip_binder().output()); + let ret_layout = fx.layout_of(fx.return_type()); fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); for (local, ebb_param, ty, stack_slot) in func_params { @@ -96,7 +151,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( destination: &Option<(Place<'tcx>, BasicBlock)>, ) -> Inst { let func = ::base::trans_operand(fx, func); - let func_ty = func.layout().ty; let return_place = if let Some((place, _)) = destination { ::base::trans_place(fx, place).expect_addr() } else { @@ -121,13 +175,9 @@ pub fn codegen_call<'a, 'tcx: 'a>( fx.bcx.ins().call(func, &args) } func => { + let func_ty = func.layout().ty; let func = func.load_value(fx); - let sig = match func_ty.sty { - TypeVariants::TyFnDef(def_id, _substs) => fx.tcx.fn_sig(def_id), - TypeVariants::TyFnPtr(fn_sig) => fn_sig, - _ => bug!("Calling non function type {:?}", func_ty), - }; - let sig = fx.bcx.import_signature(cton_sig_from_fn_sig(fx.tcx, sig, fx.param_substs)); + let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, func_ty)); fx.bcx.ins().call_indirect(sig, func, &args) } }; diff --git a/src/base.rs b/src/base.rs index a12c785a1bf52..49739c68e10b0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -13,8 +13,13 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); - let sig = tcx.fn_sig(def_id); - let sig = cton_sig_from_fn_sig(tcx, sig, substs); + let fn_ty = inst.ty(tcx); + let fn_ty = tcx.subst_and_normalize_erasing_regions( + substs, + ty::ParamEnv::reveal_all(), + &fn_ty, + ); + let sig = cton_sig_from_fn_ty(tcx, fn_ty); let func_id = { let module = &mut cx.module; *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { @@ -44,6 +49,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend match ::cranelift::codegen::verify_function(&f, &flags) { Ok(_) => {} Err(err) => { + tcx.sess.err(&format!("{:?}", err)); 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)); } diff --git a/src/common.rs b/src/common.rs index 7e471bf40a22c..0c9d86d92fb3b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,10 +1,8 @@ -extern crate rustc_target; - use std::borrow::Cow; use std::fmt; use syntax::ast::{IntTy, UintTy}; -use self::rustc_target::spec::{HasTargetSpec, Target}; +use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::{Module, FuncId, DataId}; diff --git a/src/lib.rs b/src/lib.rs index 046af45d0ad54..d5400c9ce8112 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,7 @@ extern crate syntax; extern crate rustc; extern crate rustc_mir; extern crate rustc_codegen_utils; +extern crate rustc_target; extern crate rustc_incremental; extern crate rustc_data_structures; From a3b53eb4517a7cdbacaac4e2b9f52959e402bcdf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Jul 2018 13:51:34 +0200 Subject: [PATCH 0058/1566] Better comment handling --- src/abi.rs | 11 +++++----- src/base.rs | 50 +++++++++++++++++++--------------------------- src/common.rs | 15 -------------- src/pretty_clif.rs | 27 +++++++++++++++++++------ 4 files changed, 47 insertions(+), 56 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 6f4c5e404a5b4..85210e8763849 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -149,7 +149,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( func: &Operand<'tcx>, args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, -) -> Inst { +) { let func = ::base::trans_operand(fx, func); let return_place = if let Some((place, _)) = destination { ::base::trans_place(fx, place).expect_addr() @@ -170,22 +170,21 @@ pub fn codegen_call<'a, 'tcx: 'a>( } }) ).collect::>(); - let inst = match func { + match func { CValue::Func(func, _) => { - fx.bcx.ins().call(func, &args) + fx.bcx.ins().call(func, &args); } func => { let func_ty = func.layout().ty; let func = func.load_value(fx); let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, func_ty)); - fx.bcx.ins().call_indirect(sig, func, &args) + fx.bcx.ins().call_indirect(sig, func, &args); } - }; + } if let Some((_, dest)) = *destination { let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { fx.bcx.ins().trap(TrapCode::User(!0)); } - inst } diff --git a/src/base.rs b/src/base.rs index 49739c68e10b0..49a0b30919f21 100644 --- a/src/base.rs +++ b/src/base.rs @@ -106,28 +106,33 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & let ebb = fx.get_ebb(bb); fx.bcx.switch_to_block(ebb); + fx.bcx.ins().nop(); for stmt in &bb_data.statements { - trans_stmt(fx, stmt)?; + trans_stmt(fx, ebb, stmt)?; } - let inst = match &bb_data.terminator().kind { + let mut terminator_head = "\n".to_string(); + bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap(); + let inst = fx.bcx.func.layout.last_inst(ebb).unwrap(); + fx.add_comment(inst, terminator_head); + + match &bb_data.terminator().kind { TerminatorKind::Goto { target } => { let ebb = fx.get_ebb(*target); - fx.bcx.ins().jump(ebb, &[]) + fx.bcx.ins().jump(ebb, &[]); } TerminatorKind::Return => { - fx.bcx.ins().return_(&[]) + fx.bcx.ins().return_(&[]); } TerminatorKind::Assert { cond, expected, msg: _, target, cleanup: _ } => { let cond = trans_operand(fx, cond).load_value(fx); let target = fx.get_ebb(*target); - let inst = if *expected { - fx.bcx.ins().brz(cond, target, &[]) + if *expected { + fx.bcx.ins().brz(cond, target, &[]); } else { - fx.bcx.ins().brnz(cond, target, &[]) + fx.bcx.ins().brnz(cond, target, &[]); }; fx.bcx.ins().trap(TrapCode::User(!0)); - inst } TerminatorKind::SwitchInt { discr, switch_ty: _, values, targets } => { @@ -138,16 +143,15 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & jt_data.set_entry(*value as usize, ebb); } let mut jump_table = fx.bcx.create_jump_table(jt_data); - let inst = fx.bcx.ins().br_table(discr, jump_table); + fx.bcx.ins().br_table(discr, jump_table); let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); fx.bcx.ins().jump(otherwise_ebb, &[]); - inst } TerminatorKind::Call { func, args, destination, cleanup: _ } => { - ::abi::codegen_call(fx, func, args, destination) + ::abi::codegen_call(fx, func, args, destination); } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { - fx.bcx.ins().trap(TrapCode::User(!0)) + fx.bcx.ins().trap(TrapCode::User(!0)); } TerminatorKind::Yield { .. } | TerminatorKind::FalseEdges { .. } | @@ -158,16 +162,12 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & // TODO call drop impl // unimplemented!("terminator {:?}", bb_data.terminator()); let target_ebb = fx.get_ebb(*target); - fx.bcx.ins().jump(target_ebb, &[]) + fx.bcx.ins().jump(target_ebb, &[]); } TerminatorKind::GeneratorDrop => { unimplemented!("terminator GeneratorDrop"); } }; - - let mut terminator_head = "\n".to_string(); - bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap(); - fx.add_comment(inst, terminator_head); } fx.bcx.seal_all_blocks(); @@ -176,10 +176,11 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & Ok(fx.comments.clone()) } -fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx>) -> Result<(), String> { +fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: &Statement<'tcx>) -> Result<(), String> { fx.tcx.sess.warn(&format!("stmt {:?}", stmt)); - let nop_inst = fx.bcx.ins().nop(); + let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); + fx.add_comment(inst, format!("{:?}", stmt)); match &stmt.kind { StatementKind::SetDiscriminant { place, variant_index } => { @@ -191,7 +192,6 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx match layout.variants { layout::Variants::Single { index } => { assert_eq!(index, *variant_index); - fx.bcx.ins().nop(); } layout::Variants::Tagged { .. } => { let ptr = place.place_field(fx, mir::Field::new(0)); @@ -219,8 +219,6 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx CValue::const_val(fx, niche.layout().ty, niche_value as u64 as i64) }; niche.write_cvalue(fx, niche_llval); - } else { - fx.bcx.ins().nop(); } } } @@ -393,16 +391,10 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, stmt: &Statement<'tcx Rvalue::Aggregate(_, _) => bug!("shouldn't exist at trans {:?}", rval), } } - StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop | StatementKind::ReadForMatch(_) | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) | StatementKind::UserAssertTy(_, _) => { - fx.bcx.ins().nop(); - } + StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop | StatementKind::ReadForMatch(_) | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) | StatementKind::UserAssertTy(_, _) => {} StatementKind::InlineAsm { .. } => fx.tcx.sess.fatal("Inline assembly is not supported"), } - let inst = fx.bcx.func.layout.next_inst(nop_inst).unwrap(); - fx.bcx.func.layout.remove_inst(nop_inst); - fx.add_comment(inst, format!("{:?}", stmt)); - Ok(()) } diff --git a/src/common.rs b/src/common.rs index 0c9d86d92fb3b..152166282412a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use std::fmt; use syntax::ast::{IntTy, UintTy}; @@ -259,7 +258,6 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); CPlace::Addr(fx.bcx.ins().iadd(base, field_offset), field_ty) } else { - fx.bcx.ins().nop(); CPlace::Addr(base, field_ty) } } @@ -376,17 +374,4 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { *self.local_map.get(&local).unwrap() } - - pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { - use std::collections::hash_map::Entry; - match self.comments.entry(inst) { - Entry::Occupied(mut occ) => { - occ.get_mut().push('\n'); - occ.get_mut().push_str(comment.into().as_ref()); - } - Entry::Vacant(vac) => { - vac.insert(comment.into().into_owned()); - } - } - } } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index d1194660080bd..5c38f8af11924 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -1,11 +1,10 @@ +use std::borrow::Cow; use std::collections::HashMap; use std::fmt; -use cranelift::codegen::{ - ir::{Function, Inst}, - write::{FuncWriter, PlainWriter}, -}; -use cranelift::prelude::*; +use cranelift::codegen::write::{FuncWriter, PlainWriter}; + +use prelude::*; pub struct CommentWriter(pub HashMap); @@ -18,10 +17,11 @@ impl FuncWriter for CommentWriter { inst: Inst, indent: usize, ) -> fmt::Result { + PlainWriter.write_instruction(w, func, isa, inst, indent)?; if let Some(comment) = self.0.get(&inst) { writeln!(w, "; {}", comment.replace('\n', "\n; "))?; } - PlainWriter.write_instruction(w, func, isa, inst, indent) + Ok(()) } fn write_preamble( @@ -33,3 +33,18 @@ impl FuncWriter for CommentWriter { PlainWriter.write_preamble(w, func, reg_info) } } + +impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { + pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { + use std::collections::hash_map::Entry; + match self.comments.entry(inst) { + Entry::Occupied(mut occ) => { + occ.get_mut().push('\n'); + occ.get_mut().push_str(comment.into().as_ref()); + } + Entry::Vacant(vac) => { + vac.insert(comment.into().into_owned()); + } + } + } +} From 0350f2faa97229c49ac2b7efb7058ae7abf0232b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Jul 2018 14:20:37 +0200 Subject: [PATCH 0059/1566] Don't panic on intrinsics --- example.rs | 15 ++++++++++++++- src/abi.rs | 2 ++ src/base.rs | 2 +- src/constant.rs | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/example.rs b/example.rs index f0078c5a239cb..027d0ba954247 100644 --- a/example.rs +++ b/example.rs @@ -1,4 +1,4 @@ -#![feature(no_core, lang_items)] +#![feature(no_core, lang_items, intrinsics)] #![no_core] #![allow(dead_code)] @@ -68,6 +68,10 @@ unsafe fn drop_in_place(to_drop: *mut T) { drop_in_place(to_drop); } +extern "rust-intrinsic" { + fn copy(src: *const T, dst: *mut T, count: usize); +} + fn abc(a: u8) -> u8 { a * 2 } @@ -144,3 +148,12 @@ struct DebugTuple(()); fn debug_tuple() -> DebugTuple { DebugTuple(()) } + +unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { + copy::(src, dst, 1); +} + +/*unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { + let copy2 = ©::; + copy2(src, dst, 1); +}*/ diff --git a/src/abi.rs b/src/abi.rs index 85210e8763849..01e2bc69fc701 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -15,6 +15,8 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< unimplemented!(); } Abi::System => bug!("system abi should be selected elsewhere"), + // TODO: properly implement intrinsics + Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), _ => unimplemented!("unsupported abi {:?}", sig.abi), }; Signature { diff --git a/src/base.rs b/src/base.rs index 49a0b30919f21..1186f5138558d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -322,7 +322,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & } }, Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty), - Rvalue::Cast(CastKind::Unsize, operand, ty) => unimplemented!("rval unsize {:?} {:?}", operand, ty), + Rvalue::Cast(CastKind::Unsize, operand, ty) => return Err(format!("rval unsize {:?} {:?}", operand, ty)), Rvalue::Discriminant(place) => { let place = trans_place(fx, place); let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); diff --git a/src/constant.rs b/src/constant.rs index 2e17b318fcb50..70b82cee86221 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -14,6 +14,7 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons })) .unwrap(), }; + fx.tcx.sess.warn(&format!("const: {:?}", value)); let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); From 4fad0f714f3561ecaddd5ee81a497b2613049729 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Jul 2018 18:38:08 +0200 Subject: [PATCH 0060/1566] Add some basic intrinsic support (only size_of atm) --- example.rs | 23 +++++++++++---- src/abi.rs | 80 ++++++++++++++++++++++++++++++++++++++++----------- src/common.rs | 2 +- 3 files changed, 83 insertions(+), 22 deletions(-) diff --git a/example.rs b/example.rs index 027d0ba954247..d37ca321334d9 100644 --- a/example.rs +++ b/example.rs @@ -3,7 +3,7 @@ #![allow(dead_code)] #[lang="sized"] -trait Sized {} +pub trait Sized {} #[lang="copy"] unsafe trait Copy {} @@ -68,8 +68,11 @@ unsafe fn drop_in_place(to_drop: *mut T) { drop_in_place(to_drop); } -extern "rust-intrinsic" { - fn copy(src: *const T, dst: *mut T, count: usize); +mod intrinsics { + extern "rust-intrinsic" { + pub fn size_of() -> usize; + pub fn copy(src: *const T, dst: *mut T, count: usize); + } } fn abc(a: u8) -> u8 { @@ -149,10 +152,20 @@ fn debug_tuple() -> DebugTuple { DebugTuple(()) } -unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { - copy::(src, dst, 1); +fn size_of() -> usize { + unsafe { + intrinsics::size_of::() + } +} + +fn use_size_of() -> usize { + size_of::() } +/*unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { + intrinsics::copy::(src, dst, 1); +}*/ + /*unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { let copy2 = ©::; copy2(src, dst, 1); diff --git a/src/abi.rs b/src/abi.rs index 01e2bc69fc701..e228b863b1ce1 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -12,7 +12,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< let (call_conv, inputs, _output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { - unimplemented!(); + unimplemented!("rust-call"); } Abi::System => bug!("system abi should be selected elsewhere"), // TODO: properly implement intrinsics @@ -153,25 +153,73 @@ pub fn codegen_call<'a, 'tcx: 'a>( destination: &Option<(Place<'tcx>, BasicBlock)>, ) { let func = ::base::trans_operand(fx, func); + let return_place = if let Some((place, _)) = destination { - ::base::trans_place(fx, place).expect_addr() + Some(::base::trans_place(fx, place)) } else { - fx.bcx.ins().iconst(types::I64, 0) + None }; - let args = Some(return_place) + + let args = args .into_iter() - .chain( - args - .into_iter() - .map(|arg| { - let arg = ::base::trans_operand(fx, arg); - if let Some(_) = fx.cton_type(arg.layout().ty) { - arg.load_value(fx) - } else { - arg.force_stack(fx) - } - }) - ).collect::>(); + .map(|arg| { + let arg = ::base::trans_operand(fx, arg); + if let Some(_) = fx.cton_type(arg.layout().ty) { + arg.load_value(fx) + } else { + arg.force_stack(fx) + } + }) + .collect::>(); + + let fn_ty = func.layout().ty; + if let TypeVariants::TyFnDef(def_id, substs) = fn_ty.sty { + let instance = ty::Instance::resolve( + fx.tcx, + ParamEnv::reveal_all(), + def_id, + substs + ).unwrap(); + + // Handle intrinsics old codegen wants Expr's for, ourselves. + if let InstanceDef::Intrinsic(def_id) = instance.def { + let intrinsic = fx.tcx.item_name(def_id).as_str(); + let intrinsic = &intrinsic[..]; + + let usize_layout = fx.layout_of(fx.tcx.types.usize); + match intrinsic { + "copy" => { + /*let elem_ty = substs.type_at(0); + assert_eq!(args.len(), 3); + let src = args[0]; + let dst = args[1]; + let count = args[2];*/ + unimplemented!("copy"); + } + "size_of" => { + let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); + let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); + return_place.unwrap().write_cvalue(fx, size_of); + } + _ => fx.tcx.sess.fatal(&format!("unsupported intrinsic {}", intrinsic)), + } + if let Some((_, dest)) = *destination { + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + } else { + fx.bcx.ins().trap(TrapCode::User(!0)); + } + return; + } + } + + let return_ptr = match return_place { + Some(place) => place.expect_addr(), + None => fx.bcx.ins().iconst(types::I64, 0), + }; + + let args = Some(return_ptr).into_iter().chain(args).collect::>(); + match func { CValue::Func(func, _) => { fx.bcx.ins().call(func, &args); diff --git a/src/common.rs b/src/common.rs index 152166282412a..74cc4943f56ee 100644 --- a/src/common.rs +++ b/src/common.rs @@ -168,7 +168,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { CPlace::Var(_, layout) | - CPlace::Addr(_, layout) => layout + CPlace::Addr(_, layout) => layout, } } From e40d02584332eb0752ff28df84ea4a76041ecea1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Jul 2018 18:44:34 +0200 Subject: [PATCH 0061/1566] Eval const values --- example.rs | 6 ++++++ src/constant.rs | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/example.rs b/example.rs index d37ca321334d9..a1dbe0b872e1b 100644 --- a/example.rs +++ b/example.rs @@ -170,3 +170,9 @@ fn use_size_of() -> usize { let copy2 = ©::; copy2(src, dst, 1); }*/ + +const Abc: u8 = 6 * 7; + +fn use_const() -> u8 { + Abc +} diff --git a/src/constant.rs b/src/constant.rs index 70b82cee86221..60fe341927135 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,11 +1,11 @@ use prelude::*; -use rustc::mir::interpret::{GlobalId, AllocId, read_target_uint}; +use rustc::mir::interpret::{ConstValue, GlobalId, AllocId, read_target_uint}; use rustc_mir::interpret::{CompileTimeEvaluator, Memory, MemoryKind}; use cranelift_module::*; pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Constant<'tcx>) -> CValue<'tcx> { - let value = match const_.literal { - Literal::Value { value } => value, + let const_val = match const_.literal { + Literal::Value { value } => fx.monomorphize(&value), Literal::Promoted { index } => fx .tcx .const_eval(ParamEnv::reveal_all().and(GlobalId { @@ -14,21 +14,35 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons })) .unwrap(), }; - fx.tcx.sess.warn(&format!("const: {:?}", value)); + + let const_ = match const_val.val { + ConstValue::Unevaluated(def_id, ref substs) => { + let param_env = ParamEnv::reveal_all(); + let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap(); + let cid = GlobalId { + instance, + promoted: None, + }; + fx.tcx.const_eval(param_env.and(cid)).unwrap() + }, + _ => const_val, + }; + + fx.tcx.sess.warn(&format!("const_val: {:?} const_: {:?}", const_val, const_)); let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); match ty.sty { TypeVariants::TyBool => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + let bits = const_.val.to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as u64 as i64) } TypeVariants::TyUint(_) => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + let bits = const_.val.to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as u64 as i64) } TypeVariants::TyInt(_) => { - let bits = value.to_scalar().unwrap().to_bits(layout.size).unwrap(); + let bits = const_.val.to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as i128 as i64) } TypeVariants::TyFnDef(def_id, substs) => { @@ -42,7 +56,7 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons return CValue::ByRef(fx.bcx.ins().iconst(types::I64, 0), layout); } let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); - let alloc = fx.tcx.const_value_to_allocation(value); + let alloc = fx.tcx.const_value_to_allocation(const_); //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = memory.allocate_value(alloc.clone(), MemoryKind::Stack).unwrap(); let data_id = get_global_for_alloc_id(fx, &memory, alloc_id); From eb077f67ac23cd546ab6c1c1be48bbc819d41617 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Jul 2018 11:17:39 +0200 Subject: [PATCH 0062/1566] Support metadata writing --- .gitmodules | 2 +- Cargo.lock | 449 +++++++++++++++++++++++++++++++++++++++++++++++----- Cargo.toml | 3 +- cranelift | 2 +- src/base.rs | 2 +- src/lib.rs | 92 ++++++----- 6 files changed, 471 insertions(+), 79 deletions(-) diff --git a/.gitmodules b/.gitmodules index d875e5a4ccf53..279484b1af7cf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "cranelift"] path = cranelift - url = https://github.com/CraneStation/cranelift.git + url = https://github.com/bjorn3/cretonne.git diff --git a/Cargo.lock b/Cargo.lock index 2c8b07329b07f..df75a456740c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,29 @@ +[[package]] +name = "aho-corasick" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "atty" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "backtrace" version = "0.3.9" @@ -6,7 +32,7 @@ dependencies = [ "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -15,7 +41,7 @@ name = "backtrace-sys" version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -31,7 +57,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -39,60 +65,91 @@ name = "cfg-if" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "clap" +version = "2.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cranelift" -version = "0.14.0" +version = "0.16.1" dependencies = [ - "cranelift-codegen 0.14.0", - "cranelift-frontend 0.14.0", + "cranelift-codegen 0.16.1", + "cranelift-frontend 0.16.1", ] [[package]] name = "cranelift-codegen" -version = "0.14.0" +version = "0.16.1" dependencies = [ - "cranelift-entity 0.14.0", + "cranelift-codegen-meta 0.15.0", + "cranelift-entity 0.16.1", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cranelift-codegen-meta" +version = "0.15.0" + [[package]] name = "cranelift-entity" -version = "0.14.0" +version = "0.16.1" + +[[package]] +name = "cranelift-faerie" +version = "0.16.1" +dependencies = [ + "cranelift-codegen 0.16.1", + "cranelift-module 0.16.1", + "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cranelift-frontend" -version = "0.14.0" +version = "0.16.1" dependencies = [ - "cranelift-codegen 0.14.0", + "cranelift-codegen 0.16.1", ] [[package]] name = "cranelift-module" -version = "0.14.0" +version = "0.16.1" dependencies = [ - "cranelift-codegen 0.14.0", - "cranelift-entity 0.14.0", + "cranelift-codegen 0.16.1", + "cranelift-entity 0.16.1", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.14.0" +version = "0.16.1" dependencies = [ - "cranelift-codegen 0.14.0", + "cranelift-codegen 0.16.1", "raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.14.0" +version = "0.16.1" dependencies = [ - "cranelift-codegen 0.14.0", - "cranelift-module 0.14.0", - "cranelift-native 0.14.0", + "cranelift-codegen 0.16.1", + "cranelift-module 0.16.1", + "cranelift-native 0.16.1", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -102,8 +159,20 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.4.2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "env_logger" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "errno" @@ -124,6 +193,23 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "faerie" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "failure" version = "0.1.1" @@ -148,9 +234,37 @@ name = "gcc" version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "goblin" +version = "0.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "humantime" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "indexmap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "itoa" -version = "0.4.1" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -158,6 +272,14 @@ name = "libc" version = "0.2.42" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "log" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mach" version = "0.1.2" @@ -166,18 +288,85 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "memchr" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quick-error" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "quote" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "raw-cpuid" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -195,31 +384,83 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "cranelift 0.14.0", - "cranelift-module 0.14.0", - "cranelift-simplejit 0.14.0", + "cranelift 0.16.1", + "cranelift-faerie 0.16.1", + "cranelift-module 0.16.1", + "cranelift-simplejit 0.16.1", + "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scroll" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scroll_derive" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde" -version = "1.0.68" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.22" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "string-interner" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "strsim" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "structopt" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "structopt-derive" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -232,6 +473,16 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synom" version = "0.11.3" @@ -256,14 +507,87 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termcolor" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "textwrap" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ucd-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-width" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "utf8-ranges" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi" version = "0.3.5" @@ -283,33 +607,80 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "wincolor" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] +"checksum aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c6d463cbe7ed28720b5b489e7c083eeb8f90d08be2a0d6bb9e1ffea9ce1afa" +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" -"checksum cc 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "49ec142f5768efb5b7622aebc3fdbdbb8950a4b9ba996393cb76ef7466e8747d" +"checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" "checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" -"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" +"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" +"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +"checksum faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "319f742885b740cec9adca9a9b4bc35229d7e004af9431c694e0aef3eea00f55" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" -"checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" +"checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" +"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" +"checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" +"checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" +"checksum lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb497c35d362b6a331cfd94956a07fc2c78a4604cdbee844a81170386b996dd3" "checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" +"checksum log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd98ae7f7b754bc53dca7d44b604f733c6bba044ea6f41bc8d89272d8161d2" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" +"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" +"checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +"checksum proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cccdc7557a98fe98453030f077df7f3a042052fae465bb61d2c2c41435cfd9b6" +"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" +"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" "checksum raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "233ec1847057cf4d4591a0d76908aa12812140b11ea7d7d05b4c38cadb069c31" +"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5bbbea44c5490a1e84357ff28b7d518b4619a159fed5d25f6c1de2d19cc42814" +"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" -"checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" -"checksum serde 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)" = "429fcc4efa8a11341b5422c2ace724daba276c1748467e869478f53c0ba4562e" -"checksum serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "84b8035cabe9b35878adec8ac5fe03d5f6bc97ff6edd7ccb96b44c1276ba390e" +"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" +"checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" +"checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" +"checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920" +"checksum serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" +"checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" +"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +"checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" +"checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +"checksum syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2beff8ebc3658f07512a413866875adddd20f4fd47b2a4e6c9da65cd281baaea" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" +"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" +"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" +"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" +"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" diff --git a/Cargo.toml b/Cargo.toml index 908fcc72fcc4b..921a65bcedf4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,5 @@ crate-type = ["dylib"] cranelift = { path = "./cranelift/lib/umbrella" } cranelift-module = { path = "./cranelift/lib/module" } cranelift-simplejit = { path = "./cranelift/lib/simplejit" } -#cranelift-faerie = { path = "./cranelift/lib/faerie" } +cranelift-faerie = { path = "./cranelift/lib/faerie" } +target-lexicon = "0.0.3" diff --git a/cranelift b/cranelift index 1c3601789df0a..4d50ef87a2f8f 160000 --- a/cranelift +++ b/cranelift @@ -1 +1 @@ -Subproject commit 1c3601789df0ad52880feebc2e641848838b7c14 +Subproject commit 4d50ef87a2f8faa4e590423f712d99bef5cb9148 diff --git a/src/base.rs b/src/base.rs index 1186f5138558d..2e6d0bcd15491 100644 --- a/src/base.rs +++ b/src/base.rs @@ -318,7 +318,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & let res = ::common::cton_intcast(fx, from, from_ty, to_ty, true); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - _ => unimplemented!("rval misc {:?} {:?}", operand, to_ty), + _ => return Err(format!("rval misc {:?} {:?}", operand, to_ty)), } }, Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty), diff --git a/src/lib.rs b/src/lib.rs index d5400c9ce8112..c3294c3c4cfaf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,10 +10,17 @@ extern crate rustc_target; extern crate rustc_incremental; extern crate rustc_data_structures; +extern crate target_lexicon; extern crate cranelift; extern crate cranelift_module; extern crate cranelift_simplejit; -//extern crate cranelift_faerie; +extern crate cranelift_faerie; + +use std::any::Any; +use std::sync::{mpsc, Arc}; +use std::path::Path; +use std::fs::File; +use std::io::Write; use syntax::symbol::Symbol; use rustc::session::{ @@ -23,16 +30,15 @@ use rustc::session::{ OutputFilenames, }, }; -use rustc::middle::cstore::{MetadataLoader, EncodedMetadata}; +use rustc::middle::cstore::MetadataLoader; use rustc::dep_graph::DepGraph; use rustc::ty::query::Providers; -use rustc_codegen_utils::codegen_backend::{CodegenBackend, NoLlvmMetadataLoader}; +use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::{out_filename, build_link_meta}; +use rustc_data_structures::owning_ref; -use std::any::Any; -use std::sync::{mpsc, Arc}; -use std::fs::File; -use std::io::Write; +use cranelift::codegen::settings; +use cranelift_faerie::*; mod abi; mod base; @@ -63,7 +69,7 @@ mod prelude { }; pub use cranelift::codegen::Context; pub use cranelift::prelude::*; - pub use cranelift_module::{Module, Backend, FuncId, DataId, Linkage}; + pub use cranelift_module::{Module, Backend, DataContext, FuncId, DataId, Linkage, Writability}; pub use cranelift_simplejit::{SimpleJITBuilder, SimpleJITBackend}; pub use abi::*; @@ -82,20 +88,25 @@ pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub constants: HashMap, } -struct CraneliftCodegenBackend(()); +struct CraneliftMetadataLoader; -struct OngoingCodegen { - metadata: EncodedMetadata, - //translated_module: Module, - crate_name: Symbol, -} +impl MetadataLoader for CraneliftMetadataLoader { + fn get_rlib_metadata(&self, target: &rustc_target::spec::Target, path: &Path) -> Result, String> { + self.get_dylib_metadata(target, path) + } -impl CraneliftCodegenBackend { - fn new() -> Box { - Box::new(CraneliftCodegenBackend(())) + fn get_dylib_metadata(&self, _target: &rustc_target::spec::Target, _path: &Path) -> Result, String> { + Err("metadata loading is not yet supported".to_string()) } } +struct CraneliftCodegenBackend; + +struct OngoingCodegen { + translated_module: Module, + crate_name: Symbol, +} + impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { for cty in sess.opts.crate_types.iter() { @@ -112,16 +123,13 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn metadata_loader(&self) -> Box { - Box::new(NoLlvmMetadataLoader) + Box::new(CraneliftMetadataLoader) } fn provide(&self, providers: &mut Providers) { rustc_codegen_utils::symbol_names::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| { - /*Lrc::new(rustc_codegen_utils::llvm_target_features::all_known_features() - .map(|(a, b)| (a.to_string(), b.map(|s| s.to_string()))) - .collect())*/ Lrc::new(Default::default()) }; providers.is_reachable_non_generic = |_tcx, _defid| true; @@ -172,6 +180,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); let metadata = tcx.encode_metadata(&link_meta); + let mut flags_builder = settings::builder(); + flags_builder.enable("is_pic").unwrap(); + let flags = settings::Flags::new(flags_builder); + let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()).unwrap().finish(flags); let mut module: Module = Module::new(SimpleJITBuilder::new()); let mut context = Context::new(); let mut def_id_fn_id_map = HashMap::new(); @@ -219,11 +231,23 @@ impl CodegenBackend for CraneliftCodegenBackend { module.finish(); } - tcx.sess.fatal("unimplemented"); + let mut translated_module = Module::new( + FaerieBuilder::new( + isa, + "some_file.o".to_string(), + FaerieTrapCollection::Disabled, + FaerieBuilder::default_libcall_names() + ) + .unwrap() + ); + + let metadata_id = translated_module.declare_data(".rustc.metadata", Linkage::Export, false).unwrap(); + let mut data_ctx = DataContext::new(); + data_ctx.define(metadata.raw_data.clone().into_boxed_slice(), Writability::Readonly); + translated_module.define_data(metadata_id, &data_ctx).unwrap(); Box::new(::OngoingCodegen { - metadata: metadata, - //translated_module: Module::new(::cranelift_faerie::FaerieBuilder::new(, + translated_module, crate_name: tcx.crate_name(LOCAL_CRATE), }) } @@ -235,21 +259,17 @@ impl CodegenBackend for CraneliftCodegenBackend { _dep_graph: &DepGraph, outputs: &OutputFilenames, ) -> Result<(), CompileIncomplete> { - if true { - unimplemented!(); - } - - let ongoing_codegen = ongoing_codegen.downcast::() - .expect("Expected MetadataOnlyCodegenBackend's OngoingCodegen, found Box"); + let ongoing_codegen = *ongoing_codegen.downcast::() + .expect("Expected CraneliftCodegenBackend's OngoingCodegen, found Box"); + let artifact = ongoing_codegen.translated_module.finish().artifact; for &crate_type in sess.opts.crate_types.iter() { - if crate_type != CrateType::CrateTypeRlib && crate_type != CrateType::CrateTypeDylib { - continue; + if crate_type != CrateType::CrateTypeRlib /*&& crate_type != CrateType::CrateTypeDylib*/ { + sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)); } let output_name = out_filename(sess, crate_type, &outputs, &ongoing_codegen.crate_name.as_str()); - let metadata = &ongoing_codegen.metadata.raw_data; - let mut file = File::create(&output_name).unwrap(); - file.write_all(metadata).unwrap(); + let file = File::create(&output_name).unwrap(); + artifact.write(file).unwrap(); } sess.abort_if_errors(); @@ -265,5 +285,5 @@ impl CodegenBackend for CraneliftCodegenBackend { /// This is the entrypoint for a hot plugged rustc_codegen_cranelift #[no_mangle] pub fn __rustc_codegen_backend() -> Box { - CraneliftCodegenBackend::new() + Box::new(CraneliftCodegenBackend) } From ae44a1a172a8ec1b358a174b5a306b2b017cf133 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Jul 2018 14:10:53 +0200 Subject: [PATCH 0063/1566] Add support for metadata loading --- Cargo.lock | 17 ++++++++++++ Cargo.toml | 3 ++ build.sh | 3 +- example.rs | 75 ++------------------------------------------------ mini_core.rs | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 77 ++++++++++++++++++++++++++++++++++++++++++---------- 6 files changed, 163 insertions(+), 88 deletions(-) create mode 100644 mini_core.rs diff --git a/Cargo.lock b/Cargo.lock index df75a456740c3..b20a0c7ec2cc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,6 +14,14 @@ dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ar" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.10" @@ -55,6 +63,11 @@ name = "bitflags" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "byteorder" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "cc" version = "1.0.18" @@ -391,10 +404,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ + "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.16.1", "cranelift-faerie 0.16.1", "cranelift-module 0.16.1", "cranelift-simplejit 0.16.1", + "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -618,11 +633,13 @@ dependencies = [ [metadata] "checksum aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c6d463cbe7ed28720b5b489e7c083eeb8f90d08be2a0d6bb9e1ffea9ce1afa" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "095515608290b62ac2427084f9ac3cfeb5dc76067f7d94564db9db1c46cc0a85" "checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" +"checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9" "checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" "checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" diff --git a/Cargo.toml b/Cargo.toml index 921a65bcedf4f..dc4f2d93fafc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,6 @@ cranelift-module = { path = "./cranelift/lib/module" } cranelift-simplejit = { path = "./cranelift/lib/simplejit" } cranelift-faerie = { path = "./cranelift/lib/faerie" } target-lexicon = "0.0.3" +#goblin = "0.0.17" +faerie = "0.4.4" +ar = "0.6.0" diff --git a/build.sh b/build.sh index a202d30073636..85c673d1377c4 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,5 @@ cargo build || exit 1 -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so example.rs --crate-type lib -Og +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so mini_core.rs --crate-name mini_core --crate-type lib -Og && +rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so -L crate=. example.rs --crate-type lib -Og && rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ./target/libcore/src/libcore/lib.rs --crate-type lib -Og diff --git a/example.rs b/example.rs index a1dbe0b872e1b..0df10254f760b 100644 --- a/example.rs +++ b/example.rs @@ -1,79 +1,10 @@ -#![feature(no_core, lang_items, intrinsics)] +#![feature(no_core)] #![no_core] #![allow(dead_code)] -#[lang="sized"] -pub trait Sized {} +extern crate mini_core; -#[lang="copy"] -unsafe trait Copy {} - -unsafe impl Copy for u8 {} -unsafe impl Copy for u16 {} -unsafe impl Copy for u32 {} -unsafe impl Copy for u64 {} -unsafe impl Copy for usize {} -unsafe impl Copy for i8 {} -unsafe impl Copy for i16 {} -unsafe impl Copy for i32 {} -unsafe impl Copy for isize {} -unsafe impl<'a, T: ?Sized> Copy for &'a T {} -unsafe impl Copy for *const T {} - -#[lang="freeze"] -trait Freeze {} - -#[lang="mul"] -trait Mul { - type Output; - - #[must_use] - fn mul(self, rhs: RHS) -> Self::Output; -} - -impl Mul for u8 { - type Output = Self; - - fn mul(self, rhs: Self) -> Self { - self * rhs - } -} - -#[lang = "eq"] -pub trait PartialEq { - fn eq(&self, other: &Rhs) -> bool; - fn ne(&self, other: &Rhs) -> bool; -} - -impl PartialEq for u8 { - fn eq(&self, other: &u8) -> bool { (*self) == (*other) } - fn ne(&self, other: &u8) -> bool { (*self) != (*other) } -} - -impl PartialEq for *const T { - fn eq(&self, other: &*const T) -> bool { *self == *other } - fn ne(&self, other: &*const T) -> bool { *self != *other } -} - -#[lang="panic"] -fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { - loop {} -} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -unsafe fn drop_in_place(to_drop: *mut T) { - // Code here does not matter - this is replaced by the - // real drop glue by the compiler. - drop_in_place(to_drop); -} - -mod intrinsics { - extern "rust-intrinsic" { - pub fn size_of() -> usize; - pub fn copy(src: *const T, dst: *mut T, count: usize); - } -} +use mini_core::*; fn abc(a: u8) -> u8 { a * 2 diff --git a/mini_core.rs b/mini_core.rs new file mode 100644 index 0000000000000..efd0b8818b123 --- /dev/null +++ b/mini_core.rs @@ -0,0 +1,76 @@ +#![feature(no_core, lang_items, intrinsics)] +#![no_core] +#![allow(dead_code)] + +#[lang="sized"] +pub trait Sized {} + +#[lang="copy"] +pub unsafe trait Copy {} + +unsafe impl Copy for u8 {} +unsafe impl Copy for u16 {} +unsafe impl Copy for u32 {} +unsafe impl Copy for u64 {} +unsafe impl Copy for usize {} +unsafe impl Copy for i8 {} +unsafe impl Copy for i16 {} +unsafe impl Copy for i32 {} +unsafe impl Copy for isize {} +unsafe impl<'a, T: ?Sized> Copy for &'a T {} +unsafe impl Copy for *const T {} + +#[lang="freeze"] +trait Freeze {} + +#[lang="mul"] +pub trait Mul { + type Output; + + #[must_use] + fn mul(self, rhs: RHS) -> Self::Output; +} + +impl Mul for u8 { + type Output = Self; + + fn mul(self, rhs: Self) -> Self { + self * rhs + } +} + +#[lang = "eq"] +pub trait PartialEq { + fn eq(&self, other: &Rhs) -> bool; + fn ne(&self, other: &Rhs) -> bool; +} + +impl PartialEq for u8 { + fn eq(&self, other: &u8) -> bool { (*self) == (*other) } + fn ne(&self, other: &u8) -> bool { (*self) != (*other) } +} + +impl PartialEq for *const T { + fn eq(&self, other: &*const T) -> bool { *self == *other } + fn ne(&self, other: &*const T) -> bool { *self != *other } +} + +#[lang="panic"] +pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { + loop {} +} + +#[lang = "drop_in_place"] +#[allow(unconditional_recursion)] +pub unsafe fn drop_in_place(to_drop: *mut T) { + // Code here does not matter - this is replaced by the + // real drop glue by the compiler. + drop_in_place(to_drop); +} + +pub mod intrinsics { + extern "rust-intrinsic" { + pub fn size_of() -> usize; + pub fn copy(src: *const T, dst: *mut T, count: usize); + } +} diff --git a/src/lib.rs b/src/lib.rs index c3294c3c4cfaf..53abaca552e3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,8 +8,12 @@ extern crate rustc_mir; extern crate rustc_codegen_utils; extern crate rustc_target; extern crate rustc_incremental; +#[macro_use] extern crate rustc_data_structures; +extern crate ar; +extern crate faerie; +//extern crate goblin; extern crate target_lexicon; extern crate cranelift; extern crate cranelift_module; @@ -20,7 +24,6 @@ use std::any::Any; use std::sync::{mpsc, Arc}; use std::path::Path; use std::fs::File; -use std::io::Write; use syntax::symbol::Symbol; use rustc::session::{ @@ -35,7 +38,7 @@ use rustc::dep_graph::DepGraph; use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::{out_filename, build_link_meta}; -use rustc_data_structures::owning_ref; +use rustc_data_structures::owning_ref::{self, OwningRef}; use cranelift::codegen::settings; use cranelift_faerie::*; @@ -91,19 +94,53 @@ pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { - fn get_rlib_metadata(&self, target: &rustc_target::spec::Target, path: &Path) -> Result, String> { - self.get_dylib_metadata(target, path) + fn get_rlib_metadata(&self, _target: &rustc_target::spec::Target, path: &Path) -> Result, String> { + let mut archive = ar::Archive::new(File::open(path).map_err(|e|format!("{:?}", e))?); + // Iterate over all entries in the archive: + while let Some(entry_result) = archive.next_entry() { + let mut entry = entry_result.map_err(|e|format!("{:?}", e))?; + if entry.header().identifier() == b".rustc.clif_metadata" { + let mut buf = Vec::new(); + ::std::io::copy(&mut entry, &mut buf).map_err(|e|format!("{:?}", e))?; + let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + return Ok(rustc_erase_owner!(buf.map_owner_box())); + } + } + + Err("couldn't find metadata entry".to_string()) + //self.get_dylib_metadata(target, path) } fn get_dylib_metadata(&self, _target: &rustc_target::spec::Target, _path: &Path) -> Result, String> { - Err("metadata loading is not yet supported".to_string()) + //use goblin::Object; + + //let buffer = ::std::fs::read(path).map_err(|e|format!("{:?}", e))?; + /*match Object::parse(&buffer).map_err(|e|format!("{:?}", e))? { + Object::Elf(elf) => { + println!("elf: {:#?}", &elf); + }, + Object::PE(pe) => { + println!("pe: {:#?}", &pe); + }, + Object::Mach(mach) => { + println!("mach: {:#?}", &mach); + }, + Object::Archive(archive) => { + return Err(format!("archive: {:#?}", &archive)); + }, + Object::Unknown(magic) => { + return Err(format!("unknown magic: {:#x}", magic)) + } + }*/ + Err("dylib metadata loading is not yet supported".to_string()) } } struct CraneliftCodegenBackend; struct OngoingCodegen { - translated_module: Module, + product: cranelift_faerie::FaerieProduct, + metadata: Vec, crate_name: Symbol, } @@ -231,7 +268,7 @@ impl CodegenBackend for CraneliftCodegenBackend { module.finish(); } - let mut translated_module = Module::new( + let mut translated_module: Module = Module::new( FaerieBuilder::new( isa, "some_file.o".to_string(), @@ -241,13 +278,9 @@ impl CodegenBackend for CraneliftCodegenBackend { .unwrap() ); - let metadata_id = translated_module.declare_data(".rustc.metadata", Linkage::Export, false).unwrap(); - let mut data_ctx = DataContext::new(); - data_ctx.define(metadata.raw_data.clone().into_boxed_slice(), Writability::Readonly); - translated_module.define_data(metadata_id, &data_ctx).unwrap(); - Box::new(::OngoingCodegen { - translated_module, + product: translated_module.finish(), + metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), }) } @@ -261,7 +294,19 @@ impl CodegenBackend for CraneliftCodegenBackend { ) -> Result<(), CompileIncomplete> { let ongoing_codegen = *ongoing_codegen.downcast::() .expect("Expected CraneliftCodegenBackend's OngoingCodegen, found Box"); - let artifact = ongoing_codegen.translated_module.finish().artifact; + + let mut artifact = ongoing_codegen.product.artifact; + let metadata = ongoing_codegen.metadata; + + artifact.declare_with( + ".rustc.clif_metadata", + faerie::artifact::Decl::Data { + global: true, + writeable: false + }, + metadata.clone(), + ).unwrap(); + for &crate_type in sess.opts.crate_types.iter() { if crate_type != CrateType::CrateTypeRlib /*&& crate_type != CrateType::CrateTypeDylib*/ { sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)); @@ -269,7 +314,9 @@ impl CodegenBackend for CraneliftCodegenBackend { let output_name = out_filename(sess, crate_type, &outputs, &ongoing_codegen.crate_name.as_str()); let file = File::create(&output_name).unwrap(); - artifact.write(file).unwrap(); + let mut builder = ar::Builder::new(file); + builder.append(&ar::Header::new(b".rustc.clif_metadata".to_vec(), metadata.len() as u64), ::std::io::Cursor::new(metadata.clone())).unwrap(); + //artifact.write(file).unwrap(); } sess.abort_if_errors(); From 874208bcd5490ee19a42787c529ab80c1595cf36 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Jul 2018 13:38:49 +0200 Subject: [PATCH 0064/1566] Add closure support (fixes #2) --- build.sh | 2 ++ example.rs | 10 ++++++- mini_core.rs | 16 +++++++++- src/abi.rs | 84 +++++++++++++++++++++++++++++++++------------------- 4 files changed, 79 insertions(+), 33 deletions(-) diff --git a/build.sh b/build.sh index 85c673d1377c4..724f5deedfc93 100755 --- a/build.sh +++ b/build.sh @@ -3,3 +3,5 @@ cargo build || exit 1 rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so mini_core.rs --crate-name mini_core --crate-type lib -Og && rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so -L crate=. example.rs --crate-type lib -Og && rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ./target/libcore/src/libcore/lib.rs --crate-type lib -Og + +rm libmini_core.rlib libexample.rlib diff --git a/example.rs b/example.rs index 0df10254f760b..0f37d7f4c3635 100644 --- a/example.rs +++ b/example.rs @@ -60,7 +60,7 @@ fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { a == b } -fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize) { +fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { ( a as u8, a as u16, @@ -70,6 +70,8 @@ fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize) { a as i16, a as i32, a as isize, + b as u8, + b as u32 ) } @@ -107,3 +109,9 @@ const Abc: u8 = 6 * 7; fn use_const() -> u8 { Abc } + +fn call_closure() { + (|_, _, _| { + + })(0u8, 42u8, 0u8) +} diff --git a/mini_core.rs b/mini_core.rs index efd0b8818b123..d4844cc0be2d9 100644 --- a/mini_core.rs +++ b/mini_core.rs @@ -1,4 +1,4 @@ -#![feature(no_core, lang_items, intrinsics)] +#![feature(no_core, lang_items, intrinsics, unboxed_closures)] #![no_core] #![allow(dead_code)] @@ -55,6 +55,20 @@ impl PartialEq for *const T { fn ne(&self, other: &*const T) -> bool { *self != *other } } +#[lang = "fn_once"] +#[rustc_paren_sugar] +trait FnOnce { + type Output; + + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} + +#[lang = "fn_mut"] +#[rustc_paren_sugar] +trait FnMut : FnOnce { + extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; +} + #[lang="panic"] pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { loop {} diff --git a/src/abi.rs b/src/abi.rs index e228b863b1ce1..a36ac1611a194 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -7,12 +7,22 @@ use prelude::*; pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>) -> Signature { let sig = ty_fn_sig(tcx, fn_ty); - let sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig); assert!(!sig.variadic, "Variadic function are not yet supported"); let (call_conv, inputs, _output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { - unimplemented!("rust-call"); + println!("rust-call sig: {:?} inputs: {:?} output: {:?}", sig, sig.inputs(), sig.output()); + let extra_args = match sig.inputs().last().unwrap().sty { + ty::TyTuple(ref tupled_arguments) => tupled_arguments, + _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), + }; + let mut inputs: Vec = sig.inputs()[0..sig.inputs().len() - 1].to_vec(); + inputs.extend(extra_args.into_iter()); + ( + CallConv::SystemV, + inputs, + sig.output(), + ) } Abi::System => bug!("system abi should be selected elsewhere"), // TODO: properly implement intrinsics @@ -32,8 +42,8 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< fn ty_fn_sig<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx> -) -> ty::PolyFnSig<'tcx> { - match ty.sty { +) -> ty::FnSig<'tcx> { + let sig = match ty.sty { ty::TyFnDef(..) | // Shims currently have type TyFnPtr. Not sure this should remain. ty::TyFnPtr(_) => ty.fn_sig(tcx), @@ -73,7 +83,8 @@ fn ty_fn_sig<'a, 'tcx>( }) } _ => bug!("unexpected type {:?} to ty_fn_sig", ty) - } + }; + tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig) } impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { @@ -91,8 +102,7 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { } fn self_sig(&self) -> FnSig<'tcx> { - let sig = ty_fn_sig(self.tcx, self.instance.ty(self.tcx)); - self.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig) + ty_fn_sig(self.tcx, self.instance.ty(self.tcx)) } fn return_type(&self) -> Ty<'tcx> { @@ -153,6 +163,8 @@ pub fn codegen_call<'a, 'tcx: 'a>( destination: &Option<(Place<'tcx>, BasicBlock)>, ) { let func = ::base::trans_operand(fx, func); + let fn_ty = func.layout().ty; + let sig = ty_fn_sig(fx.tcx, fn_ty); let return_place = if let Some((place, _)) = destination { Some(::base::trans_place(fx, place)) @@ -160,29 +172,33 @@ pub fn codegen_call<'a, 'tcx: 'a>( None }; - let args = args - .into_iter() - .map(|arg| { - let arg = ::base::trans_operand(fx, arg); - if let Some(_) = fx.cton_type(arg.layout().ty) { - arg.load_value(fx) - } else { - arg.force_stack(fx) - } - }) - .collect::>(); + // Unpack arguments tuple for closures + let args = if sig.abi == Abi::RustCall { + assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); + let self_arg = ::base::trans_operand(fx, &args[0]); + let pack_arg = ::base::trans_operand(fx, &args[1]); + let mut args = Vec::new(); + args.push(self_arg); + match pack_arg.layout().ty.sty { + ty::TyTuple(ref tupled_arguments) => { + for (i, _) in tupled_arguments.iter().enumerate() { + args.push(pack_arg.value_field(fx, mir::Field::new(i))); + } + }, + _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), + } + args + } else { + args + .into_iter() + .map(|arg| { + ::base::trans_operand(fx, arg) + }) + .collect::>() + }; - let fn_ty = func.layout().ty; if let TypeVariants::TyFnDef(def_id, substs) = fn_ty.sty { - let instance = ty::Instance::resolve( - fx.tcx, - ParamEnv::reveal_all(), - def_id, - substs - ).unwrap(); - - // Handle intrinsics old codegen wants Expr's for, ourselves. - if let InstanceDef::Intrinsic(def_id) = instance.def { + if sig.abi == Abi::RustIntrinsic { let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; @@ -218,17 +234,23 @@ pub fn codegen_call<'a, 'tcx: 'a>( None => fx.bcx.ins().iconst(types::I64, 0), }; - let args = Some(return_ptr).into_iter().chain(args).collect::>(); + let call_args = Some(return_ptr).into_iter().chain(args.into_iter().map(|arg| { + if fx.cton_type(arg.layout().ty).is_some() { + arg.load_value(fx) + } else { + arg.force_stack(fx) + } + })).collect::>(); match func { CValue::Func(func, _) => { - fx.bcx.ins().call(func, &args); + fx.bcx.ins().call(func, &call_args); } func => { let func_ty = func.layout().ty; let func = func.load_value(fx); let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, func_ty)); - fx.bcx.ins().call_indirect(sig, func, &args); + fx.bcx.ins().call_indirect(sig, func, &call_args); } } if let Some((_, dest)) = *destination { From 7862e2ea1cd1270744d1d22f6fdff35b7c3c8dc5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 26 Jul 2018 10:48:50 +0200 Subject: [PATCH 0065/1566] Implement some intrinsics --- example.rs | 8 ++++++++ mini_core.rs | 7 +++++++ src/abi.rs | 42 +++++++++++++++++++++++++++++++++++++++++- src/base.rs | 34 ++++++++++++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 3 deletions(-) diff --git a/example.rs b/example.rs index 0f37d7f4c3635..1c67b6810ce71 100644 --- a/example.rs +++ b/example.rs @@ -115,3 +115,11 @@ fn call_closure() { })(0u8, 42u8, 0u8) } + +fn eq_char(a: char, b: char) -> bool { + a == b +} + +unsafe fn transmute(c: char) -> u32 { + intrinsics::transmute(c) +} diff --git a/mini_core.rs b/mini_core.rs index d4844cc0be2d9..2496eb1bf4a3f 100644 --- a/mini_core.rs +++ b/mini_core.rs @@ -17,6 +17,7 @@ unsafe impl Copy for i8 {} unsafe impl Copy for i16 {} unsafe impl Copy for i32 {} unsafe impl Copy for isize {} +unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl Copy for *const T {} @@ -50,6 +51,11 @@ impl PartialEq for u8 { fn ne(&self, other: &u8) -> bool { (*self) != (*other) } } +impl PartialEq for char { + fn eq(&self, other: &char) -> bool { (*self) == (*other) } + fn ne(&self, other: &char) -> bool { (*self) != (*other) } +} + impl PartialEq for *const T { fn eq(&self, other: &*const T) -> bool { *self == *other } fn ne(&self, other: &*const T) -> bool { *self != *other } @@ -86,5 +92,6 @@ pub mod intrinsics { extern "rust-intrinsic" { pub fn size_of() -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); + pub fn transmute(e: T) -> U; } } diff --git a/src/abi.rs b/src/abi.rs index a36ac1611a194..6e57d7ac5f7e5 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -203,6 +203,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let intrinsic = &intrinsic[..]; let usize_layout = fx.layout_of(fx.tcx.types.usize); + let ret = return_place.unwrap(); match intrinsic { "copy" => { /*let elem_ty = substs.type_at(0); @@ -213,9 +214,48 @@ pub fn codegen_call<'a, 'tcx: 'a>( unimplemented!("copy"); } "size_of" => { + assert_eq!(args.len(), 0); let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); - return_place.unwrap().write_cvalue(fx, size_of); + ret.write_cvalue(fx, size_of); + } + _ if intrinsic.starts_with("unchecked_") => { + assert_eq!(args.len(), 2); + let lhs = args[0].load_value(fx); + let rhs = args[1].load_value(fx); + let bin_op = match intrinsic { + "unchecked_div" => BinOp::Div, + "unchecked_rem" => BinOp::Rem, + "unchecked_shl" => BinOp::Shl, + "unchecked_shr" => BinOp::Shr, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match ret.layout().ty.sty { + TypeVariants::TyUint(_) => { + ::base::trans_int_binop(fx, bin_op, lhs, rhs, args[0].layout().ty, false, false) + } + TypeVariants::TyInt(_) => { + ::base::trans_int_binop(fx, bin_op, lhs, rhs, args[0].layout().ty, true, false) + } + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + "offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); + } + "transmute" => { + assert_eq!(args.len(), 1); + let src_ty = substs.type_at(0); + let dst_ty = substs.type_at(1); + assert_eq!(args[0].layout().ty, src_ty); + let addr = args[0].force_stack(fx); + let dst_layout = fx.layout_of(dst_ty); + ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) } _ => fx.tcx.sess.fatal(&format!("unsupported intrinsic {}", intrinsic)), } diff --git a/src/base.rs b/src/base.rs index 2e6d0bcd15491..d5c67480ef23a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -248,6 +248,9 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & TypeVariants::TyInt(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true, false) } + TypeVariants::TyChar => { + trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) + } TypeVariants::TyRawPtr(..) => { trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } @@ -423,9 +426,9 @@ macro_rules! binop_match { } } -fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { +pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, signed, lhs, rhs, "non ptr"; + fx, bin_op, signed, lhs, rhs, "int/uint"; Add (_) iadd; Sub (_) isub; Mul (_) imul; @@ -458,6 +461,33 @@ fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l CValue::ByVal(res, fx.layout_of(ty)) } +pub fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { + let res = binop_match! { + fx, bin_op, false, lhs, rhs, "char"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) bug; + }; + + CValue::ByVal(res, fx.layout_of(ty)) +} + fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, _checked: bool) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, false, lhs, rhs, "ptr"; From ab00acfb55eafa3df8edecbd5f54c7d678784ee7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 26 Jul 2018 10:59:57 +0200 Subject: [PATCH 0066/1566] Add binop impls for TyBool --- mini_core.rs | 25 +++++++++++++++++++++++++ src/base.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/mini_core.rs b/mini_core.rs index 2496eb1bf4a3f..3829c0f588a93 100644 --- a/mini_core.rs +++ b/mini_core.rs @@ -8,6 +8,7 @@ pub trait Sized {} #[lang="copy"] pub unsafe trait Copy {} +unsafe impl Copy for bool {} unsafe impl Copy for u8 {} unsafe impl Copy for u16 {} unsafe impl Copy for u32 {} @@ -40,6 +41,30 @@ impl Mul for u8 { } } +#[lang="bitor"] +pub trait BitOr { + type Output; + + #[must_use] + fn bitor(self, rhs: RHS) -> Self::Output; +} + +impl BitOr for bool { + type Output = bool; + + fn bitor(self, rhs: bool) -> bool { + self | rhs + } +} + +impl<'a> BitOr for &'a bool { + type Output = bool; + + fn bitor(self, rhs: bool) -> bool { + *self | rhs + } +} + #[lang = "eq"] pub trait PartialEq { fn eq(&self, other: &Rhs) -> bool; diff --git a/src/base.rs b/src/base.rs index d5c67480ef23a..23dfab91f1583 100644 --- a/src/base.rs +++ b/src/base.rs @@ -242,6 +242,9 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & let rhs = trans_operand(fx, rhs).load_value(fx); let res = match ty.sty { + TypeVariants::TyBool => { + trans_bool_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) + } TypeVariants::TyUint(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false, false) } @@ -426,6 +429,33 @@ macro_rules! binop_match { } } +pub fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { + let res = binop_match! { + fx, bin_op, false, lhs, rhs, "bool"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bxor; + BitAnd (_) band; + BitOr (_) bor; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) bug; + }; + + CValue::ByVal(res, fx.layout_of(ty)) +} + pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, signed, lhs, rhs, "int/uint"; From 3a0f5dc9ec47f7295a534b2aca7795591ce4a3a0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Jul 2018 19:01:38 +0200 Subject: [PATCH 0067/1566] Fix a bug when the same function is called with different signatures --- example.rs | 10 ++++++++-- src/abi.rs | 8 ++++++-- src/base.rs | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/example.rs b/example.rs index 1c67b6810ce71..35e124c5d2d60 100644 --- a/example.rs +++ b/example.rs @@ -110,10 +110,16 @@ fn use_const() -> u8 { Abc } -fn call_closure() { +fn call_closure_3arg() { (|_, _, _| { - })(0u8, 42u8, 0u8) + })(0u8, 42u16, 0u8) +} + +fn call_closure_2arg() { + (|_, _| { + + })(0u8, 42u16) } fn eq_char(a: char, b: char) -> bool { diff --git a/src/abi.rs b/src/abi.rs index 6e57d7ac5f7e5..251d9603aa6af 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -12,11 +12,12 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { println!("rust-call sig: {:?} inputs: {:?} output: {:?}", sig, sig.inputs(), sig.output()); + assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().sty { ty::TyTuple(ref tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; - let mut inputs: Vec = sig.inputs()[0..sig.inputs().len() - 1].to_vec(); + let mut inputs: Vec = vec![sig.inputs()[0]]; inputs.extend(extra_args.into_iter()); ( CallConv::SystemV, @@ -96,7 +97,10 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { let fn_ty = inst.ty(tcx); let sig = cton_sig_from_fn_ty(tcx, fn_ty); - module.declare_function(&tcx.absolute_item_path_str(inst.def_id()), Linkage::Local, &sig).unwrap() + let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); + let mut name = String::new(); + def_path_based_names.push_instance_as_string(inst, &mut name); + module.declare_function(&name, Linkage::Local, &sig).unwrap() }); module.declare_func_in_func(func_id, &mut self.bcx.func) } diff --git a/src/base.rs b/src/base.rs index 23dfab91f1583..e58a8af828530 100644 --- a/src/base.rs +++ b/src/base.rs @@ -23,6 +23,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let func_id = { let module = &mut cx.module; *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { + // WARNING: keep in sync with FunctionCx::get_function_ref let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); let mut name = String::new(); def_path_based_names.push_instance_as_string(inst, &mut name); From d470a61d0b7044df989c70ec3acd732e801682b6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Jul 2018 19:26:19 +0200 Subject: [PATCH 0068/1566] Add patch to disable atomic ops in libcore --- 0003-Remove-atomics-from-libcore.patch | 2183 ++++++++++++++++++++++++ 1 file changed, 2183 insertions(+) create mode 100644 0003-Remove-atomics-from-libcore.patch diff --git a/0003-Remove-atomics-from-libcore.patch b/0003-Remove-atomics-from-libcore.patch new file mode 100644 index 0000000000000..f5e7449862c82 --- /dev/null +++ b/0003-Remove-atomics-from-libcore.patch @@ -0,0 +1,2183 @@ +From 950bfa9eb7a0eb441601cbe0adc1aefcfab8e031 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Fri, 27 Jul 2018 19:07:01 +0200 +Subject: [PATCH] Remove atomics from libcore + +--- + src/libcore/lib.rs | 1 - + src/libcore/sync/atomic.rs | 2128 -------------------------------------------- + src/libcore/sync/mod.rs | 15 - + 3 files changed, 2144 deletions(-) + delete mode 100644 src/libcore/sync/atomic.rs + delete mode 100644 src/libcore/sync/mod.rs + +diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs +index 3aa79087db..71fcff2e8b 100644 +--- a/src/libcore/lib.rs ++++ b/src/libcore/lib.rs +@@ -185,7 +185,6 @@ pub mod borrow; + pub mod any; + pub mod array; + pub mod ascii; +-pub mod sync; + pub mod cell; + pub mod char; + pub mod panic; +diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs +deleted file mode 100644 +index 1e2b18bf9b..0000000000 +--- a/src/libcore/sync/atomic.rs ++++ /dev/null +@@ -1,2128 +0,0 @@ +-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +-// file at the top-level directory of this distribution and at +-// http://rust-lang.org/COPYRIGHT. +-// +-// Licensed under the Apache License, Version 2.0 or the MIT license +-// , at your +-// option. This file may not be copied, modified, or distributed +-// except according to those terms. +- +-//! Atomic types +-//! +-//! Atomic types provide primitive shared-memory communication between +-//! threads, and are the building blocks of other concurrent +-//! types. +-//! +-//! This module defines atomic versions of a select number of primitive +-//! types, including [`AtomicBool`], [`AtomicIsize`], and [`AtomicUsize`]. +-//! Atomic types present operations that, when used correctly, synchronize +-//! updates between threads. +-//! +-//! [`AtomicBool`]: struct.AtomicBool.html +-//! [`AtomicIsize`]: struct.AtomicIsize.html +-//! [`AtomicUsize`]: struct.AtomicUsize.html +-//! +-//! Each method takes an [`Ordering`] which represents the strength of +-//! the memory barrier for that operation. These orderings are the +-//! same as [LLVM atomic orderings][1]. For more information see the [nomicon][2]. +-//! +-//! [`Ordering`]: enum.Ordering.html +-//! +-//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations +-//! [2]: ../../../nomicon/atomics.html +-//! +-//! Atomic variables are safe to share between threads (they implement [`Sync`]) +-//! but they do not themselves provide the mechanism for sharing and follow the +-//! [threading model](../../../std/thread/index.html#the-threading-model) of rust. +-//! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an +-//! atomically-reference-counted shared pointer). +-//! +-//! [`Sync`]: ../../marker/trait.Sync.html +-//! [arc]: ../../../std/sync/struct.Arc.html +-//! +-//! Most atomic types may be stored in static variables, initialized using +-//! the provided static initializers like [`ATOMIC_BOOL_INIT`]. Atomic statics +-//! are often used for lazy global initialization. +-//! +-//! [`ATOMIC_BOOL_INIT`]: constant.ATOMIC_BOOL_INIT.html +-//! +-//! # Examples +-//! +-//! A simple spinlock: +-//! +-//! ``` +-//! use std::sync::Arc; +-//! use std::sync::atomic::{AtomicUsize, Ordering}; +-//! use std::thread; +-//! +-//! fn main() { +-//! let spinlock = Arc::new(AtomicUsize::new(1)); +-//! +-//! let spinlock_clone = spinlock.clone(); +-//! let thread = thread::spawn(move|| { +-//! spinlock_clone.store(0, Ordering::SeqCst); +-//! }); +-//! +-//! // Wait for the other thread to release the lock +-//! while spinlock.load(Ordering::SeqCst) != 0 {} +-//! +-//! if let Err(panic) = thread.join() { +-//! println!("Thread had an error: {:?}", panic); +-//! } +-//! } +-//! ``` +-//! +-//! Keep a global count of live threads: +-//! +-//! ``` +-//! use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +-//! +-//! static GLOBAL_THREAD_COUNT: AtomicUsize = ATOMIC_USIZE_INIT; +-//! +-//! let old_thread_count = GLOBAL_THREAD_COUNT.fetch_add(1, Ordering::SeqCst); +-//! println!("live threads: {}", old_thread_count + 1); +-//! ``` +- +-#![stable(feature = "rust1", since = "1.0.0")] +-#![cfg_attr(not(target_has_atomic = "8"), allow(dead_code))] +-#![cfg_attr(not(target_has_atomic = "8"), allow(unused_imports))] +- +-use self::Ordering::*; +- +-use intrinsics; +-use cell::UnsafeCell; +-use fmt; +- +-/// Save power or switch hyperthreads in a busy-wait spin-loop. +-/// +-/// This function is deliberately more primitive than +-/// [`std::thread::yield_now`](../../../std/thread/fn.yield_now.html) and +-/// does not directly yield to the system's scheduler. +-/// In some cases it might be useful to use a combination of both functions. +-/// Careful benchmarking is advised. +-/// +-/// On some platforms this function may not do anything at all. +-#[inline] +-#[stable(feature = "spin_loop_hint", since = "1.24.0")] +-pub fn spin_loop_hint() { +- #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +- unsafe { +- asm!("pause" ::: "memory" : "volatile"); +- } +- +- #[cfg(target_arch = "aarch64")] +- unsafe { +- asm!("yield" ::: "memory" : "volatile"); +- } +-} +- +-/// A boolean type which can be safely shared between threads. +-/// +-/// This type has the same in-memory representation as a [`bool`]. +-/// +-/// [`bool`]: ../../../std/primitive.bool.html +-#[cfg(target_has_atomic = "8")] +-#[stable(feature = "rust1", since = "1.0.0")] +-#[repr(transparent)] +-pub struct AtomicBool { +- v: UnsafeCell, +-} +- +-#[cfg(target_has_atomic = "8")] +-#[stable(feature = "rust1", since = "1.0.0")] +-impl Default for AtomicBool { +- /// Creates an `AtomicBool` initialized to `false`. +- fn default() -> Self { +- Self::new(false) +- } +-} +- +-// Send is implicitly implemented for AtomicBool. +-#[cfg(target_has_atomic = "8")] +-#[stable(feature = "rust1", since = "1.0.0")] +-unsafe impl Sync for AtomicBool {} +- +-/// A raw pointer type which can be safely shared between threads. +-/// +-/// This type has the same in-memory representation as a `*mut T`. +-#[cfg(target_has_atomic = "ptr")] +-#[stable(feature = "rust1", since = "1.0.0")] +-#[repr(transparent)] +-pub struct AtomicPtr { +- p: UnsafeCell<*mut T>, +-} +- +-#[cfg(target_has_atomic = "ptr")] +-#[stable(feature = "rust1", since = "1.0.0")] +-impl Default for AtomicPtr { +- /// Creates a null `AtomicPtr`. +- fn default() -> AtomicPtr { +- AtomicPtr::new(::ptr::null_mut()) +- } +-} +- +-#[cfg(target_has_atomic = "ptr")] +-#[stable(feature = "rust1", since = "1.0.0")] +-unsafe impl Send for AtomicPtr {} +-#[cfg(target_has_atomic = "ptr")] +-#[stable(feature = "rust1", since = "1.0.0")] +-unsafe impl Sync for AtomicPtr {} +- +-/// Atomic memory orderings +-/// +-/// Memory orderings limit the ways that both the compiler and CPU may reorder +-/// instructions around atomic operations. At its most restrictive, +-/// "sequentially consistent" atomics allow neither reads nor writes +-/// to be moved either before or after the atomic operation; on the other end +-/// "relaxed" atomics allow all reorderings. +-/// +-/// Rust's memory orderings are [the same as +-/// LLVM's](http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations). +-/// +-/// For more information see the [nomicon]. +-/// +-/// [nomicon]: ../../../nomicon/atomics.html +-#[stable(feature = "rust1", since = "1.0.0")] +-#[derive(Copy, Clone, Debug)] +-pub enum Ordering { +- /// No ordering constraints, only atomic operations. +- /// +- /// Corresponds to LLVM's [`Monotonic`] ordering. +- /// +- /// [`Monotonic`]: http://llvm.org/docs/Atomics.html#monotonic +- #[stable(feature = "rust1", since = "1.0.0")] +- Relaxed, +- /// When coupled with a store, all previous writes become visible +- /// to the other threads that perform a load with [`Acquire`] ordering +- /// on the same value. +- /// +- /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire +- #[stable(feature = "rust1", since = "1.0.0")] +- Release, +- /// When coupled with a load, all subsequent loads will see data +- /// written before a store with [`Release`] ordering on the same value +- /// in other threads. +- /// +- /// [`Release`]: http://llvm.org/docs/Atomics.html#release +- #[stable(feature = "rust1", since = "1.0.0")] +- Acquire, +- /// Has the effects of both [`Acquire`] and [`Release`] together. +- /// +- /// This ordering is only applicable for operations that combine both loads and stores. +- /// +- /// For loads it uses [`Acquire`] ordering. For stores it uses the [`Release`] ordering. +- /// +- /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire +- /// [`Release`]: http://llvm.org/docs/Atomics.html#release +- #[stable(feature = "rust1", since = "1.0.0")] +- AcqRel, +- /// Like `AcqRel` with the additional guarantee that all threads see all +- /// sequentially consistent operations in the same order. +- #[stable(feature = "rust1", since = "1.0.0")] +- SeqCst, +- // Prevent exhaustive matching to allow for future extension +- #[doc(hidden)] +- #[unstable(feature = "future_atomic_orderings", issue = "0")] +- __Nonexhaustive, +-} +- +-/// An [`AtomicBool`] initialized to `false`. +-/// +-/// [`AtomicBool`]: struct.AtomicBool.html +-#[cfg(target_has_atomic = "8")] +-#[stable(feature = "rust1", since = "1.0.0")] +-pub const ATOMIC_BOOL_INIT: AtomicBool = AtomicBool::new(false); +- +-#[cfg(target_has_atomic = "8")] +-impl AtomicBool { +- /// Creates a new `AtomicBool`. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::AtomicBool; +- /// +- /// let atomic_true = AtomicBool::new(true); +- /// let atomic_false = AtomicBool::new(false); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- pub const fn new(v: bool) -> AtomicBool { +- AtomicBool { v: UnsafeCell::new(v as u8) } +- } +- +- /// Returns a mutable reference to the underlying [`bool`]. +- /// +- /// This is safe because the mutable reference guarantees that no other threads are +- /// concurrently accessing the atomic data. +- /// +- /// [`bool`]: ../../../std/primitive.bool.html +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let mut some_bool = AtomicBool::new(true); +- /// assert_eq!(*some_bool.get_mut(), true); +- /// *some_bool.get_mut() = false; +- /// assert_eq!(some_bool.load(Ordering::SeqCst), false); +- /// ``` +- #[inline] +- #[stable(feature = "atomic_access", since = "1.15.0")] +- pub fn get_mut(&mut self) -> &mut bool { +- unsafe { &mut *(self.v.get() as *mut bool) } +- } +- +- /// Consumes the atomic and returns the contained value. +- /// +- /// This is safe because passing `self` by value guarantees that no other threads are +- /// concurrently accessing the atomic data. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::AtomicBool; +- /// +- /// let some_bool = AtomicBool::new(true); +- /// assert_eq!(some_bool.into_inner(), true); +- /// ``` +- #[inline] +- #[stable(feature = "atomic_access", since = "1.15.0")] +- pub fn into_inner(self) -> bool { +- self.v.into_inner() != 0 +- } +- +- /// Loads a value from the bool. +- /// +- /// `load` takes an [`Ordering`] argument which describes the memory ordering +- /// of this operation. +- /// +- /// # Panics +- /// +- /// Panics if `order` is [`Release`] or [`AcqRel`]. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// [`Release`]: enum.Ordering.html#variant.Release +- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let some_bool = AtomicBool::new(true); +- /// +- /// assert_eq!(some_bool.load(Ordering::Relaxed), true); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn load(&self, order: Ordering) -> bool { +- unsafe { atomic_load(self.v.get(), order) != 0 } +- } +- +- /// Stores a value into the bool. +- /// +- /// `store` takes an [`Ordering`] argument which describes the memory ordering +- /// of this operation. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let some_bool = AtomicBool::new(true); +- /// +- /// some_bool.store(false, Ordering::Relaxed); +- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); +- /// ``` +- /// +- /// # Panics +- /// +- /// Panics if `order` is [`Acquire`] or [`AcqRel`]. +- /// +- /// [`Acquire`]: enum.Ordering.html#variant.Acquire +- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn store(&self, val: bool, order: Ordering) { +- unsafe { +- atomic_store(self.v.get(), val as u8, order); +- } +- } +- +- /// Stores a value into the bool, returning the previous value. +- /// +- /// `swap` takes an [`Ordering`] argument which describes the memory ordering +- /// of this operation. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let some_bool = AtomicBool::new(true); +- /// +- /// assert_eq!(some_bool.swap(false, Ordering::Relaxed), true); +- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn swap(&self, val: bool, order: Ordering) -> bool { +- unsafe { atomic_swap(self.v.get(), val as u8, order) != 0 } +- } +- +- /// Stores a value into the [`bool`] if the current value is the same as the `current` value. +- /// +- /// The return value is always the previous value. If it is equal to `current`, then the value +- /// was updated. +- /// +- /// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory +- /// ordering of this operation. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// [`bool`]: ../../../std/primitive.bool.html +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let some_bool = AtomicBool::new(true); +- /// +- /// assert_eq!(some_bool.compare_and_swap(true, false, Ordering::Relaxed), true); +- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); +- /// +- /// assert_eq!(some_bool.compare_and_swap(true, true, Ordering::Relaxed), false); +- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> bool { +- match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) { +- Ok(x) => x, +- Err(x) => x, +- } +- } +- +- /// Stores a value into the [`bool`] if the current value is the same as the `current` value. +- /// +- /// The return value is a result indicating whether the new value was written and containing +- /// the previous value. On success this value is guaranteed to be equal to `current`. +- /// +- /// `compare_exchange` takes two [`Ordering`] arguments to describe the memory +- /// ordering of this operation. The first describes the required ordering if the +- /// operation succeeds while the second describes the required ordering when the +- /// operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and must +- /// be equivalent or weaker than the success ordering. +- /// +- /// [`bool`]: ../../../std/primitive.bool.html +- /// [`Ordering`]: enum.Ordering.html +- /// [`Release`]: enum.Ordering.html#variant.Release +- /// [`AcqRel`]: enum.Ordering.html#variant.Release +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let some_bool = AtomicBool::new(true); +- /// +- /// assert_eq!(some_bool.compare_exchange(true, +- /// false, +- /// Ordering::Acquire, +- /// Ordering::Relaxed), +- /// Ok(true)); +- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); +- /// +- /// assert_eq!(some_bool.compare_exchange(true, true, +- /// Ordering::SeqCst, +- /// Ordering::Acquire), +- /// Err(false)); +- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); +- /// ``` +- #[inline] +- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn compare_exchange(&self, +- current: bool, +- new: bool, +- success: Ordering, +- failure: Ordering) +- -> Result { +- match unsafe { +- atomic_compare_exchange(self.v.get(), current as u8, new as u8, success, failure) +- } { +- Ok(x) => Ok(x != 0), +- Err(x) => Err(x != 0), +- } +- } +- +- /// Stores a value into the [`bool`] if the current value is the same as the `current` value. +- /// +- /// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the +- /// comparison succeeds, which can result in more efficient code on some platforms. The +- /// return value is a result indicating whether the new value was written and containing the +- /// previous value. +- /// +- /// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory +- /// ordering of this operation. The first describes the required ordering if the operation +- /// succeeds while the second describes the required ordering when the operation fails. The +- /// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or +- /// weaker than the success ordering. +- /// +- /// [`bool`]: ../../../std/primitive.bool.html +- /// [`compare_exchange`]: #method.compare_exchange +- /// [`Ordering`]: enum.Ordering.html +- /// [`Release`]: enum.Ordering.html#variant.Release +- /// [`AcqRel`]: enum.Ordering.html#variant.Release +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let val = AtomicBool::new(false); +- /// +- /// let new = true; +- /// let mut old = val.load(Ordering::Relaxed); +- /// loop { +- /// match val.compare_exchange_weak(old, new, Ordering::SeqCst, Ordering::Relaxed) { +- /// Ok(_) => break, +- /// Err(x) => old = x, +- /// } +- /// } +- /// ``` +- #[inline] +- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] +- pub fn compare_exchange_weak(&self, +- current: bool, +- new: bool, +- success: Ordering, +- failure: Ordering) +- -> Result { +- match unsafe { +- atomic_compare_exchange_weak(self.v.get(), current as u8, new as u8, success, failure) +- } { +- Ok(x) => Ok(x != 0), +- Err(x) => Err(x != 0), +- } +- } +- +- /// Logical "and" with a boolean value. +- /// +- /// Performs a logical "and" operation on the current value and the argument `val`, and sets +- /// the new value to the result. +- /// +- /// Returns the previous value. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_and(false, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst), false); +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_and(true, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst), true); +- /// +- /// let foo = AtomicBool::new(false); +- /// assert_eq!(foo.fetch_and(false, Ordering::SeqCst), false); +- /// assert_eq!(foo.load(Ordering::SeqCst), false); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn fetch_and(&self, val: bool, order: Ordering) -> bool { +- unsafe { atomic_and(self.v.get(), val as u8, order) != 0 } +- } +- +- /// Logical "nand" with a boolean value. +- /// +- /// Performs a logical "nand" operation on the current value and the argument `val`, and sets +- /// the new value to the result. +- /// +- /// Returns the previous value. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_nand(false, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst), true); +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_nand(true, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst) as usize, 0); +- /// assert_eq!(foo.load(Ordering::SeqCst), false); +- /// +- /// let foo = AtomicBool::new(false); +- /// assert_eq!(foo.fetch_nand(false, Ordering::SeqCst), false); +- /// assert_eq!(foo.load(Ordering::SeqCst), true); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn fetch_nand(&self, val: bool, order: Ordering) -> bool { +- // We can't use atomic_nand here because it can result in a bool with +- // an invalid value. This happens because the atomic operation is done +- // with an 8-bit integer internally, which would set the upper 7 bits. +- // So we just use fetch_xor or swap instead. +- if val { +- // !(x & true) == !x +- // We must invert the bool. +- self.fetch_xor(true, order) +- } else { +- // !(x & false) == true +- // We must set the bool to true. +- self.swap(true, order) +- } +- } +- +- /// Logical "or" with a boolean value. +- /// +- /// Performs a logical "or" operation on the current value and the argument `val`, and sets the +- /// new value to the result. +- /// +- /// Returns the previous value. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst), true); +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst), true); +- /// +- /// let foo = AtomicBool::new(false); +- /// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), false); +- /// assert_eq!(foo.load(Ordering::SeqCst), false); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn fetch_or(&self, val: bool, order: Ordering) -> bool { +- unsafe { atomic_or(self.v.get(), val as u8, order) != 0 } +- } +- +- /// Logical "xor" with a boolean value. +- /// +- /// Performs a logical "xor" operation on the current value and the argument `val`, and sets +- /// the new value to the result. +- /// +- /// Returns the previous value. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicBool, Ordering}; +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_xor(false, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst), true); +- /// +- /// let foo = AtomicBool::new(true); +- /// assert_eq!(foo.fetch_xor(true, Ordering::SeqCst), true); +- /// assert_eq!(foo.load(Ordering::SeqCst), false); +- /// +- /// let foo = AtomicBool::new(false); +- /// assert_eq!(foo.fetch_xor(false, Ordering::SeqCst), false); +- /// assert_eq!(foo.load(Ordering::SeqCst), false); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool { +- unsafe { atomic_xor(self.v.get(), val as u8, order) != 0 } +- } +-} +- +-#[cfg(target_has_atomic = "ptr")] +-impl AtomicPtr { +- /// Creates a new `AtomicPtr`. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::AtomicPtr; +- /// +- /// let ptr = &mut 5; +- /// let atomic_ptr = AtomicPtr::new(ptr); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- pub const fn new(p: *mut T) -> AtomicPtr { +- AtomicPtr { p: UnsafeCell::new(p) } +- } +- +- /// Returns a mutable reference to the underlying pointer. +- /// +- /// This is safe because the mutable reference guarantees that no other threads are +- /// concurrently accessing the atomic data. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicPtr, Ordering}; +- /// +- /// let mut atomic_ptr = AtomicPtr::new(&mut 10); +- /// *atomic_ptr.get_mut() = &mut 5; +- /// assert_eq!(unsafe { *atomic_ptr.load(Ordering::SeqCst) }, 5); +- /// ``` +- #[inline] +- #[stable(feature = "atomic_access", since = "1.15.0")] +- pub fn get_mut(&mut self) -> &mut *mut T { +- unsafe { &mut *self.p.get() } +- } +- +- /// Consumes the atomic and returns the contained value. +- /// +- /// This is safe because passing `self` by value guarantees that no other threads are +- /// concurrently accessing the atomic data. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::AtomicPtr; +- /// +- /// let atomic_ptr = AtomicPtr::new(&mut 5); +- /// assert_eq!(unsafe { *atomic_ptr.into_inner() }, 5); +- /// ``` +- #[inline] +- #[stable(feature = "atomic_access", since = "1.15.0")] +- pub fn into_inner(self) -> *mut T { +- self.p.into_inner() +- } +- +- /// Loads a value from the pointer. +- /// +- /// `load` takes an [`Ordering`] argument which describes the memory ordering +- /// of this operation. +- /// +- /// # Panics +- /// +- /// Panics if `order` is [`Release`] or [`AcqRel`]. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// [`Release`]: enum.Ordering.html#variant.Release +- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicPtr, Ordering}; +- /// +- /// let ptr = &mut 5; +- /// let some_ptr = AtomicPtr::new(ptr); +- /// +- /// let value = some_ptr.load(Ordering::Relaxed); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn load(&self, order: Ordering) -> *mut T { +- unsafe { atomic_load(self.p.get() as *mut usize, order) as *mut T } +- } +- +- /// Stores a value into the pointer. +- /// +- /// `store` takes an [`Ordering`] argument which describes the memory ordering +- /// of this operation. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicPtr, Ordering}; +- /// +- /// let ptr = &mut 5; +- /// let some_ptr = AtomicPtr::new(ptr); +- /// +- /// let other_ptr = &mut 10; +- /// +- /// some_ptr.store(other_ptr, Ordering::Relaxed); +- /// ``` +- /// +- /// # Panics +- /// +- /// Panics if `order` is [`Acquire`] or [`AcqRel`]. +- /// +- /// [`Acquire`]: enum.Ordering.html#variant.Acquire +- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- pub fn store(&self, ptr: *mut T, order: Ordering) { +- unsafe { +- atomic_store(self.p.get() as *mut usize, ptr as usize, order); +- } +- } +- +- /// Stores a value into the pointer, returning the previous value. +- /// +- /// `swap` takes an [`Ordering`] argument which describes the memory ordering +- /// of this operation. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicPtr, Ordering}; +- /// +- /// let ptr = &mut 5; +- /// let some_ptr = AtomicPtr::new(ptr); +- /// +- /// let other_ptr = &mut 10; +- /// +- /// let value = some_ptr.swap(other_ptr, Ordering::Relaxed); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T { +- unsafe { atomic_swap(self.p.get() as *mut usize, ptr as usize, order) as *mut T } +- } +- +- /// Stores a value into the pointer if the current value is the same as the `current` value. +- /// +- /// The return value is always the previous value. If it is equal to `current`, then the value +- /// was updated. +- /// +- /// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory +- /// ordering of this operation. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicPtr, Ordering}; +- /// +- /// let ptr = &mut 5; +- /// let some_ptr = AtomicPtr::new(ptr); +- /// +- /// let other_ptr = &mut 10; +- /// let another_ptr = &mut 10; +- /// +- /// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed); +- /// ``` +- #[inline] +- #[stable(feature = "rust1", since = "1.0.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn compare_and_swap(&self, current: *mut T, new: *mut T, order: Ordering) -> *mut T { +- match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) { +- Ok(x) => x, +- Err(x) => x, +- } +- } +- +- /// Stores a value into the pointer if the current value is the same as the `current` value. +- /// +- /// The return value is a result indicating whether the new value was written and containing +- /// the previous value. On success this value is guaranteed to be equal to `current`. +- /// +- /// `compare_exchange` takes two [`Ordering`] arguments to describe the memory +- /// ordering of this operation. The first describes the required ordering if +- /// the operation succeeds while the second describes the required ordering when +- /// the operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] +- /// and must be equivalent or weaker than the success ordering. +- /// +- /// [`Ordering`]: enum.Ordering.html +- /// [`Release`]: enum.Ordering.html#variant.Release +- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicPtr, Ordering}; +- /// +- /// let ptr = &mut 5; +- /// let some_ptr = AtomicPtr::new(ptr); +- /// +- /// let other_ptr = &mut 10; +- /// let another_ptr = &mut 10; +- /// +- /// let value = some_ptr.compare_exchange(other_ptr, another_ptr, +- /// Ordering::SeqCst, Ordering::Relaxed); +- /// ``` +- #[inline] +- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn compare_exchange(&self, +- current: *mut T, +- new: *mut T, +- success: Ordering, +- failure: Ordering) +- -> Result<*mut T, *mut T> { +- unsafe { +- let res = atomic_compare_exchange(self.p.get() as *mut usize, +- current as usize, +- new as usize, +- success, +- failure); +- match res { +- Ok(x) => Ok(x as *mut T), +- Err(x) => Err(x as *mut T), +- } +- } +- } +- +- /// Stores a value into the pointer if the current value is the same as the `current` value. +- /// +- /// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the +- /// comparison succeeds, which can result in more efficient code on some platforms. The +- /// return value is a result indicating whether the new value was written and containing the +- /// previous value. +- /// +- /// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory +- /// ordering of this operation. The first describes the required ordering if the operation +- /// succeeds while the second describes the required ordering when the operation fails. The +- /// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or +- /// weaker than the success ordering. +- /// +- /// [`compare_exchange`]: #method.compare_exchange +- /// [`Ordering`]: enum.Ordering.html +- /// [`Release`]: enum.Ordering.html#variant.Release +- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::sync::atomic::{AtomicPtr, Ordering}; +- /// +- /// let some_ptr = AtomicPtr::new(&mut 5); +- /// +- /// let new = &mut 10; +- /// let mut old = some_ptr.load(Ordering::Relaxed); +- /// loop { +- /// match some_ptr.compare_exchange_weak(old, new, Ordering::SeqCst, Ordering::Relaxed) { +- /// Ok(_) => break, +- /// Err(x) => old = x, +- /// } +- /// } +- /// ``` +- #[inline] +- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] +- pub fn compare_exchange_weak(&self, +- current: *mut T, +- new: *mut T, +- success: Ordering, +- failure: Ordering) +- -> Result<*mut T, *mut T> { +- unsafe { +- let res = atomic_compare_exchange_weak(self.p.get() as *mut usize, +- current as usize, +- new as usize, +- success, +- failure); +- match res { +- Ok(x) => Ok(x as *mut T), +- Err(x) => Err(x as *mut T), +- } +- } +- } +-} +- +-#[cfg(target_has_atomic = "8")] +-#[stable(feature = "atomic_bool_from", since = "1.24.0")] +-impl From for AtomicBool { +- #[inline] +- fn from(b: bool) -> Self { Self::new(b) } +-} +- +-#[cfg(target_has_atomic = "ptr")] +-#[stable(feature = "atomic_from", since = "1.23.0")] +-impl From<*mut T> for AtomicPtr { +- #[inline] +- fn from(p: *mut T) -> Self { Self::new(p) } +-} +- +-#[cfg(target_has_atomic = "ptr")] +-macro_rules! atomic_int { +- ($stable:meta, +- $stable_cxchg:meta, +- $stable_debug:meta, +- $stable_access:meta, +- $stable_from:meta, +- $stable_nand:meta, +- $s_int_type:expr, $int_ref:expr, +- $extra_feature:expr, +- $min_fn:ident, $max_fn:ident, +- $int_type:ident $atomic_type:ident $atomic_init:ident) => { +- /// An integer type which can be safely shared between threads. +- /// +- /// This type has the same in-memory representation as the underlying +- /// integer type, [` +- #[doc = $s_int_type] +- /// `]( +- #[doc = $int_ref] +- /// ). For more about the differences between atomic types and +- /// non-atomic types, please see the [module-level documentation]. +- /// +- /// [module-level documentation]: index.html +- #[$stable] +- #[repr(transparent)] +- pub struct $atomic_type { +- v: UnsafeCell<$int_type>, +- } +- +- /// An atomic integer initialized to `0`. +- #[$stable] +- pub const $atomic_init: $atomic_type = $atomic_type::new(0); +- +- #[$stable] +- impl Default for $atomic_type { +- fn default() -> Self { +- Self::new(Default::default()) +- } +- } +- +- #[$stable_from] +- impl From<$int_type> for $atomic_type { +- #[inline] +- fn from(v: $int_type) -> Self { Self::new(v) } +- } +- +- #[$stable_debug] +- impl fmt::Debug for $atomic_type { +- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +- fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) +- } +- } +- +- // Send is implicitly implemented. +- #[$stable] +- unsafe impl Sync for $atomic_type {} +- +- impl $atomic_type { +- doc_comment! { +- concat!("Creates a new atomic integer. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::", stringify!($atomic_type), "; +- +-let atomic_forty_two = ", stringify!($atomic_type), "::new(42); +-```"), +- #[inline] +- #[$stable] +- pub const fn new(v: $int_type) -> Self { +- $atomic_type {v: UnsafeCell::new(v)} +- } +- } +- +- doc_comment! { +- concat!("Returns a mutable reference to the underlying integer. +- +-This is safe because the mutable reference guarantees that no other threads are +-concurrently accessing the atomic data. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let mut some_var = ", stringify!($atomic_type), "::new(10); +-assert_eq!(*some_var.get_mut(), 10); +-*some_var.get_mut() = 5; +-assert_eq!(some_var.load(Ordering::SeqCst), 5); +-```"), +- #[inline] +- #[$stable_access] +- pub fn get_mut(&mut self) -> &mut $int_type { +- unsafe { &mut *self.v.get() } +- } +- } +- +- doc_comment! { +- concat!("Consumes the atomic and returns the contained value. +- +-This is safe because passing `self` by value guarantees that no other threads are +-concurrently accessing the atomic data. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::", stringify!($atomic_type), "; +- +-let some_var = ", stringify!($atomic_type), "::new(5); +-assert_eq!(some_var.into_inner(), 5); +-```"), +- #[inline] +- #[$stable_access] +- pub fn into_inner(self) -> $int_type { +- self.v.into_inner() +- } +- } +- +- doc_comment! { +- concat!("Loads a value from the atomic integer. +- +-`load` takes an [`Ordering`] argument which describes the memory ordering of this operation. +- +-# Panics +- +-Panics if `order` is [`Release`] or [`AcqRel`]. +- +-[`Ordering`]: enum.Ordering.html +-[`Release`]: enum.Ordering.html#variant.Release +-[`AcqRel`]: enum.Ordering.html#variant.AcqRel +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let some_var = ", stringify!($atomic_type), "::new(5); +- +-assert_eq!(some_var.load(Ordering::Relaxed), 5); +-```"), +- #[inline] +- #[$stable] +- pub fn load(&self, order: Ordering) -> $int_type { +- unsafe { atomic_load(self.v.get(), order) } +- } +- } +- +- doc_comment! { +- concat!("Stores a value into the atomic integer. +- +-`store` takes an [`Ordering`] argument which describes the memory ordering of this operation. +- +-[`Ordering`]: enum.Ordering.html +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let some_var = ", stringify!($atomic_type), "::new(5); +- +-some_var.store(10, Ordering::Relaxed); +-assert_eq!(some_var.load(Ordering::Relaxed), 10); +-``` +- +-# Panics +- +-Panics if `order` is [`Acquire`] or [`AcqRel`]. +- +-[`Acquire`]: enum.Ordering.html#variant.Acquire +-[`AcqRel`]: enum.Ordering.html#variant.AcqRel"), +- #[inline] +- #[$stable] +- pub fn store(&self, val: $int_type, order: Ordering) { +- unsafe { atomic_store(self.v.get(), val, order); } +- } +- } +- +- doc_comment! { +- concat!("Stores a value into the atomic integer, returning the previous value. +- +-`swap` takes an [`Ordering`] argument which describes the memory ordering of this operation. +- +-[`Ordering`]: enum.Ordering.html +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let some_var = ", stringify!($atomic_type), "::new(5); +- +-assert_eq!(some_var.swap(10, Ordering::Relaxed), 5); +-```"), +- #[inline] +- #[$stable] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn swap(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { atomic_swap(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Stores a value into the atomic integer if the current value is the same as +-the `current` value. +- +-The return value is always the previous value. If it is equal to `current`, then the +-value was updated. +- +-`compare_and_swap` also takes an [`Ordering`] argument which describes the memory +-ordering of this operation. +- +-[`Ordering`]: enum.Ordering.html +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let some_var = ", stringify!($atomic_type), "::new(5); +- +-assert_eq!(some_var.compare_and_swap(5, 10, Ordering::Relaxed), 5); +-assert_eq!(some_var.load(Ordering::Relaxed), 10); +- +-assert_eq!(some_var.compare_and_swap(6, 12, Ordering::Relaxed), 10); +-assert_eq!(some_var.load(Ordering::Relaxed), 10); +-```"), +- #[inline] +- #[$stable] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn compare_and_swap(&self, +- current: $int_type, +- new: $int_type, +- order: Ordering) -> $int_type { +- match self.compare_exchange(current, +- new, +- order, +- strongest_failure_ordering(order)) { +- Ok(x) => x, +- Err(x) => x, +- } +- } +- } +- +- doc_comment! { +- concat!("Stores a value into the atomic integer if the current value is the same as +-the `current` value. +- +-The return value is a result indicating whether the new value was written and +-containing the previous value. On success this value is guaranteed to be equal to +-`current`. +- +-`compare_exchange` takes two [`Ordering`] arguments to describe the memory +-ordering of this operation. The first describes the required ordering if +-the operation succeeds while the second describes the required ordering when +-the operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and +-must be equivalent or weaker than the success ordering. +- +-[`Ordering`]: enum.Ordering.html +-[`Release`]: enum.Ordering.html#variant.Release +-[`AcqRel`]: enum.Ordering.html#variant.AcqRel +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let some_var = ", stringify!($atomic_type), "::new(5); +- +-assert_eq!(some_var.compare_exchange(5, 10, +- Ordering::Acquire, +- Ordering::Relaxed), +- Ok(5)); +-assert_eq!(some_var.load(Ordering::Relaxed), 10); +- +-assert_eq!(some_var.compare_exchange(6, 12, +- Ordering::SeqCst, +- Ordering::Acquire), +- Err(10)); +-assert_eq!(some_var.load(Ordering::Relaxed), 10); +-```"), +- #[inline] +- #[$stable_cxchg] +- #[cfg(any(stage0, target_has_atomic = "cas"))] +- pub fn compare_exchange(&self, +- current: $int_type, +- new: $int_type, +- success: Ordering, +- failure: Ordering) -> Result<$int_type, $int_type> { +- unsafe { atomic_compare_exchange(self.v.get(), current, new, success, failure) } +- } +- } +- +- doc_comment! { +- concat!("Stores a value into the atomic integer if the current value is the same as +-the `current` value. +- +-Unlike [`compare_exchange`], this function is allowed to spuriously fail even +-when the comparison succeeds, which can result in more efficient code on some +-platforms. The return value is a result indicating whether the new value was +-written and containing the previous value. +- +-`compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory +-ordering of this operation. The first describes the required ordering if the +-operation succeeds while the second describes the required ordering when the +-operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and +-must be equivalent or weaker than the success ordering. +- +-[`compare_exchange`]: #method.compare_exchange +-[`Ordering`]: enum.Ordering.html +-[`Release`]: enum.Ordering.html#variant.Release +-[`AcqRel`]: enum.Ordering.html#variant.AcqRel +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let val = ", stringify!($atomic_type), "::new(4); +- +-let mut old = val.load(Ordering::Relaxed); +-loop { +- let new = old * 2; +- match val.compare_exchange_weak(old, new, Ordering::SeqCst, Ordering::Relaxed) { +- Ok(_) => break, +- Err(x) => old = x, +- } +-} +-```"), +- #[inline] +- #[$stable_cxchg] +- pub fn compare_exchange_weak(&self, +- current: $int_type, +- new: $int_type, +- success: Ordering, +- failure: Ordering) -> Result<$int_type, $int_type> { +- unsafe { +- atomic_compare_exchange_weak(self.v.get(), current, new, success, failure) +- } +- } +- } +- +- doc_comment! { +- concat!("Adds to the current value, returning the previous value. +- +-This operation wraps around on overflow. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(0); +-assert_eq!(foo.fetch_add(10, Ordering::SeqCst), 0); +-assert_eq!(foo.load(Ordering::SeqCst), 10); +-```"), +- #[inline] +- #[$stable] +- pub fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { atomic_add(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Subtracts from the current value, returning the previous value. +- +-This operation wraps around on overflow. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(20); +-assert_eq!(foo.fetch_sub(10, Ordering::SeqCst), 20); +-assert_eq!(foo.load(Ordering::SeqCst), 10); +-```"), +- #[inline] +- #[$stable] +- pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { atomic_sub(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Bitwise \"and\" with the current value. +- +-Performs a bitwise \"and\" operation on the current value and the argument `val`, and +-sets the new value to the result. +- +-Returns the previous value. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(0b101101); +-assert_eq!(foo.fetch_and(0b110011, Ordering::SeqCst), 0b101101); +-assert_eq!(foo.load(Ordering::SeqCst), 0b100001); +-```"), +- #[inline] +- #[$stable] +- pub fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { atomic_and(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Bitwise \"nand\" with the current value. +- +-Performs a bitwise \"nand\" operation on the current value and the argument `val`, and +-sets the new value to the result. +- +-Returns the previous value. +- +-# Examples +- +-``` +-", $extra_feature, " +-use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(0x13); +-assert_eq!(foo.fetch_nand(0x31, Ordering::SeqCst), 0x13); +-assert_eq!(foo.load(Ordering::SeqCst), !(0x13 & 0x31)); +-```"), +- #[inline] +- #[$stable_nand] +- pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { atomic_nand(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Bitwise \"or\" with the current value. +- +-Performs a bitwise \"or\" operation on the current value and the argument `val`, and +-sets the new value to the result. +- +-Returns the previous value. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(0b101101); +-assert_eq!(foo.fetch_or(0b110011, Ordering::SeqCst), 0b101101); +-assert_eq!(foo.load(Ordering::SeqCst), 0b111111); +-```"), +- #[inline] +- #[$stable] +- pub fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { atomic_or(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Bitwise \"xor\" with the current value. +- +-Performs a bitwise \"xor\" operation on the current value and the argument `val`, and +-sets the new value to the result. +- +-Returns the previous value. +- +-# Examples +- +-``` +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(0b101101); +-assert_eq!(foo.fetch_xor(0b110011, Ordering::SeqCst), 0b101101); +-assert_eq!(foo.load(Ordering::SeqCst), 0b011110); +-```"), +- #[inline] +- #[$stable] +- pub fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { atomic_xor(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Fetches the value, and applies a function to it that returns an optional +-new value. Returns a `Result` of `Ok(previous_value)` if the function returned `Some(_)`, else +-`Err(previous_value)`. +- +-Note: This may call the function multiple times if the value has been changed from other threads in +-the meantime, as long as the function returns `Some(_)`, but the function will have been applied +-but once to the stored value. +- +-# Examples +- +-```rust +-#![feature(no_more_cas)] +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let x = ", stringify!($atomic_type), "::new(7); +-assert_eq!(x.fetch_update(|_| None, Ordering::SeqCst, Ordering::SeqCst), Err(7)); +-assert_eq!(x.fetch_update(|x| Some(x + 1), Ordering::SeqCst, Ordering::SeqCst), Ok(7)); +-assert_eq!(x.fetch_update(|x| Some(x + 1), Ordering::SeqCst, Ordering::SeqCst), Ok(8)); +-assert_eq!(x.load(Ordering::SeqCst), 9); +-```"), +- #[inline] +- #[unstable(feature = "no_more_cas", +- reason = "no more CAS loops in user code", +- issue = "48655")] +- pub fn fetch_update(&self, +- mut f: F, +- fetch_order: Ordering, +- set_order: Ordering) -> Result<$int_type, $int_type> +- where F: FnMut($int_type) -> Option<$int_type> { +- let mut prev = self.load(fetch_order); +- while let Some(next) = f(prev) { +- match self.compare_exchange_weak(prev, next, set_order, fetch_order) { +- x @ Ok(_) => return x, +- Err(next_prev) => prev = next_prev +- } +- } +- Err(prev) +- } +- } +- +- doc_comment! { +- concat!("Maximum with the current value. +- +-Finds the maximum of the current value and the argument `val`, and +-sets the new value to the result. +- +-Returns the previous value. +- +-# Examples +- +-``` +-#![feature(atomic_min_max)] +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(23); +-assert_eq!(foo.fetch_max(42, Ordering::SeqCst), 23); +-assert_eq!(foo.load(Ordering::SeqCst), 42); +-``` +- +-If you want to obtain the maximum value in one step, you can use the following: +- +-``` +-#![feature(atomic_min_max)] +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(23); +-let bar = 42; +-let max_foo = foo.fetch_max(bar, Ordering::SeqCst).max(bar); +-assert!(max_foo == 42); +-```"), +- #[inline] +- #[unstable(feature = "atomic_min_max", +- reason = "easier and faster min/max than writing manual CAS loop", +- issue = "48655")] +- pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { $max_fn(self.v.get(), val, order) } +- } +- } +- +- doc_comment! { +- concat!("Minimum with the current value. +- +-Finds the minimum of the current value and the argument `val`, and +-sets the new value to the result. +- +-Returns the previous value. +- +-# Examples +- +-``` +-#![feature(atomic_min_max)] +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(23); +-assert_eq!(foo.fetch_min(42, Ordering::Relaxed), 23); +-assert_eq!(foo.load(Ordering::Relaxed), 23); +-assert_eq!(foo.fetch_min(22, Ordering::Relaxed), 23); +-assert_eq!(foo.load(Ordering::Relaxed), 22); +-``` +- +-If you want to obtain the minimum value in one step, you can use the following: +- +-``` +-#![feature(atomic_min_max)] +-", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; +- +-let foo = ", stringify!($atomic_type), "::new(23); +-let bar = 12; +-let min_foo = foo.fetch_min(bar, Ordering::SeqCst).min(bar); +-assert_eq!(min_foo, 12); +-```"), +- #[inline] +- #[unstable(feature = "atomic_min_max", +- reason = "easier and faster min/max than writing manual CAS loop", +- issue = "48655")] +- pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type { +- unsafe { $min_fn(self.v.get(), val, order) } +- } +- } +- +- } +- } +-} +- +-#[cfg(target_has_atomic = "8")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "i8", "../../../std/primitive.i8.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_min, atomic_max, +- i8 AtomicI8 ATOMIC_I8_INIT +-} +-#[cfg(target_has_atomic = "8")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "u8", "../../../std/primitive.u8.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_umin, atomic_umax, +- u8 AtomicU8 ATOMIC_U8_INIT +-} +-#[cfg(target_has_atomic = "16")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "i16", "../../../std/primitive.i16.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_min, atomic_max, +- i16 AtomicI16 ATOMIC_I16_INIT +-} +-#[cfg(target_has_atomic = "16")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "u16", "../../../std/primitive.u16.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_umin, atomic_umax, +- u16 AtomicU16 ATOMIC_U16_INIT +-} +-#[cfg(target_has_atomic = "32")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "i32", "../../../std/primitive.i32.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_min, atomic_max, +- i32 AtomicI32 ATOMIC_I32_INIT +-} +-#[cfg(target_has_atomic = "32")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "u32", "../../../std/primitive.u32.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_umin, atomic_umax, +- u32 AtomicU32 ATOMIC_U32_INIT +-} +-#[cfg(target_has_atomic = "64")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "i64", "../../../std/primitive.i64.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_min, atomic_max, +- i64 AtomicI64 ATOMIC_I64_INIT +-} +-#[cfg(target_has_atomic = "64")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "u64", "../../../std/primitive.u64.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_umin, atomic_umax, +- u64 AtomicU64 ATOMIC_U64_INIT +-} +-#[cfg(target_has_atomic = "ptr")] +-atomic_int!{ +- stable(feature = "rust1", since = "1.0.0"), +- stable(feature = "extended_compare_and_swap", since = "1.10.0"), +- stable(feature = "atomic_debug", since = "1.3.0"), +- stable(feature = "atomic_access", since = "1.15.0"), +- stable(feature = "atomic_from", since = "1.23.0"), +- stable(feature = "atomic_nand", since = "1.27.0"), +- "isize", "../../../std/primitive.isize.html", +- "", +- atomic_min, atomic_max, +- isize AtomicIsize ATOMIC_ISIZE_INIT +-} +-#[cfg(target_has_atomic = "ptr")] +-atomic_int!{ +- stable(feature = "rust1", since = "1.0.0"), +- stable(feature = "extended_compare_and_swap", since = "1.10.0"), +- stable(feature = "atomic_debug", since = "1.3.0"), +- stable(feature = "atomic_access", since = "1.15.0"), +- stable(feature = "atomic_from", since = "1.23.0"), +- stable(feature = "atomic_nand", since = "1.27.0"), +- "usize", "../../../std/primitive.usize.html", +- "", +- atomic_umin, atomic_umax, +- usize AtomicUsize ATOMIC_USIZE_INIT +-} +- +-#[inline] +-#[cfg(any(stage0, target_has_atomic = "cas"))] +-fn strongest_failure_ordering(order: Ordering) -> Ordering { +- match order { +- Release => Relaxed, +- Relaxed => Relaxed, +- SeqCst => SeqCst, +- Acquire => Acquire, +- AcqRel => Acquire, +- __Nonexhaustive => __Nonexhaustive, +- } +-} +- +-#[inline] +-unsafe fn atomic_store(dst: *mut T, val: T, order: Ordering) { +- match order { +- Release => intrinsics::atomic_store_rel(dst, val), +- Relaxed => intrinsics::atomic_store_relaxed(dst, val), +- SeqCst => intrinsics::atomic_store(dst, val), +- Acquire => panic!("there is no such thing as an acquire store"), +- AcqRel => panic!("there is no such thing as an acquire/release store"), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-#[inline] +-unsafe fn atomic_load(dst: *const T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_load_acq(dst), +- Relaxed => intrinsics::atomic_load_relaxed(dst), +- SeqCst => intrinsics::atomic_load(dst), +- Release => panic!("there is no such thing as a release load"), +- AcqRel => panic!("there is no such thing as an acquire/release load"), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-#[inline] +-#[cfg(any(stage0, target_has_atomic = "cas"))] +-unsafe fn atomic_swap(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_xchg_acq(dst, val), +- Release => intrinsics::atomic_xchg_rel(dst, val), +- AcqRel => intrinsics::atomic_xchg_acqrel(dst, val), +- Relaxed => intrinsics::atomic_xchg_relaxed(dst, val), +- SeqCst => intrinsics::atomic_xchg(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-/// Returns the previous value (like __sync_fetch_and_add). +-#[inline] +-unsafe fn atomic_add(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_xadd_acq(dst, val), +- Release => intrinsics::atomic_xadd_rel(dst, val), +- AcqRel => intrinsics::atomic_xadd_acqrel(dst, val), +- Relaxed => intrinsics::atomic_xadd_relaxed(dst, val), +- SeqCst => intrinsics::atomic_xadd(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-/// Returns the previous value (like __sync_fetch_and_sub). +-#[inline] +-unsafe fn atomic_sub(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_xsub_acq(dst, val), +- Release => intrinsics::atomic_xsub_rel(dst, val), +- AcqRel => intrinsics::atomic_xsub_acqrel(dst, val), +- Relaxed => intrinsics::atomic_xsub_relaxed(dst, val), +- SeqCst => intrinsics::atomic_xsub(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-#[inline] +-#[cfg(any(stage0, target_has_atomic = "cas"))] +-unsafe fn atomic_compare_exchange(dst: *mut T, +- old: T, +- new: T, +- success: Ordering, +- failure: Ordering) +- -> Result { +- let (val, ok) = match (success, failure) { +- (Acquire, Acquire) => intrinsics::atomic_cxchg_acq(dst, old, new), +- (Release, Relaxed) => intrinsics::atomic_cxchg_rel(dst, old, new), +- (AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel(dst, old, new), +- (Relaxed, Relaxed) => intrinsics::atomic_cxchg_relaxed(dst, old, new), +- (SeqCst, SeqCst) => intrinsics::atomic_cxchg(dst, old, new), +- (Acquire, Relaxed) => intrinsics::atomic_cxchg_acq_failrelaxed(dst, old, new), +- (AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_failrelaxed(dst, old, new), +- (SeqCst, Relaxed) => intrinsics::atomic_cxchg_failrelaxed(dst, old, new), +- (SeqCst, Acquire) => intrinsics::atomic_cxchg_failacq(dst, old, new), +- (__Nonexhaustive, _) => panic!("invalid memory ordering"), +- (_, __Nonexhaustive) => panic!("invalid memory ordering"), +- (_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"), +- (_, Release) => panic!("there is no such thing as a release failure ordering"), +- _ => panic!("a failure ordering can't be stronger than a success ordering"), +- }; +- if ok { Ok(val) } else { Err(val) } +-} +- +-#[inline] +-unsafe fn atomic_compare_exchange_weak(dst: *mut T, +- old: T, +- new: T, +- success: Ordering, +- failure: Ordering) +- -> Result { +- let (val, ok) = match (success, failure) { +- (Acquire, Acquire) => intrinsics::atomic_cxchgweak_acq(dst, old, new), +- (Release, Relaxed) => intrinsics::atomic_cxchgweak_rel(dst, old, new), +- (AcqRel, Acquire) => intrinsics::atomic_cxchgweak_acqrel(dst, old, new), +- (Relaxed, Relaxed) => intrinsics::atomic_cxchgweak_relaxed(dst, old, new), +- (SeqCst, SeqCst) => intrinsics::atomic_cxchgweak(dst, old, new), +- (Acquire, Relaxed) => intrinsics::atomic_cxchgweak_acq_failrelaxed(dst, old, new), +- (AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_failrelaxed(dst, old, new), +- (SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_failrelaxed(dst, old, new), +- (SeqCst, Acquire) => intrinsics::atomic_cxchgweak_failacq(dst, old, new), +- (__Nonexhaustive, _) => panic!("invalid memory ordering"), +- (_, __Nonexhaustive) => panic!("invalid memory ordering"), +- (_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"), +- (_, Release) => panic!("there is no such thing as a release failure ordering"), +- _ => panic!("a failure ordering can't be stronger than a success ordering"), +- }; +- if ok { Ok(val) } else { Err(val) } +-} +- +-#[inline] +-unsafe fn atomic_and(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_and_acq(dst, val), +- Release => intrinsics::atomic_and_rel(dst, val), +- AcqRel => intrinsics::atomic_and_acqrel(dst, val), +- Relaxed => intrinsics::atomic_and_relaxed(dst, val), +- SeqCst => intrinsics::atomic_and(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-#[inline] +-unsafe fn atomic_nand(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_nand_acq(dst, val), +- Release => intrinsics::atomic_nand_rel(dst, val), +- AcqRel => intrinsics::atomic_nand_acqrel(dst, val), +- Relaxed => intrinsics::atomic_nand_relaxed(dst, val), +- SeqCst => intrinsics::atomic_nand(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-#[inline] +-unsafe fn atomic_or(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_or_acq(dst, val), +- Release => intrinsics::atomic_or_rel(dst, val), +- AcqRel => intrinsics::atomic_or_acqrel(dst, val), +- Relaxed => intrinsics::atomic_or_relaxed(dst, val), +- SeqCst => intrinsics::atomic_or(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-#[inline] +-unsafe fn atomic_xor(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_xor_acq(dst, val), +- Release => intrinsics::atomic_xor_rel(dst, val), +- AcqRel => intrinsics::atomic_xor_acqrel(dst, val), +- Relaxed => intrinsics::atomic_xor_relaxed(dst, val), +- SeqCst => intrinsics::atomic_xor(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-/// returns the max value (signed comparison) +-#[inline] +-unsafe fn atomic_max(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_max_acq(dst, val), +- Release => intrinsics::atomic_max_rel(dst, val), +- AcqRel => intrinsics::atomic_max_acqrel(dst, val), +- Relaxed => intrinsics::atomic_max_relaxed(dst, val), +- SeqCst => intrinsics::atomic_max(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-/// returns the min value (signed comparison) +-#[inline] +-unsafe fn atomic_min(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_min_acq(dst, val), +- Release => intrinsics::atomic_min_rel(dst, val), +- AcqRel => intrinsics::atomic_min_acqrel(dst, val), +- Relaxed => intrinsics::atomic_min_relaxed(dst, val), +- SeqCst => intrinsics::atomic_min(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-/// returns the max value (signed comparison) +-#[inline] +-unsafe fn atomic_umax(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_umax_acq(dst, val), +- Release => intrinsics::atomic_umax_rel(dst, val), +- AcqRel => intrinsics::atomic_umax_acqrel(dst, val), +- Relaxed => intrinsics::atomic_umax_relaxed(dst, val), +- SeqCst => intrinsics::atomic_umax(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-/// returns the min value (signed comparison) +-#[inline] +-unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { +- match order { +- Acquire => intrinsics::atomic_umin_acq(dst, val), +- Release => intrinsics::atomic_umin_rel(dst, val), +- AcqRel => intrinsics::atomic_umin_acqrel(dst, val), +- Relaxed => intrinsics::atomic_umin_relaxed(dst, val), +- SeqCst => intrinsics::atomic_umin(dst, val), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +-} +- +-/// An atomic fence. +-/// +-/// Depending on the specified order, a fence prevents the compiler and CPU from +-/// reordering certain types of memory operations around it. +-/// That creates synchronizes-with relationships between it and atomic operations +-/// or fences in other threads. +-/// +-/// A fence 'A' which has (at least) [`Release`] ordering semantics, synchronizes +-/// with a fence 'B' with (at least) [`Acquire`] semantics, if and only if there +-/// exist operations X and Y, both operating on some atomic object 'M' such +-/// that A is sequenced before X, Y is synchronized before B and Y observes +-/// the change to M. This provides a happens-before dependence between A and B. +-/// +-/// ```text +-/// Thread 1 Thread 2 +-/// +-/// fence(Release); A -------------- +-/// x.store(3, Relaxed); X --------- | +-/// | | +-/// | | +-/// -------------> Y if x.load(Relaxed) == 3 { +-/// |-------> B fence(Acquire); +-/// ... +-/// } +-/// ``` +-/// +-/// Atomic operations with [`Release`] or [`Acquire`] semantics can also synchronize +-/// with a fence. +-/// +-/// A fence which has [`SeqCst`] ordering, in addition to having both [`Acquire`] +-/// and [`Release`] semantics, participates in the global program order of the +-/// other [`SeqCst`] operations and/or fences. +-/// +-/// Accepts [`Acquire`], [`Release`], [`AcqRel`] and [`SeqCst`] orderings. +-/// +-/// # Panics +-/// +-/// Panics if `order` is [`Relaxed`]. +-/// +-/// # Examples +-/// +-/// ``` +-/// use std::sync::atomic::AtomicBool; +-/// use std::sync::atomic::fence; +-/// use std::sync::atomic::Ordering; +-/// +-/// // A mutual exclusion primitive based on spinlock. +-/// pub struct Mutex { +-/// flag: AtomicBool, +-/// } +-/// +-/// impl Mutex { +-/// pub fn new() -> Mutex { +-/// Mutex { +-/// flag: AtomicBool::new(false), +-/// } +-/// } +-/// +-/// pub fn lock(&self) { +-/// while !self.flag.compare_and_swap(false, true, Ordering::Relaxed) {} +-/// // This fence synchronizes-with store in `unlock`. +-/// fence(Ordering::Acquire); +-/// } +-/// +-/// pub fn unlock(&self) { +-/// self.flag.store(false, Ordering::Release); +-/// } +-/// } +-/// ``` +-/// +-/// [`Ordering`]: enum.Ordering.html +-/// [`Acquire`]: enum.Ordering.html#variant.Acquire +-/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst +-/// [`Release`]: enum.Ordering.html#variant.Release +-/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +-/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed +-#[inline] +-#[stable(feature = "rust1", since = "1.0.0")] +-pub fn fence(order: Ordering) { +- unsafe { +- match order { +- Acquire => intrinsics::atomic_fence_acq(), +- Release => intrinsics::atomic_fence_rel(), +- AcqRel => intrinsics::atomic_fence_acqrel(), +- SeqCst => intrinsics::atomic_fence(), +- Relaxed => panic!("there is no such thing as a relaxed fence"), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +- } +-} +- +- +-/// A compiler memory fence. +-/// +-/// `compiler_fence` does not emit any machine code, but restricts the kinds +-/// of memory re-ordering the compiler is allowed to do. Specifically, depending on +-/// the given [`Ordering`] semantics, the compiler may be disallowed from moving reads +-/// or writes from before or after the call to the other side of the call to +-/// `compiler_fence`. Note that it does **not** prevent the *hardware* +-/// from doing such re-ordering. This is not a problem in a single-threaded, +-/// execution context, but when other threads may modify memory at the same +-/// time, stronger synchronization primitives such as [`fence`] are required. +-/// +-/// The re-ordering prevented by the different ordering semantics are: +-/// +-/// - with [`SeqCst`], no re-ordering of reads and writes across this point is allowed. +-/// - with [`Release`], preceding reads and writes cannot be moved past subsequent writes. +-/// - with [`Acquire`], subsequent reads and writes cannot be moved ahead of preceding reads. +-/// - with [`AcqRel`], both of the above rules are enforced. +-/// +-/// `compiler_fence` is generally only useful for preventing a thread from +-/// racing *with itself*. That is, if a given thread is executing one piece +-/// of code, and is then interrupted, and starts executing code elsewhere +-/// (while still in the same thread, and conceptually still on the same +-/// core). In traditional programs, this can only occur when a signal +-/// handler is registered. In more low-level code, such situations can also +-/// arise when handling interrupts, when implementing green threads with +-/// pre-emption, etc. Curious readers are encouraged to read the Linux kernel's +-/// discussion of [memory barriers]. +-/// +-/// # Panics +-/// +-/// Panics if `order` is [`Relaxed`]. +-/// +-/// # Examples +-/// +-/// Without `compiler_fence`, the `assert_eq!` in following code +-/// is *not* guaranteed to succeed, despite everything happening in a single thread. +-/// To see why, remember that the compiler is free to swap the stores to +-/// `IMPORTANT_VARIABLE` and `IS_READ` since they are both +-/// `Ordering::Relaxed`. If it does, and the signal handler is invoked right +-/// after `IS_READY` is updated, then the signal handler will see +-/// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`. +-/// Using a `compiler_fence` remedies this situation. +-/// +-/// ``` +-/// use std::sync::atomic::{AtomicBool, AtomicUsize}; +-/// use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT}; +-/// use std::sync::atomic::Ordering; +-/// use std::sync::atomic::compiler_fence; +-/// +-/// static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT; +-/// static IS_READY: AtomicBool = ATOMIC_BOOL_INIT; +-/// +-/// fn main() { +-/// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed); +-/// // prevent earlier writes from being moved beyond this point +-/// compiler_fence(Ordering::Release); +-/// IS_READY.store(true, Ordering::Relaxed); +-/// } +-/// +-/// fn signal_handler() { +-/// if IS_READY.load(Ordering::Relaxed) { +-/// assert_eq!(IMPORTANT_VARIABLE.load(Ordering::Relaxed), 42); +-/// } +-/// } +-/// ``` +-/// +-/// [`fence`]: fn.fence.html +-/// [`Ordering`]: enum.Ordering.html +-/// [`Acquire`]: enum.Ordering.html#variant.Acquire +-/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst +-/// [`Release`]: enum.Ordering.html#variant.Release +-/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel +-/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed +-/// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt +-#[inline] +-#[stable(feature = "compiler_fences", since = "1.21.0")] +-pub fn compiler_fence(order: Ordering) { +- unsafe { +- match order { +- Acquire => intrinsics::atomic_singlethreadfence_acq(), +- Release => intrinsics::atomic_singlethreadfence_rel(), +- AcqRel => intrinsics::atomic_singlethreadfence_acqrel(), +- SeqCst => intrinsics::atomic_singlethreadfence(), +- Relaxed => panic!("there is no such thing as a relaxed compiler fence"), +- __Nonexhaustive => panic!("invalid memory ordering"), +- } +- } +-} +- +- +-#[cfg(target_has_atomic = "8")] +-#[stable(feature = "atomic_debug", since = "1.3.0")] +-impl fmt::Debug for AtomicBool { +- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +- fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) +- } +-} +- +-#[cfg(target_has_atomic = "ptr")] +-#[stable(feature = "atomic_debug", since = "1.3.0")] +-impl fmt::Debug for AtomicPtr { +- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +- fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) +- } +-} +- +-#[cfg(target_has_atomic = "ptr")] +-#[stable(feature = "atomic_pointer", since = "1.24.0")] +-impl fmt::Pointer for AtomicPtr { +- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +- fmt::Pointer::fmt(&self.load(Ordering::SeqCst), f) +- } +-} +diff --git a/src/libcore/sync/mod.rs b/src/libcore/sync/mod.rs +deleted file mode 100644 +index 0080e0b5e4..0000000000 +--- a/src/libcore/sync/mod.rs ++++ /dev/null +@@ -1,15 +0,0 @@ +-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +-// file at the top-level directory of this distribution and at +-// http://rust-lang.org/COPYRIGHT. +-// +-// Licensed under the Apache License, Version 2.0 or the MIT license +-// , at your +-// option. This file may not be copied, modified, or distributed +-// except according to those terms. +- +-//! Synchronization primitives +- +-#![stable(feature = "rust1", since = "1.0.0")] +- +-pub mod atomic; +-- +2.11.0 + From ebaa122d34b37c5335fd683b86c380395e9d201c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Jul 2018 19:27:20 +0200 Subject: [PATCH 0069/1566] Fix non-closure rust-call functions and fix a field projection bug --- example.rs | 20 +++++++++++++- mini_core.rs | 4 +-- src/abi.rs | 73 ++++++++++++++++++++++++++++++++++++++++----------- src/common.rs | 57 ++++++++++++++++++++-------------------- 4 files changed, 108 insertions(+), 46 deletions(-) diff --git a/example.rs b/example.rs index 35e124c5d2d60..37161b873801c 100644 --- a/example.rs +++ b/example.rs @@ -1,4 +1,4 @@ -#![feature(no_core)] +#![feature(no_core, unboxed_closures)] #![no_core] #![allow(dead_code)] @@ -122,6 +122,24 @@ fn call_closure_2arg() { })(0u8, 42u16) } +struct IsNotEmpty; + +impl<'a, 'b> FnOnce<(&'a &'b [u16], )> for IsNotEmpty { + type Output = bool; + + #[inline] + extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16], )) -> bool { + self.call_mut(arg) + } +} + +impl<'a, 'b> FnMut<(&'a &'b [u16], )> for IsNotEmpty { + #[inline] + extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16], )) -> bool { + true + } +} + fn eq_char(a: char, b: char) -> bool { a == b } diff --git a/mini_core.rs b/mini_core.rs index 3829c0f588a93..115746d61c9e1 100644 --- a/mini_core.rs +++ b/mini_core.rs @@ -88,7 +88,7 @@ impl PartialEq for *const T { #[lang = "fn_once"] #[rustc_paren_sugar] -trait FnOnce { +pub trait FnOnce { type Output; extern "rust-call" fn call_once(self, args: Args) -> Self::Output; @@ -96,7 +96,7 @@ trait FnOnce { #[lang = "fn_mut"] #[rustc_paren_sugar] -trait FnMut : FnOnce { +pub trait FnMut : FnOnce { extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; } diff --git a/src/abi.rs b/src/abi.rs index 251d9603aa6af..6bef83a5bb735 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -26,7 +26,6 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< ) } Abi::System => bug!("system abi should be selected elsewhere"), - // TODO: properly implement intrinsics Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), _ => unimplemented!("unsupported abi {:?}", sig.abi), }; @@ -122,27 +121,70 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb offset: None, }); // Dummy stack slot for debugging + enum ArgKind { + Normal(Value), + Spread(Vec), + } + let func_params = fx.mir.args_iter().map(|local| { - let layout = fx.layout_of(fx.mir.local_decls[local].ty); + let arg_ty = fx.mir.local_decls[local].ty; + + // Adapted from https://github.com/rust-lang/rust/blob/145155dc96757002c7b2e9de8489416e2fdbbd57/src/librustc_codegen_llvm/mir/mod.rs#L442-L482 + if Some(local) == fx.mir.spread_arg { + // This argument (e.g. the last argument in the "rust-call" ABI) + // is a tuple that was spread at the ABI level and now we have + // to reconstruct it into a tuple local variable, from multiple + // individual function arguments. + + let tupled_arg_tys = match arg_ty.sty { + ty::TyTuple(ref tys) => tys, + _ => bug!("spread argument isn't a tuple?!") + }; + + let mut ebb_params = Vec::new(); + for arg_ty in tupled_arg_tys.iter() { + let cton_type = fx.cton_type(arg_ty).unwrap_or(types::I64); + ebb_params.push(fx.bcx.append_ebb_param(start_ebb, cton_type)); + } + + (local, ArgKind::Spread(ebb_params), arg_ty) + } else { + let cton_type = fx.cton_type(arg_ty).unwrap_or(types::I64); + (local, ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, cton_type)), arg_ty) + } + }).collect::>(); + + let ret_layout = fx.layout_of(fx.return_type()); + fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); + + for (local, arg_kind, ty) in func_params { + let layout = fx.layout_of(ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, offset: None, }); - let ty = fx.mir.local_decls[local].ty; - let cton_type = fx.cton_type(ty).unwrap_or(types::I64); - (local, fx.bcx.append_ebb_param(start_ebb, cton_type), ty, stack_slot) - }).collect::>(); - - let ret_layout = fx.layout_of(fx.return_type()); - fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); - for (local, ebb_param, ty, stack_slot) in func_params { let place = CPlace::from_stack_slot(fx, stack_slot, ty); - if fx.cton_type(ty).is_some() { - place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())); - } else { - place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())); + + match arg_kind { + ArgKind::Normal(ebb_param) => { + if fx.cton_type(ty).is_some() { + place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())); + } else { + place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())); + } + } + ArgKind::Spread(ebb_params) => { + for (i, ebb_param) in ebb_params.into_iter().enumerate() { + let sub_place = place.place_field(fx, mir::Field::new(i)); + if fx.cton_type(sub_place.layout().ty).is_some() { + sub_place.write_cvalue(fx, CValue::ByVal(ebb_param, sub_place.layout())); + } else { + sub_place.write_cvalue(fx, CValue::ByRef(ebb_param, sub_place.layout())); + } + } + } } fx.local_map.insert(local, place); } @@ -191,6 +233,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( }, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), } + println!("{:?} {:?}", pack_arg.layout().ty, args.iter().map(|a|a.layout().ty).collect::>()); args } else { args @@ -209,7 +252,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let usize_layout = fx.layout_of(fx.tcx.types.usize); let ret = return_place.unwrap(); match intrinsic { - "copy" => { + "copy" | "copy_nonoverlapping" => { /*let elem_ty = substs.type_at(0); assert_eq!(args.len(), 3); let src = args[0]; diff --git a/src/common.rs b/src/common.rs index 74cc4943f56ee..84f7c0fd83de3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,6 +1,6 @@ use std::fmt; -use syntax::ast::{IntTy, UintTy}; +use syntax::ast::{IntTy, UintTy, FloatTy}; use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::{Module, FuncId, DataId}; @@ -46,6 +46,12 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx> } } TypeVariants::TyChar => types::I32, + TypeVariants::TyFloat(size) => { + match size { + FloatTy::F32 => types::I32, + FloatTy::F64 => types::I64, + } + } TypeVariants::TyFnPtr(_) => types::I64, TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) | TypeVariants::TyRef(_, ty, _) => { if ty.is_sized(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { @@ -59,6 +65,22 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx> }) } +fn codegen_field<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + base: Value, + layout: TyLayout<'tcx>, + field: mir::Field +) -> (Value, TyLayout<'tcx>) { + let field_offset = layout.fields.offset(field.index()); + let field_ty = layout.field(&*fx, field.index()); + if field_offset.bytes() > 0 { + let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); + (fx.bcx.ins().iadd(base, field_offset), field_ty) + } else { + (base, field_ty) + } +} + /// A read-only value #[derive(Debug, Copy, Clone)] pub enum CValue<'tcx> { @@ -117,29 +139,13 @@ impl<'tcx> CValue<'tcx> { } pub fn value_field<'a>(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CValue<'tcx> where 'tcx: 'a { - use rustc::ty::util::IntTypeExt; - let (base, layout) = match self { CValue::ByRef(addr, layout) => (addr, layout), _ => bug!("place_field for {:?}", self), }; - let field_offset = layout.fields.offset(field.index()); - let field_layout = if field.index() == 0 { - fx.layout_of(if let ty::TyAdt(adt_def, _) = layout.ty.sty { - adt_def.repr.discr_type().to_ty(fx.tcx) - } else { - // This can only be `0`, for now, so `u8` will suffice. - fx.tcx.types.u8 - }) - } else { - layout.field(&*fx, field.index()) - }; - if field_offset.bytes() > 0 { - let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); - CValue::ByRef(fx.bcx.ins().iadd(base, field_offset), field_layout) - } else { - CValue::ByRef(base, field_layout) - } + + let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + CValue::ByRef(field_ptr, field_layout) } pub fn const_val<'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue<'tcx> where 'tcx: 'a { @@ -252,14 +258,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn place_field(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CPlace<'tcx> { let base = self.expect_addr(); let layout = self.layout(); - let field_offset = layout.fields.offset(field.index()); - let field_ty = layout.field(&*fx, field.index()); - if field_offset.bytes() > 0 { - let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); - CPlace::Addr(fx.bcx.ins().iadd(base, field_offset), field_ty) - } else { - CPlace::Addr(base, field_ty) - } + + let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + CPlace::Addr(field_ptr, field_layout) } pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { From dc4f2341150e4c8356a8e81ad9e0a6908d10c5df Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 29 Jul 2018 17:09:17 +0200 Subject: [PATCH 0070/1566] Implement float binops --- Readme.md | 1 - src/base.rs | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 320ea0fa67f65..7c1efe263f69c 100644 --- a/Readme.md +++ b/Readme.md @@ -41,7 +41,6 @@ $ ./build.sh * Unsized types * Slice indexing * Sub slice -* Closures * Some rvalue's * Inline assembly diff --git a/src/base.rs b/src/base.rs index e58a8af828530..6c060be973bbe 100644 --- a/src/base.rs +++ b/src/base.rs @@ -252,6 +252,9 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & TypeVariants::TyInt(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true, false) } + TypeVariants::TyFloat(_) => { + trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) + } TypeVariants::TyChar => { trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } @@ -413,6 +416,10 @@ macro_rules! binop_match { let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); $fx.bcx.ins().bint(types::I8, b) }}; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, fcmp($cc:ident)) => {{ + let b = $fx.bcx.ins().fcmp(FloatCC::$cc, $lhs, $rhs); + $fx.bcx.ins().bint(types::I8, b) + }}; (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $name:ident) => { $fx.bcx.ins().$name($lhs, $rhs) }; @@ -430,7 +437,7 @@ macro_rules! binop_match { } } -pub fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, false, lhs, rhs, "bool"; Add (_) bug; @@ -492,7 +499,34 @@ pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinO CValue::ByVal(res, fx.layout_of(ty)) } -pub fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_float_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { + let res = binop_match! { + fx, bin_op, false, lhs, rhs, "bool"; + Add (_) fadd; + Sub (_) fsub; + Mul (_) fmul; + Div (_) fdiv; + Rem (_) bug; + BitXor (_) bxor; + BitAnd (_) band; + BitOr (_) bor; + Shl (_) bug; + Shr (_) bug; + + Eq (_) fcmp(Equal); + Lt (_) fcmp(LessThan); + Le (_) fcmp(LessThanOrEqual); + Ne (_) fcmp(NotEqual); + Ge (_) fcmp(GreaterThanOrEqual); + Gt (_) fcmp(GreaterThan); + + Offset (_) bug; + }; + + CValue::ByVal(res, fx.layout_of(ty)) +} + +fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, false, lhs, rhs, "char"; Add (_) bug; From 812fd6dacaf070859e7adf96a0371ba8b01f6953 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 29 Jul 2018 17:22:40 +0200 Subject: [PATCH 0071/1566] Implement some intrinsics --- example.rs | 4 ++++ mini_core.rs | 1 + src/abi.rs | 29 +++++++++++++++++++++++++++++ src/base.rs | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/example.rs b/example.rs index 37161b873801c..1f9a5e0755b46 100644 --- a/example.rs +++ b/example.rs @@ -147,3 +147,7 @@ fn eq_char(a: char, b: char) -> bool { unsafe fn transmute(c: char) -> u32 { intrinsics::transmute(c) } + +unsafe fn call_uninit() -> u8 { + intrinsics::uninit() +} diff --git a/mini_core.rs b/mini_core.rs index 115746d61c9e1..9ecfd5113fffa 100644 --- a/mini_core.rs +++ b/mini_core.rs @@ -118,5 +118,6 @@ pub mod intrinsics { pub fn size_of() -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; + pub fn uninit() -> T; } } diff --git a/src/abi.rs b/src/abi.rs index 6bef83a5bb735..cc22ef0608072 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -252,6 +252,9 @@ pub fn codegen_call<'a, 'tcx: 'a>( let usize_layout = fx.layout_of(fx.tcx.types.usize); let ret = return_place.unwrap(); match intrinsic { + "abort" => { + fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + } "copy" | "copy_nonoverlapping" => { /*let elem_ty = substs.type_at(0); assert_eq!(args.len(), 3); @@ -266,6 +269,18 @@ pub fn codegen_call<'a, 'tcx: 'a>( let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); ret.write_cvalue(fx, size_of); } + "type_id" => { + assert_eq!(args.len(), 0); + let type_id = fx.tcx.type_id_hash(substs.type_at(0)); + let type_id = CValue::const_val(fx, usize_layout.ty, type_id as i64); + ret.write_cvalue(fx, type_id); + } + "min_align_of" => { + assert_eq!(args.len(), 0); + let min_align = fx.layout_of(substs.type_at(0)).align.abi(); + let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); + ret.write_cvalue(fx, min_align); + } _ if intrinsic.starts_with("unchecked_") => { assert_eq!(args.len(), 2); let lhs = args[0].load_value(fx); @@ -304,6 +319,20 @@ pub fn codegen_call<'a, 'tcx: 'a>( let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) } + "uninit" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_val = uninit_place.to_cvalue(fx); + ret.write_cvalue(fx, uninit_val); + } _ => fx.tcx.sess.fatal(&format!("unsupported intrinsic {}", intrinsic)), } if let Some((_, dest)) = *destination { diff --git a/src/base.rs b/src/base.rs index 6c060be973bbe..e65abd0ddd7b6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -501,7 +501,7 @@ pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinO fn trans_float_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, false, lhs, rhs, "bool"; + fx, bin_op, false, lhs, rhs, "float"; Add (_) fadd; Sub (_) fsub; Mul (_) fmul; From 9b06ec8f1d78264a69ee89c90958c492fea509ff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 14:36:32 +0200 Subject: [PATCH 0072/1566] Implement intrinsic discriminant_value and fix bug in discriminant reading --- src/abi.rs | 6 +++ src/base.rs | 123 +++++++++++++++++++++++++++------------------------- 2 files changed, 69 insertions(+), 60 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index cc22ef0608072..6e1c81e7bf1b9 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -263,6 +263,12 @@ pub fn codegen_call<'a, 'tcx: 'a>( let count = args[2];*/ unimplemented!("copy"); } + "discriminant_value" => { + assert_eq!(args.len(), 1); + let discr = ::base::trans_get_discriminant(fx, args[0], ret.layout()); + ret.write_cvalue(fx, discr); + unimplemented!("discriminant"); + } "size_of" => { assert_eq!(args.len(), 0); let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); diff --git a/src/base.rs b/src/base.rs index e65abd0ddd7b6..641cead4f3268 100644 --- a/src/base.rs +++ b/src/base.rs @@ -11,7 +11,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } => { let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}", def_id, String::from_utf8_lossy(&mir.into_inner()))); + tcx.sess.warn(&format!("{:?}:\n\n{}", inst, String::from_utf8_lossy(&mir.into_inner()))); let fn_ty = inst.ty(tcx); let fn_ty = tcx.subst_and_normalize_erasing_regions( @@ -334,65 +334,9 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty), Rvalue::Cast(CastKind::Unsize, operand, ty) => return Err(format!("rval unsize {:?} {:?}", operand, ty)), Rvalue::Discriminant(place) => { - let place = trans_place(fx, place); - let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); - let layout = lval.layout(); - - if layout.abi == layout::Abi::Uninhabited { - fx.bcx.ins().trap(TrapCode::User(!0)); - } - match layout.variants { - layout::Variants::Single { index } => { - let discr_val = layout.ty.ty_adt_def().map_or( - index as u128, - |def| def.discriminant_for_variant(fx.tcx, index).val); - let val = CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); - lval.write_cvalue(fx, val); - return Ok(()); - } - layout::Variants::Tagged { .. } | - layout::Variants::NicheFilling { .. } => {}, - } - - let discr = place.to_cvalue(fx).value_field(fx, mir::Field::new(0)); - let discr_ty = discr.layout().ty; - let lldiscr = discr.load_value(fx); - match layout.variants { - layout::Variants::Single { .. } => bug!(), - layout::Variants::Tagged { ref tag, .. } => { - let signed = match tag.value { - layout::Int(_, signed) => signed, - _ => false - }; - let val = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, signed); - lval.write_cvalue(fx, CValue::ByVal(val, dest_layout)); - } - layout::Variants::NicheFilling { - dataful_variant, - ref niche_variants, - niche_start, - .. - } => { - let niche_llty = fx.cton_type(discr_ty).unwrap(); - if niche_variants.start() == niche_variants.end() { - let b = fx.bcx.ins().icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); - let if_true = fx.bcx.ins().iconst(dest_cton_ty, *niche_variants.start() as u64 as i64); - let if_false = fx.bcx.ins().iconst(dest_cton_ty, dataful_variant as u64 as i64); - let val = fx.bcx.ins().select(b, if_true, if_false); - lval.write_cvalue(fx, CValue::ByVal(val, dest_layout)); - } else { - // Rebase from niche values to discriminant values. - let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); - let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); - let lldiscr = fx.bcx.ins().isub(lldiscr, delta); - let b = fx.bcx.ins().icmp_imm(IntCC::UnsignedLessThanOrEqual, lldiscr, *niche_variants.end() as u64 as i64); - let if_true = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, false); - let if_false = fx.bcx.ins().iconst(niche_llty, dataful_variant as u64 as i64); - let val = fx.bcx.ins().select(b, if_true, if_false); - lval.write_cvalue(fx, CValue::ByVal(val, dest_layout)); - } - } - } + let place = trans_place(fx, place).to_cvalue(fx); + let discr = trans_get_discriminant(fx, place, dest_layout); + lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => unimplemented!("rval repeat {:?} {:?}", operand, times), Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), @@ -408,6 +352,65 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & Ok(()) } +pub fn trans_get_discriminant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, value: CValue<'tcx>, dest_layout: TyLayout<'tcx>) -> CValue<'tcx> { + let layout = value.layout(); + + if layout.abi == layout::Abi::Uninhabited { + fx.bcx.ins().trap(TrapCode::User(!0)); + } + match layout.variants { + layout::Variants::Single { index } => { + let discr_val = layout.ty.ty_adt_def().map_or( + index as u128, + |def| def.discriminant_for_variant(fx.tcx, index).val); + return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); + } + layout::Variants::Tagged { .. } | + layout::Variants::NicheFilling { .. } => {}, + } + + let discr = value.value_field(fx, mir::Field::new(0)); + let discr_ty = discr.layout().ty; + let lldiscr = discr.load_value(fx); + match layout.variants { + layout::Variants::Single { .. } => bug!(), + layout::Variants::Tagged { ref tag, .. } => { + let signed = match tag.value { + layout::Int(_, signed) => signed, + _ => false + }; + let val = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, signed); + return CValue::ByVal(val, dest_layout); + } + layout::Variants::NicheFilling { + dataful_variant, + ref niche_variants, + niche_start, + .. + } => { + let niche_llty = fx.cton_type(discr_ty).unwrap(); + if niche_variants.start() == niche_variants.end() { + let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); + let b = fx.bcx.ins().icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); + let if_true = fx.bcx.ins().iconst(dest_cton_ty, *niche_variants.start() as u64 as i64); + let if_false = fx.bcx.ins().iconst(dest_cton_ty, dataful_variant as u64 as i64); + let val = fx.bcx.ins().select(b, if_true, if_false); + return CValue::ByVal(val, dest_layout); + } else { + // Rebase from niche values to discriminant values. + let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); + let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); + let lldiscr = fx.bcx.ins().isub(lldiscr, delta); + let b = fx.bcx.ins().icmp_imm(IntCC::UnsignedLessThanOrEqual, lldiscr, *niche_variants.end() as u64 as i64); + let if_true = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, false); + let if_false = fx.bcx.ins().iconst(niche_llty, dataful_variant as u64 as i64); + let val = fx.bcx.ins().select(b, if_true, if_false); + return CValue::ByVal(val, dest_layout); + } + } + } +} + macro_rules! binop_match { (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, bug) => { bug!("bin op {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) From 75a45965bb2181ba97c9a3f786f36580f4986b90 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 15:34:34 +0200 Subject: [PATCH 0073/1566] Add support for binop rem on floats --- src/abi.rs | 35 +++++++++++++++++--- src/base.rs | 89 ++++++++++++++++++++++++++++++--------------------- src/common.rs | 1 - src/lib.rs | 1 + 4 files changed, 83 insertions(+), 43 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 6e1c81e7bf1b9..ead77acb376ea 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -104,6 +104,34 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { module.declare_func_in_func(func_id, &mut self.bcx.func) } + pub fn lib_call( + &mut self, + name: &str, + input_tys: Vec, + output_ty: types::Type, + args: &[Value], + ) -> Value { + let sig = Signature { + params: input_tys.iter().cloned().map(AbiParam::new).collect(), + returns: vec![AbiParam::new(output_ty)], + call_conv: CallConv::SystemV, + argument_bytes: None, + }; + let func_id = self.module.declare_function(&name, Linkage::Import, &sig).unwrap(); + let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func); + let call_inst = self.bcx.ins().call(func_ref, args); + let results = self.bcx.inst_results(call_inst); + assert_eq!(results.len(), 1); + results[0] + } + + pub fn easy_call(&mut self, name: &str, args: &[CValue<'tcx>], return_ty: Ty<'tcx>) -> CValue<'tcx> { + let (input_tys, args): (Vec<_>, Vec<_>) = args.into_iter().map(|arg| (self.cton_type(arg.layout().ty).unwrap(), arg.load_value(self))).unzip(); + let return_layout = self.layout_of(return_ty); + let return_ty = self.cton_type(return_ty).unwrap(); + CValue::ByVal(self.lib_call(name, input_tys, return_ty, &args), return_layout) + } + fn self_sig(&self) -> FnSig<'tcx> { ty_fn_sig(self.tcx, self.instance.ty(self.tcx)) } @@ -267,7 +295,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( assert_eq!(args.len(), 1); let discr = ::base::trans_get_discriminant(fx, args[0], ret.layout()); ret.write_cvalue(fx, discr); - unimplemented!("discriminant"); } "size_of" => { assert_eq!(args.len(), 0); @@ -289,8 +316,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( } _ if intrinsic.starts_with("unchecked_") => { assert_eq!(args.len(), 2); - let lhs = args[0].load_value(fx); - let rhs = args[1].load_value(fx); let bin_op = match intrinsic { "unchecked_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, @@ -300,10 +325,10 @@ pub fn codegen_call<'a, 'tcx: 'a>( }; let res = match ret.layout().ty.sty { TypeVariants::TyUint(_) => { - ::base::trans_int_binop(fx, bin_op, lhs, rhs, args[0].layout().ty, false, false) + ::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, false, false) } TypeVariants::TyInt(_) => { - ::base::trans_int_binop(fx, bin_op, lhs, rhs, args[0].layout().ty, true, false) + ::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, true, false) } _ => panic!(), }; diff --git a/src/base.rs b/src/base.rs index 641cead4f3268..104b948f14843 100644 --- a/src/base.rs +++ b/src/base.rs @@ -239,8 +239,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & } Rvalue::BinaryOp(bin_op, lhs, rhs) => { let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let lhs = trans_operand(fx, lhs).load_value(fx); - let rhs = trans_operand(fx, rhs).load_value(fx); + let lhs = trans_operand(fx, lhs); + let rhs = trans_operand(fx, rhs); let res = match ty.sty { TypeVariants::TyBool => { @@ -267,8 +267,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); - let lhs = trans_operand(fx, lhs).load_value(fx); - let rhs = trans_operand(fx, rhs).load_value(fx); + let lhs = trans_operand(fx, lhs); + let rhs = trans_operand(fx, rhs); let res = match ty.sty { TypeVariants::TyUint(_) => { @@ -412,37 +412,47 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, value } macro_rules! binop_match { - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, bug) => { + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, bug) => { bug!("bin op {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) }; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, icmp($cc:ident)) => {{ + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, icmp($cc:ident)) => {{ + assert_eq!($fx.tcx.types.bool, $ret_ty); + let ret_layout = $fx.layout_of($ret_ty); let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); - $fx.bcx.ins().bint(types::I8, b) + CValue::ByVal($fx.bcx.ins().bint(types::I8, b), ret_layout) }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, fcmp($cc:ident)) => {{ + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ + assert_eq!($fx.tcx.types.bool, $ret_ty); + let ret_layout = $fx.layout_of($ret_ty); let b = $fx.bcx.ins().fcmp(FloatCC::$cc, $lhs, $rhs); - $fx.bcx.ins().bint(types::I8, b) + CValue::ByVal($fx.bcx.ins().bint(types::I8, b), ret_layout) + }}; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, custom(|| $body:expr)) => {{ + $body + }}; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $name:ident) => {{ + let ret_layout = $fx.layout_of($ret_ty); + CValue::ByVal($fx.bcx.ins().$name($lhs, $rhs), ret_layout) }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $name:ident) => { - $fx.bcx.ins().$name($lhs, $rhs) - }; ( - $fx:expr, $bin_op:expr, $signed:expr, $lhs:expr, $rhs:expr, $bug_fmt:expr; + $fx:expr, $bin_op:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $bug_fmt:expr; $( - $var:ident ($sign:pat) $name:tt $( ( $next:tt ) )? ; + $var:ident ($sign:pat) $name:tt $( ( $($next:tt)* ) )? ; )* - ) => { + ) => {{ + let lhs = $lhs.load_value($fx); + let rhs = $rhs.load_value($fx); match ($bin_op, $signed) { $( - (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, $lhs, $rhs, $name $( ( $next ) )?), + (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, lhs, rhs, $ret_ty, $name $( ( $($next)* ) )?), )* } - } + }} } -fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, false, lhs, rhs, "bool"; + fx, bin_op, false, lhs, rhs, ty, "bool"; Add (_) bug; Sub (_) bug; Mul (_) bug; @@ -464,12 +474,12 @@ fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, Offset (_) bug; }; - CValue::ByVal(res, fx.layout_of(ty)) + res } -pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { +pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, signed, lhs, rhs, "int/uint"; + fx, bin_op, signed, lhs, rhs, ty, "int/uint"; Add (_) iadd; Sub (_) isub; Mul (_) imul; @@ -499,17 +509,25 @@ pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinO }; // TODO: return correct value for checked binops - CValue::ByVal(res, fx.layout_of(ty)) + res } -fn trans_float_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_float_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, false, lhs, rhs, "float"; + fx, bin_op, false, lhs, rhs, ty, "float"; Add (_) fadd; Sub (_) fsub; Mul (_) fmul; Div (_) fdiv; - Rem (_) bug; + Rem (_) custom(|| { + assert_eq!(lhs.layout().ty, ty); + assert_eq!(rhs.layout().ty, ty); + match ty.sty { + TypeVariants::TyFloat(FloatTy::F32) => fx.easy_call("fmodf", &[lhs, rhs], ty), + TypeVariants::TyFloat(FloatTy::F64) => fx.easy_call("fmod", &[lhs, rhs], ty), + _ => bug!(), + } + }); BitXor (_) bxor; BitAnd (_) band; BitOr (_) bor; @@ -526,12 +544,12 @@ fn trans_float_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, Offset (_) bug; }; - CValue::ByVal(res, fx.layout_of(ty)) + res } -fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, false, lhs, rhs, "char"; + fx, bin_op, false, lhs, rhs, ty, "char"; Add (_) bug; Sub (_) bug; Mul (_) bug; @@ -553,12 +571,12 @@ fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, Offset (_) bug; }; - CValue::ByVal(res, fx.layout_of(ty)) + res } -fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: Value, rhs: Value, ty: Ty<'tcx>, _checked: bool) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, false, lhs, rhs, "ptr"; +fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>, _checked: bool) -> CValue<'tcx> { + binop_match! { + fx, bin_op, false, lhs, rhs, ty, "ptr"; Add (_) bug; Sub (_) bug; Mul (_) bug; @@ -578,10 +596,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l Gt (_) icmp(UnsignedGreaterThan); Offset (_) iadd; - }; - - // TODO: return correct value for checked binops - CValue::ByVal(res, fx.layout_of(ty)) + } } pub fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { diff --git a/src/common.rs b/src/common.rs index 84f7c0fd83de3..ba84b2d64611a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,6 +1,5 @@ use std::fmt; -use syntax::ast::{IntTy, UintTy, FloatTy}; use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::{Module, FuncId, DataId}; diff --git a/src/lib.rs b/src/lib.rs index 53abaca552e3c..c26b7cd19473f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,6 +54,7 @@ mod prelude { pub use std::collections::{HashMap, HashSet}; pub use syntax::codemap::DUMMY_SP; + pub use syntax::ast::{IntTy, UintTy, FloatTy}; pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; pub use rustc::mir; pub use rustc::mir::*; From dc3ec6704638fdc544a32ae5a39ea248f1600c62 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 15:58:46 +0200 Subject: [PATCH 0074/1566] Implement intrinsics copy and copy_nonoverlapping --- src/abi.rs | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index ead77acb376ea..f2e6007e5f8d5 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -104,32 +104,46 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { module.declare_func_in_func(func_id, &mut self.bcx.func) } - pub fn lib_call( + fn lib_call( &mut self, name: &str, input_tys: Vec, - output_ty: types::Type, + output_ty: Option, args: &[Value], - ) -> Value { + ) -> Option { let sig = Signature { params: input_tys.iter().cloned().map(AbiParam::new).collect(), - returns: vec![AbiParam::new(output_ty)], + returns: vec![AbiParam::new(output_ty.unwrap_or(types::VOID))], call_conv: CallConv::SystemV, argument_bytes: None, }; let func_id = self.module.declare_function(&name, Linkage::Import, &sig).unwrap(); let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); + if output_ty.is_none() { + return None; + } let results = self.bcx.inst_results(call_inst); assert_eq!(results.len(), 1); - results[0] + Some(results[0]) } pub fn easy_call(&mut self, name: &str, args: &[CValue<'tcx>], return_ty: Ty<'tcx>) -> CValue<'tcx> { let (input_tys, args): (Vec<_>, Vec<_>) = args.into_iter().map(|arg| (self.cton_type(arg.layout().ty).unwrap(), arg.load_value(self))).unzip(); let return_layout = self.layout_of(return_ty); - let return_ty = self.cton_type(return_ty).unwrap(); - CValue::ByVal(self.lib_call(name, input_tys, return_ty, &args), return_layout) + let return_ty = if let TypeVariants::TyTuple(tup) = return_ty.sty { + if !tup.is_empty() { + bug!("easy_call( (...) -> ) is not allowed"); + } + None + } else { + Some(self.cton_type(return_ty).unwrap()) + }; + if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { + CValue::ByVal(val, return_layout) + } else { + CValue::ByRef(self.bcx.ins().iconst(types::I64, 0), return_layout) + } } fn self_sig(&self) -> FnSig<'tcx> { @@ -277,6 +291,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; + let nil_ty = fx.tcx.mk_nil(); let usize_layout = fx.layout_of(fx.tcx.types.usize); let ret = return_place.unwrap(); match intrinsic { @@ -284,11 +299,15 @@ pub fn codegen_call<'a, 'tcx: 'a>( fx.bcx.ins().trap(TrapCode::User(!0 - 1)); } "copy" | "copy_nonoverlapping" => { - /*let elem_ty = substs.type_at(0); + let elem_ty = substs.type_at(0); + let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); + let elem_size = fx.bcx.ins().iconst(types::I64, elem_size as i64); assert_eq!(args.len(), 3); let src = args[0]; let dst = args[1]; - let count = args[2];*/ + let count = args[2].load_value(fx); + let byte_amount = fx.bcx.ins().imul(count, elem_size); + fx.easy_call("memmove", &[dst, src, CValue::ByVal(byte_amount, usize_layout)], nil_ty); unimplemented!("copy"); } "discriminant_value" => { From 4901a66df16d2bd75444fb79e76b9bee167f7f83 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 16:02:26 +0200 Subject: [PATCH 0075/1566] Implement intrinsics assume and (un)likely --- src/abi.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/abi.rs b/src/abi.rs index f2e6007e5f8d5..70af157e47c34 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -298,6 +298,13 @@ pub fn codegen_call<'a, 'tcx: 'a>( "abort" => { fx.bcx.ins().trap(TrapCode::User(!0 - 1)); } + "assume" => { + assert_eq!(args.len(), 1); + } + "likely" | "unlikely" => { + assert_eq!(args.len(), 1); + ret.write_cvalue(fx, args[0]); + } "copy" | "copy_nonoverlapping" => { let elem_ty = substs.type_at(0); let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); From d86339bb5c2024d48cacf127d55fece303c14df3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 16:09:09 +0200 Subject: [PATCH 0076/1566] Simpler patch for "Remove atomics from libcore" --- 0003-Remove-atomics-from-libcore.patch | 2162 +----------------------- 1 file changed, 1 insertion(+), 2161 deletions(-) diff --git a/0003-Remove-atomics-from-libcore.patch b/0003-Remove-atomics-from-libcore.patch index f5e7449862c82..5e5eaf2a4a2ac 100644 --- a/0003-Remove-atomics-from-libcore.patch +++ b/0003-Remove-atomics-from-libcore.patch @@ -5,11 +5,7 @@ Subject: [PATCH] Remove atomics from libcore --- src/libcore/lib.rs | 1 - - src/libcore/sync/atomic.rs | 2128 -------------------------------------------- - src/libcore/sync/mod.rs | 15 - - 3 files changed, 2144 deletions(-) - delete mode 100644 src/libcore/sync/atomic.rs - delete mode 100644 src/libcore/sync/mod.rs + 1 files changed, 1 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 3aa79087db..71fcff2e8b 100644 @@ -23,2161 +19,5 @@ index 3aa79087db..71fcff2e8b 100644 pub mod cell; pub mod char; pub mod panic; -diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -deleted file mode 100644 -index 1e2b18bf9b..0000000000 ---- a/src/libcore/sync/atomic.rs -+++ /dev/null -@@ -1,2128 +0,0 @@ --// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT --// file at the top-level directory of this distribution and at --// http://rust-lang.org/COPYRIGHT. --// --// Licensed under the Apache License, Version 2.0 or the MIT license --// , at your --// option. This file may not be copied, modified, or distributed --// except according to those terms. -- --//! Atomic types --//! --//! Atomic types provide primitive shared-memory communication between --//! threads, and are the building blocks of other concurrent --//! types. --//! --//! This module defines atomic versions of a select number of primitive --//! types, including [`AtomicBool`], [`AtomicIsize`], and [`AtomicUsize`]. --//! Atomic types present operations that, when used correctly, synchronize --//! updates between threads. --//! --//! [`AtomicBool`]: struct.AtomicBool.html --//! [`AtomicIsize`]: struct.AtomicIsize.html --//! [`AtomicUsize`]: struct.AtomicUsize.html --//! --//! Each method takes an [`Ordering`] which represents the strength of --//! the memory barrier for that operation. These orderings are the --//! same as [LLVM atomic orderings][1]. For more information see the [nomicon][2]. --//! --//! [`Ordering`]: enum.Ordering.html --//! --//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations --//! [2]: ../../../nomicon/atomics.html --//! --//! Atomic variables are safe to share between threads (they implement [`Sync`]) --//! but they do not themselves provide the mechanism for sharing and follow the --//! [threading model](../../../std/thread/index.html#the-threading-model) of rust. --//! The most common way to share an atomic variable is to put it into an [`Arc`][arc] (an --//! atomically-reference-counted shared pointer). --//! --//! [`Sync`]: ../../marker/trait.Sync.html --//! [arc]: ../../../std/sync/struct.Arc.html --//! --//! Most atomic types may be stored in static variables, initialized using --//! the provided static initializers like [`ATOMIC_BOOL_INIT`]. Atomic statics --//! are often used for lazy global initialization. --//! --//! [`ATOMIC_BOOL_INIT`]: constant.ATOMIC_BOOL_INIT.html --//! --//! # Examples --//! --//! A simple spinlock: --//! --//! ``` --//! use std::sync::Arc; --//! use std::sync::atomic::{AtomicUsize, Ordering}; --//! use std::thread; --//! --//! fn main() { --//! let spinlock = Arc::new(AtomicUsize::new(1)); --//! --//! let spinlock_clone = spinlock.clone(); --//! let thread = thread::spawn(move|| { --//! spinlock_clone.store(0, Ordering::SeqCst); --//! }); --//! --//! // Wait for the other thread to release the lock --//! while spinlock.load(Ordering::SeqCst) != 0 {} --//! --//! if let Err(panic) = thread.join() { --//! println!("Thread had an error: {:?}", panic); --//! } --//! } --//! ``` --//! --//! Keep a global count of live threads: --//! --//! ``` --//! use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; --//! --//! static GLOBAL_THREAD_COUNT: AtomicUsize = ATOMIC_USIZE_INIT; --//! --//! let old_thread_count = GLOBAL_THREAD_COUNT.fetch_add(1, Ordering::SeqCst); --//! println!("live threads: {}", old_thread_count + 1); --//! ``` -- --#![stable(feature = "rust1", since = "1.0.0")] --#![cfg_attr(not(target_has_atomic = "8"), allow(dead_code))] --#![cfg_attr(not(target_has_atomic = "8"), allow(unused_imports))] -- --use self::Ordering::*; -- --use intrinsics; --use cell::UnsafeCell; --use fmt; -- --/// Save power or switch hyperthreads in a busy-wait spin-loop. --/// --/// This function is deliberately more primitive than --/// [`std::thread::yield_now`](../../../std/thread/fn.yield_now.html) and --/// does not directly yield to the system's scheduler. --/// In some cases it might be useful to use a combination of both functions. --/// Careful benchmarking is advised. --/// --/// On some platforms this function may not do anything at all. --#[inline] --#[stable(feature = "spin_loop_hint", since = "1.24.0")] --pub fn spin_loop_hint() { -- #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -- unsafe { -- asm!("pause" ::: "memory" : "volatile"); -- } -- -- #[cfg(target_arch = "aarch64")] -- unsafe { -- asm!("yield" ::: "memory" : "volatile"); -- } --} -- --/// A boolean type which can be safely shared between threads. --/// --/// This type has the same in-memory representation as a [`bool`]. --/// --/// [`bool`]: ../../../std/primitive.bool.html --#[cfg(target_has_atomic = "8")] --#[stable(feature = "rust1", since = "1.0.0")] --#[repr(transparent)] --pub struct AtomicBool { -- v: UnsafeCell, --} -- --#[cfg(target_has_atomic = "8")] --#[stable(feature = "rust1", since = "1.0.0")] --impl Default for AtomicBool { -- /// Creates an `AtomicBool` initialized to `false`. -- fn default() -> Self { -- Self::new(false) -- } --} -- --// Send is implicitly implemented for AtomicBool. --#[cfg(target_has_atomic = "8")] --#[stable(feature = "rust1", since = "1.0.0")] --unsafe impl Sync for AtomicBool {} -- --/// A raw pointer type which can be safely shared between threads. --/// --/// This type has the same in-memory representation as a `*mut T`. --#[cfg(target_has_atomic = "ptr")] --#[stable(feature = "rust1", since = "1.0.0")] --#[repr(transparent)] --pub struct AtomicPtr { -- p: UnsafeCell<*mut T>, --} -- --#[cfg(target_has_atomic = "ptr")] --#[stable(feature = "rust1", since = "1.0.0")] --impl Default for AtomicPtr { -- /// Creates a null `AtomicPtr`. -- fn default() -> AtomicPtr { -- AtomicPtr::new(::ptr::null_mut()) -- } --} -- --#[cfg(target_has_atomic = "ptr")] --#[stable(feature = "rust1", since = "1.0.0")] --unsafe impl Send for AtomicPtr {} --#[cfg(target_has_atomic = "ptr")] --#[stable(feature = "rust1", since = "1.0.0")] --unsafe impl Sync for AtomicPtr {} -- --/// Atomic memory orderings --/// --/// Memory orderings limit the ways that both the compiler and CPU may reorder --/// instructions around atomic operations. At its most restrictive, --/// "sequentially consistent" atomics allow neither reads nor writes --/// to be moved either before or after the atomic operation; on the other end --/// "relaxed" atomics allow all reorderings. --/// --/// Rust's memory orderings are [the same as --/// LLVM's](http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations). --/// --/// For more information see the [nomicon]. --/// --/// [nomicon]: ../../../nomicon/atomics.html --#[stable(feature = "rust1", since = "1.0.0")] --#[derive(Copy, Clone, Debug)] --pub enum Ordering { -- /// No ordering constraints, only atomic operations. -- /// -- /// Corresponds to LLVM's [`Monotonic`] ordering. -- /// -- /// [`Monotonic`]: http://llvm.org/docs/Atomics.html#monotonic -- #[stable(feature = "rust1", since = "1.0.0")] -- Relaxed, -- /// When coupled with a store, all previous writes become visible -- /// to the other threads that perform a load with [`Acquire`] ordering -- /// on the same value. -- /// -- /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire -- #[stable(feature = "rust1", since = "1.0.0")] -- Release, -- /// When coupled with a load, all subsequent loads will see data -- /// written before a store with [`Release`] ordering on the same value -- /// in other threads. -- /// -- /// [`Release`]: http://llvm.org/docs/Atomics.html#release -- #[stable(feature = "rust1", since = "1.0.0")] -- Acquire, -- /// Has the effects of both [`Acquire`] and [`Release`] together. -- /// -- /// This ordering is only applicable for operations that combine both loads and stores. -- /// -- /// For loads it uses [`Acquire`] ordering. For stores it uses the [`Release`] ordering. -- /// -- /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire -- /// [`Release`]: http://llvm.org/docs/Atomics.html#release -- #[stable(feature = "rust1", since = "1.0.0")] -- AcqRel, -- /// Like `AcqRel` with the additional guarantee that all threads see all -- /// sequentially consistent operations in the same order. -- #[stable(feature = "rust1", since = "1.0.0")] -- SeqCst, -- // Prevent exhaustive matching to allow for future extension -- #[doc(hidden)] -- #[unstable(feature = "future_atomic_orderings", issue = "0")] -- __Nonexhaustive, --} -- --/// An [`AtomicBool`] initialized to `false`. --/// --/// [`AtomicBool`]: struct.AtomicBool.html --#[cfg(target_has_atomic = "8")] --#[stable(feature = "rust1", since = "1.0.0")] --pub const ATOMIC_BOOL_INIT: AtomicBool = AtomicBool::new(false); -- --#[cfg(target_has_atomic = "8")] --impl AtomicBool { -- /// Creates a new `AtomicBool`. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::AtomicBool; -- /// -- /// let atomic_true = AtomicBool::new(true); -- /// let atomic_false = AtomicBool::new(false); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- pub const fn new(v: bool) -> AtomicBool { -- AtomicBool { v: UnsafeCell::new(v as u8) } -- } -- -- /// Returns a mutable reference to the underlying [`bool`]. -- /// -- /// This is safe because the mutable reference guarantees that no other threads are -- /// concurrently accessing the atomic data. -- /// -- /// [`bool`]: ../../../std/primitive.bool.html -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let mut some_bool = AtomicBool::new(true); -- /// assert_eq!(*some_bool.get_mut(), true); -- /// *some_bool.get_mut() = false; -- /// assert_eq!(some_bool.load(Ordering::SeqCst), false); -- /// ``` -- #[inline] -- #[stable(feature = "atomic_access", since = "1.15.0")] -- pub fn get_mut(&mut self) -> &mut bool { -- unsafe { &mut *(self.v.get() as *mut bool) } -- } -- -- /// Consumes the atomic and returns the contained value. -- /// -- /// This is safe because passing `self` by value guarantees that no other threads are -- /// concurrently accessing the atomic data. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::AtomicBool; -- /// -- /// let some_bool = AtomicBool::new(true); -- /// assert_eq!(some_bool.into_inner(), true); -- /// ``` -- #[inline] -- #[stable(feature = "atomic_access", since = "1.15.0")] -- pub fn into_inner(self) -> bool { -- self.v.into_inner() != 0 -- } -- -- /// Loads a value from the bool. -- /// -- /// `load` takes an [`Ordering`] argument which describes the memory ordering -- /// of this operation. -- /// -- /// # Panics -- /// -- /// Panics if `order` is [`Release`] or [`AcqRel`]. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// [`Release`]: enum.Ordering.html#variant.Release -- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let some_bool = AtomicBool::new(true); -- /// -- /// assert_eq!(some_bool.load(Ordering::Relaxed), true); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- pub fn load(&self, order: Ordering) -> bool { -- unsafe { atomic_load(self.v.get(), order) != 0 } -- } -- -- /// Stores a value into the bool. -- /// -- /// `store` takes an [`Ordering`] argument which describes the memory ordering -- /// of this operation. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let some_bool = AtomicBool::new(true); -- /// -- /// some_bool.store(false, Ordering::Relaxed); -- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); -- /// ``` -- /// -- /// # Panics -- /// -- /// Panics if `order` is [`Acquire`] or [`AcqRel`]. -- /// -- /// [`Acquire`]: enum.Ordering.html#variant.Acquire -- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- pub fn store(&self, val: bool, order: Ordering) { -- unsafe { -- atomic_store(self.v.get(), val as u8, order); -- } -- } -- -- /// Stores a value into the bool, returning the previous value. -- /// -- /// `swap` takes an [`Ordering`] argument which describes the memory ordering -- /// of this operation. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let some_bool = AtomicBool::new(true); -- /// -- /// assert_eq!(some_bool.swap(false, Ordering::Relaxed), true); -- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn swap(&self, val: bool, order: Ordering) -> bool { -- unsafe { atomic_swap(self.v.get(), val as u8, order) != 0 } -- } -- -- /// Stores a value into the [`bool`] if the current value is the same as the `current` value. -- /// -- /// The return value is always the previous value. If it is equal to `current`, then the value -- /// was updated. -- /// -- /// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory -- /// ordering of this operation. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// [`bool`]: ../../../std/primitive.bool.html -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let some_bool = AtomicBool::new(true); -- /// -- /// assert_eq!(some_bool.compare_and_swap(true, false, Ordering::Relaxed), true); -- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); -- /// -- /// assert_eq!(some_bool.compare_and_swap(true, true, Ordering::Relaxed), false); -- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> bool { -- match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) { -- Ok(x) => x, -- Err(x) => x, -- } -- } -- -- /// Stores a value into the [`bool`] if the current value is the same as the `current` value. -- /// -- /// The return value is a result indicating whether the new value was written and containing -- /// the previous value. On success this value is guaranteed to be equal to `current`. -- /// -- /// `compare_exchange` takes two [`Ordering`] arguments to describe the memory -- /// ordering of this operation. The first describes the required ordering if the -- /// operation succeeds while the second describes the required ordering when the -- /// operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and must -- /// be equivalent or weaker than the success ordering. -- /// -- /// [`bool`]: ../../../std/primitive.bool.html -- /// [`Ordering`]: enum.Ordering.html -- /// [`Release`]: enum.Ordering.html#variant.Release -- /// [`AcqRel`]: enum.Ordering.html#variant.Release -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let some_bool = AtomicBool::new(true); -- /// -- /// assert_eq!(some_bool.compare_exchange(true, -- /// false, -- /// Ordering::Acquire, -- /// Ordering::Relaxed), -- /// Ok(true)); -- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); -- /// -- /// assert_eq!(some_bool.compare_exchange(true, true, -- /// Ordering::SeqCst, -- /// Ordering::Acquire), -- /// Err(false)); -- /// assert_eq!(some_bool.load(Ordering::Relaxed), false); -- /// ``` -- #[inline] -- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn compare_exchange(&self, -- current: bool, -- new: bool, -- success: Ordering, -- failure: Ordering) -- -> Result { -- match unsafe { -- atomic_compare_exchange(self.v.get(), current as u8, new as u8, success, failure) -- } { -- Ok(x) => Ok(x != 0), -- Err(x) => Err(x != 0), -- } -- } -- -- /// Stores a value into the [`bool`] if the current value is the same as the `current` value. -- /// -- /// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the -- /// comparison succeeds, which can result in more efficient code on some platforms. The -- /// return value is a result indicating whether the new value was written and containing the -- /// previous value. -- /// -- /// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory -- /// ordering of this operation. The first describes the required ordering if the operation -- /// succeeds while the second describes the required ordering when the operation fails. The -- /// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or -- /// weaker than the success ordering. -- /// -- /// [`bool`]: ../../../std/primitive.bool.html -- /// [`compare_exchange`]: #method.compare_exchange -- /// [`Ordering`]: enum.Ordering.html -- /// [`Release`]: enum.Ordering.html#variant.Release -- /// [`AcqRel`]: enum.Ordering.html#variant.Release -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let val = AtomicBool::new(false); -- /// -- /// let new = true; -- /// let mut old = val.load(Ordering::Relaxed); -- /// loop { -- /// match val.compare_exchange_weak(old, new, Ordering::SeqCst, Ordering::Relaxed) { -- /// Ok(_) => break, -- /// Err(x) => old = x, -- /// } -- /// } -- /// ``` -- #[inline] -- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] -- pub fn compare_exchange_weak(&self, -- current: bool, -- new: bool, -- success: Ordering, -- failure: Ordering) -- -> Result { -- match unsafe { -- atomic_compare_exchange_weak(self.v.get(), current as u8, new as u8, success, failure) -- } { -- Ok(x) => Ok(x != 0), -- Err(x) => Err(x != 0), -- } -- } -- -- /// Logical "and" with a boolean value. -- /// -- /// Performs a logical "and" operation on the current value and the argument `val`, and sets -- /// the new value to the result. -- /// -- /// Returns the previous value. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_and(false, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst), false); -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_and(true, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst), true); -- /// -- /// let foo = AtomicBool::new(false); -- /// assert_eq!(foo.fetch_and(false, Ordering::SeqCst), false); -- /// assert_eq!(foo.load(Ordering::SeqCst), false); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn fetch_and(&self, val: bool, order: Ordering) -> bool { -- unsafe { atomic_and(self.v.get(), val as u8, order) != 0 } -- } -- -- /// Logical "nand" with a boolean value. -- /// -- /// Performs a logical "nand" operation on the current value and the argument `val`, and sets -- /// the new value to the result. -- /// -- /// Returns the previous value. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_nand(false, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst), true); -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_nand(true, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst) as usize, 0); -- /// assert_eq!(foo.load(Ordering::SeqCst), false); -- /// -- /// let foo = AtomicBool::new(false); -- /// assert_eq!(foo.fetch_nand(false, Ordering::SeqCst), false); -- /// assert_eq!(foo.load(Ordering::SeqCst), true); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn fetch_nand(&self, val: bool, order: Ordering) -> bool { -- // We can't use atomic_nand here because it can result in a bool with -- // an invalid value. This happens because the atomic operation is done -- // with an 8-bit integer internally, which would set the upper 7 bits. -- // So we just use fetch_xor or swap instead. -- if val { -- // !(x & true) == !x -- // We must invert the bool. -- self.fetch_xor(true, order) -- } else { -- // !(x & false) == true -- // We must set the bool to true. -- self.swap(true, order) -- } -- } -- -- /// Logical "or" with a boolean value. -- /// -- /// Performs a logical "or" operation on the current value and the argument `val`, and sets the -- /// new value to the result. -- /// -- /// Returns the previous value. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst), true); -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_or(true, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst), true); -- /// -- /// let foo = AtomicBool::new(false); -- /// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), false); -- /// assert_eq!(foo.load(Ordering::SeqCst), false); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn fetch_or(&self, val: bool, order: Ordering) -> bool { -- unsafe { atomic_or(self.v.get(), val as u8, order) != 0 } -- } -- -- /// Logical "xor" with a boolean value. -- /// -- /// Performs a logical "xor" operation on the current value and the argument `val`, and sets -- /// the new value to the result. -- /// -- /// Returns the previous value. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicBool, Ordering}; -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_xor(false, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst), true); -- /// -- /// let foo = AtomicBool::new(true); -- /// assert_eq!(foo.fetch_xor(true, Ordering::SeqCst), true); -- /// assert_eq!(foo.load(Ordering::SeqCst), false); -- /// -- /// let foo = AtomicBool::new(false); -- /// assert_eq!(foo.fetch_xor(false, Ordering::SeqCst), false); -- /// assert_eq!(foo.load(Ordering::SeqCst), false); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool { -- unsafe { atomic_xor(self.v.get(), val as u8, order) != 0 } -- } --} -- --#[cfg(target_has_atomic = "ptr")] --impl AtomicPtr { -- /// Creates a new `AtomicPtr`. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::AtomicPtr; -- /// -- /// let ptr = &mut 5; -- /// let atomic_ptr = AtomicPtr::new(ptr); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- pub const fn new(p: *mut T) -> AtomicPtr { -- AtomicPtr { p: UnsafeCell::new(p) } -- } -- -- /// Returns a mutable reference to the underlying pointer. -- /// -- /// This is safe because the mutable reference guarantees that no other threads are -- /// concurrently accessing the atomic data. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicPtr, Ordering}; -- /// -- /// let mut atomic_ptr = AtomicPtr::new(&mut 10); -- /// *atomic_ptr.get_mut() = &mut 5; -- /// assert_eq!(unsafe { *atomic_ptr.load(Ordering::SeqCst) }, 5); -- /// ``` -- #[inline] -- #[stable(feature = "atomic_access", since = "1.15.0")] -- pub fn get_mut(&mut self) -> &mut *mut T { -- unsafe { &mut *self.p.get() } -- } -- -- /// Consumes the atomic and returns the contained value. -- /// -- /// This is safe because passing `self` by value guarantees that no other threads are -- /// concurrently accessing the atomic data. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::AtomicPtr; -- /// -- /// let atomic_ptr = AtomicPtr::new(&mut 5); -- /// assert_eq!(unsafe { *atomic_ptr.into_inner() }, 5); -- /// ``` -- #[inline] -- #[stable(feature = "atomic_access", since = "1.15.0")] -- pub fn into_inner(self) -> *mut T { -- self.p.into_inner() -- } -- -- /// Loads a value from the pointer. -- /// -- /// `load` takes an [`Ordering`] argument which describes the memory ordering -- /// of this operation. -- /// -- /// # Panics -- /// -- /// Panics if `order` is [`Release`] or [`AcqRel`]. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// [`Release`]: enum.Ordering.html#variant.Release -- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicPtr, Ordering}; -- /// -- /// let ptr = &mut 5; -- /// let some_ptr = AtomicPtr::new(ptr); -- /// -- /// let value = some_ptr.load(Ordering::Relaxed); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- pub fn load(&self, order: Ordering) -> *mut T { -- unsafe { atomic_load(self.p.get() as *mut usize, order) as *mut T } -- } -- -- /// Stores a value into the pointer. -- /// -- /// `store` takes an [`Ordering`] argument which describes the memory ordering -- /// of this operation. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicPtr, Ordering}; -- /// -- /// let ptr = &mut 5; -- /// let some_ptr = AtomicPtr::new(ptr); -- /// -- /// let other_ptr = &mut 10; -- /// -- /// some_ptr.store(other_ptr, Ordering::Relaxed); -- /// ``` -- /// -- /// # Panics -- /// -- /// Panics if `order` is [`Acquire`] or [`AcqRel`]. -- /// -- /// [`Acquire`]: enum.Ordering.html#variant.Acquire -- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- pub fn store(&self, ptr: *mut T, order: Ordering) { -- unsafe { -- atomic_store(self.p.get() as *mut usize, ptr as usize, order); -- } -- } -- -- /// Stores a value into the pointer, returning the previous value. -- /// -- /// `swap` takes an [`Ordering`] argument which describes the memory ordering -- /// of this operation. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicPtr, Ordering}; -- /// -- /// let ptr = &mut 5; -- /// let some_ptr = AtomicPtr::new(ptr); -- /// -- /// let other_ptr = &mut 10; -- /// -- /// let value = some_ptr.swap(other_ptr, Ordering::Relaxed); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T { -- unsafe { atomic_swap(self.p.get() as *mut usize, ptr as usize, order) as *mut T } -- } -- -- /// Stores a value into the pointer if the current value is the same as the `current` value. -- /// -- /// The return value is always the previous value. If it is equal to `current`, then the value -- /// was updated. -- /// -- /// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory -- /// ordering of this operation. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicPtr, Ordering}; -- /// -- /// let ptr = &mut 5; -- /// let some_ptr = AtomicPtr::new(ptr); -- /// -- /// let other_ptr = &mut 10; -- /// let another_ptr = &mut 10; -- /// -- /// let value = some_ptr.compare_and_swap(other_ptr, another_ptr, Ordering::Relaxed); -- /// ``` -- #[inline] -- #[stable(feature = "rust1", since = "1.0.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn compare_and_swap(&self, current: *mut T, new: *mut T, order: Ordering) -> *mut T { -- match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) { -- Ok(x) => x, -- Err(x) => x, -- } -- } -- -- /// Stores a value into the pointer if the current value is the same as the `current` value. -- /// -- /// The return value is a result indicating whether the new value was written and containing -- /// the previous value. On success this value is guaranteed to be equal to `current`. -- /// -- /// `compare_exchange` takes two [`Ordering`] arguments to describe the memory -- /// ordering of this operation. The first describes the required ordering if -- /// the operation succeeds while the second describes the required ordering when -- /// the operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] -- /// and must be equivalent or weaker than the success ordering. -- /// -- /// [`Ordering`]: enum.Ordering.html -- /// [`Release`]: enum.Ordering.html#variant.Release -- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicPtr, Ordering}; -- /// -- /// let ptr = &mut 5; -- /// let some_ptr = AtomicPtr::new(ptr); -- /// -- /// let other_ptr = &mut 10; -- /// let another_ptr = &mut 10; -- /// -- /// let value = some_ptr.compare_exchange(other_ptr, another_ptr, -- /// Ordering::SeqCst, Ordering::Relaxed); -- /// ``` -- #[inline] -- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn compare_exchange(&self, -- current: *mut T, -- new: *mut T, -- success: Ordering, -- failure: Ordering) -- -> Result<*mut T, *mut T> { -- unsafe { -- let res = atomic_compare_exchange(self.p.get() as *mut usize, -- current as usize, -- new as usize, -- success, -- failure); -- match res { -- Ok(x) => Ok(x as *mut T), -- Err(x) => Err(x as *mut T), -- } -- } -- } -- -- /// Stores a value into the pointer if the current value is the same as the `current` value. -- /// -- /// Unlike [`compare_exchange`], this function is allowed to spuriously fail even when the -- /// comparison succeeds, which can result in more efficient code on some platforms. The -- /// return value is a result indicating whether the new value was written and containing the -- /// previous value. -- /// -- /// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory -- /// ordering of this operation. The first describes the required ordering if the operation -- /// succeeds while the second describes the required ordering when the operation fails. The -- /// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or -- /// weaker than the success ordering. -- /// -- /// [`compare_exchange`]: #method.compare_exchange -- /// [`Ordering`]: enum.Ordering.html -- /// [`Release`]: enum.Ordering.html#variant.Release -- /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::sync::atomic::{AtomicPtr, Ordering}; -- /// -- /// let some_ptr = AtomicPtr::new(&mut 5); -- /// -- /// let new = &mut 10; -- /// let mut old = some_ptr.load(Ordering::Relaxed); -- /// loop { -- /// match some_ptr.compare_exchange_weak(old, new, Ordering::SeqCst, Ordering::Relaxed) { -- /// Ok(_) => break, -- /// Err(x) => old = x, -- /// } -- /// } -- /// ``` -- #[inline] -- #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] -- pub fn compare_exchange_weak(&self, -- current: *mut T, -- new: *mut T, -- success: Ordering, -- failure: Ordering) -- -> Result<*mut T, *mut T> { -- unsafe { -- let res = atomic_compare_exchange_weak(self.p.get() as *mut usize, -- current as usize, -- new as usize, -- success, -- failure); -- match res { -- Ok(x) => Ok(x as *mut T), -- Err(x) => Err(x as *mut T), -- } -- } -- } --} -- --#[cfg(target_has_atomic = "8")] --#[stable(feature = "atomic_bool_from", since = "1.24.0")] --impl From for AtomicBool { -- #[inline] -- fn from(b: bool) -> Self { Self::new(b) } --} -- --#[cfg(target_has_atomic = "ptr")] --#[stable(feature = "atomic_from", since = "1.23.0")] --impl From<*mut T> for AtomicPtr { -- #[inline] -- fn from(p: *mut T) -> Self { Self::new(p) } --} -- --#[cfg(target_has_atomic = "ptr")] --macro_rules! atomic_int { -- ($stable:meta, -- $stable_cxchg:meta, -- $stable_debug:meta, -- $stable_access:meta, -- $stable_from:meta, -- $stable_nand:meta, -- $s_int_type:expr, $int_ref:expr, -- $extra_feature:expr, -- $min_fn:ident, $max_fn:ident, -- $int_type:ident $atomic_type:ident $atomic_init:ident) => { -- /// An integer type which can be safely shared between threads. -- /// -- /// This type has the same in-memory representation as the underlying -- /// integer type, [` -- #[doc = $s_int_type] -- /// `]( -- #[doc = $int_ref] -- /// ). For more about the differences between atomic types and -- /// non-atomic types, please see the [module-level documentation]. -- /// -- /// [module-level documentation]: index.html -- #[$stable] -- #[repr(transparent)] -- pub struct $atomic_type { -- v: UnsafeCell<$int_type>, -- } -- -- /// An atomic integer initialized to `0`. -- #[$stable] -- pub const $atomic_init: $atomic_type = $atomic_type::new(0); -- -- #[$stable] -- impl Default for $atomic_type { -- fn default() -> Self { -- Self::new(Default::default()) -- } -- } -- -- #[$stable_from] -- impl From<$int_type> for $atomic_type { -- #[inline] -- fn from(v: $int_type) -> Self { Self::new(v) } -- } -- -- #[$stable_debug] -- impl fmt::Debug for $atomic_type { -- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -- fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) -- } -- } -- -- // Send is implicitly implemented. -- #[$stable] -- unsafe impl Sync for $atomic_type {} -- -- impl $atomic_type { -- doc_comment! { -- concat!("Creates a new atomic integer. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::", stringify!($atomic_type), "; -- --let atomic_forty_two = ", stringify!($atomic_type), "::new(42); --```"), -- #[inline] -- #[$stable] -- pub const fn new(v: $int_type) -> Self { -- $atomic_type {v: UnsafeCell::new(v)} -- } -- } -- -- doc_comment! { -- concat!("Returns a mutable reference to the underlying integer. -- --This is safe because the mutable reference guarantees that no other threads are --concurrently accessing the atomic data. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let mut some_var = ", stringify!($atomic_type), "::new(10); --assert_eq!(*some_var.get_mut(), 10); --*some_var.get_mut() = 5; --assert_eq!(some_var.load(Ordering::SeqCst), 5); --```"), -- #[inline] -- #[$stable_access] -- pub fn get_mut(&mut self) -> &mut $int_type { -- unsafe { &mut *self.v.get() } -- } -- } -- -- doc_comment! { -- concat!("Consumes the atomic and returns the contained value. -- --This is safe because passing `self` by value guarantees that no other threads are --concurrently accessing the atomic data. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::", stringify!($atomic_type), "; -- --let some_var = ", stringify!($atomic_type), "::new(5); --assert_eq!(some_var.into_inner(), 5); --```"), -- #[inline] -- #[$stable_access] -- pub fn into_inner(self) -> $int_type { -- self.v.into_inner() -- } -- } -- -- doc_comment! { -- concat!("Loads a value from the atomic integer. -- --`load` takes an [`Ordering`] argument which describes the memory ordering of this operation. -- --# Panics -- --Panics if `order` is [`Release`] or [`AcqRel`]. -- --[`Ordering`]: enum.Ordering.html --[`Release`]: enum.Ordering.html#variant.Release --[`AcqRel`]: enum.Ordering.html#variant.AcqRel -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let some_var = ", stringify!($atomic_type), "::new(5); -- --assert_eq!(some_var.load(Ordering::Relaxed), 5); --```"), -- #[inline] -- #[$stable] -- pub fn load(&self, order: Ordering) -> $int_type { -- unsafe { atomic_load(self.v.get(), order) } -- } -- } -- -- doc_comment! { -- concat!("Stores a value into the atomic integer. -- --`store` takes an [`Ordering`] argument which describes the memory ordering of this operation. -- --[`Ordering`]: enum.Ordering.html -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let some_var = ", stringify!($atomic_type), "::new(5); -- --some_var.store(10, Ordering::Relaxed); --assert_eq!(some_var.load(Ordering::Relaxed), 10); --``` -- --# Panics -- --Panics if `order` is [`Acquire`] or [`AcqRel`]. -- --[`Acquire`]: enum.Ordering.html#variant.Acquire --[`AcqRel`]: enum.Ordering.html#variant.AcqRel"), -- #[inline] -- #[$stable] -- pub fn store(&self, val: $int_type, order: Ordering) { -- unsafe { atomic_store(self.v.get(), val, order); } -- } -- } -- -- doc_comment! { -- concat!("Stores a value into the atomic integer, returning the previous value. -- --`swap` takes an [`Ordering`] argument which describes the memory ordering of this operation. -- --[`Ordering`]: enum.Ordering.html -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let some_var = ", stringify!($atomic_type), "::new(5); -- --assert_eq!(some_var.swap(10, Ordering::Relaxed), 5); --```"), -- #[inline] -- #[$stable] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn swap(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { atomic_swap(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Stores a value into the atomic integer if the current value is the same as --the `current` value. -- --The return value is always the previous value. If it is equal to `current`, then the --value was updated. -- --`compare_and_swap` also takes an [`Ordering`] argument which describes the memory --ordering of this operation. -- --[`Ordering`]: enum.Ordering.html -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let some_var = ", stringify!($atomic_type), "::new(5); -- --assert_eq!(some_var.compare_and_swap(5, 10, Ordering::Relaxed), 5); --assert_eq!(some_var.load(Ordering::Relaxed), 10); -- --assert_eq!(some_var.compare_and_swap(6, 12, Ordering::Relaxed), 10); --assert_eq!(some_var.load(Ordering::Relaxed), 10); --```"), -- #[inline] -- #[$stable] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn compare_and_swap(&self, -- current: $int_type, -- new: $int_type, -- order: Ordering) -> $int_type { -- match self.compare_exchange(current, -- new, -- order, -- strongest_failure_ordering(order)) { -- Ok(x) => x, -- Err(x) => x, -- } -- } -- } -- -- doc_comment! { -- concat!("Stores a value into the atomic integer if the current value is the same as --the `current` value. -- --The return value is a result indicating whether the new value was written and --containing the previous value. On success this value is guaranteed to be equal to --`current`. -- --`compare_exchange` takes two [`Ordering`] arguments to describe the memory --ordering of this operation. The first describes the required ordering if --the operation succeeds while the second describes the required ordering when --the operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and --must be equivalent or weaker than the success ordering. -- --[`Ordering`]: enum.Ordering.html --[`Release`]: enum.Ordering.html#variant.Release --[`AcqRel`]: enum.Ordering.html#variant.AcqRel -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let some_var = ", stringify!($atomic_type), "::new(5); -- --assert_eq!(some_var.compare_exchange(5, 10, -- Ordering::Acquire, -- Ordering::Relaxed), -- Ok(5)); --assert_eq!(some_var.load(Ordering::Relaxed), 10); -- --assert_eq!(some_var.compare_exchange(6, 12, -- Ordering::SeqCst, -- Ordering::Acquire), -- Err(10)); --assert_eq!(some_var.load(Ordering::Relaxed), 10); --```"), -- #[inline] -- #[$stable_cxchg] -- #[cfg(any(stage0, target_has_atomic = "cas"))] -- pub fn compare_exchange(&self, -- current: $int_type, -- new: $int_type, -- success: Ordering, -- failure: Ordering) -> Result<$int_type, $int_type> { -- unsafe { atomic_compare_exchange(self.v.get(), current, new, success, failure) } -- } -- } -- -- doc_comment! { -- concat!("Stores a value into the atomic integer if the current value is the same as --the `current` value. -- --Unlike [`compare_exchange`], this function is allowed to spuriously fail even --when the comparison succeeds, which can result in more efficient code on some --platforms. The return value is a result indicating whether the new value was --written and containing the previous value. -- --`compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory --ordering of this operation. The first describes the required ordering if the --operation succeeds while the second describes the required ordering when the --operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and --must be equivalent or weaker than the success ordering. -- --[`compare_exchange`]: #method.compare_exchange --[`Ordering`]: enum.Ordering.html --[`Release`]: enum.Ordering.html#variant.Release --[`AcqRel`]: enum.Ordering.html#variant.AcqRel -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let val = ", stringify!($atomic_type), "::new(4); -- --let mut old = val.load(Ordering::Relaxed); --loop { -- let new = old * 2; -- match val.compare_exchange_weak(old, new, Ordering::SeqCst, Ordering::Relaxed) { -- Ok(_) => break, -- Err(x) => old = x, -- } --} --```"), -- #[inline] -- #[$stable_cxchg] -- pub fn compare_exchange_weak(&self, -- current: $int_type, -- new: $int_type, -- success: Ordering, -- failure: Ordering) -> Result<$int_type, $int_type> { -- unsafe { -- atomic_compare_exchange_weak(self.v.get(), current, new, success, failure) -- } -- } -- } -- -- doc_comment! { -- concat!("Adds to the current value, returning the previous value. -- --This operation wraps around on overflow. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(0); --assert_eq!(foo.fetch_add(10, Ordering::SeqCst), 0); --assert_eq!(foo.load(Ordering::SeqCst), 10); --```"), -- #[inline] -- #[$stable] -- pub fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { atomic_add(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Subtracts from the current value, returning the previous value. -- --This operation wraps around on overflow. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(20); --assert_eq!(foo.fetch_sub(10, Ordering::SeqCst), 20); --assert_eq!(foo.load(Ordering::SeqCst), 10); --```"), -- #[inline] -- #[$stable] -- pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { atomic_sub(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Bitwise \"and\" with the current value. -- --Performs a bitwise \"and\" operation on the current value and the argument `val`, and --sets the new value to the result. -- --Returns the previous value. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(0b101101); --assert_eq!(foo.fetch_and(0b110011, Ordering::SeqCst), 0b101101); --assert_eq!(foo.load(Ordering::SeqCst), 0b100001); --```"), -- #[inline] -- #[$stable] -- pub fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { atomic_and(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Bitwise \"nand\" with the current value. -- --Performs a bitwise \"nand\" operation on the current value and the argument `val`, and --sets the new value to the result. -- --Returns the previous value. -- --# Examples -- --``` --", $extra_feature, " --use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(0x13); --assert_eq!(foo.fetch_nand(0x31, Ordering::SeqCst), 0x13); --assert_eq!(foo.load(Ordering::SeqCst), !(0x13 & 0x31)); --```"), -- #[inline] -- #[$stable_nand] -- pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { atomic_nand(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Bitwise \"or\" with the current value. -- --Performs a bitwise \"or\" operation on the current value and the argument `val`, and --sets the new value to the result. -- --Returns the previous value. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(0b101101); --assert_eq!(foo.fetch_or(0b110011, Ordering::SeqCst), 0b101101); --assert_eq!(foo.load(Ordering::SeqCst), 0b111111); --```"), -- #[inline] -- #[$stable] -- pub fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { atomic_or(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Bitwise \"xor\" with the current value. -- --Performs a bitwise \"xor\" operation on the current value and the argument `val`, and --sets the new value to the result. -- --Returns the previous value. -- --# Examples -- --``` --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(0b101101); --assert_eq!(foo.fetch_xor(0b110011, Ordering::SeqCst), 0b101101); --assert_eq!(foo.load(Ordering::SeqCst), 0b011110); --```"), -- #[inline] -- #[$stable] -- pub fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { atomic_xor(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Fetches the value, and applies a function to it that returns an optional --new value. Returns a `Result` of `Ok(previous_value)` if the function returned `Some(_)`, else --`Err(previous_value)`. -- --Note: This may call the function multiple times if the value has been changed from other threads in --the meantime, as long as the function returns `Some(_)`, but the function will have been applied --but once to the stored value. -- --# Examples -- --```rust --#![feature(no_more_cas)] --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let x = ", stringify!($atomic_type), "::new(7); --assert_eq!(x.fetch_update(|_| None, Ordering::SeqCst, Ordering::SeqCst), Err(7)); --assert_eq!(x.fetch_update(|x| Some(x + 1), Ordering::SeqCst, Ordering::SeqCst), Ok(7)); --assert_eq!(x.fetch_update(|x| Some(x + 1), Ordering::SeqCst, Ordering::SeqCst), Ok(8)); --assert_eq!(x.load(Ordering::SeqCst), 9); --```"), -- #[inline] -- #[unstable(feature = "no_more_cas", -- reason = "no more CAS loops in user code", -- issue = "48655")] -- pub fn fetch_update(&self, -- mut f: F, -- fetch_order: Ordering, -- set_order: Ordering) -> Result<$int_type, $int_type> -- where F: FnMut($int_type) -> Option<$int_type> { -- let mut prev = self.load(fetch_order); -- while let Some(next) = f(prev) { -- match self.compare_exchange_weak(prev, next, set_order, fetch_order) { -- x @ Ok(_) => return x, -- Err(next_prev) => prev = next_prev -- } -- } -- Err(prev) -- } -- } -- -- doc_comment! { -- concat!("Maximum with the current value. -- --Finds the maximum of the current value and the argument `val`, and --sets the new value to the result. -- --Returns the previous value. -- --# Examples -- --``` --#![feature(atomic_min_max)] --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(23); --assert_eq!(foo.fetch_max(42, Ordering::SeqCst), 23); --assert_eq!(foo.load(Ordering::SeqCst), 42); --``` -- --If you want to obtain the maximum value in one step, you can use the following: -- --``` --#![feature(atomic_min_max)] --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(23); --let bar = 42; --let max_foo = foo.fetch_max(bar, Ordering::SeqCst).max(bar); --assert!(max_foo == 42); --```"), -- #[inline] -- #[unstable(feature = "atomic_min_max", -- reason = "easier and faster min/max than writing manual CAS loop", -- issue = "48655")] -- pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { $max_fn(self.v.get(), val, order) } -- } -- } -- -- doc_comment! { -- concat!("Minimum with the current value. -- --Finds the minimum of the current value and the argument `val`, and --sets the new value to the result. -- --Returns the previous value. -- --# Examples -- --``` --#![feature(atomic_min_max)] --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(23); --assert_eq!(foo.fetch_min(42, Ordering::Relaxed), 23); --assert_eq!(foo.load(Ordering::Relaxed), 23); --assert_eq!(foo.fetch_min(22, Ordering::Relaxed), 23); --assert_eq!(foo.load(Ordering::Relaxed), 22); --``` -- --If you want to obtain the minimum value in one step, you can use the following: -- --``` --#![feature(atomic_min_max)] --", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering}; -- --let foo = ", stringify!($atomic_type), "::new(23); --let bar = 12; --let min_foo = foo.fetch_min(bar, Ordering::SeqCst).min(bar); --assert_eq!(min_foo, 12); --```"), -- #[inline] -- #[unstable(feature = "atomic_min_max", -- reason = "easier and faster min/max than writing manual CAS loop", -- issue = "48655")] -- pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type { -- unsafe { $min_fn(self.v.get(), val, order) } -- } -- } -- -- } -- } --} -- --#[cfg(target_has_atomic = "8")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "i8", "../../../std/primitive.i8.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_min, atomic_max, -- i8 AtomicI8 ATOMIC_I8_INIT --} --#[cfg(target_has_atomic = "8")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "u8", "../../../std/primitive.u8.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_umin, atomic_umax, -- u8 AtomicU8 ATOMIC_U8_INIT --} --#[cfg(target_has_atomic = "16")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "i16", "../../../std/primitive.i16.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_min, atomic_max, -- i16 AtomicI16 ATOMIC_I16_INIT --} --#[cfg(target_has_atomic = "16")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "u16", "../../../std/primitive.u16.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_umin, atomic_umax, -- u16 AtomicU16 ATOMIC_U16_INIT --} --#[cfg(target_has_atomic = "32")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "i32", "../../../std/primitive.i32.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_min, atomic_max, -- i32 AtomicI32 ATOMIC_I32_INIT --} --#[cfg(target_has_atomic = "32")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "u32", "../../../std/primitive.u32.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_umin, atomic_umax, -- u32 AtomicU32 ATOMIC_U32_INIT --} --#[cfg(target_has_atomic = "64")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "i64", "../../../std/primitive.i64.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_min, atomic_max, -- i64 AtomicI64 ATOMIC_I64_INIT --} --#[cfg(target_has_atomic = "64")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "u64", "../../../std/primitive.u64.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_umin, atomic_umax, -- u64 AtomicU64 ATOMIC_U64_INIT --} --#[cfg(target_has_atomic = "ptr")] --atomic_int!{ -- stable(feature = "rust1", since = "1.0.0"), -- stable(feature = "extended_compare_and_swap", since = "1.10.0"), -- stable(feature = "atomic_debug", since = "1.3.0"), -- stable(feature = "atomic_access", since = "1.15.0"), -- stable(feature = "atomic_from", since = "1.23.0"), -- stable(feature = "atomic_nand", since = "1.27.0"), -- "isize", "../../../std/primitive.isize.html", -- "", -- atomic_min, atomic_max, -- isize AtomicIsize ATOMIC_ISIZE_INIT --} --#[cfg(target_has_atomic = "ptr")] --atomic_int!{ -- stable(feature = "rust1", since = "1.0.0"), -- stable(feature = "extended_compare_and_swap", since = "1.10.0"), -- stable(feature = "atomic_debug", since = "1.3.0"), -- stable(feature = "atomic_access", since = "1.15.0"), -- stable(feature = "atomic_from", since = "1.23.0"), -- stable(feature = "atomic_nand", since = "1.27.0"), -- "usize", "../../../std/primitive.usize.html", -- "", -- atomic_umin, atomic_umax, -- usize AtomicUsize ATOMIC_USIZE_INIT --} -- --#[inline] --#[cfg(any(stage0, target_has_atomic = "cas"))] --fn strongest_failure_ordering(order: Ordering) -> Ordering { -- match order { -- Release => Relaxed, -- Relaxed => Relaxed, -- SeqCst => SeqCst, -- Acquire => Acquire, -- AcqRel => Acquire, -- __Nonexhaustive => __Nonexhaustive, -- } --} -- --#[inline] --unsafe fn atomic_store(dst: *mut T, val: T, order: Ordering) { -- match order { -- Release => intrinsics::atomic_store_rel(dst, val), -- Relaxed => intrinsics::atomic_store_relaxed(dst, val), -- SeqCst => intrinsics::atomic_store(dst, val), -- Acquire => panic!("there is no such thing as an acquire store"), -- AcqRel => panic!("there is no such thing as an acquire/release store"), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --#[inline] --unsafe fn atomic_load(dst: *const T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_load_acq(dst), -- Relaxed => intrinsics::atomic_load_relaxed(dst), -- SeqCst => intrinsics::atomic_load(dst), -- Release => panic!("there is no such thing as a release load"), -- AcqRel => panic!("there is no such thing as an acquire/release load"), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --#[inline] --#[cfg(any(stage0, target_has_atomic = "cas"))] --unsafe fn atomic_swap(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_xchg_acq(dst, val), -- Release => intrinsics::atomic_xchg_rel(dst, val), -- AcqRel => intrinsics::atomic_xchg_acqrel(dst, val), -- Relaxed => intrinsics::atomic_xchg_relaxed(dst, val), -- SeqCst => intrinsics::atomic_xchg(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --/// Returns the previous value (like __sync_fetch_and_add). --#[inline] --unsafe fn atomic_add(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_xadd_acq(dst, val), -- Release => intrinsics::atomic_xadd_rel(dst, val), -- AcqRel => intrinsics::atomic_xadd_acqrel(dst, val), -- Relaxed => intrinsics::atomic_xadd_relaxed(dst, val), -- SeqCst => intrinsics::atomic_xadd(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --/// Returns the previous value (like __sync_fetch_and_sub). --#[inline] --unsafe fn atomic_sub(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_xsub_acq(dst, val), -- Release => intrinsics::atomic_xsub_rel(dst, val), -- AcqRel => intrinsics::atomic_xsub_acqrel(dst, val), -- Relaxed => intrinsics::atomic_xsub_relaxed(dst, val), -- SeqCst => intrinsics::atomic_xsub(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --#[inline] --#[cfg(any(stage0, target_has_atomic = "cas"))] --unsafe fn atomic_compare_exchange(dst: *mut T, -- old: T, -- new: T, -- success: Ordering, -- failure: Ordering) -- -> Result { -- let (val, ok) = match (success, failure) { -- (Acquire, Acquire) => intrinsics::atomic_cxchg_acq(dst, old, new), -- (Release, Relaxed) => intrinsics::atomic_cxchg_rel(dst, old, new), -- (AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel(dst, old, new), -- (Relaxed, Relaxed) => intrinsics::atomic_cxchg_relaxed(dst, old, new), -- (SeqCst, SeqCst) => intrinsics::atomic_cxchg(dst, old, new), -- (Acquire, Relaxed) => intrinsics::atomic_cxchg_acq_failrelaxed(dst, old, new), -- (AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_failrelaxed(dst, old, new), -- (SeqCst, Relaxed) => intrinsics::atomic_cxchg_failrelaxed(dst, old, new), -- (SeqCst, Acquire) => intrinsics::atomic_cxchg_failacq(dst, old, new), -- (__Nonexhaustive, _) => panic!("invalid memory ordering"), -- (_, __Nonexhaustive) => panic!("invalid memory ordering"), -- (_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"), -- (_, Release) => panic!("there is no such thing as a release failure ordering"), -- _ => panic!("a failure ordering can't be stronger than a success ordering"), -- }; -- if ok { Ok(val) } else { Err(val) } --} -- --#[inline] --unsafe fn atomic_compare_exchange_weak(dst: *mut T, -- old: T, -- new: T, -- success: Ordering, -- failure: Ordering) -- -> Result { -- let (val, ok) = match (success, failure) { -- (Acquire, Acquire) => intrinsics::atomic_cxchgweak_acq(dst, old, new), -- (Release, Relaxed) => intrinsics::atomic_cxchgweak_rel(dst, old, new), -- (AcqRel, Acquire) => intrinsics::atomic_cxchgweak_acqrel(dst, old, new), -- (Relaxed, Relaxed) => intrinsics::atomic_cxchgweak_relaxed(dst, old, new), -- (SeqCst, SeqCst) => intrinsics::atomic_cxchgweak(dst, old, new), -- (Acquire, Relaxed) => intrinsics::atomic_cxchgweak_acq_failrelaxed(dst, old, new), -- (AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_failrelaxed(dst, old, new), -- (SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_failrelaxed(dst, old, new), -- (SeqCst, Acquire) => intrinsics::atomic_cxchgweak_failacq(dst, old, new), -- (__Nonexhaustive, _) => panic!("invalid memory ordering"), -- (_, __Nonexhaustive) => panic!("invalid memory ordering"), -- (_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"), -- (_, Release) => panic!("there is no such thing as a release failure ordering"), -- _ => panic!("a failure ordering can't be stronger than a success ordering"), -- }; -- if ok { Ok(val) } else { Err(val) } --} -- --#[inline] --unsafe fn atomic_and(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_and_acq(dst, val), -- Release => intrinsics::atomic_and_rel(dst, val), -- AcqRel => intrinsics::atomic_and_acqrel(dst, val), -- Relaxed => intrinsics::atomic_and_relaxed(dst, val), -- SeqCst => intrinsics::atomic_and(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --#[inline] --unsafe fn atomic_nand(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_nand_acq(dst, val), -- Release => intrinsics::atomic_nand_rel(dst, val), -- AcqRel => intrinsics::atomic_nand_acqrel(dst, val), -- Relaxed => intrinsics::atomic_nand_relaxed(dst, val), -- SeqCst => intrinsics::atomic_nand(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --#[inline] --unsafe fn atomic_or(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_or_acq(dst, val), -- Release => intrinsics::atomic_or_rel(dst, val), -- AcqRel => intrinsics::atomic_or_acqrel(dst, val), -- Relaxed => intrinsics::atomic_or_relaxed(dst, val), -- SeqCst => intrinsics::atomic_or(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --#[inline] --unsafe fn atomic_xor(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_xor_acq(dst, val), -- Release => intrinsics::atomic_xor_rel(dst, val), -- AcqRel => intrinsics::atomic_xor_acqrel(dst, val), -- Relaxed => intrinsics::atomic_xor_relaxed(dst, val), -- SeqCst => intrinsics::atomic_xor(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --/// returns the max value (signed comparison) --#[inline] --unsafe fn atomic_max(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_max_acq(dst, val), -- Release => intrinsics::atomic_max_rel(dst, val), -- AcqRel => intrinsics::atomic_max_acqrel(dst, val), -- Relaxed => intrinsics::atomic_max_relaxed(dst, val), -- SeqCst => intrinsics::atomic_max(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --/// returns the min value (signed comparison) --#[inline] --unsafe fn atomic_min(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_min_acq(dst, val), -- Release => intrinsics::atomic_min_rel(dst, val), -- AcqRel => intrinsics::atomic_min_acqrel(dst, val), -- Relaxed => intrinsics::atomic_min_relaxed(dst, val), -- SeqCst => intrinsics::atomic_min(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --/// returns the max value (signed comparison) --#[inline] --unsafe fn atomic_umax(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_umax_acq(dst, val), -- Release => intrinsics::atomic_umax_rel(dst, val), -- AcqRel => intrinsics::atomic_umax_acqrel(dst, val), -- Relaxed => intrinsics::atomic_umax_relaxed(dst, val), -- SeqCst => intrinsics::atomic_umax(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --/// returns the min value (signed comparison) --#[inline] --unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { -- match order { -- Acquire => intrinsics::atomic_umin_acq(dst, val), -- Release => intrinsics::atomic_umin_rel(dst, val), -- AcqRel => intrinsics::atomic_umin_acqrel(dst, val), -- Relaxed => intrinsics::atomic_umin_relaxed(dst, val), -- SeqCst => intrinsics::atomic_umin(dst, val), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } --} -- --/// An atomic fence. --/// --/// Depending on the specified order, a fence prevents the compiler and CPU from --/// reordering certain types of memory operations around it. --/// That creates synchronizes-with relationships between it and atomic operations --/// or fences in other threads. --/// --/// A fence 'A' which has (at least) [`Release`] ordering semantics, synchronizes --/// with a fence 'B' with (at least) [`Acquire`] semantics, if and only if there --/// exist operations X and Y, both operating on some atomic object 'M' such --/// that A is sequenced before X, Y is synchronized before B and Y observes --/// the change to M. This provides a happens-before dependence between A and B. --/// --/// ```text --/// Thread 1 Thread 2 --/// --/// fence(Release); A -------------- --/// x.store(3, Relaxed); X --------- | --/// | | --/// | | --/// -------------> Y if x.load(Relaxed) == 3 { --/// |-------> B fence(Acquire); --/// ... --/// } --/// ``` --/// --/// Atomic operations with [`Release`] or [`Acquire`] semantics can also synchronize --/// with a fence. --/// --/// A fence which has [`SeqCst`] ordering, in addition to having both [`Acquire`] --/// and [`Release`] semantics, participates in the global program order of the --/// other [`SeqCst`] operations and/or fences. --/// --/// Accepts [`Acquire`], [`Release`], [`AcqRel`] and [`SeqCst`] orderings. --/// --/// # Panics --/// --/// Panics if `order` is [`Relaxed`]. --/// --/// # Examples --/// --/// ``` --/// use std::sync::atomic::AtomicBool; --/// use std::sync::atomic::fence; --/// use std::sync::atomic::Ordering; --/// --/// // A mutual exclusion primitive based on spinlock. --/// pub struct Mutex { --/// flag: AtomicBool, --/// } --/// --/// impl Mutex { --/// pub fn new() -> Mutex { --/// Mutex { --/// flag: AtomicBool::new(false), --/// } --/// } --/// --/// pub fn lock(&self) { --/// while !self.flag.compare_and_swap(false, true, Ordering::Relaxed) {} --/// // This fence synchronizes-with store in `unlock`. --/// fence(Ordering::Acquire); --/// } --/// --/// pub fn unlock(&self) { --/// self.flag.store(false, Ordering::Release); --/// } --/// } --/// ``` --/// --/// [`Ordering`]: enum.Ordering.html --/// [`Acquire`]: enum.Ordering.html#variant.Acquire --/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst --/// [`Release`]: enum.Ordering.html#variant.Release --/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel --/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed --#[inline] --#[stable(feature = "rust1", since = "1.0.0")] --pub fn fence(order: Ordering) { -- unsafe { -- match order { -- Acquire => intrinsics::atomic_fence_acq(), -- Release => intrinsics::atomic_fence_rel(), -- AcqRel => intrinsics::atomic_fence_acqrel(), -- SeqCst => intrinsics::atomic_fence(), -- Relaxed => panic!("there is no such thing as a relaxed fence"), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } -- } --} -- -- --/// A compiler memory fence. --/// --/// `compiler_fence` does not emit any machine code, but restricts the kinds --/// of memory re-ordering the compiler is allowed to do. Specifically, depending on --/// the given [`Ordering`] semantics, the compiler may be disallowed from moving reads --/// or writes from before or after the call to the other side of the call to --/// `compiler_fence`. Note that it does **not** prevent the *hardware* --/// from doing such re-ordering. This is not a problem in a single-threaded, --/// execution context, but when other threads may modify memory at the same --/// time, stronger synchronization primitives such as [`fence`] are required. --/// --/// The re-ordering prevented by the different ordering semantics are: --/// --/// - with [`SeqCst`], no re-ordering of reads and writes across this point is allowed. --/// - with [`Release`], preceding reads and writes cannot be moved past subsequent writes. --/// - with [`Acquire`], subsequent reads and writes cannot be moved ahead of preceding reads. --/// - with [`AcqRel`], both of the above rules are enforced. --/// --/// `compiler_fence` is generally only useful for preventing a thread from --/// racing *with itself*. That is, if a given thread is executing one piece --/// of code, and is then interrupted, and starts executing code elsewhere --/// (while still in the same thread, and conceptually still on the same --/// core). In traditional programs, this can only occur when a signal --/// handler is registered. In more low-level code, such situations can also --/// arise when handling interrupts, when implementing green threads with --/// pre-emption, etc. Curious readers are encouraged to read the Linux kernel's --/// discussion of [memory barriers]. --/// --/// # Panics --/// --/// Panics if `order` is [`Relaxed`]. --/// --/// # Examples --/// --/// Without `compiler_fence`, the `assert_eq!` in following code --/// is *not* guaranteed to succeed, despite everything happening in a single thread. --/// To see why, remember that the compiler is free to swap the stores to --/// `IMPORTANT_VARIABLE` and `IS_READ` since they are both --/// `Ordering::Relaxed`. If it does, and the signal handler is invoked right --/// after `IS_READY` is updated, then the signal handler will see --/// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`. --/// Using a `compiler_fence` remedies this situation. --/// --/// ``` --/// use std::sync::atomic::{AtomicBool, AtomicUsize}; --/// use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT}; --/// use std::sync::atomic::Ordering; --/// use std::sync::atomic::compiler_fence; --/// --/// static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT; --/// static IS_READY: AtomicBool = ATOMIC_BOOL_INIT; --/// --/// fn main() { --/// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed); --/// // prevent earlier writes from being moved beyond this point --/// compiler_fence(Ordering::Release); --/// IS_READY.store(true, Ordering::Relaxed); --/// } --/// --/// fn signal_handler() { --/// if IS_READY.load(Ordering::Relaxed) { --/// assert_eq!(IMPORTANT_VARIABLE.load(Ordering::Relaxed), 42); --/// } --/// } --/// ``` --/// --/// [`fence`]: fn.fence.html --/// [`Ordering`]: enum.Ordering.html --/// [`Acquire`]: enum.Ordering.html#variant.Acquire --/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst --/// [`Release`]: enum.Ordering.html#variant.Release --/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel --/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed --/// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt --#[inline] --#[stable(feature = "compiler_fences", since = "1.21.0")] --pub fn compiler_fence(order: Ordering) { -- unsafe { -- match order { -- Acquire => intrinsics::atomic_singlethreadfence_acq(), -- Release => intrinsics::atomic_singlethreadfence_rel(), -- AcqRel => intrinsics::atomic_singlethreadfence_acqrel(), -- SeqCst => intrinsics::atomic_singlethreadfence(), -- Relaxed => panic!("there is no such thing as a relaxed compiler fence"), -- __Nonexhaustive => panic!("invalid memory ordering"), -- } -- } --} -- -- --#[cfg(target_has_atomic = "8")] --#[stable(feature = "atomic_debug", since = "1.3.0")] --impl fmt::Debug for AtomicBool { -- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -- fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) -- } --} -- --#[cfg(target_has_atomic = "ptr")] --#[stable(feature = "atomic_debug", since = "1.3.0")] --impl fmt::Debug for AtomicPtr { -- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -- fmt::Debug::fmt(&self.load(Ordering::SeqCst), f) -- } --} -- --#[cfg(target_has_atomic = "ptr")] --#[stable(feature = "atomic_pointer", since = "1.24.0")] --impl fmt::Pointer for AtomicPtr { -- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -- fmt::Pointer::fmt(&self.load(Ordering::SeqCst), f) -- } --} -diff --git a/src/libcore/sync/mod.rs b/src/libcore/sync/mod.rs -deleted file mode 100644 -index 0080e0b5e4..0000000000 ---- a/src/libcore/sync/mod.rs -+++ /dev/null -@@ -1,15 +0,0 @@ --// Copyright 2015 The Rust Project Developers. See the COPYRIGHT --// file at the top-level directory of this distribution and at --// http://rust-lang.org/COPYRIGHT. --// --// Licensed under the Apache License, Version 2.0 or the MIT license --// , at your --// option. This file may not be copied, modified, or distributed --// except according to those terms. -- --//! Synchronization primitives -- --#![stable(feature = "rust1", since = "1.0.0")] -- --pub mod atomic; --- 2.11.0 From 37b61e0ca62a36269c694c64da8ba4094f7e3a2f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 16:57:40 +0200 Subject: [PATCH 0077/1566] Rustup to rustc 1.29.0-nightly (866a71325 2018-07-29) --- Cargo.toml | 3 ++ src/abi.rs | 18 +++++------ src/base.rs | 19 +++++------ src/common.rs | 4 +-- src/constant.rs | 79 +++++++++++++++++++++++++++------------------- src/lib.rs | 13 ++++---- src/pretty_clif.rs | 2 +- 7 files changed, 79 insertions(+), 59 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dc4f2d93fafc4..651fba4133ac7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,10 @@ +cargo-features = ["edition"] + [package] name = "rustc_codegen_cranelift" version = "0.1.0" authors = ["bjorn3 "] +edition = "2018" [lib] crate-type = ["dylib"] diff --git a/src/abi.rs b/src/abi.rs index 70af157e47c34..144ba167c5196 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -3,7 +3,7 @@ use std::iter; use rustc::hir; use rustc_target::spec::abi::Abi; -use prelude::*; +use crate::prelude::*; pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>) -> Signature { let sig = ty_fn_sig(tcx, fn_ty); @@ -250,12 +250,12 @@ pub fn codegen_call<'a, 'tcx: 'a>( args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, ) { - let func = ::base::trans_operand(fx, func); + let func = trans_operand(fx, func); let fn_ty = func.layout().ty; let sig = ty_fn_sig(fx.tcx, fn_ty); let return_place = if let Some((place, _)) = destination { - Some(::base::trans_place(fx, place)) + Some(trans_place(fx, place)) } else { None }; @@ -263,8 +263,8 @@ pub fn codegen_call<'a, 'tcx: 'a>( // Unpack arguments tuple for closures let args = if sig.abi == Abi::RustCall { assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); - let self_arg = ::base::trans_operand(fx, &args[0]); - let pack_arg = ::base::trans_operand(fx, &args[1]); + let self_arg = trans_operand(fx, &args[0]); + let pack_arg = trans_operand(fx, &args[1]); let mut args = Vec::new(); args.push(self_arg); match pack_arg.layout().ty.sty { @@ -281,7 +281,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( args .into_iter() .map(|arg| { - ::base::trans_operand(fx, arg) + trans_operand(fx, arg) }) .collect::>() }; @@ -319,7 +319,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( } "discriminant_value" => { assert_eq!(args.len(), 1); - let discr = ::base::trans_get_discriminant(fx, args[0], ret.layout()); + let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); ret.write_cvalue(fx, discr); } "size_of" => { @@ -351,10 +351,10 @@ pub fn codegen_call<'a, 'tcx: 'a>( }; let res = match ret.layout().ty.sty { TypeVariants::TyUint(_) => { - ::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, false, false) + crate::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, false, false) } TypeVariants::TyInt(_) => { - ::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, true, false) + crate::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, true, false) } _ => panic!(), }; diff --git a/src/base.rs b/src/base.rs index 104b948f14843..dbb562e4e5ae7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,4 +1,4 @@ -use prelude::*; +use crate::prelude::*; pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, context: &mut Context, mono_item: MonoItem<'tcx>) { let tcx = cx.tcx; @@ -33,7 +33,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); - let comments = match ::base::trans_fn(cx, &mut f, inst){ + let comments = match trans_fn(cx, &mut f, inst){ Ok(comments) => comments, Err(err) => { tcx.sess.err(&err); @@ -41,7 +41,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } }; - let mut writer = ::pretty_clif::CommentWriter(comments); + let mut writer = crate::pretty_clif::CommentWriter(comments); let mut cton = String::new(); ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &f, None).unwrap(); tcx.sess.warn(&cton); @@ -99,7 +99,7 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & }; let fx = &mut fx; - ::abi::codegen_fn_prelude(fx, start_ebb); + crate::abi::codegen_fn_prelude(fx, start_ebb); fx.bcx.ins().jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); @@ -143,13 +143,13 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & let ebb = fx.get_ebb(targets[i]); jt_data.set_entry(*value as usize, ebb); } - let mut jump_table = fx.bcx.create_jump_table(jt_data); + let jump_table = fx.bcx.create_jump_table(jt_data); fx.bcx.ins().br_table(discr, jump_table); let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); fx.bcx.ins().jump(otherwise_ebb, &[]); } TerminatorKind::Call { func, args, destination, cleanup: _ } => { - ::abi::codegen_call(fx, func, args, destination); + crate::abi::codegen_call(fx, func, args, destination); } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { fx.bcx.ins().trap(TrapCode::User(!0)); @@ -319,13 +319,13 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); - let res = ::common::cton_intcast(fx, from, from_ty, to_ty, false); + let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, false); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (TypeVariants::TyInt(_), TypeVariants::TyInt(_)) | (TypeVariants::TyInt(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); - let res = ::common::cton_intcast(fx, from, from_ty, to_ty, true); + let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, true); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } _ => return Err(format!("rval misc {:?} {:?}", operand, to_ty)), @@ -602,6 +602,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l pub fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { match place { Place::Local(local) => fx.get_local_place(*local), + Place::Promoted(promoted) => crate::constant::trans_promoted(fx, promoted.0), Place::Static(static_) => unimplemented!("static place {:?} ty {:?}", static_.def_id, static_.ty), Place::Projection(projection) => { let base = trans_place(fx, &projection.base); @@ -632,7 +633,7 @@ pub fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand< cplace.to_cvalue(fx) }, Operand::Constant(const_) => { - ::constant::trans_constant(fx, const_) + crate::constant::trans_constant(fx, const_) } } } diff --git a/src/common.rs b/src/common.rs index ba84b2d64611a..2ef9d1d6772cc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -4,7 +4,7 @@ use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::{Module, FuncId, DataId}; -use prelude::*; +use crate::prelude::*; pub type CurrentBackend = ::cranelift_simplejit::SimpleJITBackend; @@ -313,7 +313,7 @@ impl<'a, 'tcx: 'a> fmt::Debug for FunctionCx<'a, 'tcx> { writeln!(f, "{:?}", self.local_map)?; let mut clif = String::new(); - let mut writer = ::pretty_clif::CommentWriter(self.comments.clone()); + let mut writer = crate::pretty_clif::CommentWriter(self.comments.clone()); ::cranelift::codegen::write::decorate_function( &mut writer, &mut clif, diff --git a/src/constant.rs b/src/constant.rs index 60fe341927135..5520a77bad359 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,21 +1,30 @@ -use prelude::*; +use crate::prelude::*; +use rustc::ty::Const; use rustc::mir::interpret::{ConstValue, GlobalId, AllocId, read_target_uint}; use rustc_mir::interpret::{CompileTimeEvaluator, Memory, MemoryKind}; use cranelift_module::*; -pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Constant<'tcx>) -> CValue<'tcx> { - let const_val = match const_.literal { - Literal::Value { value } => fx.monomorphize(&value), - Literal::Promoted { index } => fx - .tcx - .const_eval(ParamEnv::reveal_all().and(GlobalId { - instance: fx.instance, - promoted: Some(index), - })) - .unwrap(), - }; - - let const_ = match const_val.val { +pub fn trans_promoted<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, promoted: Promoted) -> CPlace<'tcx> { + let const_ = fx + .tcx + .const_eval(ParamEnv::reveal_all().and(GlobalId { + instance: fx.instance, + promoted: Some(promoted), + })) + .unwrap(); + + let const_ = force_eval_const(fx, const_); + trans_const_place(fx, const_) +} + +pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, constant: &Constant<'tcx>) -> CValue<'tcx> { + let const_ = fx.monomorphize(&constant.literal); + let const_ = force_eval_const(fx, const_); + trans_const_value(fx, const_) +} + +fn force_eval_const<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx>, const_: &'tcx Const<'tcx>) -> &'tcx Const<'tcx> { + match const_.val { ConstValue::Unevaluated(def_id, ref substs) => { let param_env = ParamEnv::reveal_all(); let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap(); @@ -25,11 +34,11 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons }; fx.tcx.const_eval(param_env.and(cid)).unwrap() }, - _ => const_val, - }; - - fx.tcx.sess.warn(&format!("const_val: {:?} const_: {:?}", const_val, const_)); + _ => const_, + } +} +fn trans_const_value<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx Const<'tcx>) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); match ty.sty { @@ -50,24 +59,30 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons CValue::Func(func_ref, layout) } _ => { - if true { - // TODO: cranelift-module api seems to be used wrong, - // thus causing panics for some consts, so this disables it - return CValue::ByRef(fx.bcx.ins().iconst(types::I64, 0), layout); - } - let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); - let alloc = fx.tcx.const_value_to_allocation(const_); - //println!("const value: {:?} allocation: {:?}", value, alloc); - let alloc_id = memory.allocate_value(alloc.clone(), MemoryKind::Stack).unwrap(); - let data_id = get_global_for_alloc_id(fx, &memory, alloc_id); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - // TODO: does global_value return a ptr of a val? - let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); - CValue::ByRef(global_ptr, layout) + trans_const_place(fx, const_).to_cvalue(fx) } } } +fn trans_const_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx Const<'tcx>) -> CPlace<'tcx> { + let ty = fx.monomorphize(&const_.ty); + let layout = fx.layout_of(ty); + if true { + // TODO: cranelift-module api seems to be used wrong, + // thus causing panics for some consts, so this disables it + return CPlace::Addr(fx.bcx.ins().iconst(types::I64, 0), layout); + } + let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); + let alloc = fx.tcx.const_value_to_allocation(const_); + //println!("const value: {:?} allocation: {:?}", value, alloc); + let alloc_id = memory.allocate_value(alloc.clone(), MemoryKind::Stack).unwrap(); + let data_id = get_global_for_alloc_id(fx, &memory, alloc_id); + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + // TODO: does global_value return a ptr of a val? + let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); + CPlace::Addr(global_ptr, layout) +} + // If ret.1 is true, then the global didn't exist before fn define_global_for_alloc_id(fx: &mut FunctionCx, alloc_id: AllocId, todo: &mut HashMap) -> (DataId, bool) { use std::collections::hash_map::Entry; diff --git a/src/lib.rs b/src/lib.rs index c26b7cd19473f..e69c1625f3fb7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,14 +76,15 @@ mod prelude { pub use cranelift_module::{Module, Backend, DataContext, FuncId, DataId, Linkage, Writability}; pub use cranelift_simplejit::{SimpleJITBuilder, SimpleJITBackend}; - pub use abi::*; - pub use common::Variable; - pub use common::*; + pub use crate::abi::*; + pub use crate::common::Variable; + pub use crate::common::*; + pub use crate::base::{trans_operand, trans_place}; - pub use CodegenCx; + pub use crate::CodegenCx; } -use prelude::*; +use crate::prelude::*; pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -279,7 +280,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .unwrap() ); - Box::new(::OngoingCodegen { + Box::new(OngoingCodegen { product: translated_module.finish(), metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 5c38f8af11924..51c170375613e 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -4,7 +4,7 @@ use std::fmt; use cranelift::codegen::write::{FuncWriter, PlainWriter}; -use prelude::*; +use crate::prelude::*; pub struct CommentWriter(pub HashMap); From a4da89d6086b2b105fbed0922d93fa54565034d7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 17:29:39 +0200 Subject: [PATCH 0078/1566] Add Coerce and CoerceUnsized to mini_core --- mini_core.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mini_core.rs b/mini_core.rs index 9ecfd5113fffa..ca97c5cd8860e 100644 --- a/mini_core.rs +++ b/mini_core.rs @@ -5,6 +5,14 @@ #[lang="sized"] pub trait Sized {} +#[lang = "unsize"] +pub trait Unsize {} + +#[lang = "coerce_unsized"] +pub trait CoerceUnsized {} + +impl<'a, 'b: 'a, T: ?Sized+Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} + #[lang="copy"] pub unsafe trait Copy {} From 82dbd0780694bd5281f9eb93199369da56e21ee2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Jul 2018 18:20:37 +0200 Subject: [PATCH 0079/1566] Add support for calling C abi functions --- build.sh | 13 ++++++--- example.rs => examples/example.rs | 0 mini_core.rs => examples/mini_core.rs | 0 examples/mini_core_hello_world.rs | 25 +++++++++++++++++ src/abi.rs | 40 +++++++++++++++++---------- src/base.rs | 15 ++++------ src/common.rs | 4 +-- src/lib.rs | 25 +++++++++++++---- 8 files changed, 87 insertions(+), 35 deletions(-) rename example.rs => examples/example.rs (100%) rename mini_core.rs => examples/mini_core.rs (100%) create mode 100644 examples/mini_core_hello_world.rs diff --git a/build.sh b/build.sh index 724f5deedfc93..82160c6435da8 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,12 @@ cargo build || exit 1 -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so mini_core.rs --crate-name mini_core --crate-type lib -Og && -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so -L crate=. example.rs --crate-type lib -Og && -rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so ./target/libcore/src/libcore/lib.rs --crate-type lib -Og +cd examples/ -rm libmini_core.rlib libexample.rlib +RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.so -Og -L crate=. --crate-type lib" + +$RUSTC mini_core.rs --crate-name mini_core && +$RUSTC example.rs && +$RUSTC mini_core_hello_world.rs && +$RUSTC ../target/libcore/src/libcore/lib.rs + +rm *.rlib diff --git a/example.rs b/examples/example.rs similarity index 100% rename from example.rs rename to examples/example.rs diff --git a/mini_core.rs b/examples/mini_core.rs similarity index 100% rename from mini_core.rs rename to examples/mini_core.rs diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs new file mode 100644 index 0000000000000..5fc0cff08bd6a --- /dev/null +++ b/examples/mini_core_hello_world.rs @@ -0,0 +1,25 @@ +// Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs + +#![feature(no_core, unboxed_closures, start)] +#![no_core] +#![allow(dead_code)] + +extern crate mini_core; + +use mini_core::*; + +#[link(name = "c")] +extern "C" {} + +extern "C" { + fn puts(s: *const u8); +} + +#[start] +fn main(i: isize, _: *const *const u8) -> isize { + unsafe { + let (ptr, _): (*const u8, usize) = intrinsics::transmute("Hello!\0"); + puts(ptr); + } + 0 +} diff --git a/src/abi.rs b/src/abi.rs index 144ba167c5196..2c9f72d2fe1da 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -9,7 +9,8 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< let sig = ty_fn_sig(tcx, fn_ty); assert!(!sig.variadic, "Variadic function are not yet supported"); let (call_conv, inputs, _output): (CallConv, Vec, Ty) = match sig.abi { - Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), + Abi::Rust => (CallConv::Fast, sig.inputs().to_vec(), sig.output()), + Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { println!("rust-call sig: {:?} inputs: {:?} output: {:?}", sig, sig.inputs(), sig.output()); assert_eq!(sig.inputs().len(), 2); @@ -20,7 +21,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< let mut inputs: Vec = vec![sig.inputs()[0]]; inputs.extend(extra_args.into_iter()); ( - CallConv::SystemV, + CallConv::Fast, inputs, sig.output(), ) @@ -31,7 +32,17 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< }; Signature { params: Some(types::I64).into_iter() // First param is place to put return val - .chain(inputs.into_iter().map(|ty| cton_type_from_ty(tcx, ty).unwrap_or(types::I64))) + .chain(inputs.into_iter().map(|ty| { + let cton_ty = cton_type_from_ty(tcx, ty); + if let Some(cton_ty) = cton_ty { + cton_ty + } else { + if sig.abi == Abi::C { + unimplemented!("Non scalars are not yet supported for \"C\" abi"); + } + types::I64 + } + })) .map(AbiParam::new).collect(), returns: vec![], call_conv, @@ -91,17 +102,13 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); - let tcx = self.tcx; - let module = &mut self.module; - let func_id = *self.def_id_fn_id_map.entry(inst).or_insert_with(|| { - let fn_ty = inst.ty(tcx); - let sig = cton_sig_from_fn_ty(tcx, fn_ty); - let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); - let mut name = String::new(); - def_path_based_names.push_instance_as_string(inst, &mut name); - module.declare_function(&name, Linkage::Local, &sig).unwrap() - }); - module.declare_func_in_func(func_id, &mut self.bcx.func) + let fn_ty = inst.ty(self.tcx); + let sig = cton_sig_from_fn_ty(self.tcx, fn_ty); + let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(self.tcx, false, false); + let mut name = String::new(); + def_path_based_names.push_instance_as_string(inst, &mut name); + let func_id = self.module.declare_function(&name, Linkage::Import, &sig).unwrap(); + self.module.declare_func_in_func(func_id, &mut self.bcx.func) } fn lib_call( @@ -156,6 +163,11 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { } pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb: Ebb) { + match fx.self_sig().abi { + Abi::Rust | Abi::RustCall => {} + _ => unimplemented!("declared function with non \"rust\" or \"rust-call\" abi"), + } + let ret_param = fx.bcx.append_ebb_param(start_ebb, types::I64); let _ = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, diff --git a/src/base.rs b/src/base.rs index dbb562e4e5ae7..3647bcc400105 100644 --- a/src/base.rs +++ b/src/base.rs @@ -20,15 +20,13 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend &fn_ty, ); let sig = cton_sig_from_fn_ty(tcx, fn_ty); + let func_id = { - let module = &mut cx.module; - *cx.def_id_fn_id_map.entry(inst).or_insert_with(|| { - // WARNING: keep in sync with FunctionCx::get_function_ref - let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); - let mut name = String::new(); - def_path_based_names.push_instance_as_string(inst, &mut name); - module.declare_function(&name, Linkage::Local, &sig).unwrap() - }) + // WARNING: keep in sync with FunctionCx::get_function_ref + let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(cx.tcx, false, false); + let mut name = String::new(); + def_path_based_names.push_instance_as_string(inst, &mut name); + cx.module.declare_function(&name, Linkage::Export, &sig).unwrap() }; let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); @@ -84,7 +82,6 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & let mut fx = FunctionCx { tcx: cx.tcx, module: &mut cx.module, - def_id_fn_id_map: &mut cx.def_id_fn_id_map, instance, mir, bcx, diff --git a/src/common.rs b/src/common.rs index 2ef9d1d6772cc..d98818604ee77 100644 --- a/src/common.rs +++ b/src/common.rs @@ -2,7 +2,7 @@ use std::fmt; use rustc_target::spec::{HasTargetSpec, Target}; -use cranelift_module::{Module, FuncId, DataId}; +use cranelift_module::{Module, DataId}; use crate::prelude::*; @@ -295,7 +295,6 @@ pub fn cton_intcast<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, fro pub struct FunctionCx<'a, 'tcx: 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, - pub def_id_fn_id_map: &'a mut HashMap, FuncId>, pub instance: Instance<'tcx>, pub mir: &'tcx Mir<'tcx>, pub param_substs: &'tcx Substs<'tcx>, @@ -308,7 +307,6 @@ pub struct FunctionCx<'a, 'tcx: 'a> { 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)?; diff --git a/src/lib.rs b/src/lib.rs index e69c1625f3fb7..66d2e662c8fab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,7 +89,6 @@ use crate::prelude::*; pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, - pub def_id_fn_id_map: &'a mut HashMap, FuncId>, pub constants: HashMap, } @@ -225,13 +224,11 @@ impl CodegenBackend for CraneliftCodegenBackend { let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()).unwrap().finish(flags); let mut module: Module = Module::new(SimpleJITBuilder::new()); let mut context = Context::new(); - let mut def_id_fn_id_map = HashMap::new(); { let mut cx = CodegenCx { tcx, module: &mut module, - def_id_fn_id_map: &mut def_id_fn_id_map, constants: HashMap::new(), }; @@ -251,12 +248,30 @@ impl CodegenBackend for CraneliftCodegenBackend { module.finalize_all(); tcx.sess.warn("Finalized everything"); - for (inst, func_id) in def_id_fn_id_map.iter() { + for mono_item in + collector::collect_crate_mono_items( + tcx, + collector::MonoItemCollectionMode::Eager + ).0 { + + let inst = match mono_item { + MonoItem::Fn(inst) => inst, + _ => continue, + }; + //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" { continue; } - let finalized_function: *const u8 = module.finalize_function(*func_id); + + let fn_ty = inst.ty(tcx); + let sig = cton_sig_from_fn_ty(tcx, fn_ty); + let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); + let mut name = String::new(); + def_path_based_names.push_instance_as_string(inst, &mut name); + let func_id = module.declare_function(&name, Linkage::Import, &sig).unwrap(); + + let finalized_function: *const u8 = module.finalize_function(func_id); /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; let mut res = 0u32; f(&mut res); From f0018082493857e744229bb8e2718a62224f45b0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Jul 2018 12:25:16 +0200 Subject: [PATCH 0080/1566] Run rustfmt 0.9.0-nightly (69ad879 2018-07-27) --- examples/example.rs | 32 ++--- examples/mini_core.rs | 40 ++++-- src/abi.rs | 132 ++++++++++++------ src/base.rs | 312 +++++++++++++++++++++++++++++++----------- src/common.rs | 144 +++++++++++-------- src/constant.rs | 78 +++++++---- src/lib.rs | 175 ++++++++++++----------- 7 files changed, 599 insertions(+), 314 deletions(-) diff --git a/examples/example.rs b/examples/example.rs index 1f9a5e0755b46..e9896ef6c7594 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -62,16 +62,8 @@ fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { ( - a as u8, - a as u16, - a as u32, - a as usize, - a as i8, - a as i16, - a as i32, - a as isize, - b as u8, - b as u32 + a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, + b as u32, ) } @@ -86,9 +78,7 @@ fn debug_tuple() -> DebugTuple { } fn size_of() -> usize { - unsafe { - intrinsics::size_of::() - } + unsafe { intrinsics::size_of::() } } fn use_size_of() -> usize { @@ -111,31 +101,27 @@ fn use_const() -> u8 { } fn call_closure_3arg() { - (|_, _, _| { - - })(0u8, 42u16, 0u8) + (|_, _, _| {})(0u8, 42u16, 0u8) } fn call_closure_2arg() { - (|_, _| { - - })(0u8, 42u16) + (|_, _| {})(0u8, 42u16) } struct IsNotEmpty; -impl<'a, 'b> FnOnce<(&'a &'b [u16], )> for IsNotEmpty { +impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty { type Output = bool; #[inline] - extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16], )) -> bool { + extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> bool { self.call_mut(arg) } } -impl<'a, 'b> FnMut<(&'a &'b [u16], )> for IsNotEmpty { +impl<'a, 'b> FnMut<(&'a &'b [u16],)> for IsNotEmpty { #[inline] - extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16], )) -> bool { + extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16],)) -> bool { true } } diff --git a/examples/mini_core.rs b/examples/mini_core.rs index ca97c5cd8860e..ff22aad5a65d0 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -2,7 +2,7 @@ #![no_core] #![allow(dead_code)] -#[lang="sized"] +#[lang = "sized"] pub trait Sized {} #[lang = "unsize"] @@ -11,9 +11,9 @@ pub trait Unsize {} #[lang = "coerce_unsized"] pub trait CoerceUnsized {} -impl<'a, 'b: 'a, T: ?Sized+Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} +impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} -#[lang="copy"] +#[lang = "copy"] pub unsafe trait Copy {} unsafe impl Copy for bool {} @@ -30,10 +30,10 @@ unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl Copy for *const T {} -#[lang="freeze"] +#[lang = "freeze"] trait Freeze {} -#[lang="mul"] +#[lang = "mul"] pub trait Mul { type Output; @@ -49,7 +49,7 @@ impl Mul for u8 { } } -#[lang="bitor"] +#[lang = "bitor"] pub trait BitOr { type Output; @@ -80,18 +80,30 @@ pub trait PartialEq { } impl PartialEq for u8 { - fn eq(&self, other: &u8) -> bool { (*self) == (*other) } - fn ne(&self, other: &u8) -> bool { (*self) != (*other) } + fn eq(&self, other: &u8) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u8) -> bool { + (*self) != (*other) + } } impl PartialEq for char { - fn eq(&self, other: &char) -> bool { (*self) == (*other) } - fn ne(&self, other: &char) -> bool { (*self) != (*other) } + fn eq(&self, other: &char) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &char) -> bool { + (*self) != (*other) + } } impl PartialEq for *const T { - fn eq(&self, other: &*const T) -> bool { *self == *other } - fn ne(&self, other: &*const T) -> bool { *self != *other } + fn eq(&self, other: &*const T) -> bool { + *self == *other + } + fn ne(&self, other: &*const T) -> bool { + *self != *other + } } #[lang = "fn_once"] @@ -104,11 +116,11 @@ pub trait FnOnce { #[lang = "fn_mut"] #[rustc_paren_sugar] -pub trait FnMut : FnOnce { +pub trait FnMut: FnOnce { extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; } -#[lang="panic"] +#[lang = "panic"] pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { loop {} } diff --git a/src/abi.rs b/src/abi.rs index 2c9f72d2fe1da..3931ef4a3f1de 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -5,14 +5,22 @@ use rustc_target::spec::abi::Abi; use crate::prelude::*; -pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>) -> Signature { +pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + fn_ty: Ty<'tcx>, +) -> Signature { let sig = ty_fn_sig(tcx, fn_ty); assert!(!sig.variadic, "Variadic function are not yet supported"); let (call_conv, inputs, _output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::Fast, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { - println!("rust-call sig: {:?} inputs: {:?} output: {:?}", sig, sig.inputs(), sig.output()); + println!( + "rust-call sig: {:?} inputs: {:?} output: {:?}", + sig, + sig.inputs(), + sig.output() + ); assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().sty { ty::TyTuple(ref tupled_arguments) => tupled_arguments, @@ -20,11 +28,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< }; let mut inputs: Vec = vec![sig.inputs()[0]]; inputs.extend(extra_args.into_iter()); - ( - CallConv::Fast, - inputs, - sig.output(), - ) + (CallConv::Fast, inputs, sig.output()) } Abi::System => bug!("system abi should be selected elsewhere"), Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), @@ -50,10 +54,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty< } } -fn ty_fn_sig<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - ty: Ty<'tcx> -) -> ty::FnSig<'tcx> { +fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<'tcx> { let sig = match ty.sty { ty::TyFnDef(..) | // Shims currently have type TyFnPtr. Not sure this should remain. @@ -104,11 +105,16 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_ty = inst.ty(self.tcx); let sig = cton_sig_from_fn_ty(self.tcx, fn_ty); - let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(self.tcx, false, false); + let def_path_based_names = + ::rustc_mir::monomorphize::item::DefPathBasedNames::new(self.tcx, false, false); let mut name = String::new(); def_path_based_names.push_instance_as_string(inst, &mut name); - let func_id = self.module.declare_function(&name, Linkage::Import, &sig).unwrap(); - self.module.declare_func_in_func(func_id, &mut self.bcx.func) + let func_id = self + .module + .declare_function(&name, Linkage::Import, &sig) + .unwrap(); + self.module + .declare_func_in_func(func_id, &mut self.bcx.func) } fn lib_call( @@ -124,8 +130,13 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { call_conv: CallConv::SystemV, argument_bytes: None, }; - let func_id = self.module.declare_function(&name, Linkage::Import, &sig).unwrap(); - let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func); + let func_id = self + .module + .declare_function(&name, Linkage::Import, &sig) + .unwrap(); + let func_ref = self + .module + .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); if output_ty.is_none() { return None; @@ -135,8 +146,20 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { Some(results[0]) } - pub fn easy_call(&mut self, name: &str, args: &[CValue<'tcx>], return_ty: Ty<'tcx>) -> CValue<'tcx> { - let (input_tys, args): (Vec<_>, Vec<_>) = args.into_iter().map(|arg| (self.cton_type(arg.layout().ty).unwrap(), arg.load_value(self))).unzip(); + pub fn easy_call( + &mut self, + name: &str, + args: &[CValue<'tcx>], + return_ty: Ty<'tcx>, + ) -> CValue<'tcx> { + let (input_tys, args): (Vec<_>, Vec<_>) = args + .into_iter() + .map(|arg| { + ( + self.cton_type(arg.layout().ty).unwrap(), + arg.load_value(self), + ) + }).unzip(); let return_layout = self.layout_of(return_ty); let return_ty = if let TypeVariants::TyTuple(tup) = return_ty.sty { if !tup.is_empty() { @@ -209,7 +232,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb }).collect::>(); let ret_layout = fx.layout_of(fx.return_type()); - fx.local_map.insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); + fx.local_map + .insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); @@ -284,17 +308,18 @@ pub fn codegen_call<'a, 'tcx: 'a>( for (i, _) in tupled_arguments.iter().enumerate() { args.push(pack_arg.value_field(fx, mir::Field::new(i))); } - }, + } _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), } - println!("{:?} {:?}", pack_arg.layout().ty, args.iter().map(|a|a.layout().ty).collect::>()); + println!( + "{:?} {:?}", + pack_arg.layout().ty, + args.iter().map(|a| a.layout().ty).collect::>() + ); args } else { - args - .into_iter() - .map(|arg| { - trans_operand(fx, arg) - }) + args.into_iter() + .map(|arg| trans_operand(fx, arg)) .collect::>() }; @@ -326,7 +351,11 @@ pub fn codegen_call<'a, 'tcx: 'a>( let dst = args[1]; let count = args[2].load_value(fx); let byte_amount = fx.bcx.ins().imul(count, elem_size); - fx.easy_call("memmove", &[dst, src, CValue::ByVal(byte_amount, usize_layout)], nil_ty); + fx.easy_call( + "memmove", + &[dst, src, CValue::ByVal(byte_amount, usize_layout)], + nil_ty, + ); unimplemented!("copy"); } "discriminant_value" => { @@ -362,12 +391,24 @@ pub fn codegen_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; let res = match ret.layout().ty.sty { - TypeVariants::TyUint(_) => { - crate::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, false, false) - } - TypeVariants::TyInt(_) => { - crate::base::trans_int_binop(fx, bin_op, args[0], args[1], ret.layout().ty, true, false) - } + TypeVariants::TyUint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + false, + ), _ => panic!(), }; ret.write_cvalue(fx, res); @@ -402,7 +443,10 @@ pub fn codegen_call<'a, 'tcx: 'a>( let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); } - _ => fx.tcx.sess.fatal(&format!("unsupported intrinsic {}", intrinsic)), + _ => fx + .tcx + .sess + .fatal(&format!("unsupported intrinsic {}", intrinsic)), } if let Some((_, dest)) = *destination { let ret_ebb = fx.get_ebb(dest); @@ -419,13 +463,15 @@ pub fn codegen_call<'a, 'tcx: 'a>( None => fx.bcx.ins().iconst(types::I64, 0), }; - let call_args = Some(return_ptr).into_iter().chain(args.into_iter().map(|arg| { - if fx.cton_type(arg.layout().ty).is_some() { - arg.load_value(fx) - } else { - arg.force_stack(fx) - } - })).collect::>(); + let call_args = Some(return_ptr) + .into_iter() + .chain(args.into_iter().map(|arg| { + if fx.cton_type(arg.layout().ty).is_some() { + arg.load_value(fx) + } else { + arg.force_stack(fx) + } + })).collect::>(); match func { CValue::Func(func, _) => { @@ -434,7 +480,9 @@ pub fn codegen_call<'a, 'tcx: 'a>( func => { let func_ty = func.layout().ty; let func = func.load_value(fx); - let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, func_ty)); + let sig = fx + .bcx + .import_signature(cton_sig_from_fn_ty(fx.tcx, func_ty)); fx.bcx.ins().call_indirect(sig, func, &call_args); } } diff --git a/src/base.rs b/src/base.rs index 3647bcc400105..4970eef10d859 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,6 +1,10 @@ use crate::prelude::*; -pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, context: &mut Context, mono_item: MonoItem<'tcx>) { +pub fn trans_mono_item<'a, 'tcx: 'a>( + cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, + context: &mut Context, + mono_item: MonoItem<'tcx>, +) { let tcx = cx.tcx; match mono_item { @@ -11,7 +15,11 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend } => { let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); - tcx.sess.warn(&format!("{:?}:\n\n{}", inst, String::from_utf8_lossy(&mir.into_inner()))); + tcx.sess.warn(&format!( + "{:?}:\n\n{}", + inst, + String::from_utf8_lossy(&mir.into_inner()) + )); let fn_ty = inst.ty(tcx); let fn_ty = tcx.subst_and_normalize_erasing_regions( @@ -23,15 +31,23 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let func_id = { // WARNING: keep in sync with FunctionCx::get_function_ref - let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(cx.tcx, false, false); + let def_path_based_names = + ::rustc_mir::monomorphize::item::DefPathBasedNames::new( + cx.tcx, false, false, + ); let mut name = String::new(); def_path_based_names.push_instance_as_string(inst, &mut name); - cx.module.declare_function(&name, Linkage::Export, &sig).unwrap() + cx.module + .declare_function(&name, Linkage::Export, &sig) + .unwrap() }; - let mut f = Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); + let mut f = Function::with_name_signature( + ExternalName::user(0, func_id.index() as u32), + sig, + ); - let comments = match trans_fn(cx, &mut f, inst){ + let comments = match trans_fn(cx, &mut f, inst) { Ok(comments) => comments, Err(err) => { tcx.sess.err(&err); @@ -41,7 +57,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend let mut writer = crate::pretty_clif::CommentWriter(comments); let mut cton = String::new(); - ::cranelift::codegen::write::decorate_function(&mut writer, &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()); @@ -49,8 +66,15 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend Ok(_) => {} Err(err) => { tcx.sess.err(&format!("{:?}", err)); - 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)); + 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)); } } @@ -60,14 +84,27 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend context.clear(); } - inst => cx.tcx.sess.warn(&format!("Unimplemented instance {:?}", inst)), - } - MonoItem::Static(def_id) => cx.tcx.sess.err(&format!("Unimplemented static mono item {:?}", def_id)), - MonoItem::GlobalAsm(node_id) => cx.tcx.sess.err(&format!("Unimplemented global asm mono item {:?}", node_id)), + inst => cx + .tcx + .sess + .warn(&format!("Unimplemented instance {:?}", inst)), + }, + MonoItem::Static(def_id) => cx + .tcx + .sess + .err(&format!("Unimplemented static mono item {:?}", def_id)), + MonoItem::GlobalAsm(node_id) => cx + .tcx + .sess + .err(&format!("Unimplemented global asm mono item {:?}", node_id)), } } -pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>) -> Result, String> { +pub fn trans_fn<'a, 'tcx: 'a>( + cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, + f: &mut Function, + instance: Instance<'tcx>, +) -> Result, String> { let mir = cx.tcx.optimized_mir(instance.def_id()); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -98,7 +135,9 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & crate::abi::codegen_fn_prelude(fx, start_ebb); - fx.bcx.ins().jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); + fx.bcx + .ins() + .jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { let ebb = fx.get_ebb(bb); @@ -110,7 +149,11 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & } let mut terminator_head = "\n".to_string(); - bb_data.terminator().kind.fmt_head(&mut terminator_head).unwrap(); + bb_data + .terminator() + .kind + .fmt_head(&mut terminator_head) + .unwrap(); let inst = fx.bcx.func.layout.last_inst(ebb).unwrap(); fx.add_comment(inst, terminator_head); @@ -122,7 +165,13 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & TerminatorKind::Return => { fx.bcx.ins().return_(&[]); } - TerminatorKind::Assert { cond, expected, msg: _, target, cleanup: _ } => { + TerminatorKind::Assert { + cond, + expected, + msg: _, + target, + cleanup: _, + } => { let cond = trans_operand(fx, cond).load_value(fx); let target = fx.get_ebb(*target); if *expected { @@ -133,7 +182,12 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & fx.bcx.ins().trap(TrapCode::User(!0)); } - TerminatorKind::SwitchInt { discr, switch_ty: _, values, targets } => { + TerminatorKind::SwitchInt { + discr, + switch_ty: _, + values, + targets, + } => { let discr = trans_operand(fx, discr).load_value(fx); let mut jt_data = JumpTableData::new(); for (i, value) in values.iter().enumerate() { @@ -145,15 +199,20 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); fx.bcx.ins().jump(otherwise_ebb, &[]); } - TerminatorKind::Call { func, args, destination, cleanup: _ } => { + TerminatorKind::Call { + func, + args, + destination, + cleanup: _, + } => { crate::abi::codegen_call(fx, func, args, destination); } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { fx.bcx.ins().trap(TrapCode::User(!0)); } - TerminatorKind::Yield { .. } | - TerminatorKind::FalseEdges { .. } | - TerminatorKind::FalseUnwind { .. } => { + TerminatorKind::Yield { .. } + | TerminatorKind::FalseEdges { .. } + | TerminatorKind::FalseUnwind { .. } => { bug!("shouldn't exist at trans {:?}", bb_data.terminator()); } TerminatorKind::Drop { target, .. } | TerminatorKind::DropAndReplace { target, .. } => { @@ -174,14 +233,21 @@ pub fn trans_fn<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: & Ok(fx.comments.clone()) } -fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: &Statement<'tcx>) -> Result<(), String> { +fn trans_stmt<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + cur_ebb: Ebb, + stmt: &Statement<'tcx>, +) -> Result<(), String> { fx.tcx.sess.warn(&format!("stmt {:?}", stmt)); let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); fx.add_comment(inst, format!("{:?}", stmt)); match &stmt.kind { - StatementKind::SetDiscriminant { place, variant_index } => { + StatementKind::SetDiscriminant { + place, + variant_index, + } => { let place = trans_place(fx, place); let layout = place.layout(); if layout.for_variant(&*fx, *variant_index).abi == layout::Abi::Uninhabited { @@ -193,7 +259,10 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & } layout::Variants::Tagged { .. } => { let ptr = place.place_field(fx, mir::Field::new(0)); - let to = layout.ty.ty_adt_def().unwrap() + let to = layout + .ty + .ty_adt_def() + .unwrap() .discriminant_for_variant(fx.tcx, *variant_index) .val; let discr = CValue::const_val(fx, ptr.layout().ty, to as u64 as i64); @@ -288,7 +357,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & UnOp::Neg => match ty.sty { TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val), _ => unimplemented!("un op Neg for {:?}", ty), - } + }, }; lval.write_cvalue(fx, CValue::ByVal(res, layout)); } @@ -306,50 +375,66 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & let operand = trans_operand(fx, operand); let from_ty = operand.layout().ty; match (&from_ty.sty, &to_ty.sty) { - (TypeVariants::TyRef(..), TypeVariants::TyRef(..)) | - (TypeVariants::TyRef(..), TypeVariants::TyRawPtr(..)) | - (TypeVariants::TyRawPtr(..), TypeVariants::TyRef(..)) | - (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { + (TypeVariants::TyRef(..), TypeVariants::TyRef(..)) + | (TypeVariants::TyRef(..), TypeVariants::TyRawPtr(..)) + | (TypeVariants::TyRawPtr(..), TypeVariants::TyRef(..)) + | (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (TypeVariants::TyChar, TypeVariants::TyUint(_)) | - (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | - (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { + (TypeVariants::TyChar, TypeVariants::TyUint(_)) + | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) + | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, false); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (TypeVariants::TyInt(_), TypeVariants::TyInt(_)) | - (TypeVariants::TyInt(_), TypeVariants::TyUint(_)) => { + (TypeVariants::TyInt(_), TypeVariants::TyInt(_)) + | (TypeVariants::TyInt(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, true); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } _ => return Err(format!("rval misc {:?} {:?}", operand, to_ty)), } - }, - Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty), - Rvalue::Cast(CastKind::Unsize, operand, ty) => return Err(format!("rval unsize {:?} {:?}", operand, ty)), + } + Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => { + unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty) + } + Rvalue::Cast(CastKind::Unsize, operand, ty) => { + return Err(format!("rval unsize {:?} {:?}", operand, ty)) + } Rvalue::Discriminant(place) => { let place = trans_place(fx, place).to_cvalue(fx); let discr = trans_get_discriminant(fx, place, dest_layout); lval.write_cvalue(fx, discr); } - Rvalue::Repeat(operand, times) => unimplemented!("rval repeat {:?} {:?}", operand, times), + Rvalue::Repeat(operand, times) => { + unimplemented!("rval repeat {:?} {:?}", operand, times) + } Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), Rvalue::NullaryOp(NullOp::SizeOf, ty) => unimplemented!("rval size_of {:?}", ty), Rvalue::Aggregate(_, _) => bug!("shouldn't exist at trans {:?}", rval), } } - StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop | StatementKind::ReadForMatch(_) | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) | StatementKind::UserAssertTy(_, _) => {} + StatementKind::StorageLive(_) + | StatementKind::StorageDead(_) + | StatementKind::Nop + | StatementKind::ReadForMatch(_) + | StatementKind::Validate(_, _) + | StatementKind::EndRegion(_) + | StatementKind::UserAssertTy(_, _) => {} StatementKind::InlineAsm { .. } => fx.tcx.sess.fatal("Inline assembly is not supported"), } Ok(()) } -pub fn trans_get_discriminant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, value: CValue<'tcx>, dest_layout: TyLayout<'tcx>) -> CValue<'tcx> { +pub fn trans_get_discriminant<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + value: CValue<'tcx>, + dest_layout: TyLayout<'tcx>, +) -> CValue<'tcx> { let layout = value.layout(); if layout.abi == layout::Abi::Uninhabited { @@ -357,13 +442,12 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, value } match layout.variants { layout::Variants::Single { index } => { - let discr_val = layout.ty.ty_adt_def().map_or( - index as u128, - |def| def.discriminant_for_variant(fx.tcx, index).val); + let discr_val = layout.ty.ty_adt_def().map_or(index as u128, |def| { + def.discriminant_for_variant(fx.tcx, index).val + }); return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); } - layout::Variants::Tagged { .. } | - layout::Variants::NicheFilling { .. } => {}, + layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {} } let discr = value.value_field(fx, mir::Field::new(0)); @@ -374,7 +458,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, value layout::Variants::Tagged { ref tag, .. } => { let signed = match tag.value { layout::Int(_, signed) => signed, - _ => false + _ => false, }; let val = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, signed); return CValue::ByVal(val, dest_layout); @@ -388,9 +472,18 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, value let niche_llty = fx.cton_type(discr_ty).unwrap(); if niche_variants.start() == niche_variants.end() { let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); - let b = fx.bcx.ins().icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); - let if_true = fx.bcx.ins().iconst(dest_cton_ty, *niche_variants.start() as u64 as i64); - let if_false = fx.bcx.ins().iconst(dest_cton_ty, dataful_variant as u64 as i64); + let b = fx + .bcx + .ins() + .icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); + let if_true = fx + .bcx + .ins() + .iconst(dest_cton_ty, *niche_variants.start() as u64 as i64); + let if_false = fx + .bcx + .ins() + .iconst(dest_cton_ty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } else { @@ -398,9 +491,16 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, value let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); let lldiscr = fx.bcx.ins().isub(lldiscr, delta); - let b = fx.bcx.ins().icmp_imm(IntCC::UnsignedLessThanOrEqual, lldiscr, *niche_variants.end() as u64 as i64); + let b = fx.bcx.ins().icmp_imm( + IntCC::UnsignedLessThanOrEqual, + lldiscr, + *niche_variants.end() as u64 as i64, + ); let if_true = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, false); - let if_false = fx.bcx.ins().iconst(niche_llty, dataful_variant as u64 as i64); + let if_false = fx + .bcx + .ins() + .iconst(niche_llty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } @@ -447,7 +547,13 @@ macro_rules! binop_match { }} } -fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_bool_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ty: Ty<'tcx>, +) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, false, lhs, rhs, ty, "bool"; Add (_) bug; @@ -474,7 +580,15 @@ fn trans_bool_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, res } -pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>, signed: bool, _checked: bool) -> CValue<'tcx> { +pub fn trans_int_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ty: Ty<'tcx>, + signed: bool, + _checked: bool, +) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, signed, lhs, rhs, ty, "int/uint"; Add (_) iadd; @@ -509,7 +623,13 @@ pub fn trans_int_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinO res } -fn trans_float_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_float_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ty: Ty<'tcx>, +) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, false, lhs, rhs, ty, "float"; Add (_) fadd; @@ -544,7 +664,13 @@ fn trans_float_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, res } -fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>) -> CValue<'tcx> { +fn trans_char_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ty: Ty<'tcx>, +) -> CValue<'tcx> { let res = binop_match! { fx, bin_op, false, lhs, rhs, ty, "char"; Add (_) bug; @@ -571,7 +697,14 @@ fn trans_char_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, res } -fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>, _checked: bool) -> CValue<'tcx> { +fn trans_ptr_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ty: Ty<'tcx>, + _checked: bool, +) -> CValue<'tcx> { binop_match! { fx, bin_op, false, lhs, rhs, ty, "ptr"; Add (_) bug; @@ -596,41 +729,66 @@ fn trans_ptr_binop<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, l } } -pub fn trans_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, place: &Place<'tcx>) -> CPlace<'tcx> { +pub fn trans_place<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + place: &Place<'tcx>, +) -> CPlace<'tcx> { match place { Place::Local(local) => fx.get_local_place(*local), Place::Promoted(promoted) => crate::constant::trans_promoted(fx, promoted.0), - Place::Static(static_) => unimplemented!("static place {:?} ty {:?}", static_.def_id, static_.ty), + Place::Static(static_) => { + unimplemented!("static place {:?} ty {:?}", static_.def_id, static_.ty) + } Place::Projection(projection) => { let base = trans_place(fx, &projection.base); match projection.elem { - ProjectionElem::Deref => { - CPlace::Addr(base.to_cvalue(fx).load_value(fx), fx.layout_of(place.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx))) - } - ProjectionElem::Field(field, _ty) => { - base.place_field(fx, field) - } - ProjectionElem::Index(local) => unimplemented!("projection index {:?} {:?}", projection.base, local), - ProjectionElem::ConstantIndex { offset, min_length: _, from_end: false } => unimplemented!("projection const index {:?} offset {:?} not from end", projection.base, offset), - ProjectionElem::ConstantIndex { offset, min_length: _, from_end: true } => unimplemented!("projection const index {:?} offset {:?} from end", projection.base, offset), - ProjectionElem::Subslice { from, to } => unimplemented!("projection subslice {:?} from {} to {}", projection.base, from, to), - ProjectionElem::Downcast(_adt_def, variant) => { - base.downcast_variant(fx, variant) + ProjectionElem::Deref => CPlace::Addr( + base.to_cvalue(fx).load_value(fx), + fx.layout_of(place.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx)), + ), + ProjectionElem::Field(field, _ty) => base.place_field(fx, field), + ProjectionElem::Index(local) => { + unimplemented!("projection index {:?} {:?}", projection.base, local) } + ProjectionElem::ConstantIndex { + offset, + min_length: _, + from_end: false, + } => unimplemented!( + "projection const index {:?} offset {:?} not from end", + projection.base, + offset + ), + ProjectionElem::ConstantIndex { + offset, + min_length: _, + from_end: true, + } => unimplemented!( + "projection const index {:?} offset {:?} from end", + projection.base, + offset + ), + ProjectionElem::Subslice { from, to } => unimplemented!( + "projection subslice {:?} from {} to {}", + projection.base, + from, + to + ), + ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant), } } } } -pub fn trans_operand<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx>, operand: &Operand<'tcx>) -> CValue<'tcx> { +pub fn trans_operand<'a, 'tcx>( + fx: &mut FunctionCx<'a, 'tcx>, + operand: &Operand<'tcx>, +) -> CValue<'tcx> { match operand { - Operand::Move(place) | - Operand::Copy(place) => { + Operand::Move(place) | Operand::Copy(place) => { let cplace = trans_place(fx, place); cplace.to_cvalue(fx) - }, - Operand::Constant(const_) => { - crate::constant::trans_constant(fx, const_) } + Operand::Constant(const_) => crate::constant::trans_constant(fx, const_), } } diff --git a/src/common.rs b/src/common.rs index d98818604ee77..421b2cb2d03b0 100644 --- a/src/common.rs +++ b/src/common.rs @@ -2,7 +2,7 @@ use std::fmt; use rustc_target::spec::{HasTargetSpec, Target}; -use cranelift_module::{Module, DataId}; +use cranelift_module::{DataId, Module}; use crate::prelude::*; @@ -21,36 +21,33 @@ impl EntityRef for Variable { } } -pub fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> Option { +pub fn cton_type_from_ty<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + ty: Ty<'tcx>, +) -> Option { Some(match ty.sty { TypeVariants::TyBool => types::I8, - TypeVariants::TyUint(size) => { - match size { - UintTy::U8 => types::I8, - UintTy::U16 => types::I16, - UintTy::U32 => types::I32, - UintTy::U64 => types::I64, - UintTy::U128 => unimplemented!("u128"), - UintTy::Usize => types::I64, - } - } - TypeVariants::TyInt(size) => { - match size { - IntTy::I8 => types::I8, - IntTy::I16 => types::I16, - IntTy::I32 => types::I32, - IntTy::I64 => types::I64, - IntTy::I128 => unimplemented!("i128"), - IntTy::Isize => types::I64, - } - } + TypeVariants::TyUint(size) => match size { + UintTy::U8 => types::I8, + UintTy::U16 => types::I16, + UintTy::U32 => types::I32, + UintTy::U64 => types::I64, + UintTy::U128 => unimplemented!("u128"), + UintTy::Usize => types::I64, + }, + TypeVariants::TyInt(size) => match size { + IntTy::I8 => types::I8, + IntTy::I16 => types::I16, + IntTy::I32 => types::I32, + IntTy::I64 => types::I64, + IntTy::I128 => unimplemented!("i128"), + IntTy::Isize => types::I64, + }, TypeVariants::TyChar => types::I32, - TypeVariants::TyFloat(size) => { - match size { - FloatTy::F32 => types::I32, - FloatTy::F64 => types::I64, - } - } + TypeVariants::TyFloat(size) => match size { + FloatTy::F32 => types::I32, + FloatTy::F64 => types::I64, + }, TypeVariants::TyFnPtr(_) => types::I64, TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) | TypeVariants::TyRef(_, ty, _) => { if ty.is_sized(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { @@ -59,7 +56,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx> return None; } } - TypeVariants::TyParam(_) => bug!("{:?}: {:?}", ty, ty.sty), + TypeVariants::TyParam(_) => bug!("{:?}: {:?}", ty, ty.sty), _ => return None, }) } @@ -68,7 +65,7 @@ fn codegen_field<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, base: Value, layout: TyLayout<'tcx>, - field: mir::Field + field: mir::Field, ) -> (Value, TyLayout<'tcx>) { let field_offset = layout.fields.offset(field.index()); let field_ty = layout.field(&*fx, field.index()); @@ -91,13 +88,14 @@ pub enum CValue<'tcx> { impl<'tcx> CValue<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { - CValue::ByRef(_, layout) | - CValue::ByVal(_, layout) | - CValue::Func(_, layout) => layout + CValue::ByRef(_, layout) | CValue::ByVal(_, layout) | CValue::Func(_, layout) => layout, } } - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value where 'tcx: 'a { + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value + where + 'tcx: 'a, + { match self { CValue::ByRef(value, _layout) => value, CValue::ByVal(value, layout) => { @@ -116,16 +114,19 @@ impl<'tcx> CValue<'tcx> { } } - pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value where 'tcx: 'a{ + pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value + where + 'tcx: 'a, + { match self { CValue::ByRef(addr, layout) => { - let cton_ty = fx.cton_type(layout.ty).expect(&format!("load_value of type {:?}", layout.ty)); + let cton_ty = fx + .cton_type(layout.ty) + .expect(&format!("load_value of type {:?}", layout.ty)); fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, - CValue::Func(func, _layout) => { - fx.bcx.ins().func_addr(types::I64, func) - } + CValue::Func(func, _layout) => fx.bcx.ins().func_addr(types::I64, func), } } @@ -137,7 +138,10 @@ impl<'tcx> CValue<'tcx> { } } - pub fn value_field<'a>(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CValue<'tcx> where 'tcx: 'a { + pub fn value_field<'a>(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CValue<'tcx> + where + 'tcx: 'a, + { let (base, layout) = match self { CValue::ByRef(addr, layout) => (addr, layout), _ => bug!("place_field for {:?}", self), @@ -147,7 +151,14 @@ impl<'tcx> CValue<'tcx> { CValue::ByRef(field_ptr, field_layout) } - pub fn const_val<'a>(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>, const_val: i64) -> CValue<'tcx> where 'tcx: 'a { + pub fn const_val<'a>( + fx: &mut FunctionCx<'a, 'tcx>, + ty: Ty<'tcx>, + const_val: i64, + ) -> CValue<'tcx> + where + 'tcx: 'a, + { let cton_ty = fx.cton_type(ty).unwrap(); let layout = fx.layout_of(ty); CValue::ByVal(fx.bcx.ins().iconst(cton_ty, const_val), layout) @@ -172,12 +183,15 @@ pub enum CPlace<'tcx> { impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { - CPlace::Var(_, layout) | - CPlace::Addr(_, layout) => layout, + CPlace::Var(_, layout) | CPlace::Addr(_, layout) => layout, } } - pub fn from_stack_slot(fx: &mut FunctionCx<'a, 'tcx>, stack_slot: StackSlot, ty: Ty<'tcx>) -> CPlace<'tcx> { + pub fn from_stack_slot( + fx: &mut FunctionCx<'a, 'tcx>, + stack_slot: StackSlot, + ty: Ty<'tcx>, + ) -> CPlace<'tcx> { let layout = fx.layout_of(ty); CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0), layout) } @@ -198,23 +212,25 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue<'tcx>) { match (&self.layout().ty.sty, &from.layout().ty.sty) { - (TypeVariants::TyRef(_, t, dest_mut), TypeVariants::TyRef(_, u, src_mut)) if ( - if *dest_mut != ::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { + (TypeVariants::TyRef(_, t, dest_mut), TypeVariants::TyRef(_, u, src_mut)) + if (if *dest_mut != ::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { false } else if t != u { false } else { true - } - ) => { + }) => + { // &mut T -> &T is allowed // &'a T -> &'b T is allowed } _ => { assert_eq!( - self.layout().ty, from.layout().ty, + self.layout().ty, + from.layout().ty, "Can't write value of incompatible type to place {:?} {:?}\n\n{:#?}", - self.layout().ty.sty, from.layout().ty.sty, + self.layout().ty.sty, + from.layout().ty.sty, fx, ); } @@ -224,7 +240,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Var(var, _) => { let data = from.load_value(fx); fx.bcx.def_var(var, data) - }, + } CPlace::Addr(addr, layout) => { let size = layout.size.bytes() as i32; @@ -235,17 +251,26 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let from = from.expect_byref(); let mut offset = 0; while size - offset >= 8 { - let byte = fx.bcx.ins().load(types::I64, MemFlags::new(), from.0, offset); + let byte = fx + .bcx + .ins() + .load(types::I64, MemFlags::new(), from.0, offset); fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); offset += 8; } while size - offset >= 4 { - let byte = fx.bcx.ins().load(types::I32, MemFlags::new(), from.0, offset); + let byte = fx + .bcx + .ins() + .load(types::I32, MemFlags::new(), from.0, offset); fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); offset += 4; } while offset < size { - let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from.0, offset); + let byte = fx + .bcx + .ins() + .load(types::I8, MemFlags::new(), from.0, offset); fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); offset += 1; } @@ -275,7 +300,13 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } -pub fn cton_intcast<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, val: Value, from: Ty<'tcx>, to: Ty<'tcx>, signed: bool) -> Value { +pub fn cton_intcast<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + val: Value, + from: Ty<'tcx>, + to: Ty<'tcx>, + signed: bool, +) -> Value { let from = fx.cton_type(from).unwrap(); let to = fx.cton_type(to).unwrap(); if from == to { @@ -352,7 +383,8 @@ impl<'a, 'tcx> HasTargetSpec for &'a FunctionCx<'a, 'tcx> { impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { pub fn monomorphize(&self, value: &T) -> T - where T: TypeFoldable<'tcx> + where + T: TypeFoldable<'tcx>, { self.tcx.subst_and_normalize_erasing_regions( self.param_substs, diff --git a/src/constant.rs b/src/constant.rs index 5520a77bad359..6136f5024fbf3 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,29 +1,37 @@ +use cranelift_module::*; use crate::prelude::*; +use rustc::mir::interpret::{read_target_uint, AllocId, ConstValue, GlobalId}; use rustc::ty::Const; -use rustc::mir::interpret::{ConstValue, GlobalId, AllocId, read_target_uint}; use rustc_mir::interpret::{CompileTimeEvaluator, Memory, MemoryKind}; -use cranelift_module::*; -pub fn trans_promoted<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, promoted: Promoted) -> CPlace<'tcx> { +pub fn trans_promoted<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + promoted: Promoted, +) -> CPlace<'tcx> { let const_ = fx .tcx .const_eval(ParamEnv::reveal_all().and(GlobalId { instance: fx.instance, promoted: Some(promoted), - })) - .unwrap(); + })).unwrap(); let const_ = force_eval_const(fx, const_); trans_const_place(fx, const_) } -pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, constant: &Constant<'tcx>) -> CValue<'tcx> { +pub fn trans_constant<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + constant: &Constant<'tcx>, +) -> CValue<'tcx> { let const_ = fx.monomorphize(&constant.literal); let const_ = force_eval_const(fx, const_); trans_const_value(fx, const_) } -fn force_eval_const<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx>, const_: &'tcx Const<'tcx>) -> &'tcx Const<'tcx> { +fn force_eval_const<'a, 'tcx: 'a>( + fx: &FunctionCx<'a, 'tcx>, + const_: &'tcx Const<'tcx>, +) -> &'tcx Const<'tcx> { match const_.val { ConstValue::Unevaluated(def_id, ref substs) => { let param_env = ParamEnv::reveal_all(); @@ -33,12 +41,15 @@ fn force_eval_const<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx>, const_: &'tcx Const promoted: None, }; fx.tcx.const_eval(param_env.and(cid)).unwrap() - }, + } _ => const_, } } -fn trans_const_value<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx Const<'tcx>) -> CValue<'tcx> { +fn trans_const_value<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + const_: &'tcx Const<'tcx>, +) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); match ty.sty { @@ -58,13 +69,14 @@ fn trans_const_value<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); CValue::Func(func_ref, layout) } - _ => { - trans_const_place(fx, const_).to_cvalue(fx) - } + _ => trans_const_place(fx, const_).to_cvalue(fx), } } -fn trans_const_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx Const<'tcx>) -> CPlace<'tcx> { +fn trans_const_place<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + const_: &'tcx Const<'tcx>, +) -> CPlace<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); if true { @@ -75,7 +87,9 @@ fn trans_const_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); let alloc = fx.tcx.const_value_to_allocation(const_); //println!("const value: {:?} allocation: {:?}", value, alloc); - let alloc_id = memory.allocate_value(alloc.clone(), MemoryKind::Stack).unwrap(); + let alloc_id = memory + .allocate_value(alloc.clone(), MemoryKind::Stack) + .unwrap(); let data_id = get_global_for_alloc_id(fx, &memory, alloc_id); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); // TODO: does global_value return a ptr of a val? @@ -84,14 +98,19 @@ fn trans_const_place<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx } // If ret.1 is true, then the global didn't exist before -fn define_global_for_alloc_id(fx: &mut FunctionCx, alloc_id: AllocId, todo: &mut HashMap) -> (DataId, bool) { +fn define_global_for_alloc_id( + fx: &mut FunctionCx, + alloc_id: AllocId, + todo: &mut HashMap, +) -> (DataId, bool) { use std::collections::hash_map::Entry; match fx.constants.entry(alloc_id) { - Entry::Occupied(mut occ) => { - (*occ.get_mut(), false) - } + Entry::Occupied(mut occ) => (*occ.get_mut(), false), Entry::Vacant(vac) => { - let data_id = fx.module.declare_data(&alloc_id.0.to_string(), Linkage::Local, false).unwrap(); + let data_id = fx + .module + .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) + .unwrap(); todo.insert(alloc_id, data_id); vac.insert(data_id); (data_id, true) @@ -99,7 +118,11 @@ fn define_global_for_alloc_id(fx: &mut FunctionCx, alloc_id: AllocId, todo: &mut } } -fn get_global_for_alloc_id(fx: &mut FunctionCx, memory: &Memory, alloc_id: AllocId) -> DataId { +fn get_global_for_alloc_id( + fx: &mut FunctionCx, + memory: &Memory, + alloc_id: AllocId, +) -> DataId { if let Some(data_id) = fx.constants.get(&alloc_id) { return *data_id; } @@ -108,13 +131,22 @@ fn get_global_for_alloc_id(fx: &mut FunctionCx, memory: &Memory { struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { - fn get_rlib_metadata(&self, _target: &rustc_target::spec::Target, path: &Path) -> Result, String> { - let mut archive = ar::Archive::new(File::open(path).map_err(|e|format!("{:?}", e))?); + fn get_rlib_metadata( + &self, + _target: &rustc_target::spec::Target, + path: &Path, + ) -> Result, String> { + let mut archive = ar::Archive::new(File::open(path).map_err(|e| format!("{:?}", e))?); // Iterate over all entries in the archive: while let Some(entry_result) = archive.next_entry() { - let mut entry = entry_result.map_err(|e|format!("{:?}", e))?; + let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; if entry.header().identifier() == b".rustc.clif_metadata" { let mut buf = Vec::new(); - ::std::io::copy(&mut entry, &mut buf).map_err(|e|format!("{:?}", e))?; + ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); return Ok(rustc_erase_owner!(buf.map_owner_box())); } @@ -112,7 +115,11 @@ impl MetadataLoader for CraneliftMetadataLoader { //self.get_dylib_metadata(target, path) } - fn get_dylib_metadata(&self, _target: &rustc_target::spec::Target, _path: &Path) -> Result, String> { + fn get_dylib_metadata( + &self, + _target: &rustc_target::spec::Target, + _path: &Path, + ) -> Result, String> { //use goblin::Object; //let buffer = ::std::fs::read(path).map_err(|e|format!("{:?}", e))?; @@ -149,13 +156,15 @@ impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { for cty in sess.opts.crate_types.iter() { match *cty { - CrateType::CrateTypeRlib | CrateType::CrateTypeDylib | - CrateType::CrateTypeExecutable => {}, + CrateType::CrateTypeRlib + | CrateType::CrateTypeDylib + | CrateType::CrateTypeExecutable => {} _ => { - sess.parse_sess.span_diagnostic.warn( - &format!("LLVM unsupported, so output type {} is not supported", cty) - ); - }, + sess.parse_sess.span_diagnostic.warn(&format!( + "LLVM unsupported, so output type {} is not supported", + cty + )); + } } } } @@ -167,9 +176,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn provide(&self, providers: &mut Providers) { rustc_codegen_utils::symbol_names::provide(providers); - providers.target_features_whitelist = |_tcx, _cnum| { - Lrc::new(Default::default()) - }; + providers.target_features_whitelist = |_tcx, _cnum| Lrc::new(Default::default()); providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); } @@ -180,7 +187,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_crate<'a, 'tcx>( &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, - _rx: mpsc::Receiver> + _rx: mpsc::Receiver>, ) -> Box { use rustc_mir::monomorphize::item::MonoItem; @@ -188,24 +195,22 @@ impl CodegenBackend for CraneliftCodegenBackend { rustc_codegen_utils::symbol_names_test::report_symbol_names(tcx); rustc_incremental::assert_dep_graph(tcx); rustc_incremental::assert_module_sources::assert_module_sources(tcx); - rustc_mir::monomorphize::assert_symbols_are_distinct(tcx, - collector::collect_crate_mono_items( - tcx, - collector::MonoItemCollectionMode::Eager - ).0.iter() + rustc_mir::monomorphize::assert_symbols_are_distinct( + tcx, + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) + .0 + .iter(), ); //::rustc::middle::dependency_format::calculate(tcx); let _ = tcx.link_args(LOCAL_CRATE); let _ = tcx.native_libraries(LOCAL_CRATE); for mono_item in - collector::collect_crate_mono_items( - tcx, - collector::MonoItemCollectionMode::Eager - ).0 { + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 + { match mono_item { MonoItem::Fn(inst) => { let def_id = inst.def_id(); - if def_id.is_local() { + if def_id.is_local() { let _ = inst.def.is_inline(tcx); let _ = tcx.codegen_fn_attrs(def_id); } @@ -221,7 +226,9 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); let flags = settings::Flags::new(flags_builder); - let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()).unwrap().finish(flags); + let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()) + .unwrap() + .finish(flags); let mut module: Module = Module::new(SimpleJITBuilder::new()); let mut context = Context::new(); @@ -233,10 +240,8 @@ impl CodegenBackend for CraneliftCodegenBackend { }; for mono_item in - collector::collect_crate_mono_items( - tcx, - collector::MonoItemCollectionMode::Eager - ).0 { + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 + { base::trans_mono_item(&mut cx, &mut context, mono_item) } } @@ -249,11 +254,8 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Finalized everything"); for mono_item in - collector::collect_crate_mono_items( - tcx, - collector::MonoItemCollectionMode::Eager - ).0 { - + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 + { let inst = match mono_item { MonoItem::Fn(inst) => inst, _ => continue, @@ -266,17 +268,21 @@ impl CodegenBackend for CraneliftCodegenBackend { let fn_ty = inst.ty(tcx); let sig = cton_sig_from_fn_ty(tcx, fn_ty); - let def_path_based_names = ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); + let def_path_based_names = + ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); let mut name = String::new(); def_path_based_names.push_instance_as_string(inst, &mut name); - let func_id = module.declare_function(&name, Linkage::Import, &sig).unwrap(); + let func_id = module + .declare_function(&name, Linkage::Import, &sig) + .unwrap(); let finalized_function: *const u8 = module.finalize_function(func_id); /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; let mut res = 0u32; f(&mut res); tcx.sess.warn(&format!("ret_42 returned {}", res));*/ - let f: extern "C" fn(&mut bool, &u8, bool) = unsafe { ::std::mem::transmute(finalized_function) }; + let f: extern "C" fn(&mut bool, &u8, bool) = + unsafe { ::std::mem::transmute(finalized_function) }; let mut res = false; f(&mut res, &3, false); tcx.sess.warn(&format!("option_unwrap_or returned {}", res)); @@ -290,9 +296,8 @@ impl CodegenBackend for CraneliftCodegenBackend { isa, "some_file.o".to_string(), FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names() - ) - .unwrap() + FaerieBuilder::default_libcall_names(), + ).unwrap(), ); Box::new(OngoingCodegen { @@ -309,30 +314,42 @@ impl CodegenBackend for CraneliftCodegenBackend { _dep_graph: &DepGraph, outputs: &OutputFilenames, ) -> Result<(), CompileIncomplete> { - let ongoing_codegen = *ongoing_codegen.downcast::() + let ongoing_codegen = *ongoing_codegen + .downcast::() .expect("Expected CraneliftCodegenBackend's OngoingCodegen, found Box"); let mut artifact = ongoing_codegen.product.artifact; let metadata = ongoing_codegen.metadata; - artifact.declare_with( - ".rustc.clif_metadata", - faerie::artifact::Decl::Data { - global: true, - writeable: false - }, - metadata.clone(), - ).unwrap(); + artifact + .declare_with( + ".rustc.clif_metadata", + faerie::artifact::Decl::Data { + global: true, + writeable: false, + }, + metadata.clone(), + ).unwrap(); for &crate_type in sess.opts.crate_types.iter() { - if crate_type != CrateType::CrateTypeRlib /*&& crate_type != CrateType::CrateTypeDylib*/ { + if crate_type != CrateType::CrateTypeRlib + /*&& crate_type != CrateType::CrateTypeDylib*/ + { sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)); } - let output_name = - out_filename(sess, crate_type, &outputs, &ongoing_codegen.crate_name.as_str()); + let output_name = out_filename( + sess, + crate_type, + &outputs, + &ongoing_codegen.crate_name.as_str(), + ); let file = File::create(&output_name).unwrap(); let mut builder = ar::Builder::new(file); - builder.append(&ar::Header::new(b".rustc.clif_metadata".to_vec(), metadata.len() as u64), ::std::io::Cursor::new(metadata.clone())).unwrap(); + builder + .append( + &ar::Header::new(b".rustc.clif_metadata".to_vec(), metadata.len() as u64), + ::std::io::Cursor::new(metadata.clone()), + ).unwrap(); //artifact.write(file).unwrap(); } From 8f602e7e7c61675aa48b4982e77ee08bafeeb525 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Aug 2018 17:44:32 +0200 Subject: [PATCH 0081/1566] Use upstream cranelift cargo git dependency instead of my submodule --- .gitmodules | 3 -- Cargo.lock | 109 +++++++++++++++++++++++++++++++++++----------------- Cargo.toml | 8 ++-- 3 files changed, 77 insertions(+), 43 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 279484b1af7cf..0000000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "cranelift"] - path = cranelift - url = https://github.com/bjorn3/cretonne.git diff --git a/Cargo.lock b/Cargo.lock index b20a0c7ec2cc8..b0ee1bcf0509d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,11 +53,6 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "bitflags" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "1.0.3" @@ -94,18 +89,20 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" dependencies = [ - "cranelift-codegen 0.16.1", - "cranelift-frontend 0.16.1", + "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" dependencies = [ - "cranelift-codegen-meta 0.15.0", - "cranelift-entity 0.16.1", + "cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -113,18 +110,21 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.15.0" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" [[package]] name = "cranelift-entity" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" [[package]] name = "cranelift-faerie" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" dependencies = [ - "cranelift-codegen 0.16.1", - "cranelift-module 0.16.1", + "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -133,36 +133,40 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" dependencies = [ - "cranelift-codegen 0.16.1", + "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-module" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" dependencies = [ - "cranelift-codegen 0.16.1", - "cranelift-entity 0.16.1", + "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" dependencies = [ - "cranelift-codegen 0.16.1", - "raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.16.1" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" dependencies = [ - "cranelift-codegen 0.16.1", - "cranelift-module 0.16.1", - "cranelift-native 0.16.1", + "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -342,11 +346,12 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "3.1.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -405,14 +410,22 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.16.1", - "cranelift-faerie 0.16.1", - "cranelift-module 0.16.1", - "cranelift-simplejit 0.16.1", + "cranelift 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustc_version" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "scroll" version = "0.9.0" @@ -431,6 +444,19 @@ dependencies = [ "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "serde" version = "1.0.70" @@ -637,12 +663,20 @@ dependencies = [ "checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" -"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9" "checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" "checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum cranelift 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" @@ -665,15 +699,18 @@ dependencies = [ "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" -"checksum raw-cpuid 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "233ec1847057cf4d4591a0d76908aa12812140b11ea7d7d05b4c38cadb069c31" +"checksum raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3c460bd35fdb75644e94ab498372bdf29a4849367ce7ba74cf358edce590c4" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5bbbea44c5490a1e84357ff28b7d518b4619a159fed5d25f6c1de2d19cc42814" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" +"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" "checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" "checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920" "checksum serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" diff --git a/Cargo.toml b/Cargo.toml index 651fba4133ac7..3ccf00cb9657b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,10 +15,10 @@ crate-type = ["dylib"] #cranelift-simplejit = "0.14.0" #cranelift-faerie = "0.14.0" -cranelift = { path = "./cranelift/lib/umbrella" } -cranelift-module = { path = "./cranelift/lib/module" } -cranelift-simplejit = { path = "./cranelift/lib/simplejit" } -cranelift-faerie = { path = "./cranelift/lib/faerie" } +cranelift = { git = "https://github.com/CraneStation/cranelift.git" } +cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } +cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } +cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.0.3" #goblin = "0.0.17" faerie = "0.4.4" From 0df01fb50357c32bde5fc79e42cd0ebc23d0017f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Aug 2018 17:02:20 +0200 Subject: [PATCH 0082/1566] Remove cranelift dir --- cranelift | 1 - 1 file changed, 1 deletion(-) delete mode 160000 cranelift diff --git a/cranelift b/cranelift deleted file mode 160000 index 4d50ef87a2f8f..0000000000000 --- a/cranelift +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4d50ef87a2f8faa4e590423f712d99bef5cb9148 From e0b1176ae53c018ca65471e87b39093e552475f6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 7 Aug 2018 16:34:45 +0200 Subject: [PATCH 0083/1566] Update Cargo.lock and rustup to rustc 1.30.0-nightly (73c78734b 2018-08-05) --- Cargo.lock | 196 ++++++++++++++++++++++++----------------------------- src/lib.rs | 14 ++-- 2 files changed, 95 insertions(+), 115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0ee1bcf0509d..62e1607beebb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,15 +19,15 @@ name = "ar" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "atty" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -39,7 +39,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -50,7 +50,7 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -60,7 +60,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.3" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -79,7 +79,7 @@ version = "2.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,34 +99,34 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" dependencies = [ "cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" [[package]] name = "cranelift-entity" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" [[package]] name = "cranelift-faerie" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -142,17 +142,17 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -162,13 +162,13 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#56a4ba84888f4d9fb9c79d17efb0364171114247" +source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,14 +181,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "env_logger" -version = "0.5.10" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -197,7 +197,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -207,7 +207,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -215,8 +215,8 @@ name = "faerie" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -229,21 +229,22 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -281,12 +282,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "libc" -version = "0.2.42" +version = "0.2.43" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -302,7 +306,7 @@ name = "mach" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -310,7 +314,7 @@ name = "memchr" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -333,12 +337,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "quote" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -351,7 +350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -394,8 +393,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -420,7 +419,7 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -440,8 +439,8 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -459,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -469,7 +468,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -477,7 +476,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -500,45 +499,29 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "0.14.4" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "synom" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "synstructure" -version = "0.6.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -546,17 +529,17 @@ name = "target-lexicon" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "termcolor" -version = "0.3.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "wincolor 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -564,7 +547,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -582,7 +565,7 @@ name = "thread_local" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -596,11 +579,6 @@ name = "unicode-width" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicode-xid" version = "0.1.0" @@ -624,6 +602,11 @@ name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "version_check" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "void" version = "1.0.2" @@ -650,7 +633,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wincolor" -version = "0.1.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -660,11 +643,11 @@ dependencies = [ "checksum aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c6d463cbe7ed28720b5b489e7c083eeb8f90d08be2a0d6bb9e1ffea9ce1afa" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "095515608290b62ac2427084f9ac3cfeb5dc76067f7d94564db9db1c46cc0a85" -"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" +"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" -"checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9" +"checksum byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8389c509ec62b9fe8eca58c502a0acaf017737355615243496cde4994f8fa4f9" "checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" "checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -678,27 +661,26 @@ dependencies = [ "checksum cranelift-native 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-simplejit 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" -"checksum env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0e6e40ebb0e66918a37b38c7acab4e10d299e0463fe2af5d29b9cc86710cfd2a" +"checksum env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "f4d7e69c283751083d53d01eac767407343b8b69c4bd70058e08adc2637cb257" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "319f742885b740cec9adca9a9b4bc35229d7e004af9431c694e0aef3eea00f55" -"checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" -"checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" +"checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" +"checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" "checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" "checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" -"checksum lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fb497c35d362b6a331cfd94956a07fc2c78a4604cdbee844a81170386b996dd3" -"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" +"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" +"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd98ae7f7b754bc53dca7d44b604f733c6bba044ea6f41bc8d89272d8161d2" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cccdc7557a98fe98453030f077df7f3a042052fae465bb61d2c2c41435cfd9b6" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" +"checksum quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3372dc35766b36a99ce2352bd1b6ea0137c38d215cc0c8780bf6de6df7842ba9" "checksum raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3c460bd35fdb75644e94ab498372bdf29a4849367ce7ba74cf358edce590c4" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" @@ -706,35 +688,33 @@ dependencies = [ "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" -"checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" "checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920" +"checksum serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfad05c8854584e5f72fb859385ecdfa03af69c3fd0572f0da2d4c95f060bdb" "checksum serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" "checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" -"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2beff8ebc3658f07512a413866875adddd20f4fd47b2a4e6c9da65cd281baaea" -"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" +"checksum syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e13df71f29f9440b50261a5882c86eac334f1badb3134ec26f0de2f1418e44" +"checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" -"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" +"checksum termcolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "722426c4a0539da2c4ffd9b419d90ad540b4cff4a053be9069c908d4d07e2836" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" -"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" +"checksum wincolor 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9dc3aa9dcda98b5a16150c54619c1ead22e3d3a5d458778ae914be760aa981a" diff --git a/src/lib.rs b/src/lib.rs index 0995639e37506..c2f1d0db977fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -156,9 +156,9 @@ impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { for cty in sess.opts.crate_types.iter() { match *cty { - CrateType::CrateTypeRlib - | CrateType::CrateTypeDylib - | CrateType::CrateTypeExecutable => {} + CrateType::Rlib + | CrateType::Dylib + | CrateType::Executable => {} _ => { sess.parse_sess.span_diagnostic.warn(&format!( "LLVM unsupported, so output type {} is not supported", @@ -332,8 +332,8 @@ impl CodegenBackend for CraneliftCodegenBackend { ).unwrap(); for &crate_type in sess.opts.crate_types.iter() { - if crate_type != CrateType::CrateTypeRlib - /*&& crate_type != CrateType::CrateTypeDylib*/ + if crate_type != CrateType::Rlib + /*&& crate_type != CrateType::Dylib*/ { sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)); } @@ -354,8 +354,8 @@ impl CodegenBackend for CraneliftCodegenBackend { } sess.abort_if_errors(); - if !sess.opts.crate_types.contains(&CrateType::CrateTypeRlib) - && !sess.opts.crate_types.contains(&CrateType::CrateTypeDylib) + if !sess.opts.crate_types.contains(&CrateType::Rlib) + && !sess.opts.crate_types.contains(&CrateType::Dylib) { sess.fatal("Executables are not supported by the metadata-only backend."); } From 5c601f7316b682179e373bf1a2e5550bf2c5ee76 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 7 Aug 2018 16:43:09 +0200 Subject: [PATCH 0084/1566] Rustfmt --- src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c2f1d0db977fd..8737a2a5954a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -156,9 +156,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { for cty in sess.opts.crate_types.iter() { match *cty { - CrateType::Rlib - | CrateType::Dylib - | CrateType::Executable => {} + CrateType::Rlib | CrateType::Dylib | CrateType::Executable => {} _ => { sess.parse_sess.span_diagnostic.warn(&format!( "LLVM unsupported, so output type {} is not supported", From 376ec8c258ff5bc0400bff16979199fa3f9ce871 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 09:34:56 +0200 Subject: [PATCH 0085/1566] Don't crash on checked binops (treated like unchecked ones atm) --- Readme.md | 2 -- build.sh | 2 +- src/abi.rs | 2 -- src/base.rs | 79 ++++++++++++++++++++++++++++++++++++++++----------- src/common.rs | 14 +++++++-- 5 files changed, 76 insertions(+), 23 deletions(-) diff --git a/Readme.md b/Readme.md index 7c1efe263f69c..8e3105d49cfe9 100644 --- a/Readme.md +++ b/Readme.md @@ -18,8 +18,6 @@ $ cargo build $ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_crate.rs --crate-type lib -Og ``` -> You must compile with `-Og`, because checked binops are not yet supported. - ## Building libcore ```bash diff --git a/build.sh b/build.sh index 82160c6435da8..762dc3a8d9443 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ cargo build || exit 1 cd examples/ -RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.so -Og -L crate=. --crate-type lib" +RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.so -L crate=. --crate-type lib" $RUSTC mini_core.rs --crate-name mini_core && $RUSTC example.rs && diff --git a/src/abi.rs b/src/abi.rs index 3931ef4a3f1de..c1097864bf0c5 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -398,7 +398,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( args[1], ret.layout().ty, false, - false, ), TypeVariants::TyInt(_) => crate::base::trans_int_binop( fx, @@ -407,7 +406,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( args[1], ret.layout().ty, true, - false, ), _ => panic!(), }; diff --git a/src/base.rs b/src/base.rs index 4970eef10d859..9d09409aa9ef2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -313,10 +313,10 @@ fn trans_stmt<'a, 'tcx: 'a>( trans_bool_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } TypeVariants::TyUint(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false, false) + trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } TypeVariants::TyInt(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true, false) + trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) } TypeVariants::TyFloat(_) => { trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) @@ -325,9 +325,9 @@ fn trans_stmt<'a, 'tcx: 'a>( trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } TypeVariants::TyRawPtr(..) => { - trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) + trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } - _ => unimplemented!("bin op {:?} for {:?}", bin_op, ty), + _ => unimplemented!("binop {:?} for {:?}", bin_op, ty), }; lval.write_cvalue(fx, res); } @@ -338,14 +338,13 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = match ty.sty { TypeVariants::TyUint(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, ty, false, true) + trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } TypeVariants::TyInt(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, ty, true, true) + trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) } - _ => unimplemented!("checked bin op {:?} for {:?}", bin_op, ty), + _ => unimplemented!("checked binop {:?} for {:?}", bin_op, ty), }; - return Err(format!("checked bin op {:?}", bin_op)); lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, operand) => { @@ -510,7 +509,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( macro_rules! binop_match { (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, bug) => { - bug!("bin op {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) + bug!("binop {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) }; (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, icmp($cc:ident)) => {{ assert_eq!($fx.tcx.types.bool, $ret_ty); @@ -585,12 +584,14 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, - ty: Ty<'tcx>, + out_ty: Ty<'tcx>, signed: bool, - _checked: bool, ) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, signed, lhs, rhs, ty, "int/uint"; + if bin_op != BinOp::Shl && bin_op != BinOp::Shr { + assert_eq!(lhs.layout().ty, rhs.layout().ty, "int binop requires lhs and rhs of same type"); + } + binop_match! { + fx, bin_op, signed, lhs, rhs, out_ty, "int/uint"; Add (_) iadd; Sub (_) isub; Mul (_) imul; @@ -617,10 +618,57 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( Gt (true) icmp(SignedGreaterThan); Offset (_) bug; + } +} + +fn trans_checked_int_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + out_ty: Ty<'tcx>, + signed: bool, +) -> CValue<'tcx> { + if bin_op != BinOp::Shl && bin_op != BinOp::Shr { + assert_eq!(lhs.layout().ty, rhs.layout().ty, "checked int binop requires lhs and rhs of same type"); + } + let res_ty = match out_ty.sty { + TypeVariants::TyTuple(tys) => tys[0], + _ => bug!("Checked int binop requires tuple as output, but got {:?}", out_ty), }; - // TODO: return correct value for checked binops - res + let res = binop_match! { + fx, bin_op, signed, lhs, rhs, res_ty, "checked int/uint"; + Add (_) iadd; + Sub (_) isub; + Mul (_) imul; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) ishl; + Shr (false) ushr; + Shr (true) sshr; + + Eq (_) bug; + Lt (_) bug; + Le (_) bug; + Ne (_) bug; + Ge (_) bug; + Gt (_) bug; + + Offset (_) bug; + }; + + let has_overflow = CValue::const_val(fx, fx.tcx.types.bool, 0); + + let out_place = CPlace::temp(fx, out_ty); + out_place.place_field(fx, mir::Field::new(0)).write_cvalue(fx, res); + println!("abc"); + out_place.place_field(fx, mir::Field::new(1)).write_cvalue(fx, has_overflow); + + out_place.to_cvalue(fx) } fn trans_float_binop<'a, 'tcx: 'a>( @@ -703,7 +751,6 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( lhs: CValue<'tcx>, rhs: CValue<'tcx>, ty: Ty<'tcx>, - _checked: bool, ) -> CValue<'tcx> { binop_match! { fx, bin_op, false, lhs, rhs, ty, "ptr"; diff --git a/src/common.rs b/src/common.rs index 421b2cb2d03b0..0f19c8c7e6b90 100644 --- a/src/common.rs +++ b/src/common.rs @@ -133,8 +133,8 @@ impl<'tcx> CValue<'tcx> { pub fn expect_byref(self) -> (Value, TyLayout<'tcx>) { match self { CValue::ByRef(value, layout) => (value, layout), - CValue::ByVal(_, _) => bug!("Expected CValue::ByRef, found CValue::ByVal"), - CValue::Func(_, _) => bug!("Expected CValue::ByRef, found CValue::Func"), + CValue::ByVal(_, _) => bug!("Expected CValue::ByRef, found CValue::ByVal: {:?}", self), + CValue::Func(_, _) => bug!("Expected CValue::ByRef, found CValue::Func: {:?}", self), } } @@ -187,6 +187,16 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } + pub fn temp(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> CPlace<'tcx> { + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0), layout) + } + pub fn from_stack_slot( fx: &mut FunctionCx<'a, 'tcx>, stack_slot: StackSlot, From 0f73b8fb4ce472d423260e43741becd6c331d044 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 09:38:00 +0200 Subject: [PATCH 0086/1566] Remove an error from Readme --- Readme.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Readme.md b/Readme.md index 8e3105d49cfe9..d845ee2815897 100644 --- a/Readme.md +++ b/Readme.md @@ -48,21 +48,3 @@ $ ./build.sh * cranelift-module api seems to be used wrong, thus causing panic for some consts * cranelift-codegen doesn't have encodings for some instructions for types smaller than I32 - -``` -[...] -warning: DefId(0/0:128 ~ lib[8787]::f64[0]::{{impl}}[0]::classify[0]): -fn f64::::classify(_1: f64) -> num::FpCategory{ -[...] -} -warning: stmt _3 = _1 -warning: stmt _5 = BitAnd(move _6, const Unevaluated(DefId(0/0:130 ~ lib[8787]::f64[0]::{{impl}}[0]::classify[0]::MAN_MASK[0]), []):u64) -thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:345:21 -stack backtrace: -[...] - 10: >::unwrap - at /checkout/src/libcore/macros.rs:20 - 11: rustc_codegen_cranelift::constant::trans_constant - at src/constant.rs:26 -[...] -``` From 018612cf22c95fe842345154f999268503a15960 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 09:49:42 +0200 Subject: [PATCH 0087/1566] Implement overflowing_* and *_with_overflowing --- src/abi.rs | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/base.rs | 3 ++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index c1097864bf0c5..85c6ff1e0123b 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -411,6 +411,66 @@ pub fn codegen_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, res); } + _ if intrinsic.ends_with("_with_overflow") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "add_with_overflow" => BinOp::Add, + "sub_with_overflow" => BinOp::Sub, + "mul_with_overflow" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + _ if intrinsic.starts_with("overflowing_") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "overflowing_add" => BinOp::Add, + "overflowing_sub" => BinOp::Sub, + "overflowing_mul" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } "offset" => { assert_eq!(args.len(), 2); let base = args[0].load_value(fx); diff --git a/src/base.rs b/src/base.rs index 9d09409aa9ef2..c61e5e39c6ed9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -621,7 +621,7 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( } } -fn trans_checked_int_binop<'a, 'tcx: 'a>( +pub fn trans_checked_int_binop<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, bin_op: BinOp, lhs: CValue<'tcx>, @@ -661,6 +661,7 @@ fn trans_checked_int_binop<'a, 'tcx: 'a>( Offset (_) bug; }; + // TODO: check for overflow let has_overflow = CValue::const_val(fx, fx.tcx.types.bool, 0); let out_place = CPlace::temp(fx, out_ty); From 40176e03fd2c80ce29e23c40dd9c1531ad0da8a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 10:26:25 +0200 Subject: [PATCH 0088/1566] Fix some bugs --- copy.clif | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/abi.rs | 1 - src/common.rs | 4 +-- 3 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 copy.clif diff --git a/copy.clif b/copy.clif new file mode 100644 index 0000000000000..e3c510d29f97f --- /dev/null +++ b/copy.clif @@ -0,0 +1,80 @@ +target x86_64 + +; copy_nonoverlapping +function u0:0(i64, i64, i64) fast { + ss0 = explicit_slot 8 + ss1 = explicit_slot 8 + ss2 = explicit_slot 8 +ebb0(v0: i64, v1: i64, v2: i64): ; fn(src, dst, count) + v99 = iconst.i64 1 + jump ebb1(v0, v1, v2) + +ebb1(v10: i64, v11: i64, v12: i64): + ; if no more bytes to copy, return + brz v12, ebb2 + + ; copy one byte + v20 = uload8.i32 v10 + istore8.i32 v20, v11 + + ; increment src and dst and decrement remaining count + v30 = iadd_imm v10, 1 + v31 = iadd_imm v11, 1 + v32 = isub v12, v99 + + ; loop + jump ebb1(v30, v31, v32) + +ebb2: + return +} + +; copy +function u0:0(i64, i64, i64) fast { + ss0 = explicit_slot 8 + ss1 = explicit_slot 8 + ss2 = explicit_slot 8 +ebb0(v0: i64, v1: i64, v2: i64): ; fn(src, dst, count): + v98 = iconst.i64 8 + v99 = iconst.i64 1 + jump ebb1(v0, v1, v2) + +; copy eight bytes +ebb1(v10: i64, v11: i64, v12: i64): + ; if less than eight bytes to copy, goto ebb2 + v90 = icmp ult v12, v98 + brz v90, ebb2(v10, v11, v12) + + ; copy one byte + v80 = load.i64 v10 + store.i64 v80, v11 + + ; increment src and dst and decrement remaining count + v20 = iadd_imm v0, 1 + v21 = iadd_imm v1, 1 + v22 = isub v2, v98 + + ; loop + jump ebb1(v20, v21, v22) + +; copy one byte +ebb2(v30: i64, v31: i64, v32: i64): + ; if no more bytes to copy, return + brz v32, ebb3 + + ; copy one byte + v81 = uload8.i32 v30 + istore8.i32 v81, v31 + + ; increment src and dst and decrement remaining count + v40 = iadd_imm v30, 1 + v41 = iadd_imm v31, 1 + v42 = isub v32, v99 + + ; loop + jump ebb2(v40, v41, v42) + +; done +ebb3: + return +} \ No newline at end of file diff --git a/src/abi.rs b/src/abi.rs index 85c6ff1e0123b..1bf39095ddf23 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -356,7 +356,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( &[dst, src, CValue::ByVal(byte_amount, usize_layout)], nil_ty, ); - unimplemented!("copy"); } "discriminant_value" => { assert_eq!(args.len(), 1); diff --git a/src/common.rs b/src/common.rs index 0f19c8c7e6b90..f49827b3a977c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -45,8 +45,8 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( }, TypeVariants::TyChar => types::I32, TypeVariants::TyFloat(size) => match size { - FloatTy::F32 => types::I32, - FloatTy::F64 => types::I64, + FloatTy::F32 => types::F32, + FloatTy::F64 => types::F64, }, TypeVariants::TyFnPtr(_) => types::I64, TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) | TypeVariants::TyRef(_, ty, _) => { From ece497cc84834e00ff6b1e43f28d17598efc24a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 10:39:10 +0200 Subject: [PATCH 0089/1566] Some misc changes --- examples/example.rs | 5 +++++ src/abi.rs | 2 +- src/base.rs | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/example.rs b/examples/example.rs index e9896ef6c7594..0537db405d3ee 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -137,3 +137,8 @@ unsafe fn transmute(c: char) -> u32 { unsafe fn call_uninit() -> u8 { intrinsics::uninit() } + +// TODO: enable when fat pointers are supported +/*unsafe fn deref_str_ptr(s: *const str) -> &'static str { + &*s +}*/ diff --git a/src/abi.rs b/src/abi.rs index 1bf39095ddf23..929002f0e8039 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -330,7 +330,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let nil_ty = fx.tcx.mk_nil(); let usize_layout = fx.layout_of(fx.tcx.types.usize); - let ret = return_place.unwrap(); + let ret = return_place.expect("return place"); match intrinsic { "abort" => { fx.bcx.ins().trap(TrapCode::User(!0 - 1)); diff --git a/src/base.rs b/src/base.rs index c61e5e39c6ed9..e0c4b80afcc46 100644 --- a/src/base.rs +++ b/src/base.rs @@ -354,6 +354,10 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = match un_op { UnOp::Not => fx.bcx.ins().bnot(val), UnOp::Neg => match ty.sty { + TypeVariants::TyInt(_) => { + let zero = fx.bcx.ins().iconst(types::I64, 0); + fx.bcx.ins().isub(zero, val) + }, TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val), _ => unimplemented!("un op Neg for {:?}", ty), }, From efd203aa0b7d748bcf5a76efe810f025306fd901 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 12:22:16 +0200 Subject: [PATCH 0090/1566] Implement indexing for arrays --- examples/example.rs | 4 ++++ examples/mini_core.rs | 14 ++++++++++++++ src/base.rs | 3 ++- src/common.rs | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/examples/example.rs b/examples/example.rs index 0537db405d3ee..74735c6a12de8 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -142,3 +142,7 @@ unsafe fn call_uninit() -> u8 { /*unsafe fn deref_str_ptr(s: *const str) -> &'static str { &*s }*/ + +fn use_array(arr: [u8; 3]) -> u8 { + arr[1] +} diff --git a/examples/mini_core.rs b/examples/mini_core.rs index ff22aad5a65d0..dc19d66b21446 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -141,3 +141,17 @@ pub mod intrinsics { pub fn uninit() -> T; } } + +#[lang = "index"] +pub trait Index { + type Output: ?Sized; + fn index(&self, index: Idx) -> &Self::Output; +} + +impl Index for [T; 3] { + type Output = T; + + fn index(&self, index: usize) -> &Self::Output { + &self[index] + } +} diff --git a/src/base.rs b/src/base.rs index e0c4b80afcc46..723eb8cdc766b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -800,7 +800,8 @@ pub fn trans_place<'a, 'tcx: 'a>( ), ProjectionElem::Field(field, _ty) => base.place_field(fx, field), ProjectionElem::Index(local) => { - unimplemented!("projection index {:?} {:?}", projection.base, local) + let index = fx.get_local_place(local).to_cvalue(fx).load_value(fx); + base.place_index(fx, index) } ProjectionElem::ConstantIndex { offset, diff --git a/src/common.rs b/src/common.rs index f49827b3a977c..c3398a9e9f390 100644 --- a/src/common.rs +++ b/src/common.rs @@ -297,6 +297,21 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(field_ptr, field_layout) } + pub fn place_index(self, fx: &mut FunctionCx<'a, 'tcx>, index: Value) -> CPlace<'tcx> { + let addr = self.expect_addr(); + let layout = self.layout(); + match layout.ty.sty { + TypeVariants::TyArray(elem_ty, _) => { + let elem_layout = fx.layout_of(elem_ty); + let size = fx.bcx.ins().iconst(types::I64, elem_layout.size.bytes() as i64); + let offset = fx.bcx.ins().imul(size, index); + CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) + } + TypeVariants::TySlice(_elem_ty) => unimplemented!("place_index(TySlice)"), + _ => bug!("place_index({:?})", layout.ty), + } + } + pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { match self { CPlace::Var(var, _) => CPlace::Var(var, layout), From 1305d1ef238731c28495b9ee40cace982588cc46 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 12:30:25 +0200 Subject: [PATCH 0091/1566] Implement Rvalue::Repeat --- examples/example.rs | 4 ++++ src/base.rs | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/example.rs b/examples/example.rs index 74735c6a12de8..ecc5db5c0db18 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -146,3 +146,7 @@ unsafe fn call_uninit() -> u8 { fn use_array(arr: [u8; 3]) -> u8 { arr[1] } + +fn repeat_array() -> [u8; 3] { + [0; 3] +} diff --git a/src/base.rs b/src/base.rs index 723eb8cdc766b..ad37f58567738 100644 --- a/src/base.rs +++ b/src/base.rs @@ -412,7 +412,12 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => { - unimplemented!("rval repeat {:?} {:?}", operand, times) + let operand = trans_operand(fx, operand); + for i in 0..*times { + let index = fx.bcx.ins().iconst(types::I64, i as i64); + let to = lval.place_index(fx, index); + to.write_cvalue(fx, operand); + } } Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), From 822a181c8783bdfd365e14ab3bd9d2ab22ed7ee2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 12:44:41 +0200 Subject: [PATCH 0092/1566] Implement NullOp::SizeOf --- src/base.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index ad37f58567738..b232d6948f87b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -421,7 +421,12 @@ fn trans_stmt<'a, 'tcx: 'a>( } Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), - Rvalue::NullaryOp(NullOp::SizeOf, ty) => unimplemented!("rval size_of {:?}", ty), + Rvalue::NullaryOp(NullOp::SizeOf, ty) => { + assert!(lval.layout().ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all())); + let ty_size = fx.layout_of(ty).size.bytes(); + let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64); + lval.write_cvalue(fx, val); + }, Rvalue::Aggregate(_, _) => bug!("shouldn't exist at trans {:?}", rval), } } From 21c52c70b3d8abb9d3995e473ee120a11f3649ff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 12:45:34 +0200 Subject: [PATCH 0093/1566] Rustfmt --- src/base.rs | 35 +++++++++++++++++++++++++++-------- src/common.rs | 5 ++++- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/base.rs b/src/base.rs index b232d6948f87b..d40c2ec20cd49 100644 --- a/src/base.rs +++ b/src/base.rs @@ -357,7 +357,7 @@ fn trans_stmt<'a, 'tcx: 'a>( TypeVariants::TyInt(_) => { let zero = fx.bcx.ins().iconst(types::I64, 0); fx.bcx.ins().isub(zero, val) - }, + } TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val), _ => unimplemented!("un op Neg for {:?}", ty), }, @@ -422,11 +422,15 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), Rvalue::NullaryOp(NullOp::SizeOf, ty) => { - assert!(lval.layout().ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all())); + assert!( + lval.layout() + .ty + .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) + ); let ty_size = fx.layout_of(ty).size.bytes(); let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64); lval.write_cvalue(fx, val); - }, + } Rvalue::Aggregate(_, _) => bug!("shouldn't exist at trans {:?}", rval), } } @@ -602,7 +606,11 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( signed: bool, ) -> CValue<'tcx> { if bin_op != BinOp::Shl && bin_op != BinOp::Shr { - assert_eq!(lhs.layout().ty, rhs.layout().ty, "int binop requires lhs and rhs of same type"); + assert_eq!( + lhs.layout().ty, + rhs.layout().ty, + "int binop requires lhs and rhs of same type" + ); } binop_match! { fx, bin_op, signed, lhs, rhs, out_ty, "int/uint"; @@ -644,11 +652,18 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( signed: bool, ) -> CValue<'tcx> { if bin_op != BinOp::Shl && bin_op != BinOp::Shr { - assert_eq!(lhs.layout().ty, rhs.layout().ty, "checked int binop requires lhs and rhs of same type"); + assert_eq!( + lhs.layout().ty, + rhs.layout().ty, + "checked int binop requires lhs and rhs of same type" + ); } let res_ty = match out_ty.sty { TypeVariants::TyTuple(tys) => tys[0], - _ => bug!("Checked int binop requires tuple as output, but got {:?}", out_ty), + _ => bug!( + "Checked int binop requires tuple as output, but got {:?}", + out_ty + ), }; let res = binop_match! { @@ -679,9 +694,13 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( let has_overflow = CValue::const_val(fx, fx.tcx.types.bool, 0); let out_place = CPlace::temp(fx, out_ty); - out_place.place_field(fx, mir::Field::new(0)).write_cvalue(fx, res); + out_place + .place_field(fx, mir::Field::new(0)) + .write_cvalue(fx, res); println!("abc"); - out_place.place_field(fx, mir::Field::new(1)).write_cvalue(fx, has_overflow); + out_place + .place_field(fx, mir::Field::new(1)) + .write_cvalue(fx, has_overflow); out_place.to_cvalue(fx) } diff --git a/src/common.rs b/src/common.rs index c3398a9e9f390..35a41dd8a6f6f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -303,7 +303,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match layout.ty.sty { TypeVariants::TyArray(elem_ty, _) => { let elem_layout = fx.layout_of(elem_ty); - let size = fx.bcx.ins().iconst(types::I64, elem_layout.size.bytes() as i64); + let size = fx + .bcx + .ins() + .iconst(types::I64, elem_layout.size.bytes() as i64); let offset = fx.bcx.ins().imul(size, index); CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) } From d4b6bce39c41add57c56b03ad950cae9ad54b3ad Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 12:53:09 +0200 Subject: [PATCH 0094/1566] Workaround two bugs --- src/base.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/base.rs b/src/base.rs index d40c2ec20cd49..d479e9350686f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -188,16 +188,20 @@ pub fn trans_fn<'a, 'tcx: 'a>( values, targets, } => { - let discr = trans_operand(fx, discr).load_value(fx); - let mut jt_data = JumpTableData::new(); - for (i, value) in values.iter().enumerate() { - let ebb = fx.get_ebb(targets[i]); - jt_data.set_entry(*value as usize, ebb); + fx.bcx.ins().trap(TrapCode::User(0)); + // TODO: prevent panics on large and negative disciminants + if false { + let discr = trans_operand(fx, discr).load_value(fx); + let mut jt_data = JumpTableData::new(); + for (i, value) in values.iter().enumerate() { + let ebb = fx.get_ebb(targets[i]); + jt_data.set_entry(*value as usize, ebb); + } + let jump_table = fx.bcx.create_jump_table(jt_data); + fx.bcx.ins().br_table(discr, jump_table); + let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); + fx.bcx.ins().jump(otherwise_ebb, &[]); } - let jump_table = fx.bcx.create_jump_table(jt_data); - fx.bcx.ins().br_table(discr, jump_table); - let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); - fx.bcx.ins().jump(otherwise_ebb, &[]); } TerminatorKind::Call { func, @@ -431,7 +435,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64); lval.write_cvalue(fx, val); } - Rvalue::Aggregate(_, _) => bug!("shouldn't exist at trans {:?}", rval), + Rvalue::Aggregate(_, _) => return Err(format!("shouldn't exist at trans {:?}", rval)), } } StatementKind::StorageLive(_) From c4705af4e2648371fdeed0ded7e3bc88cce1c6f8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 14:39:46 +0200 Subject: [PATCH 0095/1566] Implement intrinsics {ctlz,cttz}{,_nonzero} and ctpop --- examples/example.rs | 4 ++++ examples/mini_core.rs | 1 + src/abi.rs | 18 ++++++++++++++++++ src/base.rs | 3 ++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/examples/example.rs b/examples/example.rs index ecc5db5c0db18..05b370f91e08c 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -150,3 +150,7 @@ fn use_array(arr: [u8; 3]) -> u8 { fn repeat_array() -> [u8; 3] { [0; 3] } + +unsafe fn use_ctlz_nonzero(a: u16) -> u16 { + intrinsics::ctlz_nonzero(a) +} diff --git a/examples/mini_core.rs b/examples/mini_core.rs index dc19d66b21446..17d321db345da 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -139,6 +139,7 @@ pub mod intrinsics { pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; pub fn uninit() -> T; + pub fn ctlz_nonzero(x: T) -> T; } } diff --git a/src/abi.rs b/src/abi.rs index 929002f0e8039..0d44952dc0d58 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -500,6 +500,24 @@ pub fn codegen_call<'a, 'tcx: 'a>( let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); } + "ctlz" | "ctlz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "cttz" | "cttz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "ctpop" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } _ => fx .tcx .sess diff --git a/src/base.rs b/src/base.rs index d479e9350686f..31be6e58f4207 100644 --- a/src/base.rs +++ b/src/base.rs @@ -359,7 +359,8 @@ fn trans_stmt<'a, 'tcx: 'a>( UnOp::Not => fx.bcx.ins().bnot(val), UnOp::Neg => match ty.sty { TypeVariants::TyInt(_) => { - let zero = fx.bcx.ins().iconst(types::I64, 0); + let clif_ty = fx.cton_type(ty).unwrap(); + let zero = fx.bcx.ins().iconst(clif_ty, 0); fx.bcx.ins().isub(zero, val) } TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val), From 0b88b4ef09ca293acff898d14ec267c13f2ff3b2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 14:58:47 +0200 Subject: [PATCH 0096/1566] Add patch to disable float fmt, because it is big --- ...-Disable-float-fmt-because-it-is-big.patch | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 0004-Disable-float-fmt-because-it-is-big.patch diff --git a/0004-Disable-float-fmt-because-it-is-big.patch b/0004-Disable-float-fmt-because-it-is-big.patch new file mode 100644 index 0000000000000..44e7ca20c9e25 --- /dev/null +++ b/0004-Disable-float-fmt-because-it-is-big.patch @@ -0,0 +1,75 @@ +From adee817b4cdc2bda63419e0bb47c47551d71825b Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Wed, 8 Aug 2018 14:57:06 +0200 +Subject: [PATCH] Disable float fmt, because it is big + +--- + src/libcore/fmt/mod.rs | 6 ++++-- + src/libcore/num/mod.rs | 8 ++++---- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs +index 928f95e..85dc9f9 100644 +--- a/src/libcore/fmt/mod.rs ++++ b/src/libcore/fmt/mod.rs +@@ -15,13 +15,13 @@ + use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut}; + use marker::PhantomData; + use mem; +-use num::flt2dec; ++//use num::flt2dec; + use ops::Deref; + use result; + use slice; + use str; + +-mod float; ++//mod float; + mod num; + mod builders; + +@@ -1299,6 +1299,7 @@ impl<'a> Formatter<'a> { + Ok(()) + } + ++ /* + /// Takes the formatted parts and applies the padding. + /// Assumes that the caller already has rendered the parts with required precision, + /// so that `self.precision` can be ignored. +@@ -1378,6 +1379,7 @@ impl<'a> Formatter<'a> { + } + Ok(()) + } ++ */ + + /// Writes some data to the underlying buffer contained within this + /// formatter. +diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs +index 09ddf4e..2c0b1a2 100644 +--- a/src/libcore/num/mod.rs ++++ b/src/libcore/num/mod.rs +@@ -170,8 +170,8 @@ impl fmt::UpperHex for Wrapping { + } + + // All these modules are technically private and only exposed for coretests: +-pub mod flt2dec; +-pub mod dec2flt; ++//pub mod flt2dec; ++//pub mod dec2flt; + pub mod bignum; + pub mod diy_float; + +@@ -4613,8 +4613,8 @@ impl fmt::Display for ParseIntError { + } + } + +-#[stable(feature = "rust1", since = "1.0.0")] +-pub use num::dec2flt::ParseFloatError; ++//#[stable(feature = "rust1", since = "1.0.0")] ++//pub use num::dec2flt::ParseFloatError; + + // Conversion traits for primitive integer and float types + // Conversions T -> T are covered by a blanket impl and therefore excluded +-- +2.15.2 (Apple Git-101.1) + From 7f2e68e38e210e54034ffd4957c58098a90b7d98 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 15:38:03 +0200 Subject: [PATCH 0097/1566] Better unimplemented stuff handling --- src/abi.rs | 8 +++----- src/base.rs | 44 +++++++++++++++++++++----------------------- src/lib.rs | 20 +++++++++++++++++++- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 0d44952dc0d58..b3e63dce4cb14 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -329,6 +329,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let intrinsic = &intrinsic[..]; let nil_ty = fx.tcx.mk_nil(); + let u64_layout = fx.layout_of(fx.tcx.types.u64); let usize_layout = fx.layout_of(fx.tcx.types.usize); let ret = return_place.expect("return place"); match intrinsic { @@ -371,7 +372,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( "type_id" => { assert_eq!(args.len(), 0); let type_id = fx.tcx.type_id_hash(substs.type_at(0)); - let type_id = CValue::const_val(fx, usize_layout.ty, type_id as i64); + let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); ret.write_cvalue(fx, type_id); } "min_align_of" => { @@ -518,10 +519,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); ret.write_cvalue(fx, res); } - _ => fx - .tcx - .sess - .fatal(&format!("unsupported intrinsic {}", intrinsic)), + _ => unimpl!("unsupported intrinsic {}", intrinsic), } if let Some((_, dest)) = *destination { let ret_ebb = fx.get_ebb(dest); diff --git a/src/base.rs b/src/base.rs index 31be6e58f4207..6fc61ca1fa8ae 100644 --- a/src/base.rs +++ b/src/base.rs @@ -47,13 +47,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( sig, ); - let comments = match trans_fn(cx, &mut f, inst) { - Ok(comments) => comments, - Err(err) => { - tcx.sess.err(&err); - return; - } - }; + let comments = trans_fn(cx, &mut f, inst); let mut writer = crate::pretty_clif::CommentWriter(comments); let mut cton = String::new(); @@ -104,7 +98,7 @@ pub fn trans_fn<'a, 'tcx: 'a>( cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, f: &mut Function, instance: Instance<'tcx>, -) -> Result, String> { +) -> HashMap { let mir = cx.tcx.optimized_mir(instance.def_id()); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); @@ -145,7 +139,7 @@ pub fn trans_fn<'a, 'tcx: 'a>( fx.bcx.ins().nop(); for stmt in &bb_data.statements { - trans_stmt(fx, ebb, stmt)?; + trans_stmt(fx, ebb, stmt); } let mut terminator_head = "\n".to_string(); @@ -234,14 +228,14 @@ pub fn trans_fn<'a, 'tcx: 'a>( fx.bcx.seal_all_blocks(); fx.bcx.finalize(); - Ok(fx.comments.clone()) + fx.comments.clone() } fn trans_stmt<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: &Statement<'tcx>, -) -> Result<(), String> { +) { fx.tcx.sess.warn(&format!("stmt {:?}", stmt)); let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); @@ -255,7 +249,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let place = trans_place(fx, place); let layout = place.layout(); if layout.for_variant(&*fx, *variant_index).abi == layout::Abi::Uninhabited { - return Ok(()); + return; } match layout.variants { layout::Variants::Single { index } => { @@ -402,14 +396,14 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, true); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - _ => return Err(format!("rval misc {:?} {:?}", operand, to_ty)), + _ => unimpl!("rval misc {:?} {:?}", operand, to_ty), } } Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => { unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty) } Rvalue::Cast(CastKind::Unsize, operand, ty) => { - return Err(format!("rval unsize {:?} {:?}", operand, ty)) + unimpl!("rval unsize {:?} {:?}", operand, ty); } Rvalue::Discriminant(place) => { let place = trans_place(fx, place).to_cvalue(fx); @@ -424,7 +418,7 @@ fn trans_stmt<'a, 'tcx: 'a>( to.write_cvalue(fx, operand); } } - Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), + Rvalue::Len(lval) => unimpl!("rval len {:?}", lval), Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), Rvalue::NullaryOp(NullOp::SizeOf, ty) => { assert!( @@ -436,7 +430,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64); lval.write_cvalue(fx, val); } - Rvalue::Aggregate(_, _) => return Err(format!("shouldn't exist at trans {:?}", rval)), + Rvalue::Aggregate(_, _) => unimpl!("shouldn't exist at trans {:?}", rval), } } StatementKind::StorageLive(_) @@ -448,8 +442,6 @@ fn trans_stmt<'a, 'tcx: 'a>( | StatementKind::UserAssertTy(_, _) => {} StatementKind::InlineAsm { .. } => fx.tcx.sess.fatal("Inline assembly is not supported"), } - - Ok(()) } pub fn trans_get_discriminant<'a, 'tcx: 'a>( @@ -823,15 +815,21 @@ pub fn trans_place<'a, 'tcx: 'a>( Place::Local(local) => fx.get_local_place(*local), Place::Promoted(promoted) => crate::constant::trans_promoted(fx, promoted.0), Place::Static(static_) => { - unimplemented!("static place {:?} ty {:?}", static_.def_id, static_.ty) + unimpl!("static place {:?} ty {:?}", static_.def_id, static_.ty); } Place::Projection(projection) => { let base = trans_place(fx, &projection.base); match projection.elem { - ProjectionElem::Deref => CPlace::Addr( - base.to_cvalue(fx).load_value(fx), - fx.layout_of(place.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx)), - ), + ProjectionElem::Deref => { + let layout = fx.layout_of(place.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx)); + if layout.is_unsized() { + unimpl!("Unsized places are not yet implemented"); + } + CPlace::Addr( + base.to_cvalue(fx).load_value(fx), + layout, + ) + }, ProjectionElem::Field(field, _ty) => base.place_field(fx, field), ProjectionElem::Index(local) => { let index = fx.get_local_place(local).to_cvalue(fx).load_value(fx); diff --git a/src/lib.rs b/src/lib.rs index 8737a2a5954a8..2572fee5c0b7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,6 +40,14 @@ use syntax::symbol::Symbol; use cranelift::codegen::settings; use cranelift_faerie::*; +struct NonFatal(pub String); + +macro_rules! unimpl { + ($($tt:tt)*) => { + panic!(::NonFatal(format!($($tt)*))); + }; +} + mod abi; mod base; mod common; @@ -240,7 +248,17 @@ impl CodegenBackend for CraneliftCodegenBackend { for mono_item in collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 { - base::trans_mono_item(&mut cx, &mut context, mono_item) + let cx = &mut cx; + let context = &mut context; + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(move || { + base::trans_mono_item(cx, context, mono_item); + })); + if let Err(err) = res { + match err.downcast::() { + Ok(non_fatal) => tcx.sess.err(&non_fatal.0), + Err(err) => ::std::panic::resume_unwind(err), + } + } } } From 620d65c661f9d98e958a29c6bad28486cb73e2b6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 16:00:14 +0200 Subject: [PATCH 0098/1566] Fix some small bugs --- ...nd-task-modules-because-they-contain.patch | 62 +++++++++++++++++++ src/abi.rs | 32 ++++++---- 2 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 0005-Disable-future-and-task-modules-because-they-contain.patch diff --git a/0005-Disable-future-and-task-modules-because-they-contain.patch b/0005-Disable-future-and-task-modules-because-they-contain.patch new file mode 100644 index 0000000000000..669927ddcce16 --- /dev/null +++ b/0005-Disable-future-and-task-modules-because-they-contain.patch @@ -0,0 +1,62 @@ +From 439444eb7d5557daa5e8cfafd1317816fefdad70 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Wed, 8 Aug 2018 15:51:42 +0200 +Subject: [PATCH] Disable future and task modules, because they contain unsized + types + +--- + src/libcore/lib.rs | 2 ++ + src/libcore/mem.rs | 6 ++++-- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs +index 71fcff2..7dcbb4b 100644 +--- a/src/libcore/lib.rs ++++ b/src/libcore/lib.rs +@@ -202,9 +202,11 @@ pub mod time; + + pub mod unicode; + ++/* + /* Async */ + pub mod future; + pub mod task; ++*/ + + /* Heap memory allocator trait */ + #[allow(missing_docs)] +diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs +index 642fffa..f5a22ab 100644 +--- a/src/libcore/mem.rs ++++ b/src/libcore/mem.rs +@@ -18,12 +18,12 @@ + use clone; + use cmp; + use fmt; +-use future::{Future, UnsafeFutureObj}; ++//use future::{Future, UnsafeFutureObj}; + use hash; + use intrinsics; + use marker::{Copy, PhantomData, Sized, Unpin, Unsize}; + use ptr; +-use task::{Context, Poll}; ++//use task::{Context, Poll}; + use ops::{Deref, DerefMut, CoerceUnsized}; + + #[stable(feature = "rust1", since = "1.0.0")] +@@ -1148,6 +1148,7 @@ impl<'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for PinM + #[unstable(feature = "pin", issue = "49150")] + impl<'a, T: ?Sized> Unpin for PinMut<'a, T> {} + ++/* + #[unstable(feature = "futures_api", issue = "50547")] + unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinMut<'a, F> + where F: Future + 'a +@@ -1162,3 +1163,4 @@ unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinMut<'a, F> + + unsafe fn drop(_ptr: *mut ()) {} + } ++*/ +-- +2.15.2 (Apple Git-101.1) + diff --git a/src/abi.rs b/src/abi.rs index b3e63dce4cb14..25aab1940987d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -204,7 +204,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb } let func_params = fx.mir.args_iter().map(|local| { - let arg_ty = fx.mir.local_decls[local].ty; + let arg_ty = fx.monomorphize(&fx.mir.local_decls[local].ty); // Adapted from https://github.com/rust-lang/rust/blob/145155dc96757002c7b2e9de8489416e2fdbbd57/src/librustc_codegen_llvm/mir/mod.rs#L442-L482 if Some(local) == fx.mir.spread_arg { @@ -215,7 +215,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb let tupled_arg_tys = match arg_ty.sty { ty::TyTuple(ref tys) => tys, - _ => bug!("spread argument isn't a tuple?!") + _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), }; let mut ebb_params = Vec::new(); @@ -290,11 +290,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let fn_ty = func.layout().ty; let sig = ty_fn_sig(fx.tcx, fn_ty); - let return_place = if let Some((place, _)) = destination { - Some(trans_place(fx, place)) - } else { - None - }; + let return_place = destination.as_ref().map(|(place, _)| trans_place(fx, place)); // Unpack arguments tuple for closures let args = if sig.abi == Abi::RustCall { @@ -331,11 +327,25 @@ pub fn codegen_call<'a, 'tcx: 'a>( let nil_ty = fx.tcx.mk_nil(); let u64_layout = fx.layout_of(fx.tcx.types.u64); let usize_layout = fx.layout_of(fx.tcx.types.usize); - let ret = return_place.expect("return place"); - match intrinsic { - "abort" => { - fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + + let ret = match return_place { + Some(ret) => ret, + None => { + println!("codegen_call(fx, {:?}, {:?}, {:?})", func, args, destination); + // Insert non returning intrinsics here + match intrinsic { + "abort" => { + fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + } + "unreachable" => { + fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + } + _ => unimplemented!("unsupported instrinsic {}", intrinsic), + } + return; } + }; + match intrinsic { "assume" => { assert_eq!(args.len(), 1); } From 7b29b4cec18366764966bb4d4bd415cf6edb3d29 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 16:03:06 +0200 Subject: [PATCH 0099/1566] Update message about crashing on libcore --- Readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index d845ee2815897..615f6c458410f 100644 --- a/Readme.md +++ b/Readme.md @@ -26,7 +26,9 @@ $ ./prepare_libcore.sh $ ./build.sh ``` -> ⚠⚠⚠ You will get a panic because of unimplemented stuff ⚠⚠⚠ +> This should stop with `error: aborting due to <...> previous errors` +> +> Please submit a bug if not ## Not yet supported From 5b85e0fec83f8e55320887219e2f65b7719105f5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 19:33:37 +0200 Subject: [PATCH 0100/1566] Rustfmt --- src/abi.rs | 9 +++++++-- src/base.rs | 13 +++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 25aab1940987d..b6a29d0747522 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -290,7 +290,9 @@ pub fn codegen_call<'a, 'tcx: 'a>( let fn_ty = func.layout().ty; let sig = ty_fn_sig(fx.tcx, fn_ty); - let return_place = destination.as_ref().map(|(place, _)| trans_place(fx, place)); + let return_place = destination + .as_ref() + .map(|(place, _)| trans_place(fx, place)); // Unpack arguments tuple for closures let args = if sig.abi == Abi::RustCall { @@ -331,7 +333,10 @@ pub fn codegen_call<'a, 'tcx: 'a>( let ret = match return_place { Some(ret) => ret, None => { - println!("codegen_call(fx, {:?}, {:?}, {:?})", func, args, destination); + println!( + "codegen_call(fx, {:?}, {:?}, {:?})", + func, args, destination + ); // Insert non returning intrinsics here match intrinsic { "abort" => { diff --git a/src/base.rs b/src/base.rs index 6fc61ca1fa8ae..be8281c59f474 100644 --- a/src/base.rs +++ b/src/base.rs @@ -231,11 +231,7 @@ pub fn trans_fn<'a, 'tcx: 'a>( fx.comments.clone() } -fn trans_stmt<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, - cur_ebb: Ebb, - stmt: &Statement<'tcx>, -) { +fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: &Statement<'tcx>) { fx.tcx.sess.warn(&format!("stmt {:?}", stmt)); let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); @@ -825,11 +821,8 @@ pub fn trans_place<'a, 'tcx: 'a>( if layout.is_unsized() { unimpl!("Unsized places are not yet implemented"); } - CPlace::Addr( - base.to_cvalue(fx).load_value(fx), - layout, - ) - }, + CPlace::Addr(base.to_cvalue(fx).load_value(fx), layout) + } ProjectionElem::Field(field, _ty) => base.place_field(fx, field), ProjectionElem::Index(local) => { let index = fx.get_local_place(local).to_cvalue(fx).load_value(fx); From 5c4a8b0ca05ef677b13a7b86ed4d56431021c021 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 19:42:11 +0200 Subject: [PATCH 0101/1566] Make sure build.sh exits with non-zero error code on errors --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 762dc3a8d9443..a4f5e59bc8936 100755 --- a/build.sh +++ b/build.sh @@ -7,6 +7,6 @@ RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift $RUSTC mini_core.rs --crate-name mini_core && $RUSTC example.rs && $RUSTC mini_core_hello_world.rs && -$RUSTC ../target/libcore/src/libcore/lib.rs +$RUSTC ../target/libcore/src/libcore/lib.rs && rm *.rlib From 72fa53bac39e2e29e3990ae031c34c23d077e7c6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 19:46:16 +0200 Subject: [PATCH 0102/1566] Use correct dylib extension for local os --- build.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a4f5e59bc8936..2fea89d8eeb59 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,17 @@ cargo build || exit 1 cd examples/ -RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.so -L crate=. --crate-type lib" +unamestr=`uname` +if [[ "$unamestr" == 'Linux' ]]; then + dylib_ext='so' +elif [[ "$unamestr" == 'Darwin' ]]; then + dylib_ext='dylib' +else + echo "Unsupported os" + exit 1 +fi + +RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=. --crate-type lib" $RUSTC mini_core.rs --crate-name mini_core && $RUSTC example.rs && From f4e622cedc921395ccd1c73f6a8283973752a210 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 10:46:56 +0200 Subject: [PATCH 0103/1566] Add basic ssa analyzer --- Cargo.lock | 1 + Cargo.toml | 1 + src/abi.rs | 39 ++++++++++++++++++++++++++----------- src/analyze.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/common.rs | 2 +- src/lib.rs | 3 +++ 6 files changed, 86 insertions(+), 12 deletions(-) create mode 100644 src/analyze.rs diff --git a/Cargo.lock b/Cargo.lock index 62e1607beebb2..8f5ee20d25447 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -409,6 +409,7 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/Cargo.toml b/Cargo.toml index 3ccf00cb9657b..f15acbc16d90d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,3 +23,4 @@ target-lexicon = "0.0.3" #goblin = "0.0.17" faerie = "0.4.4" ar = "0.6.0" +bitflags = "1.0.3" diff --git a/src/abi.rs b/src/abi.rs index b6a29d0747522..0680ccb6e586d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -186,17 +186,15 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { } pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb: Ebb) { + let ssa_analyzed = crate::analyze::analyze(fx); + fx.tcx.sess.warn(&format!("ssa {:?}", ssa_analyzed)); + match fx.self_sig().abi { Abi::Rust | Abi::RustCall => {} _ => unimplemented!("declared function with non \"rust\" or \"rust-call\" abi"), } let ret_param = fx.bcx.append_ebb_param(start_ebb, types::I64); - let _ = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: 0, - offset: None, - }); // Dummy stack slot for debugging enum ArgKind { Normal(Value), @@ -237,6 +235,17 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); + + if let ArgKind::Normal(ebb_param) = arg_kind { + if !ssa_analyzed.get(&local).unwrap().contains(crate::analyze::Flags::NOT_SSA) { + let var = Variable(local); + fx.bcx.declare_var(var, fx.cton_type(ty).unwrap()); + fx.bcx.def_var(var, ebb_param); + fx.local_map.insert(local, CPlace::Var(var, layout)); + continue; + } + } + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -270,12 +279,20 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb for local in fx.mir.vars_and_temps_iter() { let ty = fx.mir.local_decls[local].ty; let layout = fx.layout_of(ty); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let place = CPlace::from_stack_slot(fx, stack_slot, ty); + + let place = if ssa_analyzed.get(&local).unwrap().contains(crate::analyze::Flags::NOT_SSA) { + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + CPlace::from_stack_slot(fx, stack_slot, ty) + } else { + let var = Variable(local); + fx.bcx.declare_var(var, fx.cton_type(ty).unwrap()); + CPlace::Var(var, layout) + }; + fx.local_map.insert(local, place); } } diff --git a/src/analyze.rs b/src/analyze.rs new file mode 100644 index 0000000000000..646bc69df3cf1 --- /dev/null +++ b/src/analyze.rs @@ -0,0 +1,52 @@ +use crate::prelude::*; + +use rustc::mir::{StatementKind::*}; + +bitflags! { + pub struct Flags: u8 { + const NOT_SSA = 0b00000001; + } +} + +pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx>) -> HashMap { + let mut flag_map = HashMap::new(); + + for local in fx.mir.local_decls.indices() { + flag_map.insert(local, Flags::empty()); + } + + not_ssa(&mut flag_map, RETURN_PLACE); + + for (local, local_decl) in fx.mir.local_decls.iter_enumerated() { + if fx.cton_type(local_decl.ty).is_none() { + not_ssa(&mut flag_map, local); + } + } + + for bb in fx.mir.basic_blocks().iter() { + for stmt in bb.statements.iter() { + match &stmt.kind { + Assign(_, Rvalue::Ref(_, _, place)) => analyze_non_ssa_place(&mut flag_map, place), + _ => {} + } + } + + match &bb.terminator().kind { + TerminatorKind::Call { destination: Some((place, _)), .. } => analyze_non_ssa_place(&mut flag_map, place), + _ => {} + } + } + + flag_map +} + +fn analyze_non_ssa_place(flag_map: &mut HashMap, place: &Place) { + match place { + Place::Local(local) => not_ssa(flag_map, local), + _ => {} + } +} + +fn not_ssa>(flag_map: &mut HashMap, local: L) { + *flag_map.get_mut(local.borrow()).unwrap() |= Flags::NOT_SSA; +} \ No newline at end of file diff --git a/src/common.rs b/src/common.rs index 35a41dd8a6f6f..033300455c141 100644 --- a/src/common.rs +++ b/src/common.rs @@ -9,7 +9,7 @@ use crate::prelude::*; pub type CurrentBackend = ::cranelift_simplejit::SimpleJITBackend; #[derive(Debug, Copy, Clone, Eq, PartialEq)] -pub struct Variable(Local); +pub struct Variable(pub Local); impl EntityRef for Variable { fn new(u: usize) -> Self { diff --git a/src/lib.rs b/src/lib.rs index 2572fee5c0b7b..b55497394a627 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,8 @@ extern crate rustc_target; extern crate rustc_data_structures; extern crate ar; +#[macro_use] +extern crate bitflags; extern crate faerie; //extern crate goblin; extern crate cranelift; @@ -49,6 +51,7 @@ macro_rules! unimpl { } mod abi; +mod analyze; mod base; mod common; mod constant; From f900b99e27f07cd3ce3dcca8214f01e2ba71832c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 10:55:13 +0200 Subject: [PATCH 0104/1566] Improve build.sh --- build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 2fea89d8eeb59..2a3daa17b59e3 100755 --- a/build.sh +++ b/build.sh @@ -12,11 +12,12 @@ else exit 1 fi -RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=. --crate-type lib" +RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=. --crate-type lib -Og" $RUSTC mini_core.rs --crate-name mini_core && $RUSTC example.rs && $RUSTC mini_core_hello_world.rs && -$RUSTC ../target/libcore/src/libcore/lib.rs && +$RUSTC ../target/libcore/src/libcore/lib.rs 2>&1 | (head -n 10; tail -n 100) || +(rm *.rlib; exit 1) rm *.rlib From 6c86274943032b11c60b8ea3e512d4f6cd23db57 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 11:07:10 +0200 Subject: [PATCH 0105/1566] Implement raw ptr -> usize cast --- examples/example.rs | 4 ++++ src/base.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/example.rs b/examples/example.rs index 05b370f91e08c..bbffb13fabb5d 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -154,3 +154,7 @@ fn repeat_array() -> [u8; 3] { unsafe fn use_ctlz_nonzero(a: u16) -> u16 { intrinsics::ctlz_nonzero(a) } + +fn ptr_as_usize(ptr: *const u8) -> usize { + ptr as usize +} diff --git a/src/base.rs b/src/base.rs index be8281c59f474..15d950ef01a1f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -379,6 +379,9 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & | (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } + (TypeVariants::TyRawPtr(..), TypeVariants::TyUint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { + lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); + } (TypeVariants::TyChar, TypeVariants::TyUint(_)) | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { @@ -392,7 +395,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, true); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - _ => unimpl!("rval misc {:?} {:?}", operand, to_ty), + _ => unimpl!("rval misc {:?} {:?}", from_ty, to_ty), } } Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => { From 9a2b1d4ac3e69d5218c020626fbb867642c703f2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 11:16:46 +0200 Subject: [PATCH 0106/1566] Implement float -> float and int -> float casts --- examples/example.rs | 8 ++++++++ src/base.rs | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/examples/example.rs b/examples/example.rs index bbffb13fabb5d..6f2be6c84b709 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -158,3 +158,11 @@ unsafe fn use_ctlz_nonzero(a: u16) -> u16 { fn ptr_as_usize(ptr: *const u8) -> usize { ptr as usize } + +fn float_cast(a: f32, b: f64) -> (f64, f32) { + (a as f64, b as f32) +} + +fn int_to_float(a: u8, b: i32) -> (f64, f32) { + (a as f64, b as f32) +} diff --git a/src/base.rs b/src/base.rs index 15d950ef01a1f..c26249157ca5c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -395,6 +395,31 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, true); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } + (TypeVariants::TyFloat(from_flt), TypeVariants::TyFloat(to_flt)) => { + let from = operand.load_value(fx); + let res = match (from_flt, to_flt) { + (FloatTy::F32, FloatTy::F64) => { + fx.bcx.ins().fpromote(types::F64, from) + } + (FloatTy::F64, FloatTy::F32) => { + fx.bcx.ins().fdemote(types::F32, from) + } + _ => from, + }; + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } + (TypeVariants::TyInt(_), TypeVariants::TyFloat(_)) => { + let from = operand.load_value(fx); + let f_type = fx.cton_type(to_ty).unwrap(); + let res = fx.bcx.ins().fcvt_from_sint(f_type, from); + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } + (TypeVariants::TyUint(_), TypeVariants::TyFloat(_)) => { + let from = operand.load_value(fx); + let f_type = fx.cton_type(to_ty).unwrap(); + let res = fx.bcx.ins().fcvt_from_uint(f_type, from); + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } _ => unimpl!("rval misc {:?} {:?}", from_ty, to_ty), } } From 566803f288f18d37f05b17bbbdc746eb634af488 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 11:23:04 +0200 Subject: [PATCH 0107/1566] Implement raw ptr -> usize, fn ptr -> usize, usize -> raw ptr casts --- src/base.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index c26249157ca5c..ea607370ebd1b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -379,10 +379,15 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & | (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (TypeVariants::TyRawPtr(..), TypeVariants::TyUint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { + (TypeVariants::TyRawPtr(..), TypeVariants::TyUint(_)) + | (TypeVariants::TyFnPtr(..), TypeVariants::TyUint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { + lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); + } + (TypeVariants::TyUint(_), TypeVariants::TyRawPtr(..)) if from_ty.sty == fx.tcx.types.usize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } (TypeVariants::TyChar, TypeVariants::TyUint(_)) + | (TypeVariants::TyUint(_), TypeVariants::TyChar) | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); From 2fd0d528343009a215119857a4197a827f61214b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 11:25:14 +0200 Subject: [PATCH 0108/1566] Rustfmt --- src/abi.rs | 12 ++++++++++-- src/analyze.rs | 9 ++++++--- src/base.rs | 8 ++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 0680ccb6e586d..38d18b4f68699 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -237,7 +237,11 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb let layout = fx.layout_of(ty); if let ArgKind::Normal(ebb_param) = arg_kind { - if !ssa_analyzed.get(&local).unwrap().contains(crate::analyze::Flags::NOT_SSA) { + if !ssa_analyzed + .get(&local) + .unwrap() + .contains(crate::analyze::Flags::NOT_SSA) + { let var = Variable(local); fx.bcx.declare_var(var, fx.cton_type(ty).unwrap()); fx.bcx.def_var(var, ebb_param); @@ -280,7 +284,11 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb let ty = fx.mir.local_decls[local].ty; let layout = fx.layout_of(ty); - let place = if ssa_analyzed.get(&local).unwrap().contains(crate::analyze::Flags::NOT_SSA) { + let place = if ssa_analyzed + .get(&local) + .unwrap() + .contains(crate::analyze::Flags::NOT_SSA) + { let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, diff --git a/src/analyze.rs b/src/analyze.rs index 646bc69df3cf1..cd53a810fe420 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use rustc::mir::{StatementKind::*}; +use rustc::mir::StatementKind::*; bitflags! { pub struct Flags: u8 { @@ -32,7 +32,10 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx>) -> HashMap } match &bb.terminator().kind { - TerminatorKind::Call { destination: Some((place, _)), .. } => analyze_non_ssa_place(&mut flag_map, place), + TerminatorKind::Call { + destination: Some((place, _)), + .. + } => analyze_non_ssa_place(&mut flag_map, place), _ => {} } } @@ -49,4 +52,4 @@ fn analyze_non_ssa_place(flag_map: &mut HashMap, place: &Place) { fn not_ssa>(flag_map: &mut HashMap, local: L) { *flag_map.get_mut(local.borrow()).unwrap() |= Flags::NOT_SSA; -} \ No newline at end of file +} diff --git a/src/base.rs b/src/base.rs index ea607370ebd1b..844069c04385f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -380,10 +380,14 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } (TypeVariants::TyRawPtr(..), TypeVariants::TyUint(_)) - | (TypeVariants::TyFnPtr(..), TypeVariants::TyUint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { + | (TypeVariants::TyFnPtr(..), TypeVariants::TyUint(_)) + if to_ty.sty == fx.tcx.types.usize.sty => + { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (TypeVariants::TyUint(_), TypeVariants::TyRawPtr(..)) if from_ty.sty == fx.tcx.types.usize.sty => { + (TypeVariants::TyUint(_), TypeVariants::TyRawPtr(..)) + if from_ty.sty == fx.tcx.types.usize.sty => + { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } (TypeVariants::TyChar, TypeVariants::TyUint(_)) From e9422fd4d45c39020e4bc81b5a68d7861fbe9113 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 11:41:34 +0200 Subject: [PATCH 0109/1566] Implement Rvalue::Aggregate(AggregateKind::Array, ...) --- examples/example.rs | 4 ++++ examples/mini_core.rs | 15 +++++++++++++++ src/base.rs | 12 +++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/examples/example.rs b/examples/example.rs index 6f2be6c84b709..9beef71df313f 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -166,3 +166,7 @@ fn float_cast(a: f32, b: f64) -> (f64, f32) { fn int_to_float(a: u8, b: i32) -> (f64, f32) { (a as f64, b as f32) } + +fn make_array() -> [u8; 3] { + [42, 0, 5] +} diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 17d321db345da..2bcdd454dac54 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -30,6 +30,21 @@ unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl Copy for *const T {} +#[lang = "sync"] +pub unsafe trait Sync {} + +unsafe impl Sync for bool {} +unsafe impl Sync for u8 {} +unsafe impl Sync for u16 {} +unsafe impl Sync for u32 {} +unsafe impl Sync for u64 {} +unsafe impl Sync for usize {} +unsafe impl Sync for i8 {} +unsafe impl Sync for i16 {} +unsafe impl Sync for i32 {} +unsafe impl Sync for isize {} +unsafe impl Sync for char {} + #[lang = "freeze"] trait Freeze {} diff --git a/src/base.rs b/src/base.rs index 844069c04385f..19341981ff5fd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -463,7 +463,17 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64); lval.write_cvalue(fx, val); } - Rvalue::Aggregate(_, _) => unimpl!("shouldn't exist at trans {:?}", rval), + Rvalue::Aggregate(kind, operands) => match **kind { + AggregateKind::Array(_ty) => { + for (i, operand) in operands.into_iter().enumerate() { + let operand = trans_operand(fx, operand); + let index = fx.bcx.ins().iconst(types::I64, i as i64); + let to = lval.place_index(fx, index); + to.write_cvalue(fx, operand); + } + } + _ => unimpl!("shouldn't exist at trans {:?}", rval), + }, } } StatementKind::StorageLive(_) From 48701d758d1260346291b8b4c169c5e7e5480136 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 15:08:54 +0200 Subject: [PATCH 0110/1566] Crash on some less code and fix a bug in discriminant read --- build.sh | 2 +- src/base.rs | 15 ++++++++++++--- src/common.rs | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 2a3daa17b59e3..09389c6530fd5 100755 --- a/build.sh +++ b/build.sh @@ -17,7 +17,7 @@ RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift $RUSTC mini_core.rs --crate-name mini_core && $RUSTC example.rs && $RUSTC mini_core_hello_world.rs && -$RUSTC ../target/libcore/src/libcore/lib.rs 2>&1 | (head -n 10; tail -n 100) || +$RUSTC ../target/libcore/src/libcore/lib.rs 2>&1 | (head -n 10; echo "===="; tail -n 1000) || (rm *.rlib; exit 1) rm *.rlib diff --git a/src/base.rs b/src/base.rs index 19341981ff5fd..ae33f4b0c5aec 100644 --- a/src/base.rs +++ b/src/base.rs @@ -483,7 +483,8 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) | StatementKind::UserAssertTy(_, _) => {} - StatementKind::InlineAsm { .. } => fx.tcx.sess.fatal("Inline assembly is not supported"), + + StatementKind::InlineAsm { .. } => unimpl!("Inline assembly is not supported"), } } @@ -527,8 +528,8 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( .. } => { let niche_llty = fx.cton_type(discr_ty).unwrap(); + let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); if niche_variants.start() == niche_variants.end() { - let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); let b = fx .bcx .ins() @@ -557,7 +558,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let if_false = fx .bcx .ins() - .iconst(niche_llty, dataful_variant as u64 as i64); + .iconst(dest_cton_ty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } @@ -826,6 +827,14 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( rhs: CValue<'tcx>, ty: Ty<'tcx>, ) -> CValue<'tcx> { + match lhs.layout().ty.sty { + TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _}) => { + if !ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { + unimpl!("Unsized values are not yet implemented"); + } + }, + _ => bug!("trans_ptr_binop on non ptr"), + } binop_match! { fx, bin_op, false, lhs, rhs, ty, "ptr"; Add (_) bug; diff --git a/src/common.rs b/src/common.rs index 033300455c141..70e2d283f6010 100644 --- a/src/common.rs +++ b/src/common.rs @@ -32,7 +32,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( UintTy::U16 => types::I16, UintTy::U32 => types::I32, UintTy::U64 => types::I64, - UintTy::U128 => unimplemented!("u128"), + UintTy::U128 => unimpl!("u128"), UintTy::Usize => types::I64, }, TypeVariants::TyInt(size) => match size { @@ -40,7 +40,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( IntTy::I16 => types::I16, IntTy::I32 => types::I32, IntTy::I64 => types::I64, - IntTy::I128 => unimplemented!("i128"), + IntTy::I128 => unimpl!("i128"), IntTy::Isize => types::I64, }, TypeVariants::TyChar => types::I32, From a45f0ee6e34331e515e2904afc6bc51a7ad82185 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 15:30:26 +0200 Subject: [PATCH 0111/1566] Add a log for unimplemented stuff --- build.sh | 6 +++--- src/lib.rs | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 09389c6530fd5..a4a37c5437352 100755 --- a/build.sh +++ b/build.sh @@ -17,7 +17,7 @@ RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift $RUSTC mini_core.rs --crate-name mini_core && $RUSTC example.rs && $RUSTC mini_core_hello_world.rs && -$RUSTC ../target/libcore/src/libcore/lib.rs 2>&1 | (head -n 10; echo "===="; tail -n 1000) || -(rm *.rlib; exit 1) -rm *.rlib +$RUSTC ../target/libcore/src/libcore/lib.rs 2>&1 | (head -n 10; echo "===="; tail -n 1000) +cat ../target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" +rm *.rlib ../target/log.txt diff --git a/src/lib.rs b/src/lib.rs index b55497394a627..f09f62ca04842 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -242,12 +242,15 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut context = Context::new(); { + use std::io::Write; let mut cx = CodegenCx { tcx, module: &mut module, constants: HashMap::new(), }; + let mut log = ::std::fs::File::create("../target/log.txt").unwrap(); + for mono_item in collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 { @@ -258,7 +261,10 @@ impl CodegenBackend for CraneliftCodegenBackend { })); if let Err(err) = res { match err.downcast::() { - Ok(non_fatal) => tcx.sess.err(&non_fatal.0), + Ok(non_fatal) => { + writeln!(log, "{}", &non_fatal.0); + tcx.sess.err(&non_fatal.0) + } Err(err) => ::std::panic::resume_unwind(err), } } From 11df0f5bd1349768b322dbb77aa54b3031f6a910 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 15:33:18 +0200 Subject: [PATCH 0112/1566] Remove patch "0004-Disable-float-fmt-because-it-is-big" --- ...-Disable-float-fmt-because-it-is-big.patch | 75 ------------------- ...nd-task-modules-because-they-contain.patch | 0 2 files changed, 75 deletions(-) delete mode 100644 0004-Disable-float-fmt-because-it-is-big.patch rename 0005-Disable-future-and-task-modules-because-they-contain.patch => 0004-Disable-future-and-task-modules-because-they-contain.patch (100%) diff --git a/0004-Disable-float-fmt-because-it-is-big.patch b/0004-Disable-float-fmt-because-it-is-big.patch deleted file mode 100644 index 44e7ca20c9e25..0000000000000 --- a/0004-Disable-float-fmt-because-it-is-big.patch +++ /dev/null @@ -1,75 +0,0 @@ -From adee817b4cdc2bda63419e0bb47c47551d71825b Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Wed, 8 Aug 2018 14:57:06 +0200 -Subject: [PATCH] Disable float fmt, because it is big - ---- - src/libcore/fmt/mod.rs | 6 ++++-- - src/libcore/num/mod.rs | 8 ++++---- - 2 files changed, 8 insertions(+), 6 deletions(-) - -diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs -index 928f95e..85dc9f9 100644 ---- a/src/libcore/fmt/mod.rs -+++ b/src/libcore/fmt/mod.rs -@@ -15,13 +15,13 @@ - use cell::{UnsafeCell, Cell, RefCell, Ref, RefMut}; - use marker::PhantomData; - use mem; --use num::flt2dec; -+//use num::flt2dec; - use ops::Deref; - use result; - use slice; - use str; - --mod float; -+//mod float; - mod num; - mod builders; - -@@ -1299,6 +1299,7 @@ impl<'a> Formatter<'a> { - Ok(()) - } - -+ /* - /// Takes the formatted parts and applies the padding. - /// Assumes that the caller already has rendered the parts with required precision, - /// so that `self.precision` can be ignored. -@@ -1378,6 +1379,7 @@ impl<'a> Formatter<'a> { - } - Ok(()) - } -+ */ - - /// Writes some data to the underlying buffer contained within this - /// formatter. -diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 09ddf4e..2c0b1a2 100644 ---- a/src/libcore/num/mod.rs -+++ b/src/libcore/num/mod.rs -@@ -170,8 +170,8 @@ impl fmt::UpperHex for Wrapping { - } - - // All these modules are technically private and only exposed for coretests: --pub mod flt2dec; --pub mod dec2flt; -+//pub mod flt2dec; -+//pub mod dec2flt; - pub mod bignum; - pub mod diy_float; - -@@ -4613,8 +4613,8 @@ impl fmt::Display for ParseIntError { - } - } - --#[stable(feature = "rust1", since = "1.0.0")] --pub use num::dec2flt::ParseFloatError; -+//#[stable(feature = "rust1", since = "1.0.0")] -+//pub use num::dec2flt::ParseFloatError; - - // Conversion traits for primitive integer and float types - // Conversions T -> T are covered by a blanket impl and therefore excluded --- -2.15.2 (Apple Git-101.1) - diff --git a/0005-Disable-future-and-task-modules-because-they-contain.patch b/0004-Disable-future-and-task-modules-because-they-contain.patch similarity index 100% rename from 0005-Disable-future-and-task-modules-because-they-contain.patch rename to 0004-Disable-future-and-task-modules-because-they-contain.patch From 4c312faf90ad78b38ec5925427727200d80abf8f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 15:36:02 +0200 Subject: [PATCH 0113/1566] brz <-> brnz --- src/base.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index ae33f4b0c5aec..4bc3455965d4c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -169,9 +169,9 @@ pub fn trans_fn<'a, 'tcx: 'a>( let cond = trans_operand(fx, cond).load_value(fx); let target = fx.get_ebb(*target); if *expected { - fx.bcx.ins().brz(cond, target, &[]); - } else { fx.bcx.ins().brnz(cond, target, &[]); + } else { + fx.bcx.ins().brz(cond, target, &[]); }; fx.bcx.ins().trap(TrapCode::User(!0)); } From 913daae0b439840e312b8d601772ef4d3fd3b492 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 15:43:47 +0200 Subject: [PATCH 0114/1566] Color libcore build output --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a4a37c5437352..feeadfc92980a 100755 --- a/build.sh +++ b/build.sh @@ -18,6 +18,6 @@ $RUSTC mini_core.rs --crate-name mini_core && $RUSTC example.rs && $RUSTC mini_core_hello_world.rs && -$RUSTC ../target/libcore/src/libcore/lib.rs 2>&1 | (head -n 10; echo "===="; tail -n 1000) +$RUSTC ../target/libcore/src/libcore/lib.rs --color=always 2>&1 | (head -n 10; echo "===="; tail -n 1000) cat ../target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" rm *.rlib ../target/log.txt From e1ac09a3f042c0afec8ed3398e9b3b3912fc75ea Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 15:44:01 +0200 Subject: [PATCH 0115/1566] Implement bool -> int cast --- src/base.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/base.rs b/src/base.rs index 4bc3455965d4c..6e7d1574fffe5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -429,6 +429,17 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & let res = fx.bcx.ins().fcvt_from_uint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } + (TypeVariants::TyBool, TypeVariants::TyUint(_)) + | (TypeVariants::TyBool, TypeVariants::TyInt(_)) => { + let to_ty = fx.cton_type(to_ty).unwrap(); + let from = operand.load_value(fx); + let res = if to_ty != types::I8 { + fx.bcx.ins().uextend(to_ty, from) + } else { + from + }; + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } _ => unimpl!("rval misc {:?} {:?}", from_ty, to_ty), } } From 742abd011b651452282a73acbd979559c52fac2c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Aug 2018 15:56:24 +0200 Subject: [PATCH 0116/1566] Implement intrinsic arith_offset --- src/abi.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/abi.rs b/src/abi.rs index 38d18b4f68699..0131c920aa00c 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -379,6 +379,14 @@ pub fn codegen_call<'a, 'tcx: 'a>( "assume" => { assert_eq!(args.len(), 1); } + "arith_offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + let res = CValue::ByVal(res, ret.layout()); + ret.write_cvalue(fx, res); + } "likely" | "unlikely" => { assert_eq!(args.len(), 1); ret.write_cvalue(fx, args[0]); From 5629c423ffdf5315ee4e4140d86b6b025ba7cb14 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Aug 2018 19:09:21 +0200 Subject: [PATCH 0117/1566] Add #!/bin/bash to build.sh --- build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.sh b/build.sh index feeadfc92980a..0578ee8526d7f 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,5 @@ +#!/bin/bash + cargo build || exit 1 cd examples/ From 5ebcea23e4e057a3c298ae14f3ea62033d831a18 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Aug 2018 19:20:13 +0200 Subject: [PATCH 0118/1566] Extract codegen_intrinsic_call --- src/abi.rs | 408 +++++++++++++++++++++++++++------------------------- src/base.rs | 4 +- 2 files changed, 212 insertions(+), 200 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 0131c920aa00c..fb49478bcc47d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -351,10 +351,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; - let nil_ty = fx.tcx.mk_nil(); - let u64_layout = fx.layout_of(fx.tcx.types.u64); - let usize_layout = fx.layout_of(fx.tcx.types.usize); - let ret = match return_place { Some(ret) => ret, None => { @@ -375,200 +371,9 @@ pub fn codegen_call<'a, 'tcx: 'a>( return; } }; - match intrinsic { - "assume" => { - assert_eq!(args.len(), 1); - } - "arith_offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); - let res = fx.bcx.ins().iadd(base, offset); - let res = CValue::ByVal(res, ret.layout()); - ret.write_cvalue(fx, res); - } - "likely" | "unlikely" => { - assert_eq!(args.len(), 1); - ret.write_cvalue(fx, args[0]); - } - "copy" | "copy_nonoverlapping" => { - let elem_ty = substs.type_at(0); - let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); - let elem_size = fx.bcx.ins().iconst(types::I64, elem_size as i64); - assert_eq!(args.len(), 3); - let src = args[0]; - let dst = args[1]; - let count = args[2].load_value(fx); - let byte_amount = fx.bcx.ins().imul(count, elem_size); - fx.easy_call( - "memmove", - &[dst, src, CValue::ByVal(byte_amount, usize_layout)], - nil_ty, - ); - } - "discriminant_value" => { - assert_eq!(args.len(), 1); - let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); - ret.write_cvalue(fx, discr); - } - "size_of" => { - assert_eq!(args.len(), 0); - let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); - let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); - ret.write_cvalue(fx, size_of); - } - "type_id" => { - assert_eq!(args.len(), 0); - let type_id = fx.tcx.type_id_hash(substs.type_at(0)); - let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); - ret.write_cvalue(fx, type_id); - } - "min_align_of" => { - assert_eq!(args.len(), 0); - let min_align = fx.layout_of(substs.type_at(0)).align.abi(); - let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); - ret.write_cvalue(fx, min_align); - } - _ if intrinsic.starts_with("unchecked_") => { - assert_eq!(args.len(), 2); - let bin_op = match intrinsic { - "unchecked_div" => BinOp::Div, - "unchecked_rem" => BinOp::Rem, - "unchecked_shl" => BinOp::Shl, - "unchecked_shr" => BinOp::Shr, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match ret.layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - TypeVariants::TyInt(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - _ if intrinsic.ends_with("_with_overflow") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); - let bin_op = match intrinsic { - "add_with_overflow" => BinOp::Add, - "sub_with_overflow" => BinOp::Sub, - "mul_with_overflow" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match args[0].layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - TypeVariants::TyInt(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - _ if intrinsic.starts_with("overflowing_") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); - let bin_op = match intrinsic { - "overflowing_add" => BinOp::Add, - "overflowing_sub" => BinOp::Sub, - "overflowing_mul" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match args[0].layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - TypeVariants::TyInt(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - "offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); - let res = fx.bcx.ins().iadd(base, offset); - ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); - } - "transmute" => { - assert_eq!(args.len(), 1); - let src_ty = substs.type_at(0); - let dst_ty = substs.type_at(1); - assert_eq!(args[0].layout().ty, src_ty); - let addr = args[0].force_stack(fx); - let dst_layout = fx.layout_of(dst_ty); - ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) - } - "uninit" => { - assert_eq!(args.len(), 0); - let ty = substs.type_at(0); - let layout = fx.layout_of(ty); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); - let uninit_val = uninit_place.to_cvalue(fx); - ret.write_cvalue(fx, uninit_val); - } - "ctlz" | "ctlz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "cttz" | "cttz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "ctpop" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - _ => unimpl!("unsupported intrinsic {}", intrinsic), - } + + codegen_intrinsic_call(fx, intrinsic, substs, args, ret); + if let Some((_, dest)) = *destination { let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); @@ -614,3 +419,210 @@ pub fn codegen_call<'a, 'tcx: 'a>( fx.bcx.ins().trap(TrapCode::User(!0)); } } + +fn codegen_intrinsic_call<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + intrinsic: &str, + substs: &Substs<'tcx>, + args: Vec>, + ret: CPlace<'tcx>, +) { + let nil_ty = fx.tcx.mk_nil(); + let u64_layout = fx.layout_of(fx.tcx.types.u64); + let usize_layout = fx.layout_of(fx.tcx.types.usize); + + match intrinsic { + "assume" => { + assert_eq!(args.len(), 1); + } + "arith_offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + let res = CValue::ByVal(res, ret.layout()); + ret.write_cvalue(fx, res); + } + "likely" | "unlikely" => { + assert_eq!(args.len(), 1); + ret.write_cvalue(fx, args[0]); + } + "copy" | "copy_nonoverlapping" => { + let elem_ty = substs.type_at(0); + let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); + let elem_size = fx.bcx.ins().iconst(types::I64, elem_size as i64); + assert_eq!(args.len(), 3); + let src = args[0]; + let dst = args[1]; + let count = args[2].load_value(fx); + let byte_amount = fx.bcx.ins().imul(count, elem_size); + fx.easy_call( + "memmove", + &[dst, src, CValue::ByVal(byte_amount, usize_layout)], + nil_ty, + ); + } + "discriminant_value" => { + assert_eq!(args.len(), 1); + let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); + ret.write_cvalue(fx, discr); + } + "size_of" => { + assert_eq!(args.len(), 0); + let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); + let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); + ret.write_cvalue(fx, size_of); + } + "type_id" => { + assert_eq!(args.len(), 0); + let type_id = fx.tcx.type_id_hash(substs.type_at(0)); + let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); + ret.write_cvalue(fx, type_id); + } + "min_align_of" => { + assert_eq!(args.len(), 0); + let min_align = fx.layout_of(substs.type_at(0)).align.abi(); + let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); + ret.write_cvalue(fx, min_align); + } + _ if intrinsic.starts_with("unchecked_") => { + assert_eq!(args.len(), 2); + let bin_op = match intrinsic { + "unchecked_div" => BinOp::Div, + "unchecked_rem" => BinOp::Rem, + "unchecked_shl" => BinOp::Shl, + "unchecked_shr" => BinOp::Shr, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match ret.layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + _ if intrinsic.ends_with("_with_overflow") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "add_with_overflow" => BinOp::Add, + "sub_with_overflow" => BinOp::Sub, + "mul_with_overflow" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + _ if intrinsic.starts_with("overflowing_") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "overflowing_add" => BinOp::Add, + "overflowing_sub" => BinOp::Sub, + "overflowing_mul" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + "offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); + } + "transmute" => { + assert_eq!(args.len(), 1); + let src_ty = substs.type_at(0); + let dst_ty = substs.type_at(1); + assert_eq!(args[0].layout().ty, src_ty); + let addr = args[0].force_stack(fx); + let dst_layout = fx.layout_of(dst_ty); + ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) + } + "uninit" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_val = uninit_place.to_cvalue(fx); + ret.write_cvalue(fx, uninit_val); + } + "ctlz" | "ctlz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "cttz" | "cttz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "ctpop" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + _ => unimpl!("unsupported intrinsic {}", intrinsic), + } +} diff --git a/src/base.rs b/src/base.rs index 6e7d1574fffe5..5ece23fc4db01 100644 --- a/src/base.rs +++ b/src/base.rs @@ -839,11 +839,11 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( ty: Ty<'tcx>, ) -> CValue<'tcx> { match lhs.layout().ty.sty { - TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _}) => { + TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) => { if !ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { unimpl!("Unsized values are not yet implemented"); } - }, + } _ => bug!("trans_ptr_binop on non ptr"), } binop_match! { From 29ab744f6250c075456990439bf6b25608fbefe2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Aug 2018 19:31:02 +0200 Subject: [PATCH 0119/1566] A small change --- src/abi.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index fb49478bcc47d..b1d9e94b2720b 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -315,10 +315,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( let fn_ty = func.layout().ty; let sig = ty_fn_sig(fx.tcx, fn_ty); - let return_place = destination - .as_ref() - .map(|(place, _)| trans_place(fx, place)); - // Unpack arguments tuple for closures let args = if sig.abi == Abi::RustCall { assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); @@ -351,8 +347,8 @@ pub fn codegen_call<'a, 'tcx: 'a>( let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; - let ret = match return_place { - Some(ret) => ret, + let ret = match destination { + Some((place, _)) => trans_place(fx, place), None => { println!( "codegen_call(fx, {:?}, {:?}, {:?})", @@ -384,8 +380,8 @@ pub fn codegen_call<'a, 'tcx: 'a>( } } - let return_ptr = match return_place { - Some(place) => place.expect_addr(), + let return_ptr = match destination { + Some((place, _)) => trans_place(fx, place).expect_addr(), None => fx.bcx.ins().iconst(types::I64, 0), }; From 973f191136cece92374494a7cf99eae1286818a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Aug 2018 19:43:01 +0200 Subject: [PATCH 0120/1566] Move more code to codegen_intrinsic_call --- src/abi.rs | 472 +++++++++++++++++++++++++++-------------------------- 1 file changed, 238 insertions(+), 234 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index b1d9e94b2720b..23e4d5b63a06a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -342,42 +342,8 @@ pub fn codegen_call<'a, 'tcx: 'a>( .collect::>() }; - if let TypeVariants::TyFnDef(def_id, substs) = fn_ty.sty { - if sig.abi == Abi::RustIntrinsic { - let intrinsic = fx.tcx.item_name(def_id).as_str(); - let intrinsic = &intrinsic[..]; - - let ret = match destination { - Some((place, _)) => trans_place(fx, place), - None => { - println!( - "codegen_call(fx, {:?}, {:?}, {:?})", - func, args, destination - ); - // Insert non returning intrinsics here - match intrinsic { - "abort" => { - fx.bcx.ins().trap(TrapCode::User(!0 - 1)); - } - "unreachable" => { - fx.bcx.ins().trap(TrapCode::User(!0 - 1)); - } - _ => unimplemented!("unsupported instrinsic {}", intrinsic), - } - return; - } - }; - - codegen_intrinsic_call(fx, intrinsic, substs, args, ret); - - if let Some((_, dest)) = *destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); - } else { - fx.bcx.ins().trap(TrapCode::User(!0)); - } - return; - } + if codegen_intrinsic_call(fx, fn_ty, sig, &args, destination) { + return; } let return_ptr = match destination { @@ -418,207 +384,245 @@ pub fn codegen_call<'a, 'tcx: 'a>( fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, - intrinsic: &str, - substs: &Substs<'tcx>, - args: Vec>, - ret: CPlace<'tcx>, -) { - let nil_ty = fx.tcx.mk_nil(); - let u64_layout = fx.layout_of(fx.tcx.types.u64); - let usize_layout = fx.layout_of(fx.tcx.types.usize); + fn_ty: Ty<'tcx>, + sig: FnSig<'tcx>, + args: &[CValue<'tcx>], + destination: &Option<(Place<'tcx>, BasicBlock)>, +) -> bool { + if let TypeVariants::TyFnDef(def_id, substs) = fn_ty.sty { + if sig.abi == Abi::RustIntrinsic { + let intrinsic = fx.tcx.item_name(def_id).as_str(); + let intrinsic = &intrinsic[..]; - match intrinsic { - "assume" => { - assert_eq!(args.len(), 1); - } - "arith_offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); - let res = fx.bcx.ins().iadd(base, offset); - let res = CValue::ByVal(res, ret.layout()); - ret.write_cvalue(fx, res); - } - "likely" | "unlikely" => { - assert_eq!(args.len(), 1); - ret.write_cvalue(fx, args[0]); - } - "copy" | "copy_nonoverlapping" => { - let elem_ty = substs.type_at(0); - let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); - let elem_size = fx.bcx.ins().iconst(types::I64, elem_size as i64); - assert_eq!(args.len(), 3); - let src = args[0]; - let dst = args[1]; - let count = args[2].load_value(fx); - let byte_amount = fx.bcx.ins().imul(count, elem_size); - fx.easy_call( - "memmove", - &[dst, src, CValue::ByVal(byte_amount, usize_layout)], - nil_ty, - ); - } - "discriminant_value" => { - assert_eq!(args.len(), 1); - let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); - ret.write_cvalue(fx, discr); - } - "size_of" => { - assert_eq!(args.len(), 0); - let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); - let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); - ret.write_cvalue(fx, size_of); - } - "type_id" => { - assert_eq!(args.len(), 0); - let type_id = fx.tcx.type_id_hash(substs.type_at(0)); - let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); - ret.write_cvalue(fx, type_id); - } - "min_align_of" => { - assert_eq!(args.len(), 0); - let min_align = fx.layout_of(substs.type_at(0)).align.abi(); - let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); - ret.write_cvalue(fx, min_align); - } - _ if intrinsic.starts_with("unchecked_") => { - assert_eq!(args.len(), 2); - let bin_op = match intrinsic { - "unchecked_div" => BinOp::Div, - "unchecked_rem" => BinOp::Rem, - "unchecked_shl" => BinOp::Shl, - "unchecked_shr" => BinOp::Shr, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match ret.layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - TypeVariants::TyInt(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - _ if intrinsic.ends_with("_with_overflow") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); - let bin_op = match intrinsic { - "add_with_overflow" => BinOp::Add, - "sub_with_overflow" => BinOp::Sub, - "mul_with_overflow" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match args[0].layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - TypeVariants::TyInt(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - _ if intrinsic.starts_with("overflowing_") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); - let bin_op = match intrinsic { - "overflowing_add" => BinOp::Add, - "overflowing_sub" => BinOp::Sub, - "overflowing_mul" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match args[0].layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - TypeVariants::TyInt(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), + let ret = match destination { + Some((place, _)) => trans_place(fx, place), + None => { + println!( + "codegen_call(fx, _, {:?}, {:?})", + args, destination + ); + // Insert non returning intrinsics here + match intrinsic { + "abort" => { + fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + } + "unreachable" => { + fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + } + _ => unimplemented!("unsupported instrinsic {}", intrinsic), + } + return true; + } }; - ret.write_cvalue(fx, res); - } - "offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); - let res = fx.bcx.ins().iadd(base, offset); - ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); - } - "transmute" => { - assert_eq!(args.len(), 1); - let src_ty = substs.type_at(0); - let dst_ty = substs.type_at(1); - assert_eq!(args[0].layout().ty, src_ty); - let addr = args[0].force_stack(fx); - let dst_layout = fx.layout_of(dst_ty); - ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) - } - "uninit" => { - assert_eq!(args.len(), 0); - let ty = substs.type_at(0); - let layout = fx.layout_of(ty); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); - let uninit_val = uninit_place.to_cvalue(fx); - ret.write_cvalue(fx, uninit_val); - } - "ctlz" | "ctlz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "cttz" | "cttz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "ctpop" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); - ret.write_cvalue(fx, res); + let nil_ty = fx.tcx.mk_nil(); + let u64_layout = fx.layout_of(fx.tcx.types.u64); + let usize_layout = fx.layout_of(fx.tcx.types.usize); + + match intrinsic { + "assume" => { + assert_eq!(args.len(), 1); + } + "arith_offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + let res = CValue::ByVal(res, ret.layout()); + ret.write_cvalue(fx, res); + } + "likely" | "unlikely" => { + assert_eq!(args.len(), 1); + ret.write_cvalue(fx, args[0]); + } + "copy" | "copy_nonoverlapping" => { + let elem_ty = substs.type_at(0); + let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); + let elem_size = fx.bcx.ins().iconst(types::I64, elem_size as i64); + assert_eq!(args.len(), 3); + let src = args[0]; + let dst = args[1]; + let count = args[2].load_value(fx); + let byte_amount = fx.bcx.ins().imul(count, elem_size); + fx.easy_call( + "memmove", + &[dst, src, CValue::ByVal(byte_amount, usize_layout)], + nil_ty, + ); + } + "discriminant_value" => { + assert_eq!(args.len(), 1); + let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); + ret.write_cvalue(fx, discr); + } + "size_of" => { + assert_eq!(args.len(), 0); + let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); + let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); + ret.write_cvalue(fx, size_of); + } + "type_id" => { + assert_eq!(args.len(), 0); + let type_id = fx.tcx.type_id_hash(substs.type_at(0)); + let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); + ret.write_cvalue(fx, type_id); + } + "min_align_of" => { + assert_eq!(args.len(), 0); + let min_align = fx.layout_of(substs.type_at(0)).align.abi(); + let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); + ret.write_cvalue(fx, min_align); + } + _ if intrinsic.starts_with("unchecked_") => { + assert_eq!(args.len(), 2); + let bin_op = match intrinsic { + "unchecked_div" => BinOp::Div, + "unchecked_rem" => BinOp::Rem, + "unchecked_shl" => BinOp::Shl, + "unchecked_shr" => BinOp::Shr, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match ret.layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + _ if intrinsic.ends_with("_with_overflow") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "add_with_overflow" => BinOp::Add, + "sub_with_overflow" => BinOp::Sub, + "mul_with_overflow" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + _ if intrinsic.starts_with("overflowing_") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "overflowing_add" => BinOp::Add, + "overflowing_sub" => BinOp::Sub, + "overflowing_mul" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + TypeVariants::TyUint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + TypeVariants::TyInt(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + "offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); + } + "transmute" => { + assert_eq!(args.len(), 1); + let src_ty = substs.type_at(0); + let dst_ty = substs.type_at(1); + assert_eq!(args[0].layout().ty, src_ty); + let addr = args[0].force_stack(fx); + let dst_layout = fx.layout_of(dst_ty); + ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) + } + "uninit" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_val = uninit_place.to_cvalue(fx); + ret.write_cvalue(fx, uninit_val); + } + "ctlz" | "ctlz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "cttz" | "cttz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "ctpop" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + _ => unimpl!("unsupported intrinsic {}", intrinsic), + } + + if let Some((_, dest)) = *destination { + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + } else { + fx.bcx.ins().trap(TrapCode::User(!0)); + } + return true; } - _ => unimpl!("unsupported intrinsic {}", intrinsic), } + + false } From 4df09f73255e0fba4d47f8ac0dd8490f09b03d16 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 10:58:31 +0200 Subject: [PATCH 0121/1566] Pass CPlace to codegen_intrinsic_call --- src/abi.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 23e4d5b63a06a..65271974e7266 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -342,12 +342,16 @@ pub fn codegen_call<'a, 'tcx: 'a>( .collect::>() }; + let destination = destination.as_ref().map(|(place, bb)| { + (trans_place(fx, place), *bb) + }); + if codegen_intrinsic_call(fx, fn_ty, sig, &args, destination) { return; } let return_ptr = match destination { - Some((place, _)) => trans_place(fx, place).expect_addr(), + Some((place, _)) => place.expect_addr(), None => fx.bcx.ins().iconst(types::I64, 0), }; @@ -374,7 +378,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( fx.bcx.ins().call_indirect(sig, func, &call_args); } } - if let Some((_, dest)) = *destination { + if let Some((_, dest)) = destination { let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { @@ -387,7 +391,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( fn_ty: Ty<'tcx>, sig: FnSig<'tcx>, args: &[CValue<'tcx>], - destination: &Option<(Place<'tcx>, BasicBlock)>, + destination: Option<(CPlace<'tcx>, BasicBlock)>, ) -> bool { if let TypeVariants::TyFnDef(def_id, substs) = fn_ty.sty { if sig.abi == Abi::RustIntrinsic { @@ -395,7 +399,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let intrinsic = &intrinsic[..]; let ret = match destination { - Some((place, _)) => trans_place(fx, place), + Some((place, _)) => place, None => { println!( "codegen_call(fx, _, {:?}, {:?})", @@ -614,7 +618,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimpl!("unsupported intrinsic {}", intrinsic), } - if let Some((_, dest)) = *destination { + if let Some((_, dest)) = destination { let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { From b391524b4f59ea250939def0580c0754eb839c6c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 11:01:48 +0200 Subject: [PATCH 0122/1566] Move return codegen to abi.rs --- src/abi.rs | 4 ++++ src/base.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index 65271974e7266..2c893d4939013 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -386,6 +386,10 @@ pub fn codegen_call<'a, 'tcx: 'a>( } } +pub fn codegen_return(fx: &mut FunctionCx) { + fx.bcx.ins().return_(&[]); +} + fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, fn_ty: Ty<'tcx>, diff --git a/src/base.rs b/src/base.rs index 5ece23fc4db01..a610a066ffc58 100644 --- a/src/base.rs +++ b/src/base.rs @@ -157,7 +157,7 @@ pub fn trans_fn<'a, 'tcx: 'a>( fx.bcx.ins().jump(ebb, &[]); } TerminatorKind::Return => { - fx.bcx.ins().return_(&[]); + crate::abi::codegen_return(fx); } TerminatorKind::Assert { cond, From dc323d7ffa9a5563f8c4f891992ac988db1f96fd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 12:04:54 +0200 Subject: [PATCH 0123/1566] Don't call finalize_all and then finalize_function --- src/base.rs | 17 +++++------- src/lib.rs | 80 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/src/base.rs b/src/base.rs index a610a066ffc58..4f7a086d748e2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -74,23 +74,20 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( context.func = f; // TODO: cranelift doesn't yet support some of the things needed - // cx.module.define_function(func_id, context).unwrap(); + if false { + cx.module.define_function(func_id, context).unwrap(); + cx.defined_functions.push(func_id); + } context.clear(); } - inst => cx - .tcx - .sess - .warn(&format!("Unimplemented instance {:?}", inst)), + inst => unimpl!("Unimplemented instance {:?}", inst), }, - MonoItem::Static(def_id) => cx - .tcx - .sess - .err(&format!("Unimplemented static mono item {:?}", def_id)), + MonoItem::Static(def_id) => unimpl!("Unimplemented static mono item {:?}", def_id), MonoItem::GlobalAsm(node_id) => cx .tcx .sess - .err(&format!("Unimplemented global asm mono item {:?}", node_id)), + .fatal(&format!("Unimplemented global asm mono item {:?}", node_id)), } } diff --git a/src/lib.rs b/src/lib.rs index f09f62ca04842..2a0f86f66b56b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, macro_at_most_once_rep)] +#![feature(rustc_private, macro_at_most_once_rep, iterator_find_map)] #![allow(intra_doc_link_resolution_failure)] extern crate syntax; @@ -100,6 +100,7 @@ pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, pub constants: HashMap, + pub defined_functions: Vec, } struct CraneliftMetadataLoader; @@ -241,12 +242,13 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut module: Module = Module::new(SimpleJITBuilder::new()); let mut context = Context::new(); - { + let defined_functions = { use std::io::Write; let mut cx = CodegenCx { tcx, module: &mut module, constants: HashMap::new(), + defined_functions: Vec::new(), }; let mut log = ::std::fs::File::create("../target/log.txt").unwrap(); @@ -269,49 +271,61 @@ impl CodegenBackend for CraneliftCodegenBackend { } } } - } + + std::mem::replace(&mut cx.defined_functions, Vec::new()) + }; tcx.sess.warn("Compiled everything"); // TODO: this doesn't work most of the time if false { - module.finalize_all(); - tcx.sess.warn("Finalized everything"); - - for mono_item in - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 - { + let call_instance = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0.into_iter().find_map(|mono_item| { let inst = match mono_item { MonoItem::Fn(inst) => inst, - _ => continue, + _ => return None, }; //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { - if tcx.absolute_item_path_str(inst.def_id()) != "example::option_unwrap_or" { - continue; + if tcx.absolute_item_path_str(inst.def_id()) == "example::option_unwrap_or" { + Some(inst) + } else { + None + } + }).unwrap(); + + + let fn_ty = call_instance.ty(tcx); + let sig = cton_sig_from_fn_ty(tcx, fn_ty); + let def_path_based_names = + ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); + let mut name = String::new(); + def_path_based_names.push_instance_as_string(call_instance, &mut name); + let called_func_id = module + .declare_function(&name, Linkage::Import, &sig) + .unwrap(); + + for func_id in defined_functions { + if func_id != called_func_id { + module.finalize_function(func_id); } - - let fn_ty = inst.ty(tcx); - let sig = cton_sig_from_fn_ty(tcx, fn_ty); - let def_path_based_names = - ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); - let mut name = String::new(); - def_path_based_names.push_instance_as_string(inst, &mut name); - let func_id = module - .declare_function(&name, Linkage::Import, &sig) - .unwrap(); - - let finalized_function: *const u8 = module.finalize_function(func_id); - /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = 0u32; - f(&mut res); - tcx.sess.warn(&format!("ret_42 returned {}", res));*/ - let f: extern "C" fn(&mut bool, &u8, bool) = - unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = false; - f(&mut res, &3, false); - tcx.sess.warn(&format!("option_unwrap_or returned {}", res)); } + tcx.sess.warn("Finalized everything"); + + let finalized_function: *const u8 = module.finalize_function(called_func_id); + /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = 0u32; + f(&mut res); + tcx.sess.warn(&format!("ret_42 returned {}", res));*/ + /*let f: extern "C" fn(&mut bool, &u8, bool) = +- unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = false; + f(&mut res, &3, false); + tcx.sess.warn(&format!("option_unwrap_or returned {}", res));*/ + let f: extern "C" fn(&mut u8, isize, *const *const u8) = + unsafe { ::std::mem::transmute(finalized_function) }; + let mut res = 0; + f(&mut res, 0, 0 as *const _); + tcx.sess.warn(&format!("main returned {}", res)); module.finish(); } From 419cbcbe2fa365a3251fd4361fa04eaae09dba89 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 12:34:46 +0200 Subject: [PATCH 0124/1566] Refactor abi.rs to make it easier to change the abi --- src/abi.rs | 215 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 163 insertions(+), 52 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 2c893d4939013..ccb55a45ab7ce 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -5,13 +5,53 @@ use rustc_target::spec::abi::Abi; use crate::prelude::*; +#[derive(Debug)] +enum PassMode { + NoPass, + ByVal(Type), + ByRef, +} + +impl PassMode { + fn get_param_ty(self, _fx: &FunctionCx) -> Type { + match self { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(cton_type) => cton_type, + PassMode::ByRef => types::I64, + } + } +} + +fn get_pass_mode<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + abi: Abi, + ty: Ty<'tcx>, + is_return: bool, +) -> PassMode { + if ty.sty == tcx.mk_nil().sty { + if is_return { + //if false { + PassMode::NoPass + } else { + PassMode::ByRef + } + } else if let Some(ret_ty) = crate::common::cton_type_from_ty(tcx, ty) { + PassMode::ByVal(ret_ty) + } else { + if abi == Abi::C { + unimplemented!("Non scalars are not yet supported for \"C\" abi"); + } + PassMode::ByRef + } +} + pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>, ) -> Signature { let sig = ty_fn_sig(tcx, fn_ty); assert!(!sig.variadic, "Variadic function are not yet supported"); - let (call_conv, inputs, _output): (CallConv, Vec, Ty) = match sig.abi { + let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::Fast, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { @@ -34,21 +74,35 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), _ => unimplemented!("unsupported abi {:?}", sig.abi), }; + + let inputs = inputs + .into_iter() + .filter_map(|ty| match get_pass_mode(tcx, sig.abi, ty, false) { + PassMode::ByVal(cton_ty) => Some(cton_ty), + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByRef => Some(types::I64), + }); + + let (params, returns) = match get_pass_mode(tcx, sig.abi, output, true) { + PassMode::NoPass => (inputs.map(AbiParam::new).collect(), vec![]), + PassMode::ByVal(ret_ty) => ( + inputs.map(AbiParam::new).collect(), + vec![AbiParam::new(ret_ty)], + ), + PassMode::ByRef => { + ( + Some(types::I64).into_iter() // First param is place to put return val + .chain(inputs) + .map(AbiParam::new) + .collect(), + vec![], + ) + } + }; + Signature { - params: Some(types::I64).into_iter() // First param is place to put return val - .chain(inputs.into_iter().map(|ty| { - let cton_ty = cton_type_from_ty(tcx, ty); - if let Some(cton_ty) = cton_ty { - cton_ty - } else { - if sig.abi == Abi::C { - unimplemented!("Non scalars are not yet supported for \"C\" abi"); - } - types::I64 - } - })) - .map(AbiParam::new).collect(), - returns: vec![], + params, + returns, call_conv, argument_bytes: None, } @@ -194,7 +248,19 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb _ => unimplemented!("declared function with non \"rust\" or \"rust-call\" abi"), } - let ret_param = fx.bcx.append_ebb_param(start_ebb, types::I64); + let ret_layout = fx.layout_of(fx.return_type()); + let output_pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true); + let ret_param = match output_pass_mode { + PassMode::NoPass => { + None + } + PassMode::ByVal(ret_ty) => { + None + } + PassMode::ByRef => { + Some(fx.bcx.append_ebb_param(start_ebb, types::I64)) + } + }; enum ArgKind { Normal(Value), @@ -218,20 +284,34 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb let mut ebb_params = Vec::new(); for arg_ty in tupled_arg_tys.iter() { - let cton_type = fx.cton_type(arg_ty).unwrap_or(types::I64); + let cton_type = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); ebb_params.push(fx.bcx.append_ebb_param(start_ebb, cton_type)); } (local, ArgKind::Spread(ebb_params), arg_ty) } else { - let cton_type = fx.cton_type(arg_ty).unwrap_or(types::I64); + let cton_type = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); (local, ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, cton_type)), arg_ty) } }).collect::>(); - let ret_layout = fx.layout_of(fx.return_type()); - fx.local_map - .insert(RETURN_PLACE, CPlace::Addr(ret_param, ret_layout)); + match output_pass_mode { + PassMode::NoPass => { + let null = fx.bcx.ins().iconst(types::I64, 0); + //unimplemented!("pass mode nopass"); + fx.local_map.insert(RETURN_PLACE, CPlace::Addr(null, fx.layout_of(fx.return_type()))); + } + PassMode::ByVal(ret_ty) => { + let var = Variable(RETURN_PLACE); + fx.bcx.declare_var(var, ret_ty); + fx.local_map + .insert(RETURN_PLACE, CPlace::Var(var, ret_layout)); + } + PassMode::ByRef => { + fx.local_map + .insert(RETURN_PLACE, CPlace::Addr(ret_param.unwrap(), ret_layout)); + } + } for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); @@ -244,7 +324,14 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb { let var = Variable(local); fx.bcx.declare_var(var, fx.cton_type(ty).unwrap()); - fx.bcx.def_var(var, ebb_param); + match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => fx.bcx.def_var(var, ebb_param), + PassMode::ByRef => { + let val = CValue::ByRef(ebb_param, fx.layout_of(ty)).load_value(fx); + fx.bcx.def_var(var, val); + } + } fx.local_map.insert(local, CPlace::Var(var, layout)); continue; } @@ -260,19 +347,19 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb match arg_kind { ArgKind::Normal(ebb_param) => { - if fx.cton_type(ty).is_some() { - place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())); - } else { - place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())); + match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())), + PassMode::ByRef => place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())), } } ArgKind::Spread(ebb_params) => { for (i, ebb_param) in ebb_params.into_iter().enumerate() { let sub_place = place.place_field(fx, mir::Field::new(i)); - if fx.cton_type(sub_place.layout().ty).is_some() { - sub_place.write_cvalue(fx, CValue::ByVal(ebb_param, sub_place.layout())); - } else { - sub_place.write_cvalue(fx, CValue::ByRef(ebb_param, sub_place.layout())); + match get_pass_mode(fx.tcx, fx.self_sig().abi, sub_place.layout().ty, false) { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => sub_place.write_cvalue(fx, CValue::ByVal(ebb_param, sub_place.layout())), + PassMode::ByRef => sub_place.write_cvalue(fx, CValue::ByRef(ebb_param, sub_place.layout())), } } } @@ -350,33 +437,48 @@ pub fn codegen_call<'a, 'tcx: 'a>( return; } - let return_ptr = match destination { - Some((place, _)) => place.expect_addr(), - None => fx.bcx.ins().iconst(types::I64, 0), + let ret_layout = fx.layout_of(sig.output()); + + let output_pass_mode = get_pass_mode(fx.tcx, sig.abi, sig.output(), true); + println!("{:?}", output_pass_mode); + let return_ptr = match output_pass_mode { + PassMode::NoPass => None, + PassMode::ByRef => match destination { + Some((place, _)) => Some(place.expect_addr()), + None => Some(fx.bcx.ins().iconst(types::I64, 0)), + }, + PassMode::ByVal(_) => None, }; - let call_args = Some(return_ptr) + let call_args: Vec = return_ptr .into_iter() - .chain(args.into_iter().map(|arg| { - if fx.cton_type(arg.layout().ty).is_some() { - arg.load_value(fx) - } else { - arg.force_stack(fx) - } - })).collect::>(); - - match func { - CValue::Func(func, _) => { - fx.bcx.ins().call(func, &call_args); - } + .chain( + args.into_iter() + .map(|arg| match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => arg.load_value(fx), + PassMode::ByRef => arg.force_stack(fx), + }), + ).collect::>(); + + let inst = match func { + CValue::Func(func, _) => fx.bcx.ins().call(func, &call_args), func => { - let func_ty = func.layout().ty; let func = func.load_value(fx); - let sig = fx - .bcx - .import_signature(cton_sig_from_fn_ty(fx.tcx, func_ty)); - fx.bcx.ins().call_indirect(sig, func, &call_args); + let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty)); + fx.bcx.ins().call_indirect(sig, func, &call_args) } + }; + + match output_pass_mode { + PassMode::NoPass => {} + PassMode::ByVal(_) => { + if let Some((ret_place, _)) = destination { + let results = fx.bcx.inst_results(inst); + ret_place.write_cvalue(fx, CValue::ByVal(results[0], ret_layout)); + } + } + PassMode::ByRef => {} } if let Some((_, dest)) = destination { let ret_ebb = fx.get_ebb(dest); @@ -387,7 +489,16 @@ pub fn codegen_call<'a, 'tcx: 'a>( } pub fn codegen_return(fx: &mut FunctionCx) { - fx.bcx.ins().return_(&[]); + match get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true) { + PassMode::NoPass | PassMode::ByRef => { + fx.bcx.ins().return_(&[]); + }, + PassMode::ByVal(_) => { + let place = fx.get_local_place(RETURN_PLACE); + let ret_val = place.to_cvalue(fx).load_value(fx); + fx.bcx.ins().return_(&[ret_val]); + } + } } fn codegen_intrinsic_call<'a, 'tcx: 'a>( From 2e0d6d49bf6c95185229ac19f8b1c43f1bca31fd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 13:59:08 +0200 Subject: [PATCH 0125/1566] Deduplicate function name generation --- src/abi.rs | 45 +++++++++++++++++++++++++++++++++------------ src/base.rs | 29 ++++++----------------------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index ccb55a45ab7ce..4e6ccf7adfc52 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -30,7 +30,7 @@ fn get_pass_mode<'a, 'tcx: 'a>( ) -> PassMode { if ty.sty == tcx.mk_nil().sty { if is_return { - //if false { + //if false { PassMode::NoPass } else { PassMode::ByRef @@ -153,16 +153,37 @@ fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<' tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig) } +fn get_function_name_and_sig<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + inst: Instance<'tcx>, +) -> (String, Signature) { + assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); + let fn_ty = inst.ty(tcx); + let sig = cton_sig_from_fn_ty(tcx, fn_ty); + let def_path_based_names = + ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); + let mut name = String::new(); + def_path_based_names.push_instance_as_string(inst, &mut name); + (name, sig) +} + +impl<'a, 'tcx: 'a> CodegenCx<'a, 'tcx, CurrentBackend> { + pub fn predefine_function(&mut self, inst: Instance<'tcx>) -> (FuncId, Function) { + let (name, sig) = crate::abi::get_function_name_and_sig(self.tcx, inst); + let func_id = self + .module + .declare_function(&name, Linkage::Export, &sig) + .unwrap(); + let func = + Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); + (func_id, func) + } +} + impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); - let fn_ty = inst.ty(self.tcx); - let sig = cton_sig_from_fn_ty(self.tcx, fn_ty); - let def_path_based_names = - ::rustc_mir::monomorphize::item::DefPathBasedNames::new(self.tcx, false, false); - let mut name = String::new(); - def_path_based_names.push_instance_as_string(inst, &mut name); + let (name, sig) = get_function_name_and_sig(self.tcx, inst); let func_id = self .module .declare_function(&name, Linkage::Import, &sig) @@ -455,10 +476,10 @@ pub fn codegen_call<'a, 'tcx: 'a>( .chain( args.into_iter() .map(|arg| match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => arg.load_value(fx), - PassMode::ByRef => arg.force_stack(fx), - }), + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => arg.load_value(fx), + PassMode::ByRef => arg.force_stack(fx), + }), ).collect::>(); let inst = match func { diff --git a/src/base.rs b/src/base.rs index 4f7a086d748e2..a5d93959552f8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -27,42 +27,25 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( ty::ParamEnv::reveal_all(), &fn_ty, ); - let sig = cton_sig_from_fn_ty(tcx, fn_ty); - - let func_id = { - // WARNING: keep in sync with FunctionCx::get_function_ref - let def_path_based_names = - ::rustc_mir::monomorphize::item::DefPathBasedNames::new( - cx.tcx, false, false, - ); - let mut name = String::new(); - def_path_based_names.push_instance_as_string(inst, &mut name); - cx.module - .declare_function(&name, Linkage::Export, &sig) - .unwrap() - }; - let mut f = Function::with_name_signature( - ExternalName::user(0, func_id.index() as u32), - sig, - ); + let (func_id, mut func) = cx.predefine_function(inst); - let comments = trans_fn(cx, &mut f, inst); + let comments = trans_fn(cx, &mut func, inst); let mut writer = crate::pretty_clif::CommentWriter(comments); let mut cton = String::new(); - ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &f, None) + ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None) .unwrap(); tcx.sess.warn(&cton); let flags = settings::Flags::new(settings::builder()); - match ::cranelift::codegen::verify_function(&f, &flags) { + match ::cranelift::codegen::verify_function(&func, &flags) { Ok(_) => {} Err(err) => { tcx.sess.err(&format!("{:?}", err)); let pretty_error = ::cranelift::codegen::print_errors::pretty_verifier_error( - &f, + &func, None, Some(Box::new(writer)), &err, @@ -72,7 +55,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } } - context.func = f; + context.func = func; // TODO: cranelift doesn't yet support some of the things needed if false { cx.module.define_function(func_id, context).unwrap(); From 50375db36c65a1c9669e3becf428da7c6e84ce6b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 13:59:34 +0200 Subject: [PATCH 0126/1566] Rustfmt --- src/abi.rs | 60 ++++++++++++++++++++++++++---------------------------- src/lib.rs | 34 +++++++++++++++++-------------- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 4e6ccf7adfc52..238f06f26d2b3 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -272,15 +272,9 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb let ret_layout = fx.layout_of(fx.return_type()); let output_pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true); let ret_param = match output_pass_mode { - PassMode::NoPass => { - None - } - PassMode::ByVal(ret_ty) => { - None - } - PassMode::ByRef => { - Some(fx.bcx.append_ebb_param(start_ebb, types::I64)) - } + PassMode::NoPass => None, + PassMode::ByVal(ret_ty) => None, + PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, types::I64)), }; enum ArgKind { @@ -320,7 +314,10 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb PassMode::NoPass => { let null = fx.bcx.ins().iconst(types::I64, 0); //unimplemented!("pass mode nopass"); - fx.local_map.insert(RETURN_PLACE, CPlace::Addr(null, fx.layout_of(fx.return_type()))); + fx.local_map.insert( + RETURN_PLACE, + CPlace::Addr(null, fx.layout_of(fx.return_type())), + ); } PassMode::ByVal(ret_ty) => { let var = Variable(RETURN_PLACE); @@ -367,20 +364,25 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb let place = CPlace::from_stack_slot(fx, stack_slot, ty); match arg_kind { - ArgKind::Normal(ebb_param) => { - match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())), - PassMode::ByRef => place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())), + ArgKind::Normal(ebb_param) => match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) + { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => { + place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())) } - } + PassMode::ByRef => place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())), + }, ArgKind::Spread(ebb_params) => { for (i, ebb_param) in ebb_params.into_iter().enumerate() { let sub_place = place.place_field(fx, mir::Field::new(i)); match get_pass_mode(fx.tcx, fx.self_sig().abi, sub_place.layout().ty, false) { PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => sub_place.write_cvalue(fx, CValue::ByVal(ebb_param, sub_place.layout())), - PassMode::ByRef => sub_place.write_cvalue(fx, CValue::ByRef(ebb_param, sub_place.layout())), + PassMode::ByVal(_) => { + sub_place.write_cvalue(fx, CValue::ByVal(ebb_param, sub_place.layout())) + } + PassMode::ByRef => { + sub_place.write_cvalue(fx, CValue::ByRef(ebb_param, sub_place.layout())) + } } } } @@ -450,9 +452,9 @@ pub fn codegen_call<'a, 'tcx: 'a>( .collect::>() }; - let destination = destination.as_ref().map(|(place, bb)| { - (trans_place(fx, place), *bb) - }); + let destination = destination + .as_ref() + .map(|(place, bb)| (trans_place(fx, place), *bb)); if codegen_intrinsic_call(fx, fn_ty, sig, &args, destination) { return; @@ -473,14 +475,13 @@ pub fn codegen_call<'a, 'tcx: 'a>( let call_args: Vec = return_ptr .into_iter() - .chain( - args.into_iter() - .map(|arg| match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { + .chain(args.into_iter().map(|arg| { + match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(_) => arg.load_value(fx), PassMode::ByRef => arg.force_stack(fx), - }), - ).collect::>(); + } + })).collect::>(); let inst = match func { CValue::Func(func, _) => fx.bcx.ins().call(func, &call_args), @@ -513,7 +514,7 @@ pub fn codegen_return(fx: &mut FunctionCx) { match get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true) { PassMode::NoPass | PassMode::ByRef => { fx.bcx.ins().return_(&[]); - }, + } PassMode::ByVal(_) => { let place = fx.get_local_place(RETURN_PLACE); let ret_val = place.to_cvalue(fx).load_value(fx); @@ -537,10 +538,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let ret = match destination { Some((place, _)) => place, None => { - println!( - "codegen_call(fx, _, {:?}, {:?})", - args, destination - ); + println!("codegen_call(fx, _, {:?}, {:?})", args, destination); // Insert non returning intrinsics here match intrinsic { "abort" => { diff --git a/src/lib.rs b/src/lib.rs index 2a0f86f66b56b..928760859134b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -271,7 +271,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } } } - + std::mem::replace(&mut cx.defined_functions, Vec::new()) }; @@ -279,21 +279,25 @@ impl CodegenBackend for CraneliftCodegenBackend { // TODO: this doesn't work most of the time if false { - let call_instance = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0.into_iter().find_map(|mono_item| { - let inst = match mono_item { - MonoItem::Fn(inst) => inst, - _ => return None, - }; - - //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { - if tcx.absolute_item_path_str(inst.def_id()) == "example::option_unwrap_or" { - Some(inst) - } else { - None - } - }).unwrap(); + let call_instance = + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) + .0 + .into_iter() + .find_map(|mono_item| { + let inst = match mono_item { + MonoItem::Fn(inst) => inst, + _ => return None, + }; + + //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { + if tcx.absolute_item_path_str(inst.def_id()) == "example::option_unwrap_or" + { + Some(inst) + } else { + None + } + }).unwrap(); - let fn_ty = call_instance.ty(tcx); let sig = cton_sig_from_fn_ty(tcx, fn_ty); let def_path_based_names = From d5a5aec022df4c9a09c9a68a107af64bf8834e3e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 14:10:00 +0200 Subject: [PATCH 0127/1566] Use get_function_name_and_sig for calling function from backend --- src/abi.rs | 2 +- src/lib.rs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 238f06f26d2b3..0e4f6c15b156a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -153,7 +153,7 @@ fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<' tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig) } -fn get_function_name_and_sig<'a, 'tcx>( +pub fn get_function_name_and_sig<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>, ) -> (String, Signature) { diff --git a/src/lib.rs b/src/lib.rs index 928760859134b..021602ed7c726 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -298,12 +298,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } }).unwrap(); - let fn_ty = call_instance.ty(tcx); - let sig = cton_sig_from_fn_ty(tcx, fn_ty); - let def_path_based_names = - ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); - let mut name = String::new(); - def_path_based_names.push_instance_as_string(call_instance, &mut name); + let (name, sig) = crate::abi::get_function_name_and_sig(tcx, call_instance); let called_func_id = module .declare_function(&name, Linkage::Import, &sig) .unwrap(); From 39cc4fd3fc118a2a9e5a6f28b4b8f222b46f322e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 14:24:05 +0200 Subject: [PATCH 0128/1566] Don't translate intrinsic func operand --- src/abi.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 0e4f6c15b156a..6eae368eced1c 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -421,8 +421,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, ) { - let func = trans_operand(fx, func); - let fn_ty = func.layout().ty; + let fn_ty = fx.monomorphize(&func.ty(&fx.mir.local_decls, fx.tcx)); let sig = ty_fn_sig(fx.tcx, fn_ty); // Unpack arguments tuple for closures @@ -483,7 +482,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( } })).collect::>(); - let inst = match func { + let inst = match trans_operand(fx, func) { CValue::Func(func, _) => fx.bcx.ins().call(func, &call_args), func => { let func = func.load_value(fx); @@ -538,7 +537,6 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let ret = match destination { Some((place, _)) => place, None => { - println!("codegen_call(fx, _, {:?}, {:?})", args, destination); // Insert non returning intrinsics here match intrinsic { "abort" => { From af692589717aa7c5c05cf47a28c1cc24b69bd67c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 14:29:32 +0200 Subject: [PATCH 0129/1566] Use tcx.symbol_name --- src/abi.rs | 6 +----- src/base.rs | 9 +-------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 6eae368eced1c..a87984d4cd994 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -160,11 +160,7 @@ pub fn get_function_name_and_sig<'a, 'tcx>( assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_ty = inst.ty(tcx); let sig = cton_sig_from_fn_ty(tcx, fn_ty); - let def_path_based_names = - ::rustc_mir::monomorphize::item::DefPathBasedNames::new(tcx, false, false); - let mut name = String::new(); - def_path_based_names.push_instance_as_string(inst, &mut name); - (name, sig) + (tcx.symbol_name(inst).as_str().to_string(), sig) } impl<'a, 'tcx: 'a> CodegenCx<'a, 'tcx, CurrentBackend> { diff --git a/src/base.rs b/src/base.rs index a5d93959552f8..fd0268db57398 100644 --- a/src/base.rs +++ b/src/base.rs @@ -11,7 +11,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( MonoItem::Fn(inst) => match inst { Instance { def: InstanceDef::Item(def_id), - substs, + substs: _, } => { let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); @@ -21,13 +21,6 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( String::from_utf8_lossy(&mir.into_inner()) )); - let fn_ty = inst.ty(tcx); - let fn_ty = tcx.subst_and_normalize_erasing_regions( - substs, - ty::ParamEnv::reveal_all(), - &fn_ty, - ); - let (func_id, mut func) = cx.predefine_function(inst); let comments = trans_fn(cx, &mut func, inst); From 9a8c25ae75d0f47e7db44c5fed3e9324c0e9487e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 14:52:00 +0200 Subject: [PATCH 0130/1566] Improve mini_core_hello_world.rs --- examples/mini_core.rs | 5 +++++ examples/mini_core_hello_world.rs | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 2bcdd454dac54..60c4a249eebe7 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -140,6 +140,11 @@ pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! loop {} } +#[lang = "eh_personality"] +fn eh_personality() -> ! { + loop {} +} + #[lang = "drop_in_place"] #[allow(unconditional_recursion)] pub unsafe fn drop_in_place(to_drop: *mut T) { diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 5fc0cff08bd6a..c9d0a00f4286f 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -1,7 +1,8 @@ // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs -#![feature(no_core, unboxed_closures, start)] +#![feature(no_core, unboxed_closures, start, lang_items)] #![no_core] +#![no_main] #![allow(dead_code)] extern crate mini_core; @@ -15,11 +16,11 @@ extern "C" { fn puts(s: *const u8); } -#[start] -fn main(i: isize, _: *const *const u8) -> isize { +#[lang = "start"] +fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { unsafe { let (ptr, _): (*const u8, usize) = intrinsics::transmute("Hello!\0"); puts(ptr); } - 0 + 42 } From 46ebc2bc5c8909871939ea0a96d874a82c60a360 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 15:05:57 +0200 Subject: [PATCH 0131/1566] Make the hello world example runnable --- build.sh | 10 +++--- src/base.rs | 8 ++++- src/constant.rs | 8 ++++- src/lib.rs | 91 ++++++++++++++++--------------------------------- 4 files changed, 48 insertions(+), 69 deletions(-) diff --git a/build.sh b/build.sh index 0578ee8526d7f..c0bc1978300c6 100755 --- a/build.sh +++ b/build.sh @@ -14,12 +14,12 @@ else exit 1 fi -RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=. --crate-type lib -Og" +RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=. -Og" -$RUSTC mini_core.rs --crate-name mini_core && -$RUSTC example.rs && -$RUSTC mini_core_hello_world.rs && +$RUSTC mini_core.rs --crate-name mini_core --crate-type lib && +$RUSTC example.rs --crate-type lib && +$RUSTC mini_core_hello_world.rs --crate-type bin && -$RUSTC ../target/libcore/src/libcore/lib.rs --color=always 2>&1 | (head -n 10; echo "===="; tail -n 1000) +$RUSTC ../target/libcore/src/libcore/lib.rs --color=always --crate-type lib 2>&1 | (head -n 20; echo "===="; tail -n 1000) cat ../target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" rm *.rlib ../target/log.txt diff --git a/src/base.rs b/src/base.rs index fd0268db57398..1b993e087794b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -50,7 +50,13 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( context.func = func; // TODO: cranelift doesn't yet support some of the things needed - if false { + if cx + .tcx + .sess + .crate_types + .get() + .contains(&CrateType::Executable) + { cx.module.define_function(func_id, context).unwrap(); cx.defined_functions.push(func_id); } diff --git a/src/constant.rs b/src/constant.rs index 6136f5024fbf3..91352744fe46b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -79,7 +79,13 @@ fn trans_const_place<'a, 'tcx: 'a>( ) -> CPlace<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); - if true { + if !fx + .tcx + .sess + .crate_types + .get() + .contains(&CrateType::Executable) + { // TODO: cranelift-module api seems to be used wrong, // thus causing panics for some consts, so this disables it return CPlace::Addr(fx.bcx.ins().iconst(types::I64, 0), layout); diff --git a/src/lib.rs b/src/lib.rs index 021602ed7c726..02a23097b6bf3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,10 +29,7 @@ use std::sync::{mpsc, Arc}; use rustc::dep_graph::DepGraph; use rustc::middle::cstore::MetadataLoader; -use rustc::session::{ - config::{CrateType, OutputFilenames}, - CompileIncomplete, -}; +use rustc::session::{config::OutputFilenames, CompileIncomplete}; use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::{build_link_meta, out_filename}; @@ -65,7 +62,7 @@ mod prelude { pub use rustc::mir; pub use rustc::mir::interpret::AllocId; pub use rustc::mir::*; - pub use rustc::session::Session; + pub use rustc::session::{config::CrateType, Session}; pub use rustc::ty::layout::{self, LayoutOf, Size, TyLayout}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, @@ -278,27 +275,11 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Compiled everything"); // TODO: this doesn't work most of the time - if false { - let call_instance = - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) - .0 - .into_iter() - .find_map(|mono_item| { - let inst = match mono_item { - MonoItem::Fn(inst) => inst, - _ => return None, - }; - - //if tcx.absolute_item_path_str(inst.def_id()) != "example::ret_42" { - if tcx.absolute_item_path_str(inst.def_id()) == "example::option_unwrap_or" - { - Some(inst) - } else { - None - } - }).unwrap(); + if tcx.sess.crate_types.get().contains(&CrateType::Executable) { + let start_wrapper = tcx.lang_items().start_fn().expect("no start lang item"); - let (name, sig) = crate::abi::get_function_name_and_sig(tcx, call_instance); + let (name, sig) = + crate::abi::get_function_name_and_sig(tcx, Instance::mono(tcx, start_wrapper)); let called_func_id = module .declare_function(&name, Linkage::Import, &sig) .unwrap(); @@ -311,19 +292,9 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Finalized everything"); let finalized_function: *const u8 = module.finalize_function(called_func_id); - /*let f: extern "C" fn(&mut u32) = unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = 0u32; - f(&mut res); - tcx.sess.warn(&format!("ret_42 returned {}", res));*/ - /*let f: extern "C" fn(&mut bool, &u8, bool) = -- unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = false; - f(&mut res, &3, false); - tcx.sess.warn(&format!("option_unwrap_or returned {}", res));*/ - let f: extern "C" fn(&mut u8, isize, *const *const u8) = + let f: extern "C" fn(*const u8, isize, *const *const u8) -> isize = unsafe { ::std::mem::transmute(finalized_function) }; - let mut res = 0; - f(&mut res, 0, 0 as *const _); + let res = f(0 as *const u8, 0, 0 as *const _); tcx.sess.warn(&format!("main returned {}", res)); module.finish(); @@ -370,32 +341,28 @@ impl CodegenBackend for CraneliftCodegenBackend { ).unwrap(); for &crate_type in sess.opts.crate_types.iter() { - if crate_type != CrateType::Rlib - /*&& crate_type != CrateType::Dylib*/ - { - sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)); + match crate_type { + CrateType::Executable => { + sess.warn("Rustc codegen cranelift doesn't produce executables, but is a JIT for them"); + }, + CrateType::Rlib /* | CrateType::Dylib */ => { + let output_name = out_filename( + sess, + crate_type, + &outputs, + &ongoing_codegen.crate_name.as_str(), + ); + let file = File::create(&output_name).unwrap(); + let mut builder = ar::Builder::new(file); + builder + .append( + &ar::Header::new(b".rustc.clif_metadata".to_vec(), metadata.len() as u64), + ::std::io::Cursor::new(metadata.clone()), + ).unwrap(); + //artifact.write(file).unwrap(); + } + _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), } - let output_name = out_filename( - sess, - crate_type, - &outputs, - &ongoing_codegen.crate_name.as_str(), - ); - let file = File::create(&output_name).unwrap(); - let mut builder = ar::Builder::new(file); - builder - .append( - &ar::Header::new(b".rustc.clif_metadata".to_vec(), metadata.len() as u64), - ::std::io::Cursor::new(metadata.clone()), - ).unwrap(); - //artifact.write(file).unwrap(); - } - - sess.abort_if_errors(); - if !sess.opts.crate_types.contains(&CrateType::Rlib) - && !sess.opts.crate_types.contains(&CrateType::Dylib) - { - sess.fatal("Executables are not supported by the metadata-only backend."); } Ok(()) } From 57ba6411c216cd537894cbeda87c8d73a4498b11 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 15:21:26 +0200 Subject: [PATCH 0132/1566] Measure translation speed --- src/abi.rs | 2 +- src/lib.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index a87984d4cd994..9b9c59162ff25 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -269,7 +269,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb let output_pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true); let ret_param = match output_pass_mode { PassMode::NoPass => None, - PassMode::ByVal(ret_ty) => None, + PassMode::ByVal(_) => None, PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, types::I64)), }; diff --git a/src/lib.rs b/src/lib.rs index 02a23097b6bf3..a9f8035f401f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -250,6 +250,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut log = ::std::fs::File::create("../target/log.txt").unwrap(); + let before = ::std::time::Instant::now(); for mono_item in collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 { @@ -268,6 +269,8 @@ impl CodegenBackend for CraneliftCodegenBackend { } } } + let after = ::std::time::Instant::now(); + println!("time: {:?}", after - before); std::mem::replace(&mut cx.defined_functions, Vec::new()) }; From 8e2394874e8d29f96306909842961419f1733cc3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Aug 2018 15:36:08 +0200 Subject: [PATCH 0133/1566] Group drop glue instances in unimpl log --- src/base.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/base.rs b/src/base.rs index 1b993e087794b..1c4655a6d0e4b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -63,6 +63,10 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( context.clear(); } + Instance { + def: InstanceDef::DropGlue(_, _), + substs: _ + } => unimpl!("Unimplemented drop glue instance"), inst => unimpl!("Unimplemented instance {:?}", inst), }, MonoItem::Static(def_id) => unimpl!("Unimplemented static mono item {:?}", def_id), From 5859b9b65d77732c45661ff90520a24c65cbd080 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 12 Aug 2018 18:56:05 +0200 Subject: [PATCH 0134/1566] Rustfmt --- src/base.rs | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 1c4655a6d0e4b..f001db4600d2b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -65,7 +65,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } Instance { def: InstanceDef::DropGlue(_, _), - substs: _ + substs: _, } => unimpl!("Unimplemented drop glue instance"), inst => unimpl!("Unimplemented instance {:?}", inst), }, diff --git a/src/lib.rs b/src/lib.rs index a9f8035f401f6..bec98bf586306 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -346,7 +346,7 @@ impl CodegenBackend for CraneliftCodegenBackend { for &crate_type in sess.opts.crate_types.iter() { match crate_type { CrateType::Executable => { - sess.warn("Rustc codegen cranelift doesn't produce executables, but is a JIT for them"); + sess.warn("Rustc codegen cranelift doesn't produce executables, but is a JIT for them"); }, CrateType::Rlib /* | CrateType::Dylib */ => { let output_name = out_filename( From 23b4db227a391b8c64a54c863846c0f8a8168426 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 12 Aug 2018 20:49:43 +0200 Subject: [PATCH 0135/1566] Implement basic incremental compilation --- build.sh | 2 +- src/lib.rs | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index c0bc1978300c6..3d9bcbd1919d6 100755 --- a/build.sh +++ b/build.sh @@ -20,6 +20,6 @@ $RUSTC mini_core.rs --crate-name mini_core --crate-type lib && $RUSTC example.rs --crate-type lib && $RUSTC mini_core_hello_world.rs --crate-type bin && -$RUSTC ../target/libcore/src/libcore/lib.rs --color=always --crate-type lib 2>&1 | (head -n 20; echo "===="; tail -n 1000) +$RUSTC ../target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=../target/libcore/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) cat ../target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" rm *.rlib ../target/log.txt diff --git a/src/lib.rs b/src/lib.rs index bec98bf586306..bb51ba659c3d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -68,7 +68,7 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeVariants, }; - pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc}; + pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc, fx::FxHashMap}; pub use rustc_mir::monomorphize::{collector, MonoItem}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::codemap::DUMMY_SP; @@ -186,6 +186,13 @@ impl CodegenBackend for CraneliftCodegenBackend { providers.target_features_whitelist = |_tcx, _cnum| Lrc::new(Default::default()); providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); + providers.upstream_monomorphizations = |_tcx, _cnum| Lrc::new(FxHashMap()); + providers.upstream_monomorphizations_for = |tcx, def_id| { + debug_assert!(!def_id.is_local()); + tcx.upstream_monomorphizations(LOCAL_CRATE) + .get(&def_id) + .cloned() + }; } fn provide_extern(&self, providers: &mut Providers) { providers.is_reachable_non_generic = |_tcx, _defid| true; @@ -251,9 +258,13 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut log = ::std::fs::File::create("../target/log.txt").unwrap(); let before = ::std::time::Instant::now(); - for mono_item in - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 - { + let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0; + + // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore + save_incremental(tcx); + tcx.sess.warn("Saved incremental data"); + + for mono_item in mono_items { let cx = &mut cx; let context = &mut context; let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(move || { @@ -371,6 +382,12 @@ impl CodegenBackend for CraneliftCodegenBackend { } } +fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { + rustc_incremental::assert_dep_graph(tcx); + rustc_incremental::save_dep_graph(tcx); + rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); +} + /// This is the entrypoint for a hot plugged rustc_codegen_cranelift #[no_mangle] pub fn __rustc_codegen_backend() -> Box { From c2e46950eb32fbfc62f3a3306714f977fdd704f0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 11:39:55 +0200 Subject: [PATCH 0136/1566] Update Cargo.lock --- Cargo.lock | 68 +++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f5ee20d25447..6c2f74e6f1e57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,7 +38,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" dependencies = [ "cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -111,17 +111,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" [[package]] name = "cranelift-entity" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" [[package]] name = "cranelift-faerie" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -142,7 +142,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -162,7 +162,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#963960de853343c4f234be42333ec3ef82c39f22" +source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -241,9 +241,9 @@ name = "failure_derive" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -298,7 +298,7 @@ name = "log" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -324,7 +324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -337,10 +337,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -439,9 +439,9 @@ name = "scroll_derive" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -499,18 +499,18 @@ name = "structopt-derive" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.14.7" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -519,9 +519,9 @@ name = "synstructure" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -650,7 +650,7 @@ dependencies = [ "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8389c509ec62b9fe8eca58c502a0acaf017737355615243496cde4994f8fa4f9" "checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" -"checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" +"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cranelift 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -679,9 +679,9 @@ dependencies = [ "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cccdc7557a98fe98453030f077df7f3a042052fae465bb61d2c2c41435cfd9b6" +"checksum proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "762eea716b821300a86da08870a64b597304866ceb9f54a11d67b4cf56459c6a" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3372dc35766b36a99ce2352bd1b6ea0137c38d215cc0c8780bf6de6df7842ba9" +"checksum quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ed7d650913520df631972f21e104a4fa2f9c82a14afc65d17b388a2e29731e7c" "checksum raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3c460bd35fdb75644e94ab498372bdf29a4849367ce7ba74cf358edce590c4" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" @@ -700,7 +700,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" "checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" -"checksum syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e13df71f29f9440b50261a5882c86eac334f1badb3134ec26f0de2f1418e44" +"checksum syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b7bfcbb0c068d0f642a0ffbd5c604965a360a61f99e8add013cef23a838614f3" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" "checksum termcolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "722426c4a0539da2c4ffd9b419d90ad540b4cff4a053be9069c908d4d07e2836" From 1031c659e0a6d75d0a6759dc95f4c55e2671053b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 12:13:43 +0200 Subject: [PATCH 0137/1566] Refactoring of constant.rs in preparation for static codegen --- src/base.rs | 8 ++--- src/common.rs | 4 +-- src/constant.rs | 81 ++++++++++++++++++++++++++++++++----------------- src/lib.rs | 9 ++++-- 4 files changed, 66 insertions(+), 36 deletions(-) diff --git a/src/base.rs b/src/base.rs index f001db4600d2b..4a3de4fa52b7b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -69,7 +69,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } => unimpl!("Unimplemented drop glue instance"), inst => unimpl!("Unimplemented instance {:?}", inst), }, - MonoItem::Static(def_id) => unimpl!("Unimplemented static mono item {:?}", def_id), + MonoItem::Static(def_id) => { + crate::constant::codegen_static(cx, def_id); + } MonoItem::GlobalAsm(node_id) => cx .tcx .sess @@ -860,9 +862,7 @@ pub fn trans_place<'a, 'tcx: 'a>( match place { Place::Local(local) => fx.get_local_place(*local), Place::Promoted(promoted) => crate::constant::trans_promoted(fx, promoted.0), - Place::Static(static_) => { - unimpl!("static place {:?} ty {:?}", static_.def_id, static_.ty); - } + Place::Static(static_) => crate::constant::codegen_static_ref(fx, static_), Place::Projection(projection) => { let base = trans_place(fx, &projection.base); match projection.elem { diff --git a/src/common.rs b/src/common.rs index 70e2d283f6010..ad0fb3392ca99 100644 --- a/src/common.rs +++ b/src/common.rs @@ -2,7 +2,7 @@ use std::fmt; use rustc_target::spec::{HasTargetSpec, Target}; -use cranelift_module::{DataId, Module}; +use cranelift_module::Module; use crate::prelude::*; @@ -361,7 +361,7 @@ pub struct FunctionCx<'a, 'tcx: 'a> { pub ebb_map: HashMap, pub local_map: HashMap>, pub comments: HashMap, - pub constants: &'a mut HashMap, + pub constants: &'a mut crate::constant::ConstantCx, } impl<'a, 'tcx: 'a> fmt::Debug for FunctionCx<'a, 'tcx> { diff --git a/src/constant.rs b/src/constant.rs index 91352744fe46b..700a53bd64529 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -2,7 +2,32 @@ use cranelift_module::*; use crate::prelude::*; use rustc::mir::interpret::{read_target_uint, AllocId, ConstValue, GlobalId}; use rustc::ty::Const; -use rustc_mir::interpret::{CompileTimeEvaluator, Memory, MemoryKind}; +use rustc_mir::interpret::{CompileTimeEvaluator, Memory}; + +#[derive(Default)] +pub struct ConstantCx { + constants: HashMap, + done: HashSet, +} + +impl ConstantCx { + pub fn finalize(mut self, module: &mut Module) { + for data_id in self.done.drain() { + module.finalize_data(data_id); + } + } +} + +pub fn codegen_static<'a, 'tcx: 'a, B: Backend>(_cx: &mut CodegenCx<'a, 'tcx, B>, def_id: DefId) { + unimpl!("Unimplemented static mono item {:?}", def_id); +} + +pub fn codegen_static_ref<'a, 'tcx: 'a>( + _fx: &mut FunctionCx<'a, 'tcx>, + static_: &Static<'tcx>, +) -> CPlace<'tcx> { + unimpl!("Unimplemented static mono item {:?}", static_.def_id); +} pub fn trans_promoted<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, @@ -90,13 +115,15 @@ fn trans_const_place<'a, 'tcx: 'a>( // thus causing panics for some consts, so this disables it return CPlace::Addr(fx.bcx.ins().iconst(types::I64, 0), layout); } - let mut memory = Memory::::new(fx.tcx.at(DUMMY_SP), ()); let alloc = fx.tcx.const_value_to_allocation(const_); //println!("const value: {:?} allocation: {:?}", value, alloc); - let alloc_id = memory - .allocate_value(alloc.clone(), MemoryKind::Stack) - .unwrap(); - let data_id = get_global_for_alloc_id(fx, &memory, alloc_id); + let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); + let data_id = get_global_for_alloc_id( + fx.tcx, + fx.module, + fx.constants, + alloc_id, + ); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); // TODO: does global_value return a ptr of a val? let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); @@ -104,17 +131,17 @@ fn trans_const_place<'a, 'tcx: 'a>( } // If ret.1 is true, then the global didn't exist before -fn define_global_for_alloc_id( - fx: &mut FunctionCx, +fn define_global_for_alloc_id<'a, 'tcx: 'a, B: Backend>( + module: &mut Module, + cx: &mut ConstantCx,//<'a, 'tcx>, alloc_id: AllocId, todo: &mut HashMap, ) -> (DataId, bool) { use std::collections::hash_map::Entry; - match fx.constants.entry(alloc_id) { + match cx.constants.entry(alloc_id) { Entry::Occupied(mut occ) => (*occ.get_mut(), false), Entry::Vacant(vac) => { - let data_id = fx - .module + let data_id = module .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) .unwrap(); todo.insert(alloc_id, data_id); @@ -124,18 +151,20 @@ fn define_global_for_alloc_id( } } -fn get_global_for_alloc_id( - fx: &mut FunctionCx, - memory: &Memory, +fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + cx: &mut ConstantCx,//<'a, 'tcx>, alloc_id: AllocId, ) -> DataId { - if let Some(data_id) = fx.constants.get(&alloc_id) { + if let Some(data_id) = cx.constants.get(&alloc_id) { return *data_id; } + let memory = Memory::::new(tcx.at(DUMMY_SP), ()); + let mut todo = HashMap::new(); - let mut done = HashSet::new(); - define_global_for_alloc_id(fx, alloc_id, &mut todo); + define_global_for_alloc_id(module, cx, alloc_id, &mut todo); while let Some((alloc_id, data_id)) = { let next = todo.drain().next(); @@ -143,10 +172,11 @@ fn get_global_for_alloc_id( } { println!( "cur: {:?}:{:?} todo: {:?} done: {:?}", - alloc_id, data_id, todo, done + alloc_id, data_id, todo, cx.done ); let alloc = memory.get(alloc_id).unwrap(); + //let alloc = tcx.alloc_map.lock().get(alloc_id).unwrap(); let mut data_ctx = DataContext::new(); data_ctx.define( @@ -155,26 +185,23 @@ fn get_global_for_alloc_id( ); for &(offset, reloc) in alloc.relocations.iter() { - let data_id = define_global_for_alloc_id(fx, reloc, &mut todo).0; + let data_id = define_global_for_alloc_id(module, cx, reloc, &mut todo).0; let reloc_offset = { let endianness = memory.endianness(); let offset = offset.bytes() as usize; - let ptr_size = fx.tcx.data_layout.pointer_size; + let ptr_size = tcx.data_layout.pointer_size; let bytes = &alloc.bytes[offset..offset + ptr_size.bytes() as usize]; read_target_uint(endianness, bytes).unwrap() }; // TODO: is this a correct usage of the api - let global_value = fx.module.declare_data_in_data(data_id, &mut data_ctx); + let global_value = module.declare_data_in_data(data_id, &mut data_ctx); data_ctx.write_data_addr(reloc_offset as u32, global_value, 0); } - fx.module.define_data(data_id, &data_ctx).unwrap(); - done.insert(data_id); - } - for data_id in done.drain() { - fx.module.finalize_data(data_id); + module.define_data(data_id, &data_ctx).unwrap(); + cx.done.insert(data_id); } - *fx.constants.get(&alloc_id).unwrap() + *cx.constants.get(&alloc_id).unwrap() } diff --git a/src/lib.rs b/src/lib.rs index bb51ba659c3d3..70b9418bf296f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,7 +96,7 @@ use crate::prelude::*; pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, - pub constants: HashMap, + pub constants: crate::constant::ConstantCx, pub defined_functions: Vec, } @@ -251,7 +251,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut cx = CodegenCx { tcx, module: &mut module, - constants: HashMap::new(), + constants: Default::default(), defined_functions: Vec::new(), }; @@ -280,10 +280,13 @@ impl CodegenBackend for CraneliftCodegenBackend { } } } + + cx.constants.finalize(&mut cx.module); + let after = ::std::time::Instant::now(); println!("time: {:?}", after - before); - std::mem::replace(&mut cx.defined_functions, Vec::new()) + cx.defined_functions }; tcx.sess.warn("Compiled everything"); From c40788c1b25b08c5687c00e9df44da1b417a9594 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 15:34:18 +0200 Subject: [PATCH 0138/1566] Simplify define_global_for_alloc_id --- src/constant.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 700a53bd64529..ec0a737c3f77c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -133,22 +133,17 @@ fn trans_const_place<'a, 'tcx: 'a>( // If ret.1 is true, then the global didn't exist before fn define_global_for_alloc_id<'a, 'tcx: 'a, B: Backend>( module: &mut Module, - cx: &mut ConstantCx,//<'a, 'tcx>, + cx: &mut ConstantCx, alloc_id: AllocId, todo: &mut HashMap, -) -> (DataId, bool) { - use std::collections::hash_map::Entry; - match cx.constants.entry(alloc_id) { - Entry::Occupied(mut occ) => (*occ.get_mut(), false), - Entry::Vacant(vac) => { - let data_id = module - .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) - .unwrap(); - todo.insert(alloc_id, data_id); - vac.insert(data_id); - (data_id, true) - } - } +) -> DataId { + *cx.constants.entry(alloc_id).or_insert_with(|| { + let data_id = module + .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) + .unwrap(); + todo.insert(alloc_id, data_id); + data_id + }) } fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( @@ -185,7 +180,7 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( ); for &(offset, reloc) in alloc.relocations.iter() { - let data_id = define_global_for_alloc_id(module, cx, reloc, &mut todo).0; + let data_id = define_global_for_alloc_id(module, cx, reloc, &mut todo); let reloc_offset = { let endianness = memory.endianness(); From 49d24a6333c1f30cd92048206016a006430b7a42 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 15:56:01 +0200 Subject: [PATCH 0139/1566] Remove elements from the todo list the correct way in constant.rs --- examples/example.rs | 4 ++++ examples/mini_core.rs | 17 ++++++++++++++++- src/constant.rs | 26 +++++++++++--------------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/examples/example.rs b/examples/example.rs index 9beef71df313f..7afbb0b0b650c 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -170,3 +170,7 @@ fn int_to_float(a: u8, b: i32) -> (f64, f32) { fn make_array() -> [u8; 3] { [42, 0, 5] } + +fn some_promoted_tuple() -> &'static (&'static str, &'static str) { + &("abc", "some") +} diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 60c4a249eebe7..5ff9c93a975d3 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -59,11 +59,26 @@ pub trait Mul { impl Mul for u8 { type Output = Self; - fn mul(self, rhs: Self) -> Self { + fn mul(self, rhs: Self) -> Self::Output { self * rhs } } +#[lang = "sub"] +pub trait Sub { + type Output; + + fn sub(self, rhs: RHS) -> Self::Output; +} + +impl Sub for usize { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + #[lang = "bitor"] pub trait BitOr { type Output; diff --git a/src/constant.rs b/src/constant.rs index ec0a737c3f77c..6c735e74eeef3 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -104,17 +104,7 @@ fn trans_const_place<'a, 'tcx: 'a>( ) -> CPlace<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); - if !fx - .tcx - .sess - .crate_types - .get() - .contains(&CrateType::Executable) - { - // TODO: cranelift-module api seems to be used wrong, - // thus causing panics for some consts, so this disables it - return CPlace::Addr(fx.bcx.ins().iconst(types::I64, 0), layout); - } + let alloc = fx.tcx.const_value_to_allocation(const_); //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); @@ -161,10 +151,16 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( let mut todo = HashMap::new(); define_global_for_alloc_id(module, cx, alloc_id, &mut todo); - while let Some((alloc_id, data_id)) = { - let next = todo.drain().next(); - next - } { + loop { + let (alloc_id, data_id) = { + if let Some(alloc_id) = todo.keys().next().map(|alloc_id| *alloc_id) { + let data_id = todo.remove(&alloc_id).unwrap(); + (alloc_id, data_id) + } else { + break; + } + }; + println!( "cur: {:?}:{:?} todo: {:?} done: {:?}", alloc_id, data_id, todo, cx.done From b707da40a5d0369201f80d2fed5847caeb781094 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 16:26:30 +0200 Subject: [PATCH 0140/1566] Change todo map to set of alloc id's in constant.rs --- src/constant.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 6c735e74eeef3..c518ccb895000 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -12,21 +12,23 @@ pub struct ConstantCx { impl ConstantCx { pub fn finalize(mut self, module: &mut Module) { + println!("constants {:?}", self.constants); + println!("done {:?}", self.done); for data_id in self.done.drain() { module.finalize_data(data_id); } } } -pub fn codegen_static<'a, 'tcx: 'a, B: Backend>(_cx: &mut CodegenCx<'a, 'tcx, B>, def_id: DefId) { - unimpl!("Unimplemented static mono item {:?}", def_id); +pub fn codegen_static<'a, 'tcx: 'a, B: Backend>(cx: &mut CodegenCx<'a, 'tcx, B>, def_id: DefId) { + unimpl!("static mono item {:?}", def_id); } pub fn codegen_static_ref<'a, 'tcx: 'a>( - _fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx>, static_: &Static<'tcx>, ) -> CPlace<'tcx> { - unimpl!("Unimplemented static mono item {:?}", static_.def_id); + unimpl!("static place {:?} ty {:?}", static_.def_id, static_.ty); } pub fn trans_promoted<'a, 'tcx: 'a>( @@ -125,13 +127,13 @@ fn define_global_for_alloc_id<'a, 'tcx: 'a, B: Backend>( module: &mut Module, cx: &mut ConstantCx, alloc_id: AllocId, - todo: &mut HashMap, + todo: &mut HashSet, ) -> DataId { *cx.constants.entry(alloc_id).or_insert_with(|| { let data_id = module .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) .unwrap(); - todo.insert(alloc_id, data_id); + todo.insert(alloc_id); data_id }) } @@ -139,7 +141,7 @@ fn define_global_for_alloc_id<'a, 'tcx: 'a, B: Backend>( fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, - cx: &mut ConstantCx,//<'a, 'tcx>, + cx: &mut ConstantCx, alloc_id: AllocId, ) -> DataId { if let Some(data_id) = cx.constants.get(&alloc_id) { @@ -148,23 +150,23 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( let memory = Memory::::new(tcx.at(DUMMY_SP), ()); - let mut todo = HashMap::new(); - define_global_for_alloc_id(module, cx, alloc_id, &mut todo); + let mut todo = HashSet::new(); + todo.insert(alloc_id); loop { - let (alloc_id, data_id) = { - if let Some(alloc_id) = todo.keys().next().map(|alloc_id| *alloc_id) { - let data_id = todo.remove(&alloc_id).unwrap(); - (alloc_id, data_id) + let alloc_id = { + if let Some(alloc_id) = todo.iter().next().map(|alloc_id| *alloc_id) { + todo.remove(&alloc_id); + alloc_id } else { break; } }; - println!( - "cur: {:?}:{:?} todo: {:?} done: {:?}", - alloc_id, data_id, todo, cx.done - ); + let data_id = define_global_for_alloc_id(module, cx, alloc_id, &mut todo); + if cx.done.contains(&data_id) { + continue; + } let alloc = memory.get(alloc_id).unwrap(); //let alloc = tcx.alloc_map.lock().get(alloc_id).unwrap(); From 4615359e86b78f97f36cba7c8312d2a26ee51c7e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 16:58:07 +0200 Subject: [PATCH 0141/1566] Define data for all allocs during finalization --- src/constant.rs | 49 ++++++++++++++++++++++++------------------------- src/lib.rs | 2 +- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index c518ccb895000..b393c91f7fb93 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -6,13 +6,14 @@ use rustc_mir::interpret::{CompileTimeEvaluator, Memory}; #[derive(Default)] pub struct ConstantCx { - constants: HashMap, + todo_allocs: HashSet, done: HashSet, } impl ConstantCx { - pub fn finalize(mut self, module: &mut Module) { - println!("constants {:?}", self.constants); + pub fn finalize<'a, 'tcx: 'a, B: Backend>(mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module) { + println!("todo allocs: {:?}", self.todo_allocs); + define_all_allocs(tcx, module, &mut self); println!("done {:?}", self.done); for data_id in self.done.drain() { module.finalize_data(data_id); @@ -111,7 +112,6 @@ fn trans_const_place<'a, 'tcx: 'a>( //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); let data_id = get_global_for_alloc_id( - fx.tcx, fx.module, fx.constants, alloc_id, @@ -127,43 +127,41 @@ fn define_global_for_alloc_id<'a, 'tcx: 'a, B: Backend>( module: &mut Module, cx: &mut ConstantCx, alloc_id: AllocId, - todo: &mut HashSet, ) -> DataId { - *cx.constants.entry(alloc_id).or_insert_with(|| { - let data_id = module - .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) - .unwrap(); - todo.insert(alloc_id); - data_id - }) + module + .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) + .unwrap() } fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, cx: &mut ConstantCx, alloc_id: AllocId, ) -> DataId { - if let Some(data_id) = cx.constants.get(&alloc_id) { - return *data_id; - } + cx.todo_allocs.insert(alloc_id); + let data_id = define_global_for_alloc_id(module, cx, alloc_id); + data_id +} +fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a> ( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + cx: &mut ConstantCx, +) { let memory = Memory::::new(tcx.at(DUMMY_SP), ()); - let mut todo = HashSet::new(); - todo.insert(alloc_id); - loop { let alloc_id = { - if let Some(alloc_id) = todo.iter().next().map(|alloc_id| *alloc_id) { - todo.remove(&alloc_id); + if let Some(alloc_id) = cx.todo_allocs.iter().next().map(|alloc_id| *alloc_id) { + cx.todo_allocs.remove(&alloc_id); alloc_id } else { break; } }; - let data_id = define_global_for_alloc_id(module, cx, alloc_id, &mut todo); + let data_id = define_global_for_alloc_id(module, cx, alloc_id); + println!("alloc_id {} data_id {}", alloc_id, data_id); if cx.done.contains(&data_id) { continue; } @@ -178,7 +176,8 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( ); for &(offset, reloc) in alloc.relocations.iter() { - let data_id = define_global_for_alloc_id(module, cx, reloc, &mut todo); + cx.todo_allocs.insert(reloc); + let data_id = define_global_for_alloc_id(module, cx, reloc); let reloc_offset = { let endianness = memory.endianness(); @@ -188,7 +187,6 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( read_target_uint(endianness, bytes).unwrap() }; - // TODO: is this a correct usage of the api let global_value = module.declare_data_in_data(data_id, &mut data_ctx); data_ctx.write_data_addr(reloc_offset as u32, global_value, 0); } @@ -196,5 +194,6 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( module.define_data(data_id, &data_ctx).unwrap(); cx.done.insert(data_id); } - *cx.constants.get(&alloc_id).unwrap() + + assert!(cx.todo_allocs.is_empty(), "{:?}", cx.todo_allocs); } diff --git a/src/lib.rs b/src/lib.rs index 70b9418bf296f..706d82ed2f612 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -281,7 +281,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } } - cx.constants.finalize(&mut cx.module); + cx.constants.finalize(tcx, &mut cx.module); let after = ::std::time::Instant::now(); println!("time: {:?}", after - before); From d331758f6db35418259eb0a332b81127c87002bd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 17:22:24 +0200 Subject: [PATCH 0142/1566] Add helper function to pop an element from a HashSet --- src/constant.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index b393c91f7fb93..fd3d3d67c3f54 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -150,16 +150,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a> ( ) { let memory = Memory::::new(tcx.at(DUMMY_SP), ()); - loop { - let alloc_id = { - if let Some(alloc_id) = cx.todo_allocs.iter().next().map(|alloc_id| *alloc_id) { - cx.todo_allocs.remove(&alloc_id); - alloc_id - } else { - break; - } - }; - + while let Some(alloc_id) = pop_set(&mut cx.todo_allocs) { let data_id = define_global_for_alloc_id(module, cx, alloc_id); println!("alloc_id {} data_id {}", alloc_id, data_id); if cx.done.contains(&data_id) { @@ -197,3 +188,12 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a> ( assert!(cx.todo_allocs.is_empty(), "{:?}", cx.todo_allocs); } + +fn pop_set(set: &mut HashSet) -> Option { + if let Some(elem) = set.iter().next().map(|elem| *elem) { + set.remove(&elem); + Some(elem) + } else { + None + } +} \ No newline at end of file From c7ed1ce03332e2c4affb0ad04b503415ca8cb1da Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 18:04:39 +0200 Subject: [PATCH 0143/1566] Rustfmt --- src/constant.rs | 16 ++++++++-------- src/lib.rs | 6 ++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index fd3d3d67c3f54..84955d4454414 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -11,7 +11,11 @@ pub struct ConstantCx { } impl ConstantCx { - pub fn finalize<'a, 'tcx: 'a, B: Backend>(mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module) { + pub fn finalize<'a, 'tcx: 'a, B: Backend>( + mut self, + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + ) { println!("todo allocs: {:?}", self.todo_allocs); define_all_allocs(tcx, module, &mut self); println!("done {:?}", self.done); @@ -111,11 +115,7 @@ fn trans_const_place<'a, 'tcx: 'a>( let alloc = fx.tcx.const_value_to_allocation(const_); //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); - let data_id = get_global_for_alloc_id( - fx.module, - fx.constants, - alloc_id, - ); + let data_id = get_global_for_alloc_id(fx.module, fx.constants, alloc_id); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); // TODO: does global_value return a ptr of a val? let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); @@ -143,7 +143,7 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( data_id } -fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a> ( +fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, cx: &mut ConstantCx, @@ -196,4 +196,4 @@ fn pop_set(set: &mut HashSet) -> Option } else { None } -} \ No newline at end of file +} diff --git a/src/lib.rs b/src/lib.rs index 706d82ed2f612..7781de1fb3e33 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -68,7 +68,7 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeVariants, }; - pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc, fx::FxHashMap}; + pub use rustc_data_structures::{fx::FxHashMap, indexed_vec::Idx, sync::Lrc}; pub use rustc_mir::monomorphize::{collector, MonoItem}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::codemap::DUMMY_SP; @@ -258,7 +258,9 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut log = ::std::fs::File::create("../target/log.txt").unwrap(); let before = ::std::time::Instant::now(); - let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0; + let mono_items = + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) + .0; // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore save_incremental(tcx); From 7f62fedeb8ba2e76176ec01a9474be5f319dcf29 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 18:31:26 +0200 Subject: [PATCH 0144/1566] Implement basic statics (#9) --- examples/mini_core_hello_world.rs | 5 +- src/constant.rs | 96 ++++++++++++++++++++----------- 2 files changed, 66 insertions(+), 35 deletions(-) diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index c9d0a00f4286f..e077a37b5dc19 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -16,11 +16,14 @@ extern "C" { fn puts(s: *const u8); } +static NUM: u8 = 6 * 7; + #[lang = "start"] fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { unsafe { let (ptr, _): (*const u8, usize) = intrinsics::transmute("Hello!\0"); puts(ptr); } - 42 + + NUM as isize } diff --git a/src/constant.rs b/src/constant.rs index 84955d4454414..06a06b0d450da 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -6,17 +6,23 @@ use rustc_mir::interpret::{CompileTimeEvaluator, Memory}; #[derive(Default)] pub struct ConstantCx { - todo_allocs: HashSet, + todo: HashSet, done: HashSet, } +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +enum TodoItem { + Alloc(AllocId), + Static(DefId), +} + impl ConstantCx { pub fn finalize<'a, 'tcx: 'a, B: Backend>( mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, ) { - println!("todo allocs: {:?}", self.todo_allocs); + println!("todo {:?}", self.todo); define_all_allocs(tcx, module, &mut self); println!("done {:?}", self.done); for data_id in self.done.drain() { @@ -26,14 +32,15 @@ impl ConstantCx { } pub fn codegen_static<'a, 'tcx: 'a, B: Backend>(cx: &mut CodegenCx<'a, 'tcx, B>, def_id: DefId) { - unimpl!("static mono item {:?}", def_id); + cx.constants.todo.insert(TodoItem::Static(def_id)); } pub fn codegen_static_ref<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, static_: &Static<'tcx>, ) -> CPlace<'tcx> { - unimpl!("static place {:?} ty {:?}", static_.def_id, static_.ty); + let data_id = data_id_for_static(fx.tcx, fx.module, static_.def_id); + cplace_for_dataid(fx, static_.ty, data_id) } pub fn trans_promoted<'a, 'tcx: 'a>( @@ -109,38 +116,36 @@ fn trans_const_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, const_: &'tcx Const<'tcx>, ) -> CPlace<'tcx> { - let ty = fx.monomorphize(&const_.ty); - let layout = fx.layout_of(ty); - let alloc = fx.tcx.const_value_to_allocation(const_); //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); - let data_id = get_global_for_alloc_id(fx.module, fx.constants, alloc_id); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - // TODO: does global_value return a ptr of a val? - let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); - CPlace::Addr(global_ptr, layout) + fx.constants.todo.insert(TodoItem::Alloc(alloc_id)); + let data_id = data_id_for_alloc_id(fx.module, alloc_id); + cplace_for_dataid(fx, const_.ty, data_id) } -// If ret.1 is true, then the global didn't exist before -fn define_global_for_alloc_id<'a, 'tcx: 'a, B: Backend>( - module: &mut Module, - cx: &mut ConstantCx, - alloc_id: AllocId, -) -> DataId { +fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) -> DataId { module .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) .unwrap() } -fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>( - module: &mut Module, - cx: &mut ConstantCx, - alloc_id: AllocId, -) -> DataId { - cx.todo_allocs.insert(alloc_id); - let data_id = define_global_for_alloc_id(module, cx, alloc_id); - data_id +fn data_id_for_static(tcx: TyCtxt, module: &mut Module, def_id: DefId) -> DataId { + let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); + module + .declare_data(&*symbol_name, Linkage::Export, false) + .unwrap() +} + +fn cplace_for_dataid<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx>, + ty: Ty<'tcx>, + data_id: DataId, +) -> CPlace<'tcx> { + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); + let layout = fx.layout_of(fx.monomorphize(&ty)); + CPlace::Addr(global_ptr, layout) } fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( @@ -150,15 +155,38 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( ) { let memory = Memory::::new(tcx.at(DUMMY_SP), ()); - while let Some(alloc_id) = pop_set(&mut cx.todo_allocs) { - let data_id = define_global_for_alloc_id(module, cx, alloc_id); - println!("alloc_id {} data_id {}", alloc_id, data_id); + while let Some(todo_item) = pop_set(&mut cx.todo) { + let (data_id, alloc) = match todo_item { + TodoItem::Alloc(alloc_id) => { + println!("alloc_id {}", alloc_id); + let data_id = data_id_for_alloc_id(module, alloc_id); + let alloc = memory.get(alloc_id).unwrap(); + (data_id, alloc) + } + TodoItem::Static(def_id) => { + println!("static {:?}", def_id); + let instance = ty::Instance::mono(tcx, def_id); + let cid = GlobalId { + instance, + promoted: None, + }; + let const_ = tcx.const_eval(ParamEnv::reveal_all().and(cid)).unwrap(); + + let alloc = match const_.val { + ConstValue::ByRef(alloc, n) if n.bytes() == 0 => alloc, + _ => bug!("static const eval returned {:#?}", const_), + }; + + let data_id = data_id_for_static(tcx, module, def_id); + (data_id, alloc) + } + }; + + println!("data_id {}", data_id); if cx.done.contains(&data_id) { continue; } - let alloc = memory.get(alloc_id).unwrap(); - //let alloc = tcx.alloc_map.lock().get(alloc_id).unwrap(); let mut data_ctx = DataContext::new(); data_ctx.define( @@ -167,8 +195,8 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( ); for &(offset, reloc) in alloc.relocations.iter() { - cx.todo_allocs.insert(reloc); - let data_id = define_global_for_alloc_id(module, cx, reloc); + cx.todo.insert(TodoItem::Alloc(reloc)); + let data_id = data_id_for_alloc_id(module, reloc); let reloc_offset = { let endianness = memory.endianness(); @@ -186,7 +214,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( cx.done.insert(data_id); } - assert!(cx.todo_allocs.is_empty(), "{:?}", cx.todo_allocs); + assert!(cx.todo.is_empty(), "{:?}", cx.todo); } fn pop_set(set: &mut HashSet) -> Option { From 6d1f0068d11188fd5497329f70aaf3a6a51d25da Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 19:02:42 +0200 Subject: [PATCH 0145/1566] Implement nested and mutable statics (fixes #9) --- examples/mini_core.rs | 1 + examples/mini_core_hello_world.rs | 8 ++++++-- src/constant.rs | 21 +++++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 5ff9c93a975d3..d2a205856a9c4 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -44,6 +44,7 @@ unsafe impl Sync for i16 {} unsafe impl Sync for i32 {} unsafe impl Sync for isize {} unsafe impl Sync for char {} +unsafe impl<'a, T: ?Sized> Sync for &'a T {} #[lang = "freeze"] trait Freeze {} diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index e077a37b5dc19..ffda837fac2b5 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -16,7 +16,8 @@ extern "C" { fn puts(s: *const u8); } -static NUM: u8 = 6 * 7; +static mut NUM: u8 = 6 * 7; +static NUM_REF: &'static u8 = unsafe { &NUM }; #[lang = "start"] fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { @@ -25,5 +26,8 @@ fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { puts(ptr); } - NUM as isize + unsafe { + NUM = 43; + *NUM_REF as isize + } } diff --git a/src/constant.rs b/src/constant.rs index 06a06b0d450da..7a88b78af05a1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,6 +1,7 @@ use cranelift_module::*; use crate::prelude::*; -use rustc::mir::interpret::{read_target_uint, AllocId, ConstValue, GlobalId}; +use syntax::ast::Mutability as AstMutability; +use rustc::mir::interpret::{read_target_uint, AllocId, AllocType, ConstValue, GlobalId}; use rustc::ty::Const; use rustc_mir::interpret::{CompileTimeEvaluator, Memory}; @@ -191,12 +192,24 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( data_ctx.define( alloc.bytes.to_vec().into_boxed_slice(), - Writability::Readonly, + match alloc.runtime_mutability { + AstMutability::Mutable => Writability::Writable, + AstMutability::Immutable => Writability::Readonly, + }, ); for &(offset, reloc) in alloc.relocations.iter() { - cx.todo.insert(TodoItem::Alloc(reloc)); - let data_id = data_id_for_alloc_id(module, reloc); + let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { + AllocType::Memory(_) => { + cx.todo.insert(TodoItem::Alloc(reloc)); + data_id_for_alloc_id(module, reloc) + } + AllocType::Function(_) => unimplemented!("function static reference"), + AllocType::Static(def_id) => { + cx.todo.insert(TodoItem::Static(def_id)); + data_id_for_static(tcx, module, def_id) + } + }; let reloc_offset = { let endianness = memory.endianness(); From 4ee2a864b58a1bd2a16def9a22bdf7810dc882f5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 19:03:30 +0200 Subject: [PATCH 0146/1566] Rustfmt --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 7a88b78af05a1..594cafc44fbb1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,9 +1,9 @@ use cranelift_module::*; use crate::prelude::*; -use syntax::ast::Mutability as AstMutability; use rustc::mir::interpret::{read_target_uint, AllocId, AllocType, ConstValue, GlobalId}; use rustc::ty::Const; use rustc_mir::interpret::{CompileTimeEvaluator, Memory}; +use syntax::ast::Mutability as AstMutability; #[derive(Default)] pub struct ConstantCx { From b9d7164eff9974ca10693d87e7c980a3ebad48dd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 19:14:55 +0200 Subject: [PATCH 0147/1566] Fix and test checked binops --- build.sh | 2 +- examples/mini_core.rs | 15 +++++++++++++++ examples/mini_core_hello_world.rs | 2 +- src/base.rs | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 3d9bcbd1919d6..badfe3c9e7e0b 100755 --- a/build.sh +++ b/build.sh @@ -14,7 +14,7 @@ else exit 1 fi -RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=. -Og" +RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=." $RUSTC mini_core.rs --crate-name mini_core --crate-type lib && $RUSTC example.rs --crate-type lib && diff --git a/examples/mini_core.rs b/examples/mini_core.rs index d2a205856a9c4..7813f8a4c34fb 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -65,6 +65,21 @@ impl Mul for u8 { } } +#[lang = "add"] +pub trait Add { + type Output; + + fn add(self, rhs: RHS) -> Self::Output; +} + +impl Add for u8 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + #[lang = "sub"] pub trait Sub { type Output; diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index ffda837fac2b5..2519aacc578f1 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -27,7 +27,7 @@ fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { } unsafe { - NUM = 43; + NUM = 6 * 7 + 5; *NUM_REF as isize } } diff --git a/src/base.rs b/src/base.rs index 4a3de4fa52b7b..cb4ed7900dd85 100644 --- a/src/base.rs +++ b/src/base.rs @@ -152,6 +152,8 @@ pub fn trans_fn<'a, 'tcx: 'a>( cleanup: _, } => { let cond = trans_operand(fx, cond).load_value(fx); + // TODO HACK brz/brnz for i8/i16 is not yet implemented + let cond = fx.bcx.ins().uextend(types::I32, cond); let target = fx.get_ebb(*target); if *expected { fx.bcx.ins().brnz(cond, target, &[]); From 257a607e3ecf6a89c80cf9072804273ae7e62247 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 19:40:40 +0200 Subject: [PATCH 0148/1566] Change build.sh a bit --- build.sh | 16 +++++++--------- src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index badfe3c9e7e0b..d282c788c369f 100755 --- a/build.sh +++ b/build.sh @@ -2,8 +2,6 @@ cargo build || exit 1 -cd examples/ - unamestr=`uname` if [[ "$unamestr" == 'Linux' ]]; then dylib_ext='so' @@ -14,12 +12,12 @@ else exit 1 fi -RUSTC="rustc -Zcodegen-backend=$(pwd)/../target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=." +RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=." -$RUSTC mini_core.rs --crate-name mini_core --crate-type lib && -$RUSTC example.rs --crate-type lib && -$RUSTC mini_core_hello_world.rs --crate-type bin && +$RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib && +$RUSTC examples/example.rs --crate-type lib && +$RUSTC examples/mini_core_hello_world.rs --crate-type bin && -$RUSTC ../target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=../target/libcore/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) -cat ../target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" -rm *.rlib ../target/log.txt +$RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/libcore/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) +cat target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" +rm *.rlib target/log.txt diff --git a/src/lib.rs b/src/lib.rs index 7781de1fb3e33..1f202dc9c4bc3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -255,7 +255,7 @@ impl CodegenBackend for CraneliftCodegenBackend { defined_functions: Vec::new(), }; - let mut log = ::std::fs::File::create("../target/log.txt").unwrap(); + let mut log = ::std::fs::File::create("target/log.txt").unwrap(); let before = ::std::time::Instant::now(); let mono_items = From 43a94ffdf83504beaeb3ac636d3253b5ba80ff84 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 21:39:18 +0200 Subject: [PATCH 0149/1566] Add comment about how to use local cranelift checkout --- Cargo.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index f15acbc16d90d..b4f37c2c8ae39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,10 @@ target-lexicon = "0.0.3" faerie = "0.4.4" ar = "0.6.0" bitflags = "1.0.3" + +# Uncomment to use local checkout of cranelift +#[patch."https://github.com/CraneStation/cranelift.git"] +#cranelift = { path = "../cranelift/lib/umbrella" } +#cranelift-module = { path = "../cranelift/lib/module" } +#cranelift-simplejit = { path = "../cranelift/lib/simplejit" } +#cranelift-faerie = { path = "../cranelift/lib/faerie" } \ No newline at end of file From a6835385fbb2f052bf319aebd1fd86da588b3091 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Aug 2018 21:40:14 +0200 Subject: [PATCH 0150/1566] Update Cargo.lock --- Cargo.lock | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c2f74e6f1e57..ef6d1c8d31cda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" dependencies = [ "cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -111,17 +111,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" [[package]] name = "cranelift-entity" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" [[package]] name = "cranelift-faerie" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -142,7 +142,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -162,7 +162,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#b4a0ac604fa621a3973822f29edc9d1400bb98d9" +source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -241,7 +241,7 @@ name = "failure_derive" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -324,7 +324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -340,7 +340,7 @@ name = "quote" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -439,7 +439,7 @@ name = "scroll_derive" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -499,7 +499,7 @@ name = "structopt-derive" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -509,7 +509,7 @@ name = "syn" version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -519,7 +519,7 @@ name = "synstructure" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -679,7 +679,7 @@ dependencies = [ "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "762eea716b821300a86da08870a64b597304866ceb9f54a11d67b4cf56459c6a" +"checksum proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "7a17a4d77bc20d344179de803a34694c0ac7a0b3fb4384bee99783215a8e0410" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ed7d650913520df631972f21e104a4fa2f9c82a14afc65d17b388a2e29731e7c" "checksum raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3c460bd35fdb75644e94ab498372bdf29a4849367ce7ba74cf358edce590c4" From 3f4926f43fe2ef4ba3ab54a7dc10468e26b37ea3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Aug 2018 10:02:28 +0200 Subject: [PATCH 0151/1566] Rustup to rustc 1.30.0-nightly (d5a448b3f 2018-08-13) and update Cargo.lock --- 0002-Disable-u128-and-i128-in-libcore.patch | 374 +++++++++----------- Cargo.lock | 30 +- 2 files changed, 186 insertions(+), 218 deletions(-) diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch index e4a1207fe20d6..63ef33a30cf60 100644 --- a/0002-Disable-u128-and-i128-in-libcore.patch +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From 601b4bf31350a620a9de8a50ad699852331fa17e Mon Sep 17 00:00:00 2001 +From 78c557ab91915384c4de6b743fa67dedcb0263c9 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Thu, 19 Jul 2018 18:34:03 +0200 +Date: Tue, 14 Aug 2018 09:59:32 +0200 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -14,26 +14,22 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/lib.rs | 2 - src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/i128.rs | 17 --------- - src/libcore/num/mod.rs | 87 +++++++++++++------------------------------- - src/libcore/num/u128.rs | 16 -------- + src/libcore/num/mod.rs | 92 +++++++++++++------------------------------- src/libcore/num/wrapping.rs | 14 +++---- src/libcore/ops/arith.rs | 22 +++++------ src/libcore/ops/bit.rs | 30 ++++++--------- src/libcore/tests/iter.rs | 15 -------- src/libcore/tests/num/mod.rs | 18 --------- - src/libcore/time.rs | 51 -------------------------- - 19 files changed, 62 insertions(+), 257 deletions(-) - delete mode 100644 src/libcore/num/i128.rs - delete mode 100644 src/libcore/num/u128.rs + src/libcore/time.rs | 51 ------------------------ + 17 files changed, 62 insertions(+), 229 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs -index 3b15ba2b4a..de08ce0289 100644 +index 3b15ba2..de08ce0 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -172,8 +172,8 @@ mod impls { } - + impl_clone! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -43,38 +39,38 @@ index 3b15ba2b4a..de08ce0289 100644 bool char } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index 3626a266ad..4106432a41 100644 +index 58d6c4f..a6e6496 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs -@@ -798,7 +798,7 @@ mod impls { +@@ -800,7 +800,7 @@ mod impls { } - + partial_eq_impl! { - bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 + bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + macro_rules! eq_impl { -@@ -808,7 +808,7 @@ mod impls { +@@ -810,7 +810,7 @@ mod impls { )*) } - + - eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! partial_ord_impl { ($($t:ty)*) => ($( -@@ -897,7 +897,7 @@ mod impls { +@@ -899,7 +899,7 @@ mod impls { } } - + - ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/src/libcore/default.rs b/src/libcore/default.rs -index ab36e29b1e..1926719657 100644 +index ab36e29..1926719 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -145,14 +145,12 @@ default_impl! { u8, 0, "Returns the default value of `0`" } @@ -82,18 +78,18 @@ index ab36e29b1e..1926719657 100644 default_impl! { u32, 0, "Returns the default value of `0`" } default_impl! { u64, 0, "Returns the default value of `0`" } -default_impl! { u128, 0, "Returns the default value of `0`" } - + default_impl! { isize, 0, "Returns the default value of `0`" } default_impl! { i8, 0, "Returns the default value of `0`" } default_impl! { i16, 0, "Returns the default value of `0`" } default_impl! { i32, 0, "Returns the default value of `0`" } default_impl! { i64, 0, "Returns the default value of `0`" } -default_impl! { i128, 0, "Returns the default value of `0`" } - + default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs -index 51391fa50d..140255ea7e 100644 +index 51391fa..140255e 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -29,7 +29,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + @@ -102,7 +98,7 @@ index 51391fa50d..140255ea7e 100644 fn to_u64(&self) -> u64; - fn to_u128(&self) -> u128; } - + macro_rules! doit { @@ -40,10 +39,9 @@ macro_rules! doit { fn to_u16(&self) -> u16 { *self as u16 } @@ -113,7 +109,7 @@ index 51391fa50d..140255ea7e 100644 } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + /// A type that represents a specific radix #[doc(hidden)] @@ -184,7 +182,6 @@ integer! { i8, u8 } @@ -121,11 +117,11 @@ index 51391fa50d..140255ea7e 100644 integer! { i32, u32 } integer! { i64, u64 } -integer! { i128, u128 } - + const DEC_DIGITS_LUT: &'static[u8] = b"0001020304050607080910111213141516171819\ @@ -260,7 +257,6 @@ macro_rules! impl_Display { - + impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); impl_Display!(i64, u64: to_u64); -impl_Display!(i128, u128: to_u128); @@ -133,7 +129,7 @@ index 51391fa50d..140255ea7e 100644 impl_Display!(isize, usize: to_u16); #[cfg(target_pointer_width = "32")] diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs -index e6f8dfffd6..2670d55537 100644 +index e7907e0..84b700c 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -306,12 +306,6 @@ pub trait Hasher { @@ -182,17 +178,17 @@ index e6f8dfffd6..2670d55537 100644 fn write_isize(&mut self, i: isize) { (**self).write_isize(i) } -@@ -577,8 +559,6 @@ mod impls { +@@ -587,8 +569,6 @@ mod impls { (i32, write_i32), (i64, write_i64), (isize, write_isize), - (u128, write_u128), - (i128, write_i128), } - + #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index 651c7a35d4..3708b8ea95 100644 +index 651c7a3..3708b8e 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -175,7 +175,6 @@ step_impl_signed!([i64: u64]); @@ -200,48 +196,48 @@ index 651c7a35d4..3708b8ea95 100644 #[cfg(not(target_pointer_width = "64"))] step_impl_no_between!(u64 i64); -step_impl_no_between!(u128 i128); - + macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs -index 4b2c1aa551..ec3991fa01 100644 +index 4b2c1aa..ec3991f 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -843,7 +843,7 @@ macro_rules! float_sum_product { )*) } - + -integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } float_sum_product! { f32 f64 } - + /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index bdeb6ce426..3bec7a240c 100644 +index c7618b9..31b33a2 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -146,14 +146,12 @@ mod uint_macros; +@@ -144,14 +144,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; -#[path = "num/i128.rs"] pub mod i128; - + #[path = "num/usize.rs"] pub mod usize; #[path = "num/u8.rs"] pub mod u8; #[path = "num/u16.rs"] pub mod u16; #[path = "num/u32.rs"] pub mod u32; #[path = "num/u64.rs"] pub mod u64; -#[path = "num/u128.rs"] pub mod u128; - + #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 4f37b46258..2e8d514700 100644 +index d18e167..ec2edc1 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -649,8 +649,8 @@ mod copy_impls { } - + impl_copy! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -251,7 +247,7 @@ index 4f37b46258..2e8d514700 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 8fb4e0d6a0..e9621d723d 100644 +index 8a74e7c..642fffa 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -196,12 +196,10 @@ pub fn forget(t: T) { @@ -267,31 +263,8 @@ index 8fb4e0d6a0..e9621d723d 100644 /// f32 | 4 /// f64 | 8 /// char | 4 -diff --git a/src/libcore/num/i128.rs b/src/libcore/num/i128.rs -deleted file mode 100644 -index 989376d1ac..0000000000 ---- a/src/libcore/num/i128.rs -+++ /dev/null -@@ -1,17 +0,0 @@ --// Copyright 2016 The Rust Project Developers. See the COPYRIGHT --// file at the top-level directory of this distribution and at --// http://rust-lang.org/COPYRIGHT. --// --// Licensed under the Apache License, Version 2.0 or the MIT license --// , at your --// option. This file may not be copied, modified, or distributed --// except according to those terms. -- --//! The 128-bit signed integer type. --//! --//! *[See also the `i128` primitive type](../../std/primitive.i128.html).* -- --#![stable(feature = "i128", since = "1.26.0")] -- --int_module! { i128, #[stable(feature = "i128", since="1.26.0")] } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 0b8f8f0703..584d24130e 100644 +index eb63966..eb06710 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -95,7 +95,6 @@ nonzero_integers! { @@ -301,59 +274,64 @@ index 0b8f8f0703..584d24130e 100644 - NonZeroU128(u128); NonZeroUsize(usize); } - -@@ -1954,12 +1953,6 @@ impl i64 { - int_impl! { i64, i64, u64, 64, -9223372036854775808, 9223372036854775807, "", "" } + +@@ -2025,15 +2024,6 @@ impl i64 { + "0x6a2c48091e6a2c48" } } - + -#[lang = "i128"] -impl i128 { - int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, -- 170141183460469231731687303715884105727, "", "" } +- 170141183460469231731687303715884105727, "", "", 16, +- "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", +- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48" +- } -} - #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4100,11 +4093,6 @@ impl u64 { - uint_impl! { u64, u64, 64, 18446744073709551615, "", "" } +@@ -4157,13 +4147,6 @@ impl u64 { + "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" } } - + -#[lang = "u128"] -impl u128 { -- uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "" } +- uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16, +- "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", +- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48" } -} - #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4183,7 +4171,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4244,7 +4227,7 @@ macro_rules! from_str_radix_int_impl { } )*} } -from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } +from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } - + /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4299,30 +4287,25 @@ macro_rules! rev { +@@ -4360,30 +4343,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); -try_from_upper_bounded!(u128, u64, u32, u16, u8); - + try_from_both_bounded!(i16, i8); try_from_both_bounded!(i32, i16, i8); try_from_both_bounded!(i64, i32, i16, i8); -try_from_both_bounded!(i128, i64, i32, i16, i8); - + // unsigned-to-signed try_from_upper_bounded!(u8, i8); try_from_upper_bounded!(u16, i8, i16); try_from_upper_bounded!(u32, i8, i16, i32); try_from_upper_bounded!(u64, i8, i16, i32, i64); -try_from_upper_bounded!(u128, i8, i16, i32, i64, i128); - + // signed-to-unsigned -try_from_lower_bounded!(i8, u8, u16, u32, u64, u128); -try_from_lower_bounded!(i16, u16, u32, u64, u128); @@ -368,63 +346,63 @@ index 0b8f8f0703..584d24130e 100644 try_from_both_bounded!(i32, u16, u8); try_from_both_bounded!(i64, u32, u16, u8); -try_from_both_bounded!(i128, u64, u32, u16, u8); - + // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4334,21 +4317,21 @@ mod ptr_try_from_impls { +@@ -4395,21 +4373,21 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8); - try_from_unbounded!(usize, u16, u32, u64, u128); + try_from_unbounded!(usize, u16, u32, u64); try_from_upper_bounded!(usize, i8, i16); - try_from_unbounded!(usize, i32, i64, i128); + try_from_unbounded!(usize, i32, i64); - + try_from_both_bounded!(isize, u8); - try_from_lower_bounded!(isize, u16, u32, u64, u128); + try_from_lower_bounded!(isize, u16, u32, u64); try_from_both_bounded!(isize, i8); - try_from_unbounded!(isize, i16, i32, i64, i128); + try_from_unbounded!(isize, i16, i32, i64); - + - rev!(try_from_upper_bounded, usize, u32, u64, u128); + rev!(try_from_upper_bounded, usize, u32, u64); rev!(try_from_lower_bounded, usize, i8, i16); - rev!(try_from_both_bounded, usize, i32, i64, i128); + rev!(try_from_both_bounded, usize, i32, i64); - + - rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); - rev!(try_from_both_bounded, isize, i32, i64, i128); + rev!(try_from_upper_bounded, isize, u16, u32, u64); + rev!(try_from_both_bounded, isize, i32, i64); } - + #[cfg(target_pointer_width = "32")] -@@ -4357,24 +4340,24 @@ mod ptr_try_from_impls { +@@ -4418,24 +4396,24 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8, u16); - try_from_unbounded!(usize, u32, u64, u128); + try_from_unbounded!(usize, u32, u64); try_from_upper_bounded!(usize, i8, i16, i32); - try_from_unbounded!(usize, i64, i128); + try_from_unbounded!(usize, i64); - + try_from_both_bounded!(isize, u8, u16); - try_from_lower_bounded!(isize, u32, u64, u128); + try_from_lower_bounded!(isize, u32, u64); try_from_both_bounded!(isize, i8, i16); - try_from_unbounded!(isize, i32, i64, i128); + try_from_unbounded!(isize, i32, i64); - + rev!(try_from_unbounded, usize, u32); - rev!(try_from_upper_bounded, usize, u64, u128); + rev!(try_from_upper_bounded, usize, u64); rev!(try_from_lower_bounded, usize, i8, i16, i32); - rev!(try_from_both_bounded, usize, i64, i128); + rev!(try_from_both_bounded, usize, i64); - + rev!(try_from_unbounded, isize, u16); - rev!(try_from_upper_bounded, isize, u32, u64, u128); + rev!(try_from_upper_bounded, isize, u32, u64); @@ -432,47 +410,47 @@ index 0b8f8f0703..584d24130e 100644 - rev!(try_from_both_bounded, isize, i64, i128); + rev!(try_from_both_bounded, isize, i64); } - + #[cfg(target_pointer_width = "64")] -@@ -4383,24 +4366,20 @@ mod ptr_try_from_impls { +@@ -4444,24 +4422,20 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8, u16, u32); - try_from_unbounded!(usize, u64, u128); + try_from_unbounded!(usize, u64); try_from_upper_bounded!(usize, i8, i16, i32, i64); - try_from_unbounded!(usize, i128); - + try_from_both_bounded!(isize, u8, u16, u32); - try_from_lower_bounded!(isize, u64, u128); + try_from_lower_bounded!(isize, u64); try_from_both_bounded!(isize, i8, i16, i32); - try_from_unbounded!(isize, i64, i128); + try_from_unbounded!(isize, i64); - + rev!(try_from_unbounded, usize, u32, u64); - rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); - rev!(try_from_both_bounded, usize, i128); - + rev!(try_from_unbounded, isize, u16, u32); - rev!(try_from_upper_bounded, isize, u64, u128); + rev!(try_from_upper_bounded, isize, u64); rev!(try_from_unbounded, isize, i32, i64); - rev!(try_from_both_bounded, isize, i128); } - + #[doc(hidden)] -@@ -4435,7 +4414,7 @@ macro_rules! doit { +@@ -4496,7 +4470,7 @@ macro_rules! doit { } })*) } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4603,52 +4582,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4664,52 +4638,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -484,7 +462,7 @@ index 0b8f8f0703..584d24130e 100644 impl_from_bool! { i64, #[stable(feature = "from_bool", since = "1.28.0")] } -impl_from_bool! { i128, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { isize, #[stable(feature = "from_bool", since = "1.28.0")] } - + // Unsigned -> Unsigned impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -497,7 +475,7 @@ index 0b8f8f0703..584d24130e 100644 impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] } - + // Signed -> Signed impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -510,7 +488,7 @@ index 0b8f8f0703..584d24130e 100644 impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // Unsigned -> Signed impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -522,33 +500,11 @@ index 0b8f8f0703..584d24130e 100644 impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: -diff --git a/src/libcore/num/u128.rs b/src/libcore/num/u128.rs -deleted file mode 100644 -index e8c783a1bb..0000000000 ---- a/src/libcore/num/u128.rs -+++ /dev/null -@@ -1,16 +0,0 @@ --// Copyright 2016 The Rust Project Developers. See the COPYRIGHT --// file at the top-level directory of this distribution and at --// http://rust-lang.org/COPYRIGHT. --// --// Licensed under the Apache License, Version 2.0 or the MIT license --// , at your --// option. This file may not be copied, modified, or distributed --// except according to those terms. -- --//! The 128-bit unsigned integer type. --//! --//! *[See also the `u128` primitive type](../../std/primitive.u128.html).* -- --#![stable(feature = "i128", since = "1.26.0")] --uint_module! { u128, #[stable(feature = "i128", since="1.26.0")] } diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs -index 1c826c2fa7..0779e31572 100644 +index 1c826c2..0779e31 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -112,19 +112,17 @@ macro_rules! sh_impl_all { @@ -557,7 +513,7 @@ index 1c826c2fa7..0779e31572 100644 //sh_impl_unsigned! { $t, u64 } - //sh_impl_unsigned! { $t, u128 } sh_impl_unsigned! { $t, usize } - + //sh_impl_signed! { $t, i8 } //sh_impl_signed! { $t, i16 } //sh_impl_signed! { $t, i32 } @@ -566,46 +522,46 @@ index 1c826c2fa7..0779e31572 100644 //sh_impl_signed! { $t, isize } )*) } - + -sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + // FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping macro_rules! wrapping_impl { @@ -323,7 +321,7 @@ macro_rules! wrapping_impl { )*) } - + -wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl { ($($t:ty)*) => ($( @@ -685,7 +683,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); )*) } - + -wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_int_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_signed { ($($t:ty)*) => ($( @@ -814,7 +812,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); )*) } - + -wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 } +wrapping_int_impl_signed! { isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_unsigned { ($($t:ty)*) => ($( @@ -891,7 +889,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); )*) } - + -wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 u128 } +wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 } - + mod shift_max { #![allow(non_upper_case_globals)] @@ -918,13 +916,11 @@ mod shift_max { @@ -614,7 +570,7 @@ index 1c826c2fa7..0779e31572 100644 pub const i64: u32 = (1 << 6) - 1; - pub const i128: u32 = (1 << 7) - 1; pub use self::platform::isize; - + pub const u8: u32 = i8; pub const u16: u32 = i16; pub const u32: u32 = i32; @@ -623,143 +579,143 @@ index 1c826c2fa7..0779e31572 100644 pub use self::platform::usize; } diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs -index a1bc5463f7..38742be1ce 100644 +index a1bc546..38742be 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -114,7 +114,7 @@ macro_rules! add_impl { )*) } - + -add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction operator `-`. /// @@ -212,7 +212,7 @@ macro_rules! sub_impl { )*) } - + -sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication operator `*`. /// @@ -332,7 +332,7 @@ macro_rules! mul_impl { )*) } - + -mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division operator `/`. /// @@ -457,7 +457,7 @@ macro_rules! div_impl_integer { )*) } - + -div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! div_impl_float { ($($t:ty)*) => ($( @@ -542,7 +542,7 @@ macro_rules! rem_impl_integer { )*) } - + -rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - + + macro_rules! rem_impl_float { @@ -641,7 +641,7 @@ macro_rules! neg_impl_unsigned { } - + // neg_impl_unsigned! { usize u8 u16 u32 u64 } -neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } +neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } - + /// The addition assignment operator `+=`. /// @@ -697,7 +697,7 @@ macro_rules! add_assign_impl { )+) } - + -add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction assignment operator `-=`. /// @@ -753,7 +753,7 @@ macro_rules! sub_assign_impl { )+) } - + -sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication assignment operator `*=`. /// @@ -800,7 +800,7 @@ macro_rules! mul_assign_impl { )+) } - + -mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division assignment operator `/=`. /// @@ -846,7 +846,7 @@ macro_rules! div_assign_impl { )+) } - + -div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The remainder assignment operator `%=`. /// @@ -896,4 +896,4 @@ macro_rules! rem_assign_impl { )+) } - + -rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs -index 3900f365b0..66b7980a43 100644 +index 3900f36..66b7980 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -65,7 +65,7 @@ macro_rules! not_impl { )*) } - + -not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise AND operator `&`. /// @@ -149,7 +149,7 @@ macro_rules! bitand_impl { )*) } - + -bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR operator `|`. /// @@ -233,7 +233,7 @@ macro_rules! bitor_impl { )*) } - + -bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR operator `^`. /// @@ -320,7 +320,7 @@ macro_rules! bitxor_impl { )*) } - + -bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift operator `<<`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -417,19 +417,17 @@ macro_rules! shl_impl_all { @@ -768,7 +724,7 @@ index 3900f365b0..66b7980a43 100644 shl_impl! { $t, u64 } - shl_impl! { $t, u128 } shl_impl! { $t, usize } - + shl_impl! { $t, i8 } shl_impl! { $t, i16 } shl_impl! { $t, i32 } @@ -777,10 +733,10 @@ index 3900f365b0..66b7980a43 100644 shl_impl! { $t, isize } )*) } - + -shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } +shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift operator `>>`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -526,19 +524,17 @@ macro_rules! shr_impl_all { @@ -789,7 +745,7 @@ index 3900f365b0..66b7980a43 100644 shr_impl! { $t, u64 } - shr_impl! { $t, u128 } shr_impl! { $t, usize } - + shr_impl! { $t, i8 } shr_impl! { $t, i16 } shr_impl! { $t, i32 } @@ -798,37 +754,37 @@ index 3900f365b0..66b7980a43 100644 shr_impl! { $t, isize } )*) } - + -shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The bitwise AND assignment operator `&=`. /// @@ -626,7 +622,7 @@ macro_rules! bitand_assign_impl { )+) } - + -bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR assignment operator `|=`. /// @@ -675,7 +671,7 @@ macro_rules! bitor_assign_impl { )+) } - + -bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR assignment operator `^=`. /// @@ -724,7 +720,7 @@ macro_rules! bitxor_assign_impl { )+) } - + -bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift assignment operator `<<=`. /// @@ -780,19 +776,17 @@ macro_rules! shl_assign_impl_all { @@ -837,7 +793,7 @@ index 3900f365b0..66b7980a43 100644 shl_assign_impl! { $t, u64 } - shl_assign_impl! { $t, u128 } shl_assign_impl! { $t, usize } - + shl_assign_impl! { $t, i8 } shl_assign_impl! { $t, i16 } shl_assign_impl! { $t, i32 } @@ -846,10 +802,10 @@ index 3900f365b0..66b7980a43 100644 shl_assign_impl! { $t, isize } )*) } - + -shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift assignment operator `>>=`. /// @@ -848,16 +842,14 @@ macro_rules! shr_assign_impl_all { @@ -858,7 +814,7 @@ index 3900f365b0..66b7980a43 100644 shr_assign_impl! { $t, u64 } - shr_assign_impl! { $t, u128 } shr_assign_impl! { $t, usize } - + shr_assign_impl! { $t, i8 } shr_assign_impl! { $t, i16 } shr_assign_impl! { $t, i32 } @@ -867,11 +823,11 @@ index 3900f365b0..66b7980a43 100644 shr_assign_impl! { $t, isize } )*) } - + -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index 72b115f8b5..d542e10bb0 100644 +index 72b115f..d542e10 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -224,8 +224,6 @@ fn test_iterator_step_by_nth_overflow() { @@ -880,12 +836,12 @@ index 72b115f8b5..d542e10bb0 100644 type Bigger = u64; - #[cfg(target_pointer_width = "64")] - type Bigger = u128; - + #[derive(Clone)] struct Test(Bigger); @@ -1878,19 +1876,6 @@ fn test_step_replace_signed() { } - + #[test] -fn test_step_replace_no_between() { - let mut x = 4u128; @@ -904,7 +860,7 @@ index 72b115f8b5..d542e10bb0 100644 let f = &|acc, x| i32::checked_add(2*acc, x); assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs -index ab96d3126b..bb5c1d06da 100644 +index ab96d31..bb5c1d0 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs @@ -196,12 +196,10 @@ test_impl_from! { test_boolu8, bool, u8 } @@ -917,7 +873,7 @@ index ab96d3126b..bb5c1d06da 100644 test_impl_from! { test_booli32, bool, i32 } test_impl_from! { test_booli64, bool, i64 } -test_impl_from! { test_booli128, bool, i128 } - + // Signed -> Float test_impl_from! { test_i8f32, i8, f32 } @@ -283,51 +281,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } @@ -929,7 +885,7 @@ index ab96d3126b..bb5c1d06da 100644 test_impl_try_from_always_ok! { test_try_u8i32, u8, i32 } test_impl_try_from_always_ok! { test_try_u8i64, u8, i64 } -test_impl_try_from_always_ok! { test_try_u8i128, u8, i128 } - + test_impl_try_from_always_ok! { test_try_u16u16, u16, u16 } test_impl_try_from_always_ok! { test_try_u16u32, u16, u32 } test_impl_try_from_always_ok! { test_try_u16u64, u16, u64 } @@ -937,49 +893,49 @@ index ab96d3126b..bb5c1d06da 100644 test_impl_try_from_always_ok! { test_try_u16i32, u16, i32 } test_impl_try_from_always_ok! { test_try_u16i64, u16, i64 } -test_impl_try_from_always_ok! { test_try_u16i128, u16, i128 } - + test_impl_try_from_always_ok! { test_try_u32u32, u32, u32 } test_impl_try_from_always_ok! { test_try_u32u64, u32, u64 } -test_impl_try_from_always_ok! { test_try_u32u128, u32, u128 } test_impl_try_from_always_ok! { test_try_u32i64, u32, i64 } -test_impl_try_from_always_ok! { test_try_u32i128, u32, i128 } - + test_impl_try_from_always_ok! { test_try_u64u64, u64, u64 } -test_impl_try_from_always_ok! { test_try_u64u128, u64, u128 } -test_impl_try_from_always_ok! { test_try_u64i128, u64, i128 } - -test_impl_try_from_always_ok! { test_try_u128u128, u128, u128 } - + test_impl_try_from_always_ok! { test_try_i8i8, i8, i8 } test_impl_try_from_always_ok! { test_try_i8i16, i8, i16 } test_impl_try_from_always_ok! { test_try_i8i32, i8, i32 } test_impl_try_from_always_ok! { test_try_i8i64, i8, i64 } -test_impl_try_from_always_ok! { test_try_i8i128, i8, i128 } - + test_impl_try_from_always_ok! { test_try_i16i16, i16, i16 } test_impl_try_from_always_ok! { test_try_i16i32, i16, i32 } test_impl_try_from_always_ok! { test_try_i16i64, i16, i64 } -test_impl_try_from_always_ok! { test_try_i16i128, i16, i128 } - + test_impl_try_from_always_ok! { test_try_i32i32, i32, i32 } test_impl_try_from_always_ok! { test_try_i32i64, i32, i64 } -test_impl_try_from_always_ok! { test_try_i32i128, i32, i128 } - + test_impl_try_from_always_ok! { test_try_i64i64, i64, i64 } -test_impl_try_from_always_ok! { test_try_i64i128, i64, i128 } - -test_impl_try_from_always_ok! { test_try_i128i128, i128, i128 } - + test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index 54973b7b77..1c07753e01 100644 +index b589202..0f8a2ee 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -268,57 +268,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } - + - /// Returns the total number of whole milliseconds contained by this `Duration`. - /// - /// # Examples @@ -1034,6 +990,6 @@ index 54973b7b77..1c07753e01 100644 /// Checked `Duration` addition. Computes `self + other`, returning [`None`] /// if overflow occurred. /// --- +-- 2.11.0 diff --git a/Cargo.lock b/Cargo.lock index ef6d1c8d31cda..c41191ceb21eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,38 +90,48 @@ dependencies = [ [[package]] name = "cranelift" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", ] +[[package]] +name = "cranelift-bforest" +version = "0.18.1" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +dependencies = [ + "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", +] + [[package]] name = "cranelift-codegen" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" dependencies = [ + "cranelift-bforest 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" [[package]] name = "cranelift-entity" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" [[package]] name = "cranelift-faerie" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -134,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -142,17 +152,18 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -162,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#3e01b4f35f02f757dab3d42fbf62b21fef88895f" +source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" dependencies = [ "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -653,6 +664,7 @@ dependencies = [ "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cranelift 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" From 4b10e6e613270f98d39892ab6afcce6e8992765a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Aug 2018 11:58:39 +0200 Subject: [PATCH 0152/1566] Workaround missing encoding for icmp.i8 --- Readme.md | 1 - examples/mini_core_hello_world.rs | 2 +- src/base.rs | 30 +++++++++++++++++++----------- src/common.rs | 6 ++---- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Readme.md b/Readme.md index 615f6c458410f..7f0e8d8b3b7db 100644 --- a/Readme.md +++ b/Readme.md @@ -33,7 +33,6 @@ $ ./build.sh ## Not yet supported * Checked binops -* Statics * Drop glue * Building libraries diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 2519aacc578f1..3ac2e8966b367 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -27,7 +27,7 @@ fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { } unsafe { - NUM = 6 * 7 + 5; + NUM = 6 * 7 + 1 + (1u8 == 1u8) as u8; // 44 *NUM_REF as isize } } diff --git a/src/base.rs b/src/base.rs index cb4ed7900dd85..508cbcf1b7fa0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -382,13 +382,13 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); - let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, false); + let res = crate::common::cton_intcast(fx, from, fx.cton_type(to_ty).unwrap(), false); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (TypeVariants::TyInt(_), TypeVariants::TyInt(_)) | (TypeVariants::TyInt(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); - let res = crate::common::cton_intcast(fx, from, from_ty, to_ty, true); + let res = crate::common::cton_intcast(fx, from, fx.cton_type(to_ty).unwrap(), true); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (TypeVariants::TyFloat(from_flt), TypeVariants::TyFloat(to_flt)) => { @@ -516,7 +516,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( layout::Int(_, signed) => signed, _ => false, }; - let val = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, signed); + let val = cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), signed); return CValue::ByVal(val, dest_layout); } layout::Variants::NicheFilling { @@ -552,7 +552,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( lldiscr, *niche_variants.end() as u64 as i64, ); - let if_true = cton_intcast(fx, lldiscr, discr_ty, dest_layout.ty, false); + let if_true = cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), false); let if_false = fx .bcx .ins() @@ -565,25 +565,33 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( } macro_rules! binop_match { - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, bug) => { + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, bug) => { bug!("binop {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) }; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, icmp($cc:ident)) => {{ + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, icmp($cc:ident)) => {{ assert_eq!($fx.tcx.types.bool, $ret_ty); let ret_layout = $fx.layout_of($ret_ty); - let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); + + // TODO HACK no encoding for icmp.i8 + use crate::common::cton_intcast; + let (lhs, rhs) = ( + cton_intcast($fx, $lhs, types::I64, $signed), + cton_intcast($fx, $rhs, types::I64, $signed), + ); + let b = $fx.bcx.ins().icmp(IntCC::$cc, lhs, rhs); + CValue::ByVal($fx.bcx.ins().bint(types::I8, b), ret_layout) }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ assert_eq!($fx.tcx.types.bool, $ret_ty); let ret_layout = $fx.layout_of($ret_ty); let b = $fx.bcx.ins().fcmp(FloatCC::$cc, $lhs, $rhs); CValue::ByVal($fx.bcx.ins().bint(types::I8, b), ret_layout) }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, custom(|| $body:expr)) => {{ + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, custom(|| $body:expr)) => {{ $body }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $name:ident) => {{ + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $name:ident) => {{ let ret_layout = $fx.layout_of($ret_ty); CValue::ByVal($fx.bcx.ins().$name($lhs, $rhs), ret_layout) }}; @@ -597,7 +605,7 @@ macro_rules! binop_match { let rhs = $rhs.load_value($fx); match ($bin_op, $signed) { $( - (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, lhs, rhs, $ret_ty, $name $( ( $($next)* ) )?), + (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, $signed, lhs, rhs, $ret_ty, $name $( ( $($next)* ) )?), )* } }} diff --git a/src/common.rs b/src/common.rs index ad0fb3392ca99..dc9023eda4f39 100644 --- a/src/common.rs +++ b/src/common.rs @@ -331,12 +331,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn cton_intcast<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx>, val: Value, - from: Ty<'tcx>, - to: Ty<'tcx>, + to: Type, signed: bool, ) -> Value { - let from = fx.cton_type(from).unwrap(); - let to = fx.cton_type(to).unwrap(); + let from = fx.bcx.func.dfg.value_type(val); if from == to { return val; } From 0978710ffdddd37b647d65b014d6f348d6fd96e8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Aug 2018 12:13:07 +0200 Subject: [PATCH 0153/1566] Codegen minicore --- build.sh | 2 +- src/abi.rs | 59 ++++++++++++++++++++++++++++++----------------------- src/base.rs | 27 ++++++++++++++---------- src/lib.rs | 11 ++++++++++ 4 files changed, 62 insertions(+), 37 deletions(-) diff --git a/build.sh b/build.sh index d282c788c369f..59922bb7399e1 100755 --- a/build.sh +++ b/build.sh @@ -14,7 +14,7 @@ fi RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=." -$RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib && +SHOULD_CODEGEN=1 $RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib && $RUSTC examples/example.rs --crate-type lib && $RUSTC examples/mini_core_hello_world.rs --crate-type bin && diff --git a/src/abi.rs b/src/abi.rs index 9b9c59162ff25..da28dc04c4b45 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -278,33 +278,42 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb Spread(Vec), } - let func_params = fx.mir.args_iter().map(|local| { - let arg_ty = fx.monomorphize(&fx.mir.local_decls[local].ty); - - // Adapted from https://github.com/rust-lang/rust/blob/145155dc96757002c7b2e9de8489416e2fdbbd57/src/librustc_codegen_llvm/mir/mod.rs#L442-L482 - if Some(local) == fx.mir.spread_arg { - // This argument (e.g. the last argument in the "rust-call" ABI) - // is a tuple that was spread at the ABI level and now we have - // to reconstruct it into a tuple local variable, from multiple - // individual function arguments. - - let tupled_arg_tys = match arg_ty.sty { - ty::TyTuple(ref tys) => tys, - _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), - }; + let func_params = fx + .mir + .args_iter() + .map(|local| { + let arg_ty = fx.monomorphize(&fx.mir.local_decls[local].ty); + + // Adapted from https://github.com/rust-lang/rust/blob/145155dc96757002c7b2e9de8489416e2fdbbd57/src/librustc_codegen_llvm/mir/mod.rs#L442-L482 + if Some(local) == fx.mir.spread_arg { + // This argument (e.g. the last argument in the "rust-call" ABI) + // is a tuple that was spread at the ABI level and now we have + // to reconstruct it into a tuple local variable, from multiple + // individual function arguments. + + let tupled_arg_tys = match arg_ty.sty { + ty::TyTuple(ref tys) => tys, + _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), + }; + + let mut ebb_params = Vec::new(); + for arg_ty in tupled_arg_tys.iter() { + let cton_type = + get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); + ebb_params.push(fx.bcx.append_ebb_param(start_ebb, cton_type)); + } - let mut ebb_params = Vec::new(); - for arg_ty in tupled_arg_tys.iter() { - let cton_type = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); - ebb_params.push(fx.bcx.append_ebb_param(start_ebb, cton_type)); + (local, ArgKind::Spread(ebb_params), arg_ty) + } else { + let cton_type = + get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); + ( + local, + ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, cton_type)), + arg_ty, + ) } - - (local, ArgKind::Spread(ebb_params), arg_ty) - } else { - let cton_type = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); - (local, ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, cton_type)), arg_ty) - } - }).collect::>(); + }).collect::>(); match output_pass_mode { PassMode::NoPass => { diff --git a/src/base.rs b/src/base.rs index 508cbcf1b7fa0..40c858508d317 100644 --- a/src/base.rs +++ b/src/base.rs @@ -50,13 +50,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( context.func = func; // TODO: cranelift doesn't yet support some of the things needed - if cx - .tcx - .sess - .crate_types - .get() - .contains(&CrateType::Executable) - { + if should_codegen(cx.tcx) { cx.module.define_function(func_id, context).unwrap(); cx.defined_functions.push(func_id); } @@ -171,7 +165,7 @@ pub fn trans_fn<'a, 'tcx: 'a>( } => { fx.bcx.ins().trap(TrapCode::User(0)); // TODO: prevent panics on large and negative disciminants - if false { + if should_codegen(fx.tcx) { let discr = trans_operand(fx, discr).load_value(fx); let mut jt_data = JumpTableData::new(); for (i, value) in values.iter().enumerate() { @@ -382,13 +376,23 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); - let res = crate::common::cton_intcast(fx, from, fx.cton_type(to_ty).unwrap(), false); + let res = crate::common::cton_intcast( + fx, + from, + fx.cton_type(to_ty).unwrap(), + false, + ); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (TypeVariants::TyInt(_), TypeVariants::TyInt(_)) | (TypeVariants::TyInt(_), TypeVariants::TyUint(_)) => { let from = operand.load_value(fx); - let res = crate::common::cton_intcast(fx, from, fx.cton_type(to_ty).unwrap(), true); + let res = crate::common::cton_intcast( + fx, + from, + fx.cton_type(to_ty).unwrap(), + true, + ); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (TypeVariants::TyFloat(from_flt), TypeVariants::TyFloat(to_flt)) => { @@ -552,7 +556,8 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( lldiscr, *niche_variants.end() as u64 as i64, ); - let if_true = cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), false); + let if_true = + cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), false); let if_false = fx .bcx .ins() diff --git a/src/lib.rs b/src/lib.rs index 1f202dc9c4bc3..b89586c9415a1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,6 +89,11 @@ mod prelude { pub use crate::common::*; pub use crate::CodegenCx; + + pub fn should_codegen(tcx: TyCtxt) -> bool { + ::std::env::var("SHOULD_CODEGEN").is_ok() + || tcx.sess.crate_types.get().contains(&CrateType::Executable) + } } use crate::prelude::*; @@ -317,6 +322,12 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn(&format!("main returned {}", res)); module.finish(); + } else if should_codegen(tcx) { + for func_id in defined_functions { + module.finalize_function(func_id); + } + + tcx.sess.warn("Finalized everything"); } let mut translated_module: Module = Module::new( From f67ad9c120174356d7673238a735bea0d800ea52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Aug 2018 18:52:43 +0200 Subject: [PATCH 0154/1566] Refactoring --- src/abi.rs | 19 +++----- src/base.rs | 123 ++++++++++++++++++++++++++---------------------- src/constant.rs | 4 +- src/lib.rs | 42 +++++++++-------- 4 files changed, 98 insertions(+), 90 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index da28dc04c4b45..036ea80d7ee16 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -163,19 +163,6 @@ pub fn get_function_name_and_sig<'a, 'tcx>( (tcx.symbol_name(inst).as_str().to_string(), sig) } -impl<'a, 'tcx: 'a> CodegenCx<'a, 'tcx, CurrentBackend> { - pub fn predefine_function(&mut self, inst: Instance<'tcx>) -> (FuncId, Function) { - let (name, sig) = crate::abi::get_function_name_and_sig(self.tcx, inst); - let func_id = self - .module - .declare_function(&name, Linkage::Export, &sig) - .unwrap(); - let func = - Function::with_name_signature(ExternalName::user(0, func_id.index() as u32), sig); - (func_id, func) - } -} - impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { @@ -315,6 +302,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb } }).collect::>(); + fx.bcx.switch_to_block(start_ebb); + match output_pass_mode { PassMode::NoPass => { let null = fx.bcx.ins().iconst(types::I64, 0); @@ -418,6 +407,10 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb fx.local_map.insert(local, place); } + + fx.bcx + .ins() + .jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); } pub fn codegen_call<'a, 'tcx: 'a>( diff --git a/src/base.rs b/src/base.rs index 40c858508d317..1c14c94065ccf 100644 --- a/src/base.rs +++ b/src/base.rs @@ -2,7 +2,6 @@ use crate::prelude::*; pub fn trans_mono_item<'a, 'tcx: 'a>( cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, - context: &mut Context, mono_item: MonoItem<'tcx>, ) { let tcx = cx.tcx; @@ -21,41 +20,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( String::from_utf8_lossy(&mir.into_inner()) )); - let (func_id, mut func) = cx.predefine_function(inst); - - let comments = trans_fn(cx, &mut func, inst); - - let mut writer = crate::pretty_clif::CommentWriter(comments); - let mut cton = String::new(); - ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None) - .unwrap(); - tcx.sess.warn(&cton); - - let flags = settings::Flags::new(settings::builder()); - match ::cranelift::codegen::verify_function(&func, &flags) { - Ok(_) => {} - Err(err) => { - tcx.sess.err(&format!("{:?}", err)); - let pretty_error = - ::cranelift::codegen::print_errors::pretty_verifier_error( - &func, - None, - Some(Box::new(writer)), - &err, - ); - tcx.sess - .fatal(&format!("cretonne verify error:\n{}", pretty_error)); - } - } - - context.func = func; - // TODO: cranelift doesn't yet support some of the things needed - if should_codegen(cx.tcx) { - cx.module.define_function(func_id, context).unwrap(); - cx.defined_functions.push(func_id); - } - - context.clear(); + let func_id = trans_fn(cx.tcx, cx.module, &mut cx.constants, &mut cx.context, inst); + cx.defined_functions.push(func_id); } Instance { def: InstanceDef::DropGlue(_, _), @@ -64,7 +30,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( inst => unimpl!("Unimplemented instance {:?}", inst), }, MonoItem::Static(def_id) => { - crate::constant::codegen_static(cx, def_id); + crate::constant::codegen_static(&mut cx.constants, def_id); } MonoItem::GlobalAsm(node_id) => cx .tcx @@ -73,25 +39,38 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } } -pub fn trans_fn<'a, 'tcx: 'a>( - cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, - f: &mut Function, +fn trans_fn<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + constants: &mut crate::constant::ConstantCx, + context: &mut Context, instance: Instance<'tcx>, -) -> HashMap { - let mir = cx.tcx.optimized_mir(instance.def_id()); +) -> FuncId { + // Step 1. Get mir + let mir = tcx.optimized_mir(instance.def_id()); + + // Step 2. Declare function + let (name, sig) = get_function_name_and_sig(tcx, instance); + let func_id = module + .declare_function(&name, Linkage::Export, &sig) + .unwrap(); + + // Step 3. Make FunctionBuilder + let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx: FunctionBuilder = FunctionBuilder::new(f, &mut func_ctx); + let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut func, &mut func_ctx); + // Step 4. Predefine ebb's let start_ebb = bcx.create_ebb(); - bcx.switch_to_block(start_ebb); let mut ebb_map: HashMap = HashMap::new(); for (bb, _bb_data) in mir.basic_blocks().iter_enumerated() { ebb_map.insert(bb, bcx.create_ebb()); } + // Step 5. Make FunctionCx let mut fx = FunctionCx { - tcx: cx.tcx, - module: &mut cx.module, + tcx, + module, instance, mir, bcx, @@ -102,17 +81,53 @@ pub fn trans_fn<'a, 'tcx: 'a>( ebb_map, local_map: HashMap::new(), comments: HashMap::new(), - constants: &mut cx.constants, + constants, }; - let fx = &mut fx; - crate::abi::codegen_fn_prelude(fx, start_ebb); + // Step 6. Codegen function + crate::abi::codegen_fn_prelude(&mut fx, start_ebb); + codegen_fn_content(&mut fx); + + // Step 7. Print function to terminal for debugging + let mut writer = crate::pretty_clif::CommentWriter(fx.comments); + let mut cton = String::new(); + ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None).unwrap(); + tcx.sess.warn(&cton); + + // Step 8. Verify function + verify_func(tcx, writer, &func); + + // Step 9. Define function + // TODO: cranelift doesn't yet support some of the things needed + if should_codegen(tcx) { + context.func = func; + module.define_function(func_id, context).unwrap(); + context.clear(); + } + + func_id +} - fx.bcx - .ins() - .jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); +fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Function) { + let flags = settings::Flags::new(settings::builder()); + match ::cranelift::codegen::verify_function(&func, &flags) { + Ok(_) => {} + Err(err) => { + tcx.sess.err(&format!("{:?}", err)); + let pretty_error = ::cranelift::codegen::print_errors::pretty_verifier_error( + &func, + None, + Some(Box::new(writer)), + &err, + ); + tcx.sess + .fatal(&format!("cretonne verify error:\n{}", pretty_error)); + } + } +} - for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { +fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>) { + for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { let ebb = fx.get_ebb(bb); fx.bcx.switch_to_block(ebb); @@ -208,8 +223,6 @@ pub fn trans_fn<'a, 'tcx: 'a>( fx.bcx.seal_all_blocks(); fx.bcx.finalize(); - - fx.comments.clone() } fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: &Statement<'tcx>) { diff --git a/src/constant.rs b/src/constant.rs index 594cafc44fbb1..868bf2a818101 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -32,8 +32,8 @@ impl ConstantCx { } } -pub fn codegen_static<'a, 'tcx: 'a, B: Backend>(cx: &mut CodegenCx<'a, 'tcx, B>, def_id: DefId) { - cx.constants.todo.insert(TodoItem::Static(def_id)); +pub fn codegen_static<'a, 'tcx: 'a>(ccx: &mut ConstantCx, def_id: DefId) { + ccx.todo.insert(TodoItem::Static(def_id)); } pub fn codegen_static_ref<'a, 'tcx: 'a>( diff --git a/src/lib.rs b/src/lib.rs index b89586c9415a1..9e6e9acf4c0c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,6 +103,9 @@ pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { pub module: &'a mut Module, pub constants: crate::constant::ConstantCx, pub defined_functions: Vec, + + // Cache + pub context: Context, } struct CraneliftMetadataLoader; @@ -248,16 +251,25 @@ impl CodegenBackend for CraneliftCodegenBackend { let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()) .unwrap() .finish(flags); - let mut module: Module = Module::new(SimpleJITBuilder::new()); - let mut context = Context::new(); + let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); + let mut faerie_module: Module = Module::new( + FaerieBuilder::new( + isa, + "some_file.o".to_string(), + FaerieTrapCollection::Disabled, + FaerieBuilder::default_libcall_names(), + ).unwrap(), + ); let defined_functions = { use std::io::Write; let mut cx = CodegenCx { tcx, - module: &mut module, + module: &mut jit_module, constants: Default::default(), defined_functions: Vec::new(), + + context: Context::new(), }; let mut log = ::std::fs::File::create("target/log.txt").unwrap(); @@ -273,9 +285,8 @@ impl CodegenBackend for CraneliftCodegenBackend { for mono_item in mono_items { let cx = &mut cx; - let context = &mut context; let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(move || { - base::trans_mono_item(cx, context, mono_item); + base::trans_mono_item(cx, mono_item); })); if let Err(err) = res { match err.downcast::() { @@ -304,43 +315,34 @@ impl CodegenBackend for CraneliftCodegenBackend { let (name, sig) = crate::abi::get_function_name_and_sig(tcx, Instance::mono(tcx, start_wrapper)); - let called_func_id = module + let called_func_id = jit_module .declare_function(&name, Linkage::Import, &sig) .unwrap(); for func_id in defined_functions { if func_id != called_func_id { - module.finalize_function(func_id); + jit_module.finalize_function(func_id); } } tcx.sess.warn("Finalized everything"); - let finalized_function: *const u8 = module.finalize_function(called_func_id); + let finalized_function: *const u8 = jit_module.finalize_function(called_func_id); let f: extern "C" fn(*const u8, isize, *const *const u8) -> isize = unsafe { ::std::mem::transmute(finalized_function) }; let res = f(0 as *const u8, 0, 0 as *const _); tcx.sess.warn(&format!("main returned {}", res)); - module.finish(); + jit_module.finish(); } else if should_codegen(tcx) { for func_id in defined_functions { - module.finalize_function(func_id); + jit_module.finalize_function(func_id); } tcx.sess.warn("Finalized everything"); } - let mut translated_module: Module = Module::new( - FaerieBuilder::new( - isa, - "some_file.o".to_string(), - FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names(), - ).unwrap(), - ); - Box::new(OngoingCodegen { - product: translated_module.finish(), + product: faerie_module.finish(), metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), }) From 178aa32b0cc4cfe0e590fd4a456536418bd3cf7f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Aug 2018 20:31:16 +0200 Subject: [PATCH 0155/1566] Make FunctionCx generic over Backend --- src/abi.rs | 15 +++++++------ src/analyze.rs | 2 +- src/base.rs | 26 ++++++++++++---------- src/common.rs | 54 ++++++++++++++++++++++++++++------------------ src/constant.rs | 14 ++++++------ src/pretty_clif.rs | 2 +- 6 files changed, 66 insertions(+), 47 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 036ea80d7ee16..84abc5eced8e1 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -13,7 +13,7 @@ enum PassMode { } impl PassMode { - fn get_param_ty(self, _fx: &FunctionCx) -> Type { + fn get_param_ty(self, _fx: &FunctionCx) -> Type { match self { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(cton_type) => cton_type, @@ -163,7 +163,7 @@ pub fn get_function_name_and_sig<'a, 'tcx>( (tcx.symbol_name(inst).as_str().to_string(), sig) } -impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { +impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { let (name, sig) = get_function_name_and_sig(self.tcx, inst); @@ -243,7 +243,10 @@ impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { } } -pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb: Ebb) { +pub fn codegen_fn_prelude<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + start_ebb: Ebb, +) { let ssa_analyzed = crate::analyze::analyze(fx); fx.tcx.sess.warn(&format!("ssa {:?}", ssa_analyzed)); @@ -414,7 +417,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, start_ebb } pub fn codegen_call<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, func: &Operand<'tcx>, args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, @@ -507,7 +510,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( } } -pub fn codegen_return(fx: &mut FunctionCx) { +pub fn codegen_return(fx: &mut FunctionCx) { match get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true) { PassMode::NoPass | PassMode::ByRef => { fx.bcx.ins().return_(&[]); @@ -521,7 +524,7 @@ pub fn codegen_return(fx: &mut FunctionCx) { } fn codegen_intrinsic_call<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, fn_ty: Ty<'tcx>, sig: FnSig<'tcx>, args: &[CValue<'tcx>], diff --git a/src/analyze.rs b/src/analyze.rs index cd53a810fe420..048f8812d444b 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -8,7 +8,7 @@ bitflags! { } } -pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx>) -> HashMap { +pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap { let mut flag_map = HashMap::new(); for local in fx.mir.local_decls.indices() { diff --git a/src/base.rs b/src/base.rs index 1c14c94065ccf..4c91db448c7bd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -126,7 +126,7 @@ fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Fu } } -fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>) { +fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) { for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { let ebb = fx.get_ebb(bb); fx.bcx.switch_to_block(ebb); @@ -225,7 +225,11 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>) { fx.bcx.finalize(); } -fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: &Statement<'tcx>) { +fn trans_stmt<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + cur_ebb: Ebb, + stmt: &Statement<'tcx>, +) { fx.tcx.sess.warn(&format!("stmt {:?}", stmt)); let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); @@ -504,7 +508,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: & } pub fn trans_get_discriminant<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value: CValue<'tcx>, dest_layout: TyLayout<'tcx>, ) -> CValue<'tcx> { @@ -630,7 +634,7 @@ macro_rules! binop_match { } fn trans_bool_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, @@ -663,7 +667,7 @@ fn trans_bool_binop<'a, 'tcx: 'a>( } pub fn trans_int_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, @@ -709,7 +713,7 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( } pub fn trans_checked_int_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, @@ -771,7 +775,7 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( } fn trans_float_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, @@ -812,7 +816,7 @@ fn trans_float_binop<'a, 'tcx: 'a>( } fn trans_char_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, @@ -845,7 +849,7 @@ fn trans_char_binop<'a, 'tcx: 'a>( } fn trans_ptr_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, @@ -884,7 +888,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( } pub fn trans_place<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, place: &Place<'tcx>, ) -> CPlace<'tcx> { match place { @@ -937,7 +941,7 @@ pub fn trans_place<'a, 'tcx: 'a>( } pub fn trans_operand<'a, 'tcx>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, operand: &Operand<'tcx>, ) -> CValue<'tcx> { match operand { diff --git a/src/common.rs b/src/common.rs index dc9023eda4f39..e0c66218ba264 100644 --- a/src/common.rs +++ b/src/common.rs @@ -62,7 +62,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( } fn codegen_field<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, base: Value, layout: TyLayout<'tcx>, field: mir::Field, @@ -92,7 +92,7 @@ impl<'tcx> CValue<'tcx> { } } - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value where 'tcx: 'a, { @@ -114,7 +114,7 @@ impl<'tcx> CValue<'tcx> { } } - pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx>) -> Value + pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value where 'tcx: 'a, { @@ -138,7 +138,11 @@ impl<'tcx> CValue<'tcx> { } } - pub fn value_field<'a>(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CValue<'tcx> + pub fn value_field<'a>( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + field: mir::Field, + ) -> CValue<'tcx> where 'tcx: 'a, { @@ -152,7 +156,7 @@ impl<'tcx> CValue<'tcx> { } pub fn const_val<'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, const_val: i64, ) -> CValue<'tcx> @@ -187,7 +191,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn temp(fx: &mut FunctionCx<'a, 'tcx>, ty: Ty<'tcx>) -> CPlace<'tcx> { + pub fn temp(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> CPlace<'tcx> { let layout = fx.layout_of(ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, @@ -198,7 +202,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } pub fn from_stack_slot( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, stack_slot: StackSlot, ty: Ty<'tcx>, ) -> CPlace<'tcx> { @@ -206,7 +210,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0), layout) } - pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>) -> CValue<'tcx> { + pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { match self { CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(var), layout), CPlace::Addr(addr, layout) => CValue::ByRef(addr, layout), @@ -220,7 +224,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx>, from: CValue<'tcx>) { + pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { match (&self.layout().ty.sty, &from.layout().ty.sty) { (TypeVariants::TyRef(_, t, dest_mut), TypeVariants::TyRef(_, u, src_mut)) if (if *dest_mut != ::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { @@ -289,7 +293,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn place_field(self, fx: &mut FunctionCx<'a, 'tcx>, field: mir::Field) -> CPlace<'tcx> { + pub fn place_field( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + field: mir::Field, + ) -> CPlace<'tcx> { let base = self.expect_addr(); let layout = self.layout(); @@ -297,7 +305,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(field_ptr, field_layout) } - pub fn place_index(self, fx: &mut FunctionCx<'a, 'tcx>, index: Value) -> CPlace<'tcx> { + pub fn place_index( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + index: Value, + ) -> CPlace<'tcx> { let addr = self.expect_addr(); let layout = self.layout(); match layout.ty.sty { @@ -322,14 +334,14 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx>, variant: usize) -> Self { + pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx, impl Backend>, variant: usize) -> Self { let layout = self.layout().for_variant(fx, variant); self.unchecked_cast_to(layout) } } pub fn cton_intcast<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, val: Value, to: Type, signed: bool, @@ -349,9 +361,9 @@ pub fn cton_intcast<'a, 'tcx: 'a>( } } -pub struct FunctionCx<'a, 'tcx: 'a> { +pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, - pub module: &'a mut Module, + pub module: &'a mut Module, pub instance: Instance<'tcx>, pub mir: &'tcx Mir<'tcx>, pub param_substs: &'tcx Substs<'tcx>, @@ -362,7 +374,7 @@ pub struct FunctionCx<'a, 'tcx: 'a> { pub constants: &'a mut crate::constant::ConstantCx, } -impl<'a, 'tcx: 'a> fmt::Debug for FunctionCx<'a, 'tcx> { +impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f, "{:?}", self.param_substs)?; writeln!(f, "{:?}", self.local_map)?; @@ -379,7 +391,7 @@ impl<'a, 'tcx: 'a> fmt::Debug for FunctionCx<'a, 'tcx> { } } -impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> { +impl<'a, 'tcx: 'a, B: Backend> LayoutOf for &'a FunctionCx<'a, 'tcx, B> { type Ty = Ty<'tcx>; type TyLayout = TyLayout<'tcx>; @@ -389,25 +401,25 @@ impl<'a, 'tcx: 'a> LayoutOf for &'a FunctionCx<'a, 'tcx> { } } -impl<'a, 'tcx> layout::HasTyCtxt<'tcx> for &'a FunctionCx<'a, 'tcx> { +impl<'a, 'tcx, B: Backend + 'a> layout::HasTyCtxt<'tcx> for &'a FunctionCx<'a, 'tcx, B> { fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx } } -impl<'a, 'tcx> layout::HasDataLayout for &'a FunctionCx<'a, 'tcx> { +impl<'a, 'tcx, B: Backend + 'a> layout::HasDataLayout for &'a FunctionCx<'a, 'tcx, B> { fn data_layout(&self) -> &layout::TargetDataLayout { &self.tcx.data_layout } } -impl<'a, 'tcx> HasTargetSpec for &'a FunctionCx<'a, 'tcx> { +impl<'a, 'tcx, B: Backend + 'a> HasTargetSpec for &'a FunctionCx<'a, 'tcx, B> { fn target_spec(&self) -> &Target { &self.tcx.sess.target.target } } -impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { +impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { pub fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx>, diff --git a/src/constant.rs b/src/constant.rs index 868bf2a818101..d745386e758b9 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -37,7 +37,7 @@ pub fn codegen_static<'a, 'tcx: 'a>(ccx: &mut ConstantCx, def_id: DefId) { } pub fn codegen_static_ref<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, static_: &Static<'tcx>, ) -> CPlace<'tcx> { let data_id = data_id_for_static(fx.tcx, fx.module, static_.def_id); @@ -45,7 +45,7 @@ pub fn codegen_static_ref<'a, 'tcx: 'a>( } pub fn trans_promoted<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, promoted: Promoted, ) -> CPlace<'tcx> { let const_ = fx @@ -60,7 +60,7 @@ pub fn trans_promoted<'a, 'tcx: 'a>( } pub fn trans_constant<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { let const_ = fx.monomorphize(&constant.literal); @@ -69,7 +69,7 @@ pub fn trans_constant<'a, 'tcx: 'a>( } fn force_eval_const<'a, 'tcx: 'a>( - fx: &FunctionCx<'a, 'tcx>, + fx: &FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> &'tcx Const<'tcx> { match const_.val { @@ -87,7 +87,7 @@ fn force_eval_const<'a, 'tcx: 'a>( } fn trans_const_value<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); @@ -114,7 +114,7 @@ fn trans_const_value<'a, 'tcx: 'a>( } fn trans_const_place<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> CPlace<'tcx> { let alloc = fx.tcx.const_value_to_allocation(const_); @@ -139,7 +139,7 @@ fn data_id_for_static(tcx: TyCtxt, module: &mut Module, def_id: D } fn cplace_for_dataid<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, data_id: DataId, ) -> CPlace<'tcx> { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 51c170375613e..d872a70b0fe5d 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -34,7 +34,7 @@ impl FuncWriter for CommentWriter { } } -impl<'a, 'tcx: 'a> FunctionCx<'a, 'tcx> { +impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { use std::collections::hash_map::Entry; match self.comments.entry(inst) { From 0f26781a8611a985eba374b7581a7b439dde760e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Aug 2018 20:58:24 +0200 Subject: [PATCH 0156/1566] Support simplejit and faerie at the same time --- examples/mini_core_hello_world.rs | 2 ++ src/base.rs | 18 ++++++------ src/common.rs | 2 -- src/lib.rs | 47 ++++++++++++++++++++++++------- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 3ac2e8966b367..014d7aaa40c4b 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -26,6 +26,8 @@ fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { puts(ptr); } + //panic(&("panic msg", "abc.rs", 0, 43)); + unsafe { NUM = 6 * 7 + 1 + (1u8 == 1u8) as u8; // 44 *NUM_REF as isize diff --git a/src/base.rs b/src/base.rs index 4c91db448c7bd..3944d474d26a3 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,10 +1,8 @@ use crate::prelude::*; -pub fn trans_mono_item<'a, 'tcx: 'a>( - cx: &mut CodegenCx<'a, 'tcx, CurrentBackend>, - mono_item: MonoItem<'tcx>, -) { +pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: MonoItem<'tcx>) { let tcx = cx.tcx; + let context = &mut cx.context; match mono_item { MonoItem::Fn(inst) => match inst { @@ -20,8 +18,10 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( String::from_utf8_lossy(&mir.into_inner()) )); - let func_id = trans_fn(cx.tcx, cx.module, &mut cx.constants, &mut cx.context, inst); - cx.defined_functions.push(func_id); + let res = each_module!(cx, |(ccx, m)| trans_fn(tcx, *m, ccx, context, inst)); + if let Some(func_id) = res.jit { + cx.defined_functions.push(func_id); + }; } Instance { def: InstanceDef::DropGlue(_, _), @@ -30,7 +30,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( inst => unimpl!("Unimplemented instance {:?}", inst), }, MonoItem::Static(def_id) => { - crate::constant::codegen_static(&mut cx.constants, def_id); + each_module!(cx, |(ccx, _m)| { + crate::constant::codegen_static(ccx, def_id); + }); } MonoItem::GlobalAsm(node_id) => cx .tcx @@ -41,7 +43,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( fn trans_fn<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &mut Module, + module: &mut Module, constants: &mut crate::constant::ConstantCx, context: &mut Context, instance: Instance<'tcx>, diff --git a/src/common.rs b/src/common.rs index e0c66218ba264..7ed91a30d2f75 100644 --- a/src/common.rs +++ b/src/common.rs @@ -6,8 +6,6 @@ use cranelift_module::Module; use crate::prelude::*; -pub type CurrentBackend = ::cranelift_simplejit::SimpleJITBackend; - #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct Variable(pub Local); diff --git a/src/lib.rs b/src/lib.rs index 9e6e9acf4c0c4..b2f87a2171d67 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,6 +47,15 @@ macro_rules! unimpl { }; } +macro_rules! each_module { + ($cx:expr, |$p:pat| $res:expr) => { + ModuleTup { + jit: $cx.jit.as_mut().map(|$p| $res), + faerie: $cx.faerie.as_mut().map(|$p| $res), + } + }; +} + mod abi; mod analyze; mod base; @@ -88,7 +97,7 @@ mod prelude { pub use crate::common::Variable; pub use crate::common::*; - pub use crate::CodegenCx; + pub use crate::{CodegenCx, ModuleTup}; pub fn should_codegen(tcx: TyCtxt) -> bool { ::std::env::var("SHOULD_CODEGEN").is_ok() @@ -96,18 +105,24 @@ mod prelude { } } +use crate::constant::ConstantCx; use crate::prelude::*; -pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'a> { +pub struct CodegenCx<'a, 'tcx: 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, - pub module: &'a mut Module, - pub constants: crate::constant::ConstantCx, + pub jit: Option<(ConstantCx, &'a mut Module)>, + pub faerie: Option<(ConstantCx, &'a mut Module)>, pub defined_functions: Vec, // Cache pub context: Context, } +pub struct ModuleTup { + jit: Option, + faerie: Option, +} + struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { @@ -265,8 +280,8 @@ impl CodegenBackend for CraneliftCodegenBackend { use std::io::Write; let mut cx = CodegenCx { tcx, - module: &mut jit_module, - constants: Default::default(), + jit: Some((ConstantCx::default(), &mut jit_module)), + faerie: Some((ConstantCx::default(), &mut faerie_module)), defined_functions: Vec::new(), context: Context::new(), @@ -299,7 +314,18 @@ impl CodegenBackend for CraneliftCodegenBackend { } } - cx.constants.finalize(tcx, &mut cx.module); + match cx { + CodegenCx { + tcx, + jit, + faerie, + defined_functions: _, + context: _, + } => { + jit.map(|jit| jit.0.finalize(tcx, jit.1)); + faerie.map(|faerie| faerie.0.finalize(tcx, faerie.1)); + } + } let after = ::std::time::Instant::now(); println!("time: {:?}", after - before); @@ -307,6 +333,8 @@ impl CodegenBackend for CraneliftCodegenBackend { cx.defined_functions }; + tcx.sess.abort_if_errors(); + tcx.sess.warn("Compiled everything"); // TODO: this doesn't work most of the time @@ -334,9 +362,8 @@ impl CodegenBackend for CraneliftCodegenBackend { jit_module.finish(); } else if should_codegen(tcx) { - for func_id in defined_functions { - jit_module.finalize_function(func_id); - } + jit_module.finalize_all(); + faerie_module.finalize_all(); tcx.sess.warn("Finalized everything"); } From a8ca0f02fc07fa50c564f3c873a9e2fe60e8e1c9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Aug 2018 22:01:18 +0200 Subject: [PATCH 0157/1566] Support emitting object files (fixes #5) --- .gitignore | 1 + build.sh | 28 ++++++++++++++++++++++------ src/base.rs | 4 ++-- src/lib.rs | 50 +++++++++++++++++++++++++++++++++++--------------- 4 files changed, 60 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 02ca9dcf64f2a..75bcfff8c53c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target **/*.rs.bk *.rlib +*.o diff --git a/build.sh b/build.sh index 59922bb7399e1..69730353d68f8 100755 --- a/build.sh +++ b/build.sh @@ -12,12 +12,28 @@ else exit 1 fi +extract_data() { + ar x $1 data.o && + chmod +rw data.o && + mv data.o $2 +} + RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=." -SHOULD_CODEGEN=1 $RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib && -$RUSTC examples/example.rs --crate-type lib && -$RUSTC examples/mini_core_hello_world.rs --crate-type bin && +pushd target/libcore + +SHOULD_CODEGEN=1 $RUSTC ../../examples/mini_core.rs --crate-name mini_core --crate-type lib && +extract_data libmini_core.rlib mini_core.o && + +$RUSTC ../../examples/example.rs --crate-type lib && + +SHOULD_RUN=1 $RUSTC ../../examples/mini_core_hello_world.rs --crate-type bin && + +$RUSTC ../../examples/mini_core_hello_world.rs --crate-type bin && +extract_data mini_core_hello_world mini_core_hello_world.o + +gcc mini_core.o mini_core_hello_world.o -o mini_core_hello_world && +./mini_core_hello_world && -$RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/libcore/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) -cat target/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" -rm *.rlib target/log.txt +$RUSTC src/libcore/lib.rs --color=always --crate-type lib -Cincremental=incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) +cat log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" diff --git a/src/base.rs b/src/base.rs index 3944d474d26a3..0559484e1b62d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -101,7 +101,7 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 9. Define function // TODO: cranelift doesn't yet support some of the things needed - if should_codegen(tcx) { + if should_codegen(tcx.sess) { context.func = func; module.define_function(func_id, context).unwrap(); context.clear(); @@ -182,7 +182,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } => { fx.bcx.ins().trap(TrapCode::User(0)); // TODO: prevent panics on large and negative disciminants - if should_codegen(fx.tcx) { + if should_codegen(fx.tcx.sess) { let discr = trans_operand(fx, discr).load_value(fx); let mut jt_data = JumpTableData::new(); for (i, value) in values.iter().enumerate() { diff --git a/src/lib.rs b/src/lib.rs index b2f87a2171d67..2dc70215679b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,7 @@ use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::{build_link_meta, out_filename}; use rustc_data_structures::owning_ref::{self, OwningRef}; +use rustc_data_structures::svh::Svh; use syntax::symbol::Symbol; use cranelift::codegen::settings; @@ -99,9 +100,9 @@ mod prelude { pub use crate::{CodegenCx, ModuleTup}; - pub fn should_codegen(tcx: TyCtxt) -> bool { + pub fn should_codegen(sess: &Session) -> bool { ::std::env::var("SHOULD_CODEGEN").is_ok() - || tcx.sess.crate_types.get().contains(&CrateType::Executable) + || sess.crate_types.get().contains(&CrateType::Executable) } } @@ -120,6 +121,7 @@ pub struct CodegenCx<'a, 'tcx: 'a> { pub struct ModuleTup { jit: Option, + #[allow(dead_code)] faerie: Option, } @@ -135,7 +137,7 @@ impl MetadataLoader for CraneliftMetadataLoader { // Iterate over all entries in the archive: while let Some(entry_result) = archive.next_entry() { let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; - if entry.header().identifier() == b".rustc.clif_metadata" { + if entry.header().identifier().starts_with(b".rustc.clif_metadata") { let mut buf = Vec::new(); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); @@ -182,6 +184,7 @@ struct OngoingCodegen { product: cranelift_faerie::FaerieProduct, metadata: Vec, crate_name: Symbol, + crate_hash: Svh, } impl CodegenBackend for CraneliftCodegenBackend { @@ -190,8 +193,8 @@ impl CodegenBackend for CraneliftCodegenBackend { match *cty { CrateType::Rlib | CrateType::Dylib | CrateType::Executable => {} _ => { - sess.parse_sess.span_diagnostic.warn(&format!( - "LLVM unsupported, so output type {} is not supported", + sess.err(&format!( + "Rustc codegen cranelift doesn't support output type {}", cty )); } @@ -255,6 +258,14 @@ impl CodegenBackend for CraneliftCodegenBackend { _ => {} } } + + if !tcx.sess.crate_types.get().contains(&CrateType::Executable) + && std::env::var("SHOULD_RUN").is_ok() + { + tcx.sess + .err("Can't JIT run non executable (SHOULD_RUN env var is set)"); + } + tcx.sess.abort_if_errors(); let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); @@ -287,7 +298,7 @@ impl CodegenBackend for CraneliftCodegenBackend { context: Context::new(), }; - let mut log = ::std::fs::File::create("target/log.txt").unwrap(); + let mut log = ::std::fs::File::create("log.txt").unwrap(); let before = ::std::time::Instant::now(); let mono_items = @@ -338,7 +349,8 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Compiled everything"); // TODO: this doesn't work most of the time - if tcx.sess.crate_types.get().contains(&CrateType::Executable) { + if std::env::var("SHOULD_RUN").is_ok() { + tcx.sess.warn("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); let start_wrapper = tcx.lang_items().start_fn().expect("no start lang item"); let (name, sig) = @@ -361,7 +373,8 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn(&format!("main returned {}", res)); jit_module.finish(); - } else if should_codegen(tcx) { + ::std::process::exit(0); + } else if should_codegen(tcx.sess) { jit_module.finalize_all(); faerie_module.finalize_all(); @@ -372,6 +385,7 @@ impl CodegenBackend for CraneliftCodegenBackend { product: faerie_module.finish(), metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), + crate_hash: tcx.crate_hash(LOCAL_CRATE), }) } @@ -389,9 +403,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut artifact = ongoing_codegen.product.artifact; let metadata = ongoing_codegen.metadata; + let metadata_name = ".rustc.clif_metadata".to_string() + &ongoing_codegen.crate_hash.to_string(); artifact .declare_with( - ".rustc.clif_metadata", + &metadata_name, faerie::artifact::Decl::Data { global: true, writeable: false, @@ -401,10 +416,8 @@ impl CodegenBackend for CraneliftCodegenBackend { for &crate_type in sess.opts.crate_types.iter() { match crate_type { - CrateType::Executable => { - sess.warn("Rustc codegen cranelift doesn't produce executables, but is a JIT for them"); - }, - CrateType::Rlib /* | CrateType::Dylib */ => { + // TODO: link executable + CrateType::Executable | CrateType::Rlib => { let output_name = out_filename( sess, crate_type, @@ -415,10 +428,17 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut builder = ar::Builder::new(file); builder .append( - &ar::Header::new(b".rustc.clif_metadata".to_vec(), metadata.len() as u64), + &ar::Header::new(metadata_name.as_bytes().to_vec(), metadata.len() as u64), ::std::io::Cursor::new(metadata.clone()), ).unwrap(); - //artifact.write(file).unwrap(); + if should_codegen(sess) { + let obj = artifact.emit().unwrap(); + builder + .append( + &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), + ::std::io::Cursor::new(obj), + ).unwrap(); + } } _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), } From 5ea8bae114ca825564aa3094e2f2419c72bddc6c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 11:34:35 +0200 Subject: [PATCH 0158/1566] Rustup to rustc 1.30.0-nightly (67390c0c3 2018-08-14) --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2dc70215679b2..450b6d5e0d30b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,7 +44,7 @@ struct NonFatal(pub String); macro_rules! unimpl { ($($tt:tt)*) => { - panic!(::NonFatal(format!($($tt)*))); + panic!(crate::NonFatal(format!($($tt)*))); }; } @@ -268,7 +268,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.abort_if_errors(); - let link_meta = ::build_link_meta(tcx.crate_hash(LOCAL_CRATE)); + let link_meta = build_link_meta(tcx.crate_hash(LOCAL_CRATE)); let metadata = tcx.encode_metadata(&link_meta); let mut flags_builder = settings::builder(); From b752c88fefef97c7993462e69cf4f9dff9e4bdd1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 12:07:08 +0200 Subject: [PATCH 0159/1566] Put metadata loader in its own file --- src/lib.rs | 58 ++----------------------------------------------- src/metadata.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 56 deletions(-) create mode 100644 src/metadata.rs diff --git a/src/lib.rs b/src/lib.rs index 450b6d5e0d30b..9b08d4a8a3ca2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,6 @@ extern crate target_lexicon; use std::any::Any; use std::fs::File; -use std::path::Path; use std::sync::{mpsc, Arc}; use rustc::dep_graph::DepGraph; @@ -33,7 +32,6 @@ use rustc::session::{config::OutputFilenames, CompileIncomplete}; use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::{build_link_meta, out_filename}; -use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::svh::Svh; use syntax::symbol::Symbol; @@ -63,6 +61,7 @@ mod base; mod common; mod constant; mod pretty_clif; +mod metadata; mod prelude { pub use std::any::Any; @@ -125,59 +124,6 @@ pub struct ModuleTup { faerie: Option, } -struct CraneliftMetadataLoader; - -impl MetadataLoader for CraneliftMetadataLoader { - fn get_rlib_metadata( - &self, - _target: &rustc_target::spec::Target, - path: &Path, - ) -> Result, String> { - let mut archive = ar::Archive::new(File::open(path).map_err(|e| format!("{:?}", e))?); - // Iterate over all entries in the archive: - while let Some(entry_result) = archive.next_entry() { - let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; - if entry.header().identifier().starts_with(b".rustc.clif_metadata") { - let mut buf = Vec::new(); - ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; - let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); - return Ok(rustc_erase_owner!(buf.map_owner_box())); - } - } - - Err("couldn't find metadata entry".to_string()) - //self.get_dylib_metadata(target, path) - } - - fn get_dylib_metadata( - &self, - _target: &rustc_target::spec::Target, - _path: &Path, - ) -> Result, String> { - //use goblin::Object; - - //let buffer = ::std::fs::read(path).map_err(|e|format!("{:?}", e))?; - /*match Object::parse(&buffer).map_err(|e|format!("{:?}", e))? { - Object::Elf(elf) => { - println!("elf: {:#?}", &elf); - }, - Object::PE(pe) => { - println!("pe: {:#?}", &pe); - }, - Object::Mach(mach) => { - println!("mach: {:#?}", &mach); - }, - Object::Archive(archive) => { - return Err(format!("archive: {:#?}", &archive)); - }, - Object::Unknown(magic) => { - return Err(format!("unknown magic: {:#x}", magic)) - } - }*/ - Err("dylib metadata loading is not yet supported".to_string()) - } -} - struct CraneliftCodegenBackend; struct OngoingCodegen { @@ -203,7 +149,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn metadata_loader(&self) -> Box { - Box::new(CraneliftMetadataLoader) + Box::new(crate::metadata::CraneliftMetadataLoader) } fn provide(&self, providers: &mut Providers) { diff --git a/src/metadata.rs b/src/metadata.rs new file mode 100644 index 0000000000000..384f59f171a90 --- /dev/null +++ b/src/metadata.rs @@ -0,0 +1,57 @@ +use std::path::Path; +use std::fs::File; +use rustc_data_structures::owning_ref::{self, OwningRef}; +use rustc::middle::cstore::MetadataLoader; + +pub struct CraneliftMetadataLoader; + +impl MetadataLoader for CraneliftMetadataLoader { + fn get_rlib_metadata( + &self, + _target: &::rustc_target::spec::Target, + path: &Path, + ) -> Result, String> { + let mut archive = ar::Archive::new(File::open(path).map_err(|e| format!("{:?}", e))?); + // Iterate over all entries in the archive: + while let Some(entry_result) = archive.next_entry() { + let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; + if entry.header().identifier().starts_with(b".rustc.clif_metadata") { + let mut buf = Vec::new(); + ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; + let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + return Ok(rustc_erase_owner!(buf.map_owner_box())); + } + } + + Err("couldn't find metadata entry".to_string()) + //self.get_dylib_metadata(target, path) + } + + fn get_dylib_metadata( + &self, + _target: &::rustc_target::spec::Target, + _path: &Path, + ) -> Result, String> { + //use goblin::Object; + + //let buffer = ::std::fs::read(path).map_err(|e|format!("{:?}", e))?; + /*match Object::parse(&buffer).map_err(|e|format!("{:?}", e))? { + Object::Elf(elf) => { + println!("elf: {:#?}", &elf); + }, + Object::PE(pe) => { + println!("pe: {:#?}", &pe); + }, + Object::Mach(mach) => { + println!("mach: {:#?}", &mach); + }, + Object::Archive(archive) => { + return Err(format!("archive: {:#?}", &archive)); + }, + Object::Unknown(magic) => { + return Err(format!("unknown magic: {:#x}", magic)) + } + }*/ + Err("dylib metadata loading is not yet supported".to_string()) + } +} From e6fb51540673819a956d5ac514506832da5bc153 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 12:36:13 +0200 Subject: [PATCH 0160/1566] Craneliftup --- Cargo.lock | 124 +++++++++++++++++++++++++------------------------- src/abi.rs | 19 ++++---- src/base.rs | 4 +- src/common.rs | 21 +++------ src/lib.rs | 1 - 5 files changed, 78 insertions(+), 91 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c41191ceb21eb..e0a57834216d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,7 @@ name = "backtrace" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -46,7 +46,7 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -89,29 +89,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-bforest 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -120,21 +120,21 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" [[package]] name = "cranelift-entity" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" [[package]] name = "cranelift-faerie" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -143,41 +143,41 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-module" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.18.1" -source = "git+https://github.com/CraneStation/cranelift.git#78b7d344d24705888c865defb755c5c0ae2b516e" +version = "0.19.0" +source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" dependencies = [ - "cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -185,11 +185,6 @@ dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "dtoa" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "env_logger" version = "0.5.12" @@ -421,10 +416,10 @@ version = "0.1.0" dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.18.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -437,6 +432,11 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ryu" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "scroll" version = "0.9.0" @@ -475,11 +475,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -543,7 +543,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -657,23 +657,22 @@ dependencies = [ "checksum ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "095515608290b62ac2427084f9ac3cfeb5dc76067f7d94564db9db1c46cc0a85" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" -"checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" +"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" "checksum byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8389c509ec62b9fe8eca58c502a0acaf017737355615243496cde4994f8fa4f9" "checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum cranelift 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.18.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" +"checksum cranelift 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "f4d7e69c283751083d53d01eac767407343b8b69c4bd70058e08adc2637cb257" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" @@ -702,12 +701,13 @@ dependencies = [ "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum ryu 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "16aa12da69951804cddf5f74d96abcc414a31b064e610dc81e37c1536082f491" "checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" "checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfad05c8854584e5f72fb859385ecdfa03af69c3fd0572f0da2d4c95f060bdb" -"checksum serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" +"checksum serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" diff --git a/src/abi.rs b/src/abi.rs index 84abc5eced8e1..9c8d1a13a2e1a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -317,10 +317,9 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( ); } PassMode::ByVal(ret_ty) => { - let var = Variable(RETURN_PLACE); - fx.bcx.declare_var(var, ret_ty); + fx.bcx.declare_var(mir_var(RETURN_PLACE), ret_ty); fx.local_map - .insert(RETURN_PLACE, CPlace::Var(var, ret_layout)); + .insert(RETURN_PLACE, CPlace::Var(RETURN_PLACE, ret_layout)); } PassMode::ByRef => { fx.local_map @@ -337,17 +336,16 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( .unwrap() .contains(crate::analyze::Flags::NOT_SSA) { - let var = Variable(local); - fx.bcx.declare_var(var, fx.cton_type(ty).unwrap()); + fx.bcx.declare_var(mir_var(local), fx.cton_type(ty).unwrap()); match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) { PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => fx.bcx.def_var(var, ebb_param), + PassMode::ByVal(_) => fx.bcx.def_var(mir_var(local), ebb_param), PassMode::ByRef => { let val = CValue::ByRef(ebb_param, fx.layout_of(ty)).load_value(fx); - fx.bcx.def_var(var, val); + fx.bcx.def_var(mir_var(local), val); } } - fx.local_map.insert(local, CPlace::Var(var, layout)); + fx.local_map.insert(local, CPlace::Var(local, layout)); continue; } } @@ -403,9 +401,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( }); CPlace::from_stack_slot(fx, stack_slot, ty) } else { - let var = Variable(local); - fx.bcx.declare_var(var, fx.cton_type(ty).unwrap()); - CPlace::Var(var, layout) + fx.bcx.declare_var(mir_var(local), fx.cton_type(ty).unwrap()); + CPlace::Var(local, layout) }; fx.local_map.insert(local, place); diff --git a/src/base.rs b/src/base.rs index 0559484e1b62d..6811d4a08f31e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -60,7 +60,7 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 3. Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut func, &mut func_ctx); + let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut func, &mut func_ctx); // Step 4. Predefine ebb's let start_ebb = bcx.create_ebb(); @@ -120,7 +120,7 @@ fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Fu &func, None, Some(Box::new(writer)), - &err, + err, ); tcx.sess .fatal(&format!("cretonne verify error:\n{}", pretty_error)); diff --git a/src/common.rs b/src/common.rs index 7ed91a30d2f75..02cfc1b2e743a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -6,17 +6,8 @@ use cranelift_module::Module; use crate::prelude::*; -#[derive(Debug, Copy, Clone, Eq, PartialEq)] -pub struct Variable(pub Local); - -impl EntityRef for Variable { - fn new(u: usize) -> Self { - Variable(Local::new(u)) - } - - fn index(self) -> usize { - self.0.index() - } +pub fn mir_var(loc: Local) -> Variable { + Variable::with_u32(loc.index() as u32) } pub fn cton_type_from_ty<'a, 'tcx: 'a>( @@ -178,7 +169,7 @@ impl<'tcx> CValue<'tcx> { /// A place where you can write a value to or read a value from #[derive(Debug, Copy, Clone)] pub enum CPlace<'tcx> { - Var(Variable, TyLayout<'tcx>), + Var(Local, TyLayout<'tcx>), Addr(Value, TyLayout<'tcx>), } @@ -210,7 +201,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { match self { - CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(var), layout), + CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(mir_var(var)), layout), CPlace::Addr(addr, layout) => CValue::ByRef(addr, layout), } } @@ -251,7 +242,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match self { CPlace::Var(var, _) => { let data = from.load_value(fx); - fx.bcx.def_var(var, data) + fx.bcx.def_var(mir_var(var), data) } CPlace::Addr(addr, layout) => { let size = layout.size.bytes() as i32; @@ -365,7 +356,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub instance: Instance<'tcx>, pub mir: &'tcx Mir<'tcx>, pub param_substs: &'tcx Substs<'tcx>, - pub bcx: FunctionBuilder<'a, Variable>, + pub bcx: FunctionBuilder<'a>, pub ebb_map: HashMap, pub local_map: HashMap>, pub comments: HashMap, diff --git a/src/lib.rs b/src/lib.rs index 9b08d4a8a3ca2..22089a1241fff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,6 @@ mod prelude { pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; - pub use crate::common::Variable; pub use crate::common::*; pub use crate::{CodegenCx, ModuleTup}; From bd7031afb1ba7c89e21b2889056fee76edd21b16 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 14:36:45 +0200 Subject: [PATCH 0161/1566] Fix codegen of SwitchInt --- src/base.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 6811d4a08f31e..adb032a3520ec 100644 --- a/src/base.rs +++ b/src/base.rs @@ -89,6 +89,8 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 6. Codegen function crate::abi::codegen_fn_prelude(&mut fx, start_ebb); codegen_fn_content(&mut fx); + fx.bcx.seal_all_blocks(); + fx.bcx.finalize(); // Step 7. Print function to terminal for debugging let mut writer = crate::pretty_clif::CommentWriter(fx.comments); @@ -180,7 +182,6 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) values, targets, } => { - fx.bcx.ins().trap(TrapCode::User(0)); // TODO: prevent panics on large and negative disciminants if should_codegen(fx.tcx.sess) { let discr = trans_operand(fx, discr).load_value(fx); @@ -193,6 +194,8 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) fx.bcx.ins().br_table(discr, jump_table); let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); fx.bcx.ins().jump(otherwise_ebb, &[]); + } else { + fx.bcx.ins().trap(TrapCode::User(0)); } } TerminatorKind::Call { From 7f2a887c838754c0fa392c690ff8321d5dfeb0bb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 14:45:32 +0200 Subject: [PATCH 0162/1566] Use either SimpleJIT or faerie, but not both --- src/abi.rs | 6 ++++-- src/lib.rs | 48 ++++++++++++++++++++++++++++++------------------ src/metadata.rs | 12 ++++++++---- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 9c8d1a13a2e1a..55fcc277a9a2e 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -336,7 +336,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( .unwrap() .contains(crate::analyze::Flags::NOT_SSA) { - fx.bcx.declare_var(mir_var(local), fx.cton_type(ty).unwrap()); + fx.bcx + .declare_var(mir_var(local), fx.cton_type(ty).unwrap()); match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(_) => fx.bcx.def_var(mir_var(local), ebb_param), @@ -401,7 +402,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( }); CPlace::from_stack_slot(fx, stack_slot, ty) } else { - fx.bcx.declare_var(mir_var(local), fx.cton_type(ty).unwrap()); + fx.bcx + .declare_var(mir_var(local), fx.cton_type(ty).unwrap()); CPlace::Var(local, layout) }; diff --git a/src/lib.rs b/src/lib.rs index 22089a1241fff..1cf5abd873d9a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,8 +60,8 @@ mod analyze; mod base; mod common; mod constant; -mod pretty_clif; mod metadata; +mod pretty_clif; mod prelude { pub use std::any::Any; @@ -222,22 +222,31 @@ impl CodegenBackend for CraneliftCodegenBackend { let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()) .unwrap() .finish(flags); - let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); - let mut faerie_module: Module = Module::new( - FaerieBuilder::new( - isa, - "some_file.o".to_string(), - FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names(), - ).unwrap(), - ); + let (mut jit_module, mut faerie_module): ( + Option>, + Option>, + ) = if std::env::var("SHOULD_RUN").is_ok() { + (Some(Module::new(SimpleJITBuilder::new())), None) + } else { + ( + None, + Some(Module::new( + FaerieBuilder::new( + isa, + "some_file.o".to_string(), + FaerieTrapCollection::Disabled, + FaerieBuilder::default_libcall_names(), + ).unwrap(), + )), + ) + }; let defined_functions = { use std::io::Write; let mut cx = CodegenCx { tcx, - jit: Some((ConstantCx::default(), &mut jit_module)), - faerie: Some((ConstantCx::default(), &mut faerie_module)), + jit: jit_module.as_mut().map(|m| (ConstantCx::default(), m)), + faerie: faerie_module.as_mut().map(|m| (ConstantCx::default(), m)), defined_functions: Vec::new(), context: Context::new(), @@ -294,7 +303,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Compiled everything"); // TODO: this doesn't work most of the time - if std::env::var("SHOULD_RUN").is_ok() { + if let Some(mut jit_module) = jit_module { tcx.sess.warn("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); let start_wrapper = tcx.lang_items().start_fn().expect("no start lang item"); @@ -320,14 +329,13 @@ impl CodegenBackend for CraneliftCodegenBackend { jit_module.finish(); ::std::process::exit(0); } else if should_codegen(tcx.sess) { - jit_module.finalize_all(); - faerie_module.finalize_all(); + faerie_module.as_mut().map(|m| m.finalize_all()); tcx.sess.warn("Finalized everything"); } Box::new(OngoingCodegen { - product: faerie_module.finish(), + product: faerie_module.unwrap().finish(), metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), crate_hash: tcx.crate_hash(LOCAL_CRATE), @@ -348,7 +356,8 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut artifact = ongoing_codegen.product.artifact; let metadata = ongoing_codegen.metadata; - let metadata_name = ".rustc.clif_metadata".to_string() + &ongoing_codegen.crate_hash.to_string(); + let metadata_name = + ".rustc.clif_metadata".to_string() + &ongoing_codegen.crate_hash.to_string(); artifact .declare_with( &metadata_name, @@ -373,7 +382,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut builder = ar::Builder::new(file); builder .append( - &ar::Header::new(metadata_name.as_bytes().to_vec(), metadata.len() as u64), + &ar::Header::new( + metadata_name.as_bytes().to_vec(), + metadata.len() as u64, + ), ::std::io::Cursor::new(metadata.clone()), ).unwrap(); if should_codegen(sess) { diff --git a/src/metadata.rs b/src/metadata.rs index 384f59f171a90..29bb1c8e32571 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,7 +1,7 @@ -use std::path::Path; -use std::fs::File; -use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc::middle::cstore::MetadataLoader; +use rustc_data_structures::owning_ref::{self, OwningRef}; +use std::fs::File; +use std::path::Path; pub struct CraneliftMetadataLoader; @@ -15,7 +15,11 @@ impl MetadataLoader for CraneliftMetadataLoader { // Iterate over all entries in the archive: while let Some(entry_result) = archive.next_entry() { let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; - if entry.header().identifier().starts_with(b".rustc.clif_metadata") { + if entry + .header() + .identifier() + .starts_with(b".rustc.clif_metadata") + { let mut buf = Vec::new(); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); From 7f2a8f8a66f74f51de36f914cbfe4c14b4a1566d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 14:49:36 +0200 Subject: [PATCH 0163/1566] Disable some example which don't compile yet --- build.sh | 2 +- examples/example.rs | 14 ++++++++------ src/lib.rs | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/build.sh b/build.sh index 69730353d68f8..863d80ed3c58e 100755 --- a/build.sh +++ b/build.sh @@ -30,7 +30,7 @@ $RUSTC ../../examples/example.rs --crate-type lib && SHOULD_RUN=1 $RUSTC ../../examples/mini_core_hello_world.rs --crate-type bin && $RUSTC ../../examples/mini_core_hello_world.rs --crate-type bin && -extract_data mini_core_hello_world mini_core_hello_world.o +extract_data mini_core_hello_world mini_core_hello_world.o && gcc mini_core.o mini_core_hello_world.o -o mini_core_hello_world && ./mini_core_hello_world && diff --git a/examples/example.rs b/examples/example.rs index 7afbb0b0b650c..6d84fb148c0fa 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -33,12 +33,14 @@ enum BoolOption { None, } +/* fn option_unwrap_or(o: BoolOption, d: bool) -> bool { match o { BoolOption::Some(b) => b, BoolOption::None => d, } } +*/ fn ret_42() -> u8 { 42 @@ -60,12 +62,12 @@ fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { a == b } -fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { +/*fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { ( a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, b as u32, ) -} +}*/ fn char_cast(c: char) -> u8 { c as u8 @@ -151,9 +153,9 @@ fn repeat_array() -> [u8; 3] { [0; 3] } -unsafe fn use_ctlz_nonzero(a: u16) -> u16 { +/*unsafe fn use_ctlz_nonzero(a: u16) -> u16 { intrinsics::ctlz_nonzero(a) -} +}*/ fn ptr_as_usize(ptr: *const u8) -> usize { ptr as usize @@ -163,9 +165,9 @@ fn float_cast(a: f32, b: f64) -> (f64, f32) { (a as f64, b as f32) } -fn int_to_float(a: u8, b: i32) -> (f64, f32) { +/*fn int_to_float(a: u8, b: i32) -> (f64, f32) { (a as f64, b as f32) -} +}*/ fn make_array() -> [u8; 3] { [42, 0, 5] diff --git a/src/lib.rs b/src/lib.rs index 1cf5abd873d9a..a0e59c0a0c49d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -99,6 +99,7 @@ mod prelude { pub use crate::{CodegenCx, ModuleTup}; pub fn should_codegen(sess: &Session) -> bool { + //return true; ::std::env::var("SHOULD_CODEGEN").is_ok() || sess.crate_types.get().contains(&CrateType::Executable) } From 7d3f2ba49f0166f0a5ccfd1c7a3c439c79fe3686 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 15:23:28 +0200 Subject: [PATCH 0164/1566] Change build.sh --- build.sh | 23 +++++++++++++---------- src/lib.rs | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 863d80ed3c58e..20f88163283a5 100755 --- a/build.sh +++ b/build.sh @@ -13,27 +13,30 @@ else fi extract_data() { + pushd target/out/ ar x $1 data.o && chmod +rw data.o && mv data.o $2 + popd } -RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=." +RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=target/out --out-dir target/out" -pushd target/libcore +rm -r target/out -SHOULD_CODEGEN=1 $RUSTC ../../examples/mini_core.rs --crate-name mini_core --crate-type lib && +SHOULD_CODEGEN=1 $RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib && extract_data libmini_core.rlib mini_core.o && -$RUSTC ../../examples/example.rs --crate-type lib && +$RUSTC examples/example.rs --crate-type lib && -SHOULD_RUN=1 $RUSTC ../../examples/mini_core_hello_world.rs --crate-type bin && +SHOULD_RUN=1 $RUSTC examples/mini_core_hello_world.rs --crate-type bin && -$RUSTC ../../examples/mini_core_hello_world.rs --crate-type bin && +$RUSTC examples/mini_core_hello_world.rs --crate-type bin && extract_data mini_core_hello_world mini_core_hello_world.o && -gcc mini_core.o mini_core_hello_world.o -o mini_core_hello_world && -./mini_core_hello_world && +gcc target/out/mini_core.o target/out/mini_core_hello_world.o -o target/out/mini_core_hello_world || exit 1 +./target/out/mini_core_hello_world + +$RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) +cat target/libcore/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" -$RUSTC src/libcore/lib.rs --color=always --crate-type lib -Cincremental=incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) -cat log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" diff --git a/src/lib.rs b/src/lib.rs index a0e59c0a0c49d..a5c65861688b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -253,7 +253,7 @@ impl CodegenBackend for CraneliftCodegenBackend { context: Context::new(), }; - let mut log = ::std::fs::File::create("log.txt").unwrap(); + let mut log = ::std::fs::File::create("target/out/log.txt").unwrap(); let before = ::std::time::Instant::now(); let mono_items = From a3760040b2d206607b51cf8ccfdf71da3fdd2787 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 15:28:08 +0200 Subject: [PATCH 0165/1566] Disable some prinln!'s --- src/abi.rs | 12 ------------ src/base.rs | 1 - src/constant.rs | 10 +++++----- src/metadata.rs | 20 -------------------- 4 files changed, 5 insertions(+), 38 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 55fcc277a9a2e..f230e07125cf8 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -55,12 +55,6 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( Abi::Rust => (CallConv::Fast, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { - println!( - "rust-call sig: {:?} inputs: {:?} output: {:?}", - sig, - sig.inputs(), - sig.output() - ); assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().sty { ty::TyTuple(ref tupled_arguments) => tupled_arguments, @@ -439,11 +433,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( } _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), } - println!( - "{:?} {:?}", - pack_arg.layout().ty, - args.iter().map(|a| a.layout().ty).collect::>() - ); args } else { args.into_iter() @@ -462,7 +451,6 @@ pub fn codegen_call<'a, 'tcx: 'a>( let ret_layout = fx.layout_of(sig.output()); let output_pass_mode = get_pass_mode(fx.tcx, sig.abi, sig.output(), true); - println!("{:?}", output_pass_mode); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match destination { diff --git a/src/base.rs b/src/base.rs index adb032a3520ec..48a59a154b6e0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -771,7 +771,6 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( out_place .place_field(fx, mir::Field::new(0)) .write_cvalue(fx, res); - println!("abc"); out_place .place_field(fx, mir::Field::new(1)) .write_cvalue(fx, has_overflow); diff --git a/src/constant.rs b/src/constant.rs index d745386e758b9..c2542f8bc1beb 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -23,9 +23,9 @@ impl ConstantCx { tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, ) { - println!("todo {:?}", self.todo); + //println!("todo {:?}", self.todo); define_all_allocs(tcx, module, &mut self); - println!("done {:?}", self.done); + //println!("done {:?}", self.done); for data_id in self.done.drain() { module.finalize_data(data_id); } @@ -159,13 +159,13 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( while let Some(todo_item) = pop_set(&mut cx.todo) { let (data_id, alloc) = match todo_item { TodoItem::Alloc(alloc_id) => { - println!("alloc_id {}", alloc_id); + //println!("alloc_id {}", alloc_id); let data_id = data_id_for_alloc_id(module, alloc_id); let alloc = memory.get(alloc_id).unwrap(); (data_id, alloc) } TodoItem::Static(def_id) => { - println!("static {:?}", def_id); + //println!("static {:?}", def_id); let instance = ty::Instance::mono(tcx, def_id); let cid = GlobalId { instance, @@ -183,7 +183,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( } }; - println!("data_id {}", data_id); + //("data_id {}", data_id); if cx.done.contains(&data_id) { continue; } diff --git a/src/metadata.rs b/src/metadata.rs index 29bb1c8e32571..2653300c7b248 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -36,26 +36,6 @@ impl MetadataLoader for CraneliftMetadataLoader { _target: &::rustc_target::spec::Target, _path: &Path, ) -> Result, String> { - //use goblin::Object; - - //let buffer = ::std::fs::read(path).map_err(|e|format!("{:?}", e))?; - /*match Object::parse(&buffer).map_err(|e|format!("{:?}", e))? { - Object::Elf(elf) => { - println!("elf: {:#?}", &elf); - }, - Object::PE(pe) => { - println!("pe: {:#?}", &pe); - }, - Object::Mach(mach) => { - println!("mach: {:#?}", &mach); - }, - Object::Archive(archive) => { - return Err(format!("archive: {:#?}", &archive)); - }, - Object::Unknown(magic) => { - return Err(format!("unknown magic: {:#x}", magic)) - } - }*/ Err("dylib metadata loading is not yet supported".to_string()) } } From ca59e4405e81b2ce7ba6667117241496c2c4be9a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 16:17:59 +0200 Subject: [PATCH 0166/1566] Reduce verbosity of output --- build.sh | 3 ++- src/abi.rs | 4 +++- src/base.rs | 24 +++++++++++++++++------- src/common.rs | 3 +++ src/pretty_clif.rs | 4 ++++ 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 20f88163283a5..82e613ff1c6ca 100755 --- a/build.sh +++ b/build.sh @@ -23,6 +23,8 @@ extract_data() { RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=target/out --out-dir target/out" rm -r target/out +mkdir -p target/out/mir +mkdir -p target/out/clif SHOULD_CODEGEN=1 $RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib && extract_data libmini_core.rlib mini_core.o && @@ -39,4 +41,3 @@ gcc target/out/mini_core.o target/out/mini_core_hello_world.o -o target/out/mini $RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) cat target/libcore/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" - diff --git a/src/abi.rs b/src/abi.rs index f230e07125cf8..7e19a4fba4f3d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -242,7 +242,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( start_ebb: Ebb, ) { let ssa_analyzed = crate::analyze::analyze(fx); - fx.tcx.sess.warn(&format!("ssa {:?}", ssa_analyzed)); match fx.self_sig().abi { Abi::Rust | Abi::RustCall => {} @@ -301,6 +300,9 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.bcx.switch_to_block(start_ebb); + fx.top_nop = Some(fx.bcx.ins().nop()); + fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); + match output_pass_mode { PassMode::NoPass => { let null = fx.bcx.ins().iconst(types::I64, 0); diff --git a/src/base.rs b/src/base.rs index 48a59a154b6e0..c3034164de05b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,5 +1,14 @@ use crate::prelude::*; +struct PrintOnPanic(String); +impl Drop for PrintOnPanic { + fn drop(&mut self) { + if ::std::thread::panicking() { + println!("{}", self.0); + } + } +} + pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: MonoItem<'tcx>) { let tcx = cx.tcx; let context = &mut cx.context; @@ -12,11 +21,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: Mo } => { let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); - tcx.sess.warn(&format!( - "{:?}:\n\n{}", - inst, - String::from_utf8_lossy(&mir.into_inner()) - )); + let mir_file_name = "target/out/mir/".to_string() + &format!("{:?}", def_id).replace('/', "@"); + ::std::fs::write(mir_file_name, mir.into_inner()).unwrap(); + let _print_guard = PrintOnPanic(format!("{:?}", inst)); let res = each_module!(cx, |(ccx, m)| trans_fn(tcx, *m, ccx, context, inst)); if let Some(func_id) = res.jit { @@ -84,6 +91,8 @@ fn trans_fn<'a, 'tcx: 'a>( local_map: HashMap::new(), comments: HashMap::new(), constants, + + top_nop: None, }; // Step 6. Codegen function @@ -96,7 +105,8 @@ fn trans_fn<'a, 'tcx: 'a>( let mut writer = crate::pretty_clif::CommentWriter(fx.comments); let mut cton = String::new(); ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None).unwrap(); - tcx.sess.warn(&cton); + let clif_file_name = "target/out/clif/".to_string() + &tcx.symbol_name(instance).as_str(); + ::std::fs::write(clif_file_name, cton.as_bytes()).unwrap(); // Step 8. Verify function verify_func(tcx, writer, &func); @@ -235,7 +245,7 @@ fn trans_stmt<'a, 'tcx: 'a>( cur_ebb: Ebb, stmt: &Statement<'tcx>, ) { - fx.tcx.sess.warn(&format!("stmt {:?}", stmt)); + let _print_guard = PrintOnPanic(format!("stmt {:?}", stmt)); let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); fx.add_comment(inst, format!("{:?}", stmt)); diff --git a/src/common.rs b/src/common.rs index 02cfc1b2e743a..d18b6bf43b2d1 100644 --- a/src/common.rs +++ b/src/common.rs @@ -361,6 +361,9 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub local_map: HashMap>, pub comments: HashMap, pub constants: &'a mut crate::constant::ConstantCx, + + /// add_global_comment inserts a comment here + pub top_nop: Option, } impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index d872a70b0fe5d..c6cc521f90d16 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -35,6 +35,10 @@ impl FuncWriter for CommentWriter { } impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { + pub fn add_global_comment<'s, S: Into>>(&mut self, comment: S) { + self.add_comment(self.top_nop.expect("fx.top_nop not yet set"), comment) + } + pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { use std::collections::hash_map::Entry; match self.comments.entry(inst) { From 65fa8eddbb2b39d159208e36095ce0dba0e944a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Aug 2018 16:33:19 +0200 Subject: [PATCH 0167/1566] Fix trait method calls --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index c2542f8bc1beb..cfb6c3e336fb2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -106,7 +106,7 @@ fn trans_const_value<'a, 'tcx: 'a>( CValue::const_val(fx, ty, bits as i128 as i64) } TypeVariants::TyFnDef(def_id, substs) => { - let func_ref = fx.get_function_ref(Instance::new(def_id, substs)); + let func_ref = fx.get_function_ref(Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap()); CValue::Func(func_ref, layout) } _ => trans_const_place(fx, const_).to_cvalue(fx), From eb89830f2132e6cdccf425867f2161d20b64a32e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 16 Aug 2018 20:09:26 +0200 Subject: [PATCH 0168/1566] Rustfmt --- src/base.rs | 3 ++- src/constant.rs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index c3034164de05b..e4d12139b1098 100644 --- a/src/base.rs +++ b/src/base.rs @@ -21,7 +21,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: Mo } => { let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); - let mir_file_name = "target/out/mir/".to_string() + &format!("{:?}", def_id).replace('/', "@"); + let mir_file_name = + "target/out/mir/".to_string() + &format!("{:?}", def_id).replace('/', "@"); ::std::fs::write(mir_file_name, mir.into_inner()).unwrap(); let _print_guard = PrintOnPanic(format!("{:?}", inst)); diff --git a/src/constant.rs b/src/constant.rs index cfb6c3e336fb2..e354319965d7f 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -106,7 +106,9 @@ fn trans_const_value<'a, 'tcx: 'a>( CValue::const_val(fx, ty, bits as i128 as i64) } TypeVariants::TyFnDef(def_id, substs) => { - let func_ref = fx.get_function_ref(Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap()); + let func_ref = fx.get_function_ref( + Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + ); CValue::Func(func_ref, layout) } _ => trans_const_place(fx, const_).to_cvalue(fx), From f27dfc3ac9d874685f7cff8f9f1d54f6a2df5b88 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Aug 2018 12:57:41 +0200 Subject: [PATCH 0169/1566] Make CodegenCx generic over Backend --- src/base.rs | 15 ++--- src/lib.rs | 186 ++++++++++++++++++++++------------------------------ 2 files changed, 83 insertions(+), 118 deletions(-) diff --git a/src/base.rs b/src/base.rs index e4d12139b1098..08c9d09b1f8eb 100644 --- a/src/base.rs +++ b/src/base.rs @@ -9,7 +9,7 @@ impl Drop for PrintOnPanic { } } -pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: MonoItem<'tcx>) { +pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, impl Backend>, mono_item: MonoItem<'tcx>) { let tcx = cx.tcx; let context = &mut cx.context; @@ -26,10 +26,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: Mo ::std::fs::write(mir_file_name, mir.into_inner()).unwrap(); let _print_guard = PrintOnPanic(format!("{:?}", inst)); - let res = each_module!(cx, |(ccx, m)| trans_fn(tcx, *m, ccx, context, inst)); - if let Some(func_id) = res.jit { - cx.defined_functions.push(func_id); - }; + trans_fn(tcx, cx.module, &mut cx.ccx, context, inst); } Instance { def: InstanceDef::DropGlue(_, _), @@ -38,9 +35,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx>, mono_item: Mo inst => unimpl!("Unimplemented instance {:?}", inst), }, MonoItem::Static(def_id) => { - each_module!(cx, |(ccx, _m)| { - crate::constant::codegen_static(ccx, def_id); - }); + crate::constant::codegen_static(&mut cx.ccx, def_id); } MonoItem::GlobalAsm(node_id) => cx .tcx @@ -55,7 +50,7 @@ fn trans_fn<'a, 'tcx: 'a>( constants: &mut crate::constant::ConstantCx, context: &mut Context, instance: Instance<'tcx>, -) -> FuncId { +) { // Step 1. Get mir let mir = tcx.optimized_mir(instance.def_id()); @@ -119,8 +114,6 @@ fn trans_fn<'a, 'tcx: 'a>( module.define_function(func_id, context).unwrap(); context.clear(); } - - func_id } fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Function) { diff --git a/src/lib.rs b/src/lib.rs index a5c65861688b3..bcf76d1657453 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -46,15 +46,6 @@ macro_rules! unimpl { }; } -macro_rules! each_module { - ($cx:expr, |$p:pat| $res:expr) => { - ModuleTup { - jit: $cx.jit.as_mut().map(|$p| $res), - faerie: $cx.faerie.as_mut().map(|$p| $res), - } - }; -} - mod abi; mod analyze; mod base; @@ -77,7 +68,7 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeVariants, }; - pub use rustc_data_structures::{fx::FxHashMap, indexed_vec::Idx, sync::Lrc}; + pub use rustc_data_structures::{fx::{FxHashSet, FxHashMap}, indexed_vec::Idx, sync::Lrc}; pub use rustc_mir::monomorphize::{collector, MonoItem}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::codemap::DUMMY_SP; @@ -108,11 +99,10 @@ mod prelude { use crate::constant::ConstantCx; use crate::prelude::*; -pub struct CodegenCx<'a, 'tcx: 'a> { +pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'static> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, - pub jit: Option<(ConstantCx, &'a mut Module)>, - pub faerie: Option<(ConstantCx, &'a mut Module)>, - pub defined_functions: Vec, + pub module: &'a mut Module, + pub ccx: ConstantCx, // Cache pub context: Context, @@ -223,88 +213,23 @@ impl CodegenBackend for CraneliftCodegenBackend { let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()) .unwrap() .finish(flags); - let (mut jit_module, mut faerie_module): ( - Option>, - Option>, - ) = if std::env::var("SHOULD_RUN").is_ok() { - (Some(Module::new(SimpleJITBuilder::new())), None) - } else { - ( - None, - Some(Module::new( - FaerieBuilder::new( - isa, - "some_file.o".to_string(), - FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names(), - ).unwrap(), - )), - ) - }; - let defined_functions = { - use std::io::Write; - let mut cx = CodegenCx { - tcx, - jit: jit_module.as_mut().map(|m| (ConstantCx::default(), m)), - faerie: faerie_module.as_mut().map(|m| (ConstantCx::default(), m)), - defined_functions: Vec::new(), - - context: Context::new(), - }; - - let mut log = ::std::fs::File::create("target/out/log.txt").unwrap(); - - let before = ::std::time::Instant::now(); - let mono_items = - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) - .0; - - // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore - save_incremental(tcx); - tcx.sess.warn("Saved incremental data"); - - for mono_item in mono_items { - let cx = &mut cx; - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(move || { - base::trans_mono_item(cx, mono_item); - })); - if let Err(err) = res { - match err.downcast::() { - Ok(non_fatal) => { - writeln!(log, "{}", &non_fatal.0); - tcx.sess.err(&non_fatal.0) - } - Err(err) => ::std::panic::resume_unwind(err), - } - } - } - - match cx { - CodegenCx { - tcx, - jit, - faerie, - defined_functions: _, - context: _, - } => { - jit.map(|jit| jit.0.finalize(tcx, jit.1)); - faerie.map(|faerie| faerie.0.finalize(tcx, faerie.1)); - } - } - - let after = ::std::time::Instant::now(); - println!("time: {:?}", after - before); + let mono_items = + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) + .0; + + // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore + save_incremental(tcx); + tcx.sess.warn("Saved incremental data"); - cx.defined_functions - }; + if std::env::var("SHOULD_RUN").is_ok() { + let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); - tcx.sess.abort_if_errors(); + codegen_mono_items(tcx, &mut jit_module, &mono_items); - tcx.sess.warn("Compiled everything"); + tcx.sess.abort_if_errors(); + tcx.sess.warn("Compiled everything"); - // TODO: this doesn't work most of the time - if let Some(mut jit_module) = jit_module { tcx.sess.warn("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); let start_wrapper = tcx.lang_items().start_fn().expect("no start lang item"); @@ -314,14 +239,10 @@ impl CodegenBackend for CraneliftCodegenBackend { .declare_function(&name, Linkage::Import, &sig) .unwrap(); - for func_id in defined_functions { - if func_id != called_func_id { - jit_module.finalize_function(func_id); - } - } + let finalized_function: *const u8 = jit_module.finalize_function(called_func_id); + jit_module.finalize_all(); tcx.sess.warn("Finalized everything"); - let finalized_function: *const u8 = jit_module.finalize_function(called_func_id); let f: extern "C" fn(*const u8, isize, *const *const u8) -> isize = unsafe { ::std::mem::transmute(finalized_function) }; let res = f(0 as *const u8, 0, 0 as *const _); @@ -329,18 +250,32 @@ impl CodegenBackend for CraneliftCodegenBackend { jit_module.finish(); ::std::process::exit(0); - } else if should_codegen(tcx.sess) { - faerie_module.as_mut().map(|m| m.finalize_all()); + } else { + let mut faerie_module: Module = Module::new( + FaerieBuilder::new( + isa, + "some_file.o".to_string(), + FaerieTrapCollection::Disabled, + FaerieBuilder::default_libcall_names(), + ).unwrap()); + + codegen_mono_items(tcx, &mut faerie_module, &mono_items); - tcx.sess.warn("Finalized everything"); - } + tcx.sess.abort_if_errors(); + tcx.sess.warn("Compiled everything"); + + if should_codegen(tcx.sess) { + faerie_module.finalize_all(); + tcx.sess.warn("Finalized everything"); + } - Box::new(OngoingCodegen { - product: faerie_module.unwrap().finish(), - metadata: metadata.raw_data, - crate_name: tcx.crate_name(LOCAL_CRATE), - crate_hash: tcx.crate_hash(LOCAL_CRATE), - }) + return Box::new(OngoingCodegen { + product: faerie_module.finish(), + metadata: metadata.raw_data, + crate_name: tcx.crate_name(LOCAL_CRATE), + crate_hash: tcx.crate_hash(LOCAL_CRATE), + }); + } } fn join_codegen_and_link( @@ -405,6 +340,43 @@ impl CodegenBackend for CraneliftCodegenBackend { } } +fn codegen_mono_items<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, mono_items: &FxHashSet>) { + use std::io::Write; + + let mut cx = CodegenCx { + tcx, + module, + ccx: ConstantCx::default(), + + context: Context::new(), + }; + + let mut log = ::std::fs::File::create("target/out/log.txt").unwrap(); + + let before = ::std::time::Instant::now(); + + for mono_item in mono_items { + let cx = &mut cx; + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(move || { + base::trans_mono_item(cx, *mono_item); + })); + if let Err(err) = res { + match err.downcast::() { + Ok(non_fatal) => { + writeln!(log, "{}", &non_fatal.0); + tcx.sess.err(&non_fatal.0) + } + Err(err) => ::std::panic::resume_unwind(err), + } + } + } + + cx.ccx.finalize(tcx, cx.module); + + let after = ::std::time::Instant::now(); + println!("time: {:?}", after - before); +} + fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { rustc_incremental::assert_dep_graph(tcx); rustc_incremental::save_dep_graph(tcx); From 7a3ba963e1fd3f986a66437bef3aba4bbf71afdf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Aug 2018 13:01:56 +0200 Subject: [PATCH 0170/1566] Rustfmt --- src/base.rs | 5 ++++- src/lib.rs | 32 ++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/base.rs b/src/base.rs index 08c9d09b1f8eb..b460547e8209f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -9,7 +9,10 @@ impl Drop for PrintOnPanic { } } -pub fn trans_mono_item<'a, 'tcx: 'a>(cx: &mut CodegenCx<'a, 'tcx, impl Backend>, mono_item: MonoItem<'tcx>) { +pub fn trans_mono_item<'a, 'tcx: 'a>( + cx: &mut CodegenCx<'a, 'tcx, impl Backend>, + mono_item: MonoItem<'tcx>, +) { let tcx = cx.tcx; let context = &mut cx.context; diff --git a/src/lib.rs b/src/lib.rs index bcf76d1657453..88a3498885f28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -68,7 +68,11 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeVariants, }; - pub use rustc_data_structures::{fx::{FxHashSet, FxHashMap}, indexed_vec::Idx, sync::Lrc}; + pub use rustc_data_structures::{ + fx::{FxHashMap, FxHashSet}, + indexed_vec::Idx, + sync::Lrc, + }; pub use rustc_mir::monomorphize::{collector, MonoItem}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::codemap::DUMMY_SP; @@ -215,9 +219,8 @@ impl CodegenBackend for CraneliftCodegenBackend { .finish(flags); let mono_items = - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) - .0; - + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0; + // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore save_incremental(tcx); tcx.sess.warn("Saved incremental data"); @@ -252,13 +255,14 @@ impl CodegenBackend for CraneliftCodegenBackend { ::std::process::exit(0); } else { let mut faerie_module: Module = Module::new( - FaerieBuilder::new( - isa, - "some_file.o".to_string(), - FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names(), - ).unwrap()); - + FaerieBuilder::new( + isa, + "some_file.o".to_string(), + FaerieTrapCollection::Disabled, + FaerieBuilder::default_libcall_names(), + ).unwrap(), + ); + codegen_mono_items(tcx, &mut faerie_module, &mono_items); tcx.sess.abort_if_errors(); @@ -340,7 +344,11 @@ impl CodegenBackend for CraneliftCodegenBackend { } } -fn codegen_mono_items<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, mono_items: &FxHashSet>) { +fn codegen_mono_items<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + mono_items: &FxHashSet>, +) { use std::io::Write; let mut cx = CodegenCx { From 871be2a4690cb9624d63cedd1095943776e6b902 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Aug 2018 13:21:03 +0200 Subject: [PATCH 0171/1566] Codegen entry wrapper (fixes #13) --- build.sh | 5 +- examples/mini_core_hello_world.rs | 32 ++++++-- src/lib.rs | 129 +++++++++++++++++++++++++++--- 3 files changed, 147 insertions(+), 19 deletions(-) diff --git a/build.sh b/build.sh index 82e613ff1c6ca..ce8359698f0d0 100755 --- a/build.sh +++ b/build.sh @@ -31,7 +31,8 @@ extract_data libmini_core.rlib mini_core.o && $RUSTC examples/example.rs --crate-type lib && -SHOULD_RUN=1 $RUSTC examples/mini_core_hello_world.rs --crate-type bin && +# SimpleJIT is broken +#SHOULD_RUN=1 $RUSTC examples/mini_core_hello_world.rs --crate-type bin && $RUSTC examples/mini_core_hello_world.rs --crate-type bin && extract_data mini_core_hello_world mini_core_hello_world.o && @@ -40,4 +41,4 @@ gcc target/out/mini_core.o target/out/mini_core_hello_world.o -o target/out/mini ./target/out/mini_core_hello_world $RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) -cat target/libcore/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" +cat target/out/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 014d7aaa40c4b..19cc727fb55ee 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -2,7 +2,6 @@ #![feature(no_core, unboxed_closures, start, lang_items)] #![no_core] -#![no_main] #![allow(dead_code)] extern crate mini_core; @@ -16,20 +15,37 @@ extern "C" { fn puts(s: *const u8); } +#[lang = "termination"] +trait Termination { + fn report(self) -> i32; +} + +impl Termination for () { + fn report(self) -> i32 { + unsafe { + NUM = 6 * 7 + 1 + (1u8 == 1u8) as u8; // 44 + *NUM_REF as i32 + } + } +} + +#[lang = "start"] +fn start( + main: fn() -> T, + _argc: isize, + _argv: *const *const u8, +) -> isize { + main().report() as isize +} + static mut NUM: u8 = 6 * 7; static NUM_REF: &'static u8 = unsafe { &NUM }; -#[lang = "start"] -fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize { +fn main() { unsafe { let (ptr, _): (*const u8, usize) = intrinsics::transmute("Hello!\0"); puts(ptr); } //panic(&("panic msg", "abc.rs", 0, 43)); - - unsafe { - NUM = 6 * 7 + 1 + (1u8 == 1u8) as u8; // 44 - *NUM_REF as isize - } } diff --git a/src/lib.rs b/src/lib.rs index 88a3498885f28..e056ada0260e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,6 +113,7 @@ pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'static> { } pub struct ModuleTup { + #[allow(dead_code)] jit: Option, #[allow(dead_code)] faerie: Option, @@ -234,21 +235,27 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Compiled everything"); tcx.sess.warn("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); - let start_wrapper = tcx.lang_items().start_fn().expect("no start lang item"); - let (name, sig) = - crate::abi::get_function_name_and_sig(tcx, Instance::mono(tcx, start_wrapper)); - let called_func_id = jit_module - .declare_function(&name, Linkage::Import, &sig) + let sig = Signature { + params: vec![ + AbiParam::new(types::I64 /*usize*/), + AbiParam::new(types::I64 /* *const _*/), + ], + returns: vec![AbiParam::new(types::I64 /*isize*/)], + call_conv: CallConv::SystemV, + argument_bytes: None, + }; + let main_func_id = jit_module + .declare_function("main", Linkage::Import, &sig) .unwrap(); - let finalized_function: *const u8 = jit_module.finalize_function(called_func_id); + let finalized_main: *const u8 = jit_module.finalize_function(main_func_id); jit_module.finalize_all(); tcx.sess.warn("Finalized everything"); - let f: extern "C" fn(*const u8, isize, *const *const u8) -> isize = - unsafe { ::std::mem::transmute(finalized_function) }; - let res = f(0 as *const u8, 0, 0 as *const _); + let f: extern "C" fn(isize, *const *const u8) -> isize = + unsafe { ::std::mem::transmute(finalized_main) }; + let res = f(0, 0 as *const _); tcx.sess.warn(&format!("main returned {}", res)); jit_module.finish(); @@ -379,6 +386,8 @@ fn codegen_mono_items<'a, 'tcx: 'a>( } } + maybe_create_entry_wrapper(&mut cx); + cx.ccx.finalize(tcx, cx.module); let after = ::std::time::Instant::now(); @@ -396,3 +405,105 @@ fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn __rustc_codegen_backend() -> Box { Box::new(CraneliftCodegenBackend) } + +/// Create the `main` function which will initialize the rust runtime and call +/// users main function. +fn maybe_create_entry_wrapper(cx: &mut CodegenCx) { + use rustc::middle::lang_items::StartFnLangItem; + use rustc::session::config::EntryFnType; + + let tcx = cx.tcx; + + let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { + Some((id, _, entry_ty)) => ( + tcx.hir.local_def_id(id), + match entry_ty { + EntryFnType::Main => true, + EntryFnType::Start => false, + }, + ), + None => return, + }; + + create_entry_fn(tcx, cx.module, main_def_id, use_start_lang_item);; + + fn create_entry_fn<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + m: &mut Module, + rust_main_def_id: DefId, + use_start_lang_item: bool, + ) { + let main_ret_ty = tcx.fn_sig(rust_main_def_id).output(); + // Given that `main()` has no arguments, + // then its return type cannot have + // late-bound regions, since late-bound + // regions must appear in the argument + // listing. + let main_ret_ty = tcx.erase_regions(&main_ret_ty.no_late_bound_regions().unwrap()); + + let cmain_sig = Signature { + params: vec![ + AbiParam::new(types::I64 /*usize*/), + AbiParam::new(types::I64 /* *const _*/), + ], + returns: vec![AbiParam::new(types::I64 /*isize*/)], + call_conv: CallConv::SystemV, + argument_bytes: None, + }; + + let cmain_func_id = m + .declare_function("main", Linkage::Export, &cmain_sig) + .unwrap(); + + let instance = Instance::mono(tcx, rust_main_def_id); + + let (main_name, main_sig) = get_function_name_and_sig(tcx, instance); + + let main_func_id = m + .declare_function(&main_name, Linkage::Import, &main_sig) + .unwrap(); + + let mut ctx = Context::new(); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone()); + { + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); + + let ebb = bcx.create_ebb(); + bcx.switch_to_block(ebb); + let arg_argc = bcx.append_ebb_param(ebb, types::I64 /*usize*/); + let arg_argv = bcx.append_ebb_param(ebb, types::I64 /* *const _*/); + + let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); + + let call_inst = if use_start_lang_item { + let start_def_id = tcx.require_lang_item(StartFnLangItem); + let start_instance = Instance::resolve( + tcx, + ParamEnv::reveal_all(), + start_def_id, + tcx.intern_substs(&[main_ret_ty.into()]), + ).unwrap(); + + let (start_name, start_sig) = get_function_name_and_sig(tcx, start_instance); + let start_func_id = m + .declare_function(&start_name, Linkage::Import, &start_sig) + .unwrap(); + + let main_val = bcx.ins().func_addr(types::I64, main_func_ref); + + let func_ref = m.declare_func_in_func(start_func_id, &mut bcx.func); + bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]) + } else { + // using user-defined start fn + bcx.ins().call(main_func_ref, &[arg_argc, arg_argv]) + }; + + let result = bcx.inst_results(call_inst)[0]; + bcx.ins().return_(&[result]); + bcx.seal_all_blocks(); + bcx.finalize(); + } + m.define_function(cmain_func_id, &mut ctx).unwrap(); + } +} From 2ba1f35baf8e27067622b987d6991c07780a311c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Aug 2018 10:46:29 +0200 Subject: [PATCH 0172/1566] Be honest about data mutability --- src/constant.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index e354319965d7f..7a1421ccf49c2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -133,10 +133,15 @@ fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) - .unwrap() } -fn data_id_for_static(tcx: TyCtxt, module: &mut Module, def_id: DefId) -> DataId { +fn data_id_for_static<'a, 'tcx: 'a, B: Backend>(tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, def_id: DefId) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); + let is_mutable = if let ::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { + true + } else { + !tcx.type_of(def_id).is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + }; module - .declare_data(&*symbol_name, Linkage::Export, false) + .declare_data(&*symbol_name, Linkage::Export, is_mutable) .unwrap() } From 69834cafd38573ea7ed4c4a681767b147bdb249b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Aug 2018 16:08:00 +0200 Subject: [PATCH 0173/1566] Use instance_mir instead of optimized_mir --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index b460547e8209f..a17c49868ba51 100644 --- a/src/base.rs +++ b/src/base.rs @@ -55,7 +55,7 @@ fn trans_fn<'a, 'tcx: 'a>( instance: Instance<'tcx>, ) { // Step 1. Get mir - let mir = tcx.optimized_mir(instance.def_id()); + let mir = tcx.instance_mir(instance.def); // Step 2. Declare function let (name, sig) = get_function_name_and_sig(tcx, instance); From 72f48776a14731516e3ae2baefe8d7ea371a4654 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Aug 2018 16:36:47 +0200 Subject: [PATCH 0174/1566] Support cross-compiling (untested) --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e056ada0260e9..a6648e767800f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,7 +215,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); let flags = settings::Flags::new(flags_builder); - let isa = cranelift::codegen::isa::lookup(target_lexicon::Triple::host()) + let isa = cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) .unwrap() .finish(flags); From 8a1c86473c7e5d6437398e683ed2adcad164b535 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 19 Aug 2018 10:50:39 +0200 Subject: [PATCH 0175/1566] Remove CValue::Func --- src/abi.rs | 14 ++++++++++---- src/common.rs | 10 +--------- src/constant.rs | 3 ++- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 7e19a4fba4f3d..f76aaba1d95b1 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -472,9 +472,15 @@ pub fn codegen_call<'a, 'tcx: 'a>( } })).collect::>(); - let inst = match trans_operand(fx, func) { - CValue::Func(func, _) => fx.bcx.ins().call(func, &call_args), - func => { + let call_inst = match fn_ty.sty { + TypeVariants::TyFnDef(def_id, substs) => { + let func_ref = fx.get_function_ref( + Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + ); + fx.bcx.ins().call(func_ref, &call_args) + } + _ => { + let func = trans_operand(fx, func); let func = func.load_value(fx); let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty)); fx.bcx.ins().call_indirect(sig, func, &call_args) @@ -485,7 +491,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( PassMode::NoPass => {} PassMode::ByVal(_) => { if let Some((ret_place, _)) = destination { - let results = fx.bcx.inst_results(inst); + let results = fx.bcx.inst_results(call_inst); ret_place.write_cvalue(fx, CValue::ByVal(results[0], ret_layout)); } } diff --git a/src/common.rs b/src/common.rs index d18b6bf43b2d1..8227f93f43bcb 100644 --- a/src/common.rs +++ b/src/common.rs @@ -71,13 +71,12 @@ fn codegen_field<'a, 'tcx: 'a>( pub enum CValue<'tcx> { ByRef(Value, TyLayout<'tcx>), ByVal(Value, TyLayout<'tcx>), - Func(FuncRef, TyLayout<'tcx>), } impl<'tcx> CValue<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { - CValue::ByRef(_, layout) | CValue::ByVal(_, layout) | CValue::Func(_, layout) => layout, + CValue::ByRef(_, layout) | CValue::ByVal(_, layout) => layout, } } @@ -96,10 +95,6 @@ impl<'tcx> CValue<'tcx> { fx.bcx.ins().stack_store(value, stack_slot, 0); fx.bcx.ins().stack_addr(types::I64, stack_slot, 0) } - CValue::Func(func, ty) => { - let func = fx.bcx.ins().func_addr(types::I64, func); - CValue::ByVal(func, ty).force_stack(fx) - } } } @@ -115,7 +110,6 @@ impl<'tcx> CValue<'tcx> { fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, - CValue::Func(func, _layout) => fx.bcx.ins().func_addr(types::I64, func), } } @@ -123,7 +117,6 @@ impl<'tcx> CValue<'tcx> { match self { CValue::ByRef(value, layout) => (value, layout), CValue::ByVal(_, _) => bug!("Expected CValue::ByRef, found CValue::ByVal: {:?}", self), - CValue::Func(_, _) => bug!("Expected CValue::ByRef, found CValue::Func: {:?}", self), } } @@ -161,7 +154,6 @@ impl<'tcx> CValue<'tcx> { match self { CValue::ByRef(addr, _) => CValue::ByRef(addr, layout), CValue::ByVal(val, _) => CValue::ByVal(val, layout), - CValue::Func(fun, _) => CValue::Func(fun, layout), } } } diff --git a/src/constant.rs b/src/constant.rs index 7a1421ccf49c2..3bbf74b0a314b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -109,7 +109,8 @@ fn trans_const_value<'a, 'tcx: 'a>( let func_ref = fx.get_function_ref( Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), ); - CValue::Func(func_ref, layout) + let func_addr = fx.bcx.ins().func_addr(types::I64, func_ref); + CValue::ByVal(func_addr, layout) } _ => trans_const_place(fx, const_).to_cvalue(fx), } From 954d1e7bf2fb7a7660cefec47e78e92016615f81 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Aug 2018 17:10:02 +0200 Subject: [PATCH 0176/1566] Don't hardcode usize being 64 bit (fixes #8) --- src/abi.rs | 18 +++++++++--------- src/base.rs | 4 ++-- src/common.rs | 29 +++++++++++++++++++---------- src/constant.rs | 4 ++-- src/lib.rs | 20 +++++++++++--------- 5 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index f76aaba1d95b1..0b2b1807099ac 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -13,11 +13,11 @@ enum PassMode { } impl PassMode { - fn get_param_ty(self, _fx: &FunctionCx) -> Type { + fn get_param_ty(self, fx: &FunctionCx) -> Type { match self { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(cton_type) => cton_type, - PassMode::ByRef => types::I64, + PassMode::ByRef => fx.module.pointer_type(), } } } @@ -74,7 +74,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( .filter_map(|ty| match get_pass_mode(tcx, sig.abi, ty, false) { PassMode::ByVal(cton_ty) => Some(cton_ty), PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByRef => Some(types::I64), + PassMode::ByRef => Some(pointer_ty(tcx)), }); let (params, returns) = match get_pass_mode(tcx, sig.abi, output, true) { @@ -85,7 +85,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( ), PassMode::ByRef => { ( - Some(types::I64).into_iter() // First param is place to put return val + Some(pointer_ty(tcx)).into_iter() // First param is place to put return val .chain(inputs) .map(AbiParam::new) .collect(), @@ -224,7 +224,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { CValue::ByVal(val, return_layout) } else { - CValue::ByRef(self.bcx.ins().iconst(types::I64, 0), return_layout) + CValue::ByRef(self.bcx.ins().iconst(self.module.pointer_type(), 0), return_layout) } } @@ -253,7 +253,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let ret_param = match output_pass_mode { PassMode::NoPass => None, PassMode::ByVal(_) => None, - PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, types::I64)), + PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, fx.module.pointer_type())), }; enum ArgKind { @@ -305,7 +305,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( match output_pass_mode { PassMode::NoPass => { - let null = fx.bcx.ins().iconst(types::I64, 0); + let null = fx.bcx.ins().iconst(fx.module.pointer_type(), 0); //unimplemented!("pass mode nopass"); fx.local_map.insert( RETURN_PLACE, @@ -457,7 +457,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( PassMode::NoPass => None, PassMode::ByRef => match destination { Some((place, _)) => Some(place.expect_addr()), - None => Some(fx.bcx.ins().iconst(types::I64, 0)), + None => Some(fx.bcx.ins().iconst(fx.module.pointer_type(), 0)), }, PassMode::ByVal(_) => None, }; @@ -570,7 +570,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( "copy" | "copy_nonoverlapping" => { let elem_ty = substs.type_at(0); let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); - let elem_size = fx.bcx.ins().iconst(types::I64, elem_size as i64); + let elem_size = fx.bcx.ins().iconst(fx.module.pointer_type(), elem_size as i64); assert_eq!(args.len(), 3); let src = args[0]; let dst = args[1]; diff --git a/src/base.rs b/src/base.rs index a17c49868ba51..9880d39afc7e5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -477,7 +477,7 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::Repeat(operand, times) => { let operand = trans_operand(fx, operand); for i in 0..*times { - let index = fx.bcx.ins().iconst(types::I64, i as i64); + let index = fx.bcx.ins().iconst(fx.module.pointer_type(), i as i64); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); } @@ -498,7 +498,7 @@ fn trans_stmt<'a, 'tcx: 'a>( AggregateKind::Array(_ty) => { for (i, operand) in operands.into_iter().enumerate() { let operand = trans_operand(fx, operand); - let index = fx.bcx.ins().iconst(types::I64, i as i64); + let index = fx.bcx.ins().iconst(fx.module.pointer_type(), i as i64); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); } diff --git a/src/common.rs b/src/common.rs index 8227f93f43bcb..6c537d72f9b1c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -10,6 +10,15 @@ pub fn mir_var(loc: Local) -> Variable { Variable::with_u32(loc.index() as u32) } +pub fn pointer_ty(tcx: TyCtxt) -> types::Type { + match tcx.data_layout.pointer_size.bits() { + 16 => types::I16, + 32 => types::I32, + 64 => types::I64, + bits => bug!("ptr_sized_integer: unknown pointer bit size {}", bits), + } +} + pub fn cton_type_from_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>, @@ -22,7 +31,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( UintTy::U32 => types::I32, UintTy::U64 => types::I64, UintTy::U128 => unimpl!("u128"), - UintTy::Usize => types::I64, + UintTy::Usize => pointer_ty(tcx), }, TypeVariants::TyInt(size) => match size { IntTy::I8 => types::I8, @@ -30,17 +39,17 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( IntTy::I32 => types::I32, IntTy::I64 => types::I64, IntTy::I128 => unimpl!("i128"), - IntTy::Isize => types::I64, + IntTy::Isize => pointer_ty(tcx) }, TypeVariants::TyChar => types::I32, TypeVariants::TyFloat(size) => match size { FloatTy::F32 => types::F32, FloatTy::F64 => types::F64, }, - TypeVariants::TyFnPtr(_) => types::I64, + TypeVariants::TyFnPtr(_) => pointer_ty(tcx), TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) | TypeVariants::TyRef(_, ty, _) => { if ty.is_sized(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { - types::I64 + pointer_ty(tcx) } else { return None; } @@ -59,7 +68,7 @@ fn codegen_field<'a, 'tcx: 'a>( let field_offset = layout.fields.offset(field.index()); let field_ty = layout.field(&*fx, field.index()); if field_offset.bytes() > 0 { - let field_offset = fx.bcx.ins().iconst(types::I64, field_offset.bytes() as i64); + let field_offset = fx.bcx.ins().iconst(fx.module.pointer_type(), field_offset.bytes() as i64); (fx.bcx.ins().iadd(base, field_offset), field_ty) } else { (base, field_ty) @@ -93,7 +102,7 @@ impl<'tcx> CValue<'tcx> { offset: None, }); fx.bcx.ins().stack_store(value, stack_slot, 0); - fx.bcx.ins().stack_addr(types::I64, stack_slot, 0) + fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0) } } } @@ -179,7 +188,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0), layout) + CPlace::Addr(fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0), layout) } pub fn from_stack_slot( @@ -188,7 +197,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ty: Ty<'tcx>, ) -> CPlace<'tcx> { let layout = fx.layout_of(ty); - CPlace::Addr(fx.bcx.ins().stack_addr(types::I64, stack_slot, 0), layout) + CPlace::Addr(fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0), layout) } pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { @@ -249,7 +258,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let byte = fx .bcx .ins() - .load(types::I64, MemFlags::new(), from.0, offset); + .load(fx.module.pointer_type(), MemFlags::new(), from.0, offset); fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); offset += 8; } @@ -299,7 +308,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let size = fx .bcx .ins() - .iconst(types::I64, elem_layout.size.bytes() as i64); + .iconst(fx.module.pointer_type(), elem_layout.size.bytes() as i64); let offset = fx.bcx.ins().imul(size, index); CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) } diff --git a/src/constant.rs b/src/constant.rs index 3bbf74b0a314b..5d7971bc23545 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -109,7 +109,7 @@ fn trans_const_value<'a, 'tcx: 'a>( let func_ref = fx.get_function_ref( Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), ); - let func_addr = fx.bcx.ins().func_addr(types::I64, func_ref); + let func_addr = fx.bcx.ins().func_addr(fx.module.pointer_type(), func_ref); CValue::ByVal(func_addr, layout) } _ => trans_const_place(fx, const_).to_cvalue(fx), @@ -152,7 +152,7 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( data_id: DataId, ) -> CPlace<'tcx> { let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); + let global_ptr = fx.bcx.ins().global_value(fx.module.pointer_type(), local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); CPlace::Addr(global_ptr, layout) } diff --git a/src/lib.rs b/src/lib.rs index a6648e767800f..d40c820a4f7d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -228,6 +228,7 @@ impl CodegenBackend for CraneliftCodegenBackend { if std::env::var("SHOULD_RUN").is_ok() { let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); + assert_eq!(pointer_ty(tcx), jit_module.pointer_type()); codegen_mono_items(tcx, &mut jit_module, &mono_items); @@ -238,10 +239,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let sig = Signature { params: vec![ - AbiParam::new(types::I64 /*usize*/), - AbiParam::new(types::I64 /* *const _*/), + AbiParam::new(jit_module.pointer_type()), + AbiParam::new(jit_module.pointer_type()), ], - returns: vec![AbiParam::new(types::I64 /*isize*/)], + returns: vec![AbiParam::new(jit_module.pointer_type() /*isize*/)], call_conv: CallConv::SystemV, argument_bytes: None, }; @@ -269,6 +270,7 @@ impl CodegenBackend for CraneliftCodegenBackend { FaerieBuilder::default_libcall_names(), ).unwrap(), ); + assert_eq!(pointer_ty(tcx), faerie_module.pointer_type()); codegen_mono_items(tcx, &mut faerie_module, &mono_items); @@ -443,10 +445,10 @@ fn maybe_create_entry_wrapper(cx: &mut CodegenCx) { let cmain_sig = Signature { params: vec![ - AbiParam::new(types::I64 /*usize*/), - AbiParam::new(types::I64 /* *const _*/), + AbiParam::new(m.pointer_type()), + AbiParam::new(m.pointer_type()), ], - returns: vec![AbiParam::new(types::I64 /*isize*/)], + returns: vec![AbiParam::new(m.pointer_type() /*isize*/)], call_conv: CallConv::SystemV, argument_bytes: None, }; @@ -471,8 +473,8 @@ fn maybe_create_entry_wrapper(cx: &mut CodegenCx) { let ebb = bcx.create_ebb(); bcx.switch_to_block(ebb); - let arg_argc = bcx.append_ebb_param(ebb, types::I64 /*usize*/); - let arg_argv = bcx.append_ebb_param(ebb, types::I64 /* *const _*/); + let arg_argc = bcx.append_ebb_param(ebb, m.pointer_type()); + let arg_argv = bcx.append_ebb_param(ebb, m.pointer_type()); let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); @@ -490,7 +492,7 @@ fn maybe_create_entry_wrapper(cx: &mut CodegenCx) { .declare_function(&start_name, Linkage::Import, &start_sig) .unwrap(); - let main_val = bcx.ins().func_addr(types::I64, main_func_ref); + let main_val = bcx.ins().func_addr(m.pointer_type(), main_func_ref); let func_ref = m.declare_func_in_func(start_func_id, &mut bcx.func); bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]) From 8cd9bf3162da67600fbd6046893cc4f23b90a1b3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Aug 2018 11:45:54 +0200 Subject: [PATCH 0177/1566] Use *_imm in some places --- src/common.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/common.rs b/src/common.rs index 6c537d72f9b1c..ffb984c7c11e2 100644 --- a/src/common.rs +++ b/src/common.rs @@ -68,8 +68,7 @@ fn codegen_field<'a, 'tcx: 'a>( let field_offset = layout.fields.offset(field.index()); let field_ty = layout.field(&*fx, field.index()); if field_offset.bytes() > 0 { - let field_offset = fx.bcx.ins().iconst(fx.module.pointer_type(), field_offset.bytes() as i64); - (fx.bcx.ins().iadd(base, field_offset), field_ty) + (fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), field_ty) } else { (base, field_ty) } @@ -305,11 +304,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match layout.ty.sty { TypeVariants::TyArray(elem_ty, _) => { let elem_layout = fx.layout_of(elem_ty); - let size = fx - .bcx - .ins() - .iconst(fx.module.pointer_type(), elem_layout.size.bytes() as i64); - let offset = fx.bcx.ins().imul(size, index); + let offset = fx.bcx.ins().imul_imm(index, elem_layout.size.bytes() as i64); CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) } TypeVariants::TySlice(_elem_ty) => unimplemented!("place_index(TySlice)"), From 65641b887270da200d4ea83f8f968ad67de16401 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Aug 2018 12:31:45 +0200 Subject: [PATCH 0178/1566] Rustfmt --- src/abi.rs | 10 ++++++++-- src/common.rs | 40 ++++++++++++++++++++++++++++++---------- src/constant.rs | 14 +++++++++++--- src/lib.rs | 7 ++++--- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 0b2b1807099ac..7c5ff6a809c59 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -224,7 +224,10 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { CValue::ByVal(val, return_layout) } else { - CValue::ByRef(self.bcx.ins().iconst(self.module.pointer_type(), 0), return_layout) + CValue::ByRef( + self.bcx.ins().iconst(self.module.pointer_type(), 0), + return_layout, + ) } } @@ -570,7 +573,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( "copy" | "copy_nonoverlapping" => { let elem_ty = substs.type_at(0); let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); - let elem_size = fx.bcx.ins().iconst(fx.module.pointer_type(), elem_size as i64); + let elem_size = fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), elem_size as i64); assert_eq!(args.len(), 3); let src = args[0]; let dst = args[1]; diff --git a/src/common.rs b/src/common.rs index ffb984c7c11e2..c015765195d43 100644 --- a/src/common.rs +++ b/src/common.rs @@ -39,7 +39,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( IntTy::I32 => types::I32, IntTy::I64 => types::I64, IntTy::I128 => unimpl!("i128"), - IntTy::Isize => pointer_ty(tcx) + IntTy::Isize => pointer_ty(tcx), }, TypeVariants::TyChar => types::I32, TypeVariants::TyFloat(size) => match size { @@ -68,7 +68,10 @@ fn codegen_field<'a, 'tcx: 'a>( let field_offset = layout.fields.offset(field.index()); let field_ty = layout.field(&*fx, field.index()); if field_offset.bytes() > 0 { - (fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), field_ty) + ( + fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), + field_ty, + ) } else { (base, field_ty) } @@ -101,7 +104,9 @@ impl<'tcx> CValue<'tcx> { offset: None, }); fx.bcx.ins().stack_store(value, stack_slot, 0); - fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0) + fx.bcx + .ins() + .stack_addr(fx.module.pointer_type(), stack_slot, 0) } } } @@ -187,7 +192,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - CPlace::Addr(fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0), layout) + CPlace::Addr( + fx.bcx + .ins() + .stack_addr(fx.module.pointer_type(), stack_slot, 0), + layout, + ) } pub fn from_stack_slot( @@ -196,7 +206,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ty: Ty<'tcx>, ) -> CPlace<'tcx> { let layout = fx.layout_of(ty); - CPlace::Addr(fx.bcx.ins().stack_addr(fx.module.pointer_type(), stack_slot, 0), layout) + CPlace::Addr( + fx.bcx + .ins() + .stack_addr(fx.module.pointer_type(), stack_slot, 0), + layout, + ) } pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { @@ -254,10 +269,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let from = from.expect_byref(); let mut offset = 0; while size - offset >= 8 { - let byte = fx - .bcx - .ins() - .load(fx.module.pointer_type(), MemFlags::new(), from.0, offset); + let byte = fx.bcx.ins().load( + fx.module.pointer_type(), + MemFlags::new(), + from.0, + offset, + ); fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); offset += 8; } @@ -304,7 +321,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match layout.ty.sty { TypeVariants::TyArray(elem_ty, _) => { let elem_layout = fx.layout_of(elem_ty); - let offset = fx.bcx.ins().imul_imm(index, elem_layout.size.bytes() as i64); + let offset = fx + .bcx + .ins() + .imul_imm(index, elem_layout.size.bytes() as i64); CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) } TypeVariants::TySlice(_elem_ty) => unimplemented!("place_index(TySlice)"), diff --git a/src/constant.rs b/src/constant.rs index 5d7971bc23545..10a59560ff55c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -134,12 +134,17 @@ fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) - .unwrap() } -fn data_id_for_static<'a, 'tcx: 'a, B: Backend>(tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, def_id: DefId) -> DataId { +fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + def_id: DefId, +) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); let is_mutable = if let ::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { true } else { - !tcx.type_of(def_id).is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + !tcx.type_of(def_id) + .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) }; module .declare_data(&*symbol_name, Linkage::Export, is_mutable) @@ -152,7 +157,10 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( data_id: DataId, ) -> CPlace<'tcx> { let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - let global_ptr = fx.bcx.ins().global_value(fx.module.pointer_type(), local_data_id); + let global_ptr = fx + .bcx + .ins() + .global_value(fx.module.pointer_type(), local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); CPlace::Addr(global_ptr, layout) } diff --git a/src/lib.rs b/src/lib.rs index d40c820a4f7d5..7ea6abe03a4b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,9 +215,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); let flags = settings::Flags::new(flags_builder); - let isa = cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) - .unwrap() - .finish(flags); + let isa = + cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) + .unwrap() + .finish(flags); let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0; From d87edae73ba93a3171903fd6889c554d34d5a3ee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Aug 2018 12:35:07 +0200 Subject: [PATCH 0179/1566] Add CValue variant ByValPair --- src/base.rs | 58 ++++++++++++-------------- src/common.rs | 110 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 105 insertions(+), 63 deletions(-) diff --git a/src/base.rs b/src/base.rs index 9880d39afc7e5..b1ad63135c575 100644 --- a/src/base.rs +++ b/src/base.rs @@ -727,15 +727,15 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( pub fn trans_checked_int_binop<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, + in_lhs: CValue<'tcx>, + in_rhs: CValue<'tcx>, out_ty: Ty<'tcx>, signed: bool, ) -> CValue<'tcx> { if bin_op != BinOp::Shl && bin_op != BinOp::Shr { assert_eq!( - lhs.layout().ty, - rhs.layout().ty, + in_lhs.layout().ty, + in_rhs.layout().ty, "checked int binop requires lhs and rhs of same type" ); } @@ -747,40 +747,32 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( ), }; - let res = binop_match! { - fx, bin_op, signed, lhs, rhs, res_ty, "checked int/uint"; - Add (_) iadd; - Sub (_) isub; - Mul (_) imul; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) ishl; - Shr (false) ushr; - Shr (true) sshr; - - Eq (_) bug; - Lt (_) bug; - Le (_) bug; - Ne (_) bug; - Ge (_) bug; - Gt (_) bug; - - Offset (_) bug; + let lhs = in_lhs.load_value(fx); + let rhs = in_rhs.load_value(fx); + let res = match bin_op { + BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), + BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), + BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), + BinOp::Shl => fx.bcx.ins().ishl(lhs, rhs), + BinOp::Shr => if !signed { + fx.bcx.ins().ushr(lhs, rhs) + } else { + fx.bcx.ins().sshr(lhs, rhs) + }, + _ => bug!( + "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", + bin_op, + in_lhs, + in_rhs + ), }; // TODO: check for overflow - let has_overflow = CValue::const_val(fx, fx.tcx.types.bool, 0); + let has_overflow = fx.bcx.ins().iconst(types::I8, 0); let out_place = CPlace::temp(fx, out_ty); - out_place - .place_field(fx, mir::Field::new(0)) - .write_cvalue(fx, res); - out_place - .place_field(fx, mir::Field::new(1)) - .write_cvalue(fx, has_overflow); + let out_layout = out_place.layout(); + out_place.write_cvalue(fx, CValue::ByValPair(res, has_overflow, out_layout)); out_place.to_cvalue(fx) } diff --git a/src/common.rs b/src/common.rs index c015765195d43..a4d3f81bb5d55 100644 --- a/src/common.rs +++ b/src/common.rs @@ -82,12 +82,15 @@ fn codegen_field<'a, 'tcx: 'a>( pub enum CValue<'tcx> { ByRef(Value, TyLayout<'tcx>), ByVal(Value, TyLayout<'tcx>), + ByValPair(Value, Value, TyLayout<'tcx>), } impl<'tcx> CValue<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { - CValue::ByRef(_, layout) | CValue::ByVal(_, layout) => layout, + CValue::ByRef(_, layout) + | CValue::ByVal(_, layout) + | CValue::ByValPair(_, _, layout) => layout, } } @@ -108,6 +111,19 @@ impl<'tcx> CValue<'tcx> { .ins() .stack_addr(fx.module.pointer_type(), stack_slot, 0) } + CValue::ByValPair(value, extra, layout) => { + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let base = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); + let a_addr = codegen_field(fx, base, layout, mir::Field::new(0)).0; + let b_addr = codegen_field(fx, base, layout, mir::Field::new(1)).0; + fx.bcx.ins().store(MemFlags::new(), value, a_addr, 0); + fx.bcx.ins().store(MemFlags::new(), extra, b_addr, 0); + base + } } } @@ -123,6 +139,34 @@ impl<'tcx> CValue<'tcx> { fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, + CValue::ByValPair(_, _, _layout) => bug!("Please use load_value_pair for ByValPair"), + } + } + + pub fn load_value_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> (Value, Value) + where + 'tcx: 'a, + { + match self { + CValue::ByRef(addr, layout) => { + assert_eq!( + layout.size.bytes(), + fx.tcx.data_layout.pointer_size.bytes() * 2 + ); + let val1_offset = layout.fields.offset(0).bytes() as i32; + let val2_offset = layout.fields.offset(1).bytes() as i32; + let val1 = + fx.bcx + .ins() + .load(fx.module.pointer_type(), MemFlags::new(), addr, val1_offset); + let val2 = + fx.bcx + .ins() + .load(fx.module.pointer_type(), MemFlags::new(), addr, val2_offset); + (val1, val2) + } + CValue::ByVal(_, _layout) => bug!("Please use load_value for ByVal"), + CValue::ByValPair(val1, val2, _layout) => (val1, val2), } } @@ -130,6 +174,10 @@ impl<'tcx> CValue<'tcx> { match self { CValue::ByRef(value, layout) => (value, layout), CValue::ByVal(_, _) => bug!("Expected CValue::ByRef, found CValue::ByVal: {:?}", self), + CValue::ByValPair(_, _, _) => bug!( + "Expected CValue::ByRef, found CValue::ByValPair: {:?}", + self + ), } } @@ -167,6 +215,7 @@ impl<'tcx> CValue<'tcx> { match self { CValue::ByRef(addr, _) => CValue::ByRef(addr, layout), CValue::ByVal(val, _) => CValue::ByVal(val, layout), + CValue::ByValPair(val, extra, _) => CValue::ByValPair(val, extra, layout), } } } @@ -262,37 +311,38 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(addr, layout) => { let size = layout.size.bytes() as i32; - if let Some(_) = fx.cton_type(layout.ty) { - let data = from.load_value(fx); - fx.bcx.ins().store(MemFlags::new(), data, addr, 0); - } else { - let from = from.expect_byref(); - let mut offset = 0; - while size - offset >= 8 { - let byte = fx.bcx.ins().load( - fx.module.pointer_type(), - MemFlags::new(), - from.0, - offset, - ); - fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); - offset += 8; + match from { + CValue::ByVal(val, _layout) => { + fx.bcx.ins().store(MemFlags::new(), val, addr, 0); } - while size - offset >= 4 { - let byte = fx - .bcx - .ins() - .load(types::I32, MemFlags::new(), from.0, offset); - fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); - offset += 4; + CValue::ByValPair(val1, val2, _layout) => { + let val1_offset = layout.fields.offset(0).bytes() as i32; + let val2_offset = layout.fields.offset(1).bytes() as i32; + fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); + fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); } - while offset < size { - let byte = fx - .bcx - .ins() - .load(types::I8, MemFlags::new(), from.0, offset); - fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); - offset += 1; + CValue::ByRef(from, _layout) => { + let mut offset = 0; + while size - offset >= 8 { + let byte = fx.bcx.ins().load( + fx.module.pointer_type(), + MemFlags::new(), + from, + offset, + ); + fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); + offset += 8; + } + while size - offset >= 4 { + let byte = fx.bcx.ins().load(types::I32, MemFlags::new(), from, offset); + fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); + offset += 4; + } + while offset < size { + let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from, offset); + fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); + offset += 1; + } } } } From d348f5b473ab7330a7d4d3ae0c5ccd24acb33298 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Aug 2018 18:53:57 +0200 Subject: [PATCH 0180/1566] Codegen all instance types --- src/base.rs | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/base.rs b/src/base.rs index b1ad63135c575..37145b5d847c9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -17,25 +17,29 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( let context = &mut cx.context; match mono_item { - MonoItem::Fn(inst) => match inst { - Instance { - def: InstanceDef::Item(def_id), - substs: _, - } => { - let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(tcx, Some(def_id), &mut mir).unwrap(); - let mir_file_name = - "target/out/mir/".to_string() + &format!("{:?}", def_id).replace('/', "@"); - ::std::fs::write(mir_file_name, mir.into_inner()).unwrap(); - let _print_guard = PrintOnPanic(format!("{:?}", inst)); - - trans_fn(tcx, cx.module, &mut cx.ccx, context, inst); - } - Instance { - def: InstanceDef::DropGlue(_, _), - substs: _, - } => unimpl!("Unimplemented drop glue instance"), - inst => unimpl!("Unimplemented instance {:?}", inst), + MonoItem::Fn(inst) => { + let _print_guard = PrintOnPanic(format!("{:?}", inst)); + let mir = match inst.def { + InstanceDef::Item(_) + | InstanceDef::DropGlue(_, _) + | InstanceDef::Virtual(_, _) => { + let mut mir = ::std::io::Cursor::new(Vec::new()); + ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir).unwrap(); + mir.into_inner() + } + InstanceDef::FnPtrShim(_, _) + | InstanceDef::ClosureOnceShim { .. } + | InstanceDef::CloneShim(_, _) => { + // FIXME fix write_mir_pretty for these instances + format!("{:#?}", cx.tcx.instance_mir(inst.def)).into_bytes() + } + InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"), + }; + let mir_file_name = + "target/out/mir/".to_string() + &format!("{:?}", inst.def_id()).replace('/', "@"); + ::std::fs::write(mir_file_name, mir).unwrap(); + + trans_fn(tcx, cx.module, &mut cx.ccx, context, inst); }, MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.ccx, def_id); From 8e8d03e477314ca7cbb41281832befe83b0bd53a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 23 Aug 2018 11:00:40 +0200 Subject: [PATCH 0181/1566] [PATCH] Disable some more unsupported stuff in libcore --- ...me-more-unsupported-stuff-in-libcore.patch | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 0005-Disable-some-more-unsupported-stuff-in-libcore.patch diff --git a/0005-Disable-some-more-unsupported-stuff-in-libcore.patch b/0005-Disable-some-more-unsupported-stuff-in-libcore.patch new file mode 100644 index 0000000000000..855e96feedd28 --- /dev/null +++ b/0005-Disable-some-more-unsupported-stuff-in-libcore.patch @@ -0,0 +1,101 @@ +From 3d1907db6e349aa7e6cfe3dd490a9d10db669872 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Thu, 23 Aug 2018 11:15:01 +0200 +Subject: [PATCH] Disable some more unsupported stuff in libcore + +--- + src/libcore/cell.rs | 6 +++--- + src/libcore/cmp.rs | 5 ++++- + src/libcore/num/mod.rs | 8 ++++++-- + src/libcore/str/mod.rs | 6 +++--- + 4 files changed, 16 insertions(+), 9 deletions(-) + +diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs +index 009aba5..2aa76e3 100644 +--- a/src/libcore/cell.rs ++++ b/src/libcore/cell.rs +@@ -1532,7 +1532,7 @@ impl, U> CoerceUnsized> for UnsafeCell {} + + #[allow(unused)] + fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) { +- let _: UnsafeCell<&dyn Send> = a; +- let _: Cell<&dyn Send> = b; +- let _: RefCell<&dyn Send> = c; ++ //let _: UnsafeCell<&dyn Send> = a; ++ //let _: Cell<&dyn Send> = b; ++ //let _: RefCell<&dyn Send> = c; + } +diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs +index a6e6496..f9374ea 100644 +--- a/src/libcore/cmp.rs ++++ b/src/libcore/cmp.rs +@@ -496,6 +496,7 @@ pub trait Ord: Eq + PartialOrd { + #[stable(feature = "rust1", since = "1.0.0")] + impl Eq for Ordering {} + ++/* + #[stable(feature = "rust1", since = "1.0.0")] + impl Ord for Ordering { + #[inline] +@@ -503,12 +504,14 @@ impl Ord for Ordering { + (*self as i32).cmp(&(*other as i32)) + } + } ++*/ + + #[stable(feature = "rust1", since = "1.0.0")] + impl PartialOrd for Ordering { + #[inline] + fn partial_cmp(&self, other: &Ordering) -> Option { +- (*self as i32).partial_cmp(&(*other as i32)) ++ //(*self as i32).partial_cmp(&(*other as i32)) ++ None + } + } + +diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs +index 5d00949..f077f1d 100644 +--- a/src/libcore/num/mod.rs ++++ b/src/libcore/num/mod.rs +@@ -2273,7 +2273,9 @@ assert_eq!(m, ", $swapped, "); + #[rustc_const_unstable(feature = "const_int_ops")] + #[inline] + pub const fn swap_bytes(self) -> Self { +- unsafe { intrinsics::bswap(self as $ActualT) as Self } ++ // TODO support bswap ++ //unsafe { intrinsics::bswap(self as $ActualT) as Self } ++ 0 + } + } + +@@ -2295,7 +2297,9 @@ assert_eq!(m, ", $reversed, "); + #[unstable(feature = "reverse_bits", issue = "48763")] + #[inline] + pub fn reverse_bits(self) -> Self { +- unsafe { intrinsics::bitreverse(self as $ActualT) as Self } ++ // TODO support bitreverse ++ //unsafe { intrinsics::bitreverse(self as $ActualT) as Self } ++ 0 + } + } + +diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs +index 810d19d..4c68370 100644 +--- a/src/libcore/str/mod.rs ++++ b/src/libcore/str/mod.rs +@@ -26,9 +26,9 @@ use mem; + + pub mod pattern; + +-#[unstable(feature = "str_internals", issue = "0")] +-#[allow(missing_docs)] +-pub mod lossy; ++//#[unstable(feature = "str_internals", issue = "0")] ++//#[allow(missing_docs)] ++//pub mod lossy; + + /// A trait to abstract the idea of creating a new instance of a type from a + /// string. +-- +2.11.0 + From 0d15d9e5dd33aa3b3576f091f7fb05b942afc576 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 24 Aug 2018 14:51:02 +0200 Subject: [PATCH 0182/1566] Rustup to rustc 1.30.0-nightly (63d66494a 2018-08-23) --- src/abi.rs | 32 ++++++++++++------------- src/base.rs | 64 ++++++++++++++++++++++++------------------------- src/common.rs | 22 ++++++++--------- src/constant.rs | 16 ++++++------- src/lib.rs | 9 ++++--- 5 files changed, 71 insertions(+), 72 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 7c5ff6a809c59..b5967e7341902 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -57,7 +57,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().sty { - ty::TyTuple(ref tupled_arguments) => tupled_arguments, + ty::Tuple(ref tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; let mut inputs: Vec = vec![sig.inputs()[0]]; @@ -104,10 +104,10 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<'tcx> { let sig = match ty.sty { - ty::TyFnDef(..) | + ty::FnDef(..) | // Shims currently have type TyFnPtr. Not sure this should remain. - ty::TyFnPtr(_) => ty.fn_sig(tcx), - ty::TyClosure(def_id, substs) => { + ty::FnPtr(_) => ty.fn_sig(tcx), + ty::Closure(def_id, substs) => { let sig = substs.closure_sig(def_id, tcx); let env_ty = tcx.closure_env_ty(def_id, substs).unwrap(); @@ -119,7 +119,7 @@ fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<' sig.abi )) } - ty::TyGenerator(def_id, substs, _) => { + ty::Generator(def_id, substs, _) => { let sig = substs.poly_sig(def_id, tcx); let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); @@ -213,7 +213,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { ) }).unzip(); let return_layout = self.layout_of(return_ty); - let return_ty = if let TypeVariants::TyTuple(tup) = return_ty.sty { + let return_ty = if let ty::Tuple(tup) = return_ty.sty { if !tup.is_empty() { bug!("easy_call( (...) -> ) is not allowed"); } @@ -278,7 +278,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( // individual function arguments. let tupled_arg_tys = match arg_ty.sty { - ty::TyTuple(ref tys) => tys, + ty::Tuple(ref tys) => tys, _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), }; @@ -431,7 +431,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( let mut args = Vec::new(); args.push(self_arg); match pack_arg.layout().ty.sty { - ty::TyTuple(ref tupled_arguments) => { + ty::Tuple(ref tupled_arguments) => { for (i, _) in tupled_arguments.iter().enumerate() { args.push(pack_arg.value_field(fx, mir::Field::new(i))); } @@ -476,7 +476,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( })).collect::>(); let call_inst = match fn_ty.sty { - TypeVariants::TyFnDef(def_id, substs) => { + ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), ); @@ -528,7 +528,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( args: &[CValue<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, ) -> bool { - if let TypeVariants::TyFnDef(def_id, substs) = fn_ty.sty { + if let ty::FnDef(def_id, substs) = fn_ty.sty { if sig.abi == Abi::RustIntrinsic { let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; @@ -621,7 +621,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; let res = match ret.layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_int_binop( + ty::Uint(_) => crate::base::trans_int_binop( fx, bin_op, args[0], @@ -629,7 +629,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.layout().ty, false, ), - TypeVariants::TyInt(_) => crate::base::trans_int_binop( + ty::Int(_) => crate::base::trans_int_binop( fx, bin_op, args[0], @@ -651,7 +651,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; let res = match args[0].layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_checked_int_binop( + ty::Uint(_) => crate::base::trans_checked_int_binop( fx, bin_op, args[0], @@ -659,7 +659,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.layout().ty, false, ), - TypeVariants::TyInt(_) => crate::base::trans_checked_int_binop( + ty::Int(_) => crate::base::trans_checked_int_binop( fx, bin_op, args[0], @@ -681,7 +681,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; let res = match args[0].layout().ty.sty { - TypeVariants::TyUint(_) => crate::base::trans_int_binop( + ty::Uint(_) => crate::base::trans_int_binop( fx, bin_op, args[0], @@ -689,7 +689,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.layout().ty, false, ), - TypeVariants::TyInt(_) => crate::base::trans_int_binop( + ty::Int(_) => crate::base::trans_int_binop( fx, bin_op, args[0], diff --git a/src/base.rs b/src/base.rs index 37145b5d847c9..e0a9ce610b631 100644 --- a/src/base.rs +++ b/src/base.rs @@ -317,22 +317,22 @@ fn trans_stmt<'a, 'tcx: 'a>( let rhs = trans_operand(fx, rhs); let res = match ty.sty { - TypeVariants::TyBool => { + ty::Bool => { trans_bool_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } - TypeVariants::TyUint(_) => { + ty::Uint(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } - TypeVariants::TyInt(_) => { + ty::Int(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) } - TypeVariants::TyFloat(_) => { + ty::Float(_) => { trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } - TypeVariants::TyChar => { + ty::Char => { trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } - TypeVariants::TyRawPtr(..) => { + ty::RawPtr(..) => { trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } _ => unimplemented!("binop {:?} for {:?}", bin_op, ty), @@ -345,10 +345,10 @@ fn trans_stmt<'a, 'tcx: 'a>( let rhs = trans_operand(fx, rhs); let res = match ty.sty { - TypeVariants::TyUint(_) => { + ty::Uint(_) => { trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } - TypeVariants::TyInt(_) => { + ty::Int(_) => { trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) } _ => unimplemented!("checked binop {:?} for {:?}", bin_op, ty), @@ -362,12 +362,12 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = match un_op { UnOp::Not => fx.bcx.ins().bnot(val), UnOp::Neg => match ty.sty { - TypeVariants::TyInt(_) => { + ty::Int(_) => { let clif_ty = fx.cton_type(ty).unwrap(); let zero = fx.bcx.ins().iconst(clif_ty, 0); fx.bcx.ins().isub(zero, val) } - TypeVariants::TyFloat(_) => fx.bcx.ins().fneg(val), + ty::Float(_) => fx.bcx.ins().fneg(val), _ => unimplemented!("un op Neg for {:?}", ty), }, }; @@ -387,27 +387,27 @@ fn trans_stmt<'a, 'tcx: 'a>( let operand = trans_operand(fx, operand); let from_ty = operand.layout().ty; match (&from_ty.sty, &to_ty.sty) { - (TypeVariants::TyRef(..), TypeVariants::TyRef(..)) - | (TypeVariants::TyRef(..), TypeVariants::TyRawPtr(..)) - | (TypeVariants::TyRawPtr(..), TypeVariants::TyRef(..)) - | (TypeVariants::TyRawPtr(..), TypeVariants::TyRawPtr(..)) => { + (ty::Ref(..), ty::Ref(..)) + | (ty::Ref(..), ty::RawPtr(..)) + | (ty::RawPtr(..), ty::Ref(..)) + | (ty::RawPtr(..), ty::RawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (TypeVariants::TyRawPtr(..), TypeVariants::TyUint(_)) - | (TypeVariants::TyFnPtr(..), TypeVariants::TyUint(_)) + (ty::RawPtr(..), ty::Uint(_)) + | (ty::FnPtr(..), ty::Uint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (TypeVariants::TyUint(_), TypeVariants::TyRawPtr(..)) + (ty::Uint(_), ty::RawPtr(..)) if from_ty.sty == fx.tcx.types.usize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (TypeVariants::TyChar, TypeVariants::TyUint(_)) - | (TypeVariants::TyUint(_), TypeVariants::TyChar) - | (TypeVariants::TyUint(_), TypeVariants::TyInt(_)) - | (TypeVariants::TyUint(_), TypeVariants::TyUint(_)) => { + (ty::Char, ty::Uint(_)) + | (ty::Uint(_), ty::Char) + | (ty::Uint(_), ty::Int(_)) + | (ty::Uint(_), ty::Uint(_)) => { let from = operand.load_value(fx); let res = crate::common::cton_intcast( fx, @@ -417,8 +417,8 @@ fn trans_stmt<'a, 'tcx: 'a>( ); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (TypeVariants::TyInt(_), TypeVariants::TyInt(_)) - | (TypeVariants::TyInt(_), TypeVariants::TyUint(_)) => { + (ty::Int(_), ty::Int(_)) + | (ty::Int(_), ty::Uint(_)) => { let from = operand.load_value(fx); let res = crate::common::cton_intcast( fx, @@ -428,7 +428,7 @@ fn trans_stmt<'a, 'tcx: 'a>( ); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (TypeVariants::TyFloat(from_flt), TypeVariants::TyFloat(to_flt)) => { + (ty::Float(from_flt), ty::Float(to_flt)) => { let from = operand.load_value(fx); let res = match (from_flt, to_flt) { (FloatTy::F32, FloatTy::F64) => { @@ -441,20 +441,20 @@ fn trans_stmt<'a, 'tcx: 'a>( }; lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (TypeVariants::TyInt(_), TypeVariants::TyFloat(_)) => { + (ty::Int(_), ty::Float(_)) => { let from = operand.load_value(fx); let f_type = fx.cton_type(to_ty).unwrap(); let res = fx.bcx.ins().fcvt_from_sint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (TypeVariants::TyUint(_), TypeVariants::TyFloat(_)) => { + (ty::Uint(_), ty::Float(_)) => { let from = operand.load_value(fx); let f_type = fx.cton_type(to_ty).unwrap(); let res = fx.bcx.ins().fcvt_from_uint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (TypeVariants::TyBool, TypeVariants::TyUint(_)) - | (TypeVariants::TyBool, TypeVariants::TyInt(_)) => { + (ty::Bool, ty::Uint(_)) + | (ty::Bool, ty::Int(_)) => { let to_ty = fx.cton_type(to_ty).unwrap(); let from = operand.load_value(fx); let res = if to_ty != types::I8 { @@ -744,7 +744,7 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( ); } let res_ty = match out_ty.sty { - TypeVariants::TyTuple(tys) => tys[0], + ty::Tuple(tys) => tys[0], _ => bug!( "Checked int binop requires tuple as output, but got {:?}", out_ty @@ -798,8 +798,8 @@ fn trans_float_binop<'a, 'tcx: 'a>( assert_eq!(lhs.layout().ty, ty); assert_eq!(rhs.layout().ty, ty); match ty.sty { - TypeVariants::TyFloat(FloatTy::F32) => fx.easy_call("fmodf", &[lhs, rhs], ty), - TypeVariants::TyFloat(FloatTy::F64) => fx.easy_call("fmod", &[lhs, rhs], ty), + ty::Float(FloatTy::F32) => fx.easy_call("fmodf", &[lhs, rhs], ty), + ty::Float(FloatTy::F64) => fx.easy_call("fmod", &[lhs, rhs], ty), _ => bug!(), } }); @@ -863,7 +863,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( ty: Ty<'tcx>, ) -> CValue<'tcx> { match lhs.layout().ty.sty { - TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) => { + ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { if !ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { unimpl!("Unsized values are not yet implemented"); } diff --git a/src/common.rs b/src/common.rs index a4d3f81bb5d55..7a8cc53b8d5ac 100644 --- a/src/common.rs +++ b/src/common.rs @@ -24,8 +24,8 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( ty: Ty<'tcx>, ) -> Option { Some(match ty.sty { - TypeVariants::TyBool => types::I8, - TypeVariants::TyUint(size) => match size { + ty::Bool => types::I8, + ty::Uint(size) => match size { UintTy::U8 => types::I8, UintTy::U16 => types::I16, UintTy::U32 => types::I32, @@ -33,7 +33,7 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( UintTy::U128 => unimpl!("u128"), UintTy::Usize => pointer_ty(tcx), }, - TypeVariants::TyInt(size) => match size { + ty::Int(size) => match size { IntTy::I8 => types::I8, IntTy::I16 => types::I16, IntTy::I32 => types::I32, @@ -41,20 +41,20 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( IntTy::I128 => unimpl!("i128"), IntTy::Isize => pointer_ty(tcx), }, - TypeVariants::TyChar => types::I32, - TypeVariants::TyFloat(size) => match size { + ty::Char => types::I32, + ty::Float(size) => match size { FloatTy::F32 => types::F32, FloatTy::F64 => types::F64, }, - TypeVariants::TyFnPtr(_) => pointer_ty(tcx), - TypeVariants::TyRawPtr(TypeAndMut { ty, mutbl: _ }) | TypeVariants::TyRef(_, ty, _) => { + ty::FnPtr(_) => pointer_ty(tcx), + ty::RawPtr(TypeAndMut { ty, mutbl: _ }) | ty::Ref(_, ty, _) => { if ty.is_sized(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { pointer_ty(tcx) } else { return None; } } - TypeVariants::TyParam(_) => bug!("{:?}: {:?}", ty, ty.sty), + ty::Param(_) => bug!("{:?}: {:?}", ty, ty.sty), _ => return None, }) } @@ -279,7 +279,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { match (&self.layout().ty.sty, &from.layout().ty.sty) { - (TypeVariants::TyRef(_, t, dest_mut), TypeVariants::TyRef(_, u, src_mut)) + (ty::Ref(_, t, dest_mut), ty::Ref(_, u, src_mut)) if (if *dest_mut != ::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { false } else if t != u { @@ -369,7 +369,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let addr = self.expect_addr(); let layout = self.layout(); match layout.ty.sty { - TypeVariants::TyArray(elem_ty, _) => { + ty::Array(elem_ty, _) => { let elem_layout = fx.layout_of(elem_ty); let offset = fx .bcx @@ -377,7 +377,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { .imul_imm(index, elem_layout.size.bytes() as i64); CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) } - TypeVariants::TySlice(_elem_ty) => unimplemented!("place_index(TySlice)"), + ty::Slice(_elem_ty) => unimplemented!("place_index(TySlice)"), _ => bug!("place_index({:?})", layout.ty), } } diff --git a/src/constant.rs b/src/constant.rs index 10a59560ff55c..f7bfdaf2d55d1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -93,19 +93,19 @@ fn trans_const_value<'a, 'tcx: 'a>( let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); match ty.sty { - TypeVariants::TyBool => { - let bits = const_.val.to_bits(layout.size).unwrap(); + ty::Bool => { + let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as u64 as i64) } - TypeVariants::TyUint(_) => { - let bits = const_.val.to_bits(layout.size).unwrap(); + ty::Uint(_) => { + let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as u64 as i64) } - TypeVariants::TyInt(_) => { - let bits = const_.val.to_bits(layout.size).unwrap(); + ty::Int(_) => { + let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as i128 as i64) } - TypeVariants::TyFnDef(def_id, substs) => { + ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), ); @@ -120,7 +120,7 @@ fn trans_const_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> CPlace<'tcx> { - let alloc = fx.tcx.const_value_to_allocation(const_); + let alloc = fx.tcx.const_to_allocation(const_); //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); fx.constants.todo.insert(TodoItem::Alloc(alloc_id)); diff --git a/src/lib.rs b/src/lib.rs index 7ea6abe03a4b9..3b98d03367076 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ use rustc::middle::cstore::MetadataLoader; use rustc::session::{config::OutputFilenames, CompileIncomplete}; use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; -use rustc_codegen_utils::link::{build_link_meta, out_filename}; +use rustc_codegen_utils::link::out_filename; use rustc_data_structures::svh::Svh; use syntax::symbol::Symbol; @@ -66,7 +66,7 @@ mod prelude { pub use rustc::ty::layout::{self, LayoutOf, Size, TyLayout}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, - TypeAndMut, TypeFoldable, TypeVariants, + TypeAndMut, TypeFoldable, }; pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, @@ -75,7 +75,7 @@ mod prelude { }; pub use rustc_mir::monomorphize::{collector, MonoItem}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; - pub use syntax::codemap::DUMMY_SP; + pub use syntax::source_map::DUMMY_SP; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, @@ -209,8 +209,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.abort_if_errors(); - let link_meta = build_link_meta(tcx.crate_hash(LOCAL_CRATE)); - let metadata = tcx.encode_metadata(&link_meta); + let metadata = tcx.encode_metadata(); let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); From 9dbc727b7254f0951f33b8a485b60841206dd0a0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 24 Aug 2018 14:54:22 +0200 Subject: [PATCH 0183/1566] Rustfmt --- src/base.rs | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/base.rs b/src/base.rs index e0a9ce610b631..f0729cad81db8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -20,11 +20,10 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( MonoItem::Fn(inst) => { let _print_guard = PrintOnPanic(format!("{:?}", inst)); let mir = match inst.def { - InstanceDef::Item(_) - | InstanceDef::DropGlue(_, _) - | InstanceDef::Virtual(_, _) => { + InstanceDef::Item(_) | InstanceDef::DropGlue(_, _) | InstanceDef::Virtual(_, _) => { let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir).unwrap(); + ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) + .unwrap(); mir.into_inner() } InstanceDef::FnPtrShim(_, _) @@ -40,7 +39,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( ::std::fs::write(mir_file_name, mir).unwrap(); trans_fn(tcx, cx.module, &mut cx.ccx, context, inst); - }, + } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.ccx, def_id); } @@ -317,24 +316,16 @@ fn trans_stmt<'a, 'tcx: 'a>( let rhs = trans_operand(fx, rhs); let res = match ty.sty { - ty::Bool => { - trans_bool_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) - } + ty::Bool => trans_bool_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), ty::Uint(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } ty::Int(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) } - ty::Float(_) => { - trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) - } - ty::Char => { - trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) - } - ty::RawPtr(..) => { - trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) - } + ty::Float(_) => trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), + ty::Char => trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), + ty::RawPtr(..) => trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), _ => unimplemented!("binop {:?} for {:?}", bin_op, ty), }; lval.write_cvalue(fx, res); @@ -393,15 +384,12 @@ fn trans_stmt<'a, 'tcx: 'a>( | (ty::RawPtr(..), ty::RawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (ty::RawPtr(..), ty::Uint(_)) - | (ty::FnPtr(..), ty::Uint(_)) + (ty::RawPtr(..), ty::Uint(_)) | (ty::FnPtr(..), ty::Uint(_)) if to_ty.sty == fx.tcx.types.usize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (ty::Uint(_), ty::RawPtr(..)) - if from_ty.sty == fx.tcx.types.usize.sty => - { + (ty::Uint(_), ty::RawPtr(..)) if from_ty.sty == fx.tcx.types.usize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } (ty::Char, ty::Uint(_)) @@ -417,8 +405,7 @@ fn trans_stmt<'a, 'tcx: 'a>( ); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (ty::Int(_), ty::Int(_)) - | (ty::Int(_), ty::Uint(_)) => { + (ty::Int(_), ty::Int(_)) | (ty::Int(_), ty::Uint(_)) => { let from = operand.load_value(fx); let res = crate::common::cton_intcast( fx, @@ -453,8 +440,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = fx.bcx.ins().fcvt_from_uint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (ty::Bool, ty::Uint(_)) - | (ty::Bool, ty::Int(_)) => { + (ty::Bool, ty::Uint(_)) | (ty::Bool, ty::Int(_)) => { let to_ty = fx.cton_type(to_ty).unwrap(); let from = operand.load_value(fx); let res = if to_ty != types::I8 { From e66f012d7921a409e436ff5b13bd7538e33f9be5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 26 Aug 2018 16:28:00 +0200 Subject: [PATCH 0184/1566] Remove stabilized feature gate --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 3b98d03367076..4c1d49deab19c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, macro_at_most_once_rep, iterator_find_map)] +#![feature(rustc_private, macro_at_most_once_rep)] #![allow(intra_doc_link_resolution_failure)] extern crate syntax; From 42887dfdd95aceaa533e7369d3519d4285d465e3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 26 Aug 2018 16:58:52 +0200 Subject: [PATCH 0185/1566] Remove CodegenCx --- src/base.rs | 17 +++++++++-------- src/lib.rs | 49 ++++++++++++++++++++----------------------------- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/base.rs b/src/base.rs index f0729cad81db8..2783f330254b2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -10,11 +10,13 @@ impl Drop for PrintOnPanic { } pub fn trans_mono_item<'a, 'tcx: 'a>( - cx: &mut CodegenCx<'a, 'tcx, impl Backend>, + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + caches: &mut Caches, + ccx: &mut crate::constant::ConstantCx, mono_item: MonoItem<'tcx>, ) { - let tcx = cx.tcx; - let context = &mut cx.context; + let context = &mut caches.context; match mono_item { MonoItem::Fn(inst) => { @@ -30,7 +32,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( | InstanceDef::ClosureOnceShim { .. } | InstanceDef::CloneShim(_, _) => { // FIXME fix write_mir_pretty for these instances - format!("{:#?}", cx.tcx.instance_mir(inst.def)).into_bytes() + format!("{:#?}", tcx.instance_mir(inst.def)).into_bytes() } InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"), }; @@ -38,13 +40,12 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( "target/out/mir/".to_string() + &format!("{:?}", inst.def_id()).replace('/', "@"); ::std::fs::write(mir_file_name, mir).unwrap(); - trans_fn(tcx, cx.module, &mut cx.ccx, context, inst); + trans_fn(tcx, module, ccx, context, inst); } MonoItem::Static(def_id) => { - crate::constant::codegen_static(&mut cx.ccx, def_id); + crate::constant::codegen_static(ccx, def_id); } - MonoItem::GlobalAsm(node_id) => cx - .tcx + MonoItem::GlobalAsm(node_id) => tcx .sess .fatal(&format!("Unimplemented global asm mono item {:?}", node_id)), } diff --git a/src/lib.rs b/src/lib.rs index 4c1d49deab19c..5397f5b48716b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,8 +90,7 @@ mod prelude { pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; pub use crate::common::*; - - pub use crate::{CodegenCx, ModuleTup}; + pub use crate::Caches; pub fn should_codegen(sess: &Session) -> bool { //return true; @@ -103,20 +102,16 @@ mod prelude { use crate::constant::ConstantCx; use crate::prelude::*; -pub struct CodegenCx<'a, 'tcx: 'a, B: Backend + 'static> { - pub tcx: TyCtxt<'a, 'tcx, 'tcx>, - pub module: &'a mut Module, - pub ccx: ConstantCx, - - // Cache +pub struct Caches { pub context: Context, } -pub struct ModuleTup { - #[allow(dead_code)] - jit: Option, - #[allow(dead_code)] - faerie: Option, +impl Caches { + fn new() -> Self { + Caches { + context: Context::new(), + } + } } struct CraneliftCodegenBackend; @@ -360,23 +355,18 @@ fn codegen_mono_items<'a, 'tcx: 'a>( ) { use std::io::Write; - let mut cx = CodegenCx { - tcx, - module, - ccx: ConstantCx::default(), - - context: Context::new(), - }; + let mut caches = Caches::new(); + let mut ccx = ConstantCx::default(); let mut log = ::std::fs::File::create("target/out/log.txt").unwrap(); let before = ::std::time::Instant::now(); for mono_item in mono_items { - let cx = &mut cx; - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(move || { - base::trans_mono_item(cx, *mono_item); + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { + base::trans_mono_item(tcx, module, &mut caches, &mut ccx, *mono_item); })); + if let Err(err) = res { match err.downcast::() { Ok(non_fatal) => { @@ -388,9 +378,9 @@ fn codegen_mono_items<'a, 'tcx: 'a>( } } - maybe_create_entry_wrapper(&mut cx); + maybe_create_entry_wrapper(tcx, module); - cx.ccx.finalize(tcx, cx.module); + ccx.finalize(tcx, module); let after = ::std::time::Instant::now(); println!("time: {:?}", after - before); @@ -410,12 +400,13 @@ pub fn __rustc_codegen_backend() -> Box { /// Create the `main` function which will initialize the rust runtime and call /// users main function. -fn maybe_create_entry_wrapper(cx: &mut CodegenCx) { +fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, +) { use rustc::middle::lang_items::StartFnLangItem; use rustc::session::config::EntryFnType; - let tcx = cx.tcx; - let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { Some((id, _, entry_ty)) => ( tcx.hir.local_def_id(id), @@ -427,7 +418,7 @@ fn maybe_create_entry_wrapper(cx: &mut CodegenCx) { None => return, }; - create_entry_fn(tcx, cx.module, main_def_id, use_start_lang_item);; + create_entry_fn(tcx, module, main_def_id, use_start_lang_item);; fn create_entry_fn<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, From 6f58f94cdb12ba367c37a620e7f2f40228e691b1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 26 Aug 2018 17:14:12 +0200 Subject: [PATCH 0186/1566] Add Caches to FunctionCx --- src/base.rs | 13 ++++++------- src/common.rs | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/base.rs b/src/base.rs index 2783f330254b2..e6302684c5429 100644 --- a/src/base.rs +++ b/src/base.rs @@ -16,8 +16,6 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( ccx: &mut crate::constant::ConstantCx, mono_item: MonoItem<'tcx>, ) { - let context = &mut caches.context; - match mono_item { MonoItem::Fn(inst) => { let _print_guard = PrintOnPanic(format!("{:?}", inst)); @@ -40,7 +38,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( "target/out/mir/".to_string() + &format!("{:?}", inst.def_id()).replace('/', "@"); ::std::fs::write(mir_file_name, mir).unwrap(); - trans_fn(tcx, module, ccx, context, inst); + trans_fn(tcx, module, ccx, caches, inst); } MonoItem::Static(def_id) => { crate::constant::codegen_static(ccx, def_id); @@ -55,7 +53,7 @@ fn trans_fn<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, constants: &mut crate::constant::ConstantCx, - context: &mut Context, + caches: &mut Caches, instance: Instance<'tcx>, ) { // Step 1. Get mir @@ -94,6 +92,7 @@ fn trans_fn<'a, 'tcx: 'a>( local_map: HashMap::new(), comments: HashMap::new(), constants, + caches, top_nop: None, }; @@ -117,9 +116,9 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 9. Define function // TODO: cranelift doesn't yet support some of the things needed if should_codegen(tcx.sess) { - context.func = func; - module.define_function(func_id, context).unwrap(); - context.clear(); + caches.context.func = func; + module.define_function(func_id, &mut caches.context).unwrap(); + caches.context.clear(); } } diff --git a/src/common.rs b/src/common.rs index 7a8cc53b8d5ac..8f0236fb7f00e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -427,6 +427,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub local_map: HashMap>, pub comments: HashMap, pub constants: &'a mut crate::constant::ConstantCx, + pub caches: &'a mut Caches, /// add_global_comment inserts a comment here pub top_nop: Option, From 8111eee37a6e60abc49e95646bb654efd3af0fb6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Aug 2018 20:14:56 +0200 Subject: [PATCH 0187/1566] Rustup to rustc 1.30.0-nightly (02cb8f2a4 2018-08-29) --- src/base.rs | 4 +++- src/constant.rs | 27 ++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/base.rs b/src/base.rs index e6302684c5429..8627cf66a83ee 100644 --- a/src/base.rs +++ b/src/base.rs @@ -117,7 +117,9 @@ fn trans_fn<'a, 'tcx: 'a>( // TODO: cranelift doesn't yet support some of the things needed if should_codegen(tcx.sess) { caches.context.func = func; - module.define_function(func_id, &mut caches.context).unwrap(); + module + .define_function(func_id, &mut caches.context) + .unwrap(); caches.context.clear(); } } diff --git a/src/constant.rs b/src/constant.rs index f7bfdaf2d55d1..b5ce5f198f41f 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,8 +1,10 @@ use cranelift_module::*; use crate::prelude::*; -use rustc::mir::interpret::{read_target_uint, AllocId, AllocType, ConstValue, GlobalId}; +use rustc::mir::interpret::{ + read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, +}; use rustc::ty::Const; -use rustc_mir::interpret::{CompileTimeEvaluator, Memory}; +use rustc_mir::interpret::{CompileTimeEvaluator, EvalContext, Memory, MemoryKind}; use syntax::ast::Mutability as AstMutability; #[derive(Default)] @@ -120,7 +122,22 @@ fn trans_const_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> CPlace<'tcx> { - let alloc = fx.tcx.const_to_allocation(const_); + // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 + let result = || -> EvalResult<'tcx, &'tcx Allocation> { + let mut ecx = EvalContext::new( + fx.tcx.at(DUMMY_SP), + ty::ParamEnv::reveal_all(), + CompileTimeEvaluator, + (), + ); + let op = ecx.const_to_op(const_)?; + let ptr = ecx.allocate(op.layout, MemoryKind::Stack)?; + ecx.copy_op(op, ptr.into())?; + let alloc = ecx.memory.get(ptr.to_ptr()?.alloc_id)?; + Ok(fx.tcx.intern_const_alloc(alloc.clone())) + }; + let alloc = result().expect("unable to convert ConstValue to Allocation"); + //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); fx.constants.todo.insert(TodoItem::Alloc(alloc_id)); @@ -190,7 +207,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( let const_ = tcx.const_eval(ParamEnv::reveal_all().and(cid)).unwrap(); let alloc = match const_.val { - ConstValue::ByRef(alloc, n) if n.bytes() == 0 => alloc, + ConstValue::ByRef(_alloc_id, alloc, n) if n.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", const_), }; @@ -208,7 +225,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( data_ctx.define( alloc.bytes.to_vec().into_boxed_slice(), - match alloc.runtime_mutability { + match alloc.mutability { AstMutability::Mutable => Writability::Writable, AstMutability::Immutable => Writability::Readonly, }, From 0117b7872ad9be5e9484bd27eb271022d31ce82e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 23 Aug 2018 11:03:43 +0200 Subject: [PATCH 0188/1566] Don't grep away parts of log --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index ce8359698f0d0..a3d31c6c7706b 100755 --- a/build.sh +++ b/build.sh @@ -41,4 +41,4 @@ gcc target/out/mini_core.o target/out/mini_core_hello_world.o -o target/out/mini ./target/out/mini_core_hello_world $RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) -cat target/out/log.txt | sort | uniq -c | grep -v "rval unsize move" | grep -v "rval len" +cat target/out/log.txt | sort | uniq -c From b5082f7da85303e5aee97949e98fd137fa77f845 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Aug 2018 15:38:10 +0200 Subject: [PATCH 0189/1566] Support unsized types --- examples/example.rs | 4 +- src/abi.rs | 13 +++-- src/base.rs | 11 +---- src/common.rs | 115 ++++++++++++++++++++++++++++++++++++++++---- src/constant.rs | 3 +- src/lib.rs | 2 +- 6 files changed, 123 insertions(+), 25 deletions(-) diff --git a/examples/example.rs b/examples/example.rs index 6d84fb148c0fa..efe07ca2eccbf 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -141,9 +141,9 @@ unsafe fn call_uninit() -> u8 { } // TODO: enable when fat pointers are supported -/*unsafe fn deref_str_ptr(s: *const str) -> &'static str { +unsafe fn deref_str_ptr(s: *const str) -> &'static str { &*s -}*/ +} fn use_array(arr: [u8; 3]) -> u8 { arr[1] diff --git a/src/abi.rs b/src/abi.rs index b5967e7341902..112d87743feab 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -28,6 +28,11 @@ fn get_pass_mode<'a, 'tcx: 'a>( ty: Ty<'tcx>, is_return: bool, ) -> PassMode { + assert!( + !tcx.layout_of(ParamEnv::reveal_all().and(ty)) + .unwrap() + .is_unsized() + ); if ty.sty == tcx.mk_nil().sty { if is_return { //if false { @@ -312,7 +317,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( //unimplemented!("pass mode nopass"); fx.local_map.insert( RETURN_PLACE, - CPlace::Addr(null, fx.layout_of(fx.return_type())), + CPlace::Addr(null, None, fx.layout_of(fx.return_type())), ); } PassMode::ByVal(ret_ty) => { @@ -321,8 +326,10 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( .insert(RETURN_PLACE, CPlace::Var(RETURN_PLACE, ret_layout)); } PassMode::ByRef => { - fx.local_map - .insert(RETURN_PLACE, CPlace::Addr(ret_param.unwrap(), ret_layout)); + fx.local_map.insert( + RETURN_PLACE, + CPlace::Addr(ret_param.unwrap(), None, ret_layout), + ); } } diff --git a/src/base.rs b/src/base.rs index 8627cf66a83ee..8cbdf6db855a0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -309,8 +309,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } Rvalue::Ref(_, _, place) => { let place = trans_place(fx, place); - let addr = place.expect_addr(); - lval.write_cvalue(fx, CValue::ByVal(addr, dest_layout)); + place.write_place_ref(fx, lval); } Rvalue::BinaryOp(bin_op, lhs, rhs) => { let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); @@ -893,13 +892,7 @@ pub fn trans_place<'a, 'tcx: 'a>( Place::Projection(projection) => { let base = trans_place(fx, &projection.base); match projection.elem { - ProjectionElem::Deref => { - let layout = fx.layout_of(place.ty(&*fx.mir, fx.tcx).to_ty(fx.tcx)); - if layout.is_unsized() { - unimpl!("Unsized places are not yet implemented"); - } - CPlace::Addr(base.to_cvalue(fx).load_value(fx), layout) - } + ProjectionElem::Deref => base.place_deref(fx), ProjectionElem::Field(field, _ty) => base.place_field(fx, field), ProjectionElem::Index(local) => { let index = fx.get_local_place(local).to_cvalue(fx).load_value(fx); diff --git a/src/common.rs b/src/common.rs index 8f0236fb7f00e..768c8cd25e1ab 100644 --- a/src/common.rs +++ b/src/common.rs @@ -19,6 +19,24 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } } +fn scalar_to_cton_type(tcx: TyCtxt, scalar: &Scalar) -> Type { + match scalar.value.size(tcx).bits() { + 8 => types::I8, + 16 => types::I16, + 32 => types::I32, + 64 => types::I64, + size => bug!("Unsupported scalar size {}", size), + } +} + +fn ptr_referee<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> { + match ty.sty { + ty::Ref(_, ty, _) => ty, + ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => ty, + _ => bug!("{:?}", ty), + } +} + pub fn cton_type_from_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>, @@ -224,18 +242,19 @@ impl<'tcx> CValue<'tcx> { #[derive(Debug, Copy, Clone)] pub enum CPlace<'tcx> { Var(Local, TyLayout<'tcx>), - Addr(Value, TyLayout<'tcx>), + Addr(Value, Option, TyLayout<'tcx>), } impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { - CPlace::Var(_, layout) | CPlace::Addr(_, layout) => layout, + CPlace::Var(_, layout) | CPlace::Addr(_, _, layout) => layout, } } pub fn temp(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> CPlace<'tcx> { let layout = fx.layout_of(ty); + assert!(!layout.is_unsized()); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -245,6 +264,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { fx.bcx .ins() .stack_addr(fx.module.pointer_type(), stack_slot, 0), + None, layout, ) } @@ -255,10 +275,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ty: Ty<'tcx>, ) -> CPlace<'tcx> { let layout = fx.layout_of(ty); + assert!(!layout.is_unsized()); CPlace::Addr( fx.bcx .ins() .stack_addr(fx.module.pointer_type(), stack_slot, 0), + None, layout, ) } @@ -266,13 +288,17 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { match self { CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(mir_var(var)), layout), - CPlace::Addr(addr, layout) => CValue::ByRef(addr, layout), + CPlace::Addr(addr, extra, layout) => { + assert!(extra.is_none(), "unsized values are not yet supported"); + CValue::ByRef(addr, layout) + } } } pub fn expect_addr(self) -> Value { match self { - CPlace::Addr(addr, _layout) => addr, + CPlace::Addr(addr, None, _layout) => addr, + CPlace::Addr(_, _, _) => bug!("Expected sized CPlace::Addr, found {:?}", self), CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } @@ -308,7 +334,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let data = from.load_value(fx); fx.bcx.def_var(mir_var(var), data) } - CPlace::Addr(addr, layout) => { + CPlace::Addr(addr, None, layout) => { let size = layout.size.bytes() as i32; match from { @@ -346,6 +372,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } } + CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), } } @@ -354,11 +381,14 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { fx: &mut FunctionCx<'a, 'tcx, impl Backend>, field: mir::Field, ) -> CPlace<'tcx> { - let base = self.expect_addr(); let layout = self.layout(); + if layout.is_unsized() { + unimpl!("unsized place_field"); + } + let base = self.expect_addr(); let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); - CPlace::Addr(field_ptr, field_layout) + CPlace::Addr(field_ptr, None, field_layout) } pub fn place_index( @@ -368,6 +398,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ) -> CPlace<'tcx> { let addr = self.expect_addr(); let layout = self.layout(); + if layout.is_unsized() { + unimpl!("unsized place_field"); + } + match layout.ty.sty { ty::Array(elem_ty, _) => { let elem_layout = fx.layout_of(elem_ty); @@ -375,17 +409,80 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { .bcx .ins() .imul_imm(index, elem_layout.size.bytes() as i64); - CPlace::Addr(fx.bcx.ins().iadd(addr, offset), elem_layout) + CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) } ty::Slice(_elem_ty) => unimplemented!("place_index(TySlice)"), _ => bug!("place_index({:?})", layout.ty), } } + pub fn place_deref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CPlace<'tcx> { + let inner_layout = fx.layout_of(ptr_referee(self.layout().ty)); + if !inner_layout.is_unsized() { + CPlace::Addr(self.to_cvalue(fx).load_value(fx), None, inner_layout) + } else { + match self.layout().abi { + Abi::ScalarPair(ref a, ref b) => { + let addr = self.expect_addr(); + let ptr = + fx.bcx + .ins() + .load(scalar_to_cton_type(fx.tcx, a), MemFlags::new(), addr, 0); + let extra = fx.bcx.ins().load( + scalar_to_cton_type(fx.tcx, b), + MemFlags::new(), + addr, + a.value.size(fx.tcx).bytes() as u32 as i32, + ); + println!( + "unsized deref: ptr: {:?} extra: {:?} self: {:?}", + ptr, extra, self + ); + CPlace::Addr(ptr, Some(extra), inner_layout) + } + _ => bug!( + "Fat ptr doesn't have abi ScalarPair, but it has {:?}", + self.layout().abi + ), + } + } + } + + pub fn write_place_ref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + if !self.layout().is_unsized() { + let ptr = CValue::ByVal(self.expect_addr(), dest.layout()); + dest.write_cvalue(fx, ptr); + } else { + match self { + CPlace::Var(_, _) => bug!("expected CPlace::Addr found CPlace::Var"), + CPlace::Addr(value, extra, _) => match dest.layout().abi { + Abi::ScalarPair(ref a, _) => { + fx.bcx + .ins() + .store(MemFlags::new(), value, dest.expect_addr(), 0); + fx.bcx.ins().store( + MemFlags::new(), + extra.expect("unsized type without metadata"), + dest.expect_addr(), + a.value.size(fx.tcx).bytes() as u32 as i32, + ); + } + _ => bug!( + "Non ScalarPair abi {:?} in write_place_ref dest", + dest.layout().abi + ), + }, + } + } + } + pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { match self { CPlace::Var(var, _) => CPlace::Var(var, layout), - CPlace::Addr(addr, _) => CPlace::Addr(addr, layout), + CPlace::Addr(addr, extra, _) => { + assert!(!layout.is_unsized()); + CPlace::Addr(addr, extra, layout) + } } } diff --git a/src/constant.rs b/src/constant.rs index b5ce5f198f41f..f912f435fcbf7 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -179,7 +179,8 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( .ins() .global_value(fx.module.pointer_type(), local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); - CPlace::Addr(global_ptr, layout) + assert!(!layout.is_unsized(), "unsized statics aren't supported"); + CPlace::Addr(global_ptr, None, layout) } fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( diff --git a/src/lib.rs b/src/lib.rs index 5397f5b48716b..fa74f928ddb45 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,7 @@ mod prelude { pub use rustc::mir::interpret::AllocId; pub use rustc::mir::*; pub use rustc::session::{config::CrateType, Session}; - pub use rustc::ty::layout::{self, LayoutOf, Size, TyLayout}; + pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, From 12282a8ebc2404add07224a74b872cecf6d602da Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Aug 2018 15:38:56 +0200 Subject: [PATCH 0190/1566] Implement unsize array -> slice and trait object -> trait object --- examples/example.rs | 4 ++++ examples/mini_core_hello_world.rs | 3 ++- src/base.rs | 3 ++- src/common.rs | 37 +++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/examples/example.rs b/examples/example.rs index efe07ca2eccbf..dfca3142301dc 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -153,6 +153,10 @@ fn repeat_array() -> [u8; 3] { [0; 3] } +fn array_as_slice(arr: &[u8; 3]) -> &[u8] { + arr +} + /*unsafe fn use_ctlz_nonzero(a: u16) -> u16 { intrinsics::ctlz_nonzero(a) }*/ diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 19cc727fb55ee..c775beef2f09e 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -43,7 +43,8 @@ static NUM_REF: &'static u8 = unsafe { &NUM }; fn main() { unsafe { - let (ptr, _): (*const u8, usize) = intrinsics::transmute("Hello!\0"); + let slice: &[u8] = b"Hello!\0" as &[u8; 7]; + let ptr: *const u8 = slice as *const [u8] as *const u8; puts(ptr); } diff --git a/src/base.rs b/src/base.rs index 8cbdf6db855a0..9b44cd2e4b73d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -458,7 +458,8 @@ fn trans_stmt<'a, 'tcx: 'a>( unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty) } Rvalue::Cast(CastKind::Unsize, operand, ty) => { - unimpl!("rval unsize {:?} {:?}", operand, ty); + let operand = trans_operand(fx, operand); + operand.unsize_value(fx, lval); } Rvalue::Discriminant(place) => { let place = trans_place(fx, place).to_cvalue(fx); diff --git a/src/common.rs b/src/common.rs index 768c8cd25e1ab..b785177251fa4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -216,6 +216,43 @@ impl<'tcx> CValue<'tcx> { CValue::ByRef(field_ptr, field_layout) } + pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + if self.layout().ty == dest.layout().ty { + dest.write_cvalue(fx, self); // FIXME this shouldn't happen (rust-lang/rust#53602) + return; + } + match &self.layout().ty.sty { + ty::Ref(_, ty, _) | ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { + let (ptr, extra) = match ptr_referee(dest.layout().ty).sty { + ty::Slice(slice_elem_ty) => match ty.sty { + ty::Array(array_elem_ty, size) => { + assert_eq!(slice_elem_ty, array_elem_ty); + let ptr = self.load_value(fx); + let extra = fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), size.unwrap_usize(fx.tcx) as i64); + (ptr, extra) + } + _ => bug!("unsize non array {:?} to slice", ty), + }, + ty::Dynamic(_, _) => match ty.sty { + ty::Dynamic(_, _) => self.load_value_pair(fx), + _ => unimpl!("unsize of type ... to {:?}", dest.layout().ty), + }, + _ => bug!( + "unsize of type {:?} to {:?}", + self.layout().ty, + dest.layout().ty + ), + }; + println!("ty {:?}", self.layout().ty); + dest.write_cvalue(fx, CValue::ByValPair(ptr, extra, dest.layout())); + } + ty => unimpl!("unsize of non ptr {:?}", ty), + } + } + pub fn const_val<'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, From fa4a37759be06c2b96c133cfc0f85b7cf2ce00b4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Aug 2018 17:58:25 +0200 Subject: [PATCH 0191/1566] Rvalue::Len --- src/base.rs | 10 +++++++++- src/common.rs | 15 ++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/base.rs b/src/base.rs index 9b44cd2e4b73d..c0ea7644f9037 100644 --- a/src/base.rs +++ b/src/base.rs @@ -474,7 +474,15 @@ fn trans_stmt<'a, 'tcx: 'a>( to.write_cvalue(fx, operand); } } - Rvalue::Len(lval) => unimpl!("rval len {:?}", lval), + Rvalue::Len(place) => { + let place = trans_place(fx, place); + let size = match place { + CPlace::Addr(_, size, _) => size.unwrap(), + CPlace::Var(_, _) => unreachable!(), + }; + let usize_layout = fx.layout_of(fx.tcx.types.usize); + lval.write_cvalue(fx, CValue::ByVal(size, usize_layout)); + } Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), Rvalue::NullaryOp(NullOp::SizeOf, ty) => { assert!( diff --git a/src/common.rs b/src/common.rs index b785177251fa4..9bd3e823fcb34 100644 --- a/src/common.rs +++ b/src/common.rs @@ -433,23 +433,20 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { fx: &mut FunctionCx<'a, 'tcx, impl Backend>, index: Value, ) -> CPlace<'tcx> { - let addr = self.expect_addr(); - let layout = self.layout(); - if layout.is_unsized() { - unimpl!("unsized place_field"); - } - - match layout.ty.sty { + match self.layout().ty.sty { ty::Array(elem_ty, _) => { let elem_layout = fx.layout_of(elem_ty); + let offset = fx .bcx .ins() .imul_imm(index, elem_layout.size.bytes() as i64); + + let addr = self.expect_addr(); CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) } - ty::Slice(_elem_ty) => unimplemented!("place_index(TySlice)"), - _ => bug!("place_index({:?})", layout.ty), + ty::Slice(_elem_ty) => unimpl!("place_index(TySlice)"), + _ => bug!("place_index({:?})", self.layout().ty), } } From 9878eea61c7a715d798640e932d9752043599ee3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Aug 2018 11:22:48 +0200 Subject: [PATCH 0192/1566] Implement indexing for slices --- examples/example.rs | 4 ++++ examples/mini_core.rs | 8 ++++++++ src/common.rs | 29 ++++++++++++++++------------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/examples/example.rs b/examples/example.rs index dfca3142301dc..5df8e69efd3e9 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -180,3 +180,7 @@ fn make_array() -> [u8; 3] { fn some_promoted_tuple() -> &'static (&'static str, &'static str) { &("abc", "some") } + +fn index_slice(s: &[u8]) -> u8 { + s[2] +} diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 7813f8a4c34fb..2eb2e95025654 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -207,3 +207,11 @@ impl Index for [T; 3] { &self[index] } } + +impl Index for [T] { + type Output = T; + + fn index(&self, index: usize) -> &Self::Output { + &self[index] + } +} diff --git a/src/common.rs b/src/common.rs index 9bd3e823fcb34..fd98d83221a93 100644 --- a/src/common.rs +++ b/src/common.rs @@ -433,21 +433,24 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { fx: &mut FunctionCx<'a, 'tcx, impl Backend>, index: Value, ) -> CPlace<'tcx> { - match self.layout().ty.sty { - ty::Array(elem_ty, _) => { - let elem_layout = fx.layout_of(elem_ty); + let (elem_layout, addr) = match self.layout().ty.sty { + ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.expect_addr()), + ty::Slice(elem_ty) => ( + fx.layout_of(elem_ty), + match self { + CPlace::Addr(addr, _, _) => addr, + CPlace::Var(_, _) => bug!("Expected CPlace::Addr found CPlace::Var"), + }, + ), + _ => bug!("place_index({:?})", self.layout().ty), + }; - let offset = fx - .bcx - .ins() - .imul_imm(index, elem_layout.size.bytes() as i64); + let offset = fx + .bcx + .ins() + .imul_imm(index, elem_layout.size.bytes() as i64); - let addr = self.expect_addr(); - CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) - } - ty::Slice(_elem_ty) => unimpl!("place_index(TySlice)"), - _ => bug!("place_index({:?})", self.layout().ty), - } + CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) } pub fn place_deref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CPlace<'tcx> { From 16790d54219efc70e82468dff25166ddead485a4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Aug 2018 20:48:42 +0200 Subject: [PATCH 0193/1566] Update patch 0004 to latest libcore --- ...nd-task-modules-because-they-contain.patch | 76 ++++++++++--------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/0004-Disable-future-and-task-modules-because-they-contain.patch b/0004-Disable-future-and-task-modules-because-they-contain.patch index 669927ddcce16..422cacade9b71 100644 --- a/0004-Disable-future-and-task-modules-because-they-contain.patch +++ b/0004-Disable-future-and-task-modules-because-they-contain.patch @@ -1,18 +1,27 @@ -From 439444eb7d5557daa5e8cfafd1317816fefdad70 Mon Sep 17 00:00:00 2001 +From 9db209102bf5f7850ccd456be0d5af09405ee950 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Wed, 8 Aug 2018 15:51:42 +0200 +Date: Thu, 30 Aug 2018 20:47:12 +0200 Subject: [PATCH] Disable future and task modules, because they contain unsized types --- - src/libcore/lib.rs | 2 ++ - src/libcore/mem.rs | 6 ++++-- + src/libcore/lib.rs | 4 +++- + src/libcore/option.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 71fcff2..7dcbb4b 100644 +index 9b64b7d..9d2e230 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs +@@ -188,7 +188,7 @@ pub mod cell; + pub mod char; + pub mod panic; + pub mod panicking; +-pub mod pin; ++//pub mod pin; + pub mod iter; + pub mod option; + pub mod raw; @@ -202,9 +202,11 @@ pub mod time; pub mod unicode; @@ -25,38 +34,35 @@ index 71fcff2..7dcbb4b 100644 /* Heap memory allocator trait */ #[allow(missing_docs)] -diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 642fffa..f5a22ab 100644 ---- a/src/libcore/mem.rs -+++ b/src/libcore/mem.rs -@@ -18,12 +18,12 @@ - use clone; - use cmp; - use fmt; --use future::{Future, UnsafeFutureObj}; -+//use future::{Future, UnsafeFutureObj}; - use hash; - use intrinsics; - use marker::{Copy, PhantomData, Sized, Unpin, Unsize}; - use ptr; --use task::{Context, Poll}; -+//use task::{Context, Poll}; - use ops::{Deref, DerefMut, CoerceUnsized}; +diff --git a/src/libcore/option.rs b/src/libcore/option.rs +index 3879abb..16204a8 100644 +--- a/src/libcore/option.rs ++++ b/src/libcore/option.rs +@@ -147,7 +147,7 @@ - #[stable(feature = "rust1", since = "1.0.0")] -@@ -1148,6 +1148,7 @@ impl<'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for PinM - #[unstable(feature = "pin", issue = "49150")] - impl<'a, T: ?Sized> Unpin for PinMut<'a, T> {} + use iter::{FromIterator, FusedIterator, TrustedLen}; + use {hint, mem, ops::{self, Deref}}; +-use pin::PinMut; ++//use pin::PinMut; -+/* - #[unstable(feature = "futures_api", issue = "50547")] - unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinMut<'a, F> - where F: Future + 'a -@@ -1162,3 +1163,4 @@ unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinMut<'a, F> + // Note that this is not a lang item per se, but it has a hidden dependency on + // `Iterator`, which is one. The compiler assumes that the `next` method of +@@ -270,6 +270,7 @@ impl Option { + } + } - unsafe fn drop(_ptr: *mut ()) {} - } -+*/ ++ /* + /// Converts from `Option` to `Option>` + #[inline] + #[unstable(feature = "pin", issue = "49150")] +@@ -278,6 +279,7 @@ impl Option { + PinMut::get_mut_unchecked(self).as_mut().map(|x| PinMut::new_unchecked(x)) + } + } ++ */ + + ///////////////////////////////////////////////////////////////////////// + // Getting to contained values -- -2.15.2 (Apple Git-101.1) +2.11.0 From 0cfe31403aa656b37911113cb916c042d168c7cc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Sep 2018 10:57:29 +0200 Subject: [PATCH 0194/1566] Rustup to rustc 1.30.0-nightly (28bcffead 2018-09-01) --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index f912f435fcbf7..4a8150802784b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -246,7 +246,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( }; let reloc_offset = { - let endianness = memory.endianness(); + let endianness = tcx.data_layout.endian; let offset = offset.bytes() as usize; let ptr_size = tcx.data_layout.pointer_size; let bytes = &alloc.bytes[offset..offset + ptr_size.bytes() as usize]; From 42066522fb19c7aa45d4fe75c6d5b860b29c7607 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 31 Aug 2018 19:50:26 +0200 Subject: [PATCH 0195/1566] Perform some optimizations --- .gitignore | 2 ++ src/base.rs | 57 ++++++++++++++++++++++++++++----------------------- src/common.rs | 5 ----- src/lib.rs | 3 ++- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 75bcfff8c53c0..e4b53d201ac08 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ **/*.rs.bk *.rlib *.o +perf.data +perf.data.old diff --git a/src/base.rs b/src/base.rs index c0ea7644f9037..1045275728165 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,10 +1,10 @@ use crate::prelude::*; -struct PrintOnPanic(String); -impl Drop for PrintOnPanic { +struct PrintOnPanic String>(F); +impl String> Drop for PrintOnPanic { fn drop(&mut self) { if ::std::thread::panicking() { - println!("{}", self.0); + println!("{}", (self.0)()); } } } @@ -18,25 +18,26 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( ) { match mono_item { MonoItem::Fn(inst) => { - let _print_guard = PrintOnPanic(format!("{:?}", inst)); - let mir = match inst.def { - InstanceDef::Item(_) | InstanceDef::DropGlue(_, _) | InstanceDef::Virtual(_, _) => { - let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) - .unwrap(); - mir.into_inner() - } - InstanceDef::FnPtrShim(_, _) - | InstanceDef::ClosureOnceShim { .. } - | InstanceDef::CloneShim(_, _) => { - // FIXME fix write_mir_pretty for these instances - format!("{:#?}", tcx.instance_mir(inst.def)).into_bytes() + let _inst_guard = PrintOnPanic(|| format!("{:?}", inst)); + let _mir_guard = PrintOnPanic(|| { + match inst.def { + InstanceDef::Item(_) + | InstanceDef::DropGlue(_, _) + | InstanceDef::Virtual(_, _) => { + let mut mir = ::std::io::Cursor::new(Vec::new()); + ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) + .unwrap(); + String::from_utf8(mir.into_inner()).unwrap() + } + InstanceDef::FnPtrShim(_, _) + | InstanceDef::ClosureOnceShim { .. } + | InstanceDef::CloneShim(_, _) => { + // FIXME fix write_mir_pretty for these instances + format!("{:#?}", tcx.instance_mir(inst.def)) + } + InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"), } - InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"), - }; - let mir_file_name = - "target/out/mir/".to_string() + &format!("{:?}", inst.def_id()).replace('/', "@"); - ::std::fs::write(mir_file_name, mir).unwrap(); + }); trans_fn(tcx, module, ccx, caches, inst); } @@ -103,12 +104,16 @@ fn trans_fn<'a, 'tcx: 'a>( fx.bcx.seal_all_blocks(); fx.bcx.finalize(); - // Step 7. Print function to terminal for debugging + // Step 7. Write function to file for debugging let mut writer = crate::pretty_clif::CommentWriter(fx.comments); + let mut cton = String::new(); - ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None).unwrap(); - let clif_file_name = "target/out/clif/".to_string() + &tcx.symbol_name(instance).as_str(); - ::std::fs::write(clif_file_name, cton.as_bytes()).unwrap(); + if cfg!(debug_assertions) { + ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None) + .unwrap(); + let clif_file_name = "target/out/clif/".to_string() + &tcx.symbol_name(instance).as_str(); + ::std::fs::write(clif_file_name, cton.as_bytes()).unwrap(); + } // Step 8. Verify function verify_func(tcx, writer, &func); @@ -247,7 +252,7 @@ fn trans_stmt<'a, 'tcx: 'a>( cur_ebb: Ebb, stmt: &Statement<'tcx>, ) { - let _print_guard = PrintOnPanic(format!("stmt {:?}", stmt)); + let _print_guard = PrintOnPanic(|| format!("stmt {:?}", stmt)); let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); fx.add_comment(inst, format!("{:?}", stmt)); diff --git a/src/common.rs b/src/common.rs index fd98d83221a93..3c7afe774af53 100644 --- a/src/common.rs +++ b/src/common.rs @@ -246,7 +246,6 @@ impl<'tcx> CValue<'tcx> { dest.layout().ty ), }; - println!("ty {:?}", self.layout().ty); dest.write_cvalue(fx, CValue::ByValPair(ptr, extra, dest.layout())); } ty => unimpl!("unsize of non ptr {:?}", ty), @@ -471,10 +470,6 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { addr, a.value.size(fx.tcx).bytes() as u32 as i32, ); - println!( - "unsized deref: ptr: {:?} extra: {:?} self: {:?}", - ptr, extra, self - ); CPlace::Addr(ptr, Some(extra), inner_layout) } _ => bug!( diff --git a/src/lib.rs b/src/lib.rs index fa74f928ddb45..4d04b7761fd29 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,6 +361,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( let mut log = ::std::fs::File::create("target/out/log.txt").unwrap(); let before = ::std::time::Instant::now(); + println!("[codegen mono items] start"); for mono_item in mono_items { let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { @@ -383,7 +384,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( ccx.finalize(tcx, module); let after = ::std::time::Instant::now(); - println!("time: {:?}", after - before); + println!("[codegen mono items] end time: {:?}", after - before); } fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { From 8181149de2ac1899f294759b17fde3adccf30d73 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Sep 2018 15:22:04 +0200 Subject: [PATCH 0196/1566] Replace infinite loop in mini_core::panic with intrinsic::abort --- examples/mini_core.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 2eb2e95025654..7b4eccb571329 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -168,7 +168,9 @@ pub trait FnMut: FnOnce { #[lang = "panic"] pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { - loop {} + unsafe { + intrinsics::abort(); + } } #[lang = "eh_personality"] @@ -186,6 +188,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { pub mod intrinsics { extern "rust-intrinsic" { + pub fn abort() -> !; pub fn size_of() -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; From 6f52a1937d24238ae83bfa746a09f466c3cedb3d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 31 Aug 2018 19:50:26 +0200 Subject: [PATCH 0197/1566] Improve build.sh --- build.sh | 59 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/build.sh b/build.sh index a3d31c6c7706b..eb17c716f4af4 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -cargo build || exit 1 +set -e unamestr=`uname` if [[ "$unamestr" == 'Linux' ]]; then @@ -14,31 +14,58 @@ fi extract_data() { pushd target/out/ - ar x $1 data.o && - chmod +rw data.o && + ar x $1 data.o + chmod +rw data.o mv data.o $2 popd } -RUSTC="rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.$dylib_ext -L crate=target/out --out-dir target/out" +link_and_run() { + target=$1 + shift + pushd target/out + gcc $@ -o $target + ./$target +} + +build_lib() { + SHOULD_CODEGEN=1 $RUSTC $2 --crate-name $1 --crate-type lib + extract_data lib$1.rlib $1.o +} -rm -r target/out -mkdir -p target/out/mir +run_bin() { + SHOULD_RUN=1 $RUSTC $1 --crate-type bin +} + +build_example_bin() { + $RUSTC $2 --crate-name $1 --crate-type bin + extract_data $1 $1.o + + link_and_run $1 mini_core.o $1.o +} + +if [[ "$1" == "--release" ]]; then + channel='release' + cargo build --release +else + channel='debug' + cargo build +fi + +RUSTC="rustc -Zcodegen-backend=$(pwd)/target/$channel/librustc_codegen_cranelift.$dylib_ext -Cpanic=abort -L crate=target/out --out-dir target/out" + +rm -r target/out || true mkdir -p target/out/clif -SHOULD_CODEGEN=1 $RUSTC examples/mini_core.rs --crate-name mini_core --crate-type lib && -extract_data libmini_core.rlib mini_core.o && +build_lib mini_core examples/mini_core.rs -$RUSTC examples/example.rs --crate-type lib && +$RUSTC examples/example.rs --crate-type lib # SimpleJIT is broken -#SHOULD_RUN=1 $RUSTC examples/mini_core_hello_world.rs --crate-type bin && - -$RUSTC examples/mini_core_hello_world.rs --crate-type bin && -extract_data mini_core_hello_world mini_core_hello_world.o && +# run_bin examples/mini_core_hello_world.rs -gcc target/out/mini_core.o target/out/mini_core_hello_world.o -o target/out/mini_core_hello_world || exit 1 -./target/out/mini_core_hello_world +build_example_bin mini_core_hello_world examples/mini_core_hello_world.rs -$RUSTC target/libcore/src/libcore/lib.rs --color=always --crate-type lib -Cincremental=target/incremental 2>&1 | (head -n 20; echo "===="; tail -n 1000) +time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core -Cincremental=target/incremental_core cat target/out/log.txt | sort | uniq -c +#extract_data libcore.rlib core.o From 4f9807a03728b5c695c14182bf104f296f357531 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Sep 2018 18:50:39 +0200 Subject: [PATCH 0198/1566] [PATCH] Disable all trait object unsizing --- 0006-Disable-all-trait-object-unsizing.patch | 137 +++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 0006-Disable-all-trait-object-unsizing.patch diff --git a/0006-Disable-all-trait-object-unsizing.patch b/0006-Disable-all-trait-object-unsizing.patch new file mode 100644 index 0000000000000..96226073ce3f0 --- /dev/null +++ b/0006-Disable-all-trait-object-unsizing.patch @@ -0,0 +1,137 @@ +From 307aba455c6ee3227d7c522c07761cda19dc716c Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Wed, 29 Aug 2018 14:29:05 +0200 +Subject: [PATCH] Disable all trait object unsizing + +--- + src/libcore/alloc.rs | 2 +- + src/libcore/fmt/builders.rs | 13 ++++++++----- + src/libcore/fmt/mod.rs | 3 ++- + src/libcore/panic.rs | 5 +++-- + src/libcore/slice/mod.rs | 2 +- + 5 files changed, 15 insertions(+), 10 deletions(-) + +diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs +index 35e4eea..28b6e2f 100644 +--- a/src/libcore/alloc.rs ++++ b/src/libcore/alloc.rs +@@ -144,7 +144,7 @@ impl Layout { + #[stable(feature = "alloc_layout", since = "1.28.0")] + #[inline] + pub fn for_value(t: &T) -> Self { +- let (size, align) = (mem::size_of_val(t), mem::align_of_val(t)); ++ let (size, align) = panic!(); //(mem::size_of_val(t), mem::align_of_val(t)); + // See rationale in `new` for why this us using an unsafe variant below + debug_assert!(Layout::from_size_align(size, align).is_ok()); + unsafe { +diff --git a/src/libcore/fmt/builders.rs b/src/libcore/fmt/builders.rs +index 3c5f934..1427ab3 100644 +--- a/src/libcore/fmt/builders.rs ++++ b/src/libcore/fmt/builders.rs +@@ -18,6 +18,7 @@ struct PadAdapter<'a> { + impl<'a> PadAdapter<'a> { + fn wrap<'b, 'c: 'a+'b>(fmt: &'c mut fmt::Formatter, slot: &'b mut Option) + -> fmt::Formatter<'b> { ++ /* + fmt.wrap_buf(move |buf| { + *slot = Some(PadAdapter { + buf, +@@ -25,6 +26,8 @@ impl<'a> PadAdapter<'a> { + }); + slot.as_mut().unwrap() + }) ++ */ ++ panic!(); + } + } + +@@ -107,7 +110,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, + impl<'a, 'b: 'a> DebugStruct<'a, 'b> { + /// Adds a new field to the generated struct output. + #[stable(feature = "debug_builders", since = "1.2.0")] +- pub fn field(&mut self, name: &str, value: &dyn fmt::Debug) -> &mut DebugStruct<'a, 'b> { ++ pub fn field(&mut self, name: &str, value: &impl fmt::Debug) -> &mut DebugStruct<'a, 'b> { + self.result = self.result.and_then(|_| { + let prefix = if self.has_fields { + "," +@@ -204,7 +207,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D + impl<'a, 'b: 'a> DebugTuple<'a, 'b> { + /// Adds a new field to the generated tuple struct output. + #[stable(feature = "debug_builders", since = "1.2.0")] +- pub fn field(&mut self, value: &dyn fmt::Debug) -> &mut DebugTuple<'a, 'b> { ++ pub fn field(&mut self, value: &impl fmt::Debug) -> &mut DebugTuple<'a, 'b> { + self.result = self.result.and_then(|_| { + let (prefix, space) = if self.fields > 0 { + (",", " ") +@@ -258,7 +261,7 @@ struct DebugInner<'a, 'b: 'a> { + } + + impl<'a, 'b: 'a> DebugInner<'a, 'b> { +- fn entry(&mut self, entry: &dyn fmt::Debug) { ++ fn entry(&mut self, entry: &impl fmt::Debug) { + self.result = self.result.and_then(|_| { + if self.is_pretty() { + let mut slot = None; +@@ -340,7 +343,7 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b + impl<'a, 'b: 'a> DebugSet<'a, 'b> { + /// Adds a new entry to the set output. + #[stable(feature = "debug_builders", since = "1.2.0")] +- pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugSet<'a, 'b> { ++ pub fn entry(&mut self, entry: &impl fmt::Debug) -> &mut DebugSet<'a, 'b> { + self.inner.entry(entry); + self + } +@@ -411,7 +414,7 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a, + impl<'a, 'b: 'a> DebugList<'a, 'b> { + /// Adds a new entry to the list output. + #[stable(feature = "debug_builders", since = "1.2.0")] +- pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugList<'a, 'b> { ++ pub fn entry(&mut self, entry: &impl fmt::Debug) -> &mut DebugList<'a, 'b> { + self.inner.entry(entry); + self + } +diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs +index 928f95e..ad33906 100644 +--- a/src/libcore/fmt/mod.rs ++++ b/src/libcore/fmt/mod.rs +@@ -224,7 +224,8 @@ pub trait Write { + } + } + +- write(&mut Adapter(self), args) ++ //write(&mut Adapter(self), args) ++ panic!() + } + } + +diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs +index 17cac5a..27b7dde 100644 +--- a/src/libcore/panic.rs ++++ b/src/libcore/panic.rs +@@ -58,8 +58,9 @@ impl<'a> PanicInfo<'a> { + pub fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>, + location: Location<'a>) + -> Self { +- struct NoPayload; +- PanicInfo { payload: &NoPayload, location, message } ++ //struct NoPayload; ++ //PanicInfo { payload: &NoPayload, location, message } ++ panic!(); + } + + #[doc(hidden)] +diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs +index 88fdd76..8537f0e 100644 +--- a/src/libcore/slice/mod.rs ++++ b/src/libcore/slice/mod.rs +@@ -4003,7 +4003,7 @@ impl SlicePartialEq for [A] + return true; + } + unsafe { +- let size = mem::size_of_val(self); ++ let size = panic!(); //mem::size_of_val(self); + memcmp(self.as_ptr() as *const u8, + other.as_ptr() as *const u8, size) == 0 + } +-- +2.11.0 From 4053b7c8e6e40350528893ac82a7f95016e571e3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 3 Sep 2018 18:29:55 +0200 Subject: [PATCH 0199/1566] Fix build.sh --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index eb17c716f4af4..86cefa83971b1 100755 --- a/build.sh +++ b/build.sh @@ -25,7 +25,8 @@ link_and_run() { shift pushd target/out gcc $@ -o $target - ./$target + sh -c ./$target || true + popd } build_lib() { From e407f39ba89c7ffeed4eba4ffe0688c0f80b5c9f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 4 Sep 2018 18:26:49 +0200 Subject: [PATCH 0200/1566] Rustup to rustc 1.30.0-nightly (0f063aef6 2018-09-03) --- 0005-Disable-some-more-unsupported-stuff-in-libcore.patch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/0005-Disable-some-more-unsupported-stuff-in-libcore.patch b/0005-Disable-some-more-unsupported-stuff-in-libcore.patch index 855e96feedd28..0fff0728c0664 100644 --- a/0005-Disable-some-more-unsupported-stuff-in-libcore.patch +++ b/0005-Disable-some-more-unsupported-stuff-in-libcore.patch @@ -70,8 +70,10 @@ index 5d00949..f077f1d 100644 @@ -2295,7 +2297,9 @@ assert_eq!(m, ", $reversed, "); #[unstable(feature = "reverse_bits", issue = "48763")] + #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - pub fn reverse_bits(self) -> Self { + #[cfg(not(stage0))] + pub const fn reverse_bits(self) -> Self { - unsafe { intrinsics::bitreverse(self as $ActualT) as Self } + // TODO support bitreverse + //unsafe { intrinsics::bitreverse(self as $ActualT) as Self } From 8adc744645f72dce8d3030b3c3cd282c14e8a6de Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 4 Sep 2018 19:04:25 +0200 Subject: [PATCH 0201/1566] Implement Box rvalue --- Readme.md | 1 - examples/mini_core.rs | 11 +++++++++++ examples/mini_core_hello_world.rs | 6 ++++-- src/base.rs | 23 ++++++++++++++++++++++- src/common.rs | 21 ++++++++++----------- 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Readme.md b/Readme.md index 7f0e8d8b3b7db..3c07f08f95159 100644 --- a/Readme.md +++ b/Readme.md @@ -40,7 +40,6 @@ $ ./build.sh * Unsized types * Slice indexing * Sub slice -* Some rvalue's * Inline assembly * Custom sections diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 7b4eccb571329..75059743b9d90 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -45,6 +45,7 @@ unsafe impl Sync for i32 {} unsafe impl Sync for isize {} unsafe impl Sync for char {} unsafe impl<'a, T: ?Sized> Sync for &'a T {} +unsafe impl Sync for [u8; 16] {} #[lang = "freeze"] trait Freeze {} @@ -186,6 +187,16 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { drop_in_place(to_drop); } +#[lang = "owned_box"] +pub struct Box(*mut T); + +static mut MY_TINY_HEAP: [u8; 16] = [0; 16]; + +#[lang = "exchange_malloc"] +unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { + &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8 +} + pub mod intrinsics { extern "rust-intrinsic" { pub fn abort() -> !; diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index c775beef2f09e..a8297fe761303 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -1,6 +1,6 @@ // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs -#![feature(no_core, unboxed_closures, start, lang_items)] +#![feature(no_core, unboxed_closures, start, lang_items, box_syntax)] #![no_core] #![allow(dead_code)] @@ -43,9 +43,11 @@ static NUM_REF: &'static u8 = unsafe { &NUM }; fn main() { unsafe { - let slice: &[u8] = b"Hello!\0" as &[u8; 7]; + let slice: &[u8] = b"Hello\0" as &[u8; 6]; let ptr: *const u8 = slice as *const [u8] as *const u8; + let world = box "World!\0"; puts(ptr); + puts(*world as *const str as *const u8); } //panic(&("panic msg", "abc.rs", 0, 43)); diff --git a/src/base.rs b/src/base.rs index 1045275728165..cfe44f2f6895d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -488,7 +488,28 @@ fn trans_stmt<'a, 'tcx: 'a>( let usize_layout = fx.layout_of(fx.tcx.types.usize); lval.write_cvalue(fx, CValue::ByVal(size, usize_layout)); } - Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty), + Rvalue::NullaryOp(NullOp::Box, content_ty) => { + use rustc::middle::lang_items::ExchangeMallocFnLangItem; + + let usize_type = fx.cton_type(fx.tcx.types.usize).unwrap(); + let (size, align) = fx.layout_of(content_ty).size_and_align(); + let llsize = fx.bcx.ins().iconst(usize_type, size.bytes() as i64); + let llalign = fx.bcx.ins().iconst(usize_type, align.abi() as i64); + let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty)); + + // Allocate space: + let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) { + Ok(id) => id, + Err(s) => { + fx.tcx.sess.fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); + } + }; + let instance = ty::Instance::mono(fx.tcx, def_id); + let func_ref = fx.get_function_ref(instance); + let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); + let ptr = fx.bcx.inst_results(call)[0]; + lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout)); + }, Rvalue::NullaryOp(NullOp::SizeOf, ty) => { assert!( lval.layout() diff --git a/src/common.rs b/src/common.rs index 3c7afe774af53..7081511b19bdf 100644 --- a/src/common.rs +++ b/src/common.rs @@ -29,14 +29,6 @@ fn scalar_to_cton_type(tcx: TyCtxt, scalar: &Scalar) -> Type { } } -fn ptr_referee<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> { - match ty.sty { - ty::Ref(_, ty, _) => ty, - ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => ty, - _ => bug!("{:?}", ty), - } -} - pub fn cton_type_from_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>, @@ -153,7 +145,14 @@ impl<'tcx> CValue<'tcx> { CValue::ByRef(addr, layout) => { let cton_ty = fx .cton_type(layout.ty) - .expect(&format!("load_value of type {:?}", layout.ty)); + .unwrap_or_else(|| { + if layout.ty.is_box() && !fx.layout_of(layout.ty.builtin_deref(true).unwrap().ty).is_unsized() { + // Consider sized box to be a ptr + pointer_ty(fx.tcx) + } else { + panic!("load_value of type {:?}", layout.ty); + } + }); fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, @@ -223,7 +222,7 @@ impl<'tcx> CValue<'tcx> { } match &self.layout().ty.sty { ty::Ref(_, ty, _) | ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { - let (ptr, extra) = match ptr_referee(dest.layout().ty).sty { + let (ptr, extra) = match dest.layout().ty.builtin_deref(true).unwrap().ty.sty { ty::Slice(slice_elem_ty) => match ty.sty { ty::Array(array_elem_ty, size) => { assert_eq!(slice_elem_ty, array_elem_ty); @@ -453,7 +452,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } pub fn place_deref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CPlace<'tcx> { - let inner_layout = fx.layout_of(ptr_referee(self.layout().ty)); + let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); if !inner_layout.is_unsized() { CPlace::Addr(self.to_cvalue(fx).load_value(fx), None, inner_layout) } else { From d549d0f180e0443896bd5c690354ed64f4cd028a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 5 Sep 2018 19:43:42 +0200 Subject: [PATCH 0202/1566] Update Cargo.lock --- Cargo.lock | 278 ++++++++++++++++++++++----------------------- Cargo.toml | 2 +- src/abi.rs | 4 +- src/constant.rs | 9 +- src/lib.rs | 6 +- src/pretty_clif.rs | 4 +- 6 files changed, 144 insertions(+), 159 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0a57834216d4..b2917c965c6fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,9 +1,9 @@ [[package]] name = "aho-corasick" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -19,7 +19,7 @@ name = "ar" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -49,23 +49,23 @@ name = "backtrace-sys" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.4" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.18" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -80,7 +80,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -89,53 +89,53 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-bforest 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" [[package]] name = "cranelift-entity" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" [[package]] name = "cranelift-faerie" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -143,41 +143,41 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-module" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.19.0" -source = "git+https://github.com/CraneStation/cranelift.git#24e2ecf1638614559808e1433b20bf38bf7e1184" +version = "0.21.0" +source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" dependencies = [ - "cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -187,14 +187,14 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -218,14 +218,14 @@ dependencies = [ [[package]] name = "faerie" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -247,9 +247,9 @@ name = "failure_derive" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -263,7 +263,7 @@ name = "goblin" version = "0.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -301,7 +301,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -317,7 +317,7 @@ dependencies = [ [[package]] name = "memchr" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", @@ -330,7 +330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.12" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -343,10 +343,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -354,8 +354,8 @@ name = "raw-cpuid" version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -374,14 +374,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -397,7 +397,7 @@ name = "region" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", @@ -415,12 +415,12 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.19.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -434,7 +434,7 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -450,9 +450,9 @@ name = "scroll_derive" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -470,7 +470,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.71" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -479,8 +479,8 @@ version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.76 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -488,7 +488,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.76 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -510,18 +510,18 @@ name = "structopt-derive" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.14.8" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -530,9 +530,9 @@ name = "synstructure" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -548,10 +548,10 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wincolor 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -574,11 +574,10 @@ dependencies = [ [[package]] name = "thread_local" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -596,17 +595,9 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "utf8-ranges" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -619,11 +610,6 @@ name = "version_check" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.5" @@ -638,6 +624,14 @@ name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winapi-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -645,38 +639,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wincolor" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum aho-corasick 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c1c6d463cbe7ed28720b5b489e7c083eeb8f90d08be2a0d6bb9e1ffea9ce1afa" +"checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "095515608290b62ac2427084f9ac3cfeb5dc76067f7d94564db9db1c46cc0a85" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" -"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" -"checksum byteorder 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8389c509ec62b9fe8eca58c502a0acaf017737355615243496cde4994f8fa4f9" -"checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781" +"checksum cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "c37f0efaa4b9b001fa6f02d4b644dee4af97d3414df07c51e3e4f015f3a3e131" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum cranelift 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.19.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)" = "f4d7e69c283751083d53d01eac767407343b8b69c4bd70058e08adc2637cb257" +"checksum cranelift 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "319f742885b740cec9adca9a9b4bc35229d7e004af9431c694e0aef3eea00f55" +"checksum faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3a1085754e4ac8a52d1bfe21ddeb534ac25800b56586a64554c3c32944ccb0b8" "checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" "checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" @@ -686,48 +681,47 @@ dependencies = [ "checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" -"checksum log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd98ae7f7b754bc53dca7d44b604f733c6bba044ea6f41bc8d89272d8161d2" +"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" -"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" +"checksum memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a3b4142ab8738a78c51896f704f83c11df047ff1bda9a92a661aa6361552d93d" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "7a17a4d77bc20d344179de803a34694c0ac7a0b3fb4384bee99783215a8e0410" +"checksum proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee80fbbe0ae60bcad82d15bc59d5fe2aaebc1b83fbfb145abc8c74f8e769549" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ed7d650913520df631972f21e104a4fa2f9c82a14afc65d17b388a2e29731e7c" +"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" "checksum raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3c460bd35fdb75644e94ab498372bdf29a4849367ce7ba74cf358edce590c4" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5bbbea44c5490a1e84357ff28b7d518b4619a159fed5d25f6c1de2d19cc42814" +"checksum regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "67d0301b0c6804eca7e3c275119d0b01ff3b7ab9258a65709e608a66312a1025" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "16aa12da69951804cddf5f74d96abcc414a31b064e610dc81e37c1536082f491" +"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" "checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" "checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfad05c8854584e5f72fb859385ecdfa03af69c3fd0572f0da2d4c95f060bdb" +"checksum serde 1.0.76 (registry+https://github.com/rust-lang/crates.io-index)" = "d00c69ae39089576cddfd235556e3b21bf41c2d80018063cb5ab8a1183c917fd" "checksum serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" "checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" -"checksum syn 0.14.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b7bfcbb0c068d0f642a0ffbd5c604965a360a61f99e8add013cef23a838614f3" +"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" -"checksum termcolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "722426c4a0539da2c4ffd9b419d90ad540b4cff4a053be9069c908d4d07e2836" +"checksum termcolor 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3bac0e465b59f194e7037ed404b0326e56ff234d767edc4c5cc9cd49e7a2c7" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" -"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" +"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" +"checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" -"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9dc3aa9dcda98b5a16150c54619c1ead22e3d3a5d458778ae914be760aa981a" +"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" diff --git a/Cargo.toml b/Cargo.toml index b4f37c2c8ae39..5f0893e97b24f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.0.3" #goblin = "0.0.17" -faerie = "0.4.4" +faerie = "0.5.0" ar = "0.6.0" bitflags = "1.0.3" diff --git a/src/abi.rs b/src/abi.rs index 112d87743feab..8fb3ca280bbd7 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -103,7 +103,6 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( params, returns, call_conv, - argument_bytes: None, } } @@ -183,9 +182,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { ) -> Option { let sig = Signature { params: input_tys.iter().cloned().map(AbiParam::new).collect(), - returns: vec![AbiParam::new(output_ty.unwrap_or(types::VOID))], + returns: output_ty.map(|output_ty| vec![AbiParam::new(output_ty)]).unwrap_or(Vec::new()), call_conv: CallConv::SystemV, - argument_bytes: None, }; let func_id = self .module diff --git a/src/constant.rs b/src/constant.rs index 4a8150802784b..26afe046ac179 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,6 @@ use rustc::mir::interpret::{ }; use rustc::ty::Const; use rustc_mir::interpret::{CompileTimeEvaluator, EvalContext, Memory, MemoryKind}; -use syntax::ast::Mutability as AstMutability; #[derive(Default)] pub struct ConstantCx { @@ -224,13 +223,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( let mut data_ctx = DataContext::new(); - data_ctx.define( - alloc.bytes.to_vec().into_boxed_slice(), - match alloc.mutability { - AstMutability::Mutable => Writability::Writable, - AstMutability::Immutable => Writability::Readonly, - }, - ); + data_ctx.define(alloc.bytes.to_vec().into_boxed_slice()); for &(offset, reloc) in alloc.relocations.iter() { let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { diff --git a/src/lib.rs b/src/lib.rs index 4d04b7761fd29..d4257b8f632ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,7 +83,7 @@ mod prelude { pub use cranelift::codegen::Context; pub use cranelift::prelude::*; pub use cranelift_module::{ - Backend, DataContext, DataId, FuncId, Linkage, Module, Writability, + Backend, DataContext, DataId, FuncId, Linkage, Module, }; pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; @@ -239,7 +239,6 @@ impl CodegenBackend for CraneliftCodegenBackend { ], returns: vec![AbiParam::new(jit_module.pointer_type() /*isize*/)], call_conv: CallConv::SystemV, - argument_bytes: None, }; let main_func_id = jit_module .declare_function("main", Linkage::Import, &sig) @@ -307,7 +306,7 @@ impl CodegenBackend for CraneliftCodegenBackend { &metadata_name, faerie::artifact::Decl::Data { global: true, - writeable: false, + writable: false, }, metadata.clone(), ).unwrap(); @@ -442,7 +441,6 @@ fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( ], returns: vec![AbiParam::new(m.pointer_type() /*isize*/)], call_conv: CallConv::SystemV, - argument_bytes: None, }; let cmain_func_id = m diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index c6cc521f90d16..08e685841aace 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::collections::HashMap; use std::fmt; +use cranelift::codegen::entity::EntityMap; use cranelift::codegen::write::{FuncWriter, PlainWriter}; use crate::prelude::*; @@ -13,11 +14,12 @@ impl FuncWriter for CommentWriter { &mut self, w: &mut dyn fmt::Write, func: &Function, + aliases: &EntityMap>, isa: Option<&dyn isa::TargetIsa>, inst: Inst, indent: usize, ) -> fmt::Result { - PlainWriter.write_instruction(w, func, isa, inst, indent)?; + PlainWriter.write_instruction(w, func, aliases, isa, inst, indent)?; if let Some(comment) = self.0.get(&inst) { writeln!(w, "; {}", comment.replace('\n', "\n; "))?; } From c54d9b3b430afebda4f8f0b79e723f55218d1dae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 6 Sep 2018 07:01:46 +0000 Subject: [PATCH 0203/1566] Bump cranelift-faerie from `9ca7853` to `083d1e8` Bumps [cranelift-faerie](https://github.com/CraneStation/cranelift) from `9ca7853` to `083d1e8`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/9ca7853842335032103fa1daba823fe22975215d...083d1e83f104f12093313582a56538a3506afb1f) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2917c965c6fc..d1e85f1c254bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" [[package]] name = "cranelift-entity" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" [[package]] name = "cranelift-faerie" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", From 99f2d8bdef0698d712bd25eeb4d4a3dac2d73fb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 6 Sep 2018 07:01:51 +0000 Subject: [PATCH 0204/1566] Bump cranelift-simplejit from `9ca7853` to `083d1e8` Bumps [cranelift-simplejit](https://github.com/CraneStation/cranelift) from `9ca7853` to `083d1e8`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/9ca7853842335032103fa1daba823fe22975215d...083d1e83f104f12093313582a56538a3506afb1f) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2917c965c6fc..d1e85f1c254bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" [[package]] name = "cranelift-entity" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" [[package]] name = "cranelift-faerie" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", From daf09237e3727fbe7bc5f1bcee3bc375a45f5f43 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 6 Sep 2018 07:02:00 +0000 Subject: [PATCH 0205/1566] Bump cranelift from `9ca7853` to `083d1e8` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `9ca7853` to `083d1e8`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/9ca7853842335032103fa1daba823fe22975215d...083d1e83f104f12093313582a56538a3506afb1f) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2917c965c6fc..d1e85f1c254bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" [[package]] name = "cranelift-entity" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" [[package]] name = "cranelift-faerie" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#9ca7853842335032103fa1daba823fe22975215d" +source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", From 4c0a2ff59b2e8fe6258e626d7694e185bba63922 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 5 Sep 2018 20:04:21 +0200 Subject: [PATCH 0206/1566] Don't print Storage{Live,Dead} as comment in debug clif --- src/base.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index cfe44f2f6895d..9be04e0c1e70c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -254,8 +254,13 @@ fn trans_stmt<'a, 'tcx: 'a>( ) { let _print_guard = PrintOnPanic(|| format!("stmt {:?}", stmt)); - let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); - fx.add_comment(inst, format!("{:?}", stmt)); + match &stmt.kind { + StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful + _ => { + let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); + fx.add_comment(inst, format!("{:?}", stmt)); + } + } match &stmt.kind { StatementKind::SetDiscriminant { From 871792d9abba47e5505cf57cda5a1d3f20d4683f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 6 Sep 2018 18:45:29 +0200 Subject: [PATCH 0207/1566] Implement intrinsic size_of_val for slices --- examples/mini_core.rs | 1 + examples/mini_core_hello_world.rs | 3 +++ src/abi.rs | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 75059743b9d90..5925bb6a254e5 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -201,6 +201,7 @@ pub mod intrinsics { extern "rust-intrinsic" { pub fn abort() -> !; pub fn size_of() -> usize; + pub fn size_of_val(val: &T) -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; pub fn uninit() -> T; diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index a8297fe761303..accd3dacd7a1c 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -44,6 +44,9 @@ static NUM_REF: &'static u8 = unsafe { &NUM }; fn main() { unsafe { let slice: &[u8] = b"Hello\0" as &[u8; 6]; + if intrinsics::size_of_val(slice) as u8 != 0 { + panic(&("eji", "frjio", 0, 0)); + }; let ptr: *const u8 = slice as *const [u8] as *const u8; let world = box "World!\0"; puts(ptr); diff --git a/src/abi.rs b/src/abi.rs index 8fb3ca280bbd7..c19ae0cd3008d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -604,6 +604,18 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); ret.write_cvalue(fx, size_of); } + "size_of_val" => { + assert_eq!(args.len(), 1); + let size = match &substs.type_at(0).sty { + ty::Slice(elem) => { + let len = args[0].load_value_pair(fx).1; + let elem_size = fx.layout_of(elem).size.bytes(); + fx.bcx.ins().imul_imm(len, elem_size as i64) + }, + ty => unimplemented!("size_of_val for {:?}", ty), + }; + ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); + } "type_id" => { assert_eq!(args.len(), 0); let type_id = fx.tcx.type_id_hash(substs.type_at(0)); From 0f82103c2a63d87dd776aaba32571b688bc4664e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 7 Sep 2018 06:14:27 +0000 Subject: [PATCH 0208/1566] Bump cranelift from `083d1e8` to `5b2af58` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `083d1e8` to `5b2af58`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/083d1e83f104f12093313582a56538a3506afb1f...5b2af5841f19f003e2d8e972154f8b40ba433170) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d1e85f1c254bd..9fe1639b70521 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" [[package]] name = "cranelift-entity" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" [[package]] name = "cranelift-faerie" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#083d1e83f104f12093313582a56538a3506afb1f" +source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" dependencies = [ "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", From 17c92bbd78abdc0f1c257c724571804b6e9147c8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Sep 2018 11:11:46 +0200 Subject: [PATCH 0209/1566] Rustup to rustc 1.30.0-nightly (fc81e3624 2018-09-07) --- 0002-Disable-u128-and-i128-in-libcore.patch | 93 +++++++++++---------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch index 63ef33a30cf60..a8d2745c95580 100644 --- a/0002-Disable-u128-and-i128-in-libcore.patch +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From 78c557ab91915384c4de6b743fa67dedcb0263c9 Mon Sep 17 00:00:00 2001 +From 7f8b6fdc01a17a0f963ac05bf9a488c093307090 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Tue, 14 Aug 2018 09:59:32 +0200 +Date: Sat, 8 Sep 2018 11:06:28 +0200 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -8,20 +8,20 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/cmp.rs | 6 +-- src/libcore/default.rs | 2 - src/libcore/fmt/num.rs | 6 +-- - src/libcore/hash/mod.rs | 20 ---------- + src/libcore/hash/mod.rs | 20 --------- src/libcore/iter/range.rs | 1 - src/libcore/iter/traits.rs | 2 +- src/libcore/lib.rs | 2 - src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 92 +++++++++++++------------------------------- + src/libcore/num/mod.rs | 99 ++++++++++++-------------------------------- src/libcore/num/wrapping.rs | 14 +++---- - src/libcore/ops/arith.rs | 22 +++++------ - src/libcore/ops/bit.rs | 30 ++++++--------- - src/libcore/tests/iter.rs | 15 -------- - src/libcore/tests/num/mod.rs | 18 --------- - src/libcore/time.rs | 51 ------------------------ - 17 files changed, 62 insertions(+), 229 deletions(-) + src/libcore/ops/arith.rs | 22 +++++----- + src/libcore/ops/bit.rs | 30 +++++--------- + src/libcore/tests/iter.rs | 15 ------- + src/libcore/tests/num/mod.rs | 18 -------- + src/libcore/time.rs | 51 ----------------------- + 17 files changed, 62 insertions(+), 236 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 3b15ba2..de08ce0 100644 @@ -39,10 +39,10 @@ index 3b15ba2..de08ce0 100644 bool char } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index 58d6c4f..a6e6496 100644 +index ef7d83a..e40c5c2 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs -@@ -800,7 +800,7 @@ mod impls { +@@ -883,7 +883,7 @@ mod impls { } partial_eq_impl! { @@ -51,7 +51,7 @@ index 58d6c4f..a6e6496 100644 } macro_rules! eq_impl { -@@ -810,7 +810,7 @@ mod impls { +@@ -893,7 +893,7 @@ mod impls { )*) } @@ -60,7 +60,7 @@ index 58d6c4f..a6e6496 100644 macro_rules! partial_ord_impl { ($($t:ty)*) => ($( -@@ -899,7 +899,7 @@ mod impls { +@@ -982,7 +982,7 @@ mod impls { } } @@ -188,10 +188,10 @@ index e7907e0..84b700c 100644 #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index 651c7a3..3708b8e 100644 +index 55addd8..6695cfe 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs -@@ -175,7 +175,6 @@ step_impl_signed!([i64: u64]); +@@ -183,7 +183,6 @@ step_impl_signed!([i64: u64]); // assume here that it is less than 64-bits. #[cfg(not(target_pointer_width = "64"))] step_impl_no_between!(u64 i64); @@ -213,10 +213,10 @@ index 4b2c1aa..ec3991f 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index c7618b9..31b33a2 100644 +index fb90be8..310f376 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -144,14 +144,12 @@ mod uint_macros; +@@ -152,14 +152,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -232,10 +232,10 @@ index c7618b9..31b33a2 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index d18e167..ec2edc1 100644 +index dd57d2d..b75376b 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs -@@ -649,8 +649,8 @@ mod copy_impls { +@@ -672,8 +672,8 @@ mod copy_impls { } impl_copy! { @@ -247,10 +247,10 @@ index d18e167..ec2edc1 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 8a74e7c..642fffa 100644 +index 1803ade..f7fb0cb 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs -@@ -196,12 +196,10 @@ pub fn forget(t: T) { +@@ -162,12 +162,10 @@ pub fn forget(t: T) { /// u16 | 2 /// u32 | 4 /// u64 | 8 @@ -264,10 +264,10 @@ index 8a74e7c..642fffa 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index eb63966..eb06710 100644 +index 5ae984a..63b3754 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs -@@ -95,7 +95,6 @@ nonzero_integers! { +@@ -105,7 +105,6 @@ nonzero_integers! { NonZeroU16(u16); NonZeroU32(u32); NonZeroU64(u64); @@ -275,8 +275,8 @@ index eb63966..eb06710 100644 NonZeroUsize(usize); } -@@ -2025,15 +2024,6 @@ impl i64 { - "0x6a2c48091e6a2c48" } +@@ -2282,18 +2281,6 @@ impl i64 { + "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } -#[lang = "i128"] @@ -284,28 +284,35 @@ index eb63966..eb06710 100644 - int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, - 170141183460469231731687303715884105727, "", "", 16, - "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", -- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48" -- } +- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48", +- "[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \ +- 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", +- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \ +- 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" } -} - #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4157,13 +4147,6 @@ impl u64 { - "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48" } +@@ -4729,17 +4716,6 @@ impl u64 { + "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } -#[lang = "u128"] -impl u128 { - uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16, - "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", -- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48" } +- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48", +- "[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \ +- 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", +- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \ +- 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" } -} - #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4244,7 +4227,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4823,7 +4799,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -314,7 +321,7 @@ index eb63966..eb06710 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4360,30 +4343,25 @@ macro_rules! rev { +@@ -4939,30 +4915,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -349,7 +356,7 @@ index eb63966..eb06710 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4395,21 +4373,21 @@ mod ptr_try_from_impls { +@@ -4974,21 +4945,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -379,7 +386,7 @@ index eb63966..eb06710 100644 } #[cfg(target_pointer_width = "32")] -@@ -4418,24 +4396,24 @@ mod ptr_try_from_impls { +@@ -4997,24 +4968,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -412,7 +419,7 @@ index eb63966..eb06710 100644 } #[cfg(target_pointer_width = "64")] -@@ -4444,24 +4422,20 @@ mod ptr_try_from_impls { +@@ -5023,24 +4994,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -441,7 +448,7 @@ index eb63966..eb06710 100644 } #[doc(hidden)] -@@ -4496,7 +4470,7 @@ macro_rules! doit { +@@ -5075,7 +5042,7 @@ macro_rules! doit { } })*) } @@ -450,7 +457,7 @@ index eb63966..eb06710 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4664,52 +4638,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -5243,52 +5210,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -839,10 +846,11 @@ index 72b115f..d542e10 100644 #[derive(Clone)] struct Test(Bigger); -@@ -1878,19 +1876,6 @@ fn test_step_replace_signed() { +@@ -1877,19 +1875,6 @@ fn test_step_replace_signed() { + assert_eq!(y, 5); } - #[test] +-#[test] -fn test_step_replace_no_between() { - let mut x = 4u128; - let y = x.replace_zero(); @@ -855,10 +863,9 @@ index 72b115f..d542e10 100644 - assert_eq!(y, 5); -} - --#[test] + #[test] fn test_rev_try_folds() { let f = &|acc, x| i32::checked_add(2*acc, x); - assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index ab96d31..bb5c1d0 100644 --- a/src/libcore/tests/num/mod.rs @@ -991,5 +998,5 @@ index b589202..0f8a2ee 100644 /// if overflow occurred. /// -- -2.11.0 +2.15.2 (Apple Git-101.1) From feee8b2445a2d6d3085ee58ab8d64465156546c1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Sep 2018 11:20:15 +0200 Subject: [PATCH 0210/1566] Misc changes to abi.rs --- src/abi.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index c19ae0cd3008d..bfce55cfa94fc 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -482,17 +482,17 @@ pub fn codegen_call<'a, 'tcx: 'a>( let call_inst = match fn_ty.sty { ty::FnDef(def_id, substs) => { - let func_ref = fx.get_function_ref( - Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), - ); + let inst = Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(); + let func_ref = fx.get_function_ref(inst); fx.bcx.ins().call(func_ref, &call_args) } - _ => { + ty::FnPtr(_) => { let func = trans_operand(fx, func); let func = func.load_value(fx); let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty)); fx.bcx.ins().call_indirect(sig, func, &call_args) } + _ => bug!("{:?}", fn_ty), }; match output_pass_mode { From 9ede386054bfa3918661d011b452ad67d4a32f90 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Sep 2018 14:17:42 +0200 Subject: [PATCH 0211/1566] Don't call seal_all_blocks and finalize twice --- src/base.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 9be04e0c1e70c..7293649d05277 100644 --- a/src/base.rs +++ b/src/base.rs @@ -101,8 +101,6 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 6. Codegen function crate::abi::codegen_fn_prelude(&mut fx, start_ebb); codegen_fn_content(&mut fx); - fx.bcx.seal_all_blocks(); - fx.bcx.finalize(); // Step 7. Write function to file for debugging let mut writer = crate::pretty_clif::CommentWriter(fx.comments); From 9f489bc8de02fd3c0eacd939a94938a82823c6b6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Sep 2018 14:44:32 +0200 Subject: [PATCH 0212/1566] Don't require abi of defined function to be rust or rust-call --- examples/mini_core_hello_world.rs | 8 +++++--- src/abi.rs | 5 ----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index accd3dacd7a1c..984c0341efb42 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -9,12 +9,14 @@ extern crate mini_core; use mini_core::*; #[link(name = "c")] -extern "C" {} - extern "C" { fn puts(s: *const u8); } +unsafe extern "C" fn my_puts(s: *const u8) { + puts(s); +} + #[lang = "termination"] trait Termination { fn report(self) -> i32; @@ -44,7 +46,7 @@ static NUM_REF: &'static u8 = unsafe { &NUM }; fn main() { unsafe { let slice: &[u8] = b"Hello\0" as &[u8; 6]; - if intrinsics::size_of_val(slice) as u8 != 0 { + if intrinsics::size_of_val(slice) as u8 != 6 { panic(&("eji", "frjio", 0, 0)); }; let ptr: *const u8 = slice as *const [u8] as *const u8; diff --git a/src/abi.rs b/src/abi.rs index bfce55cfa94fc..3fd161ed6b086 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -249,11 +249,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( ) { let ssa_analyzed = crate::analyze::analyze(fx); - match fx.self_sig().abi { - Abi::Rust | Abi::RustCall => {} - _ => unimplemented!("declared function with non \"rust\" or \"rust-call\" abi"), - } - let ret_layout = fx.layout_of(fx.return_type()); let output_pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true); let ret_param = match output_pass_mode { From 252607ae41f93b65ea305e79719231e8b454dc43 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Sep 2018 17:23:03 +0200 Subject: [PATCH 0213/1566] Don't use write_mir_pretty for non local mir --- src/base.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index 7293649d05277..dd0aaeaaedb7a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -23,17 +23,20 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( match inst.def { InstanceDef::Item(_) | InstanceDef::DropGlue(_, _) - | InstanceDef::Virtual(_, _) => { + | InstanceDef::Virtual(_, _) if inst.def_id().krate == LOCAL_CRATE => { let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) .unwrap(); String::from_utf8(mir.into_inner()).unwrap() } - InstanceDef::FnPtrShim(_, _) + InstanceDef::Item(_) + | InstanceDef::DropGlue(_, _) + | InstanceDef::Virtual(_, _) + | InstanceDef::FnPtrShim(_, _) | InstanceDef::ClosureOnceShim { .. } | InstanceDef::CloneShim(_, _) => { - // FIXME fix write_mir_pretty for these instances - format!("{:#?}", tcx.instance_mir(inst.def)) + // FIXME fix write_mir_pretty for these instances + format!("{:#?}", tcx.instance_mir(inst.def)) } InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"), } From 62a0203a5a1ec3ba1165b98cdfab9547fa755814 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Sep 2018 17:24:52 +0200 Subject: [PATCH 0214/1566] Rustfmt --- examples/mini_core.rs | 2 +- src/abi.rs | 9 ++++++--- src/base.rs | 14 +++++++++----- src/common.rs | 21 +++++++++++---------- src/lib.rs | 4 +--- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 5925bb6a254e5..318cfe49da184 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -194,7 +194,7 @@ static mut MY_TINY_HEAP: [u8; 16] = [0; 16]; #[lang = "exchange_malloc"] unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { - &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8 + &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8 } pub mod intrinsics { diff --git a/src/abi.rs b/src/abi.rs index 3fd161ed6b086..f77009be9811a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -90,7 +90,8 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( ), PassMode::ByRef => { ( - Some(pointer_ty(tcx)).into_iter() // First param is place to put return val + Some(pointer_ty(tcx)) // First param is place to put return val + .into_iter() .chain(inputs) .map(AbiParam::new) .collect(), @@ -182,7 +183,9 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { ) -> Option { let sig = Signature { params: input_tys.iter().cloned().map(AbiParam::new).collect(), - returns: output_ty.map(|output_ty| vec![AbiParam::new(output_ty)]).unwrap_or(Vec::new()), + returns: output_ty + .map(|output_ty| vec![AbiParam::new(output_ty)]) + .unwrap_or(Vec::new()), call_conv: CallConv::SystemV, }; let func_id = self @@ -606,7 +609,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let len = args[0].load_value_pair(fx).1; let elem_size = fx.layout_of(elem).size.bytes(); fx.bcx.ins().imul_imm(len, elem_size as i64) - }, + } ty => unimplemented!("size_of_val for {:?}", ty), }; ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); diff --git a/src/base.rs b/src/base.rs index dd0aaeaaedb7a..9e01785416786 100644 --- a/src/base.rs +++ b/src/base.rs @@ -23,7 +23,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( match inst.def { InstanceDef::Item(_) | InstanceDef::DropGlue(_, _) - | InstanceDef::Virtual(_, _) if inst.def_id().krate == LOCAL_CRATE => { + | InstanceDef::Virtual(_, _) + if inst.def_id().krate == LOCAL_CRATE => + { let mut mir = ::std::io::Cursor::new(Vec::new()); ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) .unwrap(); @@ -35,8 +37,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( | InstanceDef::FnPtrShim(_, _) | InstanceDef::ClosureOnceShim { .. } | InstanceDef::CloneShim(_, _) => { - // FIXME fix write_mir_pretty for these instances - format!("{:#?}", tcx.instance_mir(inst.def)) + // FIXME fix write_mir_pretty for these instances + format!("{:#?}", tcx.instance_mir(inst.def)) } InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"), } @@ -507,7 +509,9 @@ fn trans_stmt<'a, 'tcx: 'a>( let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) { Ok(id) => id, Err(s) => { - fx.tcx.sess.fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); + fx.tcx + .sess + .fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); } }; let instance = ty::Instance::mono(fx.tcx, def_id); @@ -515,7 +519,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); let ptr = fx.bcx.inst_results(call)[0]; lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout)); - }, + } Rvalue::NullaryOp(NullOp::SizeOf, ty) => { assert!( lval.layout() diff --git a/src/common.rs b/src/common.rs index 7081511b19bdf..a7159c210ea83 100644 --- a/src/common.rs +++ b/src/common.rs @@ -143,16 +143,17 @@ impl<'tcx> CValue<'tcx> { { match self { CValue::ByRef(addr, layout) => { - let cton_ty = fx - .cton_type(layout.ty) - .unwrap_or_else(|| { - if layout.ty.is_box() && !fx.layout_of(layout.ty.builtin_deref(true).unwrap().ty).is_unsized() { - // Consider sized box to be a ptr - pointer_ty(fx.tcx) - } else { - panic!("load_value of type {:?}", layout.ty); - } - }); + let cton_ty = fx.cton_type(layout.ty).unwrap_or_else(|| { + if layout.ty.is_box() && !fx + .layout_of(layout.ty.builtin_deref(true).unwrap().ty) + .is_unsized() + { + // Consider sized box to be a ptr + pointer_ty(fx.tcx) + } else { + panic!("load_value of type {:?}", layout.ty); + } + }); fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, diff --git a/src/lib.rs b/src/lib.rs index d4257b8f632ec..c1aea7739b86b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,9 +82,7 @@ mod prelude { }; pub use cranelift::codegen::Context; pub use cranelift::prelude::*; - pub use cranelift_module::{ - Backend, DataContext, DataId, FuncId, Linkage, Module, - }; + pub use cranelift_module::{Backend, DataContext, DataId, FuncId, Linkage, Module}; pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; pub use crate::abi::*; From 6196146ac486bcdea476a385c9b46741fe88fd89 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Sep 2018 18:00:06 +0200 Subject: [PATCH 0215/1566] Implement trait objects (cc #14) --- 0006-Disable-all-trait-object-unsizing.patch | 137 ------------------- Cargo.lock | 1 + Cargo.toml | 1 + examples/mini_core_hello_world.rs | 41 ++++-- src/abi.rs | 89 ++++++++---- src/base.rs | 4 +- src/common.rs | 10 +- src/lib.rs | 8 +- src/vtable.rs | 129 +++++++++++++++++ 9 files changed, 243 insertions(+), 177 deletions(-) delete mode 100644 0006-Disable-all-trait-object-unsizing.patch create mode 100644 src/vtable.rs diff --git a/0006-Disable-all-trait-object-unsizing.patch b/0006-Disable-all-trait-object-unsizing.patch deleted file mode 100644 index 96226073ce3f0..0000000000000 --- a/0006-Disable-all-trait-object-unsizing.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 307aba455c6ee3227d7c522c07761cda19dc716c Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Wed, 29 Aug 2018 14:29:05 +0200 -Subject: [PATCH] Disable all trait object unsizing - ---- - src/libcore/alloc.rs | 2 +- - src/libcore/fmt/builders.rs | 13 ++++++++----- - src/libcore/fmt/mod.rs | 3 ++- - src/libcore/panic.rs | 5 +++-- - src/libcore/slice/mod.rs | 2 +- - 5 files changed, 15 insertions(+), 10 deletions(-) - -diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs -index 35e4eea..28b6e2f 100644 ---- a/src/libcore/alloc.rs -+++ b/src/libcore/alloc.rs -@@ -144,7 +144,7 @@ impl Layout { - #[stable(feature = "alloc_layout", since = "1.28.0")] - #[inline] - pub fn for_value(t: &T) -> Self { -- let (size, align) = (mem::size_of_val(t), mem::align_of_val(t)); -+ let (size, align) = panic!(); //(mem::size_of_val(t), mem::align_of_val(t)); - // See rationale in `new` for why this us using an unsafe variant below - debug_assert!(Layout::from_size_align(size, align).is_ok()); - unsafe { -diff --git a/src/libcore/fmt/builders.rs b/src/libcore/fmt/builders.rs -index 3c5f934..1427ab3 100644 ---- a/src/libcore/fmt/builders.rs -+++ b/src/libcore/fmt/builders.rs -@@ -18,6 +18,7 @@ struct PadAdapter<'a> { - impl<'a> PadAdapter<'a> { - fn wrap<'b, 'c: 'a+'b>(fmt: &'c mut fmt::Formatter, slot: &'b mut Option) - -> fmt::Formatter<'b> { -+ /* - fmt.wrap_buf(move |buf| { - *slot = Some(PadAdapter { - buf, -@@ -25,6 +26,8 @@ impl<'a> PadAdapter<'a> { - }); - slot.as_mut().unwrap() - }) -+ */ -+ panic!(); - } - } - -@@ -107,7 +110,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, - impl<'a, 'b: 'a> DebugStruct<'a, 'b> { - /// Adds a new field to the generated struct output. - #[stable(feature = "debug_builders", since = "1.2.0")] -- pub fn field(&mut self, name: &str, value: &dyn fmt::Debug) -> &mut DebugStruct<'a, 'b> { -+ pub fn field(&mut self, name: &str, value: &impl fmt::Debug) -> &mut DebugStruct<'a, 'b> { - self.result = self.result.and_then(|_| { - let prefix = if self.has_fields { - "," -@@ -204,7 +207,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D - impl<'a, 'b: 'a> DebugTuple<'a, 'b> { - /// Adds a new field to the generated tuple struct output. - #[stable(feature = "debug_builders", since = "1.2.0")] -- pub fn field(&mut self, value: &dyn fmt::Debug) -> &mut DebugTuple<'a, 'b> { -+ pub fn field(&mut self, value: &impl fmt::Debug) -> &mut DebugTuple<'a, 'b> { - self.result = self.result.and_then(|_| { - let (prefix, space) = if self.fields > 0 { - (",", " ") -@@ -258,7 +261,7 @@ struct DebugInner<'a, 'b: 'a> { - } - - impl<'a, 'b: 'a> DebugInner<'a, 'b> { -- fn entry(&mut self, entry: &dyn fmt::Debug) { -+ fn entry(&mut self, entry: &impl fmt::Debug) { - self.result = self.result.and_then(|_| { - if self.is_pretty() { - let mut slot = None; -@@ -340,7 +343,7 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b - impl<'a, 'b: 'a> DebugSet<'a, 'b> { - /// Adds a new entry to the set output. - #[stable(feature = "debug_builders", since = "1.2.0")] -- pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugSet<'a, 'b> { -+ pub fn entry(&mut self, entry: &impl fmt::Debug) -> &mut DebugSet<'a, 'b> { - self.inner.entry(entry); - self - } -@@ -411,7 +414,7 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a, - impl<'a, 'b: 'a> DebugList<'a, 'b> { - /// Adds a new entry to the list output. - #[stable(feature = "debug_builders", since = "1.2.0")] -- pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugList<'a, 'b> { -+ pub fn entry(&mut self, entry: &impl fmt::Debug) -> &mut DebugList<'a, 'b> { - self.inner.entry(entry); - self - } -diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs -index 928f95e..ad33906 100644 ---- a/src/libcore/fmt/mod.rs -+++ b/src/libcore/fmt/mod.rs -@@ -224,7 +224,8 @@ pub trait Write { - } - } - -- write(&mut Adapter(self), args) -+ //write(&mut Adapter(self), args) -+ panic!() - } - } - -diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs -index 17cac5a..27b7dde 100644 ---- a/src/libcore/panic.rs -+++ b/src/libcore/panic.rs -@@ -58,8 +58,9 @@ impl<'a> PanicInfo<'a> { - pub fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>, - location: Location<'a>) - -> Self { -- struct NoPayload; -- PanicInfo { payload: &NoPayload, location, message } -+ //struct NoPayload; -+ //PanicInfo { payload: &NoPayload, location, message } -+ panic!(); - } - - #[doc(hidden)] -diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs -index 88fdd76..8537f0e 100644 ---- a/src/libcore/slice/mod.rs -+++ b/src/libcore/slice/mod.rs -@@ -4003,7 +4003,7 @@ impl SlicePartialEq for [A] - return true; - } - unsafe { -- let size = mem::size_of_val(self); -+ let size = panic!(); //mem::size_of_val(self); - memcmp(self.as_ptr() as *const u8, - other.as_ptr() as *const u8, size) == 0 - } --- -2.11.0 diff --git a/Cargo.lock b/Cargo.lock index 9fe1639b70521..8e52485c2fc8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -416,6 +416,7 @@ version = "0.1.0" dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/Cargo.toml b/Cargo.toml index 5f0893e97b24f..5a3da6179bef4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ target-lexicon = "0.0.3" faerie = "0.5.0" ar = "0.6.0" bitflags = "1.0.3" +byteorder = "1.2.6" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 984c0341efb42..b9614cf00a7ab 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -31,6 +31,18 @@ impl Termination for () { } } +trait SomeTrait { + fn object_safe(&self); +} + +impl SomeTrait for &'static str { + fn object_safe(&self) { + unsafe { + puts(*self as *const str as *const u8); + } + } +} + #[lang = "start"] fn start( main: fn() -> T, @@ -45,15 +57,28 @@ static NUM_REF: &'static u8 = unsafe { &NUM }; fn main() { unsafe { - let slice: &[u8] = b"Hello\0" as &[u8; 6]; - if intrinsics::size_of_val(slice) as u8 != 6 { - panic(&("eji", "frjio", 0, 0)); - }; - let ptr: *const u8 = slice as *const [u8] as *const u8; - let world = box "World!\0"; + let hello: &[u8] = b"Hello\0" as &[u8; 6]; + let ptr: *const u8 = hello as *const [u8] as *const u8; puts(ptr); + + let world = box "World!\0"; puts(*world as *const str as *const u8); - } - //panic(&("panic msg", "abc.rs", 0, 43)); + if intrinsics::size_of_val(hello) as u8 != 6 { + panic(&("", "", 0, 0)); + }; + + let chars = &['C', 'h', 'a', 'r', 's']; + let chars = chars as &[char]; + if intrinsics::size_of_val(chars) as u8 != 4 * 5 { + panic(&("", "", 0, 0)); + } + + let a: &dyn SomeTrait = &"abc\0"; + a.object_safe(); + + if intrinsics::size_of_val(a) as u8 != 16 { + panic(&("", "", 0, 0)); + } + } } diff --git a/src/abi.rs b/src/abi.rs index f77009be9811a..3d020087e4760 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -50,6 +50,18 @@ fn get_pass_mode<'a, 'tcx: 'a>( } } +fn adjust_arg_for_abi<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + sig: FnSig<'tcx>, + arg: CValue<'tcx>, +) -> Value { + match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => arg.load_value(fx), + PassMode::ByRef => arg.force_stack(fx), + } +} + pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>, @@ -164,12 +176,16 @@ pub fn get_function_name_and_sig<'a, 'tcx>( impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { /// Instance must be monomorphized - pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { + pub fn get_function_id(&mut self, inst: Instance<'tcx>) -> FuncId { let (name, sig) = get_function_name_and_sig(self.tcx, inst); - let func_id = self - .module + self.module .declare_function(&name, Linkage::Import, &sig) - .unwrap(); + .unwrap() + } + + /// Instance must be monomorphized + pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { + let func_id = self.get_function_id(inst); self.module .declare_func_in_func(func_id, &mut self.bcx.func) } @@ -468,29 +484,51 @@ pub fn codegen_call<'a, 'tcx: 'a>( PassMode::ByVal(_) => None, }; - let call_args: Vec = return_ptr - .into_iter() - .chain(args.into_iter().map(|arg| { - match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => arg.load_value(fx), - PassMode::ByRef => arg.force_stack(fx), - } - })).collect::>(); - - let call_inst = match fn_ty.sty { + let instance = match fn_ty.sty { ty::FnDef(def_id, substs) => { - let inst = Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(); - let func_ref = fx.get_function_ref(inst); - fx.bcx.ins().call(func_ref, &call_args) + Some(Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap()) } - ty::FnPtr(_) => { - let func = trans_operand(fx, func); - let func = func.load_value(fx); - let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty)); - fx.bcx.ins().call_indirect(sig, func, &call_args) - } - _ => bug!("{:?}", fn_ty), + _ => None, + }; + + let func_ref: Option; // Indirect call target + + let first_arg = { + if let Some(Instance { + def: InstanceDef::Virtual(_, idx), + .. + }) = instance + { + let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0], idx); + func_ref = Some(method); + Some(ptr) + } else { + func_ref = if instance.is_none() { + let func = trans_operand(fx, func); + Some(func.load_value(fx)) + } else { + None + }; + + args.get(0).map(|arg| adjust_arg_for_abi(fx, sig, *arg)) + }.into_iter() + }; + + let call_args: Vec = return_ptr + .into_iter() + .chain(first_arg) + .chain( + args.into_iter() + .skip(1) + .map(|arg| adjust_arg_for_abi(fx, sig, arg)), + ).collect::>(); + + let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty)); + let call_inst = if let Some(func_ref) = func_ref { + fx.bcx.ins().call_indirect(sig, func_ref, &call_args) + } else { + let func_ref = fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); + fx.bcx.ins().call(func_ref, &call_args) }; match output_pass_mode { @@ -610,6 +648,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let elem_size = fx.layout_of(elem).size.bytes(); fx.bcx.ins().imul_imm(len, elem_size as i64) } + ty::Dynamic(..) => crate::vtable::size_of_obj(fx, args[0]), ty => unimplemented!("size_of_val for {:?}", ty), }; ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); diff --git a/src/base.rs b/src/base.rs index 9e01785416786..caa4eae75f863 100644 --- a/src/base.rs +++ b/src/base.rs @@ -12,7 +12,7 @@ impl String> Drop for PrintOnPanic { pub fn trans_mono_item<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, - caches: &mut Caches, + caches: &mut Caches<'tcx>, ccx: &mut crate::constant::ConstantCx, mono_item: MonoItem<'tcx>, ) { @@ -59,7 +59,7 @@ fn trans_fn<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, constants: &mut crate::constant::ConstantCx, - caches: &mut Caches, + caches: &mut Caches<'tcx>, instance: Instance<'tcx>, ) { // Step 1. Get mir diff --git a/src/common.rs b/src/common.rs index a7159c210ea83..55cf333bbdc8e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -236,9 +236,13 @@ impl<'tcx> CValue<'tcx> { } _ => bug!("unsize non array {:?} to slice", ty), }, - ty::Dynamic(_, _) => match ty.sty { + ty::Dynamic(data, _) => match ty.sty { ty::Dynamic(_, _) => self.load_value_pair(fx), - _ => unimpl!("unsize of type ... to {:?}", dest.layout().ty), + _ => { + let ptr = self.load_value(fx); + let vtable = crate::vtable::get_vtable(fx, ty, data.principal()); + (ptr, vtable) + } }, _ => bug!( "unsize of type {:?} to {:?}", @@ -556,7 +560,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub local_map: HashMap>, pub comments: HashMap, pub constants: &'a mut crate::constant::ConstantCx, - pub caches: &'a mut Caches, + pub caches: &'a mut Caches<'tcx>, /// add_global_comment inserts a comment here pub top_nop: Option, diff --git a/src/lib.rs b/src/lib.rs index c1aea7739b86b..7e8f5ac0e47e3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![feature(rustc_private, macro_at_most_once_rep)] #![allow(intra_doc_link_resolution_failure)] +extern crate byteorder; extern crate syntax; #[macro_use] extern crate rustc; @@ -53,6 +54,7 @@ mod common; mod constant; mod metadata; mod pretty_clif; +mod vtable; mod prelude { pub use std::any::Any; @@ -100,14 +102,16 @@ mod prelude { use crate::constant::ConstantCx; use crate::prelude::*; -pub struct Caches { +pub struct Caches<'tcx> { pub context: Context, + pub vtables: HashMap<(Ty<'tcx>, Option>), DataId>, } -impl Caches { +impl<'tcx> Caches<'tcx> { fn new() -> Self { Caches { context: Context::new(), + vtables: HashMap::new(), } } } diff --git a/src/vtable.rs b/src/vtable.rs new file mode 100644 index 0000000000000..4d2382979c976 --- /dev/null +++ b/src/vtable.rs @@ -0,0 +1,129 @@ +//! See librustc_codegen_llvm/meth.rs for reference + +use crate::prelude::*; + +const DROP_FN_INDEX: usize = 0; +const SIZE_INDEX: usize = 1; +const ALIGN_INDEX: usize = 2; + +pub fn size_of_obj<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + val: CValue<'tcx>, +) -> Value { + let (_ptr, vtable) = val.load_value_pair(fx); + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + fx.bcx.ins().load( + pointer_ty(fx.tcx), + MemFlags::new(), + vtable, + (SIZE_INDEX * usize_size) as i32, + ) +} + +pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + arg: CValue<'tcx>, + idx: usize, +) -> (Value, Value) { + let (ptr, vtable) = arg.load_value_pair(fx); + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); + let func_ref = fx.bcx.ins().load( + pointer_ty(fx.tcx), + MemFlags::new(), + vtable, + ((idx + 3) * usize_size as usize) as i32, + ); + (ptr, func_ref) +} + +pub fn get_vtable<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ty: Ty<'tcx>, + trait_ref: Option>, +) -> Value { + let data_id = if let Some(data_id) = fx.caches.vtables.get(&(ty, trait_ref)) { + *data_id + } else { + let data_id = build_vtable(fx, ty, trait_ref); + fx.caches.vtables.insert((ty, trait_ref), data_id); + data_id + }; + + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + fx.bcx + .ins() + .global_value(fx.module.pointer_type(), local_data_id) +} + +fn build_vtable<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ty: Ty<'tcx>, + trait_ref: Option>, +) -> DataId { + let tcx = fx.tcx; + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + + let (size, align) = tcx + .layout_of(ParamEnv::reveal_all().and(ty)) + .unwrap() + .size_and_align(); + let drop_in_place_fn = + fx.get_function_id(::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty)); + + let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; + + if let Some(trait_ref) = trait_ref { + let trait_ref = trait_ref.with_self_ty(tcx, ty); + let methods = tcx.vtable_methods(trait_ref); + let methods = methods.iter().cloned().map(|opt_mth| { + opt_mth.map_or(None, |(def_id, substs)| { + Some(fx.get_function_id( + Instance::resolve(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + )) + }) + }); + components.extend(methods); + } + + let mut data_ctx = DataContext::new(); + let mut data = ::std::iter::repeat(0u8) + .take(components.len() * usize_size) + .collect::>() + .into_boxed_slice(); + write_usize(fx.tcx, &mut data, SIZE_INDEX, size.bytes()); + write_usize(fx.tcx, &mut data, ALIGN_INDEX, align.abi()); + data_ctx.define(data); + + for (i, component) in components.into_iter().enumerate() { + if let Some(func_id) = component { + let func_ref = fx.module.declare_func_in_data(func_id, &mut data_ctx); + data_ctx.write_function_addr((i * usize_size) as u32, func_ref); + } + } + + let data_id = fx + .module + .declare_data( + &format!("vtable.{:?}.for.{:?}", trait_ref, ty), + Linkage::Local, + false, + ).unwrap(); + fx.module.define_data(data_id, &data_ctx).unwrap(); + data_id +} + +fn write_usize(tcx: TyCtxt, buf: &mut [u8], idx: usize, num: u64) { + use byteorder::{BigEndian, LittleEndian, WriteBytesExt}; + + let usize_size = tcx + .layout_of(ParamEnv::reveal_all().and(tcx.types.usize)) + .unwrap() + .size + .bytes() as usize; + let mut target = &mut buf[idx * usize_size..(idx + 1) * usize_size]; + + match tcx.data_layout.endian { + layout::Endian::Little => target.write_uint::(num, usize_size), + layout::Endian::Big => target.write_uint::(num, usize_size), + }.unwrap() +} From e7ca9a186b212bf65f1ae5cd103458461ea3864f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 9 Sep 2018 14:45:23 +0200 Subject: [PATCH 0216/1566] Fix jit --- build.sh | 9 ++++++--- examples/mini_core_hello_world.rs | 12 ++++++++++-- src/constant.rs | 4 +--- src/lib.rs | 13 +++++-------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/build.sh b/build.sh index 86cefa83971b1..eb39e57490278 100755 --- a/build.sh +++ b/build.sh @@ -35,7 +35,7 @@ build_lib() { } run_bin() { - SHOULD_RUN=1 $RUSTC $1 --crate-type bin + SHOULD_RUN=1 $RUSTC $@ --crate-type bin } build_example_bin() { @@ -58,15 +58,18 @@ RUSTC="rustc -Zcodegen-backend=$(pwd)/target/$channel/librustc_codegen_cranelift rm -r target/out || true mkdir -p target/out/clif +echo "[BUILD] mini_core" build_lib mini_core examples/mini_core.rs $RUSTC examples/example.rs --crate-type lib -# SimpleJIT is broken -# run_bin examples/mini_core_hello_world.rs +echo "[JIT] mini_core_hello_world" +run_bin examples/mini_core_hello_world.rs --cfg jit +echo "[AOT] mini_core_hello_world" build_example_bin mini_core_hello_world examples/mini_core_hello_world.rs +echo "[BUILD] core" time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core -Cincremental=target/incremental_core cat target/out/log.txt | sort | uniq -c #extract_data libcore.rlib core.o diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index b9614cf00a7ab..9c08269d60baf 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -17,6 +17,10 @@ unsafe extern "C" fn my_puts(s: *const u8) { puts(s); } +// TODO remove when jit supports linking rlibs +#[cfg(jit)] +fn panic(_: T) { loop {} } + #[lang = "termination"] trait Termination { fn report(self) -> i32; @@ -61,8 +65,12 @@ fn main() { let ptr: *const u8 = hello as *const [u8] as *const u8; puts(ptr); - let world = box "World!\0"; - puts(*world as *const str as *const u8); + // TODO remove when jit supports linking rlibs + #[cfg(not(jit))] + { + let world = box "World!\0"; + puts(*world as *const str as *const u8); + } if intrinsics::size_of_val(hello) as u8 != 6 { panic(&("", "", 0, 0)); diff --git a/src/constant.rs b/src/constant.rs index 26afe046ac179..9bb89b88b2174 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -27,9 +27,7 @@ impl ConstantCx { //println!("todo {:?}", self.todo); define_all_allocs(tcx, module, &mut self); //println!("done {:?}", self.done); - for data_id in self.done.drain() { - module.finalize_data(data_id); - } + self.done.clear(); } } diff --git a/src/lib.rs b/src/lib.rs index 7e8f5ac0e47e3..82754fc47418e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -230,9 +230,8 @@ impl CodegenBackend for CraneliftCodegenBackend { codegen_mono_items(tcx, &mut jit_module, &mono_items); tcx.sess.abort_if_errors(); - tcx.sess.warn("Compiled everything"); - - tcx.sess.warn("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); + println!("Compiled everything"); + println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); let sig = Signature { params: vec![ @@ -246,14 +245,14 @@ impl CodegenBackend for CraneliftCodegenBackend { .declare_function("main", Linkage::Import, &sig) .unwrap(); - let finalized_main: *const u8 = jit_module.finalize_function(main_func_id); jit_module.finalize_all(); - tcx.sess.warn("Finalized everything"); + let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); + println!("🎉 Finalized everything"); let f: extern "C" fn(isize, *const *const u8) -> isize = unsafe { ::std::mem::transmute(finalized_main) }; let res = f(0, 0 as *const _); - tcx.sess.warn(&format!("main returned {}", res)); + tcx.sess.warn(&format!("🚀 main returned {}", res)); jit_module.finish(); ::std::process::exit(0); @@ -271,11 +270,9 @@ impl CodegenBackend for CraneliftCodegenBackend { codegen_mono_items(tcx, &mut faerie_module, &mono_items); tcx.sess.abort_if_errors(); - tcx.sess.warn("Compiled everything"); if should_codegen(tcx.sess) { faerie_module.finalize_all(); - tcx.sess.warn("Finalized everything"); } return Box::new(OngoingCodegen { From bdd914a8b2b2ee285ec764c390d5e66c0dd6e012 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 11 Sep 2018 06:00:47 +0000 Subject: [PATCH 0217/1566] Bump cranelift-simplejit from `5b2af58` to `078b07b` Bumps [cranelift-simplejit](https://github.com/CraneStation/cranelift) from `5b2af58` to `078b07b`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/5b2af5841f19f003e2d8e972154f8b40ba433170...078b07b86d60eeaef6606a93da9ffb22d509d2ba) Signed-off-by: dependabot[bot] --- Cargo.lock | 98 +++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e52485c2fc8b..3f59d2327573a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,29 +89,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -120,21 +120,21 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" [[package]] name = "cranelift-entity" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" [[package]] name = "cranelift-faerie" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -143,41 +143,41 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-module" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.21.0" -source = "git+https://github.com/CraneStation/cranelift.git#5b2af5841f19f003e2d8e972154f8b40ba433170" +version = "0.21.1" +source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" dependencies = [ - "cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -417,10 +417,10 @@ dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.21.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -659,16 +659,16 @@ dependencies = [ "checksum cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "c37f0efaa4b9b001fa6f02d4b644dee4af97d3414df07c51e3e4f015f3a3e131" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum cranelift 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.21.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From a63b85496a6b0b16e4ffcc2d56eb217f2761b97c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Sep 2018 19:28:13 +0200 Subject: [PATCH 0218/1566] Rustfmt --- examples/mini_core_hello_world.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 9c08269d60baf..ba05e5befc9a7 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -19,7 +19,9 @@ unsafe extern "C" fn my_puts(s: *const u8) { // TODO remove when jit supports linking rlibs #[cfg(jit)] -fn panic(_: T) { loop {} } +fn panic(_: T) { + loop {} +} #[lang = "termination"] trait Termination { From 29c8fcfc242023c678ca644517f7896461469064 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 12 Sep 2018 14:16:28 +0200 Subject: [PATCH 0219/1566] Rustup to rustc 1.30.0-nightly (2f1547c0a 2018-09-11) --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index caa4eae75f863..0dd7e1382c0b9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -549,7 +549,7 @@ fn trans_stmt<'a, 'tcx: 'a>( | StatementKind::ReadForMatch(_) | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) - | StatementKind::UserAssertTy(_, _) => {} + | StatementKind::AscribeUserType(..) => {} StatementKind::InlineAsm { .. } => unimpl!("Inline assembly is not supported"), } From 9a50510d0b02bc4d1f76a10f8f1bf3610e9193a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 12 Sep 2018 12:20:38 +0000 Subject: [PATCH 0220/1566] Bump cranelift from `078b07b` to `d50e73a` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `078b07b` to `d50e73a`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/078b07b86d60eeaef6606a93da9ffb22d509d2ba...d50e73af77824b9fe0aee752a2ffa8fc45e78538) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f59d2327573a..6f55db34a530a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" [[package]] name = "cranelift-entity" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" [[package]] name = "cranelift-faerie" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#078b07b86d60eeaef6606a93da9ffb22d509d2ba" +source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", From 59518987ed82c6ef3ef4882b50fcbb96df364f6d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Sep 2018 19:27:57 +0200 Subject: [PATCH 0221/1566] Implement drop support (fixes #11) --- examples/mini_core.rs | 5 ++ examples/mini_core_hello_world.rs | 28 +++++++++++ src/abi.rs | 50 +++++++++++++------ src/base.rs | 81 +++++++++++++++++++++++++++++-- 4 files changed, 143 insertions(+), 21 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 318cfe49da184..ea0a8c08ef53b 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -197,6 +197,11 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8 } +#[lang = "drop"] +pub trait Drop { + fn drop(&mut self); +} + pub mod intrinsics { extern "rust-intrinsic" { pub fn abort() -> !; diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index ba05e5befc9a7..661fa3cd7f153 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -49,6 +49,29 @@ impl SomeTrait for &'static str { } } +struct NoisyDrop { + text: &'static str, + inner: NoisyDropInner, +} + +struct NoisyDropInner; + +impl Drop for NoisyDrop { + fn drop(&mut self) { + unsafe { + puts(self.text as *const str as *const u8); + } + } +} + +impl Drop for NoisyDropInner { + fn drop(&mut self) { + unsafe { + puts("Inner got dropped!\0" as *const str as *const u8); + } + } +} + #[lang = "start"] fn start( main: fn() -> T, @@ -91,4 +114,9 @@ fn main() { panic(&("", "", 0, 0)); } } + + let _ = NoisyDrop { + text: "Outer got dropped!\0", + inner: NoisyDropInner, + }; } diff --git a/src/abi.rs b/src/abi.rs index 3d020087e4760..c1eefa430e01d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -433,7 +433,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( .jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); } -pub fn codegen_call<'a, 'tcx: 'a>( +pub fn codegen_terminator_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, func: &Operand<'tcx>, args: &[Operand<'tcx>], @@ -466,19 +466,42 @@ pub fn codegen_call<'a, 'tcx: 'a>( let destination = destination .as_ref() - .map(|(place, bb)| (trans_place(fx, place), *bb)); - - if codegen_intrinsic_call(fx, fn_ty, sig, &args, destination) { - return; + .map(|&(ref place, bb)| (trans_place(fx, place), bb)); + + if !codegen_intrinsic_call(fx, fn_ty, &args, destination) { + codegen_call_inner( + fx, + Some(func), + fn_ty, + args, + destination.map(|(place, _)| place), + ); + + if let Some((_, dest)) = destination { + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + } else { + fx.bcx.ins().trap(TrapCode::User(!0)); + } } +} + +pub fn codegen_call_inner<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + func: Option<&Operand<'tcx>>, + fn_ty: Ty<'tcx>, + args: Vec>, + ret_place: Option>, +) { + let sig = ty_fn_sig(fx.tcx, fn_ty); let ret_layout = fx.layout_of(sig.output()); let output_pass_mode = get_pass_mode(fx.tcx, sig.abi, sig.output(), true); let return_ptr = match output_pass_mode { PassMode::NoPass => None, - PassMode::ByRef => match destination { - Some((place, _)) => Some(place.expect_addr()), + PassMode::ByRef => match ret_place { + Some(ret_place) => Some(ret_place.expect_addr()), None => Some(fx.bcx.ins().iconst(fx.module.pointer_type(), 0)), }, PassMode::ByVal(_) => None, @@ -504,7 +527,7 @@ pub fn codegen_call<'a, 'tcx: 'a>( Some(ptr) } else { func_ref = if instance.is_none() { - let func = trans_operand(fx, func); + let func = trans_operand(fx, func.expect("indirect call without func Operand")); Some(func.load_value(fx)) } else { None @@ -534,19 +557,13 @@ pub fn codegen_call<'a, 'tcx: 'a>( match output_pass_mode { PassMode::NoPass => {} PassMode::ByVal(_) => { - if let Some((ret_place, _)) = destination { + if let Some(ret_place) = ret_place { let results = fx.bcx.inst_results(call_inst); ret_place.write_cvalue(fx, CValue::ByVal(results[0], ret_layout)); } } PassMode::ByRef => {} } - if let Some((_, dest)) = destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); - } else { - fx.bcx.ins().trap(TrapCode::User(!0)); - } } pub fn codegen_return(fx: &mut FunctionCx) { @@ -565,11 +582,12 @@ pub fn codegen_return(fx: &mut FunctionCx) { fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, fn_ty: Ty<'tcx>, - sig: FnSig<'tcx>, args: &[CValue<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, ) -> bool { if let ty::FnDef(def_id, substs) = fn_ty.sty { + let sig = ty_fn_sig(fx.tcx, fn_ty); + if sig.abi == Abi::RustIntrinsic { let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; diff --git a/src/base.rs b/src/base.rs index 0dd7e1382c0b9..e2422fe115788 100644 --- a/src/base.rs +++ b/src/base.rs @@ -224,19 +224,90 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) destination, cleanup: _, } => { - crate::abi::codegen_call(fx, func, args, destination); + crate::abi::codegen_terminator_call(fx, func, args, destination); } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { fx.bcx.ins().trap(TrapCode::User(!0)); } TerminatorKind::Yield { .. } | TerminatorKind::FalseEdges { .. } - | TerminatorKind::FalseUnwind { .. } => { + | TerminatorKind::FalseUnwind { .. } + | TerminatorKind::DropAndReplace { .. } => { bug!("shouldn't exist at trans {:?}", bb_data.terminator()); } - TerminatorKind::Drop { target, .. } | TerminatorKind::DropAndReplace { target, .. } => { - // TODO call drop impl - // unimplemented!("terminator {:?}", bb_data.terminator()); + TerminatorKind::Drop { + location, + target, + unwind: _, + } => { + let ty = location.ty(fx.mir, fx.tcx).to_ty(fx.tcx); + let ty = fx.monomorphize(&ty); + let drop_fn = ::rustc_mir::monomorphize::resolve_drop_in_place(fx.tcx, ty); + + if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { + // we don't actually need to drop anything + } else { + let drop_place = trans_place(fx, location); + let arg_place = CPlace::temp( + fx, + fx.tcx.mk_ref( + &ty::RegionKind::ReErased, + TypeAndMut { + ty, + mutbl: ::rustc::hir::Mutability::MutMutable, + }, + ), + ); + drop_place.write_place_ref(fx, arg_place); + match ty.sty { + ty::Dynamic(..) => { + unimplemented!("Drop for trait object"); + } + _ => { + let drop_fn_ty = drop_fn.ty(fx.tcx); + let arg_value = arg_place.to_cvalue(fx); + crate::abi::codegen_call_inner( + fx, + None, + drop_fn_ty, + vec![arg_value], + None, + ); + } + } + /* + let (args1, args2); + /*let mut args = if let Some(llextra) = place.llextra { + args2 = [place.llval, llextra]; + &args2[..] + } else { + args1 = [place.llval]; + &args1[..] + };*/ + let (drop_fn, fn_ty) = match ty.sty { + ty::Dynamic(..) => { + let fn_ty = drop_fn.ty(bx.cx.tcx); + let sig = common::ty_fn_sig(bx.cx, fn_ty); + let sig = bx.tcx().normalize_erasing_late_bound_regions( + ty::ParamEnv::reveal_all(), + &sig, + ); + let fn_ty = FnType::new_vtable(bx.cx, sig, &[]); + let vtable = args[1]; + args = &args[..1]; + (meth::DESTRUCTOR.get_fn(&bx, vtable, &fn_ty), fn_ty) + } + _ => { + let value = place.to_cvalue(fx); + (callee::get_fn(bx.cx, drop_fn), + FnType::of_instance(bx.cx, &drop_fn)) + } + }; + do_call(self, bx, fn_ty, drop_fn, args, + Some((ReturnDest::Nothing, target)), + unwind);*/ + } + let target_ebb = fx.get_ebb(*target); fx.bcx.ins().jump(target_ebb, &[]); } From eaeab0a08914163a90fc48e86a5cd29d3487ed84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 13 Sep 2018 05:56:28 +0000 Subject: [PATCH 0222/1566] Bump cranelift from `d50e73a` to `a698c50` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `d50e73a` to `a698c50`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/d50e73af77824b9fe0aee752a2ffa8fc45e78538...a698c50f96a1833137b68c6e69d4de8c09004ab3) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f55db34a530a..371be70951527 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" [[package]] name = "cranelift-entity" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" [[package]] name = "cranelift-faerie" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", From af55db646bcd78759efa53975a4ee46b08613b64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 13 Sep 2018 06:37:56 +0000 Subject: [PATCH 0223/1566] Bump cranelift-faerie from `d50e73a` to `a698c50` Bumps [cranelift-faerie](https://github.com/CraneStation/cranelift) from `d50e73a` to `a698c50`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/d50e73af77824b9fe0aee752a2ffa8fc45e78538...a698c50f96a1833137b68c6e69d4de8c09004ab3) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f55db34a530a..371be70951527 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" [[package]] name = "cranelift-entity" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" [[package]] name = "cranelift-faerie" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#d50e73af77824b9fe0aee752a2ffa8fc45e78538" +source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", From 017cb5c0d60c785f85768bb58f4d55674196fedd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 14 Sep 2018 06:13:33 +0000 Subject: [PATCH 0224/1566] Bump cranelift from `a698c50` to `9787326` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `a698c50` to `9787326`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/a698c50f96a1833137b68c6e69d4de8c09004ab3...9787326c89e5a823484f8bf61d14d09f45433011) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 371be70951527..04ccba619d703 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" [[package]] name = "cranelift-entity" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" [[package]] name = "cranelift-faerie" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#a698c50f96a1833137b68c6e69d4de8c09004ab3" +source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", From 0fb7c4d1b9a0b432db0292b2c42e88c2fa21cb02 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Sep 2018 19:49:33 +0200 Subject: [PATCH 0225/1566] Implement some intrinsics and fix a codegen error * intrinsic size_of_val for sized types * intrinsic needs_drop * incorrect codegen for UnOp::Not for bools --- examples/mini_core.rs | 16 ++++++++++++++++ examples/mini_core_hello_world.rs | 16 +++++++++++++++- src/abi.rs | 17 ++++++++++++++++- src/base.rs | 26 +++++++++++++++++++------- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index ea0a8c08ef53b..6e2e9dd37f63e 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -50,6 +50,21 @@ unsafe impl Sync for [u8; 16] {} #[lang = "freeze"] trait Freeze {} +#[lang = "not"] +pub trait Not { + type Output; + + fn not(self) -> Self::Output; +} + +impl Not for bool { + type Output = bool; + + fn not(self) -> bool { + !self + } +} + #[lang = "mul"] pub trait Mul { type Output; @@ -211,6 +226,7 @@ pub mod intrinsics { pub fn transmute(e: T) -> U; pub fn uninit() -> T; pub fn ctlz_nonzero(x: T) -> T; + pub fn needs_drop() -> bool; } } diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 661fa3cd7f153..5948415c92913 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -20,7 +20,9 @@ unsafe extern "C" fn my_puts(s: *const u8) { // TODO remove when jit supports linking rlibs #[cfg(jit)] fn panic(_: T) { - loop {} + unsafe { + intrinsics::abort(); + } } #[lang = "termination"] @@ -113,6 +115,18 @@ fn main() { if intrinsics::size_of_val(a) as u8 != 16 { panic(&("", "", 0, 0)); } + + if intrinsics::size_of_val(&0u32) as u8 != 4 { + panic(&("", "", 0, 0)); + } + + if intrinsics::needs_drop::() { + panic(&("", "", 0, 0)); + } + + if !intrinsics::needs_drop::() { + panic(&("", "", 0, 0)); + } } let _ = NoisyDrop { diff --git a/src/abi.rs b/src/abi.rs index c1eefa430e01d..8ae0136d00c52 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -660,7 +660,11 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( } "size_of_val" => { assert_eq!(args.len(), 1); - let size = match &substs.type_at(0).sty { + let layout = fx.layout_of(substs.type_at(0)); + let size = match &layout.ty.sty { + _ if !layout.is_unsized() => { + fx.bcx.ins().iconst(fx.module.pointer_type(), layout.size.bytes() as i64) + } ty::Slice(elem) => { let len = args[0].load_value_pair(fx).1; let elem_size = fx.layout_of(elem).size.bytes(); @@ -821,6 +825,17 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); ret.write_cvalue(fx, res); } + "needs_drop" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let needs_drop = if ty.needs_drop(fx.tcx, ParamEnv::reveal_all()) { + 1 + } else { + 0 + }; + let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); + ret.write_cvalue(fx, needs_drop); + } _ => unimpl!("unsupported intrinsic {}", intrinsic), } diff --git a/src/base.rs b/src/base.rs index e2422fe115788..8f2ab83ceeddc 100644 --- a/src/base.rs +++ b/src/base.rs @@ -432,19 +432,31 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, operand) => { - let ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)); - let layout = fx.layout_of(ty); - let val = trans_operand(fx, operand).load_value(fx); + let operand = trans_operand(fx, operand); + let layout = operand.layout(); + let val = operand.load_value(fx); let res = match un_op { - UnOp::Not => fx.bcx.ins().bnot(val), - UnOp::Neg => match ty.sty { + UnOp::Not => { + match layout.ty.sty { + ty::Bool => { + let val = fx.bcx.ins().uextend(types::I32, val); // WORKAROUND for CraneStation/cranelift#466 + let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); + fx.bcx.ins().bint(types::I8, res) + } + ty::Uint(_) | ty::Int(_) => { + fx.bcx.ins().bnot(val) + } + _ => unimplemented!("un op Not for {:?}", layout.ty), + } + }, + UnOp::Neg => match layout.ty.sty { ty::Int(_) => { - let clif_ty = fx.cton_type(ty).unwrap(); + let clif_ty = fx.cton_type(layout.ty).unwrap(); let zero = fx.bcx.ins().iconst(clif_ty, 0); fx.bcx.ins().isub(zero, val) } ty::Float(_) => fx.bcx.ins().fneg(val), - _ => unimplemented!("un op Neg for {:?}", ty), + _ => unimplemented!("un op Neg for {:?}", layout.ty), }, }; lval.write_cvalue(fx, CValue::ByVal(res, layout)); From 6e87a4f16d49411a0d432f0338cb5e0885f3af2e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Sep 2018 10:44:23 +0200 Subject: [PATCH 0226/1566] Rustup to rustc 1.30.0-nightly (2ab3eba30 2018-09-14) --- Cargo.toml | 2 -- src/abi.rs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5a3da6179bef4..89fe97f05ecdb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,3 @@ -cargo-features = ["edition"] - [package] name = "rustc_codegen_cranelift" version = "0.1.0" diff --git a/src/abi.rs b/src/abi.rs index 8ae0136d00c52..bc61ba5a70897 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -33,7 +33,7 @@ fn get_pass_mode<'a, 'tcx: 'a>( .unwrap() .is_unsized() ); - if ty.sty == tcx.mk_nil().sty { + if ty.sty == tcx.mk_unit().sty { if is_return { //if false { PassMode::NoPass @@ -609,7 +609,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( } }; - let nil_ty = fx.tcx.mk_nil(); + let nil_ty = fx.tcx.mk_unit(); let u64_layout = fx.layout_of(fx.tcx.types.u64); let usize_layout = fx.layout_of(fx.tcx.types.usize); From 1f1746e2d35692bed22fa0c6108b09a736cd65cb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Sep 2018 11:14:27 +0200 Subject: [PATCH 0227/1566] Implement intrinsic min_align_of_val --- examples/mini_core.rs | 2 ++ examples/mini_core_hello_world.rs | 43 +++++++++++++++++-------------- src/abi.rs | 28 +++++++++++++++----- src/vtable.rs | 14 ++++++++++ 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 6e2e9dd37f63e..544f2eceac0fa 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -222,6 +222,8 @@ pub mod intrinsics { pub fn abort() -> !; pub fn size_of() -> usize; pub fn size_of_val(val: &T) -> usize; + pub fn min_align_of() -> usize; + pub fn min_align_of_val(val: &T) -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; pub fn uninit() -> T; diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 5948415c92913..ff7d7975e2767 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -86,6 +86,22 @@ fn start( static mut NUM: u8 = 6 * 7; static NUM_REF: &'static u8 = unsafe { &NUM }; +macro_rules! assert { + ($e:expr) => { + if !$e { + panic(&(stringify!(! $e), file!(), line!(), 0)); + } + }; +} + +macro_rules! assert_eq { + ($l:expr, $r: expr) => { + if $l != $r { + panic(&(stringify!($l != $r), file!(), line!(), 0)); + } + } +} + fn main() { unsafe { let hello: &[u8] = b"Hello\0" as &[u8; 6]; @@ -99,34 +115,23 @@ fn main() { puts(*world as *const str as *const u8); } - if intrinsics::size_of_val(hello) as u8 != 6 { - panic(&("", "", 0, 0)); - }; + assert_eq!(intrinsics::size_of_val(hello) as u8, 6); let chars = &['C', 'h', 'a', 'r', 's']; let chars = chars as &[char]; - if intrinsics::size_of_val(chars) as u8 != 4 * 5 { - panic(&("", "", 0, 0)); - } + assert_eq!(intrinsics::size_of_val(chars) as u8, 4 * 5); let a: &dyn SomeTrait = &"abc\0"; a.object_safe(); - if intrinsics::size_of_val(a) as u8 != 16 { - panic(&("", "", 0, 0)); - } + assert_eq!(intrinsics::size_of_val(a) as u8, 16); + assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); - if intrinsics::size_of_val(&0u32) as u8 != 4 { - panic(&("", "", 0, 0)); - } + assert_eq!(intrinsics::min_align_of::() as u8, 2); + assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8); - if intrinsics::needs_drop::() { - panic(&("", "", 0, 0)); - } - - if !intrinsics::needs_drop::() { - panic(&("", "", 0, 0)); - } + assert!(!intrinsics::needs_drop::()); + assert!(intrinsics::needs_drop::()); } let _ = NoisyDrop { diff --git a/src/abi.rs b/src/abi.rs index bc61ba5a70897..2188621896209 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -675,18 +675,34 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); } - "type_id" => { - assert_eq!(args.len(), 0); - let type_id = fx.tcx.type_id_hash(substs.type_at(0)); - let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); - ret.write_cvalue(fx, type_id); - } "min_align_of" => { assert_eq!(args.len(), 0); let min_align = fx.layout_of(substs.type_at(0)).align.abi(); let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); ret.write_cvalue(fx, min_align); } + "min_align_of_val" => { + assert_eq!(args.len(), 1); + let layout = fx.layout_of(substs.type_at(0)); + let align = match &layout.ty.sty { + _ if !layout.is_unsized() => { + fx.bcx.ins().iconst(fx.module.pointer_type(), layout.align.abi() as i64) + } + ty::Slice(elem) => { + let align = fx.layout_of(elem).align.abi() as i64; + fx.bcx.ins().iconst(fx.module.pointer_type(), align) + } + ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, args[0]), + ty => unimplemented!("min_align_of_val for {:?}", ty), + }; + ret.write_cvalue(fx, CValue::ByVal(align, usize_layout)); + } + "type_id" => { + assert_eq!(args.len(), 0); + let type_id = fx.tcx.type_id_hash(substs.type_at(0)); + let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); + ret.write_cvalue(fx, type_id); + } _ if intrinsic.starts_with("unchecked_") => { assert_eq!(args.len(), 2); let bin_op = match intrinsic { diff --git a/src/vtable.rs b/src/vtable.rs index 4d2382979c976..da9c3765588c4 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -20,6 +20,20 @@ pub fn size_of_obj<'a, 'tcx: 'a>( ) } +pub fn min_align_of_obj<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + val: CValue<'tcx>, +) -> Value { + let (_ptr, vtable) = val.load_value_pair(fx); + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + fx.bcx.ins().load( + pointer_ty(fx.tcx), + MemFlags::new(), + vtable, + (ALIGN_INDEX * usize_size) as i32, + ) +} + pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, arg: CValue<'tcx>, From b9b0fc59f95da8872c353380cbfa2cafce8cf0b5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 11:23:44 +0200 Subject: [PATCH 0228/1566] Update Cargo.lock --- Cargo.lock | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04ccba619d703..166ecfb104bfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ name = "backtrace-sys" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.23" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -193,8 +193,8 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -247,7 +247,7 @@ name = "failure_derive" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -283,7 +283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itoa" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -330,7 +330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -346,7 +346,7 @@ name = "quote" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -355,7 +355,7 @@ version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -374,7 +374,7 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -451,7 +451,7 @@ name = "scroll_derive" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -471,17 +471,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.76" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.76 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -489,7 +489,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.76 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -511,7 +511,7 @@ name = "structopt-derive" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -521,7 +521,7 @@ name = "syn" version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -531,7 +531,7 @@ name = "synstructure" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -544,12 +544,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "termcolor" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -656,7 +656,7 @@ dependencies = [ "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781" -"checksum cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "c37f0efaa4b9b001fa6f02d4b644dee4af97d3414df07c51e3e4f015f3a3e131" +"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cranelift 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -679,20 +679,20 @@ dependencies = [ "checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" -"checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" +"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" "checksum memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a3b4142ab8738a78c51896f704f83c11df047ff1bda9a92a661aa6361552d93d" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee80fbbe0ae60bcad82d15bc59d5fe2aaebc1b83fbfb145abc8c74f8e769549" +"checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" "checksum raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3c460bd35fdb75644e94ab498372bdf29a4849367ce7ba74cf358edce590c4" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "67d0301b0c6804eca7e3c275119d0b01ff3b7ab9258a65709e608a66312a1025" +"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" @@ -702,8 +702,8 @@ dependencies = [ "checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.76 (registry+https://github.com/rust-lang/crates.io-index)" = "d00c69ae39089576cddfd235556e3b21bf41c2d80018063cb5ab8a1183c917fd" -"checksum serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae" +"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9" +"checksum serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "59790990c5115d16027f00913e2e66de23a51f70422e549d2ad68c8c5f268f1c" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" @@ -711,7 +711,7 @@ dependencies = [ "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" -"checksum termcolor 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3bac0e465b59f194e7037ed404b0326e56ff234d767edc4c5cc9cd49e7a2c7" +"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" From 73248114eaf11c0f99f389e138aa2c1930d5ac14 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 11:57:27 +0200 Subject: [PATCH 0229/1566] Implement unsize of adt's (cc #14) --- examples/mini_core.rs | 5 ++++- examples/mini_core_hello_world.rs | 3 ++- src/common.rs | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 544f2eceac0fa..8fa27662bdacc 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -12,6 +12,7 @@ pub trait Unsize {} pub trait CoerceUnsized {} impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} +impl, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} #[lang = "copy"] pub unsafe trait Copy {} @@ -203,7 +204,9 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { } #[lang = "owned_box"] -pub struct Box(*mut T); +pub struct Box(*mut T); + +impl, U: ?Sized> CoerceUnsized> for Box {} static mut MY_TINY_HEAP: [u8; 16] = [0; 16]; diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index ff7d7975e2767..84651ffd5ff5b 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -111,8 +111,9 @@ fn main() { // TODO remove when jit supports linking rlibs #[cfg(not(jit))] { - let world = box "World!\0"; + let world: Box<&str> = box "World!\0"; puts(*world as *const str as *const u8); + world as Box; } assert_eq!(intrinsics::size_of_val(hello) as u8, 6); diff --git a/src/common.rs b/src/common.rs index 55cf333bbdc8e..3213a94ba23c6 100644 --- a/src/common.rs +++ b/src/common.rs @@ -252,7 +252,22 @@ impl<'tcx> CValue<'tcx> { }; dest.write_cvalue(fx, CValue::ByValPair(ptr, extra, dest.layout())); } - ty => unimpl!("unsize of non ptr {:?}", ty), + _ => { + assert!(!self.layout().ty.is_enum(), "Tried to unsize enum"); + let field_count = self.layout().fields.count(); + let mut found_unsize_field = false; + for idx in 0..field_count { + let field_dest = dest.place_field(fx, mir::Field::new(idx)); + let field_src = self.value_field(fx, mir::Field::new(idx)); + if field_src.layout().ty != field_dest.layout().ty { + assert!(!found_unsize_field); + found_unsize_field = true; + field_src.unsize_value(fx, field_dest); + } else { + field_dest.write_cvalue(fx, field_src); + } + } + } } } From 19eb4194b239918d599f0602339a1d0193df5547 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 14:49:45 +0200 Subject: [PATCH 0230/1566] Fix unsize coerce for structs containing `PhantomData` like `Unique` --- examples/mini_core.rs | 4 ++++ examples/mini_core_hello_world.rs | 12 ++++++++++++ src/common.rs | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index 8fa27662bdacc..b6f5ad7589092 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -12,6 +12,7 @@ pub trait Unsize {} pub trait CoerceUnsized {} impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} +impl, U: ?Sized> CoerceUnsized<*const U> for *const T {} impl, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} #[lang = "copy"] @@ -169,6 +170,9 @@ impl PartialEq for *const T { } } +#[lang = "phantom_data"] +pub struct PhantomData; + #[lang = "fn_once"] #[rustc_paren_sugar] pub trait FnOnce { diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 84651ffd5ff5b..b47b46640898a 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -102,6 +102,13 @@ macro_rules! assert_eq { } } +struct Unique { + pointer: *const T, + _marker: PhantomData, +} + +impl CoerceUnsized> for Unique where T: Unsize {} + fn main() { unsafe { let hello: &[u8] = b"Hello\0" as &[u8; 6]; @@ -133,6 +140,11 @@ fn main() { assert!(!intrinsics::needs_drop::()); assert!(intrinsics::needs_drop::()); + + Unique { + pointer: 0 as *const &str, + _marker: PhantomData, + } as Unique; } let _ = NoisyDrop { diff --git a/src/common.rs b/src/common.rs index 3213a94ba23c6..68a82e65515eb 100644 --- a/src/common.rs +++ b/src/common.rs @@ -259,6 +259,17 @@ impl<'tcx> CValue<'tcx> { for idx in 0..field_count { let field_dest = dest.place_field(fx, mir::Field::new(idx)); let field_src = self.value_field(fx, mir::Field::new(idx)); + if field_src.layout().ty.is_phantom_data() { + // Ignore PhantomData so for example `Unique<()>` can coerce to `Unique` + // + // ```rust + // struct Unique { + // pointer: NonZero<*const T>, + // _marker: PhantomData, + // } + // ``` + continue; + } if field_src.layout().ty != field_dest.layout().ty { assert!(!found_unsize_field); found_unsize_field = true; From 086ff67cff3c9c3d2315252d1b05c91ad87e0fc0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 14:59:49 +0200 Subject: [PATCH 0231/1566] Implement returning `!` for "C" abi --- examples/mini_core_hello_world.rs | 2 +- src/abi.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index b47b46640898a..1aa3a1fc2dd98 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -19,7 +19,7 @@ unsafe extern "C" fn my_puts(s: *const u8) { // TODO remove when jit supports linking rlibs #[cfg(jit)] -fn panic(_: T) { +extern "C" fn panic(_: T) -> ! { unsafe { intrinsics::abort(); } diff --git a/src/abi.rs b/src/abi.rs index 2188621896209..448c072429cd0 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -33,9 +33,14 @@ fn get_pass_mode<'a, 'tcx: 'a>( .unwrap() .is_unsized() ); - if ty.sty == tcx.mk_unit().sty { + if let ty::Never = ty.sty { + if is_return { + PassMode::NoPass + } else { + PassMode::ByRef + } + } else if ty.sty == tcx.mk_unit().sty { if is_return { - //if false { PassMode::NoPass } else { PassMode::ByRef From 470a310f2e2a9c080a4813554c201a509425c4fe Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 15:28:27 +0200 Subject: [PATCH 0232/1566] Implement place_field for unsized places --- ...me-more-unsupported-stuff-in-libcore.patch | 48 +++---------------- examples/example.rs | 8 ++++ src/common.rs | 15 +++--- 3 files changed, 22 insertions(+), 49 deletions(-) diff --git a/0005-Disable-some-more-unsupported-stuff-in-libcore.patch b/0005-Disable-some-more-unsupported-stuff-in-libcore.patch index 0fff0728c0664..25bae13ff30b3 100644 --- a/0005-Disable-some-more-unsupported-stuff-in-libcore.patch +++ b/0005-Disable-some-more-unsupported-stuff-in-libcore.patch @@ -4,27 +4,10 @@ Date: Thu, 23 Aug 2018 11:15:01 +0200 Subject: [PATCH] Disable some more unsupported stuff in libcore --- - src/libcore/cell.rs | 6 +++--- src/libcore/cmp.rs | 5 ++++- src/libcore/num/mod.rs | 8 ++++++-- - src/libcore/str/mod.rs | 6 +++--- - 4 files changed, 16 insertions(+), 9 deletions(-) + 2 files changed, 9 insertions(+), 3 deletions(-) -diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs -index 009aba5..2aa76e3 100644 ---- a/src/libcore/cell.rs -+++ b/src/libcore/cell.rs -@@ -1532,7 +1532,7 @@ impl, U> CoerceUnsized> for UnsafeCell {} - - #[allow(unused)] - fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) { -- let _: UnsafeCell<&dyn Send> = a; -- let _: Cell<&dyn Send> = b; -- let _: RefCell<&dyn Send> = c; -+ //let _: UnsafeCell<&dyn Send> = a; -+ //let _: Cell<&dyn Send> = b; -+ //let _: RefCell<&dyn Send> = c; - } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index a6e6496..f9374ea 100644 --- a/src/libcore/cmp.rs @@ -32,7 +15,7 @@ index a6e6496..f9374ea 100644 @@ -496,6 +496,7 @@ pub trait Ord: Eq + PartialOrd { #[stable(feature = "rust1", since = "1.0.0")] impl Eq for Ordering {} - + +/* #[stable(feature = "rust1", since = "1.0.0")] impl Ord for Ordering { @@ -42,7 +25,7 @@ index a6e6496..f9374ea 100644 } } +*/ - + #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for Ordering { #[inline] @@ -52,7 +35,7 @@ index a6e6496..f9374ea 100644 + None } } - + diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 5d00949..f077f1d 100644 --- a/src/libcore/num/mod.rs @@ -67,7 +50,7 @@ index 5d00949..f077f1d 100644 + 0 } } - + @@ -2295,7 +2297,9 @@ assert_eq!(m, ", $reversed, "); #[unstable(feature = "reverse_bits", issue = "48763")] #[rustc_const_unstable(feature = "const_int_conversion")] @@ -80,24 +63,5 @@ index 5d00949..f077f1d 100644 + 0 } } - -diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs -index 810d19d..4c68370 100644 ---- a/src/libcore/str/mod.rs -+++ b/src/libcore/str/mod.rs -@@ -26,9 +26,9 @@ use mem; - - pub mod pattern; - --#[unstable(feature = "str_internals", issue = "0")] --#[allow(missing_docs)] --pub mod lossy; -+//#[unstable(feature = "str_internals", issue = "0")] -+//#[allow(missing_docs)] -+//pub mod lossy; - - /// A trait to abstract the idea of creating a new instance of a type from a - /// string. --- +-- 2.11.0 - diff --git a/examples/example.rs b/examples/example.rs index 5df8e69efd3e9..67ebf94cf916d 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -184,3 +184,11 @@ fn some_promoted_tuple() -> &'static (&'static str, &'static str) { fn index_slice(s: &[u8]) -> u8 { s[2] } + +pub struct StrWrapper { + s: str, +} + +fn str_wrapper_get(w: &StrWrapper) -> &str { + &w.s +} diff --git a/src/common.rs b/src/common.rs index 68a82e65515eb..ad7269bccc453 100644 --- a/src/common.rs +++ b/src/common.rs @@ -447,14 +447,15 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { fx: &mut FunctionCx<'a, 'tcx, impl Backend>, field: mir::Field, ) -> CPlace<'tcx> { - let layout = self.layout(); - if layout.is_unsized() { - unimpl!("unsized place_field"); + match self { + CPlace::Var(var, layout) => { + bug!("Tried to project {:?}, which is put in SSA var {:?}", layout.ty, var); + } + CPlace::Addr(base, extra, layout) => { + let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + CPlace::Addr(field_ptr, extra, field_layout) + } } - - let base = self.expect_addr(); - let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); - CPlace::Addr(field_ptr, None, field_layout) } pub fn place_index( From d5bfb762163017a909bb48efe3482a9361fbc7d9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 16:00:34 +0200 Subject: [PATCH 0233/1566] Implement some atomic intrinsics in a non atomic version --- src/abi.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/abi.rs b/src/abi.rs index 448c072429cd0..1960e390d1a7a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -857,6 +857,38 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); ret.write_cvalue(fx, needs_drop); } + _ if intrinsic.starts_with("atomic_fence") => {} + _ if intrinsic.starts_with("atomic_load") => { + assert_eq!(args.len(), 1); + let inner_layout = fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); + let val = CValue::ByRef(args[0].load_value(fx), inner_layout); + ret.write_cvalue(fx, val); + } + _ if intrinsic.starts_with("atomic_store") => { + assert_eq!(args.len(), 2); + let dest = CPlace::Addr(args[0].load_value(fx), None, args[1].layout()); + dest.write_cvalue(fx, args[1]); + } + _ if intrinsic.starts_with("atomic_xadd") => { + assert_eq!(args.len(), 2); + let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); + let ptr = args[0].load_value(fx); + let amount = args[1].load_value(fx); + let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); + let new = fx.bcx.ins().iadd(old, amount); + fx.bcx.ins().store(MemFlags::new(), ptr, new, 0); + ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); + } + _ if intrinsic.starts_with("atomic_xsub") => { + assert_eq!(args.len(), 2); + let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); + let ptr = args[0].load_value(fx); + let amount = args[1].load_value(fx); + let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); + let new = fx.bcx.ins().isub(old, amount); + fx.bcx.ins().store(MemFlags::new(), ptr, new, 0); + ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); + } _ => unimpl!("unsupported intrinsic {}", intrinsic), } From 716856364933d0bd9661a6b39b1e3cf50a024857 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 16:21:07 +0200 Subject: [PATCH 0234/1566] Implement function reference in static --- examples/mini_core.rs | 7 +++++++ examples/mini_core_hello_world.rs | 6 ++++++ src/constant.rs | 24 +++++++++++++++--------- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/examples/mini_core.rs b/examples/mini_core.rs index b6f5ad7589092..0c9eb7a01f05b 100644 --- a/examples/mini_core.rs +++ b/examples/mini_core.rs @@ -170,6 +170,13 @@ impl PartialEq for *const T { } } +pub enum Option { + Some(T), + None, +} + +pub use Option::*; + #[lang = "phantom_data"] pub struct PhantomData; diff --git a/examples/mini_core_hello_world.rs b/examples/mini_core_hello_world.rs index 1aa3a1fc2dd98..a60d2363ad1e7 100644 --- a/examples/mini_core_hello_world.rs +++ b/examples/mini_core_hello_world.rs @@ -151,4 +151,10 @@ fn main() { text: "Outer got dropped!\0", inner: NoisyDropInner, }; + + const FUNC_REF: Option = Some(main); + match FUNC_REF { + Some(_) => {}, + None => assert!(false), + } } diff --git a/src/constant.rs b/src/constant.rs index 9bb89b88b2174..9274d313259c2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -224,26 +224,32 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( data_ctx.define(alloc.bytes.to_vec().into_boxed_slice()); for &(offset, reloc) in alloc.relocations.iter() { + let reloc_offset = { + let endianness = tcx.data_layout.endian; + let offset = offset.bytes() as usize; + let ptr_size = tcx.data_layout.pointer_size; + let bytes = &alloc.bytes[offset..offset + ptr_size.bytes() as usize]; + read_target_uint(endianness, bytes).unwrap() + }; + let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { + AllocType::Function(instance) => { + let (func_name, sig) = crate::abi::get_function_name_and_sig(tcx, instance); + let func_id = module.declare_function(&func_name, Linkage::Import, &sig).unwrap(); + let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx); + data_ctx.write_function_addr(reloc_offset as u32, local_func_id); + continue; + }, AllocType::Memory(_) => { cx.todo.insert(TodoItem::Alloc(reloc)); data_id_for_alloc_id(module, reloc) } - AllocType::Function(_) => unimplemented!("function static reference"), AllocType::Static(def_id) => { cx.todo.insert(TodoItem::Static(def_id)); data_id_for_static(tcx, module, def_id) } }; - let reloc_offset = { - let endianness = tcx.data_layout.endian; - let offset = offset.bytes() as usize; - let ptr_size = tcx.data_layout.pointer_size; - let bytes = &alloc.bytes[offset..offset + ptr_size.bytes() as usize]; - read_target_uint(endianness, bytes).unwrap() - }; - let global_value = module.declare_data_in_data(data_id, &mut data_ctx); data_ctx.write_data_addr(reloc_offset as u32, global_value, 0); } From 7c510c0661e82d5f49d829ec9f59e23ec4bb9b24 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 17:48:13 +0200 Subject: [PATCH 0235/1566] Remove some code --- src/lib.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 82754fc47418e..cbad8c76567a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -167,36 +167,6 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx: TyCtxt<'a, 'tcx, 'tcx>, _rx: mpsc::Receiver>, ) -> Box { - use rustc_mir::monomorphize::item::MonoItem; - - rustc_codegen_utils::check_for_rustc_errors_attr(tcx); - rustc_codegen_utils::symbol_names_test::report_symbol_names(tcx); - rustc_incremental::assert_dep_graph(tcx); - rustc_incremental::assert_module_sources::assert_module_sources(tcx); - rustc_mir::monomorphize::assert_symbols_are_distinct( - tcx, - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager) - .0 - .iter(), - ); - //::rustc::middle::dependency_format::calculate(tcx); - let _ = tcx.link_args(LOCAL_CRATE); - let _ = tcx.native_libraries(LOCAL_CRATE); - for mono_item in - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0 - { - match mono_item { - MonoItem::Fn(inst) => { - let def_id = inst.def_id(); - if def_id.is_local() { - let _ = inst.def.is_inline(tcx); - let _ = tcx.codegen_fn_attrs(def_id); - } - } - _ => {} - } - } - if !tcx.sess.crate_types.get().contains(&CrateType::Executable) && std::env::var("SHOULD_RUN").is_ok() { From 39fbea8c1b45c11503facdabb8f9dc0614f4137c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Sep 2018 18:46:19 +0200 Subject: [PATCH 0236/1566] Better error message for unsupported "C" abi args --- src/abi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index 1960e390d1a7a..980f854a5ede1 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -49,7 +49,7 @@ fn get_pass_mode<'a, 'tcx: 'a>( PassMode::ByVal(ret_ty) } else { if abi == Abi::C { - unimplemented!("Non scalars are not yet supported for \"C\" abi"); + unimpl!("Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}", ty, is_return); } PassMode::ByRef } From a1b8e02a881c3b5124dff3b51f20245d146425b9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 17 Sep 2018 18:49:10 +0200 Subject: [PATCH 0237/1566] Rustup to rustc 1.30.0-nightly (cb6d2dfa8 2018-09-16) --- src/abi.rs | 4 ++-- src/analyze.rs | 2 +- src/base.rs | 8 ++++---- src/common.rs | 4 ++-- src/constant.rs | 8 ++++---- src/lib.rs | 42 +++++++++++++++++++++--------------------- src/metadata.rs | 8 ++++---- src/vtable.rs | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 980f854a5ede1..b95c9e72ced31 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -1,7 +1,7 @@ use std::iter; -use rustc::hir; -use rustc_target::spec::abi::Abi; +use crate::rustc::hir; +use crate::rustc_target::spec::abi::Abi; use crate::prelude::*; diff --git a/src/analyze.rs b/src/analyze.rs index 048f8812d444b..2ef21dbb4592a 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use rustc::mir::StatementKind::*; +use crate::rustc::mir::StatementKind::*; bitflags! { pub struct Flags: u8 { diff --git a/src/base.rs b/src/base.rs index 8f2ab83ceeddc..c5620b62d5b15 100644 --- a/src/base.rs +++ b/src/base.rs @@ -27,7 +27,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( if inst.def_id().krate == LOCAL_CRATE => { let mut mir = ::std::io::Cursor::new(Vec::new()); - ::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) + crate::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) .unwrap(); String::from_utf8(mir.into_inner()).unwrap() } @@ -242,7 +242,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } => { let ty = location.ty(fx.mir, fx.tcx).to_ty(fx.tcx); let ty = fx.monomorphize(&ty); - let drop_fn = ::rustc_mir::monomorphize::resolve_drop_in_place(fx.tcx, ty); + let drop_fn = crate::rustc_mir::monomorphize::resolve_drop_in_place(fx.tcx, ty); if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything @@ -254,7 +254,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) &ty::RegionKind::ReErased, TypeAndMut { ty, - mutbl: ::rustc::hir::Mutability::MutMutable, + mutbl: crate::rustc::hir::Mutability::MutMutable, }, ), ); @@ -580,7 +580,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(size, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { - use rustc::middle::lang_items::ExchangeMallocFnLangItem; + use crate::rustc::middle::lang_items::ExchangeMallocFnLangItem; let usize_type = fx.cton_type(fx.tcx.types.usize).unwrap(); let (size, align) = fx.layout_of(content_ty).size_and_align(); diff --git a/src/common.rs b/src/common.rs index ad7269bccc453..9384f8c9b591c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,6 +1,6 @@ use std::fmt; -use rustc_target::spec::{HasTargetSpec, Target}; +use crate::rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::Module; @@ -372,7 +372,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { match (&self.layout().ty.sty, &from.layout().ty.sty) { (ty::Ref(_, t, dest_mut), ty::Ref(_, u, src_mut)) - if (if *dest_mut != ::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { + if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { false } else if t != u { false diff --git a/src/constant.rs b/src/constant.rs index 9274d313259c2..862ced4ce5c70 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,10 +1,10 @@ use cranelift_module::*; use crate::prelude::*; -use rustc::mir::interpret::{ +use crate::rustc::mir::interpret::{ read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, }; -use rustc::ty::Const; -use rustc_mir::interpret::{CompileTimeEvaluator, EvalContext, Memory, MemoryKind}; +use crate::rustc::ty::Const; +use crate::rustc_mir::interpret::{CompileTimeEvaluator, EvalContext, Memory, MemoryKind}; #[derive(Default)] pub struct ConstantCx { @@ -154,7 +154,7 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( def_id: DefId, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); - let is_mutable = if let ::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { + let is_mutable = if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { true } else { !tcx.type_of(def_id) diff --git a/src/lib.rs b/src/lib.rs index cbad8c76567a6..9d136a9d28a82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,14 +27,14 @@ use std::any::Any; use std::fs::File; use std::sync::{mpsc, Arc}; -use rustc::dep_graph::DepGraph; -use rustc::middle::cstore::MetadataLoader; -use rustc::session::{config::OutputFilenames, CompileIncomplete}; -use rustc::ty::query::Providers; -use rustc_codegen_utils::codegen_backend::CodegenBackend; -use rustc_codegen_utils::link::out_filename; -use rustc_data_structures::svh::Svh; -use syntax::symbol::Symbol; +use crate::rustc::dep_graph::DepGraph; +use crate::rustc::middle::cstore::MetadataLoader; +use crate::rustc::session::{config::OutputFilenames, CompileIncomplete}; +use crate::rustc::ty::query::Providers; +use crate::rustc_codegen_utils::codegen_backend::CodegenBackend; +use crate::rustc_codegen_utils::link::out_filename; +use crate::rustc_data_structures::svh::Svh; +use crate::syntax::symbol::Symbol; use cranelift::codegen::settings; use cranelift_faerie::*; @@ -60,24 +60,24 @@ mod prelude { pub use std::any::Any; pub use std::collections::{HashMap, HashSet}; - pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; - pub use rustc::mir; - pub use rustc::mir::interpret::AllocId; - pub use rustc::mir::*; - pub use rustc::session::{config::CrateType, Session}; - pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; - pub use rustc::ty::{ + pub use crate::rustc::hir::def_id::{DefId, LOCAL_CRATE}; + pub use crate::rustc::mir; + pub use crate::rustc::mir::interpret::AllocId; + pub use crate::rustc::mir::*; + pub use crate::rustc::session::{config::CrateType, Session}; + pub use crate::rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; + pub use crate::rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; - pub use rustc_data_structures::{ + pub use crate::rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, indexed_vec::Idx, sync::Lrc, }; - pub use rustc_mir::monomorphize::{collector, MonoItem}; - pub use syntax::ast::{FloatTy, IntTy, UintTy}; - pub use syntax::source_map::DUMMY_SP; + pub use crate::rustc_mir::monomorphize::{collector, MonoItem}; + pub use crate::syntax::ast::{FloatTy, IntTy, UintTy}; + pub use crate::syntax::source_map::DUMMY_SP; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, @@ -373,8 +373,8 @@ fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, ) { - use rustc::middle::lang_items::StartFnLangItem; - use rustc::session::config::EntryFnType; + use crate::rustc::middle::lang_items::StartFnLangItem; + use crate::rustc::session::config::EntryFnType; let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { Some((id, _, entry_ty)) => ( diff --git a/src/metadata.rs b/src/metadata.rs index 2653300c7b248..e4db778396360 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,5 +1,5 @@ -use rustc::middle::cstore::MetadataLoader; -use rustc_data_structures::owning_ref::{self, OwningRef}; +use crate::rustc::middle::cstore::MetadataLoader; +use crate::rustc_data_structures::owning_ref::{self, OwningRef}; use std::fs::File; use std::path::Path; @@ -8,7 +8,7 @@ pub struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { fn get_rlib_metadata( &self, - _target: &::rustc_target::spec::Target, + _target: &crate::rustc_target::spec::Target, path: &Path, ) -> Result, String> { let mut archive = ar::Archive::new(File::open(path).map_err(|e| format!("{:?}", e))?); @@ -33,7 +33,7 @@ impl MetadataLoader for CraneliftMetadataLoader { fn get_dylib_metadata( &self, - _target: &::rustc_target::spec::Target, + _target: &crate::rustc_target::spec::Target, _path: &Path, ) -> Result, String> { Err("dylib metadata loading is not yet supported".to_string()) diff --git a/src/vtable.rs b/src/vtable.rs index da9c3765588c4..6b4ae6a0aee6f 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -82,7 +82,7 @@ fn build_vtable<'a, 'tcx: 'a>( .unwrap() .size_and_align(); let drop_in_place_fn = - fx.get_function_id(::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty)); + fx.get_function_id(crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; From c6bb2e7223d467e124d7e8a36c94d608ea4846b0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 18 Sep 2018 18:41:41 +0200 Subject: [PATCH 0238/1566] Improve prepare_libcore.sh --- prepare_libcore.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/prepare_libcore.sh b/prepare_libcore.sh index 32e90144a25c7..75b6c8a908452 100755 --- a/prepare_libcore.sh +++ b/prepare_libcore.sh @@ -1,11 +1,14 @@ #!/bin/bash --verbose +set -e + SRC_DIR="target/libcore" -rm -rf $SRC_DIR && -mkdir -p $SRC_DIR/src && +rm -rf $SRC_DIR +mkdir -p $SRC_DIR/src cp -r $(dirname $(rustup which rustc))/../lib/rustlib/src/rust/src/libcore $SRC_DIR/src/libcore || (echo "Please install rust-src component"; exit 1) -cd $SRC_DIR || exit 1 -git init || exit 1 -git add . || exit 1 -git commit -m "Initial commit" -q || exit 1 -git apply ../../000*.patch || exit 1 +cd $SRC_DIR +git init +git add . +git commit -m "Initial commit" -q +git apply ../../000*.patch + echo "Successfully prepared libcore for building" From 46581af155e2f2a668bbd1145902cc40c39e3e69 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 18 Sep 2018 18:46:17 +0200 Subject: [PATCH 0239/1566] Replace an unimplemented! with a bug! --- src/abi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index b95c9e72ced31..82f8257b6329f 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -676,7 +676,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx.bcx.ins().imul_imm(len, elem_size as i64) } ty::Dynamic(..) => crate::vtable::size_of_obj(fx, args[0]), - ty => unimplemented!("size_of_val for {:?}", ty), + ty => bug!("size_of_val for unknown unsized type {:?}", ty), }; ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); } From a92566404c01704a73666bc687e067e846a86c7f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 18 Sep 2018 19:51:36 +0200 Subject: [PATCH 0240/1566] Update Cargo.lock --- Cargo.lock | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 166ecfb104bfc..c16e01349c32a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "aho-corasick" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -317,10 +317,12 @@ dependencies = [ [[package]] name = "memchr" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -378,7 +380,7 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -684,7 +686,7 @@ dependencies = [ "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" -"checksum memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a3b4142ab8738a78c51896f704f83c11df047ff1bda9a92a661aa6361552d93d" +"checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" From 056bf8ca7de6dc1cedb4e7c6c1282ef4eff7c02a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 20 Sep 2018 18:20:04 +0200 Subject: [PATCH 0241/1566] Rustup to rustc 1.30.0-nightly (20dc0c507 2018-09-19) --- ...nd-task-modules-because-they-contain.patch | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/0004-Disable-future-and-task-modules-because-they-contain.patch b/0004-Disable-future-and-task-modules-because-they-contain.patch index 422cacade9b71..9b272a8f34b61 100644 --- a/0004-Disable-future-and-task-modules-because-they-contain.patch +++ b/0004-Disable-future-and-task-modules-because-they-contain.patch @@ -1,6 +1,6 @@ -From 9db209102bf5f7850ccd456be0d5af09405ee950 Mon Sep 17 00:00:00 2001 +From 8838226899913c8636fa00f4dfbc7497c685abc5 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Thu, 30 Aug 2018 20:47:12 +0200 +Date: Thu, 20 Sep 2018 18:16:25 +0200 Subject: [PATCH] Disable future and task modules, because they contain unsized types @@ -10,10 +10,10 @@ Subject: [PATCH] Disable future and task modules, because they contain unsized 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 9b64b7d..9d2e230 100644 +index 09f5035..f129254 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -188,7 +188,7 @@ pub mod cell; +@@ -194,7 +194,7 @@ pub mod cell; pub mod char; pub mod panic; pub mod panicking; @@ -22,7 +22,7 @@ index 9b64b7d..9d2e230 100644 pub mod iter; pub mod option; pub mod raw; -@@ -202,9 +202,11 @@ pub mod time; +@@ -209,9 +209,11 @@ pub mod time; pub mod unicode; @@ -35,28 +35,28 @@ index 9b64b7d..9d2e230 100644 /* Heap memory allocator trait */ #[allow(missing_docs)] diff --git a/src/libcore/option.rs b/src/libcore/option.rs -index 3879abb..16204a8 100644 +index 58bf6be..902d38f 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -147,7 +147,7 @@ use iter::{FromIterator, FusedIterator, TrustedLen}; use {hint, mem, ops::{self, Deref}}; --use pin::PinMut; -+//use pin::PinMut; +-use pin::Pin; ++//use pin::Pin; // Note that this is not a lang item per se, but it has a hidden dependency on // `Iterator`, which is one. The compiler assumes that the `next` method of -@@ -270,6 +270,7 @@ impl Option { - } +@@ -271,6 +271,7 @@ impl Option { } + + /* - /// Converts from `Option` to `Option>` + /// Converts from `Pin<&Option>` to `Option>` #[inline] #[unstable(feature = "pin", issue = "49150")] -@@ -278,6 +279,7 @@ impl Option { - PinMut::get_mut_unchecked(self).as_mut().map(|x| PinMut::new_unchecked(x)) +@@ -288,6 +289,7 @@ impl Option { + Pin::get_mut_unchecked(self).as_mut().map(|x| Pin::new_unchecked(x)) } } + */ From ed9e766aa76e66edcdcccfc1c41d253a40e116c1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 20 Sep 2018 18:22:23 +0200 Subject: [PATCH 0242/1566] Update Cargo.lock --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c16e01349c32a..d0552a469a80e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" [[package]] name = "cranelift-entity" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" [[package]] name = "cranelift-faerie" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#9787326c89e5a823484f8bf61d14d09f45433011" +source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -478,7 +478,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -546,7 +546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -705,7 +705,7 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9" -"checksum serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "59790990c5115d16027f00913e2e66de23a51f70422e549d2ad68c8c5f268f1c" +"checksum serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "d30ec34ac923489285d24688c7a9c0898d16edff27fc1f1bd854edeff6ca3b7f" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" From bccc1fd7a1c36078f96441975562e2ffad4b292e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Sep 2018 11:12:25 +0200 Subject: [PATCH 0243/1566] Rustup to rustc 1.30.0-nightly (63c75d375 2018-09-21) --- 0002-Disable-u128-and-i128-in-libcore.patch | 122 ++++++-------------- 1 file changed, 34 insertions(+), 88 deletions(-) diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch index a8d2745c95580..cf731ad89bda7 100644 --- a/0002-Disable-u128-and-i128-in-libcore.patch +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From 7f8b6fdc01a17a0f963ac05bf9a488c093307090 Mon Sep 17 00:00:00 2001 +From 5a91929290f0ced810185e9f81bbdb4d5cf53804 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 8 Sep 2018 11:06:28 +0200 +Date: Sat, 22 Sep 2018 11:09:38 +0200 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -8,20 +8,19 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/cmp.rs | 6 +-- src/libcore/default.rs | 2 - src/libcore/fmt/num.rs | 6 +-- - src/libcore/hash/mod.rs | 20 --------- + src/libcore/hash/mod.rs | 20 -------- src/libcore/iter/range.rs | 1 - src/libcore/iter/traits.rs | 2 +- - src/libcore/lib.rs | 2 - + src/libcore/lib.rs | 4 +- src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 99 ++++++++++++-------------------------------- - src/libcore/num/wrapping.rs | 14 +++---- - src/libcore/ops/arith.rs | 22 +++++----- - src/libcore/ops/bit.rs | 30 +++++--------- - src/libcore/tests/iter.rs | 15 ------- - src/libcore/tests/num/mod.rs | 18 -------- - src/libcore/time.rs | 51 ----------------------- - 17 files changed, 62 insertions(+), 236 deletions(-) + src/libcore/num/mod.rs | 99 ++++++++++-------------------------- + src/libcore/num/wrapping.rs | 14 ++--- + src/libcore/ops/arith.rs | 22 ++++---- + src/libcore/ops/bit.rs | 30 ++++------- + src/libcore/tests/iter.rs | 15 ------ + src/libcore/tests/num/mod.rs | 18 ------- + 16 files changed, 63 insertions(+), 186 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 3b15ba2..de08ce0 100644 @@ -213,10 +212,10 @@ index 4b2c1aa..ec3991f 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index fb90be8..310f376 100644 +index 6a3f169..883ae4b 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -152,14 +152,12 @@ mod uint_macros; +@@ -151,14 +151,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -231,8 +230,17 @@ index fb90be8..310f376 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; +@@ -208,7 +206,7 @@ pub mod slice; + pub mod str; + pub mod hash; + pub mod fmt; +-pub mod time; ++//pub mod time; + + pub mod unicode; + diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index dd57d2d..b75376b 100644 +index 5572fe1..c8d8144 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -672,8 +672,8 @@ mod copy_impls { @@ -264,7 +272,7 @@ index 1803ade..f7fb0cb 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 5ae984a..63b3754 100644 +index 12da045..f02bf78 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -105,7 +105,6 @@ nonzero_integers! { @@ -275,7 +283,7 @@ index 5ae984a..63b3754 100644 NonZeroUsize(usize); } -@@ -2282,18 +2281,6 @@ impl i64 { +@@ -2285,18 +2284,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -294,7 +302,7 @@ index 5ae984a..63b3754 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4729,17 +4716,6 @@ impl u64 { +@@ -4732,17 +4719,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -312,7 +320,7 @@ index 5ae984a..63b3754 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4823,7 +4799,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4826,7 +4802,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -321,7 +329,7 @@ index 5ae984a..63b3754 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4939,30 +4915,25 @@ macro_rules! rev { +@@ -4942,30 +4918,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -356,7 +364,7 @@ index 5ae984a..63b3754 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4974,21 +4945,21 @@ mod ptr_try_from_impls { +@@ -4977,21 +4948,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -386,7 +394,7 @@ index 5ae984a..63b3754 100644 } #[cfg(target_pointer_width = "32")] -@@ -4997,24 +4968,24 @@ mod ptr_try_from_impls { +@@ -5000,24 +4971,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -419,7 +427,7 @@ index 5ae984a..63b3754 100644 } #[cfg(target_pointer_width = "64")] -@@ -5023,24 +4994,20 @@ mod ptr_try_from_impls { +@@ -5026,24 +4997,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -448,7 +456,7 @@ index 5ae984a..63b3754 100644 } #[doc(hidden)] -@@ -5075,7 +5042,7 @@ macro_rules! doit { +@@ -5078,7 +5045,7 @@ macro_rules! doit { } })*) } @@ -457,7 +465,7 @@ index 5ae984a..63b3754 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -5243,52 +5210,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -5246,52 +5213,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -935,68 +943,6 @@ index ab96d31..bb5c1d0 100644 test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } -diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index b589202..0f8a2ee 100644 ---- a/src/libcore/time.rs -+++ b/src/libcore/time.rs -@@ -268,57 +268,6 @@ impl Duration { - #[inline] - pub const fn subsec_nanos(&self) -> u32 { self.nanos } - -- /// Returns the total number of whole milliseconds contained by this `Duration`. -- /// -- /// # Examples -- /// -- /// ``` -- /// # #![feature(duration_as_u128)] -- /// use std::time::Duration; -- /// -- /// let duration = Duration::new(5, 730023852); -- /// assert_eq!(duration.as_millis(), 5730); -- /// ``` -- #[unstable(feature = "duration_as_u128", issue = "50202")] -- #[inline] -- pub fn as_millis(&self) -> u128 { -- self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 -- } -- -- /// Returns the total number of whole microseconds contained by this `Duration`. -- /// -- /// # Examples -- /// -- /// ``` -- /// # #![feature(duration_as_u128)] -- /// use std::time::Duration; -- /// -- /// let duration = Duration::new(5, 730023852); -- /// assert_eq!(duration.as_micros(), 5730023); -- /// ``` -- #[unstable(feature = "duration_as_u128", issue = "50202")] -- #[inline] -- pub fn as_micros(&self) -> u128 { -- self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128 -- } -- -- /// Returns the total number of nanoseconds contained by this `Duration`. -- /// -- /// # Examples -- /// -- /// ``` -- /// # #![feature(duration_as_u128)] -- /// use std::time::Duration; -- /// -- /// let duration = Duration::new(5, 730023852); -- /// assert_eq!(duration.as_nanos(), 5730023852); -- /// ``` -- #[unstable(feature = "duration_as_u128", issue = "50202")] -- #[inline] -- pub fn as_nanos(&self) -> u128 { -- self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128 -- } -- - /// Checked `Duration` addition. Computes `self + other`, returning [`None`] - /// if overflow occurred. - /// -- -2.15.2 (Apple Git-101.1) +2.17.1 (Apple Git-112) From 663533fec355a40e082f9769c95ba8c78914ca1e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Sep 2018 11:14:45 +0200 Subject: [PATCH 0244/1566] Patch faerie for Mach-O support --- Cargo.lock | 8 ++++---- Cargo.toml | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0552a469a80e..58117cee0c5b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,7 +135,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472 dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.5.0 (git+https://github.com/m4b/faerie.git?branch=mach_data_relocations)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -219,7 +219,7 @@ dependencies = [ [[package]] name = "faerie" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/m4b/faerie.git?branch=mach_data_relocations#c8587ada91fd0af6961e0a884fa44454efbb2a21" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -423,7 +423,7 @@ dependencies = [ "cranelift-faerie 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.5.0 (git+https://github.com/m4b/faerie.git?branch=mach_data_relocations)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -674,7 +674,7 @@ dependencies = [ "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3a1085754e4ac8a52d1bfe21ddeb534ac25800b56586a64554c3c32944ccb0b8" +"checksum faerie 0.5.0 (git+https://github.com/m4b/faerie.git?branch=mach_data_relocations)" = "" "checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" "checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" diff --git a/Cargo.toml b/Cargo.toml index 89fe97f05ecdb..665c37e4f4165 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,4 +29,8 @@ byteorder = "1.2.6" #cranelift = { path = "../cranelift/lib/umbrella" } #cranelift-module = { path = "../cranelift/lib/module" } #cranelift-simplejit = { path = "../cranelift/lib/simplejit" } -#cranelift-faerie = { path = "../cranelift/lib/faerie" } \ No newline at end of file +#cranelift-faerie = { path = "../cranelift/lib/faerie" } + +[patch.crates-io] +# Use https://github.com/m4b/faerie/pull/47, because faerie 0.5.0 doesn't create valid Mach-O binaries +faerie = { git = "https://github.com/m4b/faerie.git", branch = "mach_data_relocations" } From f1270426390116bfda9e4419aaccb1989a134ec0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Sep 2018 12:15:56 +0200 Subject: [PATCH 0245/1566] Rename examples directory to example to prevent rls trying to compile its content --- build.sh | 8 ++++---- {examples => example}/example.rs | 0 {examples => example}/mini_core.rs | 0 {examples => example}/mini_core_hello_world.rs | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename {examples => example}/example.rs (100%) rename {examples => example}/mini_core.rs (100%) rename {examples => example}/mini_core_hello_world.rs (100%) diff --git a/build.sh b/build.sh index eb39e57490278..245fc7cea3eca 100755 --- a/build.sh +++ b/build.sh @@ -59,15 +59,15 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -build_lib mini_core examples/mini_core.rs +build_lib mini_core example/mini_core.rs -$RUSTC examples/example.rs --crate-type lib +$RUSTC example/example.rs --crate-type lib echo "[JIT] mini_core_hello_world" -run_bin examples/mini_core_hello_world.rs --cfg jit +run_bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" -build_example_bin mini_core_hello_world examples/mini_core_hello_world.rs +build_example_bin mini_core_hello_world example/mini_core_hello_world.rs echo "[BUILD] core" time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core -Cincremental=target/incremental_core diff --git a/examples/example.rs b/example/example.rs similarity index 100% rename from examples/example.rs rename to example/example.rs diff --git a/examples/mini_core.rs b/example/mini_core.rs similarity index 100% rename from examples/mini_core.rs rename to example/mini_core.rs diff --git a/examples/mini_core_hello_world.rs b/example/mini_core_hello_world.rs similarity index 100% rename from examples/mini_core_hello_world.rs rename to example/mini_core_hello_world.rs From a83e7766b7ceca85b24e7d406ae917f3a1a70d87 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Sep 2018 13:55:23 +0200 Subject: [PATCH 0246/1566] Update Cargo.lock --- Cargo.lock | 40 ++++++++++++++++++++-------------------- src/lib.rs | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58117cee0c5b5..5225e95deafe1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,7 +11,7 @@ name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -29,7 +29,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -41,7 +41,7 @@ dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" [[package]] name = "cranelift-entity" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" [[package]] name = "cranelift-faerie" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,7 +152,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +173,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#7d08f6da158693215472a1ff7a6adc3203f9797c" +source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -204,7 +204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -404,7 +404,7 @@ dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -615,7 +615,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -632,7 +632,7 @@ name = "winapi-util" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -645,7 +645,7 @@ name = "wincolor" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -723,7 +723,7 @@ dependencies = [ "checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" -"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" +"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/src/lib.rs b/src/lib.rs index 9d136a9d28a82..fb717d4454202 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -215,7 +215,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .declare_function("main", Linkage::Import, &sig) .unwrap(); - jit_module.finalize_all(); + jit_module.finalize_definitions(); let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); println!("🎉 Finalized everything"); @@ -242,7 +242,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.abort_if_errors(); if should_codegen(tcx.sess) { - faerie_module.finalize_all(); + faerie_module.finalize_definitions(); } return Box::new(OngoingCodegen { From 5b721a29407c3f79e729a2f61ecd03bd3c4059c4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 23 Sep 2018 10:16:26 +0200 Subject: [PATCH 0247/1566] Rustup to rustc 1.30.0-nightly (4591a245c 2018-09-22) --- Cargo.lock | 10 +++++----- Cargo.toml | 6 +----- src/base.rs | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5225e95deafe1..28b6411febff1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -135,7 +135,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93d dependencies = [ "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.5.0 (git+https://github.com/m4b/faerie.git?branch=mach_data_relocations)", + "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -218,8 +218,8 @@ dependencies = [ [[package]] name = "faerie" -version = "0.5.0" -source = "git+https://github.com/m4b/faerie.git?branch=mach_data_relocations#c8587ada91fd0af6961e0a884fa44454efbb2a21" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -423,7 +423,7 @@ dependencies = [ "cranelift-faerie 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.5.0 (git+https://github.com/m4b/faerie.git?branch=mach_data_relocations)", + "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -674,7 +674,7 @@ dependencies = [ "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.5.0 (git+https://github.com/m4b/faerie.git?branch=mach_data_relocations)" = "" +"checksum faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c878c9fe0eb38d5fe1a09c5df7348253b7e6a67868fd8540be525dc04d63cb" "checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" "checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" diff --git a/Cargo.toml b/Cargo.toml index 665c37e4f4165..2fc6666871d79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.0.3" #goblin = "0.0.17" -faerie = "0.5.0" +faerie = "0.5.1" ar = "0.6.0" bitflags = "1.0.3" byteorder = "1.2.6" @@ -30,7 +30,3 @@ byteorder = "1.2.6" #cranelift-module = { path = "../cranelift/lib/module" } #cranelift-simplejit = { path = "../cranelift/lib/simplejit" } #cranelift-faerie = { path = "../cranelift/lib/faerie" } - -[patch.crates-io] -# Use https://github.com/m4b/faerie/pull/47, because faerie 0.5.0 doesn't create valid Mach-O binaries -faerie = { git = "https://github.com/m4b/faerie.git", branch = "mach_data_relocations" } diff --git a/src/base.rs b/src/base.rs index c5620b62d5b15..f01cf12e0be39 100644 --- a/src/base.rs +++ b/src/base.rs @@ -629,7 +629,7 @@ fn trans_stmt<'a, 'tcx: 'a>( StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::Nop - | StatementKind::ReadForMatch(_) + | StatementKind::FakeRead(..) | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) | StatementKind::AscribeUserType(..) => {} From a99e458022444608880936fe20a30ffa573bf0e8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 24 Sep 2018 19:31:46 +0200 Subject: [PATCH 0248/1566] Rustup to rustc 1.30.0-nightly (f49f6e73a 2018-09-23) --- 0001-Disable-stdsimd-in-libcore.patch | 24 ++++----- src/constant.rs | 71 +++++++++++++++++++++++---- 2 files changed, 74 insertions(+), 21 deletions(-) diff --git a/0001-Disable-stdsimd-in-libcore.patch b/0001-Disable-stdsimd-in-libcore.patch index 7db533929d8bc..dbbaf6ca841d1 100644 --- a/0001-Disable-stdsimd-in-libcore.patch +++ b/0001-Disable-stdsimd-in-libcore.patch @@ -1,6 +1,6 @@ -From a26747487d398af360dc16344b1f9d2b367720c9 Mon Sep 17 00:00:00 2001 +From 09ba4e4d2574ba591524cffe18eb11e05e6726a4 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Thu, 19 Jul 2018 18:26:56 +0200 +Date: Mon, 24 Sep 2018 18:50:20 +0200 Subject: [PATCH] Disable stdsimd in libcore --- @@ -8,22 +8,22 @@ Subject: [PATCH] Disable stdsimd in libcore 1 file changed, 2 insertions(+) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index bbe6ae8619..bdeb6ce426 100644 +index 3b7646f..d349a49 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -238,6 +238,7 @@ macro_rules! test_v256 { ($item:item) => {}; } - macro_rules! test_v512 { ($item:item) => {}; } - #[allow(unused_macros)] - macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } } +@@ -226,6 +226,7 @@ mod nonzero; + mod tuple; + mod unit; + +/* - #[path = "../stdsimd/coresimd/mod.rs"] - #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)] - #[unstable(feature = "stdsimd", issue = "48556")] -@@ -250,3 +251,4 @@ pub use coresimd::simd; + // Pull in the the `coresimd` crate directly into libcore. This is where all the + // architecture-specific (and vendor-specific) intrinsics are defined. AKA + // things like SIMD and such. Note that the actual source for all this lies in a +@@ -256,3 +257,4 @@ mod coresimd; #[stable(feature = "simd_arch", since = "1.27.0")] #[cfg(not(stage0))] pub use coresimd::arch; +*/ --- +-- 2.11.0 diff --git a/src/constant.rs b/src/constant.rs index 862ced4ce5c70..94c2e85411a1e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,10 +1,10 @@ use cranelift_module::*; use crate::prelude::*; use crate::rustc::mir::interpret::{ - read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, + read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; use crate::rustc::ty::Const; -use crate::rustc_mir::interpret::{CompileTimeEvaluator, EvalContext, Memory, MemoryKind}; +use crate::rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, OpTy, PlaceTy}; #[derive(Default)] pub struct ConstantCx { @@ -124,7 +124,7 @@ fn trans_const_place<'a, 'tcx: 'a>( let mut ecx = EvalContext::new( fx.tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all(), - CompileTimeEvaluator, + TransPlaceInterpreter, (), ); let op = ecx.const_to_op(const_)?; @@ -155,11 +155,11 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); let is_mutable = if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { - true - } else { - !tcx.type_of(def_id) - .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) - }; + true + } else { + !tcx.type_of(def_id) + .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + }; module .declare_data(&*symbol_name, Linkage::Export, is_mutable) .unwrap() @@ -185,7 +185,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( module: &mut Module, cx: &mut ConstantCx, ) { - let memory = Memory::::new(tcx.at(DUMMY_SP), ()); + let memory = Memory::::new(tcx.at(DUMMY_SP), ()); while let Some(todo_item) = pop_set(&mut cx.todo) { let (data_id, alloc) = match todo_item { @@ -269,3 +269,56 @@ fn pop_set(set: &mut HashSet) -> Option None } } + +struct TransPlaceInterpreter; + +impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { + type MemoryData = (); + type MemoryKinds = (); + const MUT_STATIC_KIND: Option<()> = None; + + fn before_terminator(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { + panic!(); + } + + fn find_fn( + _: &mut EvalContext<'a, 'mir, 'tcx, Self>, + _: Instance<'tcx>, + _: &[OpTy<'tcx>], + _: Option>, + _: Option, + ) -> EvalResult<'tcx, Option<&'mir Mir<'tcx>>> { + panic!(); + } + + fn call_intrinsic( + _: &mut EvalContext<'a, 'mir, 'tcx, Self>, + _: Instance<'tcx>, + _: &[OpTy<'tcx>], + _: PlaceTy<'tcx>, + ) -> EvalResult<'tcx> { + panic!(); + } + + fn find_foreign_static( + _: crate::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, + _: DefId, + ) -> EvalResult<'tcx, &'tcx Allocation> { + panic!(); + } + + fn ptr_op( + _: &EvalContext<'a, 'mir, 'tcx, Self>, + _: mir::BinOp, + _: Scalar, + _: TyLayout<'tcx>, + _: Scalar, + _: TyLayout<'tcx>, + ) -> EvalResult<'tcx, (Scalar, bool)> { + panic!(); + } + + fn box_alloc(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> EvalResult<'tcx> { + panic!(); + } +} From aa7855cc1b8346748febf665900a637d92ed66b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 25 Sep 2018 05:57:33 +0000 Subject: [PATCH 0249/1566] Bump cranelift from `dcd54af` to `940e254` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `dcd54af` to `940e254`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/dcd54af61885eb5ba93da724120c101d55e3e9f9...940e2545fd041a766a48316fab0fb079d139da23) Signed-off-by: dependabot[bot] --- Cargo.lock | 98 +++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28b6411febff1..c8615405d0e6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,29 +89,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -120,21 +120,21 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" [[package]] name = "cranelift-entity" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" [[package]] name = "cranelift-faerie" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -143,41 +143,41 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-module" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.21.1" -source = "git+https://github.com/CraneStation/cranelift.git#dcd54af61885eb5ba93da724120c101d55e3e9f9" +version = "0.22.0" +source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" dependencies = [ - "cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -419,10 +419,10 @@ dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.21.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -661,16 +661,16 @@ dependencies = [ "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum cranelift 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.21.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From b11cb572dcf2a2868e977e1b2521df7cf5edbe5e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 25 Sep 2018 18:02:37 +0200 Subject: [PATCH 0250/1566] Use cranelift_frontend::Switch for switchInt --- Cargo.lock | 63 +++++++++++++++++++------------- example/mini_core.rs | 15 ++++++++ example/mini_core_hello_world.rs | 11 ++++++ src/base.rs | 21 ++++------- 4 files changed, 71 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8615405d0e6e..b751a1a3eae39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,15 +144,16 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -163,7 +164,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,7 +174,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#940e2545fd041a766a48316fab0fb079d139da23" +source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -226,7 +227,7 @@ dependencies = [ "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -265,7 +266,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -291,7 +292,7 @@ name = "lazy_static" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -322,7 +323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -442,20 +443,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "scroll" -version = "0.9.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "scroll_derive" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -478,7 +480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -528,6 +530,16 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" version = "0.9.0" @@ -546,7 +558,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -610,7 +622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "version_check" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -700,17 +712,18 @@ dependencies = [ "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" -"checksum scroll 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66f024a8cc5e456eb870f688dbd899c84f61190c82c7a911e40f926941969074" -"checksum scroll_derive 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a353f5dd99e42ff097d5a61db3257aa2c7127d76a3fa8287b642ef9ae0f7c5" +"checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" +"checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9" -"checksum serde_json 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "d30ec34ac923489285d24688c7a9c0898d16edff27fc1f1bd854edeff6ca3b7f" +"checksum serde_json 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "7f60a296fed15c3edbbe9aa83b646531459e565c525b0ab628deb1a4b28e4180" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" "checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" +"checksum syn 0.15.6 (registry+https://github.com/rust-lang/crates.io-index)" = "854b08a640fc8f54728fb95321e3ec485b365a97fe47609797c671addd1dde69" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" @@ -722,7 +735,7 @@ dependencies = [ "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" +"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" diff --git a/example/mini_core.rs b/example/mini_core.rs index 0c9eb7a01f05b..455661bd77e15 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -170,6 +170,21 @@ impl PartialEq for *const T { } } +#[lang = "neg"] +pub trait Neg { + type Output; + + fn neg(self) -> Self::Output; +} + +impl Neg for isize { + type Output = isize; + + fn neg(self) -> isize { + -self + } +} + pub enum Option { Some(T), None, diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index a60d2363ad1e7..3e6d2aa992ad8 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -74,6 +74,12 @@ impl Drop for NoisyDropInner { } } +enum Ordering { + Less = -1, + Equal = 0, + Greater = 1, +} + #[lang = "start"] fn start( main: fn() -> T, @@ -157,4 +163,9 @@ fn main() { Some(_) => {}, None => assert!(false), } + + match Ordering::Less { + Ordering::Less => {}, + _ => assert!(false), + } } diff --git a/src/base.rs b/src/base.rs index f01cf12e0be39..e3df8769b987b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -202,21 +202,14 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) values, targets, } => { - // TODO: prevent panics on large and negative disciminants - if should_codegen(fx.tcx.sess) { - let discr = trans_operand(fx, discr).load_value(fx); - let mut jt_data = JumpTableData::new(); - for (i, value) in values.iter().enumerate() { - let ebb = fx.get_ebb(targets[i]); - jt_data.set_entry(*value as usize, ebb); - } - let jump_table = fx.bcx.create_jump_table(jt_data); - fx.bcx.ins().br_table(discr, jump_table); - let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); - fx.bcx.ins().jump(otherwise_ebb, &[]); - } else { - fx.bcx.ins().trap(TrapCode::User(0)); + let discr = trans_operand(fx, discr).load_value(fx); + let mut switch = ::cranelift::frontend::Switch::new(); + for (i, value) in values.iter().enumerate() { + let ebb = fx.get_ebb(targets[i]); + switch.set_entry(*value as u64, ebb); } + let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); + switch.emit(&mut fx.bcx, discr, otherwise_ebb); } TerminatorKind::Call { func, From 889150a4f9eb603a90ec241d14777e001b2c3b08 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 25 Sep 2018 18:35:05 +0200 Subject: [PATCH 0251/1566] Implement binop eq and ne for fat ptr's --- ...nd-task-modules-because-they-contain.patch | 68 ------------------- ...me-more-unsupported-stuff-in-libcore.patch | 0 src/base.rs | 61 ++++++++++------- 3 files changed, 36 insertions(+), 93 deletions(-) delete mode 100644 0004-Disable-future-and-task-modules-because-they-contain.patch rename 0005-Disable-some-more-unsupported-stuff-in-libcore.patch => 0004-Disable-some-more-unsupported-stuff-in-libcore.patch (100%) diff --git a/0004-Disable-future-and-task-modules-because-they-contain.patch b/0004-Disable-future-and-task-modules-because-they-contain.patch deleted file mode 100644 index 9b272a8f34b61..0000000000000 --- a/0004-Disable-future-and-task-modules-because-they-contain.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 8838226899913c8636fa00f4dfbc7497c685abc5 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Thu, 20 Sep 2018 18:16:25 +0200 -Subject: [PATCH] Disable future and task modules, because they contain unsized - types - ---- - src/libcore/lib.rs | 4 +++- - src/libcore/option.rs | 4 +++- - 2 files changed, 6 insertions(+), 2 deletions(-) - -diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 09f5035..f129254 100644 ---- a/src/libcore/lib.rs -+++ b/src/libcore/lib.rs -@@ -194,7 +194,7 @@ pub mod cell; - pub mod char; - pub mod panic; - pub mod panicking; --pub mod pin; -+//pub mod pin; - pub mod iter; - pub mod option; - pub mod raw; -@@ -209,9 +209,11 @@ pub mod time; - - pub mod unicode; - -+/* - /* Async */ - pub mod future; - pub mod task; -+*/ - - /* Heap memory allocator trait */ - #[allow(missing_docs)] -diff --git a/src/libcore/option.rs b/src/libcore/option.rs -index 58bf6be..902d38f 100644 ---- a/src/libcore/option.rs -+++ b/src/libcore/option.rs -@@ -147,7 +147,7 @@ - - use iter::{FromIterator, FusedIterator, TrustedLen}; - use {hint, mem, ops::{self, Deref}}; --use pin::Pin; -+//use pin::Pin; - - // Note that this is not a lang item per se, but it has a hidden dependency on - // `Iterator`, which is one. The compiler assumes that the `next` method of -@@ -271,6 +271,7 @@ impl Option { - } - - -+ /* - /// Converts from `Pin<&Option>` to `Option>` - #[inline] - #[unstable(feature = "pin", issue = "49150")] -@@ -288,6 +289,7 @@ impl Option { - Pin::get_mut_unchecked(self).as_mut().map(|x| Pin::new_unchecked(x)) - } - } -+ */ - - ///////////////////////////////////////////////////////////////////////// - // Getting to contained values --- -2.11.0 - diff --git a/0005-Disable-some-more-unsupported-stuff-in-libcore.patch b/0004-Disable-some-more-unsupported-stuff-in-libcore.patch similarity index 100% rename from 0005-Disable-some-more-unsupported-stuff-in-libcore.patch rename to 0004-Disable-some-more-unsupported-stuff-in-libcore.patch diff --git a/src/base.rs b/src/base.rs index e3df8769b987b..590f6d6326476 100644 --- a/src/base.rs +++ b/src/base.rs @@ -968,38 +968,49 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, - ty: Ty<'tcx>, + ret_ty: Ty<'tcx>, ) -> CValue<'tcx> { match lhs.layout().ty.sty { ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { - if !ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { - unimpl!("Unsized values are not yet implemented"); + if ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { + binop_match! { + fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) iadd; + } + } else { + let lhs = lhs.load_value_pair(fx).0; + let rhs = rhs.load_value_pair(fx).0; + let res = match bin_op { + BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs), + BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs), + _ => unimplemented!("trans_ptr_binop({:?}, , ) not implemented", bin_op), + }; + + assert_eq!(fx.tcx.types.bool, ret_ty); + let ret_layout = fx.layout_of(ret_ty); + CValue::ByVal(fx.bcx.ins().bint(types::I8, res), ret_layout) } } _ => bug!("trans_ptr_binop on non ptr"), } - binop_match! { - fx, bin_op, false, lhs, rhs, ty, "ptr"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) iadd; - } } pub fn trans_place<'a, 'tcx: 'a>( From fbe35291afbab8daf486afed438765b87e6ec6a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 26 Sep 2018 05:55:45 +0000 Subject: [PATCH 0252/1566] Bump cranelift from `0157cda` to `8a79275` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `0157cda` to `8a79275`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4...8a79275d8900266a42a97890ecde5264a9caa295) Signed-off-by: dependabot[bot] --- Cargo.lock | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b751a1a3eae39..b986be61f4c22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,16 +144,17 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -164,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -174,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0157cdabe4f96bf4cb6cf9f7a207cbe38b89dab4" +source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From 16e936b93f5318aa34d309a8a3c4904a32b30c95 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 26 Sep 2018 15:40:11 +0200 Subject: [PATCH 0253/1566] Rustfmt --- src/abi.rs | 23 +++++++++++++++-------- src/base.rs | 18 +++++++++++------- src/common.rs | 10 ++++++++-- src/constant.rs | 9 ++++++--- src/vtable.rs | 5 +++-- 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 82f8257b6329f..2388807025985 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -49,7 +49,11 @@ fn get_pass_mode<'a, 'tcx: 'a>( PassMode::ByVal(ret_ty) } else { if abi == Abi::C { - unimpl!("Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}", ty, is_return); + unimpl!( + "Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}", + ty, + is_return + ); } PassMode::ByRef } @@ -667,9 +671,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( assert_eq!(args.len(), 1); let layout = fx.layout_of(substs.type_at(0)); let size = match &layout.ty.sty { - _ if !layout.is_unsized() => { - fx.bcx.ins().iconst(fx.module.pointer_type(), layout.size.bytes() as i64) - } + _ if !layout.is_unsized() => fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), layout.size.bytes() as i64), ty::Slice(elem) => { let len = args[0].load_value_pair(fx).1; let elem_size = fx.layout_of(elem).size.bytes(); @@ -690,9 +695,10 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( assert_eq!(args.len(), 1); let layout = fx.layout_of(substs.type_at(0)); let align = match &layout.ty.sty { - _ if !layout.is_unsized() => { - fx.bcx.ins().iconst(fx.module.pointer_type(), layout.align.abi() as i64) - } + _ if !layout.is_unsized() => fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), layout.align.abi() as i64), ty::Slice(elem) => { let align = fx.layout_of(elem).align.abi() as i64; fx.bcx.ins().iconst(fx.module.pointer_type(), align) @@ -860,7 +866,8 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("atomic_fence") => {} _ if intrinsic.starts_with("atomic_load") => { assert_eq!(args.len(), 1); - let inner_layout = fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); + let inner_layout = + fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); let val = CValue::ByRef(args[0].load_value(fx), inner_layout); ret.write_cvalue(fx, val); } diff --git a/src/base.rs b/src/base.rs index 590f6d6326476..f3088da411986 100644 --- a/src/base.rs +++ b/src/base.rs @@ -27,8 +27,11 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( if inst.def_id().krate == LOCAL_CRATE => { let mut mir = ::std::io::Cursor::new(Vec::new()); - crate::rustc_mir::util::write_mir_pretty(tcx, Some(inst.def_id()), &mut mir) - .unwrap(); + crate::rustc_mir::util::write_mir_pretty( + tcx, + Some(inst.def_id()), + &mut mir, + ).unwrap(); String::from_utf8(mir.into_inner()).unwrap() } InstanceDef::Item(_) @@ -436,12 +439,10 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); fx.bcx.ins().bint(types::I8, res) } - ty::Uint(_) | ty::Int(_) => { - fx.bcx.ins().bnot(val) - } + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().bnot(val), _ => unimplemented!("un op Not for {:?}", layout.ty), } - }, + } UnOp::Neg => match layout.ty.sty { ty::Int(_) => { let clif_ty = fx.cton_type(layout.ty).unwrap(); @@ -1001,7 +1002,10 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( let res = match bin_op { BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs), BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs), - _ => unimplemented!("trans_ptr_binop({:?}, , ) not implemented", bin_op), + _ => unimplemented!( + "trans_ptr_binop({:?}, , ) not implemented", + bin_op + ), }; assert_eq!(fx.tcx.types.bool, ret_ty); diff --git a/src/common.rs b/src/common.rs index 9384f8c9b591c..51706c888e4de 100644 --- a/src/common.rs +++ b/src/common.rs @@ -372,7 +372,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { match (&self.layout().ty.sty, &from.layout().ty.sty) { (ty::Ref(_, t, dest_mut), ty::Ref(_, u, src_mut)) - if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { + if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable + && src_mut != dest_mut + { false } else if t != u { false @@ -449,7 +451,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ) -> CPlace<'tcx> { match self { CPlace::Var(var, layout) => { - bug!("Tried to project {:?}, which is put in SSA var {:?}", layout.ty, var); + bug!( + "Tried to project {:?}, which is put in SSA var {:?}", + layout.ty, + var + ); } CPlace::Addr(base, extra, layout) => { let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); diff --git a/src/constant.rs b/src/constant.rs index 94c2e85411a1e..30dab10495f95 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -154,7 +154,8 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( def_id: DefId, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); - let is_mutable = if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { + let is_mutable = + if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { true } else { !tcx.type_of(def_id) @@ -235,11 +236,13 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { AllocType::Function(instance) => { let (func_name, sig) = crate::abi::get_function_name_and_sig(tcx, instance); - let func_id = module.declare_function(&func_name, Linkage::Import, &sig).unwrap(); + let func_id = module + .declare_function(&func_name, Linkage::Import, &sig) + .unwrap(); let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx); data_ctx.write_function_addr(reloc_offset as u32, local_func_id); continue; - }, + } AllocType::Memory(_) => { cx.todo.insert(TodoItem::Alloc(reloc)); data_id_for_alloc_id(module, reloc) diff --git a/src/vtable.rs b/src/vtable.rs index 6b4ae6a0aee6f..e8e3899e38891 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -81,8 +81,9 @@ fn build_vtable<'a, 'tcx: 'a>( .layout_of(ParamEnv::reveal_all().and(ty)) .unwrap() .size_and_align(); - let drop_in_place_fn = - fx.get_function_id(crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty)); + let drop_in_place_fn = fx.get_function_id( + crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty), + ); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; From 742a795c78773d997f5d475c32574536b91b0688 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 26 Sep 2018 15:42:07 +0200 Subject: [PATCH 0254/1566] Use FunctionBuilder::call_mem{cpy,move} --- src/abi.rs | 15 ++++++++------- src/base.rs | 5 ++++- src/common.rs | 2 ++ src/lib.rs | 20 ++++++++++++-------- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 2388807025985..e1ac63a0c9d5e 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -646,15 +646,16 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( .ins() .iconst(fx.module.pointer_type(), elem_size as i64); assert_eq!(args.len(), 3); - let src = args[0]; - let dst = args[1]; + let src = args[0].load_value(fx); + let dst = args[1].load_value(fx); let count = args[2].load_value(fx); let byte_amount = fx.bcx.ins().imul(count, elem_size); - fx.easy_call( - "memmove", - &[dst, src, CValue::ByVal(byte_amount, usize_layout)], - nil_ty, - ); + + if intrinsic.ends_with("_nonoverlapping") { + fx.bcx.call_memcpy(fx.isa, dst, src, byte_amount); + } else { + fx.bcx.call_memmove(fx.isa, dst, src, byte_amount); + } } "discriminant_value" => { assert_eq!(args.len(), 1); diff --git a/src/base.rs b/src/base.rs index f3088da411986..3ba4b75a071e4 100644 --- a/src/base.rs +++ b/src/base.rs @@ -11,6 +11,7 @@ impl String> Drop for PrintOnPanic { pub fn trans_mono_item<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, + isa: &isa::TargetIsa, module: &mut Module, caches: &mut Caches<'tcx>, ccx: &mut crate::constant::ConstantCx, @@ -47,7 +48,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } }); - trans_fn(tcx, module, ccx, caches, inst); + trans_fn(tcx, isa, module, ccx, caches, inst); } MonoItem::Static(def_id) => { crate::constant::codegen_static(ccx, def_id); @@ -60,6 +61,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( fn trans_fn<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, + isa: &isa::TargetIsa, module: &mut Module, constants: &mut crate::constant::ConstantCx, caches: &mut Caches<'tcx>, @@ -89,6 +91,7 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 5. Make FunctionCx let mut fx = FunctionCx { tcx, + isa, module, instance, mir, diff --git a/src/common.rs b/src/common.rs index 51706c888e4de..64cdd182175f3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -584,6 +584,8 @@ pub fn cton_intcast<'a, 'tcx: 'a>( pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, + // FIXME get isa from Module + pub isa: &'a isa::TargetIsa, pub module: &'a mut Module, pub instance: Instance<'tcx>, pub mir: &'tcx Mir<'tcx>, diff --git a/src/lib.rs b/src/lib.rs index fb717d4454202..38c5836848601 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,13 +178,16 @@ impl CodegenBackend for CraneliftCodegenBackend { let metadata = tcx.encode_metadata(); - let mut flags_builder = settings::builder(); - flags_builder.enable("is_pic").unwrap(); - let flags = settings::Flags::new(flags_builder); - let isa = + fn build_isa(tcx: TyCtxt) -> Box { + let mut flags_builder = settings::builder(); + flags_builder.enable("is_pic").unwrap(); + let flags = settings::Flags::new(flags_builder); cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) .unwrap() - .finish(flags); + .finish(flags) + } + + let isa = build_isa(tcx); let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0; @@ -197,7 +200,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); assert_eq!(pointer_ty(tcx), jit_module.pointer_type()); - codegen_mono_items(tcx, &mut jit_module, &mono_items); + codegen_mono_items(tcx, &*isa, &mut jit_module, &mono_items); tcx.sess.abort_if_errors(); println!("Compiled everything"); @@ -237,7 +240,7 @@ impl CodegenBackend for CraneliftCodegenBackend { ); assert_eq!(pointer_ty(tcx), faerie_module.pointer_type()); - codegen_mono_items(tcx, &mut faerie_module, &mono_items); + codegen_mono_items(tcx, &*build_isa(tcx), &mut faerie_module, &mono_items); tcx.sess.abort_if_errors(); @@ -318,6 +321,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_mono_items<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, + isa: &isa::TargetIsa, module: &mut Module, mono_items: &FxHashSet>, ) { @@ -333,7 +337,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( for mono_item in mono_items { let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { - base::trans_mono_item(tcx, module, &mut caches, &mut ccx, *mono_item); + base::trans_mono_item(tcx, isa, module, &mut caches, &mut ccx, *mono_item); })); if let Err(err) = res { From 53b53c77d9f502e8528c567a9be2338b022b2831 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 27 Sep 2018 05:59:34 +0000 Subject: [PATCH 0255/1566] Bump cranelift from `8a79275` to `0199e3d` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `8a79275` to `0199e3d`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/8a79275d8900266a42a97890ecde5264a9caa295...0199e3d82845b5a49769b326d0c520a4c7b62901) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b986be61f4c22..6d5b3afa336d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8a79275d8900266a42a97890ecde5264a9caa295" +source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From 0c42107ea6f63cc1a4d6fcf86d62579a5713aabf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 27 Sep 2018 19:19:16 +0200 Subject: [PATCH 0256/1566] EntityMap got renamed to SecondaryMap --- src/pretty_clif.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 08e685841aace..53e0d5cd1cefc 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use std::collections::HashMap; use std::fmt; -use cranelift::codegen::entity::EntityMap; +use cranelift::codegen::entity::SecondaryMap; use cranelift::codegen::write::{FuncWriter, PlainWriter}; use crate::prelude::*; @@ -14,7 +14,7 @@ impl FuncWriter for CommentWriter { &mut self, w: &mut dyn fmt::Write, func: &Function, - aliases: &EntityMap>, + aliases: &SecondaryMap>, isa: Option<&dyn isa::TargetIsa>, inst: Inst, indent: usize, From 84e8585c7db2157a941b26ce9c1612f84493dc0f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 28 Sep 2018 05:39:32 +0000 Subject: [PATCH 0257/1566] Bump cranelift from `0199e3d` to `191638e` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `0199e3d` to `191638e`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/0199e3d82845b5a49769b326d0c520a4c7b62901...191638ebe085b9b53a5616d1064e6d4e812d12dc) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d5b3afa336d2..98e0972032bfd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0199e3d82845b5a49769b326d0c520a4c7b62901" +source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From ed996759f1b3b677f4b451bb2ef2bc7b875c487b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 28 Sep 2018 18:21:11 +0200 Subject: [PATCH 0258/1566] Rustup --- src/analyze.rs | 7 ++++++- src/base.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index 2ef21dbb4592a..69d7d15aa5b82 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -26,7 +26,12 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap for bb in fx.mir.basic_blocks().iter() { for stmt in bb.statements.iter() { match &stmt.kind { - Assign(_, Rvalue::Ref(_, _, place)) => analyze_non_ssa_place(&mut flag_map, place), + Assign(_, rval) => { + match &**rval { + Rvalue::Ref(_, _, place) => analyze_non_ssa_place(&mut flag_map, place), + _ => {} + } + } _ => {} } } diff --git a/src/base.rs b/src/base.rs index 3ba4b75a071e4..b35ef24e898fa 100644 --- a/src/base.rs +++ b/src/base.rs @@ -385,7 +385,7 @@ fn trans_stmt<'a, 'tcx: 'a>( StatementKind::Assign(to_place, rval) => { let lval = trans_place(fx, to_place); let dest_layout = lval.layout(); - match rval { + match &**rval { Rvalue::Use(operand) => { let val = trans_operand(fx, operand); lval.write_cvalue(fx, val); From 3965a65a79b38797480e1a27d4286ef16f747015 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 30 Sep 2018 10:35:44 +0200 Subject: [PATCH 0259/1566] Optimize all dependencies in debug mode --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 2fc6666871d79..d46a9cfe7b815 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["profile-overrides"] + [package] name = "rustc_codegen_cranelift" version = "0.1.0" @@ -30,3 +32,6 @@ byteorder = "1.2.6" #cranelift-module = { path = "../cranelift/lib/module" } #cranelift-simplejit = { path = "../cranelift/lib/simplejit" } #cranelift-faerie = { path = "../cranelift/lib/faerie" } + +[profile.dev.overrides."*"] +opt-level = 3 From 69fe4d6f92424441115ee521bfff951eb0493af4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 30 Sep 2018 16:33:55 +0200 Subject: [PATCH 0260/1566] Workaround some missing encodings in cranelift --- example/example.rs | 4 ++++ src/base.rs | 19 +++++++++++++++++++ src/common.rs | 7 ++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/example/example.rs b/example/example.rs index 67ebf94cf916d..9e247964f32b6 100644 --- a/example/example.rs +++ b/example/example.rs @@ -192,3 +192,7 @@ pub struct StrWrapper { fn str_wrapper_get(w: &StrWrapper) -> &str { &w.s } + +fn i16_as_i8(a: i16) -> i8 { + a as i8 +} diff --git a/src/base.rs b/src/base.rs index b35ef24e898fa..c9b09be83ea4a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -158,6 +158,11 @@ fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Fu fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) { for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { + if bb_data.is_cleanup { + // Unwinding after panicking is not supported + continue; + } + let ebb = fx.get_ebb(bb); fx.bcx.switch_to_block(ebb); @@ -523,13 +528,27 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Int(_), ty::Float(_)) => { + let from_ty = fx.cton_type(from_ty).unwrap(); let from = operand.load_value(fx); + // FIXME missing encoding for fcvt_from_sint.f32.i8 + let from = if from_ty == types::I8 || from_ty == types::I16 { + fx.bcx.ins().sextend(types::I32, from) + } else { + from + }; let f_type = fx.cton_type(to_ty).unwrap(); let res = fx.bcx.ins().fcvt_from_sint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Uint(_), ty::Float(_)) => { + let from_ty = fx.cton_type(from_ty).unwrap(); let from = operand.load_value(fx); + // FIXME missing encoding for fcvt_from_uint.f32.i8 + let from = if from_ty == types::I8 || from_ty == types::I16 { + fx.bcx.ins().uextend(types::I32, from) + } else { + from + }; let f_type = fx.cton_type(to_ty).unwrap(); let res = fx.bcx.ins().fcvt_from_uint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); diff --git a/src/common.rs b/src/common.rs index 64cdd182175f3..b11ab0445d3f3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -116,10 +116,11 @@ impl<'tcx> CValue<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - fx.bcx.ins().stack_store(value, stack_slot, 0); - fx.bcx + let addr = fx.bcx .ins() - .stack_addr(fx.module.pointer_type(), stack_slot, 0) + .stack_addr(fx.module.pointer_type(), stack_slot, 0); + fx.bcx.ins().store(MemFlags::new(), value, addr, 0); + addr } CValue::ByValPair(value, extra, layout) => { let stack_slot = fx.bcx.create_stack_slot(StackSlotData { From fce5fa5231fc0c4ae7c6cb1b4831ec2b23ffe2f2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 2 Oct 2018 18:12:03 +0200 Subject: [PATCH 0261/1566] Rustup to rustc 1.31.0-nightly (de3d640f5 2018-10-01), fix a atomic bug and implement intrinsic bitreverse --- ...able-some-more-unsupported-stuff-in-libcore.patch | 12 ------------ src/abi.rs | 10 ++++++++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/0004-Disable-some-more-unsupported-stuff-in-libcore.patch b/0004-Disable-some-more-unsupported-stuff-in-libcore.patch index 25bae13ff30b3..c265db96a26f3 100644 --- a/0004-Disable-some-more-unsupported-stuff-in-libcore.patch +++ b/0004-Disable-some-more-unsupported-stuff-in-libcore.patch @@ -51,17 +51,5 @@ index 5d00949..f077f1d 100644 } } -@@ -2295,7 +2297,9 @@ assert_eq!(m, ", $reversed, "); - #[unstable(feature = "reverse_bits", issue = "48763")] - #[rustc_const_unstable(feature = "const_int_conversion")] - #[inline] - #[cfg(not(stage0))] - pub const fn reverse_bits(self) -> Self { -- unsafe { intrinsics::bitreverse(self as $ActualT) as Self } -+ // TODO support bitreverse -+ //unsafe { intrinsics::bitreverse(self as $ActualT) as Self } -+ 0 - } - } -- 2.11.0 diff --git a/src/abi.rs b/src/abi.rs index e1ac63a0c9d5e..7b9b0a1802513 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -853,6 +853,12 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); ret.write_cvalue(fx, res); } + "bitreverse" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().bitrev(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } "needs_drop" => { assert_eq!(args.len(), 0); let ty = substs.type_at(0); @@ -884,7 +890,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let amount = args[1].load_value(fx); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); let new = fx.bcx.ins().iadd(old, amount); - fx.bcx.ins().store(MemFlags::new(), ptr, new, 0); + fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); } _ if intrinsic.starts_with("atomic_xsub") => { @@ -894,7 +900,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let amount = args[1].load_value(fx); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); let new = fx.bcx.ins().isub(old, amount); - fx.bcx.ins().store(MemFlags::new(), ptr, new, 0); + fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); } _ => unimpl!("unsupported intrinsic {}", intrinsic), From 1694b07b8767311cb48870191e90734211b3e697 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 2 Oct 2018 18:40:58 +0200 Subject: [PATCH 0262/1566] Implement intrinsic init --- src/abi.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/abi.rs b/src/abi.rs index 7b9b0a1802513..ea4275e50b0ec 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -821,6 +821,24 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) } + "init" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let addr = fx.bcx.ins().stack_addr(pointer_ty(fx.tcx), stack_slot, 0); + let zero_val = fx.bcx.ins().iconst(types::I8, 0); + let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); + fx.bcx.call_memset(fx.isa, addr, zero_val, len_val); + + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_val = uninit_place.to_cvalue(fx); + ret.write_cvalue(fx, uninit_val); + } "uninit" => { assert_eq!(args.len(), 0); let ty = substs.type_at(0); From 87eab0a51e65803d2b2bd01be497050e7d8fc154 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 3 Oct 2018 05:43:03 +0000 Subject: [PATCH 0263/1566] Bump cranelift from `191638e` to `0fd3769` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `191638e` to `0fd3769`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/191638ebe085b9b53a5616d1064e6d4e812d12dc...0fd3769a49beb9531dafaf04dd376646e407212f) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 98e0972032bfd..71f8c5ecf358e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#191638ebe085b9b53a5616d1064e6d4e812d12dc" +source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From 6289d212fbf4f0b8717fe61519ce430fd1a4c36e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 3 Oct 2018 18:12:15 +0200 Subject: [PATCH 0264/1566] Implement atomic_singlethreadfence_* --- src/abi.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/abi.rs b/src/abi.rs index ea4275e50b0ec..b6fd98e0dd159 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -889,6 +889,7 @@ fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, needs_drop); } _ if intrinsic.starts_with("atomic_fence") => {} + _ if intrinsic.starts_with("atomic_singlethreadfence") => {} _ if intrinsic.starts_with("atomic_load") => { assert_eq!(args.len(), 1); let inner_layout = From a94dd977bf253898a16bf69302159c45542d675e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 3 Oct 2018 18:21:52 +0200 Subject: [PATCH 0265/1566] Move intrinsics codegen to intrinsics.rs --- src/abi.rs | 385 +++------------------------------------------- src/intrinsics.rs | 343 +++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 3 files changed, 365 insertions(+), 364 deletions(-) create mode 100644 src/intrinsics.rs diff --git a/src/abi.rs b/src/abi.rs index b6fd98e0dd159..a079979fa475a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -477,22 +477,29 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( .as_ref() .map(|&(ref place, bb)| (trans_place(fx, place), bb)); - if !codegen_intrinsic_call(fx, fn_ty, &args, destination) { - codegen_call_inner( - fx, - Some(func), - fn_ty, - args, - destination.map(|(place, _)| place), - ); - - if let Some((_, dest)) = destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); - } else { - fx.bcx.ins().trap(TrapCode::User(!0)); + if let ty::FnDef(def_id, substs) = fn_ty.sty { + let sig = ty_fn_sig(fx.tcx, fn_ty); + + if sig.abi == Abi::RustIntrinsic { + crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, &args, destination); + return; } } + + codegen_call_inner( + fx, + Some(func), + fn_ty, + args, + destination.map(|(place, _)| place), + ); + + if let Some((_, dest)) = destination { + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + } else { + fx.bcx.ins().trap(TrapCode::User(!0)); + } } pub fn codegen_call_inner<'a, 'tcx: 'a>( @@ -587,353 +594,3 @@ pub fn codegen_return(fx: &mut FunctionCx) { } } } - -fn codegen_intrinsic_call<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - fn_ty: Ty<'tcx>, - args: &[CValue<'tcx>], - destination: Option<(CPlace<'tcx>, BasicBlock)>, -) -> bool { - if let ty::FnDef(def_id, substs) = fn_ty.sty { - let sig = ty_fn_sig(fx.tcx, fn_ty); - - if sig.abi == Abi::RustIntrinsic { - let intrinsic = fx.tcx.item_name(def_id).as_str(); - let intrinsic = &intrinsic[..]; - - let ret = match destination { - Some((place, _)) => place, - None => { - // Insert non returning intrinsics here - match intrinsic { - "abort" => { - fx.bcx.ins().trap(TrapCode::User(!0 - 1)); - } - "unreachable" => { - fx.bcx.ins().trap(TrapCode::User(!0 - 1)); - } - _ => unimplemented!("unsupported instrinsic {}", intrinsic), - } - return true; - } - }; - - let nil_ty = fx.tcx.mk_unit(); - let u64_layout = fx.layout_of(fx.tcx.types.u64); - let usize_layout = fx.layout_of(fx.tcx.types.usize); - - match intrinsic { - "assume" => { - assert_eq!(args.len(), 1); - } - "arith_offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); - let res = fx.bcx.ins().iadd(base, offset); - let res = CValue::ByVal(res, ret.layout()); - ret.write_cvalue(fx, res); - } - "likely" | "unlikely" => { - assert_eq!(args.len(), 1); - ret.write_cvalue(fx, args[0]); - } - "copy" | "copy_nonoverlapping" => { - let elem_ty = substs.type_at(0); - let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); - let elem_size = fx - .bcx - .ins() - .iconst(fx.module.pointer_type(), elem_size as i64); - assert_eq!(args.len(), 3); - let src = args[0].load_value(fx); - let dst = args[1].load_value(fx); - let count = args[2].load_value(fx); - let byte_amount = fx.bcx.ins().imul(count, elem_size); - - if intrinsic.ends_with("_nonoverlapping") { - fx.bcx.call_memcpy(fx.isa, dst, src, byte_amount); - } else { - fx.bcx.call_memmove(fx.isa, dst, src, byte_amount); - } - } - "discriminant_value" => { - assert_eq!(args.len(), 1); - let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); - ret.write_cvalue(fx, discr); - } - "size_of" => { - assert_eq!(args.len(), 0); - let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); - let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); - ret.write_cvalue(fx, size_of); - } - "size_of_val" => { - assert_eq!(args.len(), 1); - let layout = fx.layout_of(substs.type_at(0)); - let size = match &layout.ty.sty { - _ if !layout.is_unsized() => fx - .bcx - .ins() - .iconst(fx.module.pointer_type(), layout.size.bytes() as i64), - ty::Slice(elem) => { - let len = args[0].load_value_pair(fx).1; - let elem_size = fx.layout_of(elem).size.bytes(); - fx.bcx.ins().imul_imm(len, elem_size as i64) - } - ty::Dynamic(..) => crate::vtable::size_of_obj(fx, args[0]), - ty => bug!("size_of_val for unknown unsized type {:?}", ty), - }; - ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); - } - "min_align_of" => { - assert_eq!(args.len(), 0); - let min_align = fx.layout_of(substs.type_at(0)).align.abi(); - let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); - ret.write_cvalue(fx, min_align); - } - "min_align_of_val" => { - assert_eq!(args.len(), 1); - let layout = fx.layout_of(substs.type_at(0)); - let align = match &layout.ty.sty { - _ if !layout.is_unsized() => fx - .bcx - .ins() - .iconst(fx.module.pointer_type(), layout.align.abi() as i64), - ty::Slice(elem) => { - let align = fx.layout_of(elem).align.abi() as i64; - fx.bcx.ins().iconst(fx.module.pointer_type(), align) - } - ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, args[0]), - ty => unimplemented!("min_align_of_val for {:?}", ty), - }; - ret.write_cvalue(fx, CValue::ByVal(align, usize_layout)); - } - "type_id" => { - assert_eq!(args.len(), 0); - let type_id = fx.tcx.type_id_hash(substs.type_at(0)); - let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); - ret.write_cvalue(fx, type_id); - } - _ if intrinsic.starts_with("unchecked_") => { - assert_eq!(args.len(), 2); - let bin_op = match intrinsic { - "unchecked_div" => BinOp::Div, - "unchecked_rem" => BinOp::Rem, - "unchecked_shl" => BinOp::Shl, - "unchecked_shr" => BinOp::Shr, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match ret.layout().ty.sty { - ty::Uint(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - ty::Int(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - _ if intrinsic.ends_with("_with_overflow") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); - let bin_op = match intrinsic { - "add_with_overflow" => BinOp::Add, - "sub_with_overflow" => BinOp::Sub, - "mul_with_overflow" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match args[0].layout().ty.sty { - ty::Uint(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - ty::Int(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - _ if intrinsic.starts_with("overflowing_") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); - let bin_op = match intrinsic { - "overflowing_add" => BinOp::Add, - "overflowing_sub" => BinOp::Sub, - "overflowing_mul" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), - }; - let res = match args[0].layout().ty.sty { - ty::Uint(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - false, - ), - ty::Int(_) => crate::base::trans_int_binop( - fx, - bin_op, - args[0], - args[1], - ret.layout().ty, - true, - ), - _ => panic!(), - }; - ret.write_cvalue(fx, res); - } - "offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); - let res = fx.bcx.ins().iadd(base, offset); - ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); - } - "transmute" => { - assert_eq!(args.len(), 1); - let src_ty = substs.type_at(0); - let dst_ty = substs.type_at(1); - assert_eq!(args[0].layout().ty, src_ty); - let addr = args[0].force_stack(fx); - let dst_layout = fx.layout_of(dst_ty); - ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) - } - "init" => { - assert_eq!(args.len(), 0); - let ty = substs.type_at(0); - let layout = fx.layout_of(ty); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let addr = fx.bcx.ins().stack_addr(pointer_ty(fx.tcx), stack_slot, 0); - let zero_val = fx.bcx.ins().iconst(types::I8, 0); - let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); - fx.bcx.call_memset(fx.isa, addr, zero_val, len_val); - - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); - let uninit_val = uninit_place.to_cvalue(fx); - ret.write_cvalue(fx, uninit_val); - } - "uninit" => { - assert_eq!(args.len(), 0); - let ty = substs.type_at(0); - let layout = fx.layout_of(ty); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); - let uninit_val = uninit_place.to_cvalue(fx); - ret.write_cvalue(fx, uninit_val); - } - "ctlz" | "ctlz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "cttz" | "cttz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "ctpop" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "bitreverse" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); - let res = CValue::ByVal(fx.bcx.ins().bitrev(arg), args[0].layout()); - ret.write_cvalue(fx, res); - } - "needs_drop" => { - assert_eq!(args.len(), 0); - let ty = substs.type_at(0); - let needs_drop = if ty.needs_drop(fx.tcx, ParamEnv::reveal_all()) { - 1 - } else { - 0 - }; - let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); - ret.write_cvalue(fx, needs_drop); - } - _ if intrinsic.starts_with("atomic_fence") => {} - _ if intrinsic.starts_with("atomic_singlethreadfence") => {} - _ if intrinsic.starts_with("atomic_load") => { - assert_eq!(args.len(), 1); - let inner_layout = - fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); - let val = CValue::ByRef(args[0].load_value(fx), inner_layout); - ret.write_cvalue(fx, val); - } - _ if intrinsic.starts_with("atomic_store") => { - assert_eq!(args.len(), 2); - let dest = CPlace::Addr(args[0].load_value(fx), None, args[1].layout()); - dest.write_cvalue(fx, args[1]); - } - _ if intrinsic.starts_with("atomic_xadd") => { - assert_eq!(args.len(), 2); - let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); - let ptr = args[0].load_value(fx); - let amount = args[1].load_value(fx); - let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); - let new = fx.bcx.ins().iadd(old, amount); - fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); - ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); - } - _ if intrinsic.starts_with("atomic_xsub") => { - assert_eq!(args.len(), 2); - let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); - let ptr = args[0].load_value(fx); - let amount = args[1].load_value(fx); - let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); - let new = fx.bcx.ins().isub(old, amount); - fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); - ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); - } - _ => unimpl!("unsupported intrinsic {}", intrinsic), - } - - if let Some((_, dest)) = destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); - } else { - fx.bcx.ins().trap(TrapCode::User(!0)); - } - return true; - } - } - - false -} diff --git a/src/intrinsics.rs b/src/intrinsics.rs new file mode 100644 index 0000000000000..3e5bfec943834 --- /dev/null +++ b/src/intrinsics.rs @@ -0,0 +1,343 @@ + +use crate::prelude::*; + +pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + def_id: DefId, + substs: &'tcx Substs, + args: &[CValue<'tcx>], + destination: Option<(CPlace<'tcx>, BasicBlock)>, +) { + let intrinsic = fx.tcx.item_name(def_id).as_str(); + let intrinsic = &intrinsic[..]; + + let ret = match destination { + Some((place, _)) => place, + None => { + // Insert non returning intrinsics here + match intrinsic { + "abort" => { + fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + } + "unreachable" => { + fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + } + _ => unimplemented!("unsupported instrinsic {}", intrinsic), + } + return; + } + }; + + let u64_layout = fx.layout_of(fx.tcx.types.u64); + let usize_layout = fx.layout_of(fx.tcx.types.usize); + + match intrinsic { + "assume" => { + assert_eq!(args.len(), 1); + } + "arith_offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + let res = CValue::ByVal(res, ret.layout()); + ret.write_cvalue(fx, res); + } + "likely" | "unlikely" => { + assert_eq!(args.len(), 1); + ret.write_cvalue(fx, args[0]); + } + "copy" | "copy_nonoverlapping" => { + let elem_ty = substs.type_at(0); + let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); + let elem_size = fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), elem_size as i64); + assert_eq!(args.len(), 3); + let src = args[0].load_value(fx); + let dst = args[1].load_value(fx); + let count = args[2].load_value(fx); + let byte_amount = fx.bcx.ins().imul(count, elem_size); + + if intrinsic.ends_with("_nonoverlapping") { + fx.bcx.call_memcpy(fx.isa, dst, src, byte_amount); + } else { + fx.bcx.call_memmove(fx.isa, dst, src, byte_amount); + } + } + "discriminant_value" => { + assert_eq!(args.len(), 1); + let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); + ret.write_cvalue(fx, discr); + } + "size_of" => { + assert_eq!(args.len(), 0); + let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); + let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); + ret.write_cvalue(fx, size_of); + } + "size_of_val" => { + assert_eq!(args.len(), 1); + let layout = fx.layout_of(substs.type_at(0)); + let size = match &layout.ty.sty { + _ if !layout.is_unsized() => fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), layout.size.bytes() as i64), + ty::Slice(elem) => { + let len = args[0].load_value_pair(fx).1; + let elem_size = fx.layout_of(elem).size.bytes(); + fx.bcx.ins().imul_imm(len, elem_size as i64) + } + ty::Dynamic(..) => crate::vtable::size_of_obj(fx, args[0]), + ty => bug!("size_of_val for unknown unsized type {:?}", ty), + }; + ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); + } + "min_align_of" => { + assert_eq!(args.len(), 0); + let min_align = fx.layout_of(substs.type_at(0)).align.abi(); + let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); + ret.write_cvalue(fx, min_align); + } + "min_align_of_val" => { + assert_eq!(args.len(), 1); + let layout = fx.layout_of(substs.type_at(0)); + let align = match &layout.ty.sty { + _ if !layout.is_unsized() => fx + .bcx + .ins() + .iconst(fx.module.pointer_type(), layout.align.abi() as i64), + ty::Slice(elem) => { + let align = fx.layout_of(elem).align.abi() as i64; + fx.bcx.ins().iconst(fx.module.pointer_type(), align) + } + ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, args[0]), + ty => unimplemented!("min_align_of_val for {:?}", ty), + }; + ret.write_cvalue(fx, CValue::ByVal(align, usize_layout)); + } + "type_id" => { + assert_eq!(args.len(), 0); + let type_id = fx.tcx.type_id_hash(substs.type_at(0)); + let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); + ret.write_cvalue(fx, type_id); + } + _ if intrinsic.starts_with("unchecked_") => { + assert_eq!(args.len(), 2); + let bin_op = match intrinsic { + "unchecked_div" => BinOp::Div, + "unchecked_rem" => BinOp::Rem, + "unchecked_shl" => BinOp::Shl, + "unchecked_shr" => BinOp::Shr, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match ret.layout().ty.sty { + ty::Uint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + ty::Int(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + _ if intrinsic.ends_with("_with_overflow") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "add_with_overflow" => BinOp::Add, + "sub_with_overflow" => BinOp::Sub, + "mul_with_overflow" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + ty::Uint(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + ty::Int(_) => crate::base::trans_checked_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + _ if intrinsic.starts_with("overflowing_") => { + assert_eq!(args.len(), 2); + assert_eq!(args[0].layout().ty, args[1].layout().ty); + let bin_op = match intrinsic { + "overflowing_add" => BinOp::Add, + "overflowing_sub" => BinOp::Sub, + "overflowing_mul" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match args[0].layout().ty.sty { + ty::Uint(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + false, + ), + ty::Int(_) => crate::base::trans_int_binop( + fx, + bin_op, + args[0], + args[1], + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + } + "offset" => { + assert_eq!(args.len(), 2); + let base = args[0].load_value(fx); + let offset = args[1].load_value(fx); + let res = fx.bcx.ins().iadd(base, offset); + ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); + } + "transmute" => { + assert_eq!(args.len(), 1); + let src_ty = substs.type_at(0); + let dst_ty = substs.type_at(1); + assert_eq!(args[0].layout().ty, src_ty); + let addr = args[0].force_stack(fx); + let dst_layout = fx.layout_of(dst_ty); + ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) + } + "init" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let addr = fx.bcx.ins().stack_addr(pointer_ty(fx.tcx), stack_slot, 0); + let zero_val = fx.bcx.ins().iconst(types::I8, 0); + let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); + fx.bcx.call_memset(fx.isa, addr, zero_val, len_val); + + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_val = uninit_place.to_cvalue(fx); + ret.write_cvalue(fx, uninit_val); + } + "uninit" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let layout = fx.layout_of(ty); + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_val = uninit_place.to_cvalue(fx); + ret.write_cvalue(fx, uninit_val); + } + "ctlz" | "ctlz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "cttz" | "cttz_nonzero" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "ctpop" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "bitreverse" => { + assert_eq!(args.len(), 1); + let arg = args[0].load_value(fx); + let res = CValue::ByVal(fx.bcx.ins().bitrev(arg), args[0].layout()); + ret.write_cvalue(fx, res); + } + "needs_drop" => { + assert_eq!(args.len(), 0); + let ty = substs.type_at(0); + let needs_drop = if ty.needs_drop(fx.tcx, ParamEnv::reveal_all()) { + 1 + } else { + 0 + }; + let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); + ret.write_cvalue(fx, needs_drop); + } + _ if intrinsic.starts_with("atomic_fence") => {} + _ if intrinsic.starts_with("atomic_singlethreadfence") => {} + _ if intrinsic.starts_with("atomic_load") => { + assert_eq!(args.len(), 1); + let inner_layout = + fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); + let val = CValue::ByRef(args[0].load_value(fx), inner_layout); + ret.write_cvalue(fx, val); + } + _ if intrinsic.starts_with("atomic_store") => { + assert_eq!(args.len(), 2); + let dest = CPlace::Addr(args[0].load_value(fx), None, args[1].layout()); + dest.write_cvalue(fx, args[1]); + } + _ if intrinsic.starts_with("atomic_xadd") => { + assert_eq!(args.len(), 2); + let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); + let ptr = args[0].load_value(fx); + let amount = args[1].load_value(fx); + let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); + let new = fx.bcx.ins().iadd(old, amount); + fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); + ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); + } + _ if intrinsic.starts_with("atomic_xsub") => { + assert_eq!(args.len(), 2); + let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); + let ptr = args[0].load_value(fx); + let amount = args[1].load_value(fx); + let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); + let new = fx.bcx.ins().isub(old, amount); + fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); + ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); + } + _ => unimpl!("unsupported intrinsic {}", intrinsic), + } + + if let Some((_, dest)) = destination { + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + } else { + fx.bcx.ins().trap(TrapCode::User(!0)); + } +} diff --git a/src/lib.rs b/src/lib.rs index 38c5836848601..82b3c3ebbdca2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -52,6 +52,7 @@ mod analyze; mod base; mod common; mod constant; +mod intrinsics; mod metadata; mod pretty_clif; mod vtable; From 62af9c9a04c6eb947c34ffa63313340f21135b86 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Oct 2018 08:34:26 +0200 Subject: [PATCH 0266/1566] Update Readme.md --- Readme.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Readme.md b/Readme.md index 3c07f08f95159..751a9ae3375d8 100644 --- a/Readme.md +++ b/Readme.md @@ -26,19 +26,12 @@ $ ./prepare_libcore.sh $ ./build.sh ``` -> This should stop with `error: aborting due to <...> previous errors` -> -> Please submit a bug if not - ## Not yet supported * Checked binops * Drop glue -* Building libraries * Other call abi's -* Unsized types -* Slice indexing * Sub slice * Inline assembly From cd4bcb7a2c90a8447a7610572bafdd8fd822acf5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Oct 2018 19:23:26 +0200 Subject: [PATCH 0267/1566] Rustup to rustc 1.31.0-nightly (8c4ad4e9e 2018-10-04) --- src/base.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/base.rs b/src/base.rs index c9b09be83ea4a..1cb5f51fcf728 100644 --- a/src/base.rs +++ b/src/base.rs @@ -227,6 +227,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) args, destination, cleanup: _, + from_hir_call: _, } => { crate::abi::codegen_terminator_call(fx, func, args, destination); } From a1bb16fdc36f528e78aeb47b5a9612cbc807c844 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Oct 2018 19:55:06 +0200 Subject: [PATCH 0268/1566] Use dsl for declaring intrinsic codegen --- src/abi.rs | 2 +- src/intrinsics.rs | 247 +++++++++++++++++++++++----------------------- 2 files changed, 126 insertions(+), 123 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index a079979fa475a..d20da83982e38 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -481,7 +481,7 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( let sig = ty_fn_sig(fx.tcx, fn_ty); if sig.abi == Abi::RustIntrinsic { - crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, &args, destination); + crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination); return; } } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 3e5bfec943834..a75ef796342d7 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1,11 +1,54 @@ use crate::prelude::*; +macro_rules! intrinsic_pat { + (_) => { + _ + }; + ($name:ident) => { + stringify!($name) + } +} + +macro_rules! intrinsic_arg { + (c $fx:expr, $arg:ident) => { + $arg + }; + (v $fx:expr, $arg:ident) => { + $arg.load_value($fx) + }; +} + +macro_rules! intrinsic_match { + ($fx:expr, $intrinsic:expr, $args:expr, $( + $($name:tt)|+ $(if $cond:expr)?, |$($a:ident $arg:ident),*| $content:block; + )*) => { + match $intrinsic { + $( + $(intrinsic_pat!($name))|* $(if $cond)? => { + if let [$($arg),*] = *$args { + #[allow(unused_parens)] + { + let ($($arg),*) = ( + $(intrinsic_arg!($a $fx, $arg)),* + ); + $content + } + } else { + bug!("wrong number of args for intrinsic {:?}", $intrinsic); + } + } + )* + _ => unimpl!("unsupported intrinsic {}", $intrinsic), + } + }; +} + pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, def_id: DefId, substs: &'tcx Substs, - args: &[CValue<'tcx>], + args: Vec>, destination: Option<(CPlace<'tcx>, BasicBlock)>, ) { let intrinsic = fx.tcx.item_name(def_id).as_str(); @@ -31,23 +74,19 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let u64_layout = fx.layout_of(fx.tcx.types.u64); let usize_layout = fx.layout_of(fx.tcx.types.usize); - match intrinsic { - "assume" => { - assert_eq!(args.len(), 1); - } - "arith_offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); + intrinsic_match! { + fx, intrinsic, args, + + assume, |c _a| {}; + arith_offset, |v base, v offset| { let res = fx.bcx.ins().iadd(base, offset); let res = CValue::ByVal(res, ret.layout()); ret.write_cvalue(fx, res); - } - "likely" | "unlikely" => { - assert_eq!(args.len(), 1); - ret.write_cvalue(fx, args[0]); - } - "copy" | "copy_nonoverlapping" => { + }; + likely | unlikely, |c a| { + ret.write_cvalue(fx, a); + }; + copy | copy_nonoverlapping, |v src, v dst, v count| { let elem_ty = substs.type_at(0); let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); let elem_size = fx @@ -55,9 +94,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( .ins() .iconst(fx.module.pointer_type(), elem_size as i64); assert_eq!(args.len(), 3); - let src = args[0].load_value(fx); - let dst = args[1].load_value(fx); - let count = args[2].load_value(fx); let byte_amount = fx.bcx.ins().imul(count, elem_size); if intrinsic.ends_with("_nonoverlapping") { @@ -65,20 +101,17 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( } else { fx.bcx.call_memmove(fx.isa, dst, src, byte_amount); } - } - "discriminant_value" => { - assert_eq!(args.len(), 1); + }; + discriminant_value, |c val| { let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); ret.write_cvalue(fx, discr); - } - "size_of" => { - assert_eq!(args.len(), 0); + }; + size_of, | | { let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); ret.write_cvalue(fx, size_of); - } - "size_of_val" => { - assert_eq!(args.len(), 1); + }; + size_of_val, |c ptr| { let layout = fx.layout_of(substs.type_at(0)); let size = match &layout.ty.sty { _ if !layout.is_unsized() => fx @@ -86,23 +119,21 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( .ins() .iconst(fx.module.pointer_type(), layout.size.bytes() as i64), ty::Slice(elem) => { - let len = args[0].load_value_pair(fx).1; + let len = ptr.load_value_pair(fx).1; let elem_size = fx.layout_of(elem).size.bytes(); fx.bcx.ins().imul_imm(len, elem_size as i64) } - ty::Dynamic(..) => crate::vtable::size_of_obj(fx, args[0]), + ty::Dynamic(..) => crate::vtable::size_of_obj(fx, ptr), ty => bug!("size_of_val for unknown unsized type {:?}", ty), }; ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); - } - "min_align_of" => { - assert_eq!(args.len(), 0); + }; + min_align_of, | | { let min_align = fx.layout_of(substs.type_at(0)).align.abi(); let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); ret.write_cvalue(fx, min_align); - } - "min_align_of_val" => { - assert_eq!(args.len(), 1); + }; + min_align_of_val, |c ptr| { let layout = fx.layout_of(substs.type_at(0)); let align = match &layout.ty.sty { _ if !layout.is_unsized() => fx @@ -113,19 +144,17 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let align = fx.layout_of(elem).align.abi() as i64; fx.bcx.ins().iconst(fx.module.pointer_type(), align) } - ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, args[0]), + ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, ptr), ty => unimplemented!("min_align_of_val for {:?}", ty), }; ret.write_cvalue(fx, CValue::ByVal(align, usize_layout)); - } - "type_id" => { - assert_eq!(args.len(), 0); + }; + type_id, | | { let type_id = fx.tcx.type_id_hash(substs.type_at(0)); let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); ret.write_cvalue(fx, type_id); - } - _ if intrinsic.starts_with("unchecked_") => { - assert_eq!(args.len(), 2); + }; + _ if intrinsic.starts_with("unchecked_"), |c x, c y| { let bin_op = match intrinsic { "unchecked_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, @@ -137,26 +166,25 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ty::Uint(_) => crate::base::trans_int_binop( fx, bin_op, - args[0], - args[1], + x, + y, ret.layout().ty, false, ), ty::Int(_) => crate::base::trans_int_binop( fx, bin_op, - args[0], - args[1], + x, + y, ret.layout().ty, true, ), _ => panic!(), }; ret.write_cvalue(fx, res); - } - _ if intrinsic.ends_with("_with_overflow") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); + }; + _ if intrinsic.ends_with("_with_overflow"), |c x, c y| { + assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { "add_with_overflow" => BinOp::Add, "sub_with_overflow" => BinOp::Sub, @@ -167,71 +195,65 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ty::Uint(_) => crate::base::trans_checked_int_binop( fx, bin_op, - args[0], - args[1], + x, + y, ret.layout().ty, false, ), ty::Int(_) => crate::base::trans_checked_int_binop( fx, bin_op, - args[0], - args[1], + x, + y, ret.layout().ty, true, ), _ => panic!(), }; ret.write_cvalue(fx, res); - } - _ if intrinsic.starts_with("overflowing_") => { - assert_eq!(args.len(), 2); - assert_eq!(args[0].layout().ty, args[1].layout().ty); + }; + _ if intrinsic.starts_with("overflowing_"), |c x, c y| { + assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { "overflowing_add" => BinOp::Add, "overflowing_sub" => BinOp::Sub, "overflowing_mul" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = match args[0].layout().ty.sty { + let res = match x.layout().ty.sty { ty::Uint(_) => crate::base::trans_int_binop( fx, bin_op, - args[0], - args[1], + x, + y, ret.layout().ty, false, ), ty::Int(_) => crate::base::trans_int_binop( fx, bin_op, - args[0], - args[1], + x, + y, ret.layout().ty, true, ), _ => panic!(), }; ret.write_cvalue(fx, res); - } - "offset" => { - assert_eq!(args.len(), 2); - let base = args[0].load_value(fx); - let offset = args[1].load_value(fx); + }; + offset, |v base, v offset| { let res = fx.bcx.ins().iadd(base, offset); ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); - } - "transmute" => { - assert_eq!(args.len(), 1); + }; + transmute, |c from| { let src_ty = substs.type_at(0); let dst_ty = substs.type_at(1); - assert_eq!(args[0].layout().ty, src_ty); - let addr = args[0].force_stack(fx); + assert_eq!(from.layout().ty, src_ty); + let addr = from.force_stack(fx); let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) - } - "init" => { - assert_eq!(args.len(), 0); + }; + init, | | { let ty = substs.type_at(0); let layout = fx.layout_of(ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { @@ -247,9 +269,8 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); - } - "uninit" => { - assert_eq!(args.len(), 0); + }; + uninit, | | { let ty = substs.type_at(0); let layout = fx.layout_of(ty); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { @@ -261,33 +282,24 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); - } - "ctlz" | "ctlz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); + }; + ctlz | ctlz_nonzero, |v arg| { let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); ret.write_cvalue(fx, res); - } - "cttz" | "cttz_nonzero" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); + }; + cttz | cttz_nonzero, |v arg| { let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); ret.write_cvalue(fx, res); - } - "ctpop" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); + }; + ctpop, |v arg| { let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); ret.write_cvalue(fx, res); - } - "bitreverse" => { - assert_eq!(args.len(), 1); - let arg = args[0].load_value(fx); + }; + bitreverse, |v arg| { let res = CValue::ByVal(fx.bcx.ins().bitrev(arg), args[0].layout()); ret.write_cvalue(fx, res); - } - "needs_drop" => { - assert_eq!(args.len(), 0); + }; + needs_drop, | | { let ty = substs.type_at(0); let needs_drop = if ty.needs_drop(fx.tcx, ParamEnv::reveal_all()) { 1 @@ -296,42 +308,33 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); ret.write_cvalue(fx, needs_drop); - } - _ if intrinsic.starts_with("atomic_fence") => {} - _ if intrinsic.starts_with("atomic_singlethreadfence") => {} - _ if intrinsic.starts_with("atomic_load") => { - assert_eq!(args.len(), 1); + }; + _ if intrinsic.starts_with("atomic_fence"), | | {}; + _ if intrinsic.starts_with("atomic_singlethreadfence"), | | {}; + _ if intrinsic.starts_with("atomic_load"), |c ptr| { let inner_layout = - fx.layout_of(args[0].layout().ty.builtin_deref(true).unwrap().ty); - let val = CValue::ByRef(args[0].load_value(fx), inner_layout); + fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); + let val = CValue::ByRef(ptr.load_value(fx), inner_layout); ret.write_cvalue(fx, val); - } - _ if intrinsic.starts_with("atomic_store") => { - assert_eq!(args.len(), 2); - let dest = CPlace::Addr(args[0].load_value(fx), None, args[1].layout()); - dest.write_cvalue(fx, args[1]); - } - _ if intrinsic.starts_with("atomic_xadd") => { - assert_eq!(args.len(), 2); + }; + _ if intrinsic.starts_with("atomic_store"), |v ptr, c val| { + let dest = CPlace::Addr(ptr, None, val.layout()); + dest.write_cvalue(fx, val); + }; + _ if intrinsic.starts_with("atomic_xadd"), |v ptr, v amount| { let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); - let ptr = args[0].load_value(fx); - let amount = args[1].load_value(fx); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); let new = fx.bcx.ins().iadd(old, amount); fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); - } - _ if intrinsic.starts_with("atomic_xsub") => { - assert_eq!(args.len(), 2); + }; + _ if intrinsic.starts_with("atomic_xsub"), |v ptr, v amount| { let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); - let ptr = args[0].load_value(fx); - let amount = args[1].load_value(fx); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); let new = fx.bcx.ins().isub(old, amount); fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); - } - _ => unimpl!("unsupported intrinsic {}", intrinsic), + }; } if let Some((_, dest)) = destination { From 42b80c21af14846ef12714448512a12bed84023b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Oct 2018 20:11:47 +0200 Subject: [PATCH 0269/1566] Improve dsl --- src/intrinsics.rs | 136 ++++++++++++++++++++++++---------------------- 1 file changed, 72 insertions(+), 64 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index a75ef796342d7..69d2b20284aea 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -19,23 +19,37 @@ macro_rules! intrinsic_arg { }; } +macro_rules! intrinsic_substs { + ($substs:expr, $index:expr,) => {}; + ($substs:expr, $index:expr, $first:ident $(,$rest:ident)*) => { + let $first = $substs.type_at($index); + intrinsic_substs!($substs, $index+1, $($rest),*); + }; +} + macro_rules! intrinsic_match { - ($fx:expr, $intrinsic:expr, $args:expr, $( - $($name:tt)|+ $(if $cond:expr)?, |$($a:ident $arg:ident),*| $content:block; + ($fx:expr, $intrinsic:expr, $substs:expr, $args:expr, $( + $($name:tt)|+ $(if $cond:expr)?, $(<$($subst:ident),*>)? ($($a:ident $arg:ident),*) $content:block; )*) => { match $intrinsic { $( $(intrinsic_pat!($name))|* $(if $cond)? => { - if let [$($arg),*] = *$args { - #[allow(unused_parens)] - { + #[allow(unused_parens, non_snake_case)] + { + $( + intrinsic_substs!($substs, 0, $($subst),*); + )? + if let [$($arg),*] = *$args { let ($($arg),*) = ( $(intrinsic_arg!($a $fx, $arg)),* ); - $content + #[warn(unused_parens, non_snake_case)] + { + $content + } + } else { + bug!("wrong number of args for intrinsic {:?}", $intrinsic); } - } else { - bug!("wrong number of args for intrinsic {:?}", $intrinsic); } } )* @@ -75,19 +89,18 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let usize_layout = fx.layout_of(fx.tcx.types.usize); intrinsic_match! { - fx, intrinsic, args, + fx, intrinsic, substs, args, - assume, |c _a| {}; - arith_offset, |v base, v offset| { + assume, (c _a) {}; + arith_offset, (v base, v offset) { let res = fx.bcx.ins().iadd(base, offset); let res = CValue::ByVal(res, ret.layout()); ret.write_cvalue(fx, res); }; - likely | unlikely, |c a| { + likely | unlikely, (c a) { ret.write_cvalue(fx, a); }; - copy | copy_nonoverlapping, |v src, v dst, v count| { - let elem_ty = substs.type_at(0); + copy | copy_nonoverlapping, (v src, v dst, v count) { let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); let elem_size = fx .bcx @@ -102,17 +115,17 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx.bcx.call_memmove(fx.isa, dst, src, byte_amount); } }; - discriminant_value, |c val| { - let discr = crate::base::trans_get_discriminant(fx, args[0], ret.layout()); + discriminant_value, (c val) { + let discr = crate::base::trans_get_discriminant(fx, val, ret.layout()); ret.write_cvalue(fx, discr); }; - size_of, | | { - let size_of = fx.layout_of(substs.type_at(0)).size.bytes(); + size_of, () { + let size_of = fx.layout_of(T).size.bytes(); let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); ret.write_cvalue(fx, size_of); }; - size_of_val, |c ptr| { - let layout = fx.layout_of(substs.type_at(0)); + size_of_val, (c ptr) { + let layout = fx.layout_of(T); let size = match &layout.ty.sty { _ if !layout.is_unsized() => fx .bcx @@ -128,13 +141,13 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); }; - min_align_of, | | { - let min_align = fx.layout_of(substs.type_at(0)).align.abi(); + min_align_of, () { + let min_align = fx.layout_of(T).align.abi(); let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); ret.write_cvalue(fx, min_align); }; - min_align_of_val, |c ptr| { - let layout = fx.layout_of(substs.type_at(0)); + min_align_of_val, (c ptr) { + let layout = fx.layout_of(T); let align = match &layout.ty.sty { _ if !layout.is_unsized() => fx .bcx @@ -149,12 +162,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, CValue::ByVal(align, usize_layout)); }; - type_id, | | { - let type_id = fx.tcx.type_id_hash(substs.type_at(0)); + type_id, () { + let type_id = fx.tcx.type_id_hash(T); let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); ret.write_cvalue(fx, type_id); }; - _ if intrinsic.starts_with("unchecked_"), |c x, c y| { + _ if intrinsic.starts_with("unchecked_"), (c x, c y) { let bin_op = match intrinsic { "unchecked_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, @@ -183,7 +196,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, res); }; - _ if intrinsic.ends_with("_with_overflow"), |c x, c y| { + _ if intrinsic.ends_with("_with_overflow"), (c x, c y) { assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { "add_with_overflow" => BinOp::Add, @@ -191,7 +204,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "mul_with_overflow" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = match args[0].layout().ty.sty { + let res = match T.sty { ty::Uint(_) => crate::base::trans_checked_int_binop( fx, bin_op, @@ -212,7 +225,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, res); }; - _ if intrinsic.starts_with("overflowing_"), |c x, c y| { + _ if intrinsic.starts_with("overflowing_"), (c x, c y) { assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { "overflowing_add" => BinOp::Add, @@ -220,7 +233,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "overflowing_mul" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = match x.layout().ty.sty { + let res = match T.sty { ty::Uint(_) => crate::base::trans_int_binop( fx, bin_op, @@ -241,21 +254,18 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, res); }; - offset, |v base, v offset| { + offset, (v base, v offset) { let res = fx.bcx.ins().iadd(base, offset); ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); }; - transmute, |c from| { - let src_ty = substs.type_at(0); - let dst_ty = substs.type_at(1); + transmute, (c from) { assert_eq!(from.layout().ty, src_ty); let addr = from.force_stack(fx); let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) }; - init, | | { - let ty = substs.type_at(0); - let layout = fx.layout_of(ty); + init, () { + let layout = fx.layout_of(T); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -266,42 +276,40 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); fx.bcx.call_memset(fx.isa, addr, zero_val, len_val); - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, T); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); }; - uninit, | | { - let ty = substs.type_at(0); - let layout = fx.layout_of(ty); + uninit, () { + let layout = fx.layout_of(T); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, offset: None, }); - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, ty); + let uninit_place = CPlace::from_stack_slot(fx, stack_slot, T); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); }; - ctlz | ctlz_nonzero, |v arg| { - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + ctlz | ctlz_nonzero, (v arg) { + let res = CValue::ByVal(fx.bcx.ins().clz(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - cttz | cttz_nonzero, |v arg| { - let res = CValue::ByVal(fx.bcx.ins().clz(arg), args[0].layout()); + cttz | cttz_nonzero, (v arg) { + let res = CValue::ByVal(fx.bcx.ins().clz(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - ctpop, |v arg| { - let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), args[0].layout()); + ctpop, (v arg) { + let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - bitreverse, |v arg| { - let res = CValue::ByVal(fx.bcx.ins().bitrev(arg), args[0].layout()); + bitreverse, (v arg) { + let res = CValue::ByVal(fx.bcx.ins().bitrev(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - needs_drop, | | { - let ty = substs.type_at(0); - let needs_drop = if ty.needs_drop(fx.tcx, ParamEnv::reveal_all()) { + needs_drop, () { + let needs_drop = if T.needs_drop(fx.tcx, ParamEnv::reveal_all()) { 1 } else { 0 @@ -309,31 +317,31 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); ret.write_cvalue(fx, needs_drop); }; - _ if intrinsic.starts_with("atomic_fence"), | | {}; - _ if intrinsic.starts_with("atomic_singlethreadfence"), | | {}; - _ if intrinsic.starts_with("atomic_load"), |c ptr| { + _ if intrinsic.starts_with("atomic_fence"), () {}; + _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; + _ if intrinsic.starts_with("atomic_load"), (c ptr) { let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); let val = CValue::ByRef(ptr.load_value(fx), inner_layout); ret.write_cvalue(fx, val); }; - _ if intrinsic.starts_with("atomic_store"), |v ptr, c val| { + _ if intrinsic.starts_with("atomic_store"), (v ptr, c val) { let dest = CPlace::Addr(ptr, None, val.layout()); dest.write_cvalue(fx, val); }; - _ if intrinsic.starts_with("atomic_xadd"), |v ptr, v amount| { - let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); + _ if intrinsic.starts_with("atomic_xadd"), (v ptr, v amount) { + let clif_ty = fx.cton_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); let new = fx.bcx.ins().iadd(old, amount); fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); - ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); + ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(T))); }; - _ if intrinsic.starts_with("atomic_xsub"), |v ptr, v amount| { - let clif_ty = fx.cton_type(substs.type_at(0)).unwrap(); + _ if intrinsic.starts_with("atomic_xsub"), (v ptr, v amount) { + let clif_ty = fx.cton_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); let new = fx.bcx.ins().isub(old, amount); fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); - ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(substs.type_at(0)))); + ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(T))); }; } From f8e2ce6b4b5c89b5906ccdf10d8f1366404c2103 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 10:24:09 +0200 Subject: [PATCH 0270/1566] Implement a lot of atomic intrinsics --- ...le-inline-assembly-in-spin_loop_hint.patch | 32 +++++++ 0003-Remove-atomics-from-libcore.patch | 23 ----- src/intrinsics.rs | 84 +++++++++++++++++-- 3 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 0003-Disable-inline-assembly-in-spin_loop_hint.patch delete mode 100644 0003-Remove-atomics-from-libcore.patch diff --git a/0003-Disable-inline-assembly-in-spin_loop_hint.patch b/0003-Disable-inline-assembly-in-spin_loop_hint.patch new file mode 100644 index 0000000000000..e2e2406697471 --- /dev/null +++ b/0003-Disable-inline-assembly-in-spin_loop_hint.patch @@ -0,0 +1,32 @@ +From 6a5c292f9f9e28de4319f52b05744ed7d8863f76 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 6 Oct 2018 10:22:16 +0200 +Subject: [PATCH] Disable inline assembly in spin_loop_hint + +--- + src/libcore/sync/atomic.rs | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs +index f130dbf..31db7a2 100644 +--- a/src/libcore/sync/atomic.rs ++++ b/src/libcore/sync/atomic.rs +@@ -106,6 +106,7 @@ use fmt; + #[inline] + #[stable(feature = "spin_loop_hint", since = "1.24.0")] + pub fn spin_loop_hint() { ++ /* + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + unsafe { + asm!("pause" ::: "memory" : "volatile"); +@@ -115,6 +116,7 @@ pub fn spin_loop_hint() { + unsafe { + asm!("yield" ::: "memory" : "volatile"); + } ++ */ + } + + /// A boolean type which can be safely shared between threads. +-- +2.17.1 (Apple Git-112) + diff --git a/0003-Remove-atomics-from-libcore.patch b/0003-Remove-atomics-from-libcore.patch deleted file mode 100644 index 5e5eaf2a4a2ac..0000000000000 --- a/0003-Remove-atomics-from-libcore.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 950bfa9eb7a0eb441601cbe0adc1aefcfab8e031 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Fri, 27 Jul 2018 19:07:01 +0200 -Subject: [PATCH] Remove atomics from libcore - ---- - src/libcore/lib.rs | 1 - - 1 files changed, 1 deletions(-) - -diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 3aa79087db..71fcff2e8b 100644 ---- a/src/libcore/lib.rs -+++ b/src/libcore/lib.rs -@@ -185,7 +185,6 @@ pub mod borrow; - pub mod any; - pub mod array; - pub mod ascii; --pub mod sync; - pub mod cell; - pub mod char; - pub mod panic; -2.11.0 - diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 69d2b20284aea..4f3e0c88195a2 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -58,6 +58,34 @@ macro_rules! intrinsic_match { }; } +macro_rules! atomic_binop_return_old { + ($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) => { + let clif_ty = $fx.cton_type($T).unwrap(); + let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); + let new = $fx.bcx.ins().band(old, $src); + $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); + $ret.write_cvalue($fx, CValue::ByVal(old, $fx.layout_of($T))); + }; +} + +macro_rules! atomic_minmax { + ($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ret:ident) => { + // Read old + let clif_ty = $fx.cton_type($T).unwrap(); + let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); + + // Compare + let is_eq = $fx.bcx.ins().icmp(IntCC::SignedGreaterThan, old, $src); + let new = $fx.bcx.ins().select(is_eq, old, $src); + + // Write new + $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); + + let ret_val = CValue::ByVal(old, $ret.layout()); + $ret.write_cvalue($fx, ret_val); + }; +} + pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, def_id: DefId, @@ -317,6 +345,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); ret.write_cvalue(fx, needs_drop); }; + _ if intrinsic.starts_with("atomic_fence"), () {}; _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; _ if intrinsic.starts_with("atomic_load"), (c ptr) { @@ -329,19 +358,62 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let dest = CPlace::Addr(ptr, None, val.layout()); dest.write_cvalue(fx, val); }; - _ if intrinsic.starts_with("atomic_xadd"), (v ptr, v amount) { + _ if intrinsic.starts_with("atomic_xchg"), (v ptr, c src) { + // Read old let clif_ty = fx.cton_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); - let new = fx.bcx.ins().iadd(old, amount); - fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(T))); + + // Write new + let dest = CPlace::Addr(ptr, None, src.layout()); + dest.write_cvalue(fx, src); }; - _ if intrinsic.starts_with("atomic_xsub"), (v ptr, v amount) { + _ if intrinsic.starts_with("atomic_cxchg"), (v ptr, v test_old, v new) { // both atomic_cxchg_* and atomic_cxchgweak_* + // Read old let clif_ty = fx.cton_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); - let new = fx.bcx.ins().isub(old, amount); + + // Compare + let is_eq = fx.bcx.ins().icmp(IntCC::Equal, old, test_old); + let new = fx.bcx.ins().select(is_eq, old, new); // Keep old if not equal to test_old + + // Write new fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); - ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(T))); + + let ret_val = CValue::ByValPair(old, fx.bcx.ins().bint(types::I8, is_eq), ret.layout()); + ret.write_cvalue(fx, ret_val); + }; + + _ if intrinsic.starts_with("atomic_xadd"), (v ptr, v amount) { + atomic_binop_return_old! (fx, iadd(ptr, amount) -> ret); + }; + _ if intrinsic.starts_with("atomic_xsub"), (v ptr, v amount) { + atomic_binop_return_old! (fx, isub(ptr, amount) -> ret); + }; + _ if intrinsic.starts_with("atomic_and"), (v ptr, v src) { + atomic_binop_return_old! (fx, band(ptr, src) -> ret); + }; + _ if intrinsic.starts_with("atomic_nand"), (v ptr, v src) { + atomic_binop_return_old! (fx, bnand(ptr, src) -> ret); + }; + _ if intrinsic.starts_with("atomic_or"), (v ptr, v src) { + atomic_binop_return_old! (fx, bor(ptr, src) -> ret); + }; + _ if intrinsic.starts_with("atomic_xor"), (v ptr, v src) { + atomic_binop_return_old! (fx, bxor(ptr, src) -> ret); + }; + + _ if intrinsic.starts_with("atomic_max"), (v ptr, v src) { + atomic_minmax!(fx, IntCC::SignedGreaterThan, (ptr, src) -> ret); + }; + _ if intrinsic.starts_with("atomic_umax"), (v ptr, v src) { + atomic_minmax!(fx, IntCC::UnsignedGreaterThan, (ptr, src) -> ret); + }; + _ if intrinsic.starts_with("atomic_min"), (v ptr, v src) { + atomic_minmax!(fx, IntCC::SignedLessThan, (ptr, src) -> ret); + }; + _ if intrinsic.starts_with("atomic_umin"), (v ptr, v src) { + atomic_minmax!(fx, IntCC::UnsignedLessThan, (ptr, src) -> ret); }; } From f16947dfb40056d5e3786923135a240280a067e1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 10:43:01 +0200 Subject: [PATCH 0271/1566] Implement intrinsic write_bytes --- src/intrinsics.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 4f3e0c88195a2..1cc16419413cc 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -308,6 +308,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); }; + write_bytes, (v dst, v val, v count) { + fx.bcx.call_memset(fx.isa, dst, val, count); + }; uninit, () { let layout = fx.layout_of(T); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { From aab736a137693945657e86bdd8a5d843ea829553 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 11:12:06 +0200 Subject: [PATCH 0272/1566] Disable stdsimd in libstd too --- 0001-Disable-stdsimd-in-libcore.patch | 29 ---------------- 0001-Disable-stdsimd.patch | 50 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 29 deletions(-) delete mode 100644 0001-Disable-stdsimd-in-libcore.patch create mode 100644 0001-Disable-stdsimd.patch diff --git a/0001-Disable-stdsimd-in-libcore.patch b/0001-Disable-stdsimd-in-libcore.patch deleted file mode 100644 index dbbaf6ca841d1..0000000000000 --- a/0001-Disable-stdsimd-in-libcore.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 09ba4e4d2574ba591524cffe18eb11e05e6726a4 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Mon, 24 Sep 2018 18:50:20 +0200 -Subject: [PATCH] Disable stdsimd in libcore - ---- - src/libcore/lib.rs | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 3b7646f..d349a49 100644 ---- a/src/libcore/lib.rs -+++ b/src/libcore/lib.rs -@@ -226,6 +226,7 @@ mod nonzero; - mod tuple; - mod unit; - -+/* - // Pull in the the `coresimd` crate directly into libcore. This is where all the - // architecture-specific (and vendor-specific) intrinsics are defined. AKA - // things like SIMD and such. Note that the actual source for all this lies in a -@@ -256,3 +257,4 @@ mod coresimd; - #[stable(feature = "simd_arch", since = "1.27.0")] - #[cfg(not(stage0))] - pub use coresimd::arch; -+*/ --- -2.11.0 - diff --git a/0001-Disable-stdsimd.patch b/0001-Disable-stdsimd.patch new file mode 100644 index 0000000000000..cd299b3f334fd --- /dev/null +++ b/0001-Disable-stdsimd.patch @@ -0,0 +1,50 @@ +From 17e82251ba8f36149c03aee327de8b4054e6c88e Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 6 Oct 2018 11:07:31 +0200 +Subject: [PATCH] Disable stdsimd + +--- + src/libcore/lib.rs | 2 ++ + src/libstd/lib.rs | 2 ++ + 2 files changed, 4 insertions(+) + +diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs +index 0211b05..cd224f1 100644 +--- a/src/libcore/lib.rs ++++ b/src/libcore/lib.rs +@@ -226,6 +226,7 @@ mod nonzero; + mod tuple; + mod unit; + ++/* + // Pull in the the `coresimd` crate directly into libcore. This is where all the + // architecture-specific (and vendor-specific) intrinsics are defined. AKA + // things like SIMD and such. Note that the actual source for all this lies in a +@@ -254,3 +255,4 @@ mod coresimd; + #[stable(feature = "simd_arch", since = "1.27.0")] + #[cfg(not(stage0))] + pub use coresimd::arch; ++*/ +diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs +index c58bd36..4768e8b 100644 +--- a/src/libstd/lib.rs ++++ b/src/libstd/lib.rs +@@ -501,6 +501,7 @@ mod memchr; + // compiler + pub mod rt; + ++/* + // Pull in the the `stdsimd` crate directly into libstd. This is the same as + // libcore's arch/simd modules where the source of truth here is in a different + // repository, but we pull things in here manually to get it into libstd. +@@ -525,6 +526,7 @@ mod coresimd { + #[stable(feature = "simd_arch", since = "1.27.0")] + #[cfg(all(not(stage0), not(test)))] + pub use stdsimd::arch; ++*/ + + // Include a number of private modules that exist solely to provide + // the rustdoc documentation for primitive types. Using `include!` +-- +2.17.1 (Apple Git-112) + From ab57af4e6ac5d307db006a1b1cbd4ab60577eeb2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 11:21:18 +0200 Subject: [PATCH 0273/1566] Fix projection of sized field in unsized type --- example/example.rs | 10 ++++++++++ src/common.rs | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/example/example.rs b/example/example.rs index 9e247964f32b6..eebc8c126e9b6 100644 --- a/example/example.rs +++ b/example/example.rs @@ -196,3 +196,13 @@ fn str_wrapper_get(w: &StrWrapper) -> &str { fn i16_as_i8(a: i16) -> i8 { a as i8 } + +struct Unsized(u8, str); + +fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 { + &u.0 +} + +fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str { + &u.1 +} diff --git a/src/common.rs b/src/common.rs index b11ab0445d3f3..fb030470936a4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -460,6 +460,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } CPlace::Addr(base, extra, layout) => { let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + let extra = if field_layout.is_unsized() { + assert!(extra.is_some()); + extra + } else { + None + }; CPlace::Addr(field_ptr, extra, field_layout) } } From 3e75d84e929fb4a9b7b0e728aca44b8c9fdc6205 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 11:30:32 +0200 Subject: [PATCH 0274/1566] Fix build --- prepare_libcore.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/prepare_libcore.sh b/prepare_libcore.sh index 75b6c8a908452..561ddf9776398 100755 --- a/prepare_libcore.sh +++ b/prepare_libcore.sh @@ -1,11 +1,20 @@ #!/bin/bash --verbose set -e -SRC_DIR="target/libcore" -rm -rf $SRC_DIR -mkdir -p $SRC_DIR/src -cp -r $(dirname $(rustup which rustc))/../lib/rustlib/src/rust/src/libcore $SRC_DIR/src/libcore || (echo "Please install rust-src component"; exit 1) -cd $SRC_DIR +SRC_DIR=$(dirname $(rustup which rustc))"/../lib/rustlib/src/rust/" +DST_DIR="target/libcore" + +if [ ! -e $SRC_DIR ]; then + echo "Please install rust-src component" + exit 1 +fi + +rm -rf $DST_DIR +mkdir -p $DST_DIR/src +for crate in libcore libstd; do + cp -r $SRC_DIR/src/$crate $DST_DIR/src/ +done +cd $DST_DIR git init git add . git commit -m "Initial commit" -q From 2cf7a64021c056f61981d1a373c9b886ce1416be Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 13:04:29 +0200 Subject: [PATCH 0275/1566] Don't disable core::time completely --- 0002-Disable-u128-and-i128-in-libcore.patch | 249 +++++++++++++++----- 1 file changed, 196 insertions(+), 53 deletions(-) diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch index cf731ad89bda7..0e192f790d6ab 100644 --- a/0002-Disable-u128-and-i128-in-libcore.patch +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,29 +1,30 @@ -From 5a91929290f0ced810185e9f81bbdb4d5cf53804 Mon Sep 17 00:00:00 2001 +From 7bc14b679a5e5a43940fd47a7f3be7f1cc27509b Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 22 Sep 2018 11:09:38 +0200 +Date: Sat, 6 Oct 2018 13:08:34 +0200 Subject: [PATCH] Disable u128 and i128 in libcore --- - src/libcore/clone.rs | 4 +- - src/libcore/cmp.rs | 6 +-- - src/libcore/default.rs | 2 - - src/libcore/fmt/num.rs | 6 +-- - src/libcore/hash/mod.rs | 20 -------- - src/libcore/iter/range.rs | 1 - - src/libcore/iter/traits.rs | 2 +- - src/libcore/lib.rs | 4 +- - src/libcore/marker.rs | 4 +- - src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 99 ++++++++++-------------------------- - src/libcore/num/wrapping.rs | 14 ++--- - src/libcore/ops/arith.rs | 22 ++++---- - src/libcore/ops/bit.rs | 30 ++++------- - src/libcore/tests/iter.rs | 15 ------ - src/libcore/tests/num/mod.rs | 18 ------- - 16 files changed, 63 insertions(+), 186 deletions(-) + src/libcore/clone.rs | 4 +- + src/libcore/cmp.rs | 6 +- + src/libcore/default.rs | 2 - + src/libcore/fmt/num.rs | 6 +- + src/libcore/hash/mod.rs | 20 ------ + src/libcore/iter/range.rs | 1 - + src/libcore/iter/traits.rs | 2 +- + src/libcore/lib.rs | 2 - + src/libcore/marker.rs | 4 +- + src/libcore/mem.rs | 2 - + src/libcore/num/mod.rs | 99 ++++++++------------------- + src/libcore/num/wrapping.rs | 14 ++-- + src/libcore/ops/arith.rs | 22 +++--- + src/libcore/ops/bit.rs | 30 +++------ + src/libcore/tests/iter.rs | 15 ----- + src/libcore/tests/num/mod.rs | 18 ----- + src/libcore/time.rs | 126 ----------------------------------- + 17 files changed, 62 insertions(+), 311 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs -index 3b15ba2..de08ce0 100644 +index 46bb580..fcf9fa8 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -172,8 +172,8 @@ mod impls { @@ -38,10 +39,10 @@ index 3b15ba2..de08ce0 100644 bool char } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index ef7d83a..e40c5c2 100644 +index edaed31..570217b 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs -@@ -883,7 +883,7 @@ mod impls { +@@ -886,7 +886,7 @@ mod impls { } partial_eq_impl! { @@ -50,7 +51,7 @@ index ef7d83a..e40c5c2 100644 } macro_rules! eq_impl { -@@ -893,7 +893,7 @@ mod impls { +@@ -896,7 +896,7 @@ mod impls { )*) } @@ -59,7 +60,7 @@ index ef7d83a..e40c5c2 100644 macro_rules! partial_ord_impl { ($($t:ty)*) => ($( -@@ -982,7 +982,7 @@ mod impls { +@@ -985,7 +985,7 @@ mod impls { } } @@ -128,7 +129,7 @@ index 51391fa..140255e 100644 impl_Display!(isize, usize: to_u16); #[cfg(target_pointer_width = "32")] diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs -index e7907e0..84b700c 100644 +index bbebadd..d6de656 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -306,12 +306,6 @@ pub trait Hasher { @@ -157,7 +158,7 @@ index e7907e0..84b700c 100644 /// Writes a single `isize` into this hasher. #[inline] #[stable(feature = "hasher_write", since = "1.3.0")] -@@ -380,9 +368,6 @@ impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { +@@ -380,9 +368,6 @@ impl Hasher for &mut H { fn write_u64(&mut self, i: u64) { (**self).write_u64(i) } @@ -167,7 +168,7 @@ index e7907e0..84b700c 100644 fn write_usize(&mut self, i: usize) { (**self).write_usize(i) } -@@ -398,9 +383,6 @@ impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { +@@ -398,9 +383,6 @@ impl Hasher for &mut H { fn write_i64(&mut self, i: i64) { (**self).write_i64(i) } @@ -199,7 +200,7 @@ index 55addd8..6695cfe 100644 macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs -index 4b2c1aa..ec3991f 100644 +index f95f8e7..549d832 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -843,7 +843,7 @@ macro_rules! float_sum_product { @@ -212,10 +213,10 @@ index 4b2c1aa..ec3991f 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 6a3f169..883ae4b 100644 +index 61181c2..5694583 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -151,14 +151,12 @@ mod uint_macros; +@@ -153,14 +153,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -230,17 +231,8 @@ index 6a3f169..883ae4b 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; -@@ -208,7 +206,7 @@ pub mod slice; - pub mod str; - pub mod hash; - pub mod fmt; --pub mod time; -+//pub mod time; - - pub mod unicode; - diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 5572fe1..c8d8144 100644 +index 266c691..39feadb 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -672,8 +672,8 @@ mod copy_impls { @@ -255,7 +247,7 @@ index 5572fe1..c8d8144 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 1803ade..f7fb0cb 100644 +index 27ee955..e45a2c9 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -162,12 +162,10 @@ pub fn forget(t: T) { @@ -272,10 +264,10 @@ index 1803ade..f7fb0cb 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 12da045..f02bf78 100644 +index c6473a2..c513f30 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs -@@ -105,7 +105,6 @@ nonzero_integers! { +@@ -112,7 +112,6 @@ nonzero_integers! { NonZeroU16(u16); NonZeroU32(u32); NonZeroU64(u64); @@ -283,7 +275,7 @@ index 12da045..f02bf78 100644 NonZeroUsize(usize); } -@@ -2285,18 +2284,6 @@ impl i64 { +@@ -2087,18 +2086,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -302,7 +294,7 @@ index 12da045..f02bf78 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4732,17 +4719,6 @@ impl u64 { +@@ -4339,17 +4326,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -320,7 +312,7 @@ index 12da045..f02bf78 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4826,7 +4802,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4433,7 +4409,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -329,7 +321,7 @@ index 12da045..f02bf78 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4942,30 +4918,25 @@ macro_rules! rev { +@@ -4549,30 +4525,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -364,7 +356,7 @@ index 12da045..f02bf78 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4977,21 +4948,21 @@ mod ptr_try_from_impls { +@@ -4584,21 +4555,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -394,7 +386,7 @@ index 12da045..f02bf78 100644 } #[cfg(target_pointer_width = "32")] -@@ -5000,24 +4971,24 @@ mod ptr_try_from_impls { +@@ -4607,24 +4578,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -427,7 +419,7 @@ index 12da045..f02bf78 100644 } #[cfg(target_pointer_width = "64")] -@@ -5026,24 +4997,20 @@ mod ptr_try_from_impls { +@@ -4633,24 +4604,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -456,7 +448,7 @@ index 12da045..f02bf78 100644 } #[doc(hidden)] -@@ -5078,7 +5045,7 @@ macro_rules! doit { +@@ -4685,7 +4652,7 @@ macro_rules! doit { } })*) } @@ -465,7 +457,7 @@ index 12da045..f02bf78 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -5246,52 +5213,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4853,52 +4820,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -842,7 +834,7 @@ index 3900f36..66b7980 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index 72b115f..d542e10 100644 +index 2476c07..2075670 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -224,8 +224,6 @@ fn test_iterator_step_by_nth_overflow() { @@ -943,6 +935,157 @@ index ab96d31..bb5c1d0 100644 test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } +diff --git a/src/libcore/time.rs b/src/libcore/time.rs +index 81ae8ad..0e3dd39 100644 +--- a/src/libcore/time.rs ++++ b/src/libcore/time.rs +@@ -30,7 +30,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; + const NANOS_PER_MICRO: u32 = 1_000; + const MILLIS_PER_SEC: u64 = 1_000; + const MICROS_PER_SEC: u64 = 1_000_000; +-const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; + + /// A `Duration` type to represent a span of time, typically used for system + /// timeouts. +@@ -273,57 +272,6 @@ impl Duration { + #[inline] + pub const fn subsec_nanos(&self) -> u32 { self.nanos } + +- /// Returns the total number of whole milliseconds contained by this `Duration`. +- /// +- /// # Examples +- /// +- /// ``` +- /// # #![feature(duration_as_u128)] +- /// use std::time::Duration; +- /// +- /// let duration = Duration::new(5, 730023852); +- /// assert_eq!(duration.as_millis(), 5730); +- /// ``` +- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[inline] +- pub fn as_millis(&self) -> u128 { +- self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 +- } +- +- /// Returns the total number of whole microseconds contained by this `Duration`. +- /// +- /// # Examples +- /// +- /// ``` +- /// # #![feature(duration_as_u128)] +- /// use std::time::Duration; +- /// +- /// let duration = Duration::new(5, 730023852); +- /// assert_eq!(duration.as_micros(), 5730023); +- /// ``` +- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[inline] +- pub fn as_micros(&self) -> u128 { +- self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128 +- } +- +- /// Returns the total number of nanoseconds contained by this `Duration`. +- /// +- /// # Examples +- /// +- /// ``` +- /// # #![feature(duration_as_u128)] +- /// use std::time::Duration; +- /// +- /// let duration = Duration::new(5, 730023852); +- /// assert_eq!(duration.as_nanos(), 5730023852); +- /// ``` +- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[inline] +- pub fn as_nanos(&self) -> u128 { +- self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128 +- } +- + /// Checked `Duration` addition. Computes `self + other`, returning [`None`] + /// if overflow occurred. + /// +@@ -482,80 +430,6 @@ impl Duration { + (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) + } + +- /// Creates a new `Duration` from the specified number of seconds. +- /// +- /// # Panics +- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur = Duration::from_float_secs(2.7); +- /// assert_eq!(dur, Duration::new(2, 700_000_000)); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn from_float_secs(secs: f64) -> Duration { +- let nanos = secs * (NANOS_PER_SEC as f64); +- if !nanos.is_finite() { +- panic!("got non-finite value when converting float to duration"); +- } +- if nanos >= MAX_NANOS_F64 { +- panic!("overflow when converting float to duration"); +- } +- if nanos < 0.0 { +- panic!("underflow when converting float to duration"); +- } +- let nanos = nanos as u128; +- Duration { +- secs: (nanos / (NANOS_PER_SEC as u128)) as u64, +- nanos: (nanos % (NANOS_PER_SEC as u128)) as u32, +- } +- } +- +- /// Multiply `Duration` by `f64`. +- /// +- /// # Panics +- /// This method will panic if result is not finite, negative or overflows `Duration`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur = Duration::new(2, 700_000_000); +- /// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000)); +- /// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0)); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn mul_f64(self, rhs: f64) -> Duration { +- Duration::from_float_secs(rhs * self.as_float_secs()) +- } +- +- /// Divide `Duration` by `f64`. +- /// +- /// # Panics +- /// This method will panic if result is not finite, negative or overflows `Duration`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur = Duration::new(2, 700_000_000); +- /// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611)); +- /// // note that truncation is used, not rounding +- /// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_598)); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn div_f64(self, rhs: f64) -> Duration { +- Duration::from_float_secs(self.as_float_secs() / rhs) +- } +- + /// Divide `Duration` by `Duration` and return `f64`. + /// + /// # Examples -- 2.17.1 (Apple Git-112) From f4e544894abc6424d70ec27c196ef4d722dd9379 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 13:50:31 +0200 Subject: [PATCH 0276/1566] Implement Rvalue::Len for arrays --- example/mini_core_hello_world.rs | 2 ++ src/base.rs | 17 ++++++++++++----- src/constant.rs | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 3e6d2aa992ad8..4d9021ce04eda 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -168,4 +168,6 @@ fn main() { Ordering::Less => {}, _ => assert!(false), } + + [NoisyDropInner, NoisyDropInner]; } diff --git a/src/base.rs b/src/base.rs index 1cb5f51fcf728..7b81481fb4660 100644 --- a/src/base.rs +++ b/src/base.rs @@ -589,12 +589,19 @@ fn trans_stmt<'a, 'tcx: 'a>( } Rvalue::Len(place) => { let place = trans_place(fx, place); - let size = match place { - CPlace::Addr(_, size, _) => size.unwrap(), - CPlace::Var(_, _) => unreachable!(), - }; let usize_layout = fx.layout_of(fx.tcx.types.usize); - lval.write_cvalue(fx, CValue::ByVal(size, usize_layout)); + let len = match place.layout().ty.sty { + ty::Array(_elem_ty, len) => { + let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx) as i64; + fx.bcx.ins().iconst(fx.module.pointer_type(), len) + }, + ty::Slice(_elem_ty) => match place { + CPlace::Addr(_, size, _) => size.unwrap(), + CPlace::Var(_, _) => unreachable!(), + } + _ => bug!("Rvalue::Len({:?})", place), + }; + lval.write_cvalue(fx, CValue::ByVal(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { use crate::rustc::middle::lang_items::ExchangeMallocFnLangItem; diff --git a/src/constant.rs b/src/constant.rs index 30dab10495f95..f962511c7000e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -67,7 +67,7 @@ pub fn trans_constant<'a, 'tcx: 'a>( trans_const_value(fx, const_) } -fn force_eval_const<'a, 'tcx: 'a>( +pub fn force_eval_const<'a, 'tcx: 'a>( fx: &FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> &'tcx Const<'tcx> { From 0fa547ac9894e31b1c8aa37461fe029fc7400c2d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 14:48:34 +0200 Subject: [PATCH 0277/1566] Use absolute compile time paths for some log files --- src/base.rs | 2 +- src/lib.rs | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/base.rs b/src/base.rs index 7b81481fb4660..22fa1593a1e5a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -120,7 +120,7 @@ fn trans_fn<'a, 'tcx: 'a>( if cfg!(debug_assertions) { ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None) .unwrap(); - let clif_file_name = "target/out/clif/".to_string() + &tcx.symbol_name(instance).as_str(); + let clif_file_name = concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif/").to_string() + &tcx.symbol_name(instance).as_str(); ::std::fs::write(clif_file_name, cton.as_bytes()).unwrap(); } diff --git a/src/lib.rs b/src/lib.rs index 82b3c3ebbdca2..017a6bfc4cb1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -331,7 +331,11 @@ fn codegen_mono_items<'a, 'tcx: 'a>( let mut caches = Caches::new(); let mut ccx = ConstantCx::default(); - let mut log = ::std::fs::File::create("target/out/log.txt").unwrap(); + let mut log = if cfg!(debug_assertions) { + Some(::std::fs::File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) + } else { + None + }; let before = ::std::time::Instant::now(); println!("[codegen mono items] start"); @@ -344,7 +348,9 @@ fn codegen_mono_items<'a, 'tcx: 'a>( if let Err(err) = res { match err.downcast::() { Ok(non_fatal) => { - writeln!(log, "{}", &non_fatal.0); + if cfg!(debug_assertions) { + writeln!(log.as_mut().unwrap(), "{}", &non_fatal.0); + } tcx.sess.err(&non_fatal.0) } Err(err) => ::std::panic::resume_unwind(err), From 3f7adf2d228f9a0043dd6408816ed65d41fbbf49 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Oct 2018 14:57:06 +0200 Subject: [PATCH 0278/1566] Add some more patches --- 0005-Disable-compiler_builtins.patch | 29 ++++ ...alloc-Disable-some-unsupported-stuff.patch | 92 ++++++++++++ 0007-Fix-libstd-building.patch | 131 ++++++++++++++++++ prepare_libcore.sh | 5 +- 4 files changed, 254 insertions(+), 3 deletions(-) create mode 100644 0005-Disable-compiler_builtins.patch create mode 100644 0006-alloc-Disable-some-unsupported-stuff.patch create mode 100644 0007-Fix-libstd-building.patch diff --git a/0005-Disable-compiler_builtins.patch b/0005-Disable-compiler_builtins.patch new file mode 100644 index 0000000000000..8ffb00cff42c2 --- /dev/null +++ b/0005-Disable-compiler_builtins.patch @@ -0,0 +1,29 @@ +From d873311b7bd16bac383d71d49f93d0448cfcb0b1 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sun, 30 Sep 2018 18:32:50 +0200 +Subject: [PATCH] Disable compiler_builtins + +--- + src/libcompiler_builtins/src/lib.rs | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/libcompiler_builtins/src/lib.rs b/src/libcompiler_builtins/src/lib.rs +index 9f1dd15..b1eed26 100644 +--- a/src/libcompiler_builtins/src/lib.rs ++++ b/src/libcompiler_builtins/src/lib.rs +@@ -34,6 +34,7 @@ + // that follow "x86 naming convention" (e.g. addsf3). Those aeabi intrinsics must adhere to the + // AAPCS calling convention (`extern "aapcs"`) because that's how LLVM will call them. + ++/* + #[cfg(test)] + extern crate core; + +@@ -68,3 +69,4 @@ pub mod x86; + pub mod x86_64; + + pub mod probestack; ++*/ +-- +2.17.1 (Apple Git-112) + diff --git a/0006-alloc-Disable-some-unsupported-stuff.patch b/0006-alloc-Disable-some-unsupported-stuff.patch new file mode 100644 index 0000000000000..ca336859109d8 --- /dev/null +++ b/0006-alloc-Disable-some-unsupported-stuff.patch @@ -0,0 +1,92 @@ +From a65665bae4e5ad6ef76a365b7cdff8bdfbd3db67 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 6 Oct 2018 11:03:00 +0200 +Subject: [PATCH] [alloc] Disable some unsupported stuff + +--- + src/liballoc/boxed.rs | 6 ------ + src/liballoc/str.rs | 4 ++++ + src/liballoc/vec.rs | 2 -- + 3 files changed, 4 insertions(+), 8 deletions(-) + +diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs +index f989e70..597dd15 100644 +--- a/src/liballoc/boxed.rs ++++ b/src/liballoc/boxed.rs +@@ -410,9 +410,6 @@ impl Hasher for Box { + fn write_u64(&mut self, i: u64) { + (**self).write_u64(i) + } +- fn write_u128(&mut self, i: u128) { +- (**self).write_u128(i) +- } + fn write_usize(&mut self, i: usize) { + (**self).write_usize(i) + } +@@ -428,9 +425,6 @@ impl Hasher for Box { + fn write_i64(&mut self, i: i64) { + (**self).write_i64(i) + } +- fn write_i128(&mut self, i: i128) { +- (**self).write_i128(i) +- } + fn write_isize(&mut self, i: isize) { + (**self).write_isize(i) + } +diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs +index 2af8956..23dbb79 100644 +--- a/src/liballoc/str.rs ++++ b/src/liballoc/str.rs +@@ -361,6 +361,7 @@ impl str { + #[stable(feature = "unicode_case_mapping", since = "1.2.0")] + pub fn to_lowercase(&self) -> String { + let mut s = String::with_capacity(self.len()); ++ /* + for (i, c) in self[..].char_indices() { + if c == 'Σ' { + // Σ maps to σ, except at the end of a word where it maps to ς. +@@ -384,6 +385,7 @@ impl str { + } + } + } ++ */ + return s; + + fn map_uppercase_sigma(from: &str, i: usize, to: &mut String) { +@@ -435,6 +437,7 @@ impl str { + #[stable(feature = "unicode_case_mapping", since = "1.2.0")] + pub fn to_uppercase(&self) -> String { + let mut s = String::with_capacity(self.len()); ++ /* + for c in self[..].chars() { + match conversions::to_upper(c) { + [a, '\0', _] => s.push(a), +@@ -449,6 +452,7 @@ impl str { + } + } + } ++ */ + return s; + } + +diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs +index 2bc037e..2fe8894 100644 +--- a/src/liballoc/vec.rs ++++ b/src/liballoc/vec.rs +@@ -1569,13 +1569,11 @@ impl_is_zero!(i8, |x| x == 0); + impl_is_zero!(i16, |x| x == 0); + impl_is_zero!(i32, |x| x == 0); + impl_is_zero!(i64, |x| x == 0); +-impl_is_zero!(i128, |x| x == 0); + impl_is_zero!(isize, |x| x == 0); + + impl_is_zero!(u16, |x| x == 0); + impl_is_zero!(u32, |x| x == 0); + impl_is_zero!(u64, |x| x == 0); +-impl_is_zero!(u128, |x| x == 0); + impl_is_zero!(usize, |x| x == 0); + + impl_is_zero!(char, |x| x == '\0'); +-- +2.17.1 (Apple Git-112) + diff --git a/0007-Fix-libstd-building.patch b/0007-Fix-libstd-building.patch new file mode 100644 index 0000000000000..be930ae302279 --- /dev/null +++ b/0007-Fix-libstd-building.patch @@ -0,0 +1,131 @@ +From 40c86527fe92b608a65cc1187901035ebc56b281 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 6 Oct 2018 13:21:15 +0200 +Subject: [PATCH] Fix libstd building + +--- + src/libstd/lib.rs | 6 ------ + src/libstd/net/ip.rs | 20 -------------------- + src/libstd/num.rs | 2 +- + src/libstd/primitive_docs.rs | 16 ---------------- + 4 files changed, 1 insertion(+), 43 deletions(-) + +diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs +index 4768e8b..c89f99a 100644 +--- a/src/libstd/lib.rs ++++ b/src/libstd/lib.rs +@@ -257,7 +257,6 @@ + #![feature(const_cstr_unchecked)] + #![feature(core_intrinsics)] + #![feature(dropck_eyepatch)] +-#![feature(duration_as_u128)] + #![feature(exact_size_is_empty)] + #![feature(external_doc)] + #![feature(fixed_size_array)] +@@ -287,7 +286,6 @@ + #![feature(rustc_attrs)] + #![feature(rustc_const_unstable)] + #![feature(std_internals)] +-#![cfg_attr(not(stage0), feature(stdsimd))] + #![feature(shrink_to)] + #![feature(slice_concat_ext)] + #![feature(slice_internals)] +@@ -410,8 +408,6 @@ pub use core::i16; + pub use core::i32; + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::i64; +-#[stable(feature = "i128", since = "1.26.0")] +-pub use core::i128; + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::usize; + #[stable(feature = "rust1", since = "1.0.0")] +@@ -444,8 +440,6 @@ pub use alloc_crate::string; + pub use alloc_crate::vec; + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::char; +-#[stable(feature = "i128", since = "1.26.0")] +-pub use core::u128; + #[stable(feature = "core_hint", since = "1.27.0")] + pub use core::hint; + +diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs +index d45a66e..b25b862 100644 +--- a/src/libstd/net/ip.rs ++++ b/src/libstd/net/ip.rs +@@ -1393,26 +1393,6 @@ impl FromInner for Ipv6Addr { + } + } + +-#[stable(feature = "i128", since = "1.26.0")] +-impl From for u128 { +- fn from(ip: Ipv6Addr) -> u128 { +- let ip = ip.segments(); +- ((ip[0] as u128) << 112) + ((ip[1] as u128) << 96) + ((ip[2] as u128) << 80) + +- ((ip[3] as u128) << 64) + ((ip[4] as u128) << 48) + ((ip[5] as u128) << 32) + +- ((ip[6] as u128) << 16) + (ip[7] as u128) +- } +-} +-#[stable(feature = "i128", since = "1.26.0")] +-impl From for Ipv6Addr { +- fn from(ip: u128) -> Ipv6Addr { +- Ipv6Addr::new( +- (ip >> 112) as u16, (ip >> 96) as u16, (ip >> 80) as u16, +- (ip >> 64) as u16, (ip >> 48) as u16, (ip >> 32) as u16, +- (ip >> 16) as u16, ip as u16, +- ) +- } +-} +- + #[stable(feature = "ipv6_from_octets", since = "1.9.0")] + impl From<[u8; 16]> for Ipv6Addr { + fn from(octets: [u8; 16]) -> Ipv6Addr { +diff --git a/src/libstd/num.rs b/src/libstd/num.rs +index 3f90c1f..85aab83 100644 +--- a/src/libstd/num.rs ++++ b/src/libstd/num.rs +@@ -22,7 +22,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} + pub use core::num::Wrapping; + + #[stable(feature = "nonzero", since = "1.28.0")] +-pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; ++pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; + + #[cfg(test)] use fmt; + #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; +diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs +index 8d54728..c36893c 100644 +--- a/src/libstd/primitive_docs.rs ++++ b/src/libstd/primitive_docs.rs +@@ -809,14 +809,6 @@ mod prim_i32 { } + #[stable(feature = "rust1", since = "1.0.0")] + mod prim_i64 { } + +-#[doc(primitive = "i128")] +-// +-/// The 128-bit signed integer type. +-/// +-/// *[See also the `std::i128` module](i128/index.html).* +-#[stable(feature = "i128", since="1.26.0")] +-mod prim_i128 { } +- + #[doc(primitive = "u8")] + // + /// The 8-bit unsigned integer type. +@@ -849,14 +841,6 @@ mod prim_u32 { } + #[stable(feature = "rust1", since = "1.0.0")] + mod prim_u64 { } + +-#[doc(primitive = "u128")] +-// +-/// The 128-bit unsigned integer type. +-/// +-/// *[See also the `std::u128` module](u128/index.html).* +-#[stable(feature = "i128", since="1.26.0")] +-mod prim_u128 { } +- + #[doc(primitive = "isize")] + // + /// The pointer-sized signed integer type. +-- +2.17.1 (Apple Git-112) + diff --git a/prepare_libcore.sh b/prepare_libcore.sh index 561ddf9776398..409b7845238a4 100755 --- a/prepare_libcore.sh +++ b/prepare_libcore.sh @@ -11,9 +11,8 @@ fi rm -rf $DST_DIR mkdir -p $DST_DIR/src -for crate in libcore libstd; do - cp -r $SRC_DIR/src/$crate $DST_DIR/src/ -done +cp -r $SRC_DIR/src $DST_DIR/ + cd $DST_DIR git init git add . From 39cfb1e51ff3caa73118591eb7336d3ae703ac49 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 7 Oct 2018 11:18:08 +0200 Subject: [PATCH 0279/1566] Workaround for missing select.i8 encoding --- src/common.rs | 15 +++++++++++++++ src/intrinsics.rs | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/common.rs b/src/common.rs index fb030470936a4..54c393e2824fe 100644 --- a/src/common.rs +++ b/src/common.rs @@ -69,6 +69,21 @@ pub fn cton_type_from_ty<'a, 'tcx: 'a>( }) } +pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: Value) -> Value { + let lhs_ty = bcx.func.dfg.value_type(lhs); + let rhs_ty = bcx.func.dfg.value_type(rhs); + assert_eq!(lhs_ty, rhs_ty); + if lhs_ty == types::I8 || lhs_ty == types::I16 { + // FIXME workaround for missing enocding for select.i8 + let lhs = bcx.ins().uextend(types::I32, lhs); + let rhs = bcx.ins().uextend(types::I32, rhs); + let res = bcx.ins().select(cond, lhs, rhs); + bcx.ins().ireduce(lhs_ty, res) + } else { + bcx.ins().select(cond, lhs, rhs) + } +} + fn codegen_field<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, base: Value, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 1cc16419413cc..79ed21ce3112e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -76,7 +76,7 @@ macro_rules! atomic_minmax { // Compare let is_eq = $fx.bcx.ins().icmp(IntCC::SignedGreaterThan, old, $src); - let new = $fx.bcx.ins().select(is_eq, old, $src); + let new = crate::common::codegen_select(&mut $fx.bcx, is_eq, old, $src); // Write new $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); @@ -378,7 +378,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // Compare let is_eq = fx.bcx.ins().icmp(IntCC::Equal, old, test_old); - let new = fx.bcx.ins().select(is_eq, old, new); // Keep old if not equal to test_old + let new = crate::common::codegen_select(&mut fx.bcx, is_eq, old, new); // Keep old if not equal to test_old // Write new fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); From 562bd8abfdc345b8694e180ea75d36df095826af Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 8 Oct 2018 19:40:06 +0200 Subject: [PATCH 0280/1566] Add xargo example --- build.sh | 11 ++++++++++- xargo/Cargo.lock | 4 ++++ xargo/Cargo.toml | 6 ++++++ xargo/Xargo.toml | 9 +++++++++ xargo/src/lib.rs | 5 +++++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 xargo/Cargo.lock create mode 100644 xargo/Cargo.toml create mode 100644 xargo/Xargo.toml create mode 100644 xargo/src/lib.rs diff --git a/build.sh b/build.sh index 245fc7cea3eca..ff3405aa8da7b 100755 --- a/build.sh +++ b/build.sh @@ -53,7 +53,8 @@ else cargo build fi -RUSTC="rustc -Zcodegen-backend=$(pwd)/target/$channel/librustc_codegen_cranelift.$dylib_ext -Cpanic=abort -L crate=target/out --out-dir target/out" +export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext +RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" rm -r target/out || true mkdir -p target/out/clif @@ -71,5 +72,13 @@ build_example_bin mini_core_hello_world example/mini_core_hello_world.rs echo "[BUILD] core" time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core -Cincremental=target/incremental_core + +pushd xargo +rm -r ~/.xargo/HOST +export XARGO_RUST_SRC=$(pwd)'/../target/libcore/src' +time xargo build --color always +rm -r target/ +popd + cat target/out/log.txt | sort | uniq -c #extract_data libcore.rlib core.o diff --git a/xargo/Cargo.lock b/xargo/Cargo.lock new file mode 100644 index 0000000000000..6bcf3b8bc5285 --- /dev/null +++ b/xargo/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "xargo" +version = "0.1.0" + diff --git a/xargo/Cargo.toml b/xargo/Cargo.toml new file mode 100644 index 0000000000000..9498cce26287f --- /dev/null +++ b/xargo/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "xargo" +version = "0.1.0" +authors = ["bjorn3 "] + +[dependencies] diff --git a/xargo/Xargo.toml b/xargo/Xargo.toml new file mode 100644 index 0000000000000..51f6c78ea2b00 --- /dev/null +++ b/xargo/Xargo.toml @@ -0,0 +1,9 @@ +[dependencies] +core = {} + +# Disabled due to bug in current cranelift version, fixed in master +#alloc = {} +#alloc_system = {} + +# Disabled due to missing support for many things (intrinsics, etc) in rustc_codegen_cranelift +#std = {features = ["force_alloc_system"]} diff --git a/xargo/src/lib.rs b/xargo/src/lib.rs new file mode 100644 index 0000000000000..1b5eb57bb460a --- /dev/null +++ b/xargo/src/lib.rs @@ -0,0 +1,5 @@ +#![feature(compiler_builtins)] + +#![no_std] +#![compiler_builtins] // Don't link to compiler builtins +// Just a dummy From 460d3f05a2508c53ffbed63aaa9583b02f9549bd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 8 Oct 2018 19:46:07 +0200 Subject: [PATCH 0281/1566] Mention xargo in Readme.md and fix travis --- .travis.yml | 1 + Readme.md | 1 + build.sh | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 78ed95bb6a5d5..db9dbdcc2592e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ rust: script: - rustup component add rust-src + - cargo install xargo || echo "Skipping xargo install" - ./prepare_libcore.sh - ./build.sh diff --git a/Readme.md b/Readme.md index 751a9ae3375d8..a305c2b5091c4 100644 --- a/Readme.md +++ b/Readme.md @@ -8,6 +8,7 @@ $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift $ rustup override set nightly +$ cargo install xargo $ git submodule update --init $ cargo build ``` diff --git a/build.sh b/build.sh index ff3405aa8da7b..3d0e081f3850e 100755 --- a/build.sh +++ b/build.sh @@ -74,7 +74,7 @@ echo "[BUILD] core" time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core -Cincremental=target/incremental_core pushd xargo -rm -r ~/.xargo/HOST +rm -r ~/.xargo/HOST || true export XARGO_RUST_SRC=$(pwd)'/../target/libcore/src' time xargo build --color always rm -r target/ From 738b320d67ac4fda1b9a6d601abe8166477a84c8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Oct 2018 16:38:47 +0200 Subject: [PATCH 0282/1566] Rustup to rustc 1.31.0-nightly (96cafc53c 2018-10-09) --- src/constant.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/constant.rs b/src/constant.rs index f962511c7000e..1bf10902752b9 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -279,6 +279,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { type MemoryData = (); type MemoryKinds = (); const MUT_STATIC_KIND: Option<()> = None; + const ENFORCE_VALIDITY: bool = true; fn before_terminator(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { panic!(); From 0078481dcc06aa69bc4c655d0c992c738d16cd47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 10 Oct 2018 14:42:15 +0000 Subject: [PATCH 0283/1566] Bump cranelift from `0fd3769` to `8fe3ae8` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `0fd3769` to `8fe3ae8`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/0fd3769a49beb9531dafaf04dd376646e407212f...8fe3ae89501591022270ce146a8d677be1a8d341) Signed-off-by: dependabot[bot] --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 71f8c5ecf358e..3dec4757ac33b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,17 +165,17 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#0fd3769a49beb9531dafaf04dd376646e407212f" +source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -355,7 +355,7 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "5.0.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -704,7 +704,7 @@ dependencies = [ "checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" -"checksum raw-cpuid 5.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3c460bd35fdb75644e94ab498372bdf29a4849367ce7ba74cf358edce590c4" +"checksum raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41219962ecab392f1e68db9e7ebd972800d4045a128cc23462b384e8c312cde1" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" From f6346e8e15c114cf28892324f7dfe78607ef7d6b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Oct 2018 18:36:47 +0200 Subject: [PATCH 0284/1566] Some changes --- build.sh | 2 +- xargo/Xargo.toml | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 3d0e081f3850e..3f65c9e97aeb9 100755 --- a/build.sh +++ b/build.sh @@ -76,7 +76,7 @@ time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core pushd xargo rm -r ~/.xargo/HOST || true export XARGO_RUST_SRC=$(pwd)'/../target/libcore/src' -time xargo build --color always +time SHOULD_CODEGEN=1 xargo build --color always rm -r target/ popd diff --git a/xargo/Xargo.toml b/xargo/Xargo.toml index 51f6c78ea2b00..57feaa9000870 100644 --- a/xargo/Xargo.toml +++ b/xargo/Xargo.toml @@ -1,9 +1,7 @@ [dependencies] core = {} - -# Disabled due to bug in current cranelift version, fixed in master -#alloc = {} -#alloc_system = {} +alloc = {} +alloc_system = {} # Disabled due to missing support for many things (intrinsics, etc) in rustc_codegen_cranelift #std = {features = ["force_alloc_system"]} From 4177e804e9d2f312152803a909b271befc5cfb28 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Oct 2018 19:04:20 +0200 Subject: [PATCH 0285/1566] Some more changes --- .gitignore | 2 +- build.sh | 1 - src/lib.rs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index e4b53d201ac08..cbb4eeafa3408 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/target +target **/*.rs.bk *.rlib *.o diff --git a/build.sh b/build.sh index 3f65c9e97aeb9..8488bf74aa35f 100755 --- a/build.sh +++ b/build.sh @@ -77,7 +77,6 @@ pushd xargo rm -r ~/.xargo/HOST || true export XARGO_RUST_SRC=$(pwd)'/../target/libcore/src' time SHOULD_CODEGEN=1 xargo build --color always -rm -r target/ popd cat target/out/log.txt | sort | uniq -c diff --git a/src/lib.rs b/src/lib.rs index 017a6bfc4cb1e..5f0fb37dfc05f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,7 +191,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let isa = build_isa(tcx); let mono_items = - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0; + collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Lazy).0; // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore save_incremental(tcx); From b5dffe97654e00aefe4feda0dd4114f0939ab8b0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Oct 2018 19:07:13 +0200 Subject: [PATCH 0286/1566] Rustfmt --- src/abi.rs | 12 ++++++--- src/analyze.rs | 10 +++----- src/base.rs | 63 +++++++++++++++++++++++++---------------------- src/common.rs | 6 +++-- src/constant.rs | 3 ++- src/intrinsics.rs | 1 - src/lib.rs | 20 ++++++++++----- src/vtable.rs | 6 +++-- 8 files changed, 70 insertions(+), 51 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index d20da83982e38..aa84ff32c3db9 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -242,7 +242,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { self.cton_type(arg.layout().ty).unwrap(), arg.load_value(self), ) - }).unzip(); + }) + .unzip(); let return_layout = self.layout_of(return_ty); let return_ty = if let ty::Tuple(tup) = return_ty.sty { if !tup.is_empty() { @@ -325,7 +326,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( arg_ty, ) } - }).collect::>(); + }) + .collect::>(); fx.bcx.switch_to_block(start_ebb); @@ -550,7 +552,8 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( }; args.get(0).map(|arg| adjust_arg_for_abi(fx, sig, *arg)) - }.into_iter() + } + .into_iter() }; let call_args: Vec = return_ptr @@ -560,7 +563,8 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( args.into_iter() .skip(1) .map(|arg| adjust_arg_for_abi(fx, sig, arg)), - ).collect::>(); + ) + .collect::>(); let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty)); let call_inst = if let Some(func_ref) = func_ref { diff --git a/src/analyze.rs b/src/analyze.rs index 69d7d15aa5b82..c8b4697bec9b1 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -26,12 +26,10 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap for bb in fx.mir.basic_blocks().iter() { for stmt in bb.statements.iter() { match &stmt.kind { - Assign(_, rval) => { - match &**rval { - Rvalue::Ref(_, _, place) => analyze_non_ssa_place(&mut flag_map, place), - _ => {} - } - } + Assign(_, rval) => match &**rval { + Rvalue::Ref(_, _, place) => analyze_non_ssa_place(&mut flag_map, place), + _ => {} + }, _ => {} } } diff --git a/src/base.rs b/src/base.rs index 22fa1593a1e5a..bbc090d503b4c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -32,7 +32,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( tcx, Some(inst.def_id()), &mut mir, - ).unwrap(); + ) + .unwrap(); String::from_utf8(mir.into_inner()).unwrap() } InstanceDef::Item(_) @@ -120,7 +121,8 @@ fn trans_fn<'a, 'tcx: 'a>( if cfg!(debug_assertions) { ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None) .unwrap(); - let clif_file_name = concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif/").to_string() + &tcx.symbol_name(instance).as_str(); + let clif_file_name = concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif/").to_string() + + &tcx.symbol_name(instance).as_str(); ::std::fs::write(clif_file_name, cton.as_bytes()).unwrap(); } @@ -290,27 +292,27 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) &args1[..] };*/ let (drop_fn, fn_ty) = match ty.sty { - ty::Dynamic(..) => { - let fn_ty = drop_fn.ty(bx.cx.tcx); - let sig = common::ty_fn_sig(bx.cx, fn_ty); - let sig = bx.tcx().normalize_erasing_late_bound_regions( - ty::ParamEnv::reveal_all(), - &sig, - ); - let fn_ty = FnType::new_vtable(bx.cx, sig, &[]); - let vtable = args[1]; - args = &args[..1]; - (meth::DESTRUCTOR.get_fn(&bx, vtable, &fn_ty), fn_ty) - } - _ => { - let value = place.to_cvalue(fx); - (callee::get_fn(bx.cx, drop_fn), - FnType::of_instance(bx.cx, &drop_fn)) - } + ty::Dynamic(..) => { + let fn_ty = drop_fn.ty(bx.cx.tcx); + let sig = common::ty_fn_sig(bx.cx, fn_ty); + let sig = bx.tcx().normalize_erasing_late_bound_regions( + ty::ParamEnv::reveal_all(), + &sig, + ); + let fn_ty = FnType::new_vtable(bx.cx, sig, &[]); + let vtable = args[1]; + args = &args[..1]; + (meth::DESTRUCTOR.get_fn(&bx, vtable, &fn_ty), fn_ty) + } + _ => { + let value = place.to_cvalue(fx); + (callee::get_fn(bx.cx, drop_fn), + FnType::of_instance(bx.cx, &drop_fn)) + } }; do_call(self, bx, fn_ty, drop_fn, args, - Some((ReturnDest::Nothing, target)), - unwind);*/ + Some((ReturnDest::Nothing, target)), + unwind);*/ } let target_ebb = fx.get_ebb(*target); @@ -592,13 +594,14 @@ fn trans_stmt<'a, 'tcx: 'a>( let usize_layout = fx.layout_of(fx.tcx.types.usize); let len = match place.layout().ty.sty { ty::Array(_elem_ty, len) => { - let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx) as i64; + let len = crate::constant::force_eval_const(fx, len) + .unwrap_usize(fx.tcx) as i64; fx.bcx.ins().iconst(fx.module.pointer_type(), len) - }, + } ty::Slice(_elem_ty) => match place { CPlace::Addr(_, size, _) => size.unwrap(), CPlace::Var(_, _) => unreachable!(), - } + }, _ => bug!("Rvalue::Len({:?})", place), }; lval.write_cvalue(fx, CValue::ByVal(len, usize_layout)); @@ -897,11 +900,13 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), BinOp::Shl => fx.bcx.ins().ishl(lhs, rhs), - BinOp::Shr => if !signed { - fx.bcx.ins().ushr(lhs, rhs) - } else { - fx.bcx.ins().sshr(lhs, rhs) - }, + BinOp::Shr => { + if !signed { + fx.bcx.ins().ushr(lhs, rhs) + } else { + fx.bcx.ins().sshr(lhs, rhs) + } + } _ => bug!( "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, diff --git a/src/common.rs b/src/common.rs index 54c393e2824fe..dbfc27d609ed8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -131,7 +131,8 @@ impl<'tcx> CValue<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - let addr = fx.bcx + let addr = fx + .bcx .ins() .stack_addr(fx.module.pointer_type(), stack_slot, 0); fx.bcx.ins().store(MemFlags::new(), value, addr, 0); @@ -635,7 +636,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { &mut clif, &self.bcx.func, None, - ).unwrap(); + ) + .unwrap(); writeln!(f, "\n{}", clif) } } diff --git a/src/constant.rs b/src/constant.rs index 1bf10902752b9..11e6d932ad02c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -52,7 +52,8 @@ pub fn trans_promoted<'a, 'tcx: 'a>( .const_eval(ParamEnv::reveal_all().and(GlobalId { instance: fx.instance, promoted: Some(promoted), - })).unwrap(); + })) + .unwrap(); let const_ = force_eval_const(fx, const_); trans_const_place(fx, const_) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 79ed21ce3112e..86f4f2e70b136 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1,4 +1,3 @@ - use crate::prelude::*; macro_rules! intrinsic_pat { diff --git a/src/lib.rs b/src/lib.rs index 5f0fb37dfc05f..e030d5371d369 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -237,7 +237,8 @@ impl CodegenBackend for CraneliftCodegenBackend { "some_file.o".to_string(), FaerieTrapCollection::Disabled, FaerieBuilder::default_libcall_names(), - ).unwrap(), + ) + .unwrap(), ); assert_eq!(pointer_ty(tcx), faerie_module.pointer_type()); @@ -282,7 +283,8 @@ impl CodegenBackend for CraneliftCodegenBackend { writable: false, }, metadata.clone(), - ).unwrap(); + ) + .unwrap(); for &crate_type in sess.opts.crate_types.iter() { match crate_type { @@ -303,14 +305,16 @@ impl CodegenBackend for CraneliftCodegenBackend { metadata.len() as u64, ), ::std::io::Cursor::new(metadata.clone()), - ).unwrap(); + ) + .unwrap(); if should_codegen(sess) { let obj = artifact.emit().unwrap(); builder .append( &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), ::std::io::Cursor::new(obj), - ).unwrap(); + ) + .unwrap(); } } _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), @@ -332,7 +336,10 @@ fn codegen_mono_items<'a, 'tcx: 'a>( let mut ccx = ConstantCx::default(); let mut log = if cfg!(debug_assertions) { - Some(::std::fs::File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) + Some( + ::std::fs::File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")) + .unwrap(), + ) } else { None }; @@ -455,7 +462,8 @@ fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( ParamEnv::reveal_all(), start_def_id, tcx.intern_substs(&[main_ret_ty.into()]), - ).unwrap(); + ) + .unwrap(); let (start_name, start_sig) = get_function_name_and_sig(tcx, start_instance); let start_func_id = m diff --git a/src/vtable.rs b/src/vtable.rs index e8e3899e38891..5fb1e8a835517 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -122,7 +122,8 @@ fn build_vtable<'a, 'tcx: 'a>( &format!("vtable.{:?}.for.{:?}", trait_ref, ty), Linkage::Local, false, - ).unwrap(); + ) + .unwrap(); fx.module.define_data(data_id, &data_ctx).unwrap(); data_id } @@ -140,5 +141,6 @@ fn write_usize(tcx: TyCtxt, buf: &mut [u8], idx: usize, num: u64) { match tcx.data_layout.endian { layout::Endian::Little => target.write_uint::(num, usize_size), layout::Endian::Big => target.write_uint::(num, usize_size), - }.unwrap() + } + .unwrap() } From 0195181363f6a2dd3d559a1b0dc324f8c9cffee9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Oct 2018 19:08:52 +0200 Subject: [PATCH 0287/1566] Fix some warnings --- src/base.rs | 9 +-------- src/intrinsics.rs | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/base.rs b/src/base.rs index bbc090d503b4c..5d6052ea99e95 100644 --- a/src/base.rs +++ b/src/base.rs @@ -572,7 +572,7 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => { unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty) } - Rvalue::Cast(CastKind::Unsize, operand, ty) => { + Rvalue::Cast(CastKind::Unsize, operand, _ty) => { let operand = trans_operand(fx, operand); operand.unsize_value(fx, lval); } @@ -885,13 +885,6 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( "checked int binop requires lhs and rhs of same type" ); } - let res_ty = match out_ty.sty { - ty::Tuple(tys) => tys[0], - _ => bug!( - "Checked int binop requires tuple as output, but got {:?}", - out_ty - ), - }; let lhs = in_lhs.load_value(fx); let rhs = in_rhs.load_value(fx); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 86f4f2e70b136..b143c5789c7a5 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -307,7 +307,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); }; - write_bytes, (v dst, v val, v count) { + write_bytes, (v dst, v val, v count) { fx.bcx.call_memset(fx.isa, dst, val, count); }; uninit, () { From 2b9c1e91492d37beda4735229de6f9571ccacec7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Oct 2018 19:12:41 +0200 Subject: [PATCH 0288/1566] Update Readme.md --- Readme.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index a305c2b5091c4..741142b869a33 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # Work in progress cranelift codegen backend for rust -> ⚠⚠⚠ This doesn't do anything useful yet ⚠⚠⚠ +> ⚠⚠⚠ This doesn't do much useful yet ⚠⚠⚠ ## Building @@ -37,8 +37,3 @@ $ ./build.sh * Inline assembly * Custom sections - -## Known errors - -* cranelift-module api seems to be used wrong, thus causing panic for some consts -* cranelift-codegen doesn't have encodings for some instructions for types smaller than I32 From 086f3567eac8848f34b33251460826c4c8eff42b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 12 Oct 2018 19:23:24 +0200 Subject: [PATCH 0289/1566] Rustup to rustc 1.31.0-nightly (77af31408 2018-10-11) --- src/constant.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 11e6d932ad02c..53ef5368b2a13 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use cranelift_module::*; use crate::prelude::*; use crate::rustc::mir::interpret::{ @@ -225,7 +226,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( data_ctx.define(alloc.bytes.to_vec().into_boxed_slice()); - for &(offset, reloc) in alloc.relocations.iter() { + for &(offset, (_tag, reloc)) in alloc.relocations.iter() { let reloc_offset = { let endianness = tcx.data_layout.endian; let offset = offset.bytes() as usize; @@ -279,7 +280,9 @@ struct TransPlaceInterpreter; impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { type MemoryData = (); type MemoryKinds = (); - const MUT_STATIC_KIND: Option<()> = None; + type MemoryMap = FxHashMap, Allocation<()>)>; + type PointerTag = (); + const STATIC_KIND: Option<()> = None; const ENFORCE_VALIDITY: bool = true; fn before_terminator(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { @@ -308,10 +311,14 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { fn find_foreign_static( _: crate::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, _: DefId, - ) -> EvalResult<'tcx, &'tcx Allocation> { + ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } + fn static_with_default_tag(alloc: &Allocation) -> Cow> { + Cow::Borrowed(alloc) + } + fn ptr_op( _: &EvalContext<'a, 'mir, 'tcx, Self>, _: mir::BinOp, From 42b6d734bf22d8b1edc7eb3ab60709d4d8335789 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Oct 2018 14:16:37 +0200 Subject: [PATCH 0290/1566] Rustup to rustc 1.31.0-nightly (46880f41b 2018-10-15) --- src/constant.rs | 7 +++++-- src/lib.rs | 2 +- src/vtable.rs | 26 ++++++++++++-------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 53ef5368b2a13..5fa18d1b6b44e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use cranelift_module::*; use crate::prelude::*; use crate::rustc::mir::interpret::{ @@ -6,6 +5,7 @@ use crate::rustc::mir::interpret::{ }; use crate::rustc::ty::Const; use crate::rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, OpTy, PlaceTy}; +use std::borrow::Cow; #[derive(Default)] pub struct ConstantCx { @@ -283,7 +283,10 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { type MemoryMap = FxHashMap, Allocation<()>)>; type PointerTag = (); const STATIC_KIND: Option<()> = None; - const ENFORCE_VALIDITY: bool = true; + + fn enforce_validity(_: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool { + false + } fn before_terminator(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { panic!(); diff --git a/src/lib.rs b/src/lib.rs index e030d5371d369..f0f2438a24182 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,7 +105,7 @@ use crate::prelude::*; pub struct Caches<'tcx> { pub context: Context, - pub vtables: HashMap<(Ty<'tcx>, Option>), DataId>, + pub vtables: HashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), DataId>, } impl<'tcx> Caches<'tcx> { diff --git a/src/vtable.rs b/src/vtable.rs index 5fb1e8a835517..5bc92049381dd 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -53,7 +53,7 @@ pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( pub fn get_vtable<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, - trait_ref: Option>, + trait_ref: ty::PolyExistentialTraitRef<'tcx>, ) -> Value { let data_id = if let Some(data_id) = fx.caches.vtables.get(&(ty, trait_ref)) { *data_id @@ -72,7 +72,7 @@ pub fn get_vtable<'a, 'tcx: 'a>( fn build_vtable<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, - trait_ref: Option>, + trait_ref: ty::PolyExistentialTraitRef<'tcx>, ) -> DataId { let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; @@ -87,18 +87,16 @@ fn build_vtable<'a, 'tcx: 'a>( let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; - if let Some(trait_ref) = trait_ref { - let trait_ref = trait_ref.with_self_ty(tcx, ty); - let methods = tcx.vtable_methods(trait_ref); - let methods = methods.iter().cloned().map(|opt_mth| { - opt_mth.map_or(None, |(def_id, substs)| { - Some(fx.get_function_id( - Instance::resolve(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), - )) - }) - }); - components.extend(methods); - } + let trait_ref = trait_ref.with_self_ty(tcx, ty); + let methods = tcx.vtable_methods(trait_ref); + let methods = methods.iter().cloned().map(|opt_mth| { + opt_mth.map_or(None, |(def_id, substs)| { + Some(fx.get_function_id( + Instance::resolve(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + )) + }) + }); + components.extend(methods); let mut data_ctx = DataContext::new(); let mut data = ::std::iter::repeat(0u8) From a8c3ae1160a0ff4d8801a91a28c81d31adbf2305 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 16 Oct 2018 12:19:28 +0000 Subject: [PATCH 0291/1566] Bump cranelift from `8fe3ae8` to `69fb510` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `8fe3ae8` to `69fb510`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/8fe3ae89501591022270ce146a8d677be1a8d341...69fb51092b022ea2ceef456a29bd79a2f97b3e86) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dec4757ac33b..4ec3459165e6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8fe3ae89501591022270ce146a8d677be1a8d341" +source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From c99e5ff9dc0047f0e61fcbf54a4569c260527581 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Oct 2018 17:24:45 +0200 Subject: [PATCH 0292/1566] Update Cargo.lock --- Cargo.lock | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ec3459165e6a..c0287b1b85b41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -214,7 +214,7 @@ name = "errno-dragonfly" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -230,8 +230,8 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -249,7 +249,7 @@ name = "failure_derive" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -257,7 +257,7 @@ dependencies = [ [[package]] name = "gcc" -version = "0.3.54" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -334,7 +334,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -350,7 +350,7 @@ name = "quote" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -456,9 +456,9 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -476,17 +476,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.79" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.30" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -494,7 +494,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -504,21 +504,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -526,17 +526,17 @@ name = "syn" version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.6" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -546,7 +546,7 @@ name = "synstructure" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -559,7 +559,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -690,7 +690,7 @@ dependencies = [ "checksum faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c878c9fe0eb38d5fe1a09c5df7348253b7e6a67868fd8540be525dc04d63cb" "checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" "checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" -"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" +"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" @@ -701,7 +701,7 @@ dependencies = [ "checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901" +"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" "checksum raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41219962ecab392f1e68db9e7ebd972800d4045a128cc23462b384e8c312cde1" @@ -717,14 +717,14 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9" -"checksum serde_json 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "7f60a296fed15c3edbbe9aa83b646531459e565c525b0ab628deb1a4b28e4180" +"checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" +"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d8e9ad6a11096cbecdcca0cc6aa403fdfdbaeda2fb3323a39c98e6a166a1e45a" -"checksum structopt-derive 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4cbce8ccdc62166bd594c14396a3242bf94c337a51dbfa9be1076dd74b3db2af" +"checksum structopt 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "d77af7242f18c40fd19cb270985930f239ee1646cfb482050bbae9da1d18743b" +"checksum structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "17ff01fe96de9d16e7372ae5f19dd7ece2c703b51043c3db9ea27f9e393ea311" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.6 (registry+https://github.com/rust-lang/crates.io-index)" = "854b08a640fc8f54728fb95321e3ec485b365a97fe47609797c671addd1dde69" +"checksum syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b036b7b35e846707c0e55c2c9441fa47867c0f87fca416921db3261b1d8c741a" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" From 4fdf9352970f6e097c82026fc8fd69557901d474 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 17 Oct 2018 05:22:44 +0000 Subject: [PATCH 0293/1566] Bump cranelift from `69fb510` to `e41e9fb` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `69fb510` to `e41e9fb`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/69fb51092b022ea2ceef456a29bd79a2f97b3e86...e41e9fb2f603d3cf981409434b159a37ca3f6e99) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0287b1b85b41..3763448a13018 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#69fb51092b022ea2ceef456a29bd79a2f97b3e86" +source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From 3f574e9f7bbf7a5745cfb5ee38d393702341e6be Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Oct 2018 15:19:07 +0200 Subject: [PATCH 0294/1566] Use `ranlib` instead of `ar x` --- build.sh | 25 ++++--------------------- src/lib.rs | 34 ++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/build.sh b/build.sh index 8488bf74aa35f..b7d791220c578 100755 --- a/build.sh +++ b/build.sh @@ -12,26 +12,8 @@ else exit 1 fi -extract_data() { - pushd target/out/ - ar x $1 data.o - chmod +rw data.o - mv data.o $2 - popd -} - -link_and_run() { - target=$1 - shift - pushd target/out - gcc $@ -o $target - sh -c ./$target || true - popd -} - build_lib() { SHOULD_CODEGEN=1 $RUSTC $2 --crate-name $1 --crate-type lib - extract_data lib$1.rlib $1.o } run_bin() { @@ -40,9 +22,11 @@ run_bin() { build_example_bin() { $RUSTC $2 --crate-name $1 --crate-type bin - extract_data $1 $1.o - link_and_run $1 mini_core.o $1.o + pushd target/out + gcc libmini_core.rlib $1 -o $1_bin + sh -c ./$1_bin || true + popd } if [[ "$1" == "--release" ]]; then @@ -80,4 +64,3 @@ time SHOULD_CODEGEN=1 xargo build --color always popd cat target/out/log.txt | sort | uniq -c -#extract_data libcore.rlib core.o diff --git a/src/lib.rs b/src/lib.rs index f0f2438a24182..f808ac459c033 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -298,6 +298,21 @@ impl CodegenBackend for CraneliftCodegenBackend { ); let file = File::create(&output_name).unwrap(); let mut builder = ar::Builder::new(file); + + if should_codegen(sess) { + // Add main object file + let obj = artifact.emit().unwrap(); + builder + .append( + &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), + ::std::io::Cursor::new(obj), + ) + .unwrap(); + } + + // Non object files need to be added after object files, because ranlib will + // try to read the native architecture from the first file, even if it isn't + // an object file builder .append( &ar::Header::new( @@ -307,14 +322,17 @@ impl CodegenBackend for CraneliftCodegenBackend { ::std::io::Cursor::new(metadata.clone()), ) .unwrap(); - if should_codegen(sess) { - let obj = artifact.emit().unwrap(); - builder - .append( - &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), - ::std::io::Cursor::new(obj), - ) - .unwrap(); + + // Finalize archive + std::mem::drop(builder); + + // Run ranlib to be able to link the archive + let status = std::process::Command::new("ranlib") + .arg(output_name) + .status() + .expect("Couldn't run ranlib"); + if !status.success() { + sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); } } _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), From a139f73f7762fea8486fb0238ac71965d41ee5e3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Oct 2018 18:41:26 +0200 Subject: [PATCH 0295/1566] Move maybe_create_entry_wrapper to main_shim.rs --- src/lib.rs | 130 ++++++----------------------------------------- src/main_shim.rs | 104 +++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 114 deletions(-) create mode 100644 src/main_shim.rs diff --git a/src/lib.rs b/src/lib.rs index f808ac459c033..32c3827eaa7a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,6 +53,7 @@ mod base; mod common; mod constant; mod intrinsics; +mod main_shim; mod metadata; mod pretty_clif; mod vtable; @@ -270,11 +271,12 @@ impl CodegenBackend for CraneliftCodegenBackend { .downcast::() .expect("Expected CraneliftCodegenBackend's OngoingCodegen, found Box"); - let mut artifact = ongoing_codegen.product.artifact; + let artifact = ongoing_codegen.product.artifact; let metadata = ongoing_codegen.metadata; let metadata_name = ".rustc.clif_metadata".to_string() + &ongoing_codegen.crate_hash.to_string(); + /* artifact .declare_with( &metadata_name, @@ -285,6 +287,7 @@ impl CodegenBackend for CraneliftCodegenBackend { metadata.clone(), ) .unwrap(); + */ for &crate_type in sess.opts.crate_types.iter() { match crate_type { @@ -313,15 +316,17 @@ impl CodegenBackend for CraneliftCodegenBackend { // Non object files need to be added after object files, because ranlib will // try to read the native architecture from the first file, even if it isn't // an object file - builder - .append( - &ar::Header::new( - metadata_name.as_bytes().to_vec(), - metadata.len() as u64, - ), - ::std::io::Cursor::new(metadata.clone()), - ) - .unwrap(); + if crate_type != CrateType::Executable { + builder + .append( + &ar::Header::new( + metadata_name.as_bytes().to_vec(), + metadata.len() as u64, + ), + ::std::io::Cursor::new(metadata.clone()), + ) + .unwrap(); + } // Finalize archive std::mem::drop(builder); @@ -383,7 +388,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( } } - maybe_create_entry_wrapper(tcx, module); + crate::main_shim::maybe_create_entry_wrapper(tcx, module); ccx.finalize(tcx, module); @@ -402,106 +407,3 @@ fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { pub fn __rustc_codegen_backend() -> Box { Box::new(CraneliftCodegenBackend) } - -/// Create the `main` function which will initialize the rust runtime and call -/// users main function. -fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &mut Module, -) { - use crate::rustc::middle::lang_items::StartFnLangItem; - use crate::rustc::session::config::EntryFnType; - - let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { - Some((id, _, entry_ty)) => ( - tcx.hir.local_def_id(id), - match entry_ty { - EntryFnType::Main => true, - EntryFnType::Start => false, - }, - ), - None => return, - }; - - create_entry_fn(tcx, module, main_def_id, use_start_lang_item);; - - fn create_entry_fn<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - m: &mut Module, - rust_main_def_id: DefId, - use_start_lang_item: bool, - ) { - let main_ret_ty = tcx.fn_sig(rust_main_def_id).output(); - // Given that `main()` has no arguments, - // then its return type cannot have - // late-bound regions, since late-bound - // regions must appear in the argument - // listing. - let main_ret_ty = tcx.erase_regions(&main_ret_ty.no_late_bound_regions().unwrap()); - - let cmain_sig = Signature { - params: vec![ - AbiParam::new(m.pointer_type()), - AbiParam::new(m.pointer_type()), - ], - returns: vec![AbiParam::new(m.pointer_type() /*isize*/)], - call_conv: CallConv::SystemV, - }; - - let cmain_func_id = m - .declare_function("main", Linkage::Export, &cmain_sig) - .unwrap(); - - let instance = Instance::mono(tcx, rust_main_def_id); - - let (main_name, main_sig) = get_function_name_and_sig(tcx, instance); - - let main_func_id = m - .declare_function(&main_name, Linkage::Import, &main_sig) - .unwrap(); - - let mut ctx = Context::new(); - ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone()); - { - let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); - - let ebb = bcx.create_ebb(); - bcx.switch_to_block(ebb); - let arg_argc = bcx.append_ebb_param(ebb, m.pointer_type()); - let arg_argv = bcx.append_ebb_param(ebb, m.pointer_type()); - - let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); - - let call_inst = if use_start_lang_item { - let start_def_id = tcx.require_lang_item(StartFnLangItem); - let start_instance = Instance::resolve( - tcx, - ParamEnv::reveal_all(), - start_def_id, - tcx.intern_substs(&[main_ret_ty.into()]), - ) - .unwrap(); - - let (start_name, start_sig) = get_function_name_and_sig(tcx, start_instance); - let start_func_id = m - .declare_function(&start_name, Linkage::Import, &start_sig) - .unwrap(); - - let main_val = bcx.ins().func_addr(m.pointer_type(), main_func_ref); - - let func_ref = m.declare_func_in_func(start_func_id, &mut bcx.func); - bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]) - } else { - // using user-defined start fn - bcx.ins().call(main_func_ref, &[arg_argc, arg_argv]) - }; - - let result = bcx.inst_results(call_inst)[0]; - bcx.ins().return_(&[result]); - bcx.seal_all_blocks(); - bcx.finalize(); - } - m.define_function(cmain_func_id, &mut ctx).unwrap(); - } -} diff --git a/src/main_shim.rs b/src/main_shim.rs new file mode 100644 index 0000000000000..204a933fb8d6b --- /dev/null +++ b/src/main_shim.rs @@ -0,0 +1,104 @@ +use crate::prelude::*; + +/// Create the `main` function which will initialize the rust runtime and call +/// users main function. +pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, +) { + use crate::rustc::middle::lang_items::StartFnLangItem; + use crate::rustc::session::config::EntryFnType; + + let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { + Some((id, _, entry_ty)) => ( + tcx.hir.local_def_id(id), + match entry_ty { + EntryFnType::Main => true, + EntryFnType::Start => false, + }, + ), + None => return, + }; + + create_entry_fn(tcx, module, main_def_id, use_start_lang_item);; + + fn create_entry_fn<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + m: &mut Module, + rust_main_def_id: DefId, + use_start_lang_item: bool, + ) { + let main_ret_ty = tcx.fn_sig(rust_main_def_id).output(); + // Given that `main()` has no arguments, + // then its return type cannot have + // late-bound regions, since late-bound + // regions must appear in the argument + // listing. + let main_ret_ty = tcx.erase_regions(&main_ret_ty.no_late_bound_regions().unwrap()); + + let cmain_sig = Signature { + params: vec![ + AbiParam::new(m.pointer_type()), + AbiParam::new(m.pointer_type()), + ], + returns: vec![AbiParam::new(m.pointer_type() /*isize*/)], + call_conv: CallConv::SystemV, + }; + + let cmain_func_id = m + .declare_function("main", Linkage::Export, &cmain_sig) + .unwrap(); + + let instance = Instance::mono(tcx, rust_main_def_id); + + let (main_name, main_sig) = get_function_name_and_sig(tcx, instance); + + let main_func_id = m + .declare_function(&main_name, Linkage::Import, &main_sig) + .unwrap(); + + let mut ctx = Context::new(); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone()); + { + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); + + let ebb = bcx.create_ebb(); + bcx.switch_to_block(ebb); + let arg_argc = bcx.append_ebb_param(ebb, m.pointer_type()); + let arg_argv = bcx.append_ebb_param(ebb, m.pointer_type()); + + let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); + + let call_inst = if use_start_lang_item { + let start_def_id = tcx.require_lang_item(StartFnLangItem); + let start_instance = Instance::resolve( + tcx, + ParamEnv::reveal_all(), + start_def_id, + tcx.intern_substs(&[main_ret_ty.into()]), + ) + .unwrap(); + + let (start_name, start_sig) = get_function_name_and_sig(tcx, start_instance); + let start_func_id = m + .declare_function(&start_name, Linkage::Import, &start_sig) + .unwrap(); + + let main_val = bcx.ins().func_addr(m.pointer_type(), main_func_ref); + + let func_ref = m.declare_func_in_func(start_func_id, &mut bcx.func); + bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]) + } else { + // using user-defined start fn + bcx.ins().call(main_func_ref, &[arg_argc, arg_argv]) + }; + + let result = bcx.inst_results(call_inst)[0]; + bcx.ins().return_(&[result]); + bcx.seal_all_blocks(); + bcx.finalize(); + } + m.define_function(cmain_func_id, &mut ctx).unwrap(); + } +} From 397c6843d06ad440b1c4e19101e0e4c4e201a1f0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 21 Oct 2018 16:32:19 +0200 Subject: [PATCH 0296/1566] Rustup to rustc 1.31.0-nightly (155510e37 2018-10-20) and fix test --- build.sh | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index b7d791220c578..264fdf2e455e3 100755 --- a/build.sh +++ b/build.sh @@ -24,7 +24,7 @@ build_example_bin() { $RUSTC $2 --crate-name $1 --crate-type bin pushd target/out - gcc libmini_core.rlib $1 -o $1_bin + gcc $1 libmini_core.rlib -o $1_bin sh -c ./$1_bin || true popd } diff --git a/src/lib.rs b/src/lib.rs index 32c3827eaa7a6..6ac0a0530e485 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -152,7 +152,7 @@ impl CodegenBackend for CraneliftCodegenBackend { providers.target_features_whitelist = |_tcx, _cnum| Lrc::new(Default::default()); providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); - providers.upstream_monomorphizations = |_tcx, _cnum| Lrc::new(FxHashMap()); + providers.upstream_monomorphizations = |_tcx, _cnum| Lrc::new(FxHashMap::default()); providers.upstream_monomorphizations_for = |tcx, def_id| { debug_assert!(!def_id.is_local()); tcx.upstream_monomorphizations(LOCAL_CRATE) From 35d4d22e5cb1e3ef7fdd7245950f2bb53d62223f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 22 Oct 2018 11:06:09 +0200 Subject: [PATCH 0297/1566] Rustup to rustc 1.31.0-nightly (424a749a0 2018-10-21) --- src/constant.rs | 22 +++++++++++++++------- src/lib.rs | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 5fa18d1b6b44e..fb823f1e81c5a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -4,7 +4,7 @@ use crate::rustc::mir::interpret::{ read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; use crate::rustc::ty::Const; -use crate::rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, OpTy, PlaceTy}; +use crate::rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer}; use std::borrow::Cow; #[derive(Default)] @@ -127,7 +127,6 @@ fn trans_const_place<'a, 'tcx: 'a>( fx.tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all(), TransPlaceInterpreter, - (), ); let op = ecx.const_to_op(const_)?; let ptr = ecx.allocate(op.layout, MemoryKind::Stack)?; @@ -188,7 +187,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( module: &mut Module, cx: &mut ConstantCx, ) { - let memory = Memory::::new(tcx.at(DUMMY_SP), ()); + let memory = Memory::::new(tcx.at(DUMMY_SP)); while let Some(todo_item) = pop_set(&mut cx.todo) { let (data_id, alloc) = match todo_item { @@ -278,11 +277,12 @@ fn pop_set(set: &mut HashSet) -> Option struct TransPlaceInterpreter; impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { - type MemoryData = (); - type MemoryKinds = (); - type MemoryMap = FxHashMap, Allocation<()>)>; + type MemoryKinds = !; type PointerTag = (); - const STATIC_KIND: Option<()> = None; + type AllocExtra = (); + type MemoryMap = FxHashMap, Allocation<()>)>; + const STATIC_KIND: Option = None; + const ENABLE_PTR_TRACKING_HOOKS: bool = false; fn enforce_validity(_: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool { false @@ -336,4 +336,12 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { fn box_alloc(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> EvalResult<'tcx> { panic!(); } + + fn tag_reference(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: Pointer<()>, _: Ty<'tcx>, _: Size, _: Option) -> EvalResult<'tcx> { + panic!(); + } + + fn tag_dereference(_: &EvalContext<'a, 'mir, 'tcx, Self>, _: Pointer<()>, _: Ty<'tcx>) -> EvalResult<'tcx> { + panic!(); + } } diff --git a/src/lib.rs b/src/lib.rs index 6ac0a0530e485..c95aa0a0cbad2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, macro_at_most_once_rep)] +#![feature(rustc_private, macro_at_most_once_rep, never_type)] #![allow(intra_doc_link_resolution_failure)] extern crate byteorder; From e5b0c40fe234cdea3996bbec7dea2bb147167330 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 23 Oct 2018 05:34:46 +0000 Subject: [PATCH 0298/1566] Bump cranelift from `e41e9fb` to `b3bda48` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `e41e9fb` to `b3bda48`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/e41e9fb2f603d3cf981409434b159a37ca3f6e99...b3bda48431ec4978e40d57174614bdf5b4bdf863) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3763448a13018..149df9e6fa85f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#e41e9fb2f603d3cf981409434b159a37ca3f6e99" +source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From 75baefebbbad16b844496cbaab3d995fc9d9e445 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 23 Oct 2018 10:57:09 +0200 Subject: [PATCH 0299/1566] Enable codegen by default --- build.sh | 4 ++-- src/lib.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 264fdf2e455e3..daf1c325dfa59 100755 --- a/build.sh +++ b/build.sh @@ -13,7 +13,7 @@ else fi build_lib() { - SHOULD_CODEGEN=1 $RUSTC $2 --crate-name $1 --crate-type lib + $RUSTC $2 --crate-name $1 --crate-type lib } run_bin() { @@ -60,7 +60,7 @@ time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core pushd xargo rm -r ~/.xargo/HOST || true export XARGO_RUST_SRC=$(pwd)'/../target/libcore/src' -time SHOULD_CODEGEN=1 xargo build --color always +time xargo build --color always popd cat target/out/log.txt | sort | uniq -c diff --git a/src/lib.rs b/src/lib.rs index c95aa0a0cbad2..7d316be513ff3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,9 +95,9 @@ mod prelude { pub use crate::Caches; pub fn should_codegen(sess: &Session) -> bool { - //return true; - ::std::env::var("SHOULD_CODEGEN").is_ok() - || sess.crate_types.get().contains(&CrateType::Executable) + true + //::std::env::var("SHOULD_CODEGEN").is_ok() + // || sess.crate_types.get().contains(&CrateType::Executable) } } From a13562cf832b353972473429d039b0cb24cb407a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 24 Oct 2018 05:51:38 +0000 Subject: [PATCH 0300/1566] Bump cranelift from `b3bda48` to `177e727` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `b3bda48` to `177e727`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/b3bda48431ec4978e40d57174614bdf5b4bdf863...177e727c1b676643878a1680f4ec259676250d90) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 149df9e6fa85f..68bbbd8f13f6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b3bda48431ec4978e40d57174614bdf5b4bdf863" +source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From b2866d67af38cc7a1c6875628194755f80ceb1e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 25 Oct 2018 05:33:18 +0000 Subject: [PATCH 0301/1566] Bump cranelift from `177e727` to `138b2ce` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `177e727` to `138b2ce`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/177e727c1b676643878a1680f4ec259676250d90...138b2ce94143bc32d16397fe7758a2da4bb5647e) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68bbbd8f13f6e..841467c11e073 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#177e727c1b676643878a1680f4ec259676250d90" +source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From ab9a0b77248c81a32a8153d52c7eade0f2b37e7f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 25 Oct 2018 14:59:02 +0200 Subject: [PATCH 0302/1566] Change name of metadata file to rust.metadata.bin to match cg_llvm --- src/lib.rs | 9 ++------- src/metadata.rs | 5 +++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7d316be513ff3..b14ed0e67863d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,6 @@ use crate::rustc::session::{config::OutputFilenames, CompileIncomplete}; use crate::rustc::ty::query::Providers; use crate::rustc_codegen_utils::codegen_backend::CodegenBackend; use crate::rustc_codegen_utils::link::out_filename; -use crate::rustc_data_structures::svh::Svh; use crate::syntax::symbol::Symbol; use cranelift::codegen::settings; @@ -94,7 +93,7 @@ mod prelude { pub use crate::common::*; pub use crate::Caches; - pub fn should_codegen(sess: &Session) -> bool { + pub fn should_codegen(_sess: &Session) -> bool { true //::std::env::var("SHOULD_CODEGEN").is_ok() // || sess.crate_types.get().contains(&CrateType::Executable) @@ -124,7 +123,6 @@ struct OngoingCodegen { product: cranelift_faerie::FaerieProduct, metadata: Vec, crate_name: Symbol, - crate_hash: Svh, } impl CodegenBackend for CraneliftCodegenBackend { @@ -255,7 +253,6 @@ impl CodegenBackend for CraneliftCodegenBackend { product: faerie_module.finish(), metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), - crate_hash: tcx.crate_hash(LOCAL_CRATE), }); } } @@ -274,8 +271,6 @@ impl CodegenBackend for CraneliftCodegenBackend { let artifact = ongoing_codegen.product.artifact; let metadata = ongoing_codegen.metadata; - let metadata_name = - ".rustc.clif_metadata".to_string() + &ongoing_codegen.crate_hash.to_string(); /* artifact .declare_with( @@ -320,7 +315,7 @@ impl CodegenBackend for CraneliftCodegenBackend { builder .append( &ar::Header::new( - metadata_name.as_bytes().to_vec(), + metadata::METADATA_FILE.to_vec(), metadata.len() as u64, ), ::std::io::Cursor::new(metadata.clone()), diff --git a/src/metadata.rs b/src/metadata.rs index e4db778396360..1e68e9f1363a9 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -3,6 +3,8 @@ use crate::rustc_data_structures::owning_ref::{self, OwningRef}; use std::fs::File; use std::path::Path; +pub const METADATA_FILE: &'static [u8] = b"rust.metadata.bin" as &[u8]; + pub struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { @@ -17,8 +19,7 @@ impl MetadataLoader for CraneliftMetadataLoader { let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; if entry .header() - .identifier() - .starts_with(b".rustc.clif_metadata") + .identifier() == METADATA_FILE { let mut buf = Vec::new(); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; From fe3a9660eabf68ef9f7b8d827bfbdb4d6a5835b2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 25 Oct 2018 17:36:29 +0200 Subject: [PATCH 0303/1566] Bump cranelift --- Cargo.lock | 91 ++++++++++++++++++++++----------------------------- src/common.rs | 18 +++++----- 2 files changed, 50 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 841467c11e073..2748628cfcf81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,7 +38,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,13 +107,13 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -121,22 +121,22 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,18 +154,18 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#138b2ce94143bc32d16397fe7758a2da4bb5647e" +source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -224,9 +224,9 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -237,22 +237,22 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -306,7 +306,7 @@ name = "log" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -322,7 +322,7 @@ name = "memchr" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -403,7 +403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -458,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -518,22 +518,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.14.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "0.15.11" +version = "0.15.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -543,12 +533,12 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -557,8 +547,8 @@ name = "target-lexicon" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -672,7 +662,7 @@ dependencies = [ "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" -"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" +"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cranelift 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -688,12 +678,12 @@ dependencies = [ "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c878c9fe0eb38d5fe1a09c5df7348253b7e6a67868fd8540be525dc04d63cb" -"checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9" -"checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" +"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" +"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" -"checksum indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08173ba1e906efb6538785a8844dd496f5d34f0a2d88038e95195172fc667220" +"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" @@ -723,9 +713,8 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "d77af7242f18c40fd19cb270985930f239ee1646cfb482050bbae9da1d18743b" "checksum structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "17ff01fe96de9d16e7372ae5f19dd7ece2c703b51043c3db9ea27f9e393ea311" -"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b036b7b35e846707c0e55c2c9441fa47867c0f87fca416921db3261b1d8c741a" -"checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" +"checksum syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4439ee8325b4e4b57e59309c3724c9a4478eaeb4eb094b6f3fac180a3b2876" +"checksum synstructure 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec37f4fab4bafaf6b5621c1d54e6aa5d4d059a8f84929e87abfdd7f9f04c6db2" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" diff --git a/src/common.rs b/src/common.rs index dbfc27d609ed8..c4658f2b51f6c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -419,20 +419,22 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let data = from.load_value(fx); fx.bcx.def_var(mir_var(var), data) } - CPlace::Addr(addr, None, layout) => { - let size = layout.size.bytes() as i32; - + CPlace::Addr(addr, None, dst_layout) => { match from { - CValue::ByVal(val, _layout) => { + CValue::ByVal(val, _src_layout) => { fx.bcx.ins().store(MemFlags::new(), val, addr, 0); } - CValue::ByValPair(val1, val2, _layout) => { - let val1_offset = layout.fields.offset(0).bytes() as i32; - let val2_offset = layout.fields.offset(1).bytes() as i32; + CValue::ByValPair(val1, val2, _src_layout) => { + let val1_offset = dst_layout.fields.offset(0).bytes() as i32; + let val2_offset = dst_layout.fields.offset(1).bytes() as i32; fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); } - CValue::ByRef(from, _layout) => { + CValue::ByRef(from, _src_layout) => { + let size = dst_layout.size.bytes() as i32; + // FIXME emit_small_memcpy has a bug as of commit CraneStation/cranelift@b2281ed + // fx.bcx.emit_small_memcpy(fx.isa, addr, from, size, layout.align.abi() as u8, src_layout.align.abi() as u8); + let mut offset = 0; while size - offset >= 8 { let byte = fx.bcx.ins().load( From 42c735dd78418fa86681e8a36a797daf491b6cdb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Oct 2018 18:16:18 +0200 Subject: [PATCH 0304/1566] Update Cargo.lock --- Cargo.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2748628cfcf81..c28f6a617e397 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ name = "ar" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -60,7 +60,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.6" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b2281ed5bc640fa04a4ec88f24ceb2cf9c4242e6" +source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -251,7 +251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -420,7 +420,7 @@ version = "0.1.0" dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -458,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -518,12 +518,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.13" +version = "0.15.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -538,7 +538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -660,7 +660,7 @@ dependencies = [ "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781" +"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -713,7 +713,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "d77af7242f18c40fd19cb270985930f239ee1646cfb482050bbae9da1d18743b" "checksum structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "17ff01fe96de9d16e7372ae5f19dd7ece2c703b51043c3db9ea27f9e393ea311" -"checksum syn 0.15.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4439ee8325b4e4b57e59309c3724c9a4478eaeb4eb094b6f3fac180a3b2876" +"checksum syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)" = "baaba45c6bf60fe29aaf241fa33306c0b75c801edea8378263a8f043b09a5634" "checksum synstructure 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec37f4fab4bafaf6b5621c1d54e6aa5d4d059a8f84929e87abfdd7f9f04c6db2" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" From 52ab6583dcf42e65f5a21dd25d842dc48c81a811 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Oct 2018 18:23:37 +0200 Subject: [PATCH 0305/1566] Better clif file writing --- src/base.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/base.rs b/src/base.rs index 5d6052ea99e95..3ae1acbee3036 100644 --- a/src/base.rs +++ b/src/base.rs @@ -121,9 +121,15 @@ fn trans_fn<'a, 'tcx: 'a>( if cfg!(debug_assertions) { ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None) .unwrap(); - let clif_file_name = concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif/").to_string() - + &tcx.symbol_name(instance).as_str(); - ::std::fs::write(clif_file_name, cton.as_bytes()).unwrap(); + let clif_file_name = format!( + "{}/{}__{}.clif", + concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), + tcx.crate_name(LOCAL_CRATE), + tcx.symbol_name(instance).as_str(), + ); + if let Err(e) = ::std::fs::write(clif_file_name, cton.as_bytes()) { + tcx.sess.warn(&format!("err writing clif file: {:?}", e)); + } } // Step 8. Verify function From 172e705b275d44f250d733a87973e2137b39c8bc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Oct 2018 18:23:03 +0100 Subject: [PATCH 0306/1566] Rustup to rustc 1.31.0-nightly (cae6efc37 2018-10-27) --- src/base.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/base.rs b/src/base.rs index 3ae1acbee3036..a056b8e3d54bb 100644 --- a/src/base.rs +++ b/src/base.rs @@ -36,16 +36,10 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( .unwrap(); String::from_utf8(mir.into_inner()).unwrap() } - InstanceDef::Item(_) - | InstanceDef::DropGlue(_, _) - | InstanceDef::Virtual(_, _) - | InstanceDef::FnPtrShim(_, _) - | InstanceDef::ClosureOnceShim { .. } - | InstanceDef::CloneShim(_, _) => { + _ => { // FIXME fix write_mir_pretty for these instances format!("{:#?}", tcx.instance_mir(inst.def)) } - InstanceDef::Intrinsic(_) => bug!("tried to codegen intrinsic"), } }); From a658322df1152a893ffc7c6c7374fc70f7bcd89d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 29 Oct 2018 05:25:12 +0000 Subject: [PATCH 0307/1566] Bump cranelift from `b874861` to `1f43e47` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `b874861` to `1f43e47`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/b874861920314dee35bab8b87ffa1894fa2c242a...1f43e474586776d27d5db3b230240402ec01d1ee) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c28f6a617e397..c71eff79e453d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#b874861920314dee35bab8b87ffa1894fa2c242a" +source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From cf71df0da451f7a198b42c1c21b29090a9e486eb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Oct 2018 17:58:42 +0100 Subject: [PATCH 0308/1566] Rustup to rustc 1.31.0-nightly (d586d5d2f 2018-10-29) --- src/constant.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index fb823f1e81c5a..0097386591235 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -4,7 +4,7 @@ use crate::rustc::mir::interpret::{ read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; use crate::rustc::ty::Const; -use crate::rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer}; +use crate::rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, MemPlace, OpTy, PlaceTy, Pointer}; use std::borrow::Cow; #[derive(Default)] @@ -131,7 +131,7 @@ fn trans_const_place<'a, 'tcx: 'a>( let op = ecx.const_to_op(const_)?; let ptr = ecx.allocate(op.layout, MemoryKind::Stack)?; ecx.copy_op(op, ptr.into())?; - let alloc = ecx.memory.get(ptr.to_ptr()?.alloc_id)?; + let alloc = ecx.memory().get(ptr.to_ptr()?.alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) }; let alloc = result().expect("unable to convert ConstValue to Allocation"); @@ -318,10 +318,6 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn static_with_default_tag(alloc: &Allocation) -> Cow> { - Cow::Borrowed(alloc) - } - fn ptr_op( _: &EvalContext<'a, 'mir, 'tcx, Self>, _: mir::BinOp, @@ -337,11 +333,19 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn tag_reference(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: Pointer<()>, _: Ty<'tcx>, _: Size, _: Option) -> EvalResult<'tcx> { - panic!(); + fn tag_reference(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: MemPlace, _: Ty<'tcx>, _: Size, _: Option) -> EvalResult<'tcx, MemPlace> { + panic!() } - fn tag_dereference(_: &EvalContext<'a, 'mir, 'tcx, Self>, _: Pointer<()>, _: Ty<'tcx>) -> EvalResult<'tcx> { + fn tag_dereference(_: &EvalContext<'a, 'mir, 'tcx, Self>, _: MemPlace, _: Ty<'tcx>, _: Size, _: Option) -> EvalResult<'tcx, MemPlace> { panic!(); } + + fn adjust_static_allocation(alloc: &Allocation) -> Cow<'_, Allocation> { + Cow::Borrowed(alloc) + } + + fn tag_new_allocation(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, ptr: Pointer, _: MemoryKind) -> EvalResult<'tcx, Pointer> { + Ok(ptr) + } } From d7cf54dcac6570409d9f6929860232293e69438e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 31 Oct 2018 05:51:48 +0000 Subject: [PATCH 0309/1566] Bump cranelift from `1f43e47` to `48fe38d` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `1f43e47` to `48fe38d`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/1f43e474586776d27d5db3b230240402ec01d1ee...48fe38d756c005f56363e761f722d6790316a685) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c71eff79e453d..0cc3a33136aae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,17 +121,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f43e474586776d27d5db3b230240402ec01d1ee" +source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", From 7fe1745d6be43d76367f2f692c1424450ad1bf40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 1 Nov 2018 06:22:47 +0000 Subject: [PATCH 0310/1566] Bump cranelift from `48fe38d` to `8382f9e` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `48fe38d` to `8382f9e`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/48fe38d756c005f56363e761f722d6790316a685...8382f9e9886818b3cb9ed3e49fdceb8f4ec19456) Signed-off-by: dependabot[bot] --- Cargo.lock | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0cc3a33136aae..e52b883b441e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,30 +121,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,14 +175,14 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#48fe38d756c005f56363e761f722d6790316a685" +source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -270,6 +270,16 @@ dependencies = [ "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "goblin" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "humantime" version = "1.1.1" @@ -311,7 +321,7 @@ dependencies = [ [[package]] name = "mach" -version = "0.1.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", @@ -398,14 +408,12 @@ dependencies = [ [[package]] name = "region" -version = "0.3.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -682,13 +690,14 @@ dependencies = [ "checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" +"checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" -"checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9" +"checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" @@ -699,7 +708,7 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" -"checksum region 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9d3f2bb4b7085e6996e2765b56b783bd8f3a8a4ea5b95683063ca13cded993" +"checksum region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cff177f64744f6f2a2054d231279383e59b0857b4d58dc2e8881e60b58aec8e5" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" From 58f076cf3824e9ad6cb79cd2f0a46ded8cfb8e6d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 2 Nov 2018 19:50:14 +0100 Subject: [PATCH 0311/1566] Print pass mode for locals in clif --- src/abi.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/abi.rs b/src/abi.rs index aa84ff32c3db9..13dddebd02e45 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -334,6 +334,12 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.top_nop = Some(fx.bcx.ins().nop()); fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); + for local in fx.mir.args_iter() { + let arg_ty = fx.monomorphize(&fx.mir.local_decls[local].ty); + let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false); + fx.add_global_comment(format!("pass {:?}: {:?} {:?}", local, arg_ty, pass_mode)); + } + match output_pass_mode { PassMode::NoPass => { let null = fx.bcx.ins().iconst(fx.module.pointer_type(), 0); From 12a5d777d3871785f4be82cde1f12e4e830acb70 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 2 Nov 2018 20:09:52 +0100 Subject: [PATCH 0312/1566] Misc build.sh changes --- build.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index daf1c325dfa59..b77536bf329a2 100755 --- a/build.sh +++ b/build.sh @@ -12,14 +12,6 @@ else exit 1 fi -build_lib() { - $RUSTC $2 --crate-name $1 --crate-type lib -} - -run_bin() { - SHOULD_RUN=1 $RUSTC $@ --crate-type bin -} - build_example_bin() { $RUSTC $2 --crate-name $1 --crate-type bin @@ -44,12 +36,13 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -build_lib mini_core example/mini_core.rs +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib +echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib echo "[JIT] mini_core_hello_world" -run_bin example/mini_core_hello_world.rs --cfg jit +SHOULD_RUN=1 $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" build_example_bin mini_core_hello_world example/mini_core_hello_world.rs From 23e0b0bd9caac40500a51b6cf86d6dd8ea04a5fd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 3 Nov 2018 12:49:55 +0100 Subject: [PATCH 0313/1566] Rustup to rustc 1.32.0-nightly (8b096314a 2018-11-02) --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index a056b8e3d54bb..1a15079a7a67f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -657,8 +657,8 @@ fn trans_stmt<'a, 'tcx: 'a>( | StatementKind::StorageDead(_) | StatementKind::Nop | StatementKind::FakeRead(..) - | StatementKind::Validate(_, _) | StatementKind::EndRegion(_) + | StatementKind::Retag { .. } | StatementKind::AscribeUserType(..) => {} StatementKind::InlineAsm { .. } => unimpl!("Inline assembly is not supported"), From fc8a6c343a3982534ccb64cd93fb0bc4e1273bab Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 3 Nov 2018 13:14:28 +0100 Subject: [PATCH 0314/1566] Update Cargo.lock Also update for cranelift changes. --- Cargo.lock | 126 ++++++++++++++++++++++++++-------------------- src/abi.rs | 10 ++-- src/base.rs | 13 +++-- src/common.rs | 19 ++++--- src/constant.rs | 4 +- src/intrinsics.rs | 16 +++--- src/lib.rs | 34 ++++++------- src/main_shim.rs | 12 ++--- src/vtable.rs | 2 +- 9 files changed, 123 insertions(+), 113 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e52b883b441e0..4f967960e3503 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,9 +1,9 @@ [[package]] name = "aho-corasick" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,31 +107,31 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" [[package]] name = "cranelift-entity" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" [[package]] name = "cranelift-faerie" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,28 +144,28 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8382f9e9886818b3cb9ed3e49fdceb8f4ec19456" +source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" dependencies = [ "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -194,7 +194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -227,11 +227,11 @@ dependencies = [ "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -250,9 +250,9 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -265,7 +265,7 @@ name = "goblin" version = "0.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -275,11 +275,19 @@ name = "goblin" version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "heck" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "humantime" version = "1.1.1" @@ -313,7 +321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -329,7 +337,7 @@ dependencies = [ [[package]] name = "memchr" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -357,7 +365,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.8" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", @@ -391,11 +399,11 @@ name = "regex" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -403,7 +411,7 @@ name = "regex-syntax" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -465,8 +473,8 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -512,41 +520,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.14" +version = "0.15.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "synstructure" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -596,7 +605,12 @@ dependencies = [ [[package]] name = "ucd-util" -version = "0.1.1" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-segmentation" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -611,7 +625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "utf8-ranges" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -661,7 +675,7 @@ dependencies = [ ] [metadata] -"checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a" +"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "095515608290b62ac2427084f9ac3cfeb5dc76067f7d94564db9db1c46cc0a85" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" @@ -691,18 +705,19 @@ dependencies = [ "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" +"checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" -"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" +"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" +"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" +"checksum quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "63b5829244f52738cfee93b3a165c1911388675be000c888d2fae620dee8fa5b" "checksum raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41219962ecab392f1e68db9e7ebd972800d4045a128cc23462b384e8c312cde1" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" @@ -720,19 +735,20 @@ dependencies = [ "checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "d77af7242f18c40fd19cb270985930f239ee1646cfb482050bbae9da1d18743b" -"checksum structopt-derive 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "17ff01fe96de9d16e7372ae5f19dd7ece2c703b51043c3db9ea27f9e393ea311" -"checksum syn 0.15.14 (registry+https://github.com/rust-lang/crates.io-index)" = "baaba45c6bf60fe29aaf241fa33306c0b75c801edea8378263a8f043b09a5634" -"checksum synstructure 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec37f4fab4bafaf6b5621c1d54e6aa5d4d059a8f84929e87abfdd7f9f04c6db2" +"checksum structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "41c4a2479a078509940d82773d90ff824a8c89533ab3b59cd3ce8b0c0e369c02" +"checksum structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5352090cfae7a2c85e1a31146268b53396106c88ca5d6ccee2e3fae83b6e35c2" +"checksum syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)" = "90c39a061e2f412a9f869540471ab679e85e50c6b05604daf28bc3060f75c430" +"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" +"checksum ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0f8bfa9ff0cadcd210129ad9d2c5f145c13e9ced3d3e5d948a6213487d52444" +"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" +"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" diff --git a/src/abi.rs b/src/abi.rs index 13dddebd02e45..42119a9bfad84 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -17,7 +17,7 @@ impl PassMode { match self { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(cton_type) => cton_type, - PassMode::ByRef => fx.module.pointer_type(), + PassMode::ByRef => fx.pointer_type, } } } @@ -257,7 +257,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { CValue::ByVal(val, return_layout) } else { CValue::ByRef( - self.bcx.ins().iconst(self.module.pointer_type(), 0), + self.bcx.ins().iconst(self.pointer_type, 0), return_layout, ) } @@ -283,7 +283,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let ret_param = match output_pass_mode { PassMode::NoPass => None, PassMode::ByVal(_) => None, - PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, fx.module.pointer_type())), + PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, fx.pointer_type)), }; enum ArgKind { @@ -342,7 +342,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( match output_pass_mode { PassMode::NoPass => { - let null = fx.bcx.ins().iconst(fx.module.pointer_type(), 0); + let null = fx.bcx.ins().iconst(fx.pointer_type, 0); //unimplemented!("pass mode nopass"); fx.local_map.insert( RETURN_PLACE, @@ -526,7 +526,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( PassMode::NoPass => None, PassMode::ByRef => match ret_place { Some(ret_place) => Some(ret_place.expect_addr()), - None => Some(fx.bcx.ins().iconst(fx.module.pointer_type(), 0)), + None => Some(fx.bcx.ins().iconst(fx.pointer_type, 0)), }, PassMode::ByVal(_) => None, }; diff --git a/src/base.rs b/src/base.rs index 1a15079a7a67f..81ab980c334b6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -11,7 +11,6 @@ impl String> Drop for PrintOnPanic { pub fn trans_mono_item<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - isa: &isa::TargetIsa, module: &mut Module, caches: &mut Caches<'tcx>, ccx: &mut crate::constant::ConstantCx, @@ -43,7 +42,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } }); - trans_fn(tcx, isa, module, ccx, caches, inst); + trans_fn(tcx, module, ccx, caches, inst); } MonoItem::Static(def_id) => { crate::constant::codegen_static(ccx, def_id); @@ -56,7 +55,6 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( fn trans_fn<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - isa: &isa::TargetIsa, module: &mut Module, constants: &mut crate::constant::ConstantCx, caches: &mut Caches<'tcx>, @@ -84,10 +82,11 @@ fn trans_fn<'a, 'tcx: 'a>( } // Step 5. Make FunctionCx + let pointer_type = module.target_config().pointer_type(); let mut fx = FunctionCx { tcx, - isa, module, + pointer_type, instance, mir, bcx, @@ -584,7 +583,7 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::Repeat(operand, times) => { let operand = trans_operand(fx, operand); for i in 0..*times { - let index = fx.bcx.ins().iconst(fx.module.pointer_type(), i as i64); + let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); } @@ -596,7 +595,7 @@ fn trans_stmt<'a, 'tcx: 'a>( ty::Array(_elem_ty, len) => { let len = crate::constant::force_eval_const(fx, len) .unwrap_usize(fx.tcx) as i64; - fx.bcx.ins().iconst(fx.module.pointer_type(), len) + fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => match place { CPlace::Addr(_, size, _) => size.unwrap(), @@ -644,7 +643,7 @@ fn trans_stmt<'a, 'tcx: 'a>( AggregateKind::Array(_ty) => { for (i, operand) in operands.into_iter().enumerate() { let operand = trans_operand(fx, operand); - let index = fx.bcx.ins().iconst(fx.module.pointer_type(), i as i64); + let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); } diff --git a/src/common.rs b/src/common.rs index c4658f2b51f6c..39bd293a2892d 100644 --- a/src/common.rs +++ b/src/common.rs @@ -134,7 +134,7 @@ impl<'tcx> CValue<'tcx> { let addr = fx .bcx .ins() - .stack_addr(fx.module.pointer_type(), stack_slot, 0); + .stack_addr(fx.pointer_type, stack_slot, 0); fx.bcx.ins().store(MemFlags::new(), value, addr, 0); addr } @@ -193,11 +193,11 @@ impl<'tcx> CValue<'tcx> { let val1 = fx.bcx .ins() - .load(fx.module.pointer_type(), MemFlags::new(), addr, val1_offset); + .load(fx.pointer_type, MemFlags::new(), addr, val1_offset); let val2 = fx.bcx .ins() - .load(fx.module.pointer_type(), MemFlags::new(), addr, val2_offset); + .load(fx.pointer_type, MemFlags::new(), addr, val2_offset); (val1, val2) } CValue::ByVal(_, _layout) => bug!("Please use load_value for ByVal"), @@ -248,7 +248,7 @@ impl<'tcx> CValue<'tcx> { let extra = fx .bcx .ins() - .iconst(fx.module.pointer_type(), size.unwrap_usize(fx.tcx) as i64); + .iconst(fx.pointer_type, size.unwrap_usize(fx.tcx) as i64); (ptr, extra) } _ => bug!("unsize non array {:?} to slice", ty), @@ -346,7 +346,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr( fx.bcx .ins() - .stack_addr(fx.module.pointer_type(), stack_slot, 0), + .stack_addr(fx.pointer_type, stack_slot, 0), None, layout, ) @@ -362,7 +362,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr( fx.bcx .ins() - .stack_addr(fx.module.pointer_type(), stack_slot, 0), + .stack_addr(fx.pointer_type, stack_slot, 0), None, layout, ) @@ -433,12 +433,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CValue::ByRef(from, _src_layout) => { let size = dst_layout.size.bytes() as i32; // FIXME emit_small_memcpy has a bug as of commit CraneStation/cranelift@b2281ed - // fx.bcx.emit_small_memcpy(fx.isa, addr, from, size, layout.align.abi() as u8, src_layout.align.abi() as u8); + // fx.bcx.emit_small_memcpy(fx.module.target_config(), addr, from, size, layout.align.abi() as u8, src_layout.align.abi() as u8); let mut offset = 0; while size - offset >= 8 { let byte = fx.bcx.ins().load( - fx.module.pointer_type(), + fx.pointer_type, MemFlags::new(), from, offset, @@ -609,9 +609,8 @@ pub fn cton_intcast<'a, 'tcx: 'a>( pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, - // FIXME get isa from Module - pub isa: &'a isa::TargetIsa, pub module: &'a mut Module, + pub pointer_type: Type, // Cached from module pub instance: Instance<'tcx>, pub mir: &'tcx Mir<'tcx>, pub param_substs: &'tcx Substs<'tcx>, diff --git a/src/constant.rs b/src/constant.rs index 0097386591235..c7a6b971041db 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -110,7 +110,7 @@ fn trans_const_value<'a, 'tcx: 'a>( let func_ref = fx.get_function_ref( Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), ); - let func_addr = fx.bcx.ins().func_addr(fx.module.pointer_type(), func_ref); + let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); CValue::ByVal(func_addr, layout) } _ => trans_const_place(fx, const_).to_cvalue(fx), @@ -176,7 +176,7 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( let global_ptr = fx .bcx .ins() - .global_value(fx.module.pointer_type(), local_data_id); + .global_value(fx.pointer_type, local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); assert!(!layout.is_unsized(), "unsized statics aren't supported"); CPlace::Addr(global_ptr, None, layout) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index b143c5789c7a5..f2cdb9b48f813 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -132,14 +132,14 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let elem_size = fx .bcx .ins() - .iconst(fx.module.pointer_type(), elem_size as i64); + .iconst(fx.pointer_type, elem_size as i64); assert_eq!(args.len(), 3); let byte_amount = fx.bcx.ins().imul(count, elem_size); if intrinsic.ends_with("_nonoverlapping") { - fx.bcx.call_memcpy(fx.isa, dst, src, byte_amount); + fx.bcx.call_memcpy(&fx.module.target_config(), dst, src, byte_amount); } else { - fx.bcx.call_memmove(fx.isa, dst, src, byte_amount); + fx.bcx.call_memmove(&fx.module.target_config(), dst, src, byte_amount); } }; discriminant_value, (c val) { @@ -157,7 +157,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if !layout.is_unsized() => fx .bcx .ins() - .iconst(fx.module.pointer_type(), layout.size.bytes() as i64), + .iconst(fx.pointer_type, layout.size.bytes() as i64), ty::Slice(elem) => { let len = ptr.load_value_pair(fx).1; let elem_size = fx.layout_of(elem).size.bytes(); @@ -179,10 +179,10 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if !layout.is_unsized() => fx .bcx .ins() - .iconst(fx.module.pointer_type(), layout.align.abi() as i64), + .iconst(fx.pointer_type, layout.align.abi() as i64), ty::Slice(elem) => { let align = fx.layout_of(elem).align.abi() as i64; - fx.bcx.ins().iconst(fx.module.pointer_type(), align) + fx.bcx.ins().iconst(fx.pointer_type, align) } ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, ptr), ty => unimplemented!("min_align_of_val for {:?}", ty), @@ -301,14 +301,14 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let addr = fx.bcx.ins().stack_addr(pointer_ty(fx.tcx), stack_slot, 0); let zero_val = fx.bcx.ins().iconst(types::I8, 0); let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); - fx.bcx.call_memset(fx.isa, addr, zero_val, len_val); + fx.bcx.call_memset(&fx.module.target_config(), addr, zero_val, len_val); let uninit_place = CPlace::from_stack_slot(fx, stack_slot, T); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); }; write_bytes, (v dst, v val, v count) { - fx.bcx.call_memset(fx.isa, dst, val, count); + fx.bcx.call_memset(&fx.module.target_config(), dst, val, count); }; uninit, () { let layout = fx.layout_of(T); diff --git a/src/lib.rs b/src/lib.rs index b14ed0e67863d..9e7e527e98d2c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,6 +80,7 @@ mod prelude { pub use crate::syntax::ast::{FloatTy, IntTy, UintTy}; pub use crate::syntax::source_map::DUMMY_SP; + pub use cranelift::codegen::isa::CallConv; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, }; @@ -178,16 +179,12 @@ impl CodegenBackend for CraneliftCodegenBackend { let metadata = tcx.encode_metadata(); - fn build_isa(tcx: TyCtxt) -> Box { - let mut flags_builder = settings::builder(); - flags_builder.enable("is_pic").unwrap(); - let flags = settings::Flags::new(flags_builder); - cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) - .unwrap() - .finish(flags) - } - - let isa = build_isa(tcx); + let mut flags_builder = settings::builder(); + flags_builder.enable("is_pic").unwrap(); + let flags = settings::Flags::new(flags_builder); + let isa = cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) + .unwrap() + .finish(flags); let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Lazy).0; @@ -198,9 +195,9 @@ impl CodegenBackend for CraneliftCodegenBackend { if std::env::var("SHOULD_RUN").is_ok() { let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); - assert_eq!(pointer_ty(tcx), jit_module.pointer_type()); + assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); - codegen_mono_items(tcx, &*isa, &mut jit_module, &mono_items); + codegen_mono_items(tcx, &mut jit_module, &mono_items); tcx.sess.abort_if_errors(); println!("Compiled everything"); @@ -208,10 +205,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let sig = Signature { params: vec![ - AbiParam::new(jit_module.pointer_type()), - AbiParam::new(jit_module.pointer_type()), + AbiParam::new(jit_module.target_config().pointer_type()), + AbiParam::new(jit_module.target_config().pointer_type()), ], - returns: vec![AbiParam::new(jit_module.pointer_type() /*isize*/)], + returns: vec![AbiParam::new(jit_module.target_config().pointer_type() /*isize*/)], call_conv: CallConv::SystemV, }; let main_func_id = jit_module @@ -239,9 +236,9 @@ impl CodegenBackend for CraneliftCodegenBackend { ) .unwrap(), ); - assert_eq!(pointer_ty(tcx), faerie_module.pointer_type()); + assert_eq!(pointer_ty(tcx), faerie_module.target_config().pointer_type()); - codegen_mono_items(tcx, &*build_isa(tcx), &mut faerie_module, &mono_items); + codegen_mono_items(tcx, &mut faerie_module, &mono_items); tcx.sess.abort_if_errors(); @@ -344,7 +341,6 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_mono_items<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - isa: &isa::TargetIsa, module: &mut Module, mono_items: &FxHashSet>, ) { @@ -367,7 +363,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( for mono_item in mono_items { let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { - base::trans_mono_item(tcx, isa, module, &mut caches, &mut ccx, *mono_item); + base::trans_mono_item(tcx, module, &mut caches, &mut ccx, *mono_item); })); if let Err(err) = res { diff --git a/src/main_shim.rs b/src/main_shim.rs index 204a933fb8d6b..f7b325f7038fc 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -38,10 +38,10 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( let cmain_sig = Signature { params: vec![ - AbiParam::new(m.pointer_type()), - AbiParam::new(m.pointer_type()), + AbiParam::new(m.target_config().pointer_type()), + AbiParam::new(m.target_config().pointer_type()), ], - returns: vec![AbiParam::new(m.pointer_type() /*isize*/)], + returns: vec![AbiParam::new(m.target_config().pointer_type() /*isize*/)], call_conv: CallConv::SystemV, }; @@ -65,8 +65,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( let ebb = bcx.create_ebb(); bcx.switch_to_block(ebb); - let arg_argc = bcx.append_ebb_param(ebb, m.pointer_type()); - let arg_argv = bcx.append_ebb_param(ebb, m.pointer_type()); + let arg_argc = bcx.append_ebb_param(ebb, m.target_config().pointer_type()); + let arg_argv = bcx.append_ebb_param(ebb, m.target_config().pointer_type()); let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); @@ -85,7 +85,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( .declare_function(&start_name, Linkage::Import, &start_sig) .unwrap(); - let main_val = bcx.ins().func_addr(m.pointer_type(), main_func_ref); + 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); bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]) diff --git a/src/vtable.rs b/src/vtable.rs index 5bc92049381dd..185ce4abfe0c5 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -66,7 +66,7 @@ pub fn get_vtable<'a, 'tcx: 'a>( let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); fx.bcx .ins() - .global_value(fx.module.pointer_type(), local_data_id) + .global_value(fx.pointer_type, local_data_id) } fn build_vtable<'a, 'tcx: 'a>( From c080c0bfec41e883e019e49de9b4b0cc35a4ff59 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 3 Nov 2018 15:04:27 +0100 Subject: [PATCH 0315/1566] Misc changes --- build.sh | 3 ++- src/lib.rs | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index b77536bf329a2..6bbf024044b55 100755 --- a/build.sh +++ b/build.sh @@ -30,6 +30,7 @@ else fi export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext +export XARGO_RUST_SRC=$(pwd)'/target/libcore/src' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" rm -r target/out || true @@ -52,7 +53,7 @@ time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core pushd xargo rm -r ~/.xargo/HOST || true -export XARGO_RUST_SRC=$(pwd)'/../target/libcore/src' +rm -r target || true time xargo build --color always popd diff --git a/src/lib.rs b/src/lib.rs index 9e7e527e98d2c..0ce01e1f51ef0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -197,7 +197,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); - codegen_mono_items(tcx, &mut jit_module, &mono_items); + codegen_mono_items(tcx, &mut jit_module, mono_items); tcx.sess.abort_if_errors(); println!("Compiled everything"); @@ -238,7 +238,7 @@ impl CodegenBackend for CraneliftCodegenBackend { ); assert_eq!(pointer_ty(tcx), faerie_module.target_config().pointer_type()); - codegen_mono_items(tcx, &mut faerie_module, &mono_items); + codegen_mono_items(tcx, &mut faerie_module, mono_items); tcx.sess.abort_if_errors(); @@ -342,7 +342,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_mono_items<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, - mono_items: &FxHashSet>, + mono_items: FxHashSet>, ) { use std::io::Write; @@ -363,7 +363,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( for mono_item in mono_items { let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { - base::trans_mono_item(tcx, module, &mut caches, &mut ccx, *mono_item); + base::trans_mono_item(tcx, module, &mut caches, &mut ccx, mono_item); })); if let Err(err) = res { From 4f7f65ce550e1c8b633155366435e91064726aca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 3 Nov 2018 18:22:05 +0100 Subject: [PATCH 0316/1566] Rustup to rustc 1.32.0-nightly (04fdb44f5 2018-11-03) --- example/mini_core.rs | 12 ++++++++++++ src/main_shim.rs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 455661bd77e15..b8504a147715b 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -15,6 +15,18 @@ impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b impl, U: ?Sized> CoerceUnsized<*const U> for *const T {} impl, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} +#[lang = "dispatch_from_dyn"] +pub trait DispatchFromDyn {} + +// &T -> &U +impl<'a, T: ?Sized+Unsize, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} +// &mut T -> &mut U +impl<'a, T: ?Sized+Unsize, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {} +// *const T -> *const U +impl, U: ?Sized> DispatchFromDyn<*const U> for *const T {} +// *mut T -> *mut U +impl, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {} + #[lang = "copy"] pub unsafe trait Copy {} diff --git a/src/main_shim.rs b/src/main_shim.rs index f7b325f7038fc..f96f353cac95d 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -34,7 +34,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( // late-bound regions, since late-bound // regions must appear in the argument // listing. - let main_ret_ty = tcx.erase_regions(&main_ret_ty.no_late_bound_regions().unwrap()); + let main_ret_ty = tcx.erase_regions(&main_ret_ty.no_bound_vars().unwrap()); let cmain_sig = Signature { params: vec![ From 438bee5fb1a988fe6bd5a4f06d33cfb25df72f9c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Nov 2018 18:03:47 +0100 Subject: [PATCH 0317/1566] Rustup to rustc 1.32.0-nightly (e6c5cf923 2018-11-04) --- src/abi.rs | 2 +- src/base.rs | 4 ++-- src/common.rs | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 42119a9bfad84..24645279f97fb 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -456,7 +456,7 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, ) { - let fn_ty = fx.monomorphize(&func.ty(&fx.mir.local_decls, fx.tcx)); + let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); let sig = ty_fn_sig(fx.tcx, fn_ty); // Unpack arguments tuple for closures diff --git a/src/base.rs b/src/base.rs index 81ab980c334b6..3d4112dba1042 100644 --- a/src/base.rs +++ b/src/base.rs @@ -402,7 +402,7 @@ fn trans_stmt<'a, 'tcx: 'a>( place.write_place_ref(fx, lval); } Rvalue::BinaryOp(bin_op, lhs, rhs) => { - let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); + let ty = fx.monomorphize(&lhs.ty(fx.mir, fx.tcx)); let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); @@ -422,7 +422,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, res); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { - let ty = fx.monomorphize(&lhs.ty(&fx.mir.local_decls, fx.tcx)); + let ty = fx.monomorphize(&lhs.ty(fx.mir, fx.tcx)); let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); diff --git a/src/common.rs b/src/common.rs index 39bd293a2892d..f642384634af0 100644 --- a/src/common.rs +++ b/src/common.rs @@ -20,7 +20,7 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } fn scalar_to_cton_type(tcx: TyCtxt, scalar: &Scalar) -> Type { - match scalar.value.size(tcx).bits() { + match scalar.value.size(&tcx).bits() { 8 => types::I8, 16 => types::I16, 32 => types::I32, @@ -530,7 +530,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { scalar_to_cton_type(fx.tcx, b), MemFlags::new(), addr, - a.value.size(fx.tcx).bytes() as u32 as i32, + a.value.size(&fx.tcx).bytes() as u32 as i32, ); CPlace::Addr(ptr, Some(extra), inner_layout) } @@ -558,7 +558,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { MemFlags::new(), extra.expect("unsized type without metadata"), dest.expect_addr(), - a.value.size(fx.tcx).bytes() as u32 as i32, + a.value.size(&fx.tcx).bytes() as u32 as i32, ); } _ => bug!( @@ -643,29 +643,29 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { } } -impl<'a, 'tcx: 'a, B: Backend> LayoutOf for &'a FunctionCx<'a, 'tcx, B> { +impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> { type Ty = Ty<'tcx>; type TyLayout = TyLayout<'tcx>; - fn layout_of(self, ty: Ty<'tcx>) -> TyLayout<'tcx> { + fn layout_of(&self, ty: Ty<'tcx>) -> TyLayout<'tcx> { let ty = self.monomorphize(&ty); self.tcx.layout_of(ParamEnv::reveal_all().and(&ty)).unwrap() } } -impl<'a, 'tcx, B: Backend + 'a> layout::HasTyCtxt<'tcx> for &'a FunctionCx<'a, 'tcx, B> { +impl<'a, 'tcx, B: Backend + 'a> layout::HasTyCtxt<'tcx> for FunctionCx<'a, 'tcx, B> { fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { self.tcx } } -impl<'a, 'tcx, B: Backend + 'a> layout::HasDataLayout for &'a FunctionCx<'a, 'tcx, B> { +impl<'a, 'tcx, B: Backend + 'a> layout::HasDataLayout for FunctionCx<'a, 'tcx, B> { fn data_layout(&self) -> &layout::TargetDataLayout { &self.tcx.data_layout } } -impl<'a, 'tcx, B: Backend + 'a> HasTargetSpec for &'a FunctionCx<'a, 'tcx, B> { +impl<'a, 'tcx, B: Backend + 'a> HasTargetSpec for FunctionCx<'a, 'tcx, B> { fn target_spec(&self) -> &Target { &self.tcx.sess.target.target } From d67fd1698286204e5491e4df9376b97e0e3392fe Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Nov 2018 18:13:58 +0100 Subject: [PATCH 0318/1566] Use cg_utils::symbol_export::provide{,_extern} --- src/lib.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0ce01e1f51ef0..28dd372ca6598 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -147,20 +147,12 @@ impl CodegenBackend for CraneliftCodegenBackend { fn provide(&self, providers: &mut Providers) { rustc_codegen_utils::symbol_names::provide(providers); + rustc_codegen_utils::symbol_export::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| Lrc::new(Default::default()); - providers.is_reachable_non_generic = |_tcx, _defid| true; - providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); - providers.upstream_monomorphizations = |_tcx, _cnum| Lrc::new(FxHashMap::default()); - providers.upstream_monomorphizations_for = |tcx, def_id| { - debug_assert!(!def_id.is_local()); - tcx.upstream_monomorphizations(LOCAL_CRATE) - .get(&def_id) - .cloned() - }; } fn provide_extern(&self, providers: &mut Providers) { - providers.is_reachable_non_generic = |_tcx, _defid| true; + rustc_codegen_utils::symbol_export::provide_extern(providers); } fn codegen_crate<'a, 'tcx>( From f19f8e4b4961e279cfe389bb177b86ea97613dbc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Nov 2018 18:27:10 +0100 Subject: [PATCH 0319/1566] Use tcx.collect_and_partition_mono_items --- src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 28dd372ca6598..c9ca758e55ab5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,9 +178,6 @@ impl CodegenBackend for CraneliftCodegenBackend { .unwrap() .finish(flags); - let mono_items = - collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Lazy).0; - // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore save_incremental(tcx); tcx.sess.warn("Saved incremental data"); @@ -189,7 +186,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); - codegen_mono_items(tcx, &mut jit_module, mono_items); + codegen_mono_items(tcx, &mut jit_module); tcx.sess.abort_if_errors(); println!("Compiled everything"); @@ -230,7 +227,7 @@ impl CodegenBackend for CraneliftCodegenBackend { ); assert_eq!(pointer_ty(tcx), faerie_module.target_config().pointer_type()); - codegen_mono_items(tcx, &mut faerie_module, mono_items); + codegen_mono_items(tcx, &mut faerie_module); tcx.sess.abort_if_errors(); @@ -334,7 +331,6 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_mono_items<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, - mono_items: FxHashSet>, ) { use std::io::Write; @@ -350,10 +346,15 @@ fn codegen_mono_items<'a, 'tcx: 'a>( None }; + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus.iter().map(|cgu| { + cgu.items().iter() + }).flatten().collect::>(); + let before = ::std::time::Instant::now(); println!("[codegen mono items] start"); - for mono_item in mono_items { + for (&mono_item, &(_linkage, _vis)) in mono_items { let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { base::trans_mono_item(tcx, module, &mut caches, &mut ccx, mono_item); })); From 4e4cad8a205276bdaf577a81b6af5102fbc2ee15 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Nov 2018 18:29:15 +0100 Subject: [PATCH 0320/1566] Allocator shim --- src/allocator.rs | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 13 ++++++++ 2 files changed, 94 insertions(+) create mode 100644 src/allocator.rs diff --git a/src/allocator.rs b/src/allocator.rs new file mode 100644 index 0000000000000..72ddf5312bd60 --- /dev/null +++ b/src/allocator.rs @@ -0,0 +1,81 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crate::prelude::*; + +use crate::rustc::middle::allocator::AllocatorKind; +use crate::rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; + +pub fn codegen(tcx: TyCtxt, module: &mut Module, kind: AllocatorKind) { + let usize_ty = module.target_config().pointer_type(); + + for method in ALLOCATOR_METHODS { + let mut arg_tys = Vec::with_capacity(method.inputs.len()); + for ty in method.inputs.iter() { + match *ty { + AllocatorTy::Layout => { + arg_tys.push(usize_ty); // size + arg_tys.push(usize_ty); // align + } + AllocatorTy::Ptr => arg_tys.push(usize_ty), + AllocatorTy::Usize => arg_tys.push(usize_ty), + + AllocatorTy::ResultPtr | + AllocatorTy::Unit => panic!("invalid allocator arg"), + } + } + let output = match method.output { + AllocatorTy::ResultPtr => Some(usize_ty), + AllocatorTy::Unit => None, + + AllocatorTy::Layout | + AllocatorTy::Usize | + AllocatorTy::Ptr => panic!("invalid allocator output"), + }; + + let sig = Signature { + call_conv: CallConv::Fast, + params: arg_tys.iter().cloned().map(AbiParam::new).collect(), + returns: output.into_iter().map(AbiParam::new).collect(), + }; + + let func_id = module + .declare_function(&format!("__rust_{}", method.name), Linkage::Export, &sig) + .unwrap(); + + let callee_func_id = module + .declare_function(&kind.fn_name(method.name), Linkage::Import, &sig) + .unwrap(); + + let mut ctx = Context::new(); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); + { + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); + + let ebb = bcx.create_ebb(); + bcx.switch_to_block(ebb); + let args = arg_tys + .into_iter() + .map(|ty| bcx.append_ebb_param(ebb, ty)) + .collect::>(); + + let callee_func_ref = module.declare_func_in_func(callee_func_id, &mut bcx.func); + + let call_inst = bcx.ins().call(callee_func_ref, &args); + + let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error + bcx.ins().return_(&results); + bcx.seal_all_blocks(); + bcx.finalize(); + } + module.define_function(func_id, &mut ctx).unwrap(); + } +} diff --git a/src/lib.rs b/src/lib.rs index c9ca758e55ab5..013dbc510d826 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ extern crate byteorder; extern crate syntax; #[macro_use] extern crate rustc; +extern crate rustc_allocator; extern crate rustc_codegen_utils; extern crate rustc_incremental; extern crate rustc_mir; @@ -47,6 +48,7 @@ macro_rules! unimpl { } mod abi; +mod allocator; mod analyze; mod base; mod common; @@ -374,6 +376,17 @@ fn codegen_mono_items<'a, 'tcx: 'a>( crate::main_shim::maybe_create_entry_wrapper(tcx, module); + let any_dynamic_crate = tcx.sess.dependency_formats.borrow() + .iter() + .any(|(_, list)| { + use crate::rustc::middle::dependency_format::Linkage; + list.iter().any(|&linkage| linkage == Linkage::Dynamic) + }); + if any_dynamic_crate { + } else if let Some(kind) = *tcx.sess.allocator_kind.get() { + allocator::codegen(tcx, module, kind); + } + ccx.finalize(tcx, module); let after = ::std::time::Instant::now(); From d20f54bb1a873a16681c687a58b7946dc6924913 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Nov 2018 18:42:43 +0100 Subject: [PATCH 0321/1566] Add some benchmarks --- .travis.yml | 1 + build.sh | 24 +++++++++++++++++++---- example/alloc_example.rs | 41 ++++++++++++++++++++++++++++++++++++++++ example/mod_bench.rs | 37 ++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 example/alloc_example.rs create mode 100644 example/mod_bench.rs diff --git a/.travis.yml b/.travis.yml index db9dbdcc2592e..9ee74793c72db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ rust: script: - rustup component add rust-src - cargo install xargo || echo "Skipping xargo install" + - cargo install hyperfine || echo "Skipping hyperfine install" - ./prepare_libcore.sh - ./build.sh diff --git a/build.sh b/build.sh index 6bbf024044b55..acb9bbc92d70f 100755 --- a/build.sh +++ b/build.sh @@ -48,13 +48,29 @@ SHOULD_RUN=1 $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" build_example_bin mini_core_hello_world example/mini_core_hello_world.rs -echo "[BUILD] core" -time $RUSTC target/libcore/src/libcore/lib.rs --crate-type lib --crate-name core -Cincremental=target/incremental_core - pushd xargo rm -r ~/.xargo/HOST || true rm -r target || true -time xargo build --color always +time xargo build popd +$RUSTC --sysroot ~/.xargo/HOST example/alloc_example.rs --crate-type bin +# TODO linux linker doesn't accept duplicate definitions +#gcc -Wl,--gc-sections target/out/alloc_example ~/.xargo/HOST/lib/rustlib/*/lib/libcore-*.rlib ~/.xargo/HOST/lib/rustlib/*/lib/liballoc-*.rlib ~/.xargo/HOST/lib/rustlib/*/lib/liballoc_system-*.rlib -o target/out/alloc_example_exe +#hyperfine ./target/out/alloc_example_exe + +$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin +gcc -Wl,--gc-sections target/out/mod_bench -lc -o target/out/mod_bench_exe + +$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 --crate-name mod_bench_inline +gcc -Wl,--gc-sections target/out/mod_bench_inline -lc -o target/out/mod_bench_inline_exe + +rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort +rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort +rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort +rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort +echo +echo "[Bench] mod_bench" +hyperfine ./target/out/mod_bench{,_inline}_exe ./target/out/mod_bench_llvm_* + cat target/out/log.txt | sort | uniq -c diff --git a/example/alloc_example.rs b/example/alloc_example.rs new file mode 100644 index 0000000000000..06746ab1f76e9 --- /dev/null +++ b/example/alloc_example.rs @@ -0,0 +1,41 @@ +#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_error_handler)] +#![no_std] + +extern crate alloc; +extern crate alloc_system; + +use alloc::prelude::*; + +use alloc_system::System; + +#[global_allocator] +static ALLOC: System = System; + +#[link(name = "c")] +extern "C" { + fn puts(s: *const u8); +} + +#[panic_handler] +fn panic_handler(_: &core::panic::PanicInfo) -> ! { + unsafe { + core::intrinsics::abort(); + } +} + +#[alloc_error_handler] +fn alloc_error_handler(_: alloc::alloc::Layout) -> ! { + unsafe { + core::intrinsics::abort(); + } +} + +#[start] +fn main(_argc: isize, _argv: *const *const u8) -> isize { + let world: Box<&str> = box "Hello World!\0"; + unsafe { + puts(*world as *const str as *const u8); + } + + 0 +} diff --git a/example/mod_bench.rs b/example/mod_bench.rs new file mode 100644 index 0000000000000..2e2b0052dee8b --- /dev/null +++ b/example/mod_bench.rs @@ -0,0 +1,37 @@ +#![feature(start, box_syntax, core_intrinsics, lang_items)] +#![no_std] + +#[link(name = "c")] +extern {} + +#[panic_handler] +fn panic_handler(_: &core::panic::PanicInfo) -> ! { + unsafe { + core::intrinsics::abort(); + } +} + +#[lang="eh_personality"] +fn eh_personality(){} + +// Required for rustc_codegen_llvm +#[no_mangle] +unsafe extern "C" fn _Unwind_Resume() { + core::intrinsics::unreachable(); +} + +#[start] +fn main(_argc: isize, _argv: *const *const u8) -> isize { + for i in 2..100_000_000 { + black_box((i + 1) % i); + } + + 0 +} + +#[inline(never)] +fn black_box(i: u32) { + if i != 1 { + unsafe { core::intrinsics::abort(); } + } +} From 648f491977546945afa31587390041d3fdb17c61 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Nov 2018 13:29:38 +0100 Subject: [PATCH 0322/1566] Enable feature gate extern_crate_item_prelude --- src/abi.rs | 4 ++-- src/allocator.rs | 4 ++-- src/analyze.rs | 2 +- src/base.rs | 2 +- src/common.rs | 2 +- src/constant.rs | 15 +++++++++------ src/lib.rs | 40 +++++++++++++++++++--------------------- src/main_shim.rs | 4 ++-- src/metadata.rs | 4 ++-- 9 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 24645279f97fb..217064e51b880 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -1,7 +1,7 @@ use std::iter; -use crate::rustc::hir; -use crate::rustc_target::spec::abi::Abi; +use rustc::hir; +use rustc_target::spec::abi::Abi; use crate::prelude::*; diff --git a/src/allocator.rs b/src/allocator.rs index 72ddf5312bd60..72f1046a56b0c 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -10,8 +10,8 @@ use crate::prelude::*; -use crate::rustc::middle::allocator::AllocatorKind; -use crate::rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; +use rustc::middle::allocator::AllocatorKind; +use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; pub fn codegen(tcx: TyCtxt, module: &mut Module, kind: AllocatorKind) { let usize_ty = module.target_config().pointer_type(); diff --git a/src/analyze.rs b/src/analyze.rs index c8b4697bec9b1..bdb40411ffa26 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use crate::rustc::mir::StatementKind::*; +use rustc::mir::StatementKind::*; bitflags! { pub struct Flags: u8 { diff --git a/src/base.rs b/src/base.rs index 3d4112dba1042..6c55e12fde78c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -606,7 +606,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { - use crate::rustc::middle::lang_items::ExchangeMallocFnLangItem; + use rustc::middle::lang_items::ExchangeMallocFnLangItem; let usize_type = fx.cton_type(fx.tcx.types.usize).unwrap(); let (size, align) = fx.layout_of(content_ty).size_and_align(); diff --git a/src/common.rs b/src/common.rs index f642384634af0..8b3c019691e86 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,6 +1,6 @@ use std::fmt; -use crate::rustc_target::spec::{HasTargetSpec, Target}; +use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::Module; diff --git a/src/constant.rs b/src/constant.rs index c7a6b971041db..f66abe052a595 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,11 +1,14 @@ -use cranelift_module::*; -use crate::prelude::*; -use crate::rustc::mir::interpret::{ +use std::borrow::Cow; + +use rustc::mir::interpret::{ read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; -use crate::rustc::ty::Const; -use crate::rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, MemPlace, OpTy, PlaceTy, Pointer}; -use std::borrow::Cow; +use rustc::ty::Const; +use rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, MemPlace, OpTy, PlaceTy, Pointer}; + +use cranelift_module::*; + +use crate::prelude::*; #[derive(Default)] pub struct ConstantCx { diff --git a/src/lib.rs b/src/lib.rs index 013dbc510d826..c7b09c22a8b47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, macro_at_most_once_rep, never_type)] +#![feature(rustc_private, macro_at_most_once_rep, never_type, extern_crate_item_prelude)] #![allow(intra_doc_link_resolution_failure)] extern crate byteorder; @@ -26,15 +26,15 @@ extern crate target_lexicon; use std::any::Any; use std::fs::File; -use std::sync::{mpsc, Arc}; +use std::sync::mpsc; -use crate::rustc::dep_graph::DepGraph; -use crate::rustc::middle::cstore::MetadataLoader; -use crate::rustc::session::{config::OutputFilenames, CompileIncomplete}; -use crate::rustc::ty::query::Providers; -use crate::rustc_codegen_utils::codegen_backend::CodegenBackend; -use crate::rustc_codegen_utils::link::out_filename; -use crate::syntax::symbol::Symbol; +use rustc::dep_graph::DepGraph; +use rustc::middle::cstore::MetadataLoader; +use rustc::session::{config::OutputFilenames, CompileIncomplete}; +use rustc::ty::query::Providers; +use rustc_codegen_utils::codegen_backend::CodegenBackend; +use rustc_codegen_utils::link::out_filename; +use syntax::symbol::Symbol; use cranelift::codegen::settings; use cranelift_faerie::*; @@ -63,24 +63,22 @@ mod prelude { pub use std::any::Any; pub use std::collections::{HashMap, HashSet}; - pub use crate::rustc::hir::def_id::{DefId, LOCAL_CRATE}; - pub use crate::rustc::mir; - pub use crate::rustc::mir::interpret::AllocId; - pub use crate::rustc::mir::*; - pub use crate::rustc::session::{config::CrateType, Session}; - pub use crate::rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; - pub use crate::rustc::ty::{ + pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; + pub use rustc::mir::{self, interpret::AllocId, *}; + pub use rustc::session::{config::CrateType, Session}; + pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; + pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; - pub use crate::rustc_data_structures::{ + pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, indexed_vec::Idx, sync::Lrc, }; - pub use crate::rustc_mir::monomorphize::{collector, MonoItem}; - pub use crate::syntax::ast::{FloatTy, IntTy, UintTy}; - pub use crate::syntax::source_map::DUMMY_SP; + pub use rustc_mir::monomorphize::{collector, MonoItem}; + pub use syntax::ast::{FloatTy, IntTy, UintTy}; + pub use syntax::source_map::DUMMY_SP; pub use cranelift::codegen::isa::CallConv; pub use cranelift::codegen::ir::{ @@ -379,7 +377,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( let any_dynamic_crate = tcx.sess.dependency_formats.borrow() .iter() .any(|(_, list)| { - use crate::rustc::middle::dependency_format::Linkage; + use rustc::middle::dependency_format::Linkage; list.iter().any(|&linkage| linkage == Linkage::Dynamic) }); if any_dynamic_crate { diff --git a/src/main_shim.rs b/src/main_shim.rs index f96f353cac95d..ef9409f4bb25d 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -6,8 +6,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, ) { - use crate::rustc::middle::lang_items::StartFnLangItem; - use crate::rustc::session::config::EntryFnType; + use rustc::middle::lang_items::StartFnLangItem; + use rustc::session::config::EntryFnType; let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { Some((id, _, entry_ty)) => ( diff --git a/src/metadata.rs b/src/metadata.rs index 1e68e9f1363a9..bbcbd083fa7e1 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,5 +1,5 @@ -use crate::rustc::middle::cstore::MetadataLoader; -use crate::rustc_data_structures::owning_ref::{self, OwningRef}; +use rustc::middle::cstore::MetadataLoader; +use rustc_data_structures::owning_ref::{self, OwningRef}; use std::fs::File; use std::path::Path; From b73bda1c3f845680a4e0da40b5b6519c2ba4845b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Nov 2018 13:31:02 +0100 Subject: [PATCH 0323/1566] Fix warnings --- src/allocator.rs | 2 +- src/common.rs | 11 ----------- src/lib.rs | 4 ++-- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 72f1046a56b0c..d1bff9ac524bf 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -13,7 +13,7 @@ use crate::prelude::*; use rustc::middle::allocator::AllocatorKind; use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; -pub fn codegen(tcx: TyCtxt, module: &mut Module, kind: AllocatorKind) { +pub fn codegen(module: &mut Module, kind: AllocatorKind) { let usize_ty = module.target_config().pointer_type(); for method in ALLOCATOR_METHODS { diff --git a/src/common.rs b/src/common.rs index 8b3c019691e86..c4a33695fe25c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -205,17 +205,6 @@ impl<'tcx> CValue<'tcx> { } } - pub fn expect_byref(self) -> (Value, TyLayout<'tcx>) { - match self { - CValue::ByRef(value, layout) => (value, layout), - CValue::ByVal(_, _) => bug!("Expected CValue::ByRef, found CValue::ByVal: {:?}", self), - CValue::ByValPair(_, _, _) => bug!( - "Expected CValue::ByRef, found CValue::ByValPair: {:?}", - self - ), - } - } - pub fn value_field<'a>( self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, diff --git a/src/lib.rs b/src/lib.rs index c7b09c22a8b47..7cce688712338 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -363,7 +363,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( match err.downcast::() { Ok(non_fatal) => { if cfg!(debug_assertions) { - writeln!(log.as_mut().unwrap(), "{}", &non_fatal.0); + writeln!(log.as_mut().unwrap(), "{}", &non_fatal.0).unwrap(); } tcx.sess.err(&non_fatal.0) } @@ -382,7 +382,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( }); if any_dynamic_crate { } else if let Some(kind) = *tcx.sess.allocator_kind.get() { - allocator::codegen(tcx, module, kind); + allocator::codegen(module, kind); } ccx.finalize(tcx, module); From 29b4c34c540db66fd13b63037109528eeb97146b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Nov 2018 13:32:02 +0100 Subject: [PATCH 0324/1566] Rustfmt --- src/abi.rs | 14 +++++--------- src/allocator.rs | 11 +++++------ src/base.rs | 9 ++++----- src/common.rs | 46 +++++++++++++++++++--------------------------- src/constant.rs | 31 +++++++++++++++++++++++-------- src/lib.rs | 38 +++++++++++++++++++++++++++----------- src/main_shim.rs | 8 ++++++-- src/metadata.rs | 5 +---- src/vtable.rs | 4 +--- 9 files changed, 91 insertions(+), 75 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 217064e51b880..f42707b5f80d1 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -28,11 +28,10 @@ fn get_pass_mode<'a, 'tcx: 'a>( ty: Ty<'tcx>, is_return: bool, ) -> PassMode { - assert!( - !tcx.layout_of(ParamEnv::reveal_all().and(ty)) - .unwrap() - .is_unsized() - ); + assert!(!tcx + .layout_of(ParamEnv::reveal_all().and(ty)) + .unwrap() + .is_unsized()); if let ty::Never = ty.sty { if is_return { PassMode::NoPass @@ -256,10 +255,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { CValue::ByVal(val, return_layout) } else { - CValue::ByRef( - self.bcx.ins().iconst(self.pointer_type, 0), - return_layout, - ) + CValue::ByRef(self.bcx.ins().iconst(self.pointer_type, 0), return_layout) } } diff --git a/src/allocator.rs b/src/allocator.rs index d1bff9ac524bf..d84838634e798 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -11,7 +11,7 @@ use crate::prelude::*; use rustc::middle::allocator::AllocatorKind; -use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy}; +use rustc_allocator::{AllocatorTy, ALLOCATOR_METHODS}; pub fn codegen(module: &mut Module, kind: AllocatorKind) { let usize_ty = module.target_config().pointer_type(); @@ -27,17 +27,16 @@ pub fn codegen(module: &mut Module, kind: AllocatorKind) AllocatorTy::Ptr => arg_tys.push(usize_ty), AllocatorTy::Usize => arg_tys.push(usize_ty), - AllocatorTy::ResultPtr | - AllocatorTy::Unit => panic!("invalid allocator arg"), + AllocatorTy::ResultPtr | AllocatorTy::Unit => panic!("invalid allocator arg"), } } let output = match method.output { AllocatorTy::ResultPtr => Some(usize_ty), AllocatorTy::Unit => None, - AllocatorTy::Layout | - AllocatorTy::Usize | - AllocatorTy::Ptr => panic!("invalid allocator output"), + AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => { + panic!("invalid allocator output") + } }; let sig = Signature { diff --git a/src/base.rs b/src/base.rs index 6c55e12fde78c..0b7e657f17f38 100644 --- a/src/base.rs +++ b/src/base.rs @@ -630,11 +630,10 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout)); } Rvalue::NullaryOp(NullOp::SizeOf, ty) => { - assert!( - lval.layout() - .ty - .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) - ); + assert!(lval + .layout() + .ty + .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all())); let ty_size = fx.layout_of(ty).size.bytes(); let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64); lval.write_cvalue(fx, val); diff --git a/src/common.rs b/src/common.rs index c4a33695fe25c..848f66a48d2bb 100644 --- a/src/common.rs +++ b/src/common.rs @@ -131,10 +131,7 @@ impl<'tcx> CValue<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - let addr = fx - .bcx - .ins() - .stack_addr(fx.pointer_type, stack_slot, 0); + let addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); fx.bcx.ins().store(MemFlags::new(), value, addr, 0); addr } @@ -161,9 +158,10 @@ impl<'tcx> CValue<'tcx> { match self { CValue::ByRef(addr, layout) => { let cton_ty = fx.cton_type(layout.ty).unwrap_or_else(|| { - if layout.ty.is_box() && !fx - .layout_of(layout.ty.builtin_deref(true).unwrap().ty) - .is_unsized() + if layout.ty.is_box() + && !fx + .layout_of(layout.ty.builtin_deref(true).unwrap().ty) + .is_unsized() { // Consider sized box to be a ptr pointer_ty(fx.tcx) @@ -190,14 +188,14 @@ impl<'tcx> CValue<'tcx> { ); let val1_offset = layout.fields.offset(0).bytes() as i32; let val2_offset = layout.fields.offset(1).bytes() as i32; - let val1 = - fx.bcx - .ins() - .load(fx.pointer_type, MemFlags::new(), addr, val1_offset); - let val2 = - fx.bcx - .ins() - .load(fx.pointer_type, MemFlags::new(), addr, val2_offset); + let val1 = fx + .bcx + .ins() + .load(fx.pointer_type, MemFlags::new(), addr, val1_offset); + let val2 = fx + .bcx + .ins() + .load(fx.pointer_type, MemFlags::new(), addr, val2_offset); (val1, val2) } CValue::ByVal(_, _layout) => bug!("Please use load_value for ByVal"), @@ -333,9 +331,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { offset: None, }); CPlace::Addr( - fx.bcx - .ins() - .stack_addr(fx.pointer_type, stack_slot, 0), + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None, layout, ) @@ -349,9 +345,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let layout = fx.layout_of(ty); assert!(!layout.is_unsized()); CPlace::Addr( - fx.bcx - .ins() - .stack_addr(fx.pointer_type, stack_slot, 0), + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None, layout, ) @@ -426,12 +420,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let mut offset = 0; while size - offset >= 8 { - let byte = fx.bcx.ins().load( - fx.pointer_type, - MemFlags::new(), - from, - offset, - ); + let byte = + fx.bcx + .ins() + .load(fx.pointer_type, MemFlags::new(), from, offset); fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); offset += 8; } diff --git a/src/constant.rs b/src/constant.rs index f66abe052a595..4dcbf1da82c8b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -4,7 +4,9 @@ use rustc::mir::interpret::{ read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; use rustc::ty::Const; -use rustc_mir::interpret::{EvalContext, Machine, Memory, MemoryKind, MemPlace, OpTy, PlaceTy, Pointer}; +use rustc_mir::interpret::{ + EvalContext, Machine, MemPlace, Memory, MemoryKind, OpTy, PlaceTy, Pointer, +}; use cranelift_module::*; @@ -176,10 +178,7 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( data_id: DataId, ) -> CPlace<'tcx> { let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - let global_ptr = fx - .bcx - .ins() - .global_value(fx.pointer_type, local_data_id); + let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); assert!(!layout.is_unsized(), "unsized statics aren't supported"); CPlace::Addr(global_ptr, None, layout) @@ -336,11 +335,23 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn tag_reference(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: MemPlace, _: Ty<'tcx>, _: Size, _: Option) -> EvalResult<'tcx, MemPlace> { + fn tag_reference( + _: &mut EvalContext<'a, 'mir, 'tcx, Self>, + _: MemPlace, + _: Ty<'tcx>, + _: Size, + _: Option, + ) -> EvalResult<'tcx, MemPlace> { panic!() } - fn tag_dereference(_: &EvalContext<'a, 'mir, 'tcx, Self>, _: MemPlace, _: Ty<'tcx>, _: Size, _: Option) -> EvalResult<'tcx, MemPlace> { + fn tag_dereference( + _: &EvalContext<'a, 'mir, 'tcx, Self>, + _: MemPlace, + _: Ty<'tcx>, + _: Size, + _: Option, + ) -> EvalResult<'tcx, MemPlace> { panic!(); } @@ -348,7 +359,11 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { Cow::Borrowed(alloc) } - fn tag_new_allocation(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, ptr: Pointer, _: MemoryKind) -> EvalResult<'tcx, Pointer> { + fn tag_new_allocation( + _: &mut EvalContext<'a, 'mir, 'tcx, Self>, + ptr: Pointer, + _: MemoryKind, + ) -> EvalResult<'tcx, Pointer> { Ok(ptr) } } diff --git a/src/lib.rs b/src/lib.rs index 7cce688712338..8dccc6e26a846 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,9 @@ -#![feature(rustc_private, macro_at_most_once_rep, never_type, extern_crate_item_prelude)] +#![feature( + rustc_private, + macro_at_most_once_rep, + never_type, + extern_crate_item_prelude +)] #![allow(intra_doc_link_resolution_failure)] extern crate byteorder; @@ -80,10 +85,10 @@ mod prelude { pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::source_map::DUMMY_SP; - pub use cranelift::codegen::isa::CallConv; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, }; + pub use cranelift::codegen::isa::CallConv; pub use cranelift::codegen::Context; pub use cranelift::prelude::*; pub use cranelift_module::{Backend, DataContext, DataId, FuncId, Linkage, Module}; @@ -174,9 +179,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); let flags = settings::Flags::new(flags_builder); - let isa = cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) - .unwrap() - .finish(flags); + let isa = + cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) + .unwrap() + .finish(flags); // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore save_incremental(tcx); @@ -197,7 +203,9 @@ impl CodegenBackend for CraneliftCodegenBackend { AbiParam::new(jit_module.target_config().pointer_type()), AbiParam::new(jit_module.target_config().pointer_type()), ], - returns: vec![AbiParam::new(jit_module.target_config().pointer_type() /*isize*/)], + returns: vec![AbiParam::new( + jit_module.target_config().pointer_type(), /*isize*/ + )], call_conv: CallConv::SystemV, }; let main_func_id = jit_module @@ -225,7 +233,10 @@ impl CodegenBackend for CraneliftCodegenBackend { ) .unwrap(), ); - assert_eq!(pointer_ty(tcx), faerie_module.target_config().pointer_type()); + assert_eq!( + pointer_ty(tcx), + faerie_module.target_config().pointer_type() + ); codegen_mono_items(tcx, &mut faerie_module); @@ -347,9 +358,11 @@ fn codegen_mono_items<'a, 'tcx: 'a>( }; let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let mono_items = cgus.iter().map(|cgu| { - cgu.items().iter() - }).flatten().collect::>(); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items().iter()) + .flatten() + .collect::>(); let before = ::std::time::Instant::now(); println!("[codegen mono items] start"); @@ -374,7 +387,10 @@ fn codegen_mono_items<'a, 'tcx: 'a>( crate::main_shim::maybe_create_entry_wrapper(tcx, module); - let any_dynamic_crate = tcx.sess.dependency_formats.borrow() + let any_dynamic_crate = tcx + .sess + .dependency_formats + .borrow() .iter() .any(|(_, list)| { use rustc::middle::dependency_format::Linkage; diff --git a/src/main_shim.rs b/src/main_shim.rs index ef9409f4bb25d..5b61ef24cf2e5 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -41,7 +41,9 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( AbiParam::new(m.target_config().pointer_type()), AbiParam::new(m.target_config().pointer_type()), ], - returns: vec![AbiParam::new(m.target_config().pointer_type() /*isize*/)], + returns: vec![AbiParam::new( + m.target_config().pointer_type(), /*isize*/ + )], call_conv: CallConv::SystemV, }; @@ -85,7 +87,9 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( .declare_function(&start_name, Linkage::Import, &start_sig) .unwrap(); - let main_val = bcx.ins().func_addr(m.target_config().pointer_type(), main_func_ref); + 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); bcx.ins().call(func_ref, &[main_val, arg_argc, arg_argv]) diff --git a/src/metadata.rs b/src/metadata.rs index bbcbd083fa7e1..bef1d7fccda2c 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -17,10 +17,7 @@ impl MetadataLoader for CraneliftMetadataLoader { // Iterate over all entries in the archive: while let Some(entry_result) = archive.next_entry() { let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; - if entry - .header() - .identifier() == METADATA_FILE - { + if entry.header().identifier() == METADATA_FILE { let mut buf = Vec::new(); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); diff --git a/src/vtable.rs b/src/vtable.rs index 185ce4abfe0c5..d0ea60666d180 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -64,9 +64,7 @@ pub fn get_vtable<'a, 'tcx: 'a>( }; let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - fx.bcx - .ins() - .global_value(fx.pointer_type, local_data_id) + fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } fn build_vtable<'a, 'tcx: 'a>( From 0b76af209587ac366351c9eb470c609c4e9cf065 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Nov 2018 13:35:10 +0100 Subject: [PATCH 0325/1566] Remove should_codegen --- src/base.rs | 13 +++++-------- src/lib.rs | 28 +++++++++------------------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/base.rs b/src/base.rs index 0b7e657f17f38..3bf906a460c2b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -129,14 +129,11 @@ fn trans_fn<'a, 'tcx: 'a>( verify_func(tcx, writer, &func); // Step 9. Define function - // TODO: cranelift doesn't yet support some of the things needed - if should_codegen(tcx.sess) { - caches.context.func = func; - module - .define_function(func_id, &mut caches.context) - .unwrap(); - caches.context.clear(); - } + caches.context.func = func; + module + .define_function(func_id, &mut caches.context) + .unwrap(); + caches.context.clear(); } fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Function) { diff --git a/src/lib.rs b/src/lib.rs index 8dccc6e26a846..2fd5d8c04eac6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,12 +98,6 @@ mod prelude { pub use crate::base::{trans_operand, trans_place}; pub use crate::common::*; pub use crate::Caches; - - pub fn should_codegen(_sess: &Session) -> bool { - true - //::std::env::var("SHOULD_CODEGEN").is_ok() - // || sess.crate_types.get().contains(&CrateType::Executable) - } } use crate::constant::ConstantCx; @@ -242,9 +236,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.abort_if_errors(); - if should_codegen(tcx.sess) { - faerie_module.finalize_definitions(); - } + faerie_module.finalize_definitions(); return Box::new(OngoingCodegen { product: faerie_module.finish(), @@ -294,16 +286,14 @@ impl CodegenBackend for CraneliftCodegenBackend { let file = File::create(&output_name).unwrap(); let mut builder = ar::Builder::new(file); - if should_codegen(sess) { - // Add main object file - let obj = artifact.emit().unwrap(); - builder - .append( - &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), - ::std::io::Cursor::new(obj), - ) - .unwrap(); - } + // Add main object file + let obj = artifact.emit().unwrap(); + builder + .append( + &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), + ::std::io::Cursor::new(obj), + ) + .unwrap(); // Non object files need to be added after object files, because ranlib will // try to read the native architecture from the first file, even if it isn't From d0a3f9921483ada9246fc4e27b4d81ef544f6fd8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Nov 2018 14:04:44 +0100 Subject: [PATCH 0326/1566] Introduce link module --- src/lib.rs | 85 ++++++++--------------------------------------------- src/link.rs | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 72 deletions(-) create mode 100644 src/link.rs diff --git a/src/lib.rs b/src/lib.rs index 2fd5d8c04eac6..912184dd8f38a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,7 +30,6 @@ extern crate cranelift_simplejit; extern crate target_lexicon; use std::any::Any; -use std::fs::File; use std::sync::mpsc; use rustc::dep_graph::DepGraph; @@ -59,6 +58,7 @@ mod base; mod common; mod constant; mod intrinsics; +mod link; mod main_shim; mod metadata; mod pretty_clif; @@ -119,8 +119,8 @@ impl<'tcx> Caches<'tcx> { struct CraneliftCodegenBackend; -struct OngoingCodegen { - product: cranelift_faerie::FaerieProduct, +struct CodegenResult { + artifact: faerie::Artifact, metadata: Vec, crate_name: Symbol, } @@ -238,8 +238,8 @@ impl CodegenBackend for CraneliftCodegenBackend { faerie_module.finalize_definitions(); - return Box::new(OngoingCodegen { - product: faerie_module.finish(), + return Box::new(CodegenResult { + artifact: faerie_module.finish().artifact, metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), }); @@ -248,80 +248,21 @@ impl CodegenBackend for CraneliftCodegenBackend { fn join_codegen_and_link( &self, - ongoing_codegen: Box, + res: Box, sess: &Session, _dep_graph: &DepGraph, outputs: &OutputFilenames, ) -> Result<(), CompileIncomplete> { - let ongoing_codegen = *ongoing_codegen - .downcast::() - .expect("Expected CraneliftCodegenBackend's OngoingCodegen, found Box"); - - let artifact = ongoing_codegen.product.artifact; - let metadata = ongoing_codegen.metadata; - - /* - artifact - .declare_with( - &metadata_name, - faerie::artifact::Decl::Data { - global: true, - writable: false, - }, - metadata.clone(), - ) - .unwrap(); - */ + let res = *res + .downcast::() + .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); for &crate_type in sess.opts.crate_types.iter() { + let output_name = + out_filename(sess, crate_type, &outputs, &res.crate_name.as_str()); match crate_type { - // TODO: link executable - CrateType::Executable | CrateType::Rlib => { - let output_name = out_filename( - sess, - crate_type, - &outputs, - &ongoing_codegen.crate_name.as_str(), - ); - let file = File::create(&output_name).unwrap(); - let mut builder = ar::Builder::new(file); - - // Add main object file - let obj = artifact.emit().unwrap(); - builder - .append( - &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), - ::std::io::Cursor::new(obj), - ) - .unwrap(); - - // Non object files need to be added after object files, because ranlib will - // try to read the native architecture from the first file, even if it isn't - // an object file - if crate_type != CrateType::Executable { - builder - .append( - &ar::Header::new( - metadata::METADATA_FILE.to_vec(), - metadata.len() as u64, - ), - ::std::io::Cursor::new(metadata.clone()), - ) - .unwrap(); - } - - // Finalize archive - std::mem::drop(builder); - - // Run ranlib to be able to link the archive - let status = std::process::Command::new("ranlib") - .arg(output_name) - .status() - .expect("Couldn't run ranlib"); - if !status.success() { - sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); - } - } + CrateType::Rlib => link::link_rlib(sess, &res, output_name), + CrateType::Executable => link::link_bin(sess, &res, output_name), _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), } } diff --git a/src/link.rs b/src/link.rs new file mode 100644 index 0000000000000..822c908da42b3 --- /dev/null +++ b/src/link.rs @@ -0,0 +1,67 @@ +use std::fs::File; +use std::path::PathBuf; + +use rustc::session::Session; + +pub(crate) fn link_rlib( + sess: &Session, + res: &crate::CodegenResult, + output_name: PathBuf, +) { + let file = File::create(&output_name).unwrap(); + let mut builder = ar::Builder::new(file); + + // Add main object file + let obj = res.artifact.emit().unwrap(); + builder + .append( + &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), + ::std::io::Cursor::new(obj), + ) + .unwrap(); + + // Non object files need to be added after object files, because ranlib will + // try to read the native architecture from the first file, even if it isn't + // an object file + builder + .append( + &ar::Header::new( + crate::metadata::METADATA_FILE.to_vec(), + res.metadata.len() as u64, + ), + ::std::io::Cursor::new(res.metadata.clone()), + ) + .unwrap(); + + // Finalize archive + std::mem::drop(builder); + + // Run ranlib to be able to link the archive + let status = std::process::Command::new("ranlib") + .arg(output_name) + .status() + .expect("Couldn't run ranlib"); + if !status.success() { + sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); + } +} + +pub(crate) fn link_bin(sess: &Session, res: &crate::CodegenResult, output_name: PathBuf) { + // TODO: link executable + let obj = res.artifact.emit().unwrap(); + std::fs::write(output_name, obj).unwrap(); +} + + +/* +res.artifact + .declare_with( + &metadata_name, + faerie::artifact::Decl::Data { + global: true, + writable: false, + }, + res.metadata.clone(), + ) + .unwrap(); +*/ From 85d0c1f4878fc6e4c6ddb71332ac0a0677eda686 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Nov 2018 14:07:12 +0100 Subject: [PATCH 0327/1566] [Travis] test on macOS too --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9ee74793c72db..5d07a2775f1d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ sudo: false language: rust cache: cargo +os: + - linux + - osx + rust: - nightly From 7d602513b1f7b909d4b22d5968e9e94bcb28b77d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 9 Nov 2018 17:54:28 +0100 Subject: [PATCH 0328/1566] Rustup to rustc 1.32.0-nightly (653da4fd0 2018-11-08) --- src/constant.rs | 33 ++++++++++++++------------------- src/lib.rs | 3 +-- src/link.rs | 7 +------ 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 4dcbf1da82c8b..0fc1b52b2f2d6 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::Const; use rustc_mir::interpret::{ - EvalContext, Machine, MemPlace, Memory, MemoryKind, OpTy, PlaceTy, Pointer, + EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, }; use cranelift_module::*; @@ -160,13 +160,12 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( def_id: DefId, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); - let is_mutable = - if let crate::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { - true - } else { - !tcx.type_of(def_id) - .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) - }; + let is_mutable = if let ::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { + true + } else { + !tcx.type_of(def_id) + .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + }; module .declare_data(&*symbol_name, Linkage::Export, is_mutable) .unwrap() @@ -314,7 +313,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { } fn find_foreign_static( - _: crate::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, + _: ::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, _: DefId, ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { panic!(); @@ -337,21 +336,17 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { fn tag_reference( _: &mut EvalContext<'a, 'mir, 'tcx, Self>, - _: MemPlace, - _: Ty<'tcx>, - _: Size, - _: Option, - ) -> EvalResult<'tcx, MemPlace> { + _: MPlaceTy<'tcx>, + _: Option<::rustc::hir::Mutability>, + ) -> EvalResult<'tcx, Scalar> { panic!() } fn tag_dereference( _: &EvalContext<'a, 'mir, 'tcx, Self>, - _: MemPlace, - _: Ty<'tcx>, - _: Size, - _: Option, - ) -> EvalResult<'tcx, MemPlace> { + _: MPlaceTy<'tcx>, + _: Option<::rustc::hir::Mutability>, + ) -> EvalResult<'tcx, Scalar> { panic!(); } diff --git a/src/lib.rs b/src/lib.rs index 912184dd8f38a..f7af549c8a499 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -258,8 +258,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); for &crate_type in sess.opts.crate_types.iter() { - let output_name = - out_filename(sess, crate_type, &outputs, &res.crate_name.as_str()); + let output_name = out_filename(sess, crate_type, &outputs, &res.crate_name.as_str()); match crate_type { CrateType::Rlib => link::link_rlib(sess, &res, output_name), CrateType::Executable => link::link_bin(sess, &res, output_name), diff --git a/src/link.rs b/src/link.rs index 822c908da42b3..82afe6fd677f5 100644 --- a/src/link.rs +++ b/src/link.rs @@ -3,11 +3,7 @@ use std::path::PathBuf; use rustc::session::Session; -pub(crate) fn link_rlib( - sess: &Session, - res: &crate::CodegenResult, - output_name: PathBuf, -) { +pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResult, output_name: PathBuf) { let file = File::create(&output_name).unwrap(); let mut builder = ar::Builder::new(file); @@ -52,7 +48,6 @@ pub(crate) fn link_bin(sess: &Session, res: &crate::CodegenResult, output_name: std::fs::write(output_name, obj).unwrap(); } - /* res.artifact .declare_with( From e1fc9a56d9ec243562e88740c3c86895ab3fd846 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 9 Nov 2018 18:03:47 +0100 Subject: [PATCH 0329/1566] Update dependencies --- Cargo.lock | 191 ++++++++++++++++++++++------------------------ Cargo.toml | 4 +- src/intrinsics.rs | 8 +- 3 files changed, 96 insertions(+), 107 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f967960e3503..25c776f04c003 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,101 +89,104 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +dependencies = [ + "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", +] [[package]] name = "cranelift-entity" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" [[package]] name = "cranelift-faerie" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.22.0" -source = "git+https://github.com/CraneStation/cranelift.git#8e7112166726d66640e26c3d4df7def406b0df10" +version = "0.23.0" +source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" dependencies = [ - "cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -195,7 +198,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -220,19 +223,19 @@ dependencies = [ [[package]] name = "faerie" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -249,8 +252,8 @@ name = "failure_derive" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -260,16 +263,6 @@ name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "goblin" -version = "0.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "goblin" version = "0.0.19" @@ -308,11 +301,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "libc" @@ -352,7 +342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -365,10 +355,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -396,19 +386,19 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -437,12 +427,12 @@ dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.22.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -472,8 +462,8 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -533,8 +523,8 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -543,8 +533,8 @@ name = "syn" version = "0.15.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -553,15 +543,15 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "target-lexicon" -version = "0.0.3" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -600,7 +590,7 @@ name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -686,43 +676,42 @@ dependencies = [ "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum cranelift 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.22.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c878c9fe0eb38d5fe1a09c5df7348253b7e6a67868fd8540be525dc04d63cb" +"checksum faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f869e12bcad2b4ff6ac60e01c2354957312fbf0c10dc938f340d58932b3db52" "checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" "checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum goblin 0.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5911d7df7b8f65ab676c5327b50acea29d3c6a1a4ad05e444cf5dce321b26db2" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" +"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee" +"checksum proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ab2fc21ba78ac73e4ff6b3818ece00be4e175ffbef4d0a717d978b48b24150c4" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "63b5829244f52738cfee93b3a165c1911388675be000c888d2fae620dee8fa5b" +"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41219962ecab392f1e68db9e7ebd972800d4045a128cc23462b384e8c312cde1" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341" -"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" +"checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" +"checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" "checksum region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cff177f64744f6f2a2054d231279383e59b0857b4d58dc2e8881e60b58aec8e5" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" @@ -739,7 +728,7 @@ dependencies = [ "checksum structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5352090cfae7a2c85e1a31146268b53396106c88ca5d6ccee2e3fae83b6e35c2" "checksum syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)" = "90c39a061e2f412a9f869540471ab679e85e50c6b05604daf28bc3060f75c430" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum target-lexicon 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a34226bd63b5a26fc909f5f0d7ef4dc55d5851077035e49437e4e14bf567247f" +"checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" diff --git a/Cargo.toml b/Cargo.toml index d46a9cfe7b815..83e1ac42bdfa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,9 @@ cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } -target-lexicon = "0.0.3" +target-lexicon = "0.2.0" #goblin = "0.0.17" -faerie = "0.5.1" +faerie = "0.6.0" ar = "0.6.0" bitflags = "1.0.3" byteorder = "1.2.6" diff --git a/src/intrinsics.rs b/src/intrinsics.rs index f2cdb9b48f813..3926a6b05adf6 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -137,9 +137,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let byte_amount = fx.bcx.ins().imul(count, elem_size); if intrinsic.ends_with("_nonoverlapping") { - fx.bcx.call_memcpy(&fx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memcpy(fx.module.target_config(), dst, src, byte_amount); } else { - fx.bcx.call_memmove(&fx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memmove(fx.module.target_config(), dst, src, byte_amount); } }; discriminant_value, (c val) { @@ -301,14 +301,14 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let addr = fx.bcx.ins().stack_addr(pointer_ty(fx.tcx), stack_slot, 0); let zero_val = fx.bcx.ins().iconst(types::I8, 0); let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); - fx.bcx.call_memset(&fx.module.target_config(), addr, zero_val, len_val); + fx.bcx.call_memset(fx.module.target_config(), addr, zero_val, len_val); let uninit_place = CPlace::from_stack_slot(fx, stack_slot, T); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); }; write_bytes, (v dst, v val, v count) { - fx.bcx.call_memset(&fx.module.target_config(), dst, val, count); + fx.bcx.call_memset(fx.module.target_config(), dst, val, count); }; uninit, () { let layout = fx.layout_of(T); From c2be4b83f147d75353ea49bf8017946a1f0bcaa8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Nov 2018 10:52:23 +0100 Subject: [PATCH 0330/1566] Rustup to rustc 1.32.0-nightly (36a50c29f 2018-11-09) --- 0002-Disable-u128-and-i128-in-libcore.patch | 86 +++++++++++++++------ 1 file changed, 63 insertions(+), 23 deletions(-) diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch index 0e192f790d6ab..8b837400468bf 100644 --- a/0002-Disable-u128-and-i128-in-libcore.patch +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From 7bc14b679a5e5a43940fd47a7f3be7f1cc27509b Mon Sep 17 00:00:00 2001 +From 13b3aab50eec5bd0ae22ebb76eba4d0ccb90ae14 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 6 Oct 2018 13:08:34 +0200 +Date: Sat, 10 Nov 2018 10:49:26 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -18,10 +18,11 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/num/wrapping.rs | 14 ++-- src/libcore/ops/arith.rs | 22 +++--- src/libcore/ops/bit.rs | 30 +++------ + src/libcore/sync/atomic.rs | 28 -------- src/libcore/tests/iter.rs | 15 ----- src/libcore/tests/num/mod.rs | 18 ----- src/libcore/time.rs | 126 ----------------------------------- - 17 files changed, 62 insertions(+), 311 deletions(-) + 18 files changed, 62 insertions(+), 339 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 46bb580..fcf9fa8 100644 @@ -39,10 +40,10 @@ index 46bb580..fcf9fa8 100644 bool char } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index edaed31..570217b 100644 +index 33881de..0e1e823 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs -@@ -886,7 +886,7 @@ mod impls { +@@ -883,7 +883,7 @@ mod impls { } partial_eq_impl! { @@ -51,7 +52,7 @@ index edaed31..570217b 100644 } macro_rules! eq_impl { -@@ -896,7 +896,7 @@ mod impls { +@@ -893,7 +893,7 @@ mod impls { )*) } @@ -60,7 +61,7 @@ index edaed31..570217b 100644 macro_rules! partial_ord_impl { ($($t:ty)*) => ($( -@@ -985,7 +985,7 @@ mod impls { +@@ -982,7 +982,7 @@ mod impls { } } @@ -70,7 +71,7 @@ index edaed31..570217b 100644 #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/src/libcore/default.rs b/src/libcore/default.rs -index ab36e29..1926719 100644 +index 638aceb..8b6ff80 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -145,14 +145,12 @@ default_impl! { u8, 0, "Returns the default value of `0`" } @@ -213,7 +214,7 @@ index f95f8e7..549d832 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 61181c2..5694583 100644 +index 3e7db7a..1217d4a 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -153,14 +153,12 @@ mod uint_macros; @@ -232,10 +233,10 @@ index 61181c2..5694583 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 266c691..39feadb 100644 +index 662a8dd..856878e 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs -@@ -672,8 +672,8 @@ mod copy_impls { +@@ -673,8 +673,8 @@ mod copy_impls { } impl_copy! { @@ -247,7 +248,7 @@ index 266c691..39feadb 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 27ee955..e45a2c9 100644 +index 1d0b194..cf15fda 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -162,12 +162,10 @@ pub fn forget(t: T) { @@ -264,7 +265,7 @@ index 27ee955..e45a2c9 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index c6473a2..c513f30 100644 +index c6cbeea..08ef46c 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -112,7 +112,6 @@ nonzero_integers! { @@ -294,7 +295,7 @@ index c6473a2..c513f30 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4339,17 +4326,6 @@ impl u64 { +@@ -4337,17 +4324,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -312,7 +313,7 @@ index c6473a2..c513f30 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4433,7 +4409,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4431,7 +4407,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -321,7 +322,7 @@ index c6473a2..c513f30 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4549,30 +4525,25 @@ macro_rules! rev { +@@ -4547,30 +4523,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -356,7 +357,7 @@ index c6473a2..c513f30 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4584,21 +4555,21 @@ mod ptr_try_from_impls { +@@ -4582,21 +4553,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -386,7 +387,7 @@ index c6473a2..c513f30 100644 } #[cfg(target_pointer_width = "32")] -@@ -4607,24 +4578,24 @@ mod ptr_try_from_impls { +@@ -4605,24 +4576,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -419,7 +420,7 @@ index c6473a2..c513f30 100644 } #[cfg(target_pointer_width = "64")] -@@ -4633,24 +4604,20 @@ mod ptr_try_from_impls { +@@ -4631,24 +4602,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -448,7 +449,7 @@ index c6473a2..c513f30 100644 } #[doc(hidden)] -@@ -4685,7 +4652,7 @@ macro_rules! doit { +@@ -4683,7 +4650,7 @@ macro_rules! doit { } })*) } @@ -457,7 +458,7 @@ index c6473a2..c513f30 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4853,52 +4820,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4851,52 +4818,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -833,6 +834,45 @@ index 3900f36..66b7980 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } +diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs +index 56d3b42..34df75f 100644 +--- a/src/libcore/sync/atomic.rs ++++ b/src/libcore/sync/atomic.rs +@@ -1938,34 +1938,6 @@ atomic_int! { + 8, + u64 AtomicU64 ATOMIC_U64_INIT + } +-#[cfg(all(not(stage0), target_has_atomic = "128"))] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "i128", "../../../std/primitive.i128.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_min, atomic_max, +- 16, +- i128 AtomicI128 ATOMIC_I128_INIT +-} +-#[cfg(all(not(stage0), target_has_atomic = "128"))] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "u128", "../../../std/primitive.u128.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_umin, atomic_umax, +- 16, +- u128 AtomicU128 ATOMIC_U128_INIT +-} + #[cfg(target_pointer_width = "16")] + macro_rules! ptr_width { + () => { 2 } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 2476c07..2075670 100644 --- a/src/libcore/tests/iter.rs @@ -936,7 +976,7 @@ index ab96d31..bb5c1d0 100644 test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index 81ae8ad..0e3dd39 100644 +index cfbd431..aee8065 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -30,7 +30,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; @@ -1087,5 +1127,5 @@ index 81ae8ad..0e3dd39 100644 /// /// # Examples -- -2.17.1 (Apple Git-112) +2.17.2 (Apple Git-113) From 9ceb1a170be3af2d394babc376e1a021eab6f252 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Nov 2018 12:49:25 +0100 Subject: [PATCH 0331/1566] Misc renames and changes --- src/lib.rs | 56 ++++++++++++++++++++++++------------------------- src/link.rs | 6 +++--- src/metadata.rs | 4 ++-- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f7af549c8a499..9811793b8677a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -68,7 +68,10 @@ mod prelude { pub use std::any::Any; pub use std::collections::{HashMap, HashSet}; - pub use rustc::hir::def_id::{DefId, LOCAL_CRATE}; + pub use syntax::ast::{FloatTy, IntTy, UintTy}; + pub use syntax::source_map::DUMMY_SP; + + pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; pub use rustc::mir::{self, interpret::AllocId, *}; pub use rustc::session::{config::CrateType, Session}; pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; @@ -82,8 +85,7 @@ mod prelude { sync::Lrc, }; pub use rustc_mir::monomorphize::{collector, MonoItem}; - pub use syntax::ast::{FloatTy, IntTy, UintTy}; - pub use syntax::source_map::DUMMY_SP; + pub use rustc_codegen_utils::CompiledModule; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, @@ -97,9 +99,12 @@ mod prelude { pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; pub use crate::common::*; - pub use crate::Caches; + pub use crate::{Caches, CodegenResults}; } +use std::fs::File; +use std::io::Write; + use crate::constant::ConstantCx; use crate::prelude::*; @@ -119,7 +124,7 @@ impl<'tcx> Caches<'tcx> { struct CraneliftCodegenBackend; -struct CodegenResult { +pub struct CodegenResults { artifact: faerie::Artifact, metadata: Vec, crate_name: Symbol, @@ -182,16 +187,17 @@ impl CodegenBackend for CraneliftCodegenBackend { save_incremental(tcx); tcx.sess.warn("Saved incremental data"); + let mut log = if cfg!(debug_assertions) { + Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")) + .unwrap()) + } else { + None + }; + if std::env::var("SHOULD_RUN").is_ok() { let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); - codegen_mono_items(tcx, &mut jit_module); - - tcx.sess.abort_if_errors(); - println!("Compiled everything"); - println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); - let sig = Signature { params: vec![ AbiParam::new(jit_module.target_config().pointer_type()), @@ -206,7 +212,12 @@ impl CodegenBackend for CraneliftCodegenBackend { .declare_function("main", Linkage::Import, &sig) .unwrap(); - jit_module.finalize_definitions(); + codegen_mono_items(tcx, &mut jit_module, &mut log); + + tcx.sess.abort_if_errors(); + println!("Compiled everything"); + println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); + let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); println!("🎉 Finalized everything"); @@ -232,13 +243,11 @@ impl CodegenBackend for CraneliftCodegenBackend { faerie_module.target_config().pointer_type() ); - codegen_mono_items(tcx, &mut faerie_module); + codegen_mono_items(tcx, &mut faerie_module, &mut log); tcx.sess.abort_if_errors(); - faerie_module.finalize_definitions(); - - return Box::new(CodegenResult { + return Box::new(CodegenResults { artifact: faerie_module.finish().artifact, metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), @@ -254,7 +263,7 @@ impl CodegenBackend for CraneliftCodegenBackend { outputs: &OutputFilenames, ) -> Result<(), CompileIncomplete> { let res = *res - .downcast::() + .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); for &crate_type in sess.opts.crate_types.iter() { @@ -272,21 +281,11 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_mono_items<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, + log: &mut Option, ) { - use std::io::Write; - let mut caches = Caches::new(); let mut ccx = ConstantCx::default(); - let mut log = if cfg!(debug_assertions) { - Some( - ::std::fs::File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")) - .unwrap(), - ) - } else { - None - }; - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); let mono_items = cgus .iter() @@ -332,6 +331,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( } ccx.finalize(tcx, module); + module.finalize_definitions(); let after = ::std::time::Instant::now(); println!("[codegen mono items] end time: {:?}", after - before); diff --git a/src/link.rs b/src/link.rs index 82afe6fd677f5..474584fa2a114 100644 --- a/src/link.rs +++ b/src/link.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use rustc::session::Session; -pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResult, output_name: PathBuf) { +pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResults, output_name: PathBuf) { let file = File::create(&output_name).unwrap(); let mut builder = ar::Builder::new(file); @@ -22,7 +22,7 @@ pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResult, output_name: builder .append( &ar::Header::new( - crate::metadata::METADATA_FILE.to_vec(), + crate::metadata::METADATA_FILENAME.to_vec(), res.metadata.len() as u64, ), ::std::io::Cursor::new(res.metadata.clone()), @@ -42,7 +42,7 @@ pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResult, output_name: } } -pub(crate) fn link_bin(sess: &Session, res: &crate::CodegenResult, output_name: PathBuf) { +pub(crate) fn link_bin(sess: &Session, res: &crate::CodegenResults, output_name: PathBuf) { // TODO: link executable let obj = res.artifact.emit().unwrap(); std::fs::write(output_name, obj).unwrap(); diff --git a/src/metadata.rs b/src/metadata.rs index bef1d7fccda2c..faeeeaa411d9b 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -3,7 +3,7 @@ use rustc_data_structures::owning_ref::{self, OwningRef}; use std::fs::File; use std::path::Path; -pub const METADATA_FILE: &'static [u8] = b"rust.metadata.bin" as &[u8]; +pub const METADATA_FILENAME: &'static [u8] = b"rust.metadata.bin" as &[u8]; pub struct CraneliftMetadataLoader; @@ -17,7 +17,7 @@ impl MetadataLoader for CraneliftMetadataLoader { // Iterate over all entries in the archive: while let Some(entry_result) = archive.next_entry() { let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; - if entry.header().identifier() == METADATA_FILE { + if entry.header().identifier() == METADATA_FILENAME { let mut buf = Vec::new(); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); From c88353c94290ce06c8cfddf11d83a515c9c82b24 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Nov 2018 15:01:01 +0100 Subject: [PATCH 0332/1566] Warn and error about some things and make METADATA_FILENAME an &str --- src/lib.rs | 14 +++++++++++++- src/link.rs | 2 +- src/metadata.rs | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9811793b8677a..aacb3dae1215e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,7 +73,7 @@ mod prelude { pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; pub use rustc::mir::{self, interpret::AllocId, *}; - pub use rustc::session::{config::CrateType, Session}; + pub use rustc::session::{config::{CrateType, Lto}, Session}; pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, @@ -143,6 +143,18 @@ impl CodegenBackend for CraneliftCodegenBackend { } } } + match sess.lto() { + Lto::Fat | Lto::Thin | Lto::ThinLocal => { + sess.warn("Rustc codegen cranelift doesn't support lto"); + } + Lto::No => {}, + } + if sess.opts.cg.rpath { + sess.err("rpath is not yet supported"); + } + if sess.opts.debugging_opts.pgo_gen.is_some() { + sess.err("pgo is not supported"); + } } fn metadata_loader(&self) -> Box { diff --git a/src/link.rs b/src/link.rs index 474584fa2a114..14202a4a6d454 100644 --- a/src/link.rs +++ b/src/link.rs @@ -22,7 +22,7 @@ pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResults, output_name builder .append( &ar::Header::new( - crate::metadata::METADATA_FILENAME.to_vec(), + crate::metadata::METADATA_FILENAME.as_bytes().to_vec(), res.metadata.len() as u64, ), ::std::io::Cursor::new(res.metadata.clone()), diff --git a/src/metadata.rs b/src/metadata.rs index faeeeaa411d9b..c70fdba35d848 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -3,7 +3,7 @@ use rustc_data_structures::owning_ref::{self, OwningRef}; use std::fs::File; use std::path::Path; -pub const METADATA_FILENAME: &'static [u8] = b"rust.metadata.bin" as &[u8]; +pub const METADATA_FILENAME: &str = "rust.metadata.bin"; pub struct CraneliftMetadataLoader; @@ -17,7 +17,7 @@ impl MetadataLoader for CraneliftMetadataLoader { // Iterate over all entries in the archive: while let Some(entry_result) = archive.next_entry() { let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; - if entry.header().identifier() == METADATA_FILENAME { + if entry.header().identifier() == METADATA_FILENAME.as_bytes() { let mut buf = Vec::new(); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); From b9c648daedda8ad529e85b3c0bd6426cd2c35905 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Nov 2018 15:12:00 +0100 Subject: [PATCH 0333/1566] Rustfmt --- src/lib.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index aacb3dae1215e..78e5eed0adb11 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,19 +30,25 @@ extern crate cranelift_simplejit; extern crate target_lexicon; use std::any::Any; +use std::fs::File; +use std::io::Write; use std::sync::mpsc; +use syntax::symbol::Symbol; + use rustc::dep_graph::DepGraph; use rustc::middle::cstore::MetadataLoader; use rustc::session::{config::OutputFilenames, CompileIncomplete}; use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::out_filename; -use syntax::symbol::Symbol; use cranelift::codegen::settings; use cranelift_faerie::*; +use crate::constant::ConstantCx; +use crate::prelude::*; + struct NonFatal(pub String); macro_rules! unimpl { @@ -73,19 +79,22 @@ mod prelude { pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; pub use rustc::mir::{self, interpret::AllocId, *}; - pub use rustc::session::{config::{CrateType, Lto}, Session}; + pub use rustc::session::{ + config::{CrateType, Lto}, + Session, + }; pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; + pub use rustc_codegen_utils::CompiledModule; pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, indexed_vec::Idx, sync::Lrc, }; pub use rustc_mir::monomorphize::{collector, MonoItem}; - pub use rustc_codegen_utils::CompiledModule; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, @@ -102,12 +111,6 @@ mod prelude { pub use crate::{Caches, CodegenResults}; } -use std::fs::File; -use std::io::Write; - -use crate::constant::ConstantCx; -use crate::prelude::*; - pub struct Caches<'tcx> { pub context: Context, pub vtables: HashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), DataId>, @@ -147,7 +150,7 @@ impl CodegenBackend for CraneliftCodegenBackend { Lto::Fat | Lto::Thin | Lto::ThinLocal => { sess.warn("Rustc codegen cranelift doesn't support lto"); } - Lto::No => {}, + Lto::No => {} } if sess.opts.cg.rpath { sess.err("rpath is not yet supported"); @@ -200,8 +203,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.warn("Saved incremental data"); let mut log = if cfg!(debug_assertions) { - Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")) - .unwrap()) + Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) } else { None }; From 104e9ffe89913a4c5f4fe937296626f329af1893 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Nov 2018 15:19:26 +0100 Subject: [PATCH 0334/1566] Update cranelift --- Cargo.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25c776f04c003..a5ca5e81b20a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -129,12 +129,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" [[package]] name = "cranelift-faerie" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -157,7 +157,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -168,7 +168,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -178,7 +178,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#05144fe5b3ecae5fb59e1c207c89ad1111a2cc10" +source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -487,7 +487,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -556,7 +556,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -721,7 +721,7 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" -"checksum serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "43344e7ce05d0d8280c5940cabb4964bea626aa58b1ec0e8c73fa2a8512a38ce" +"checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "41c4a2479a078509940d82773d90ff824a8c89533ab3b59cd3ce8b0c0e369c02" From 640d66c77776cdcac9e959cea9052c2dd51cde98 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 9 Nov 2018 18:38:30 +0100 Subject: [PATCH 0335/1566] Call linker from cg_clif --- Cargo.lock | 79 ++++ Cargo.toml | 3 + build.sh | 16 +- src/archive.rs | 99 +++++ src/lib.rs | 175 +++++++- src/link.rs | 1141 +++++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 1489 insertions(+), 24 deletions(-) create mode 100644 src/archive.rs diff --git a/Cargo.lock b/Cargo.lock index a5ca5e81b20a2..bb14d457f37cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,6 +87,14 @@ dependencies = [ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cranelift" version = "0.23.0" @@ -258,6 +266,20 @@ dependencies = [ "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "gcc" version = "0.3.55" @@ -361,6 +383,31 @@ dependencies = [ "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "raw-cpuid" version = "6.0.0" @@ -415,6 +462,14 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "remove_dir_all" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rustc-demangle" version = "0.1.9" @@ -427,12 +482,15 @@ dependencies = [ "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -559,6 +617,19 @@ dependencies = [ "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tempfile" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "termcolor" version = "1.0.4" @@ -676,6 +747,7 @@ dependencies = [ "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cranelift 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -692,6 +764,8 @@ dependencies = [ "checksum faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f869e12bcad2b4ff6ac60e01c2354957312fbf0c10dc938f340d58932b3db52" "checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" "checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" @@ -707,12 +781,16 @@ dependencies = [ "checksum proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ab2fc21ba78ac73e4ff6b3818ece00be4e175ffbef4d0a717d978b48b24150c4" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" +"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" +"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" +"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" "checksum raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41219962ecab392f1e68db9e7ebd972800d4045a128cc23462b384e8c312cde1" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" "checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" "checksum region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cff177f64744f6f2a2054d231279383e59b0857b4d58dc2e8881e60b58aec8e5" +"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" @@ -729,6 +807,7 @@ dependencies = [ "checksum syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)" = "90c39a061e2f412a9f869540471ab679e85e50c6b05604daf28bc3060f75c430" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" +"checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" diff --git a/Cargo.toml b/Cargo.toml index 83e1ac42bdfa1..cc71244fc4d2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,9 @@ faerie = "0.6.0" ar = "0.6.0" bitflags = "1.0.3" byteorder = "1.2.6" +cc = "1.0.25" +libc = "0.2.43" +tempfile = "3.0.4" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] diff --git a/build.sh b/build.sh index acb9bbc92d70f..2b1b065393237 100755 --- a/build.sh +++ b/build.sh @@ -14,11 +14,7 @@ fi build_example_bin() { $RUSTC $2 --crate-name $1 --crate-type bin - - pushd target/out - gcc $1 libmini_core.rlib -o $1_bin - sh -c ./$1_bin || true - popd + sh -c ./target/out/$1 || true } if [[ "$1" == "--release" ]]; then @@ -54,16 +50,12 @@ rm -r target || true time xargo build popd -$RUSTC --sysroot ~/.xargo/HOST example/alloc_example.rs --crate-type bin # TODO linux linker doesn't accept duplicate definitions -#gcc -Wl,--gc-sections target/out/alloc_example ~/.xargo/HOST/lib/rustlib/*/lib/libcore-*.rlib ~/.xargo/HOST/lib/rustlib/*/lib/liballoc-*.rlib ~/.xargo/HOST/lib/rustlib/*/lib/liballoc_system-*.rlib -o target/out/alloc_example_exe -#hyperfine ./target/out/alloc_example_exe +$RUSTC --sysroot ~/.xargo/HOST example/alloc_example.rs --crate-type bin +./target/out/alloc_example $RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -gcc -Wl,--gc-sections target/out/mod_bench -lc -o target/out/mod_bench_exe - $RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 --crate-name mod_bench_inline -gcc -Wl,--gc-sections target/out/mod_bench_inline -lc -o target/out/mod_bench_inline_exe rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort @@ -71,6 +63,6 @@ rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_benc rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort echo echo "[Bench] mod_bench" -hyperfine ./target/out/mod_bench{,_inline}_exe ./target/out/mod_bench_llvm_* +hyperfine ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* cat target/out/log.txt | sort | uniq -c diff --git a/src/archive.rs b/src/archive.rs new file mode 100644 index 0000000000000..1e57ff0f2c41c --- /dev/null +++ b/src/archive.rs @@ -0,0 +1,99 @@ +use std::collections::HashMap; +use std::fs::File; +use std::path::PathBuf; + +use crate::prelude::*; + +pub struct ArchiveConfig<'a> { + pub sess: &'a Session, + pub dst: PathBuf, + pub src: Option, + pub lib_search_paths: Vec, +} + +pub struct ArchiveBuilder<'a> { + cfg: ArchiveConfig<'a>, + src_archive: Option>, + src_entries: HashMap, + builder: ar::Builder, + update_symbols: bool, +} + +impl<'a> ArchiveBuilder<'a> { + pub fn new(cfg: ArchiveConfig<'a>) -> Self { + let (src_archive, src_entries) = if let Some(src) = &cfg.src { + let mut archive = ar::Archive::new(File::open(src).unwrap()); + let mut entries = HashMap::new(); + + let mut i = 0; + while let Some(entry) = archive.next_entry() { + let entry = entry.unwrap(); + entries.insert( + String::from_utf8(entry.header().identifier().to_vec()).unwrap(), + i, + ); + i += 1; + } + + (Some(archive), entries) + } else { + (None, HashMap::new()) + }; + + let builder = ar::Builder::new(File::create(&cfg.dst).unwrap()); + + ArchiveBuilder { + cfg, + src_archive, + src_entries, + builder, + update_symbols: false, + } + } + + pub fn src_files(&self) -> Vec { + self.src_entries.keys().cloned().collect() + } + + pub fn remove_file(&mut self, name: &str) { + assert!( + self.src_entries.remove(name).is_some(), + "Tried to remove file not existing in src archive", + ); + } + + pub fn update_symbols(&mut self) { + self.update_symbols = true; + } + + pub fn build(mut self) { + // Add files from original archive + if let Some(mut src_archive) = self.src_archive { + for (_entry_name, entry_idx) in self.src_entries.into_iter() { + let entry = src_archive.jump_to_entry(entry_idx).unwrap(); + let orig_header = entry.header(); + let mut header = + ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); + header.set_mtime(orig_header.mtime()); + header.set_uid(orig_header.uid()); + header.set_gid(orig_header.gid()); + header.set_mode(orig_header.mode()); + self.builder.append(&header, entry).unwrap(); + } + } + + // Finalize archive + std::mem::drop(self.builder); + + // Run ranlib to be able to link the archive + let status = std::process::Command::new("ranlib") + .arg(self.cfg.dst) + .status() + .expect("Couldn't run ranlib"); + assert!( + status.success(), + "Ranlib exited with code {:?}", + status.code() + ); + } +} diff --git a/src/lib.rs b/src/lib.rs index 78e5eed0adb11..fb0d6067bff8f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,9 @@ extern crate rustc_mir; extern crate rustc_target; #[macro_use] extern crate rustc_data_structures; +extern crate rustc_fs_util; +#[macro_use] +extern crate log; extern crate ar; #[macro_use] @@ -37,11 +40,19 @@ use std::sync::mpsc; use syntax::symbol::Symbol; use rustc::dep_graph::DepGraph; -use rustc::middle::cstore::MetadataLoader; -use rustc::session::{config::OutputFilenames, CompileIncomplete}; +use rustc::middle::cstore::{ + self, CrateSource, LibSource, LinkagePreference, MetadataLoader, NativeLibrary, +}; +use rustc::middle::lang_items::LangItem; +use rustc::middle::weak_lang_items; +use rustc::session::{ + config::{self, OutputFilenames, OutputType}, + CompileIncomplete, +}; use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::out_filename; +use rustc_codegen_utils::linker::LinkerInfo; use cranelift::codegen::settings; use cranelift_faerie::*; @@ -60,6 +71,7 @@ macro_rules! unimpl { mod abi; mod allocator; mod analyze; +mod archive; mod base; mod common; mod constant; @@ -88,7 +100,7 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; - pub use rustc_codegen_utils::CompiledModule; + pub use rustc_codegen_utils::{CompiledModule, ModuleKind}; pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, indexed_vec::Idx, @@ -108,7 +120,7 @@ mod prelude { pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; pub use crate::common::*; - pub use crate::{Caches, CodegenResults}; + pub use crate::{Caches, CodegenResults, CrateInfo}; } pub struct Caches<'tcx> { @@ -127,10 +139,132 @@ impl<'tcx> Caches<'tcx> { struct CraneliftCodegenBackend; +pub struct CrateInfo { + panic_runtime: Option, + compiler_builtins: Option, + profiler_runtime: Option, + sanitizer_runtime: Option, + is_no_builtins: FxHashSet, + native_libraries: FxHashMap>>, + crate_name: FxHashMap, + used_libraries: Lrc>, + link_args: Lrc>, + used_crate_source: FxHashMap>, + used_crates_static: Vec<(CrateNum, LibSource)>, + used_crates_dynamic: Vec<(CrateNum, LibSource)>, + wasm_imports: FxHashMap, + lang_item_to_crate: FxHashMap, + missing_lang_items: FxHashMap>, +} + +impl CrateInfo { + pub fn new(tcx: TyCtxt) -> CrateInfo { + let mut info = CrateInfo { + panic_runtime: None, + compiler_builtins: None, + profiler_runtime: None, + sanitizer_runtime: None, + is_no_builtins: Default::default(), + native_libraries: Default::default(), + used_libraries: tcx.native_libraries(LOCAL_CRATE), + link_args: tcx.link_args(LOCAL_CRATE), + crate_name: Default::default(), + used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic), + used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), + used_crate_source: Default::default(), + wasm_imports: Default::default(), + lang_item_to_crate: Default::default(), + missing_lang_items: Default::default(), + }; + let lang_items = tcx.lang_items(); + + let load_wasm_items = tcx + .sess + .crate_types + .borrow() + .iter() + .any(|c| *c != config::CrateType::Rlib) + && tcx.sess.opts.target_triple.triple() == "wasm32-unknown-unknown"; + + if load_wasm_items { + info.load_wasm_imports(tcx, LOCAL_CRATE); + } + + let crates = tcx.crates(); + + let n_crates = crates.len(); + info.native_libraries.reserve(n_crates); + info.crate_name.reserve(n_crates); + info.used_crate_source.reserve(n_crates); + info.missing_lang_items.reserve(n_crates); + + for &cnum in crates.iter() { + info.native_libraries + .insert(cnum, tcx.native_libraries(cnum)); + info.crate_name + .insert(cnum, tcx.crate_name(cnum).to_string()); + info.used_crate_source + .insert(cnum, tcx.used_crate_source(cnum)); + if tcx.is_panic_runtime(cnum) { + info.panic_runtime = Some(cnum); + } + if tcx.is_compiler_builtins(cnum) { + info.compiler_builtins = Some(cnum); + } + if tcx.is_profiler_runtime(cnum) { + info.profiler_runtime = Some(cnum); + } + if tcx.is_sanitizer_runtime(cnum) { + info.sanitizer_runtime = Some(cnum); + } + if tcx.is_no_builtins(cnum) { + info.is_no_builtins.insert(cnum); + } + if load_wasm_items { + info.load_wasm_imports(tcx, cnum); + } + let missing = tcx.missing_lang_items(cnum); + for &item in missing.iter() { + if let Ok(id) = lang_items.require(item) { + info.lang_item_to_crate.insert(item, id.krate); + } + } + + // No need to look for lang items that are whitelisted and don't + // actually need to exist. + let missing = missing + .iter() + .cloned() + .filter(|&l| !weak_lang_items::whitelisted(tcx, l)) + .collect(); + info.missing_lang_items.insert(cnum, missing); + } + + return info; + } + + fn load_wasm_imports(&mut self, tcx: TyCtxt, cnum: CrateNum) { + self.wasm_imports.extend( + tcx.wasm_import_module_map(cnum) + .iter() + .map(|(&id, module)| { + let instance = Instance::mono(tcx, id); + let import_name = tcx.symbol_name(instance); + + (import_name.to_string(), module.clone()) + }), + ); + } +} + pub struct CodegenResults { artifact: faerie::Artifact, + modules: Vec, + allocator_module: Option, metadata: Vec, crate_name: Symbol, + crate_info: CrateInfo, + linker_info: LinkerInfo, } impl CodegenBackend for CraneliftCodegenBackend { @@ -261,10 +395,39 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.abort_if_errors(); + let artifact = faerie_module.finish().artifact; + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, None); + let obj = artifact.emit().unwrap(); + std::fs::write(&tmp_file, obj).unwrap(); + + /*use rustc_mir::monomorphize::partitioning::CodegenUnitExt; + + let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx); + let ((stats, module), _) = tcx.dep_graph.with_task( + dep_node, + tcx, + cgu_name, + module_codegen, + );*/ + return Box::new(CodegenResults { - artifact: faerie_module.finish().artifact, + artifact, metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), + crate_info: CrateInfo::new(tcx), + linker_info: LinkerInfo::new(tcx), + modules: vec![CompiledModule { + name: "dummy".to_string(), + kind: ModuleKind::Regular, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + }], + //modules: vec![], + allocator_module: None, }); } } @@ -284,7 +447,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let output_name = out_filename(sess, crate_type, &outputs, &res.crate_name.as_str()); match crate_type { CrateType::Rlib => link::link_rlib(sess, &res, output_name), - CrateType::Executable => link::link_bin(sess, &res, output_name), + CrateType::Executable => link::link_bin(sess, &res, &output_name), _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), } } diff --git a/src/link.rs b/src/link.rs index 14202a4a6d454..f51b978725746 100644 --- a/src/link.rs +++ b/src/link.rs @@ -1,9 +1,36 @@ -use std::fs::File; -use std::path::PathBuf; +use std::env; +use std::fmt; +use std::fs::{self, File}; +use std::io; +use std::iter; +use std::path::{Path, PathBuf}; +use std::process::{Output, Stdio}; +use cc::windows_registry; +use tempfile::Builder as TempFileBuilder; + +use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; +use rustc::middle::dependency_format::Linkage; +use rustc::session::config::{self, CrateType, DebugInfo, OutputType, RUST_CGU_EXT}; +use rustc::session::search_paths::PathKind; use rustc::session::Session; +use rustc::util::common::time; +use rustc_codegen_utils::command::Command; +use rustc_codegen_utils::linker::*; +use rustc_data_structures::fx::FxHashSet; +use rustc_fs_util::fix_windows_verbatim_for_gcc; +use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel}; +use syntax::attr; + +use crate::prelude::*; + +use crate::archive::{ArchiveBuilder, ArchiveConfig}; +use crate::metadata::METADATA_FILENAME; -pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResults, output_name: PathBuf) { +// cg_clif doesn't have bytecode, so this is just a dummy +const RLIB_BYTECODE_EXTENSION: &str = ".cg_clif_bytecode_dummy"; + +pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathBuf) { let file = File::create(&output_name).unwrap(); let mut builder = ar::Builder::new(file); @@ -42,10 +69,201 @@ pub(crate) fn link_rlib(sess: &Session, res: &crate::CodegenResults, output_name } } -pub(crate) fn link_bin(sess: &Session, res: &crate::CodegenResults, output_name: PathBuf) { +pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_filename: &Path) { + let tmpdir = match TempFileBuilder::new().prefix("rustc").tempdir() { + Ok(tmpdir) => tmpdir, + Err(err) => sess.fatal(&format!("couldn't create a temp dir: {}", err)), + }; + // TODO: link executable - let obj = res.artifact.emit().unwrap(); - std::fs::write(output_name, obj).unwrap(); + let obj = codegen_results.artifact.emit().unwrap(); + std::fs::write(tmpdir.path().join("out".to_string() + RUST_CGU_EXT), obj).unwrap(); + + let (linker, flavor) = linker_and_flavor(sess); + let (pname, mut cmd) = get_linker(sess, &linker, flavor); + + let root = sess.target_filesearch(PathKind::Native).get_lib_path(); + if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) { + cmd.args(args); + } + if let Some(args) = sess.target.target.options.pre_link_args_crt.get(&flavor) { + if sess.crt_static() { + cmd.args(args); + } + } + if let Some(ref args) = sess.opts.debugging_opts.pre_link_args { + cmd.args(args); + } + cmd.args(&sess.opts.debugging_opts.pre_link_arg); + + for obj in &sess.target.target.options.pre_link_objects_exe { + cmd.arg(root.join(obj)); + } + + if sess.crt_static() { + for obj in &sess.target.target.options.pre_link_objects_exe_crt { + cmd.arg(root.join(obj)); + } + } + + if sess.target.target.options.is_like_emscripten { + cmd.arg("-s"); + cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort { + "DISABLE_EXCEPTION_CATCHING=1" + } else { + "DISABLE_EXCEPTION_CATCHING=0" + }); + } + + { + let target_cpu = "x86_64-apple-darwin"; //::llvm_util::target_cpu(sess); + let mut linker = codegen_results.linker_info.to_linker(cmd, &sess, flavor, target_cpu); + link_args(&mut *linker, flavor, sess, CrateType::Executable, tmpdir.path(), + out_filename, codegen_results); + cmd = linker.finalize(); + } + if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) { + cmd.args(args); + } + for obj in &sess.target.target.options.post_link_objects { + cmd.arg(root.join(obj)); + } + if sess.crt_static() { + for obj in &sess.target.target.options.post_link_objects_crt { + cmd.arg(root.join(obj)); + } + } + if let Some(args) = sess.target.target.options.post_link_args.get(&flavor) { + cmd.args(args); + } + for &(ref k, ref v) in &sess.target.target.options.link_env { + cmd.env(k, v); + } + + if sess.opts.debugging_opts.print_link_args { + println!("{:?}", &cmd); + } + + // May have not found libraries in the right formats. + sess.abort_if_errors(); + + // Invoke the system linker + // + // Note that there's a terribly awful hack that really shouldn't be present + // in any compiler. Here an environment variable is supported to + // automatically retry the linker invocation if the linker looks like it + // segfaulted. + // + // Gee that seems odd, normally segfaults are things we want to know about! + // Unfortunately though in rust-lang/rust#38878 we're experiencing the + // linker segfaulting on Travis quite a bit which is causing quite a bit of + // pain to land PRs when they spuriously fail due to a segfault. + // + // The issue #38878 has some more debugging information on it as well, but + // this unfortunately looks like it's just a race condition in macOS's linker + // with some thread pool working in the background. It seems that no one + // currently knows a fix for this so in the meantime we're left with this... + let retry_on_segfault = env::var("RUSTC_RETRY_LINKER_ON_SEGFAULT").is_ok(); + let mut prog; + let mut i = 0; + loop { + i += 1; + prog = exec_linker(sess, &mut cmd, out_filename, tmpdir.path()); + let output = match prog { + Ok(ref output) => output, + Err(_) => break, + }; + if output.status.success() { + break + } + let mut out = output.stderr.clone(); + out.extend(&output.stdout); + let out = String::from_utf8_lossy(&out); + + // Check to see if the link failed with "unrecognized command line option: + // '-no-pie'" for gcc or "unknown argument: '-no-pie'" for clang. If so, + // reperform the link step without the -no-pie option. This is safe because + // if the linker doesn't support -no-pie then it should not default to + // linking executables as pie. Different versions of gcc seem to use + // different quotes in the error message so don't check for them. + if sess.target.target.options.linker_is_gnu && + flavor != LinkerFlavor::Ld && + (out.contains("unrecognized command line option") || + out.contains("unknown argument")) && + out.contains("-no-pie") && + cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") { + for arg in cmd.take_args() { + if arg.to_string_lossy() != "-no-pie" { + cmd.arg(arg); + } + } + continue; + } + if !retry_on_segfault || i > 3 { + break + } + let msg_segv = "clang: error: unable to execute command: Segmentation fault: 11"; + let msg_bus = "clang: error: unable to execute command: Bus error: 10"; + if !(out.contains(msg_segv) || out.contains(msg_bus)) { + break + } + } + + match prog { + Ok(prog) => { + if !prog.status.success() { + let mut output = prog.stderr.clone(); + output.extend_from_slice(&prog.stdout); + sess.struct_err(&format!("linking with `{}` failed: {}", + pname.display(), + prog.status)) + .note(&format!("{:?}", &cmd)) + .note(&String::from_utf8_lossy(&output)) + .emit(); + sess.abort_if_errors(); + } + }, + Err(e) => { + let linker_not_found = e.kind() == io::ErrorKind::NotFound; + + let mut linker_error = { + if linker_not_found { + sess.struct_err(&format!("linker `{}` not found", pname.display())) + } else { + sess.struct_err(&format!("could not exec the linker `{}`", pname.display())) + } + }; + + linker_error.note(&e.to_string()); + + if !linker_not_found { + linker_error.note(&format!("{:?}", &cmd)); + } + + linker_error.emit(); + + if sess.target.target.options.is_like_msvc && linker_not_found { + sess.note_without_error("the msvc targets depend on the msvc linker \ + but `link.exe` was not found"); + sess.note_without_error("please ensure that VS 2013, VS 2015 or VS 2017 \ + was installed with the Visual C++ option"); + } + sess.abort_if_errors(); + } + } + + + // On macOS, debuggers need this utility to get run to do some munging of + // the symbols. Note, though, that if the object files are being preserved + // for their debug information there's no need for us to run dsymutil. + if sess.target.target.options.is_like_osx && + sess.opts.debuginfo != DebugInfo::None + { + match Command::new("dsymutil").arg(out_filename).output() { + Ok(..) => {} + Err(e) => sess.fatal(&format!("failed to run dsymutil: {}", e)), + } + } } /* @@ -60,3 +278,914 @@ res.artifact ) .unwrap(); */ + + +fn link_args(cmd: &mut dyn Linker, + flavor: LinkerFlavor, + sess: &Session, + crate_type: config::CrateType, + tmpdir: &Path, + out_filename: &Path, + codegen_results: &CodegenResults) { + + // Linker plugins should be specified early in the list of arguments + cmd.cross_lang_lto(); + + // The default library location, we need this to find the runtime. + // The location of crates will be determined as needed. + let lib_path = sess.target_filesearch(PathKind::All).get_lib_path(); + + // target descriptor + let t = &sess.target.target; + + cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path)); + for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) { + cmd.add_object(obj); + } + cmd.output_filename(out_filename); + + // If we're building a dynamic library then some platforms need to make sure + // that all symbols are exported correctly from the dynamic library. + if crate_type != config::CrateType::Executable || + sess.target.target.options.is_like_emscripten { + cmd.export_symbols(tmpdir, crate_type); + } + + let obj = codegen_results.allocator_module + .as_ref() + .and_then(|m| m.object.as_ref()); + if let Some(obj) = obj { + cmd.add_object(obj); + } + + // Try to strip as much out of the generated object by removing unused + // sections if possible. See more comments in linker.rs + if !sess.opts.cg.link_dead_code { + let keep_metadata = crate_type == config::CrateType::Dylib; + cmd.gc_sections(keep_metadata); + } + + let used_link_args = &codegen_results.crate_info.link_args; + + if crate_type == config::CrateType::Executable { + let mut position_independent_executable = false; + + if t.options.position_independent_executables { + let empty_vec = Vec::new(); + let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec); + let more_args = &sess.opts.cg.link_arg; + let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter()); + + if !sess.crt_static() && !args.any(|x| *x == "-static") { + position_independent_executable = true; + } + } + + if position_independent_executable { + cmd.position_independent_executable(); + } else { + // recent versions of gcc can be configured to generate position + // independent executables by default. We have to pass -no-pie to + // explicitly turn that off. Not applicable to ld. + if sess.target.target.options.linker_is_gnu + && flavor != LinkerFlavor::Ld { + cmd.no_position_independent_executable(); + } + } + } + + let relro_level = match sess.opts.debugging_opts.relro_level { + Some(level) => level, + None => t.options.relro_level, + }; + match relro_level { + RelroLevel::Full => { + cmd.full_relro(); + }, + RelroLevel::Partial => { + cmd.partial_relro(); + }, + RelroLevel::Off => { + cmd.no_relro(); + }, + RelroLevel::None => { + }, + } + + // Pass optimization flags down to the linker. + cmd.optimize(); + + // Pass debuginfo flags down to the linker. + cmd.debuginfo(); + + // We want to, by default, prevent the compiler from accidentally leaking in + // any system libraries, so we may explicitly ask linkers to not link to any + // libraries by default. Note that this does not happen for windows because + // windows pulls in some large number of libraries and I couldn't quite + // figure out which subset we wanted. + // + // This is all naturally configurable via the standard methods as well. + if !sess.opts.cg.default_linker_libraries.unwrap_or(false) && + t.options.no_default_libraries + { + cmd.no_default_libraries(); + } + + // Take careful note of the ordering of the arguments we pass to the linker + // here. Linkers will assume that things on the left depend on things to the + // right. Things on the right cannot depend on things on the left. This is + // all formally implemented in terms of resolving symbols (libs on the right + // resolve unknown symbols of libs on the left, but not vice versa). + // + // For this reason, we have organized the arguments we pass to the linker as + // such: + // + // 1. The local object that LLVM just generated + // 2. Local native libraries + // 3. Upstream rust libraries + // 4. Upstream native libraries + // + // The rationale behind this ordering is that those items lower down in the + // list can't depend on items higher up in the list. For example nothing can + // depend on what we just generated (e.g. that'd be a circular dependency). + // Upstream rust libraries are not allowed to depend on our local native + // libraries as that would violate the structure of the DAG, in that + // scenario they are required to link to them as well in a shared fashion. + // + // Note that upstream rust libraries may contain native dependencies as + // well, but they also can't depend on what we just started to add to the + // link line. And finally upstream native libraries can't depend on anything + // in this DAG so far because they're only dylibs and dylibs can only depend + // on other dylibs (e.g. other native deps). + add_local_native_libraries(cmd, sess, codegen_results); + add_upstream_rust_crates(cmd, sess, codegen_results, crate_type, tmpdir); + add_upstream_native_libraries(cmd, sess, codegen_results, crate_type); + + // Tell the linker what we're doing. + if crate_type != config::CrateType::Executable { + cmd.build_dylib(out_filename); + } + if crate_type == config::CrateType::Executable && sess.crt_static() { + cmd.build_static_executable(); + } + + if sess.opts.debugging_opts.pgo_gen.is_some() { + cmd.pgo_gen(); + } + + // Finally add all the linker arguments provided on the command line along + // with any #[link_args] attributes found inside the crate + if let Some(ref args) = sess.opts.cg.link_args { + cmd.args(args); + } + cmd.args(&sess.opts.cg.link_arg); + cmd.args(&used_link_args); +} + +// =========================== +// Copied from https://github.com/rust-lang/rust/blob/942864a000efd74b73e36bda5606b2cdb55ecf39/src/librustc_codegen_llvm/back/link.rs +// =========================== + +fn archive_search_paths(sess: &Session) -> Vec { + let mut search = Vec::new(); + sess.target_filesearch(PathKind::Native).for_each_lib_search_path(|path, _| { + search.push(path.to_path_buf()); + }); + return search; +} + +fn archive_config<'a>(sess: &'a Session, + output: &Path, + input: Option<&Path>) -> ArchiveConfig<'a> { + ArchiveConfig { + sess, + dst: output.to_path_buf(), + src: input.map(|p| p.to_path_buf()), + lib_search_paths: archive_search_paths(sess), + } +} + +// The third parameter is for env vars, used on windows to set up the +// path for MSVC to find its DLLs, and gcc to find its bundled +// toolchain +fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathBuf, Command) { + let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe"); + + // If our linker looks like a batch script on Windows then to execute this + // we'll need to spawn `cmd` explicitly. This is primarily done to handle + // emscripten where the linker is `emcc.bat` and needs to be spawned as + // `cmd /c emcc.bat ...`. + // + // This worked historically but is needed manually since #42436 (regression + // was tagged as #42791) and some more info can be found on #44443 for + // emscripten itself. + let mut cmd = match linker.to_str() { + Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker), + _ => match flavor { + LinkerFlavor::Lld(f) => Command::lld(linker, f), + LinkerFlavor::Msvc + if sess.opts.cg.linker.is_none() && sess.target.target.options.linker.is_none() => + { + Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker)) + }, + _ => Command::new(linker), + } + }; + + // The compiler's sysroot often has some bundled tools, so add it to the + // PATH for the child. + let mut new_path = sess.host_filesearch(PathKind::All) + .get_tools_search_paths(); + let mut msvc_changed_path = false; + if sess.target.target.options.is_like_msvc { + if let Some(ref tool) = msvc_tool { + cmd.args(tool.args()); + for &(ref k, ref v) in tool.env() { + if k == "PATH" { + new_path.extend(env::split_paths(v)); + msvc_changed_path = true; + } else { + cmd.env(k, v); + } + } + } + } + + if !msvc_changed_path { + if let Some(path) = env::var_os("PATH") { + new_path.extend(env::split_paths(&path)); + } + } + cmd.env("PATH", env::join_paths(new_path).unwrap()); + + (linker.to_path_buf(), cmd) +} + +fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { + fn infer_from( + sess: &Session, + linker: Option, + flavor: Option, + ) -> Option<(PathBuf, LinkerFlavor)> { + match (linker, flavor) { + (Some(linker), Some(flavor)) => Some((linker, flavor)), + // only the linker flavor is known; use the default linker for the selected flavor + (None, Some(flavor)) => Some((PathBuf::from(match flavor { + LinkerFlavor::Em => if cfg!(windows) { "emcc.bat" } else { "emcc" }, + LinkerFlavor::Gcc => "cc", + LinkerFlavor::Ld => "ld", + LinkerFlavor::Msvc => "link.exe", + LinkerFlavor::Lld(_) => "lld", + }), flavor)), + (Some(linker), None) => { + let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { + sess.fatal("couldn't extract file stem from specified linker"); + }).to_owned(); + + let flavor = if stem == "emcc" { + LinkerFlavor::Em + } else if stem == "gcc" || stem.ends_with("-gcc") { + LinkerFlavor::Gcc + } else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") { + LinkerFlavor::Ld + } else if stem == "link" || stem == "lld-link" { + LinkerFlavor::Msvc + } else if stem == "lld" || stem == "rust-lld" { + LinkerFlavor::Lld(sess.target.target.options.lld_flavor) + } else { + // fall back to the value in the target spec + sess.target.target.linker_flavor + }; + + Some((linker, flavor)) + }, + (None, None) => None, + } + } + + // linker and linker flavor specified via command line have precedence over what the target + // specification specifies + if let Some(ret) = infer_from( + sess, + sess.opts.cg.linker.clone(), + sess.opts.debugging_opts.linker_flavor, + ) { + return ret; + } + + if let Some(ret) = infer_from( + sess, + sess.target.target.options.linker.clone().map(PathBuf::from), + Some(sess.target.target.linker_flavor), + ) { + return ret; + } + + bug!("Not enough information provided to determine how to invoke the linker"); +} + +fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &Path) + -> io::Result +{ + // When attempting to spawn the linker we run a risk of blowing out the + // size limits for spawning a new process with respect to the arguments + // we pass on the command line. + // + // Here we attempt to handle errors from the OS saying "your list of + // arguments is too big" by reinvoking the linker again with an `@`-file + // that contains all the arguments. The theory is that this is then + // accepted on all linkers and the linker will read all its options out of + // there instead of looking at the command line. + if !cmd.very_likely_to_exceed_some_spawn_limit() { + match cmd.command().stdout(Stdio::piped()).stderr(Stdio::piped()).spawn() { + Ok(child) => { + let output = child.wait_with_output(); + flush_linked_file(&output, out_filename)?; + return output; + } + Err(ref e) if command_line_too_big(e) => { + info!("command line to linker was too big: {}", e); + } + Err(e) => return Err(e) + } + } + + info!("falling back to passing arguments to linker via an @-file"); + let mut cmd2 = cmd.clone(); + let mut args = String::new(); + for arg in cmd2.take_args() { + args.push_str(&Escape { + arg: arg.to_str().unwrap(), + is_like_msvc: sess.target.target.options.is_like_msvc, + }.to_string()); + args.push_str("\n"); + } + let file = tmpdir.join("linker-arguments"); + let bytes = if sess.target.target.options.is_like_msvc { + let mut out = Vec::with_capacity((1 + args.len()) * 2); + // start the stream with a UTF-16 BOM + for c in iter::once(0xFEFF).chain(args.encode_utf16()) { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + args.into_bytes() + }; + fs::write(&file, &bytes)?; + cmd2.arg(format!("@{}", file.display())); + info!("invoking linker {:?}", cmd2); + let output = cmd2.output(); + flush_linked_file(&output, out_filename)?; + return output; + + #[cfg(unix)] + fn flush_linked_file(_: &io::Result, _: &Path) -> io::Result<()> { + Ok(()) + } + + #[cfg(windows)] + fn flush_linked_file(command_output: &io::Result, out_filename: &Path) + -> io::Result<()> + { + // On Windows, under high I/O load, output buffers are sometimes not flushed, + // even long after process exit, causing nasty, non-reproducible output bugs. + // + // File::sync_all() calls FlushFileBuffers() down the line, which solves the problem. + // + // А full writeup of the original Chrome bug can be found at + // randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/amp + + if let &Ok(ref out) = command_output { + if out.status.success() { + if let Ok(of) = fs::OpenOptions::new().write(true).open(out_filename) { + of.sync_all()?; + } + } + } + + Ok(()) + } + + #[cfg(unix)] + fn command_line_too_big(err: &io::Error) -> bool { + err.raw_os_error() == Some(::libc::E2BIG) + } + + #[cfg(windows)] + fn command_line_too_big(err: &io::Error) -> bool { + const ERROR_FILENAME_EXCED_RANGE: i32 = 206; + err.raw_os_error() == Some(ERROR_FILENAME_EXCED_RANGE) + } + + struct Escape<'a> { + arg: &'a str, + is_like_msvc: bool, + } + + impl<'a> fmt::Display for Escape<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.is_like_msvc { + // This is "documented" at + // https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx + // + // Unfortunately there's not a great specification of the + // syntax I could find online (at least) but some local + // testing showed that this seemed sufficient-ish to catch + // at least a few edge cases. + write!(f, "\"")?; + for c in self.arg.chars() { + match c { + '"' => write!(f, "\\{}", c)?, + c => write!(f, "{}", c)?, + } + } + write!(f, "\"")?; + } else { + // This is documented at https://linux.die.net/man/1/ld, namely: + // + // > Options in file are separated by whitespace. A whitespace + // > character may be included in an option by surrounding the + // > entire option in either single or double quotes. Any + // > character (including a backslash) may be included by + // > prefixing the character to be included with a backslash. + // + // We put an argument on each line, so all we need to do is + // ensure the line is interpreted as one whole argument. + for c in self.arg.chars() { + match c { + '\\' | + ' ' => write!(f, "\\{}", c)?, + c => write!(f, "{}", c)?, + } + } + } + Ok(()) + } + } +} + +// # Rust Crate linking +// +// Rust crates are not considered at all when creating an rlib output. All +// dependencies will be linked when producing the final output (instead of +// the intermediate rlib version) +fn add_upstream_rust_crates(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + crate_type: config::CrateType, + tmpdir: &Path) { + // All of the heavy lifting has previously been accomplished by the + // dependency_format module of the compiler. This is just crawling the + // output of that module, adding crates as necessary. + // + // Linking to a rlib involves just passing it to the linker (the linker + // will slurp up the object files inside), and linking to a dynamic library + // involves just passing the right -l flag. + + let formats = sess.dependency_formats.borrow(); + let data = formats.get(&crate_type).unwrap(); + + // Invoke get_used_crates to ensure that we get a topological sorting of + // crates. + let deps = &codegen_results.crate_info.used_crates_dynamic; + + // There's a few internal crates in the standard library (aka libcore and + // libstd) which actually have a circular dependence upon one another. This + // currently arises through "weak lang items" where libcore requires things + // like `rust_begin_unwind` but libstd ends up defining it. To get this + // circular dependence to work correctly in all situations we'll need to be + // sure to correctly apply the `--start-group` and `--end-group` options to + // GNU linkers, otherwise if we don't use any other symbol from the standard + // library it'll get discarded and the whole application won't link. + // + // In this loop we're calculating the `group_end`, after which crate to + // pass `--end-group` and `group_start`, before which crate to pass + // `--start-group`. We currently do this by passing `--end-group` after + // the first crate (when iterating backwards) that requires a lang item + // defined somewhere else. Once that's set then when we've defined all the + // necessary lang items we'll pass `--start-group`. + // + // Note that this isn't amazing logic for now but it should do the trick + // for the current implementation of the standard library. + let mut group_end = None; + let mut group_start = None; + let mut end_with = FxHashSet::default(); + let info = &codegen_results.crate_info; + for &(cnum, _) in deps.iter().rev() { + if let Some(missing) = info.missing_lang_items.get(&cnum) { + end_with.extend(missing.iter().cloned()); + if end_with.len() > 0 && group_end.is_none() { + group_end = Some(cnum); + } + } + end_with.retain(|item| info.lang_item_to_crate.get(item) != Some(&cnum)); + if end_with.len() == 0 && group_end.is_some() { + group_start = Some(cnum); + break + } + } + + // If we didn't end up filling in all lang items from upstream crates then + // we'll be filling it in with our crate. This probably means we're the + // standard library itself, so skip this for now. + if group_end.is_some() && group_start.is_none() { + group_end = None; + } + + let mut compiler_builtins = None; + + for &(cnum, _) in deps.iter() { + if group_start == Some(cnum) { + cmd.group_start(); + } + + // We may not pass all crates through to the linker. Some crates may + // appear statically in an existing dylib, meaning we'll pick up all the + // symbols from the dylib. + let src = &codegen_results.crate_info.used_crate_source[&cnum]; + match data[cnum.as_usize() - 1] { + _ if codegen_results.crate_info.profiler_runtime == Some(cnum) => { + add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); + } + _ if codegen_results.crate_info.sanitizer_runtime == Some(cnum) => { + link_sanitizer_runtime(cmd, sess, codegen_results, tmpdir, cnum); + } + // compiler-builtins are always placed last to ensure that they're + // linked correctly. + _ if codegen_results.crate_info.compiler_builtins == Some(cnum) => { + assert!(compiler_builtins.is_none()); + compiler_builtins = Some(cnum); + } + Linkage::NotLinked | + Linkage::IncludedFromDylib => {} + Linkage::Static => { + add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); + } + Linkage::Dynamic => { + add_dynamic_crate(cmd, sess, &src.dylib.as_ref().unwrap().0) + } + } + + if group_end == Some(cnum) { + cmd.group_end(); + } + } + + // compiler-builtins are always placed last to ensure that they're + // linked correctly. + // We must always link the `compiler_builtins` crate statically. Even if it + // was already "included" in a dylib (e.g. `libstd` when `-C prefer-dynamic` + // is used) + if let Some(cnum) = compiler_builtins { + add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); + } + + // Converts a library file-stem into a cc -l argument + fn unlib<'a>(config: &config::Config, stem: &'a str) -> &'a str { + if stem.starts_with("lib") && !config.target.options.is_like_windows { + &stem[3..] + } else { + stem + } + } + + // We must link the sanitizer runtime using -Wl,--whole-archive but since + // it's packed in a .rlib, it contains stuff that are not objects that will + // make the linker error. So we must remove those bits from the .rlib before + // linking it. + fn link_sanitizer_runtime(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + tmpdir: &Path, + cnum: CrateNum) { + let src = &codegen_results.crate_info.used_crate_source[&cnum]; + let cratepath = &src.rlib.as_ref().unwrap().0; + + if sess.target.target.options.is_like_osx { + // On Apple platforms, the sanitizer is always built as a dylib, and + // LLVM will link to `@rpath/*.dylib`, so we need to specify an + // rpath to the library as well (the rpath should be absolute, see + // PR #41352 for details). + // + // FIXME: Remove this logic into librustc_*san once Cargo supports it + let rpath = cratepath.parent().unwrap(); + let rpath = rpath.to_str().expect("non-utf8 component in path"); + cmd.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]); + } + + let dst = tmpdir.join(cratepath.file_name().unwrap()); + let cfg = archive_config(sess, &dst, Some(cratepath)); + let mut archive = ArchiveBuilder::new(cfg); + archive.update_symbols(); + + for f in archive.src_files() { + if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { + archive.remove_file(&f); + continue + } + } + + archive.build(); + + cmd.link_whole_rlib(&dst); + } + + // Adds the static "rlib" versions of all crates to the command line. + // There's a bit of magic which happens here specifically related to LTO and + // dynamic libraries. Specifically: + // + // * For LTO, we remove upstream object files. + // * For dylibs we remove metadata and bytecode from upstream rlibs + // + // When performing LTO, almost(*) all of the bytecode from the upstream + // libraries has already been included in our object file output. As a + // result we need to remove the object files in the upstream libraries so + // the linker doesn't try to include them twice (or whine about duplicate + // symbols). We must continue to include the rest of the rlib, however, as + // it may contain static native libraries which must be linked in. + // + // (*) Crates marked with `#![no_builtins]` don't participate in LTO and + // their bytecode wasn't included. The object files in those libraries must + // still be passed to the linker. + // + // When making a dynamic library, linkers by default don't include any + // object files in an archive if they're not necessary to resolve the link. + // We basically want to convert the archive (rlib) to a dylib, though, so we + // *do* want everything included in the output, regardless of whether the + // linker thinks it's needed or not. As a result we must use the + // --whole-archive option (or the platform equivalent). When using this + // option the linker will fail if there are non-objects in the archive (such + // as our own metadata and/or bytecode). All in all, for rlibs to be + // entirely included in dylibs, we need to remove all non-object files. + // + // Note, however, that if we're not doing LTO or we're not producing a dylib + // (aka we're making an executable), we can just pass the rlib blindly to + // the linker (fast) because it's fine if it's not actually included as + // we're at the end of the dependency chain. + fn add_static_crate(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + tmpdir: &Path, + crate_type: config::CrateType, + cnum: CrateNum) { + let src = &codegen_results.crate_info.used_crate_source[&cnum]; + let cratepath = &src.rlib.as_ref().unwrap().0; + + // See the comment above in `link_staticlib` and `link_rlib` for why if + // there's a static library that's not relevant we skip all object + // files. + let native_libs = &codegen_results.crate_info.native_libraries[&cnum]; + let skip_native = native_libs.iter().any(|lib| { + lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib) + }); + + if (!are_upstream_rust_objects_already_included(sess) || + ignored_for_lto(sess, &codegen_results.crate_info, cnum)) && + crate_type != config::CrateType::Dylib && + !skip_native { + cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath)); + return + } + + let dst = tmpdir.join(cratepath.file_name().unwrap()); + let name = cratepath.file_name().unwrap().to_str().unwrap(); + let name = &name[3..name.len() - 5]; // chop off lib/.rlib + + time(sess, &format!("altering {}.rlib", name), || { + let cfg = archive_config(sess, &dst, Some(cratepath)); + let mut archive = ArchiveBuilder::new(cfg); + archive.update_symbols(); + + let mut any_objects = false; + for f in archive.src_files() { + if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { + archive.remove_file(&f); + continue + } + + let canonical = f.replace("-", "_"); + let canonical_name = name.replace("-", "_"); + + // Look for `.rcgu.o` at the end of the filename to conclude + // that this is a Rust-related object file. + fn looks_like_rust(s: &str) -> bool { + let path = Path::new(s); + let ext = path.extension().and_then(|s| s.to_str()); + if ext != Some(OutputType::Object.extension()) { + return false + } + let ext2 = path.file_stem() + .and_then(|s| Path::new(s).extension()) + .and_then(|s| s.to_str()); + ext2 == Some(RUST_CGU_EXT) + } + + let is_rust_object = + canonical.starts_with(&canonical_name) && + looks_like_rust(&f); + + // If we've been requested to skip all native object files + // (those not generated by the rust compiler) then we can skip + // this file. See above for why we may want to do this. + let skip_because_cfg_say_so = skip_native && !is_rust_object; + + // If we're performing LTO and this is a rust-generated object + // file, then we don't need the object file as it's part of the + // LTO module. Note that `#![no_builtins]` is excluded from LTO, + // though, so we let that object file slide. + let skip_because_lto = are_upstream_rust_objects_already_included(sess) && + is_rust_object && + (sess.target.target.options.no_builtins || + !codegen_results.crate_info.is_no_builtins.contains(&cnum)); + + if skip_because_cfg_say_so || skip_because_lto { + archive.remove_file(&f); + } else { + any_objects = true; + } + } + + if !any_objects { + return + } + archive.build(); + + // If we're creating a dylib, then we need to include the + // whole of each object in our archive into that artifact. This is + // because a `dylib` can be reused as an intermediate artifact. + // + // Note, though, that we don't want to include the whole of a + // compiler-builtins crate (e.g. compiler-rt) because it'll get + // repeatedly linked anyway. + if crate_type == config::CrateType::Dylib && + codegen_results.crate_info.compiler_builtins != Some(cnum) { + cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst)); + } else { + cmd.link_rlib(&fix_windows_verbatim_for_gcc(&dst)); + } + }); + } + + // Same thing as above, but for dynamic crates instead of static crates. + fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) { + // If we're performing LTO, then it should have been previously required + // that all upstream rust dependencies were available in an rlib format. + assert!(!are_upstream_rust_objects_already_included(sess)); + + // Just need to tell the linker about where the library lives and + // what its name is + let parent = cratepath.parent(); + if let Some(dir) = parent { + cmd.include_path(&fix_windows_verbatim_for_gcc(dir)); + } + let filestem = cratepath.file_stem().unwrap().to_str().unwrap(); + cmd.link_rust_dylib(&unlib(&sess.target, filestem), + parent.unwrap_or(Path::new(""))); + } +} + +// # Native library linking +// +// User-supplied library search paths (-L on the command line). These are +// the same paths used to find Rust crates, so some of them may have been +// added already by the previous crate linking code. This only allows them +// to be found at compile time so it is still entirely up to outside +// forces to make sure that library can be found at runtime. +// +// Also note that the native libraries linked here are only the ones located +// in the current crate. Upstream crates with native library dependencies +// may have their native library pulled in above. +fn add_local_native_libraries(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults) { + sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, k| { + match k { + PathKind::Framework => { cmd.framework_path(path); } + _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(path)); } + } + }); + + let relevant_libs = codegen_results.crate_info.used_libraries.iter().filter(|l| { + relevant_lib(sess, l) + }); + + let search_path = archive_search_paths(sess); + for lib in relevant_libs { + let name = match lib.name { + Some(ref l) => l, + None => continue, + }; + match lib.kind { + NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), + NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), + NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()), + NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(), + &search_path) + } + } +} + +// Link in all of our upstream crates' native dependencies. Remember that +// all of these upstream native dependencies are all non-static +// dependencies. We've got two cases then: +// +// 1. The upstream crate is an rlib. In this case we *must* link in the +// native dependency because the rlib is just an archive. +// +// 2. The upstream crate is a dylib. In order to use the dylib, we have to +// have the dependency present on the system somewhere. Thus, we don't +// gain a whole lot from not linking in the dynamic dependency to this +// crate as well. +// +// The use case for this is a little subtle. In theory the native +// dependencies of a crate are purely an implementation detail of the crate +// itself, but the problem arises with generic and inlined functions. If a +// generic function calls a native function, then the generic function must +// be instantiated in the target crate, meaning that the native symbol must +// also be resolved in the target crate. +fn add_upstream_native_libraries(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + crate_type: config::CrateType) { + // Be sure to use a topological sorting of crates because there may be + // interdependencies between native libraries. When passing -nodefaultlibs, + // for example, almost all native libraries depend on libc, so we have to + // make sure that's all the way at the right (liblibc is near the base of + // the dependency chain). + // + // This passes RequireStatic, but the actual requirement doesn't matter, + // we're just getting an ordering of crate numbers, we're not worried about + // the paths. + let formats = sess.dependency_formats.borrow(); + let data = formats.get(&crate_type).unwrap(); + + let crates = &codegen_results.crate_info.used_crates_static; + for &(cnum, _) in crates { + for lib in codegen_results.crate_info.native_libraries[&cnum].iter() { + let name = match lib.name { + Some(ref l) => l, + None => continue, + }; + if !relevant_lib(sess, &lib) { + continue + } + match lib.kind { + NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), + NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), + NativeLibraryKind::NativeStaticNobundle => { + // Link "static-nobundle" native libs only if the crate they originate from + // is being linked statically to the current crate. If it's linked dynamically + // or is an rlib already included via some other dylib crate, the symbols from + // native libs will have already been included in that dylib. + if data[cnum.as_usize() - 1] == Linkage::Static { + cmd.link_staticlib(&name.as_str()) + } + }, + // ignore statically included native libraries here as we've + // already included them when we included the rust library + // previously + NativeLibraryKind::NativeStatic => {} + } + } + } +} + +/// Returns a boolean indicating whether the specified crate should be ignored +/// during LTO. +/// +/// Crates ignored during LTO are not lumped together in the "massive object +/// file" that we create and are linked in their normal rlib states. See +/// comments below for what crates do not participate in LTO. +/// +/// It's unusual for a crate to not participate in LTO. Typically only +/// compiler-specific and unstable crates have a reason to not participate in +/// LTO. +fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool { + // If our target enables builtin function lowering in LLVM then the + // crates providing these functions don't participate in LTO (e.g. + // no_builtins or compiler builtins crates). + !sess.target.target.options.no_builtins && + (info.is_no_builtins.contains(&cnum) || info.compiler_builtins == Some(cnum)) +} + +fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { + match lib.cfg { + Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None), + None => true, + } +} + +fn are_upstream_rust_objects_already_included(sess: &Session) -> bool { + match sess.lto() { + Lto::Fat => true, + Lto::Thin => { + // If we defer LTO to the linker, we haven't run LTO ourselves, so + // any upstream object files have not been copied yet. + !sess.opts.debugging_opts.cross_lang_lto.enabled() + } + Lto::No | + Lto::ThinLocal => false, + } +} From 7ef83ec641cff0d2c50d6253588cc86e788254bc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Nov 2018 15:33:44 +0100 Subject: [PATCH 0336/1566] Disable alloc_example and compile mod_bench_inline's sysroot with -Zmir-opt-level=3 --- build.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 2b1b065393237..4917dff7ce6e1 100755 --- a/build.sh +++ b/build.sh @@ -51,10 +51,18 @@ time xargo build popd # TODO linux linker doesn't accept duplicate definitions -$RUSTC --sysroot ~/.xargo/HOST example/alloc_example.rs --crate-type bin -./target/out/alloc_example +#$RUSTC --sysroot ~/.xargo/HOST example/alloc_example.rs --crate-type bin +#./target/out/alloc_example $RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin + +echo "[BUILD] RUSTFLAGS=-Zmir-opt-level=3" +pushd xargo +rm -r ~/.xargo/HOST || true +rm -r target || true +time RUSTFLAGS="-Zmir-opt-level=3 $RUSTFLAGS" xargo build +popd + $RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 --crate-name mod_bench_inline rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort From f955c8ef2a703de41c347b86b4f828c76f76dede Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Nov 2018 11:36:11 +0100 Subject: [PATCH 0337/1566] Move all functions in link.rs copied from cg_llvm to link_copied.rs --- src/lib.rs | 3 +- src/link.rs | 767 +------------------------------------------- src/link_copied.rs | 777 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 782 insertions(+), 765 deletions(-) create mode 100644 src/link_copied.rs diff --git a/src/lib.rs b/src/lib.rs index fb0d6067bff8f..fdfa0d1d78707 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,6 +77,7 @@ mod common; mod constant; mod intrinsics; mod link; +mod link_copied; mod main_shim; mod metadata; mod pretty_clif; @@ -404,7 +405,7 @@ impl CodegenBackend for CraneliftCodegenBackend { std::fs::write(&tmp_file, obj).unwrap(); /*use rustc_mir::monomorphize::partitioning::CodegenUnitExt; - + let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx); let ((stats, module), _) = tcx.dep_graph.with_task( dep_node, diff --git a/src/link.rs b/src/link.rs index f51b978725746..1335b209f8c58 100644 --- a/src/link.rs +++ b/src/link.rs @@ -1,34 +1,21 @@ use std::env; -use std::fmt; -use std::fs::{self, File}; +use std::fs::File; use std::io; -use std::iter; use std::path::{Path, PathBuf}; -use std::process::{Output, Stdio}; -use cc::windows_registry; use tempfile::Builder as TempFileBuilder; -use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; -use rustc::middle::dependency_format::Linkage; -use rustc::session::config::{self, CrateType, DebugInfo, OutputType, RUST_CGU_EXT}; +use rustc::session::config::{self, CrateType, DebugInfo, RUST_CGU_EXT}; use rustc::session::search_paths::PathKind; use rustc::session::Session; -use rustc::util::common::time; use rustc_codegen_utils::command::Command; use rustc_codegen_utils::linker::*; -use rustc_data_structures::fx::FxHashSet; use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel}; -use syntax::attr; use crate::prelude::*; -use crate::archive::{ArchiveBuilder, ArchiveConfig}; -use crate::metadata::METADATA_FILENAME; - -// cg_clif doesn't have bytecode, so this is just a dummy -const RLIB_BYTECODE_EXTENSION: &str = ".cg_clif_bytecode_dummy"; +use crate::link_copied::*; pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathBuf) { let file = File::create(&output_name).unwrap(); @@ -441,751 +428,3 @@ fn link_args(cmd: &mut dyn Linker, cmd.args(&sess.opts.cg.link_arg); cmd.args(&used_link_args); } - -// =========================== -// Copied from https://github.com/rust-lang/rust/blob/942864a000efd74b73e36bda5606b2cdb55ecf39/src/librustc_codegen_llvm/back/link.rs -// =========================== - -fn archive_search_paths(sess: &Session) -> Vec { - let mut search = Vec::new(); - sess.target_filesearch(PathKind::Native).for_each_lib_search_path(|path, _| { - search.push(path.to_path_buf()); - }); - return search; -} - -fn archive_config<'a>(sess: &'a Session, - output: &Path, - input: Option<&Path>) -> ArchiveConfig<'a> { - ArchiveConfig { - sess, - dst: output.to_path_buf(), - src: input.map(|p| p.to_path_buf()), - lib_search_paths: archive_search_paths(sess), - } -} - -// The third parameter is for env vars, used on windows to set up the -// path for MSVC to find its DLLs, and gcc to find its bundled -// toolchain -fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathBuf, Command) { - let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe"); - - // If our linker looks like a batch script on Windows then to execute this - // we'll need to spawn `cmd` explicitly. This is primarily done to handle - // emscripten where the linker is `emcc.bat` and needs to be spawned as - // `cmd /c emcc.bat ...`. - // - // This worked historically but is needed manually since #42436 (regression - // was tagged as #42791) and some more info can be found on #44443 for - // emscripten itself. - let mut cmd = match linker.to_str() { - Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker), - _ => match flavor { - LinkerFlavor::Lld(f) => Command::lld(linker, f), - LinkerFlavor::Msvc - if sess.opts.cg.linker.is_none() && sess.target.target.options.linker.is_none() => - { - Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker)) - }, - _ => Command::new(linker), - } - }; - - // The compiler's sysroot often has some bundled tools, so add it to the - // PATH for the child. - let mut new_path = sess.host_filesearch(PathKind::All) - .get_tools_search_paths(); - let mut msvc_changed_path = false; - if sess.target.target.options.is_like_msvc { - if let Some(ref tool) = msvc_tool { - cmd.args(tool.args()); - for &(ref k, ref v) in tool.env() { - if k == "PATH" { - new_path.extend(env::split_paths(v)); - msvc_changed_path = true; - } else { - cmd.env(k, v); - } - } - } - } - - if !msvc_changed_path { - if let Some(path) = env::var_os("PATH") { - new_path.extend(env::split_paths(&path)); - } - } - cmd.env("PATH", env::join_paths(new_path).unwrap()); - - (linker.to_path_buf(), cmd) -} - -fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { - fn infer_from( - sess: &Session, - linker: Option, - flavor: Option, - ) -> Option<(PathBuf, LinkerFlavor)> { - match (linker, flavor) { - (Some(linker), Some(flavor)) => Some((linker, flavor)), - // only the linker flavor is known; use the default linker for the selected flavor - (None, Some(flavor)) => Some((PathBuf::from(match flavor { - LinkerFlavor::Em => if cfg!(windows) { "emcc.bat" } else { "emcc" }, - LinkerFlavor::Gcc => "cc", - LinkerFlavor::Ld => "ld", - LinkerFlavor::Msvc => "link.exe", - LinkerFlavor::Lld(_) => "lld", - }), flavor)), - (Some(linker), None) => { - let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { - sess.fatal("couldn't extract file stem from specified linker"); - }).to_owned(); - - let flavor = if stem == "emcc" { - LinkerFlavor::Em - } else if stem == "gcc" || stem.ends_with("-gcc") { - LinkerFlavor::Gcc - } else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") { - LinkerFlavor::Ld - } else if stem == "link" || stem == "lld-link" { - LinkerFlavor::Msvc - } else if stem == "lld" || stem == "rust-lld" { - LinkerFlavor::Lld(sess.target.target.options.lld_flavor) - } else { - // fall back to the value in the target spec - sess.target.target.linker_flavor - }; - - Some((linker, flavor)) - }, - (None, None) => None, - } - } - - // linker and linker flavor specified via command line have precedence over what the target - // specification specifies - if let Some(ret) = infer_from( - sess, - sess.opts.cg.linker.clone(), - sess.opts.debugging_opts.linker_flavor, - ) { - return ret; - } - - if let Some(ret) = infer_from( - sess, - sess.target.target.options.linker.clone().map(PathBuf::from), - Some(sess.target.target.linker_flavor), - ) { - return ret; - } - - bug!("Not enough information provided to determine how to invoke the linker"); -} - -fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &Path) - -> io::Result -{ - // When attempting to spawn the linker we run a risk of blowing out the - // size limits for spawning a new process with respect to the arguments - // we pass on the command line. - // - // Here we attempt to handle errors from the OS saying "your list of - // arguments is too big" by reinvoking the linker again with an `@`-file - // that contains all the arguments. The theory is that this is then - // accepted on all linkers and the linker will read all its options out of - // there instead of looking at the command line. - if !cmd.very_likely_to_exceed_some_spawn_limit() { - match cmd.command().stdout(Stdio::piped()).stderr(Stdio::piped()).spawn() { - Ok(child) => { - let output = child.wait_with_output(); - flush_linked_file(&output, out_filename)?; - return output; - } - Err(ref e) if command_line_too_big(e) => { - info!("command line to linker was too big: {}", e); - } - Err(e) => return Err(e) - } - } - - info!("falling back to passing arguments to linker via an @-file"); - let mut cmd2 = cmd.clone(); - let mut args = String::new(); - for arg in cmd2.take_args() { - args.push_str(&Escape { - arg: arg.to_str().unwrap(), - is_like_msvc: sess.target.target.options.is_like_msvc, - }.to_string()); - args.push_str("\n"); - } - let file = tmpdir.join("linker-arguments"); - let bytes = if sess.target.target.options.is_like_msvc { - let mut out = Vec::with_capacity((1 + args.len()) * 2); - // start the stream with a UTF-16 BOM - for c in iter::once(0xFEFF).chain(args.encode_utf16()) { - // encode in little endian - out.push(c as u8); - out.push((c >> 8) as u8); - } - out - } else { - args.into_bytes() - }; - fs::write(&file, &bytes)?; - cmd2.arg(format!("@{}", file.display())); - info!("invoking linker {:?}", cmd2); - let output = cmd2.output(); - flush_linked_file(&output, out_filename)?; - return output; - - #[cfg(unix)] - fn flush_linked_file(_: &io::Result, _: &Path) -> io::Result<()> { - Ok(()) - } - - #[cfg(windows)] - fn flush_linked_file(command_output: &io::Result, out_filename: &Path) - -> io::Result<()> - { - // On Windows, under high I/O load, output buffers are sometimes not flushed, - // even long after process exit, causing nasty, non-reproducible output bugs. - // - // File::sync_all() calls FlushFileBuffers() down the line, which solves the problem. - // - // А full writeup of the original Chrome bug can be found at - // randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/amp - - if let &Ok(ref out) = command_output { - if out.status.success() { - if let Ok(of) = fs::OpenOptions::new().write(true).open(out_filename) { - of.sync_all()?; - } - } - } - - Ok(()) - } - - #[cfg(unix)] - fn command_line_too_big(err: &io::Error) -> bool { - err.raw_os_error() == Some(::libc::E2BIG) - } - - #[cfg(windows)] - fn command_line_too_big(err: &io::Error) -> bool { - const ERROR_FILENAME_EXCED_RANGE: i32 = 206; - err.raw_os_error() == Some(ERROR_FILENAME_EXCED_RANGE) - } - - struct Escape<'a> { - arg: &'a str, - is_like_msvc: bool, - } - - impl<'a> fmt::Display for Escape<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.is_like_msvc { - // This is "documented" at - // https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx - // - // Unfortunately there's not a great specification of the - // syntax I could find online (at least) but some local - // testing showed that this seemed sufficient-ish to catch - // at least a few edge cases. - write!(f, "\"")?; - for c in self.arg.chars() { - match c { - '"' => write!(f, "\\{}", c)?, - c => write!(f, "{}", c)?, - } - } - write!(f, "\"")?; - } else { - // This is documented at https://linux.die.net/man/1/ld, namely: - // - // > Options in file are separated by whitespace. A whitespace - // > character may be included in an option by surrounding the - // > entire option in either single or double quotes. Any - // > character (including a backslash) may be included by - // > prefixing the character to be included with a backslash. - // - // We put an argument on each line, so all we need to do is - // ensure the line is interpreted as one whole argument. - for c in self.arg.chars() { - match c { - '\\' | - ' ' => write!(f, "\\{}", c)?, - c => write!(f, "{}", c)?, - } - } - } - Ok(()) - } - } -} - -// # Rust Crate linking -// -// Rust crates are not considered at all when creating an rlib output. All -// dependencies will be linked when producing the final output (instead of -// the intermediate rlib version) -fn add_upstream_rust_crates(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - crate_type: config::CrateType, - tmpdir: &Path) { - // All of the heavy lifting has previously been accomplished by the - // dependency_format module of the compiler. This is just crawling the - // output of that module, adding crates as necessary. - // - // Linking to a rlib involves just passing it to the linker (the linker - // will slurp up the object files inside), and linking to a dynamic library - // involves just passing the right -l flag. - - let formats = sess.dependency_formats.borrow(); - let data = formats.get(&crate_type).unwrap(); - - // Invoke get_used_crates to ensure that we get a topological sorting of - // crates. - let deps = &codegen_results.crate_info.used_crates_dynamic; - - // There's a few internal crates in the standard library (aka libcore and - // libstd) which actually have a circular dependence upon one another. This - // currently arises through "weak lang items" where libcore requires things - // like `rust_begin_unwind` but libstd ends up defining it. To get this - // circular dependence to work correctly in all situations we'll need to be - // sure to correctly apply the `--start-group` and `--end-group` options to - // GNU linkers, otherwise if we don't use any other symbol from the standard - // library it'll get discarded and the whole application won't link. - // - // In this loop we're calculating the `group_end`, after which crate to - // pass `--end-group` and `group_start`, before which crate to pass - // `--start-group`. We currently do this by passing `--end-group` after - // the first crate (when iterating backwards) that requires a lang item - // defined somewhere else. Once that's set then when we've defined all the - // necessary lang items we'll pass `--start-group`. - // - // Note that this isn't amazing logic for now but it should do the trick - // for the current implementation of the standard library. - let mut group_end = None; - let mut group_start = None; - let mut end_with = FxHashSet::default(); - let info = &codegen_results.crate_info; - for &(cnum, _) in deps.iter().rev() { - if let Some(missing) = info.missing_lang_items.get(&cnum) { - end_with.extend(missing.iter().cloned()); - if end_with.len() > 0 && group_end.is_none() { - group_end = Some(cnum); - } - } - end_with.retain(|item| info.lang_item_to_crate.get(item) != Some(&cnum)); - if end_with.len() == 0 && group_end.is_some() { - group_start = Some(cnum); - break - } - } - - // If we didn't end up filling in all lang items from upstream crates then - // we'll be filling it in with our crate. This probably means we're the - // standard library itself, so skip this for now. - if group_end.is_some() && group_start.is_none() { - group_end = None; - } - - let mut compiler_builtins = None; - - for &(cnum, _) in deps.iter() { - if group_start == Some(cnum) { - cmd.group_start(); - } - - // We may not pass all crates through to the linker. Some crates may - // appear statically in an existing dylib, meaning we'll pick up all the - // symbols from the dylib. - let src = &codegen_results.crate_info.used_crate_source[&cnum]; - match data[cnum.as_usize() - 1] { - _ if codegen_results.crate_info.profiler_runtime == Some(cnum) => { - add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); - } - _ if codegen_results.crate_info.sanitizer_runtime == Some(cnum) => { - link_sanitizer_runtime(cmd, sess, codegen_results, tmpdir, cnum); - } - // compiler-builtins are always placed last to ensure that they're - // linked correctly. - _ if codegen_results.crate_info.compiler_builtins == Some(cnum) => { - assert!(compiler_builtins.is_none()); - compiler_builtins = Some(cnum); - } - Linkage::NotLinked | - Linkage::IncludedFromDylib => {} - Linkage::Static => { - add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); - } - Linkage::Dynamic => { - add_dynamic_crate(cmd, sess, &src.dylib.as_ref().unwrap().0) - } - } - - if group_end == Some(cnum) { - cmd.group_end(); - } - } - - // compiler-builtins are always placed last to ensure that they're - // linked correctly. - // We must always link the `compiler_builtins` crate statically. Even if it - // was already "included" in a dylib (e.g. `libstd` when `-C prefer-dynamic` - // is used) - if let Some(cnum) = compiler_builtins { - add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); - } - - // Converts a library file-stem into a cc -l argument - fn unlib<'a>(config: &config::Config, stem: &'a str) -> &'a str { - if stem.starts_with("lib") && !config.target.options.is_like_windows { - &stem[3..] - } else { - stem - } - } - - // We must link the sanitizer runtime using -Wl,--whole-archive but since - // it's packed in a .rlib, it contains stuff that are not objects that will - // make the linker error. So we must remove those bits from the .rlib before - // linking it. - fn link_sanitizer_runtime(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - tmpdir: &Path, - cnum: CrateNum) { - let src = &codegen_results.crate_info.used_crate_source[&cnum]; - let cratepath = &src.rlib.as_ref().unwrap().0; - - if sess.target.target.options.is_like_osx { - // On Apple platforms, the sanitizer is always built as a dylib, and - // LLVM will link to `@rpath/*.dylib`, so we need to specify an - // rpath to the library as well (the rpath should be absolute, see - // PR #41352 for details). - // - // FIXME: Remove this logic into librustc_*san once Cargo supports it - let rpath = cratepath.parent().unwrap(); - let rpath = rpath.to_str().expect("non-utf8 component in path"); - cmd.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]); - } - - let dst = tmpdir.join(cratepath.file_name().unwrap()); - let cfg = archive_config(sess, &dst, Some(cratepath)); - let mut archive = ArchiveBuilder::new(cfg); - archive.update_symbols(); - - for f in archive.src_files() { - if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { - archive.remove_file(&f); - continue - } - } - - archive.build(); - - cmd.link_whole_rlib(&dst); - } - - // Adds the static "rlib" versions of all crates to the command line. - // There's a bit of magic which happens here specifically related to LTO and - // dynamic libraries. Specifically: - // - // * For LTO, we remove upstream object files. - // * For dylibs we remove metadata and bytecode from upstream rlibs - // - // When performing LTO, almost(*) all of the bytecode from the upstream - // libraries has already been included in our object file output. As a - // result we need to remove the object files in the upstream libraries so - // the linker doesn't try to include them twice (or whine about duplicate - // symbols). We must continue to include the rest of the rlib, however, as - // it may contain static native libraries which must be linked in. - // - // (*) Crates marked with `#![no_builtins]` don't participate in LTO and - // their bytecode wasn't included. The object files in those libraries must - // still be passed to the linker. - // - // When making a dynamic library, linkers by default don't include any - // object files in an archive if they're not necessary to resolve the link. - // We basically want to convert the archive (rlib) to a dylib, though, so we - // *do* want everything included in the output, regardless of whether the - // linker thinks it's needed or not. As a result we must use the - // --whole-archive option (or the platform equivalent). When using this - // option the linker will fail if there are non-objects in the archive (such - // as our own metadata and/or bytecode). All in all, for rlibs to be - // entirely included in dylibs, we need to remove all non-object files. - // - // Note, however, that if we're not doing LTO or we're not producing a dylib - // (aka we're making an executable), we can just pass the rlib blindly to - // the linker (fast) because it's fine if it's not actually included as - // we're at the end of the dependency chain. - fn add_static_crate(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - tmpdir: &Path, - crate_type: config::CrateType, - cnum: CrateNum) { - let src = &codegen_results.crate_info.used_crate_source[&cnum]; - let cratepath = &src.rlib.as_ref().unwrap().0; - - // See the comment above in `link_staticlib` and `link_rlib` for why if - // there's a static library that's not relevant we skip all object - // files. - let native_libs = &codegen_results.crate_info.native_libraries[&cnum]; - let skip_native = native_libs.iter().any(|lib| { - lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib) - }); - - if (!are_upstream_rust_objects_already_included(sess) || - ignored_for_lto(sess, &codegen_results.crate_info, cnum)) && - crate_type != config::CrateType::Dylib && - !skip_native { - cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath)); - return - } - - let dst = tmpdir.join(cratepath.file_name().unwrap()); - let name = cratepath.file_name().unwrap().to_str().unwrap(); - let name = &name[3..name.len() - 5]; // chop off lib/.rlib - - time(sess, &format!("altering {}.rlib", name), || { - let cfg = archive_config(sess, &dst, Some(cratepath)); - let mut archive = ArchiveBuilder::new(cfg); - archive.update_symbols(); - - let mut any_objects = false; - for f in archive.src_files() { - if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { - archive.remove_file(&f); - continue - } - - let canonical = f.replace("-", "_"); - let canonical_name = name.replace("-", "_"); - - // Look for `.rcgu.o` at the end of the filename to conclude - // that this is a Rust-related object file. - fn looks_like_rust(s: &str) -> bool { - let path = Path::new(s); - let ext = path.extension().and_then(|s| s.to_str()); - if ext != Some(OutputType::Object.extension()) { - return false - } - let ext2 = path.file_stem() - .and_then(|s| Path::new(s).extension()) - .and_then(|s| s.to_str()); - ext2 == Some(RUST_CGU_EXT) - } - - let is_rust_object = - canonical.starts_with(&canonical_name) && - looks_like_rust(&f); - - // If we've been requested to skip all native object files - // (those not generated by the rust compiler) then we can skip - // this file. See above for why we may want to do this. - let skip_because_cfg_say_so = skip_native && !is_rust_object; - - // If we're performing LTO and this is a rust-generated object - // file, then we don't need the object file as it's part of the - // LTO module. Note that `#![no_builtins]` is excluded from LTO, - // though, so we let that object file slide. - let skip_because_lto = are_upstream_rust_objects_already_included(sess) && - is_rust_object && - (sess.target.target.options.no_builtins || - !codegen_results.crate_info.is_no_builtins.contains(&cnum)); - - if skip_because_cfg_say_so || skip_because_lto { - archive.remove_file(&f); - } else { - any_objects = true; - } - } - - if !any_objects { - return - } - archive.build(); - - // If we're creating a dylib, then we need to include the - // whole of each object in our archive into that artifact. This is - // because a `dylib` can be reused as an intermediate artifact. - // - // Note, though, that we don't want to include the whole of a - // compiler-builtins crate (e.g. compiler-rt) because it'll get - // repeatedly linked anyway. - if crate_type == config::CrateType::Dylib && - codegen_results.crate_info.compiler_builtins != Some(cnum) { - cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst)); - } else { - cmd.link_rlib(&fix_windows_verbatim_for_gcc(&dst)); - } - }); - } - - // Same thing as above, but for dynamic crates instead of static crates. - fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) { - // If we're performing LTO, then it should have been previously required - // that all upstream rust dependencies were available in an rlib format. - assert!(!are_upstream_rust_objects_already_included(sess)); - - // Just need to tell the linker about where the library lives and - // what its name is - let parent = cratepath.parent(); - if let Some(dir) = parent { - cmd.include_path(&fix_windows_verbatim_for_gcc(dir)); - } - let filestem = cratepath.file_stem().unwrap().to_str().unwrap(); - cmd.link_rust_dylib(&unlib(&sess.target, filestem), - parent.unwrap_or(Path::new(""))); - } -} - -// # Native library linking -// -// User-supplied library search paths (-L on the command line). These are -// the same paths used to find Rust crates, so some of them may have been -// added already by the previous crate linking code. This only allows them -// to be found at compile time so it is still entirely up to outside -// forces to make sure that library can be found at runtime. -// -// Also note that the native libraries linked here are only the ones located -// in the current crate. Upstream crates with native library dependencies -// may have their native library pulled in above. -fn add_local_native_libraries(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults) { - sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, k| { - match k { - PathKind::Framework => { cmd.framework_path(path); } - _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(path)); } - } - }); - - let relevant_libs = codegen_results.crate_info.used_libraries.iter().filter(|l| { - relevant_lib(sess, l) - }); - - let search_path = archive_search_paths(sess); - for lib in relevant_libs { - let name = match lib.name { - Some(ref l) => l, - None => continue, - }; - match lib.kind { - NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), - NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), - NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()), - NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(), - &search_path) - } - } -} - -// Link in all of our upstream crates' native dependencies. Remember that -// all of these upstream native dependencies are all non-static -// dependencies. We've got two cases then: -// -// 1. The upstream crate is an rlib. In this case we *must* link in the -// native dependency because the rlib is just an archive. -// -// 2. The upstream crate is a dylib. In order to use the dylib, we have to -// have the dependency present on the system somewhere. Thus, we don't -// gain a whole lot from not linking in the dynamic dependency to this -// crate as well. -// -// The use case for this is a little subtle. In theory the native -// dependencies of a crate are purely an implementation detail of the crate -// itself, but the problem arises with generic and inlined functions. If a -// generic function calls a native function, then the generic function must -// be instantiated in the target crate, meaning that the native symbol must -// also be resolved in the target crate. -fn add_upstream_native_libraries(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - crate_type: config::CrateType) { - // Be sure to use a topological sorting of crates because there may be - // interdependencies between native libraries. When passing -nodefaultlibs, - // for example, almost all native libraries depend on libc, so we have to - // make sure that's all the way at the right (liblibc is near the base of - // the dependency chain). - // - // This passes RequireStatic, but the actual requirement doesn't matter, - // we're just getting an ordering of crate numbers, we're not worried about - // the paths. - let formats = sess.dependency_formats.borrow(); - let data = formats.get(&crate_type).unwrap(); - - let crates = &codegen_results.crate_info.used_crates_static; - for &(cnum, _) in crates { - for lib in codegen_results.crate_info.native_libraries[&cnum].iter() { - let name = match lib.name { - Some(ref l) => l, - None => continue, - }; - if !relevant_lib(sess, &lib) { - continue - } - match lib.kind { - NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), - NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), - NativeLibraryKind::NativeStaticNobundle => { - // Link "static-nobundle" native libs only if the crate they originate from - // is being linked statically to the current crate. If it's linked dynamically - // or is an rlib already included via some other dylib crate, the symbols from - // native libs will have already been included in that dylib. - if data[cnum.as_usize() - 1] == Linkage::Static { - cmd.link_staticlib(&name.as_str()) - } - }, - // ignore statically included native libraries here as we've - // already included them when we included the rust library - // previously - NativeLibraryKind::NativeStatic => {} - } - } - } -} - -/// Returns a boolean indicating whether the specified crate should be ignored -/// during LTO. -/// -/// Crates ignored during LTO are not lumped together in the "massive object -/// file" that we create and are linked in their normal rlib states. See -/// comments below for what crates do not participate in LTO. -/// -/// It's unusual for a crate to not participate in LTO. Typically only -/// compiler-specific and unstable crates have a reason to not participate in -/// LTO. -fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool { - // If our target enables builtin function lowering in LLVM then the - // crates providing these functions don't participate in LTO (e.g. - // no_builtins or compiler builtins crates). - !sess.target.target.options.no_builtins && - (info.is_no_builtins.contains(&cnum) || info.compiler_builtins == Some(cnum)) -} - -fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { - match lib.cfg { - Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None), - None => true, - } -} - -fn are_upstream_rust_objects_already_included(sess: &Session) -> bool { - match sess.lto() { - Lto::Fat => true, - Lto::Thin => { - // If we defer LTO to the linker, we haven't run LTO ourselves, so - // any upstream object files have not been copied yet. - !sess.opts.debugging_opts.cross_lang_lto.enabled() - } - Lto::No | - Lto::ThinLocal => false, - } -} diff --git a/src/link_copied.rs b/src/link_copied.rs new file mode 100644 index 0000000000000..986fe71e906b3 --- /dev/null +++ b/src/link_copied.rs @@ -0,0 +1,777 @@ +//! All functions here are copied from https://github.com/rust-lang/rust/blob/942864a000efd74b73e36bda5606b2cdb55ecf39/src/librustc_codegen_llvm/back/link.rs + +use std::env; +use std::fmt; +use std::fs; +use std::io; +use std::iter; +use std::path::{Path, PathBuf}; +use std::process::{Output, Stdio}; + +use cc::windows_registry; + +use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; +use rustc::middle::dependency_format::Linkage; +use rustc::session::config::{self, OutputType, RUST_CGU_EXT}; +use rustc::session::search_paths::PathKind; +use rustc::session::Session; +use rustc::util::common::time; +use rustc_codegen_utils::command::Command; +use rustc_codegen_utils::linker::*; +use rustc_data_structures::fx::FxHashSet; +use rustc_fs_util::fix_windows_verbatim_for_gcc; +use rustc_target::spec::LinkerFlavor; +use syntax::attr; + +use crate::prelude::*; + +use crate::archive::{ArchiveBuilder, ArchiveConfig}; +use crate::metadata::METADATA_FILENAME; + + +// cg_clif doesn't have bytecode, so this is just a dummy +const RLIB_BYTECODE_EXTENSION: &str = ".cg_clif_bytecode_dummy"; + +fn archive_search_paths(sess: &Session) -> Vec { + let mut search = Vec::new(); + sess.target_filesearch(PathKind::Native).for_each_lib_search_path(|path, _| { + search.push(path.to_path_buf()); + }); + return search; +} + +fn archive_config<'a>(sess: &'a Session, + output: &Path, + input: Option<&Path>) -> ArchiveConfig<'a> { + ArchiveConfig { + sess, + dst: output.to_path_buf(), + src: input.map(|p| p.to_path_buf()), + lib_search_paths: archive_search_paths(sess), + } +} + +// The third parameter is for env vars, used on windows to set up the +// path for MSVC to find its DLLs, and gcc to find its bundled +// toolchain +pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathBuf, Command) { + let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe"); + + // If our linker looks like a batch script on Windows then to execute this + // we'll need to spawn `cmd` explicitly. This is primarily done to handle + // emscripten where the linker is `emcc.bat` and needs to be spawned as + // `cmd /c emcc.bat ...`. + // + // This worked historically but is needed manually since #42436 (regression + // was tagged as #42791) and some more info can be found on #44443 for + // emscripten itself. + let mut cmd = match linker.to_str() { + Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker), + _ => match flavor { + LinkerFlavor::Lld(f) => Command::lld(linker, f), + LinkerFlavor::Msvc + if sess.opts.cg.linker.is_none() && sess.target.target.options.linker.is_none() => + { + Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker)) + }, + _ => Command::new(linker), + } + }; + + // The compiler's sysroot often has some bundled tools, so add it to the + // PATH for the child. + let mut new_path = sess.host_filesearch(PathKind::All) + .get_tools_search_paths(); + let mut msvc_changed_path = false; + if sess.target.target.options.is_like_msvc { + if let Some(ref tool) = msvc_tool { + cmd.args(tool.args()); + for &(ref k, ref v) in tool.env() { + if k == "PATH" { + new_path.extend(env::split_paths(v)); + msvc_changed_path = true; + } else { + cmd.env(k, v); + } + } + } + } + + if !msvc_changed_path { + if let Some(path) = env::var_os("PATH") { + new_path.extend(env::split_paths(&path)); + } + } + cmd.env("PATH", env::join_paths(new_path).unwrap()); + + (linker.to_path_buf(), cmd) +} + +pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { + fn infer_from( + sess: &Session, + linker: Option, + flavor: Option, + ) -> Option<(PathBuf, LinkerFlavor)> { + match (linker, flavor) { + (Some(linker), Some(flavor)) => Some((linker, flavor)), + // only the linker flavor is known; use the default linker for the selected flavor + (None, Some(flavor)) => Some((PathBuf::from(match flavor { + LinkerFlavor::Em => if cfg!(windows) { "emcc.bat" } else { "emcc" }, + LinkerFlavor::Gcc => "cc", + LinkerFlavor::Ld => "ld", + LinkerFlavor::Msvc => "link.exe", + LinkerFlavor::Lld(_) => "lld", + }), flavor)), + (Some(linker), None) => { + let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { + sess.fatal("couldn't extract file stem from specified linker"); + }).to_owned(); + + let flavor = if stem == "emcc" { + LinkerFlavor::Em + } else if stem == "gcc" || stem.ends_with("-gcc") { + LinkerFlavor::Gcc + } else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") { + LinkerFlavor::Ld + } else if stem == "link" || stem == "lld-link" { + LinkerFlavor::Msvc + } else if stem == "lld" || stem == "rust-lld" { + LinkerFlavor::Lld(sess.target.target.options.lld_flavor) + } else { + // fall back to the value in the target spec + sess.target.target.linker_flavor + }; + + Some((linker, flavor)) + }, + (None, None) => None, + } + } + + // linker and linker flavor specified via command line have precedence over what the target + // specification specifies + if let Some(ret) = infer_from( + sess, + sess.opts.cg.linker.clone(), + sess.opts.debugging_opts.linker_flavor, + ) { + return ret; + } + + if let Some(ret) = infer_from( + sess, + sess.target.target.options.linker.clone().map(PathBuf::from), + Some(sess.target.target.linker_flavor), + ) { + return ret; + } + + bug!("Not enough information provided to determine how to invoke the linker"); +} + +pub fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &Path) + -> io::Result +{ + // When attempting to spawn the linker we run a risk of blowing out the + // size limits for spawning a new process with respect to the arguments + // we pass on the command line. + // + // Here we attempt to handle errors from the OS saying "your list of + // arguments is too big" by reinvoking the linker again with an `@`-file + // that contains all the arguments. The theory is that this is then + // accepted on all linkers and the linker will read all its options out of + // there instead of looking at the command line. + if !cmd.very_likely_to_exceed_some_spawn_limit() { + match cmd.command().stdout(Stdio::piped()).stderr(Stdio::piped()).spawn() { + Ok(child) => { + let output = child.wait_with_output(); + flush_linked_file(&output, out_filename)?; + return output; + } + Err(ref e) if command_line_too_big(e) => { + info!("command line to linker was too big: {}", e); + } + Err(e) => return Err(e) + } + } + + info!("falling back to passing arguments to linker via an @-file"); + let mut cmd2 = cmd.clone(); + let mut args = String::new(); + for arg in cmd2.take_args() { + args.push_str(&Escape { + arg: arg.to_str().unwrap(), + is_like_msvc: sess.target.target.options.is_like_msvc, + }.to_string()); + args.push_str("\n"); + } + let file = tmpdir.join("linker-arguments"); + let bytes = if sess.target.target.options.is_like_msvc { + let mut out = Vec::with_capacity((1 + args.len()) * 2); + // start the stream with a UTF-16 BOM + for c in iter::once(0xFEFF).chain(args.encode_utf16()) { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + args.into_bytes() + }; + fs::write(&file, &bytes)?; + cmd2.arg(format!("@{}", file.display())); + info!("invoking linker {:?}", cmd2); + let output = cmd2.output(); + flush_linked_file(&output, out_filename)?; + return output; + + #[cfg(unix)] + fn flush_linked_file(_: &io::Result, _: &Path) -> io::Result<()> { + Ok(()) + } + + #[cfg(windows)] + fn flush_linked_file(command_output: &io::Result, out_filename: &Path) + -> io::Result<()> + { + // On Windows, under high I/O load, output buffers are sometimes not flushed, + // even long after process exit, causing nasty, non-reproducible output bugs. + // + // File::sync_all() calls FlushFileBuffers() down the line, which solves the problem. + // + // А full writeup of the original Chrome bug can be found at + // randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/amp + + if let &Ok(ref out) = command_output { + if out.status.success() { + if let Ok(of) = fs::OpenOptions::new().write(true).open(out_filename) { + of.sync_all()?; + } + } + } + + Ok(()) + } + + #[cfg(unix)] + fn command_line_too_big(err: &io::Error) -> bool { + err.raw_os_error() == Some(::libc::E2BIG) + } + + #[cfg(windows)] + fn command_line_too_big(err: &io::Error) -> bool { + const ERROR_FILENAME_EXCED_RANGE: i32 = 206; + err.raw_os_error() == Some(ERROR_FILENAME_EXCED_RANGE) + } + + struct Escape<'a> { + arg: &'a str, + is_like_msvc: bool, + } + + impl<'a> fmt::Display for Escape<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if self.is_like_msvc { + // This is "documented" at + // https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx + // + // Unfortunately there's not a great specification of the + // syntax I could find online (at least) but some local + // testing showed that this seemed sufficient-ish to catch + // at least a few edge cases. + write!(f, "\"")?; + for c in self.arg.chars() { + match c { + '"' => write!(f, "\\{}", c)?, + c => write!(f, "{}", c)?, + } + } + write!(f, "\"")?; + } else { + // This is documented at https://linux.die.net/man/1/ld, namely: + // + // > Options in file are separated by whitespace. A whitespace + // > character may be included in an option by surrounding the + // > entire option in either single or double quotes. Any + // > character (including a backslash) may be included by + // > prefixing the character to be included with a backslash. + // + // We put an argument on each line, so all we need to do is + // ensure the line is interpreted as one whole argument. + for c in self.arg.chars() { + match c { + '\\' | + ' ' => write!(f, "\\{}", c)?, + c => write!(f, "{}", c)?, + } + } + } + Ok(()) + } + } +} + +// # Rust Crate linking +// +// Rust crates are not considered at all when creating an rlib output. All +// dependencies will be linked when producing the final output (instead of +// the intermediate rlib version) +pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + crate_type: config::CrateType, + tmpdir: &Path) { + // All of the heavy lifting has previously been accomplished by the + // dependency_format module of the compiler. This is just crawling the + // output of that module, adding crates as necessary. + // + // Linking to a rlib involves just passing it to the linker (the linker + // will slurp up the object files inside), and linking to a dynamic library + // involves just passing the right -l flag. + + let formats = sess.dependency_formats.borrow(); + let data = formats.get(&crate_type).unwrap(); + + // Invoke get_used_crates to ensure that we get a topological sorting of + // crates. + let deps = &codegen_results.crate_info.used_crates_dynamic; + + // There's a few internal crates in the standard library (aka libcore and + // libstd) which actually have a circular dependence upon one another. This + // currently arises through "weak lang items" where libcore requires things + // like `rust_begin_unwind` but libstd ends up defining it. To get this + // circular dependence to work correctly in all situations we'll need to be + // sure to correctly apply the `--start-group` and `--end-group` options to + // GNU linkers, otherwise if we don't use any other symbol from the standard + // library it'll get discarded and the whole application won't link. + // + // In this loop we're calculating the `group_end`, after which crate to + // pass `--end-group` and `group_start`, before which crate to pass + // `--start-group`. We currently do this by passing `--end-group` after + // the first crate (when iterating backwards) that requires a lang item + // defined somewhere else. Once that's set then when we've defined all the + // necessary lang items we'll pass `--start-group`. + // + // Note that this isn't amazing logic for now but it should do the trick + // for the current implementation of the standard library. + let mut group_end = None; + let mut group_start = None; + let mut end_with = FxHashSet::default(); + let info = &codegen_results.crate_info; + for &(cnum, _) in deps.iter().rev() { + if let Some(missing) = info.missing_lang_items.get(&cnum) { + end_with.extend(missing.iter().cloned()); + if end_with.len() > 0 && group_end.is_none() { + group_end = Some(cnum); + } + } + end_with.retain(|item| info.lang_item_to_crate.get(item) != Some(&cnum)); + if end_with.len() == 0 && group_end.is_some() { + group_start = Some(cnum); + break + } + } + + // If we didn't end up filling in all lang items from upstream crates then + // we'll be filling it in with our crate. This probably means we're the + // standard library itself, so skip this for now. + if group_end.is_some() && group_start.is_none() { + group_end = None; + } + + let mut compiler_builtins = None; + + for &(cnum, _) in deps.iter() { + if group_start == Some(cnum) { + cmd.group_start(); + } + + // We may not pass all crates through to the linker. Some crates may + // appear statically in an existing dylib, meaning we'll pick up all the + // symbols from the dylib. + let src = &codegen_results.crate_info.used_crate_source[&cnum]; + match data[cnum.as_usize() - 1] { + _ if codegen_results.crate_info.profiler_runtime == Some(cnum) => { + add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); + } + _ if codegen_results.crate_info.sanitizer_runtime == Some(cnum) => { + link_sanitizer_runtime(cmd, sess, codegen_results, tmpdir, cnum); + } + // compiler-builtins are always placed last to ensure that they're + // linked correctly. + _ if codegen_results.crate_info.compiler_builtins == Some(cnum) => { + assert!(compiler_builtins.is_none()); + compiler_builtins = Some(cnum); + } + Linkage::NotLinked | + Linkage::IncludedFromDylib => {} + Linkage::Static => { + add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); + } + Linkage::Dynamic => { + add_dynamic_crate(cmd, sess, &src.dylib.as_ref().unwrap().0) + } + } + + if group_end == Some(cnum) { + cmd.group_end(); + } + } + + // compiler-builtins are always placed last to ensure that they're + // linked correctly. + // We must always link the `compiler_builtins` crate statically. Even if it + // was already "included" in a dylib (e.g. `libstd` when `-C prefer-dynamic` + // is used) + if let Some(cnum) = compiler_builtins { + add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); + } + + // Converts a library file-stem into a cc -l argument + fn unlib<'a>(config: &config::Config, stem: &'a str) -> &'a str { + if stem.starts_with("lib") && !config.target.options.is_like_windows { + &stem[3..] + } else { + stem + } + } + + // We must link the sanitizer runtime using -Wl,--whole-archive but since + // it's packed in a .rlib, it contains stuff that are not objects that will + // make the linker error. So we must remove those bits from the .rlib before + // linking it. + fn link_sanitizer_runtime(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + tmpdir: &Path, + cnum: CrateNum) { + let src = &codegen_results.crate_info.used_crate_source[&cnum]; + let cratepath = &src.rlib.as_ref().unwrap().0; + + if sess.target.target.options.is_like_osx { + // On Apple platforms, the sanitizer is always built as a dylib, and + // LLVM will link to `@rpath/*.dylib`, so we need to specify an + // rpath to the library as well (the rpath should be absolute, see + // PR #41352 for details). + // + // FIXME: Remove this logic into librustc_*san once Cargo supports it + let rpath = cratepath.parent().unwrap(); + let rpath = rpath.to_str().expect("non-utf8 component in path"); + cmd.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]); + } + + let dst = tmpdir.join(cratepath.file_name().unwrap()); + let cfg = archive_config(sess, &dst, Some(cratepath)); + let mut archive = ArchiveBuilder::new(cfg); + archive.update_symbols(); + + for f in archive.src_files() { + if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { + archive.remove_file(&f); + continue + } + } + + archive.build(); + + cmd.link_whole_rlib(&dst); + } + + // Adds the static "rlib" versions of all crates to the command line. + // There's a bit of magic which happens here specifically related to LTO and + // dynamic libraries. Specifically: + // + // * For LTO, we remove upstream object files. + // * For dylibs we remove metadata and bytecode from upstream rlibs + // + // When performing LTO, almost(*) all of the bytecode from the upstream + // libraries has already been included in our object file output. As a + // result we need to remove the object files in the upstream libraries so + // the linker doesn't try to include them twice (or whine about duplicate + // symbols). We must continue to include the rest of the rlib, however, as + // it may contain static native libraries which must be linked in. + // + // (*) Crates marked with `#![no_builtins]` don't participate in LTO and + // their bytecode wasn't included. The object files in those libraries must + // still be passed to the linker. + // + // When making a dynamic library, linkers by default don't include any + // object files in an archive if they're not necessary to resolve the link. + // We basically want to convert the archive (rlib) to a dylib, though, so we + // *do* want everything included in the output, regardless of whether the + // linker thinks it's needed or not. As a result we must use the + // --whole-archive option (or the platform equivalent). When using this + // option the linker will fail if there are non-objects in the archive (such + // as our own metadata and/or bytecode). All in all, for rlibs to be + // entirely included in dylibs, we need to remove all non-object files. + // + // Note, however, that if we're not doing LTO or we're not producing a dylib + // (aka we're making an executable), we can just pass the rlib blindly to + // the linker (fast) because it's fine if it's not actually included as + // we're at the end of the dependency chain. + fn add_static_crate(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + tmpdir: &Path, + crate_type: config::CrateType, + cnum: CrateNum) { + let src = &codegen_results.crate_info.used_crate_source[&cnum]; + let cratepath = &src.rlib.as_ref().unwrap().0; + + // See the comment above in `link_staticlib` and `link_rlib` for why if + // there's a static library that's not relevant we skip all object + // files. + let native_libs = &codegen_results.crate_info.native_libraries[&cnum]; + let skip_native = native_libs.iter().any(|lib| { + lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib) + }); + + if (!are_upstream_rust_objects_already_included(sess) || + ignored_for_lto(sess, &codegen_results.crate_info, cnum)) && + crate_type != config::CrateType::Dylib && + !skip_native { + cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath)); + return + } + + let dst = tmpdir.join(cratepath.file_name().unwrap()); + let name = cratepath.file_name().unwrap().to_str().unwrap(); + let name = &name[3..name.len() - 5]; // chop off lib/.rlib + + time(sess, &format!("altering {}.rlib", name), || { + let cfg = archive_config(sess, &dst, Some(cratepath)); + let mut archive = ArchiveBuilder::new(cfg); + archive.update_symbols(); + + let mut any_objects = false; + for f in archive.src_files() { + if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { + archive.remove_file(&f); + continue + } + + let canonical = f.replace("-", "_"); + let canonical_name = name.replace("-", "_"); + + // Look for `.rcgu.o` at the end of the filename to conclude + // that this is a Rust-related object file. + fn looks_like_rust(s: &str) -> bool { + let path = Path::new(s); + let ext = path.extension().and_then(|s| s.to_str()); + if ext != Some(OutputType::Object.extension()) { + return false + } + let ext2 = path.file_stem() + .and_then(|s| Path::new(s).extension()) + .and_then(|s| s.to_str()); + ext2 == Some(RUST_CGU_EXT) + } + + let is_rust_object = + canonical.starts_with(&canonical_name) && + looks_like_rust(&f); + + // If we've been requested to skip all native object files + // (those not generated by the rust compiler) then we can skip + // this file. See above for why we may want to do this. + let skip_because_cfg_say_so = skip_native && !is_rust_object; + + // If we're performing LTO and this is a rust-generated object + // file, then we don't need the object file as it's part of the + // LTO module. Note that `#![no_builtins]` is excluded from LTO, + // though, so we let that object file slide. + let skip_because_lto = are_upstream_rust_objects_already_included(sess) && + is_rust_object && + (sess.target.target.options.no_builtins || + !codegen_results.crate_info.is_no_builtins.contains(&cnum)); + + if skip_because_cfg_say_so || skip_because_lto { + archive.remove_file(&f); + } else { + any_objects = true; + } + } + + if !any_objects { + return + } + archive.build(); + + // If we're creating a dylib, then we need to include the + // whole of each object in our archive into that artifact. This is + // because a `dylib` can be reused as an intermediate artifact. + // + // Note, though, that we don't want to include the whole of a + // compiler-builtins crate (e.g. compiler-rt) because it'll get + // repeatedly linked anyway. + if crate_type == config::CrateType::Dylib && + codegen_results.crate_info.compiler_builtins != Some(cnum) { + cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst)); + } else { + cmd.link_rlib(&fix_windows_verbatim_for_gcc(&dst)); + } + }); + } + + // Same thing as above, but for dynamic crates instead of static crates. + fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) { + // If we're performing LTO, then it should have been previously required + // that all upstream rust dependencies were available in an rlib format. + assert!(!are_upstream_rust_objects_already_included(sess)); + + // Just need to tell the linker about where the library lives and + // what its name is + let parent = cratepath.parent(); + if let Some(dir) = parent { + cmd.include_path(&fix_windows_verbatim_for_gcc(dir)); + } + let filestem = cratepath.file_stem().unwrap().to_str().unwrap(); + cmd.link_rust_dylib(&unlib(&sess.target, filestem), + parent.unwrap_or(Path::new(""))); + } +} + +// # Native library linking +// +// User-supplied library search paths (-L on the command line). These are +// the same paths used to find Rust crates, so some of them may have been +// added already by the previous crate linking code. This only allows them +// to be found at compile time so it is still entirely up to outside +// forces to make sure that library can be found at runtime. +// +// Also note that the native libraries linked here are only the ones located +// in the current crate. Upstream crates with native library dependencies +// may have their native library pulled in above. +pub fn add_local_native_libraries(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults) { + sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, k| { + match k { + PathKind::Framework => { cmd.framework_path(path); } + _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(path)); } + } + }); + + let relevant_libs = codegen_results.crate_info.used_libraries.iter().filter(|l| { + relevant_lib(sess, l) + }); + + let search_path = archive_search_paths(sess); + for lib in relevant_libs { + let name = match lib.name { + Some(ref l) => l, + None => continue, + }; + match lib.kind { + NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), + NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), + NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()), + NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(), + &search_path) + } + } +} + +// Link in all of our upstream crates' native dependencies. Remember that +// all of these upstream native dependencies are all non-static +// dependencies. We've got two cases then: +// +// 1. The upstream crate is an rlib. In this case we *must* link in the +// native dependency because the rlib is just an archive. +// +// 2. The upstream crate is a dylib. In order to use the dylib, we have to +// have the dependency present on the system somewhere. Thus, we don't +// gain a whole lot from not linking in the dynamic dependency to this +// crate as well. +// +// The use case for this is a little subtle. In theory the native +// dependencies of a crate are purely an implementation detail of the crate +// itself, but the problem arises with generic and inlined functions. If a +// generic function calls a native function, then the generic function must +// be instantiated in the target crate, meaning that the native symbol must +// also be resolved in the target crate. +pub fn add_upstream_native_libraries(cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, + crate_type: config::CrateType) { + // Be sure to use a topological sorting of crates because there may be + // interdependencies between native libraries. When passing -nodefaultlibs, + // for example, almost all native libraries depend on libc, so we have to + // make sure that's all the way at the right (liblibc is near the base of + // the dependency chain). + // + // This passes RequireStatic, but the actual requirement doesn't matter, + // we're just getting an ordering of crate numbers, we're not worried about + // the paths. + let formats = sess.dependency_formats.borrow(); + let data = formats.get(&crate_type).unwrap(); + + let crates = &codegen_results.crate_info.used_crates_static; + for &(cnum, _) in crates { + for lib in codegen_results.crate_info.native_libraries[&cnum].iter() { + let name = match lib.name { + Some(ref l) => l, + None => continue, + }; + if !relevant_lib(sess, &lib) { + continue + } + match lib.kind { + NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), + NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), + NativeLibraryKind::NativeStaticNobundle => { + // Link "static-nobundle" native libs only if the crate they originate from + // is being linked statically to the current crate. If it's linked dynamically + // or is an rlib already included via some other dylib crate, the symbols from + // native libs will have already been included in that dylib. + if data[cnum.as_usize() - 1] == Linkage::Static { + cmd.link_staticlib(&name.as_str()) + } + }, + // ignore statically included native libraries here as we've + // already included them when we included the rust library + // previously + NativeLibraryKind::NativeStatic => {} + } + } + } +} + +/// Returns a boolean indicating whether the specified crate should be ignored +/// during LTO. +/// +/// Crates ignored during LTO are not lumped together in the "massive object +/// file" that we create and are linked in their normal rlib states. See +/// comments below for what crates do not participate in LTO. +/// +/// It's unusual for a crate to not participate in LTO. Typically only +/// compiler-specific and unstable crates have a reason to not participate in +/// LTO. +fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool { + // If our target enables builtin function lowering in LLVM then the + // crates providing these functions don't participate in LTO (e.g. + // no_builtins or compiler builtins crates). + !sess.target.target.options.no_builtins && + (info.is_no_builtins.contains(&cnum) || info.compiler_builtins == Some(cnum)) +} + +fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { + match lib.cfg { + Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None), + None => true, + } +} + +fn are_upstream_rust_objects_already_included(sess: &Session) -> bool { + match sess.lto() { + Lto::Fat => true, + Lto::Thin => { + // If we defer LTO to the linker, we haven't run LTO ourselves, so + // any upstream object files have not been copied yet. + !sess.opts.debugging_opts.cross_lang_lto.enabled() + } + Lto::No | + Lto::ThinLocal => false, + } +} From 29e1d617d41f53c22989ec4b54624b582bf37057 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Nov 2018 11:37:59 +0100 Subject: [PATCH 0338/1566] Remove commented out code --- src/lib.rs | 10 ---------- src/link.rs | 14 -------------- 2 files changed, 24 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fdfa0d1d78707..f5415584eff0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -404,16 +404,6 @@ impl CodegenBackend for CraneliftCodegenBackend { let obj = artifact.emit().unwrap(); std::fs::write(&tmp_file, obj).unwrap(); - /*use rustc_mir::monomorphize::partitioning::CodegenUnitExt; - - let dep_node = tcx.codegen_unit(cgu_name).codegen_dep_node(tcx); - let ((stats, module), _) = tcx.dep_graph.with_task( - dep_node, - tcx, - cgu_name, - module_codegen, - );*/ - return Box::new(CodegenResults { artifact, metadata: metadata.raw_data, diff --git a/src/link.rs b/src/link.rs index 1335b209f8c58..5fccac4712380 100644 --- a/src/link.rs +++ b/src/link.rs @@ -253,20 +253,6 @@ pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_fil } } -/* -res.artifact - .declare_with( - &metadata_name, - faerie::artifact::Decl::Data { - global: true, - writable: false, - }, - res.metadata.clone(), - ) - .unwrap(); -*/ - - fn link_args(cmd: &mut dyn Linker, flavor: LinkerFlavor, sess: &Session, From 27d90ab1d56fb9727f5f1fd5673c8845abca97cd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 12 Nov 2018 07:20:25 -0800 Subject: [PATCH 0339/1566] Change "cretonne" to "cranelift". --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 3bf906a460c2b..c51bf3be41e65 100644 --- a/src/base.rs +++ b/src/base.rs @@ -149,7 +149,7 @@ fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Fu err, ); tcx.sess - .fatal(&format!("cretonne verify error:\n{}", pretty_error)); + .fatal(&format!("cranelift verify error:\n{}", pretty_error)); } } } From 7b5f4894f18a04042a652e4a25503f46aacfadb4 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 12 Nov 2018 07:23:39 -0800 Subject: [PATCH 0340/1566] Change "cton" to "clif". --- src/abi.rs | 28 +++++++++++++-------------- src/analyze.rs | 2 +- src/base.rs | 48 +++++++++++++++++++++++------------------------ src/common.rs | 22 +++++++++++----------- src/intrinsics.rs | 8 ++++---- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index f42707b5f80d1..597e288d6033d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -16,7 +16,7 @@ impl PassMode { fn get_param_ty(self, fx: &FunctionCx) -> Type { match self { PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(cton_type) => cton_type, + PassMode::ByVal(clif_type) => clif_type, PassMode::ByRef => fx.pointer_type, } } @@ -44,7 +44,7 @@ fn get_pass_mode<'a, 'tcx: 'a>( } else { PassMode::ByRef } - } else if let Some(ret_ty) = crate::common::cton_type_from_ty(tcx, ty) { + } else if let Some(ret_ty) = crate::common::clif_type_from_ty(tcx, ty) { PassMode::ByVal(ret_ty) } else { if abi == Abi::C { @@ -70,7 +70,7 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( } } -pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( +pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>, ) -> Signature { @@ -97,7 +97,7 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>( let inputs = inputs .into_iter() .filter_map(|ty| match get_pass_mode(tcx, sig.abi, ty, false) { - PassMode::ByVal(cton_ty) => Some(cton_ty), + PassMode::ByVal(clif_ty) => Some(clif_ty), PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByRef => Some(pointer_ty(tcx)), }); @@ -178,7 +178,7 @@ pub fn get_function_name_and_sig<'a, 'tcx>( ) -> (String, Signature) { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_ty = inst.ty(tcx); - let sig = cton_sig_from_fn_ty(tcx, fn_ty); + let sig = clif_sig_from_fn_ty(tcx, fn_ty); (tcx.symbol_name(inst).as_str().to_string(), sig) } @@ -238,7 +238,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { .into_iter() .map(|arg| { ( - self.cton_type(arg.layout().ty).unwrap(), + self.clif_type(arg.layout().ty).unwrap(), arg.load_value(self), ) }) @@ -250,7 +250,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } None } else { - Some(self.cton_type(return_ty).unwrap()) + Some(self.clif_type(return_ty).unwrap()) }; if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { CValue::ByVal(val, return_layout) @@ -307,18 +307,18 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let mut ebb_params = Vec::new(); for arg_ty in tupled_arg_tys.iter() { - let cton_type = + let clif_type = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); - ebb_params.push(fx.bcx.append_ebb_param(start_ebb, cton_type)); + ebb_params.push(fx.bcx.append_ebb_param(start_ebb, clif_type)); } (local, ArgKind::Spread(ebb_params), arg_ty) } else { - let cton_type = + let clif_type = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); ( local, - ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, cton_type)), + ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, clif_type)), arg_ty, ) } @@ -368,7 +368,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( .contains(crate::analyze::Flags::NOT_SSA) { fx.bcx - .declare_var(mir_var(local), fx.cton_type(ty).unwrap()); + .declare_var(mir_var(local), fx.clif_type(ty).unwrap()); match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(_) => fx.bcx.def_var(mir_var(local), ebb_param), @@ -434,7 +434,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( CPlace::from_stack_slot(fx, stack_slot, ty) } else { fx.bcx - .declare_var(mir_var(local), fx.cton_type(ty).unwrap()); + .declare_var(mir_var(local), fx.clif_type(ty).unwrap()); CPlace::Var(local, layout) }; @@ -568,7 +568,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( ) .collect::>(); - let sig = fx.bcx.import_signature(cton_sig_from_fn_ty(fx.tcx, fn_ty)); + let sig = fx.bcx.import_signature(clif_sig_from_fn_ty(fx.tcx, fn_ty)); let call_inst = if let Some(func_ref) = func_ref { fx.bcx.ins().call_indirect(sig, func_ref, &call_args) } else { diff --git a/src/analyze.rs b/src/analyze.rs index bdb40411ffa26..025fc1fecba67 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -18,7 +18,7 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap not_ssa(&mut flag_map, RETURN_PLACE); for (local, local_decl) in fx.mir.local_decls.iter_enumerated() { - if fx.cton_type(local_decl.ty).is_none() { + if fx.clif_type(local_decl.ty).is_none() { not_ssa(&mut flag_map, local); } } diff --git a/src/base.rs b/src/base.rs index c51bf3be41e65..00e80dfa8ca46 100644 --- a/src/base.rs +++ b/src/base.rs @@ -110,9 +110,9 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 7. Write function to file for debugging let mut writer = crate::pretty_clif::CommentWriter(fx.comments); - let mut cton = String::new(); + let mut clif = String::new(); if cfg!(debug_assertions) { - ::cranelift::codegen::write::decorate_function(&mut writer, &mut cton, &func, None) + ::cranelift::codegen::write::decorate_function(&mut writer, &mut clif, &func, None) .unwrap(); let clif_file_name = format!( "{}/{}__{}.clif", @@ -120,7 +120,7 @@ fn trans_fn<'a, 'tcx: 'a>( tcx.crate_name(LOCAL_CRATE), tcx.symbol_name(instance).as_str(), ); - if let Err(e) = ::std::fs::write(clif_file_name, cton.as_bytes()) { + if let Err(e) = ::std::fs::write(clif_file_name, clif.as_bytes()) { tcx.sess.warn(&format!("err writing clif file: {:?}", e)); } } @@ -452,7 +452,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } UnOp::Neg => match layout.ty.sty { ty::Int(_) => { - let clif_ty = fx.cton_type(layout.ty).unwrap(); + let clif_ty = fx.clif_type(layout.ty).unwrap(); let zero = fx.bcx.ins().iconst(clif_ty, 0); fx.bcx.ins().isub(zero, val) } @@ -495,20 +495,20 @@ fn trans_stmt<'a, 'tcx: 'a>( | (ty::Uint(_), ty::Int(_)) | (ty::Uint(_), ty::Uint(_)) => { let from = operand.load_value(fx); - let res = crate::common::cton_intcast( + let res = crate::common::clif_intcast( fx, from, - fx.cton_type(to_ty).unwrap(), + fx.clif_type(to_ty).unwrap(), false, ); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Int(_), ty::Int(_)) | (ty::Int(_), ty::Uint(_)) => { let from = operand.load_value(fx); - let res = crate::common::cton_intcast( + let res = crate::common::clif_intcast( fx, from, - fx.cton_type(to_ty).unwrap(), + fx.clif_type(to_ty).unwrap(), true, ); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); @@ -527,7 +527,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Int(_), ty::Float(_)) => { - let from_ty = fx.cton_type(from_ty).unwrap(); + let from_ty = fx.clif_type(from_ty).unwrap(); let from = operand.load_value(fx); // FIXME missing encoding for fcvt_from_sint.f32.i8 let from = if from_ty == types::I8 || from_ty == types::I16 { @@ -535,12 +535,12 @@ fn trans_stmt<'a, 'tcx: 'a>( } else { from }; - let f_type = fx.cton_type(to_ty).unwrap(); + let f_type = fx.clif_type(to_ty).unwrap(); let res = fx.bcx.ins().fcvt_from_sint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Uint(_), ty::Float(_)) => { - let from_ty = fx.cton_type(from_ty).unwrap(); + let from_ty = fx.clif_type(from_ty).unwrap(); let from = operand.load_value(fx); // FIXME missing encoding for fcvt_from_uint.f32.i8 let from = if from_ty == types::I8 || from_ty == types::I16 { @@ -548,12 +548,12 @@ fn trans_stmt<'a, 'tcx: 'a>( } else { from }; - let f_type = fx.cton_type(to_ty).unwrap(); + let f_type = fx.clif_type(to_ty).unwrap(); let res = fx.bcx.ins().fcvt_from_uint(f_type, from); lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Bool, ty::Uint(_)) | (ty::Bool, ty::Int(_)) => { - let to_ty = fx.cton_type(to_ty).unwrap(); + let to_ty = fx.clif_type(to_ty).unwrap(); let from = operand.load_value(fx); let res = if to_ty != types::I8 { fx.bcx.ins().uextend(to_ty, from) @@ -605,7 +605,7 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::NullaryOp(NullOp::Box, content_ty) => { use rustc::middle::lang_items::ExchangeMallocFnLangItem; - let usize_type = fx.cton_type(fx.tcx.types.usize).unwrap(); + let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); let (size, align) = fx.layout_of(content_ty).size_and_align(); let llsize = fx.bcx.ins().iconst(usize_type, size.bytes() as i64); let llalign = fx.bcx.ins().iconst(usize_type, align.abi() as i64); @@ -690,7 +690,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( layout::Int(_, signed) => signed, _ => false, }; - let val = cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), signed); + let val = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), signed); return CValue::ByVal(val, dest_layout); } layout::Variants::NicheFilling { @@ -699,8 +699,8 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( niche_start, .. } => { - let niche_llty = fx.cton_type(discr_ty).unwrap(); - let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap(); + let niche_llty = fx.clif_type(discr_ty).unwrap(); + let dest_clif_ty = fx.clif_type(dest_layout.ty).unwrap(); if niche_variants.start() == niche_variants.end() { let b = fx .bcx @@ -709,11 +709,11 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let if_true = fx .bcx .ins() - .iconst(dest_cton_ty, *niche_variants.start() as u64 as i64); + .iconst(dest_clif_ty, *niche_variants.start() as u64 as i64); let if_false = fx .bcx .ins() - .iconst(dest_cton_ty, dataful_variant as u64 as i64); + .iconst(dest_clif_ty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } else { @@ -727,11 +727,11 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( *niche_variants.end() as u64 as i64, ); let if_true = - cton_intcast(fx, lldiscr, fx.cton_type(dest_layout.ty).unwrap(), false); + clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false); let if_false = fx .bcx .ins() - .iconst(dest_cton_ty, dataful_variant as u64 as i64); + .iconst(dest_clif_ty, dataful_variant as u64 as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } @@ -748,10 +748,10 @@ macro_rules! binop_match { let ret_layout = $fx.layout_of($ret_ty); // TODO HACK no encoding for icmp.i8 - use crate::common::cton_intcast; + use crate::common::clif_intcast; let (lhs, rhs) = ( - cton_intcast($fx, $lhs, types::I64, $signed), - cton_intcast($fx, $rhs, types::I64, $signed), + clif_intcast($fx, $lhs, types::I64, $signed), + clif_intcast($fx, $rhs, types::I64, $signed), ); let b = $fx.bcx.ins().icmp(IntCC::$cc, lhs, rhs); diff --git a/src/common.rs b/src/common.rs index 848f66a48d2bb..d024cb49e4fba 100644 --- a/src/common.rs +++ b/src/common.rs @@ -19,7 +19,7 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } } -fn scalar_to_cton_type(tcx: TyCtxt, scalar: &Scalar) -> Type { +fn scalar_to_clif_type(tcx: TyCtxt, scalar: &Scalar) -> Type { match scalar.value.size(&tcx).bits() { 8 => types::I8, 16 => types::I16, @@ -29,7 +29,7 @@ fn scalar_to_cton_type(tcx: TyCtxt, scalar: &Scalar) -> Type { } } -pub fn cton_type_from_ty<'a, 'tcx: 'a>( +pub fn clif_type_from_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>, ) -> Option { @@ -157,7 +157,7 @@ impl<'tcx> CValue<'tcx> { { match self { CValue::ByRef(addr, layout) => { - let cton_ty = fx.cton_type(layout.ty).unwrap_or_else(|| { + let clif_ty = fx.clif_type(layout.ty).unwrap_or_else(|| { if layout.ty.is_box() && !fx .layout_of(layout.ty.builtin_deref(true).unwrap().ty) @@ -169,7 +169,7 @@ impl<'tcx> CValue<'tcx> { panic!("load_value of type {:?}", layout.ty); } }); - fx.bcx.ins().load(cton_ty, MemFlags::new(), addr, 0) + fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, CValue::ByValPair(_, _, _layout) => bug!("Please use load_value_pair for ByValPair"), @@ -294,9 +294,9 @@ impl<'tcx> CValue<'tcx> { where 'tcx: 'a, { - let cton_ty = fx.cton_type(ty).unwrap(); + let clif_ty = fx.clif_type(ty).unwrap(); let layout = fx.layout_of(ty); - CValue::ByVal(fx.bcx.ins().iconst(cton_ty, const_val), layout) + CValue::ByVal(fx.bcx.ins().iconst(clif_ty, const_val), layout) } pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { @@ -506,9 +506,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let ptr = fx.bcx .ins() - .load(scalar_to_cton_type(fx.tcx, a), MemFlags::new(), addr, 0); + .load(scalar_to_clif_type(fx.tcx, a), MemFlags::new(), addr, 0); let extra = fx.bcx.ins().load( - scalar_to_cton_type(fx.tcx, b), + scalar_to_clif_type(fx.tcx, b), MemFlags::new(), addr, a.value.size(&fx.tcx).bytes() as u32 as i32, @@ -567,7 +567,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } -pub fn cton_intcast<'a, 'tcx: 'a>( +pub fn clif_intcast<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, val: Value, to: Type, @@ -664,8 +664,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { ) } - pub fn cton_type(&self, ty: Ty<'tcx>) -> Option { - cton_type_from_ty(self.tcx, self.monomorphize(&ty)) + pub fn clif_type(&self, ty: Ty<'tcx>) -> Option { + clif_type_from_ty(self.tcx, self.monomorphize(&ty)) } pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 3926a6b05adf6..427ed7c1e5da6 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -59,7 +59,7 @@ macro_rules! intrinsic_match { macro_rules! atomic_binop_return_old { ($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) => { - let clif_ty = $fx.cton_type($T).unwrap(); + let clif_ty = $fx.clif_type($T).unwrap(); let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); let new = $fx.bcx.ins().band(old, $src); $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); @@ -70,7 +70,7 @@ macro_rules! atomic_binop_return_old { macro_rules! atomic_minmax { ($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ret:ident) => { // Read old - let clif_ty = $fx.cton_type($T).unwrap(); + let clif_ty = $fx.clif_type($T).unwrap(); let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); // Compare @@ -362,7 +362,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; _ if intrinsic.starts_with("atomic_xchg"), (v ptr, c src) { // Read old - let clif_ty = fx.cton_type(T).unwrap(); + let clif_ty = fx.clif_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(T))); @@ -372,7 +372,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; _ if intrinsic.starts_with("atomic_cxchg"), (v ptr, v test_old, v new) { // both atomic_cxchg_* and atomic_cxchgweak_* // Read old - let clif_ty = fx.cton_type(T).unwrap(); + let clif_ty = fx.clif_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); // Compare From 1fb6912cfd07812b106ad4e1bf9705a57b6f0ef6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 12 Nov 2018 19:37:54 +0100 Subject: [PATCH 0341/1566] Rustup to rustc 1.32.0-nightly (ca79ecd69 2018-11-11) I had to put the original source of liballoc_system in tree, because it got removed from rustc --- 0001-Disable-stdsimd.patch | 22 +-- alloc_system/Cargo.toml | 16 ++ alloc_system/lib.rs | 365 +++++++++++++++++++++++++++++++++++++ prepare_libcore.sh | 7 +- xargo/Xargo.toml | 2 +- 5 files changed, 399 insertions(+), 13 deletions(-) create mode 100644 alloc_system/Cargo.toml create mode 100644 alloc_system/lib.rs diff --git a/0001-Disable-stdsimd.patch b/0001-Disable-stdsimd.patch index cd299b3f334fd..bdd3615d6e4f6 100644 --- a/0001-Disable-stdsimd.patch +++ b/0001-Disable-stdsimd.patch @@ -1,6 +1,6 @@ -From 17e82251ba8f36149c03aee327de8b4054e6c88e Mon Sep 17 00:00:00 2001 +From fd6acae580c2be9e8ba9c32b013df4e9547d936f Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 6 Oct 2018 11:07:31 +0200 +Date: Mon, 12 Nov 2018 19:08:45 +0100 Subject: [PATCH] Disable stdsimd --- @@ -9,35 +9,35 @@ Subject: [PATCH] Disable stdsimd 2 files changed, 4 insertions(+) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 0211b05..cd224f1 100644 +index c69d444..1b7abad 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -226,6 +226,7 @@ mod nonzero; +@@ -228,6 +228,7 @@ mod nonzero; mod tuple; mod unit; +/* - // Pull in the the `coresimd` crate directly into libcore. This is where all the + // Pull in the `coresimd` crate directly into libcore. This is where all the // architecture-specific (and vendor-specific) intrinsics are defined. AKA // things like SIMD and such. Note that the actual source for all this lies in a -@@ -254,3 +255,4 @@ mod coresimd; +@@ -256,3 +257,4 @@ mod coresimd; #[stable(feature = "simd_arch", since = "1.27.0")] #[cfg(not(stage0))] pub use coresimd::arch; +*/ diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index c58bd36..4768e8b 100644 +index f460d10..6110b05 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -501,6 +501,7 @@ mod memchr; +@@ -493,6 +493,7 @@ mod memchr; // compiler pub mod rt; +/* - // Pull in the the `stdsimd` crate directly into libstd. This is the same as + // Pull in the `stdsimd` crate directly into libstd. This is the same as // libcore's arch/simd modules where the source of truth here is in a different // repository, but we pull things in here manually to get it into libstd. -@@ -525,6 +526,7 @@ mod coresimd { +@@ -517,6 +518,7 @@ mod coresimd { #[stable(feature = "simd_arch", since = "1.27.0")] #[cfg(all(not(stage0), not(test)))] pub use stdsimd::arch; @@ -46,5 +46,5 @@ index c58bd36..4768e8b 100644 // Include a number of private modules that exist solely to provide // the rustdoc documentation for primitive types. Using `include!` -- -2.17.1 (Apple Git-112) +2.11.0 diff --git a/alloc_system/Cargo.toml b/alloc_system/Cargo.toml new file mode 100644 index 0000000000000..ae146c48e3aac --- /dev/null +++ b/alloc_system/Cargo.toml @@ -0,0 +1,16 @@ +[package] +authors = ["The Rust Project Developers", "bjorn3 (edited to be usable outside the rust source)"] +name = "alloc_system" +version = "0.0.0" +[lib] +name = "alloc_system" +path = "lib.rs" +test = false +doc = false +[dependencies] +core = { path = "../libcore" } +libc = { path = "../rustc/libc_shim" } +compiler_builtins = { path = "../rustc/compiler_builtins_shim" } +# See comments in the source for what this dependency is +[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] +dlmalloc = { path = "../rustc/dlmalloc_shim" } diff --git a/alloc_system/lib.rs b/alloc_system/lib.rs new file mode 100644 index 0000000000000..74b52a6497e17 --- /dev/null +++ b/alloc_system/lib.rs @@ -0,0 +1,365 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![no_std] +#![allow(unused_attributes)] +#![unstable(feature = "alloc_system", + reason = "this library is unlikely to be stabilized in its current \ + form or name", + issue = "32838")] +#![feature(allocator_api)] +#![feature(core_intrinsics)] +#![feature(nll)] +#![feature(staged_api)] +#![feature(rustc_attrs)] +#![cfg_attr( + all(target_arch = "wasm32", not(target_os = "emscripten")), + feature(integer_atomics, stdsimd) +)] +#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] +#![rustc_alloc_kind = "lib"] +// The minimum alignment guaranteed by the architecture. This value is used to +// add fast paths for low alignment values. +#[cfg(all(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "asmjs", + target_arch = "wasm32")))] +#[allow(dead_code)] +const MIN_ALIGN: usize = 8; +#[cfg(all(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")))] +#[allow(dead_code)] +const MIN_ALIGN: usize = 16; +use core::alloc::{Alloc, GlobalAlloc, AllocErr, Layout}; +use core::ptr::NonNull; +/// The default memory allocator provided by the operating system. +/// +/// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows, +/// plus related functions. +/// +/// This type can be used in a `static` item +/// with the `#[global_allocator]` attribute +/// to force the global allocator to be the system’s one. +/// (The default is jemalloc for executables, on some platforms.) +/// +/// ```rust +/// use std::alloc::System; +/// +/// #[global_allocator] +/// static A: System = System; +/// +/// fn main() { +/// let a = Box::new(4); // Allocates from the system allocator. +/// println!("{}", a); +/// } +/// ``` +/// +/// It can also be used directly to allocate memory +/// independently of the standard library’s global allocator. +#[stable(feature = "alloc_system_type", since = "1.28.0")] +pub struct System; +#[unstable(feature = "allocator_api", issue = "32838")] +unsafe impl Alloc for System { + #[inline] + unsafe fn alloc(&mut self, layout: Layout) -> Result, AllocErr> { + NonNull::new(GlobalAlloc::alloc(self, layout)).ok_or(AllocErr) + } + #[inline] + unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result, AllocErr> { + NonNull::new(GlobalAlloc::alloc_zeroed(self, layout)).ok_or(AllocErr) + } + #[inline] + unsafe fn dealloc(&mut self, ptr: NonNull, layout: Layout) { + GlobalAlloc::dealloc(self, ptr.as_ptr(), layout) + } + #[inline] + unsafe fn realloc(&mut self, + ptr: NonNull, + layout: Layout, + new_size: usize) -> Result, AllocErr> { + NonNull::new(GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size)).ok_or(AllocErr) + } +} +#[cfg(any(windows, unix, target_os = "cloudabi", target_os = "redox"))] +mod realloc_fallback { + use core::alloc::{GlobalAlloc, Layout}; + use core::cmp; + use core::ptr; + impl super::System { + pub(crate) unsafe fn realloc_fallback(&self, ptr: *mut u8, old_layout: Layout, + new_size: usize) -> *mut u8 { + // Docs for GlobalAlloc::realloc require this to be valid: + let new_layout = Layout::from_size_align_unchecked(new_size, old_layout.align()); + let new_ptr = GlobalAlloc::alloc(self, new_layout); + if !new_ptr.is_null() { + let size = cmp::min(old_layout.size(), new_size); + ptr::copy_nonoverlapping(ptr, new_ptr, size); + GlobalAlloc::dealloc(self, ptr, old_layout); + } + new_ptr + } + } +} +#[cfg(any(unix, target_os = "cloudabi", target_os = "redox"))] +mod platform { + extern crate libc; + use core::ptr; + use MIN_ALIGN; + use System; + use core::alloc::{GlobalAlloc, Layout}; + #[stable(feature = "alloc_system_type", since = "1.28.0")] + unsafe impl GlobalAlloc for System { + #[inline] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { + libc::malloc(layout.size()) as *mut u8 + } else { + #[cfg(target_os = "macos")] + { + if layout.align() > (1 << 31) { + return ptr::null_mut() + } + } + aligned_malloc(&layout) + } + } + #[inline] + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { + libc::calloc(layout.size(), 1) as *mut u8 + } else { + let ptr = self.alloc(layout.clone()); + if !ptr.is_null() { + ptr::write_bytes(ptr, 0, layout.size()); + } + ptr + } + } + #[inline] + unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { + libc::free(ptr as *mut libc::c_void) + } + #[inline] + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + if layout.align() <= MIN_ALIGN && layout.align() <= new_size { + libc::realloc(ptr as *mut libc::c_void, new_size) as *mut u8 + } else { + self.realloc_fallback(ptr, layout, new_size) + } + } + } + #[cfg(any(target_os = "android", + target_os = "hermit", + target_os = "redox", + target_os = "solaris"))] + #[inline] + unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 { + // On android we currently target API level 9 which unfortunately + // doesn't have the `posix_memalign` API used below. Instead we use + // `memalign`, but this unfortunately has the property on some systems + // where the memory returned cannot be deallocated by `free`! + // + // Upon closer inspection, however, this appears to work just fine with + // Android, so for this platform we should be fine to call `memalign` + // (which is present in API level 9). Some helpful references could + // possibly be chromium using memalign [1], attempts at documenting that + // memalign + free is ok [2] [3], or the current source of chromium + // which still uses memalign on android [4]. + // + // [1]: https://codereview.chromium.org/10796020/ + // [2]: https://code.google.com/p/android/issues/detail?id=35391 + // [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=138579 + // [4]: https://chromium.googlesource.com/chromium/src/base/+/master/ + // /memory/aligned_memory.cc + libc::memalign(layout.align(), layout.size()) as *mut u8 + } + #[cfg(not(any(target_os = "android", + target_os = "hermit", + target_os = "redox", + target_os = "solaris")))] + #[inline] + unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 { + let mut out = ptr::null_mut(); + let ret = libc::posix_memalign(&mut out, layout.align(), layout.size()); + if ret != 0 { + ptr::null_mut() + } else { + out as *mut u8 + } + } +} +#[cfg(windows)] +#[allow(nonstandard_style)] +mod platform { + use MIN_ALIGN; + use System; + use core::alloc::{GlobalAlloc, Layout}; + type LPVOID = *mut u8; + type HANDLE = LPVOID; + type SIZE_T = usize; + type DWORD = u32; + type BOOL = i32; + extern "system" { + fn GetProcessHeap() -> HANDLE; + fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID; + fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID; + fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL; + fn GetLastError() -> DWORD; + } + #[repr(C)] + struct Header(*mut u8); + const HEAP_ZERO_MEMORY: DWORD = 0x00000008; + unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header { + &mut *(ptr as *mut Header).offset(-1) + } + unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 { + let aligned = ptr.add(align - (ptr as usize & (align - 1))); + *get_header(aligned) = Header(ptr); + aligned + } + #[inline] + unsafe fn allocate_with_flags(layout: Layout, flags: DWORD) -> *mut u8 { + let ptr = if layout.align() <= MIN_ALIGN { + HeapAlloc(GetProcessHeap(), flags, layout.size()) + } else { + let size = layout.size() + layout.align(); + let ptr = HeapAlloc(GetProcessHeap(), flags, size); + if ptr.is_null() { + ptr + } else { + align_ptr(ptr, layout.align()) + } + }; + ptr as *mut u8 + } + #[stable(feature = "alloc_system_type", since = "1.28.0")] + unsafe impl GlobalAlloc for System { + #[inline] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + allocate_with_flags(layout, 0) + } + #[inline] + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + allocate_with_flags(layout, HEAP_ZERO_MEMORY) + } + #[inline] + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + if layout.align() <= MIN_ALIGN { + let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID); + debug_assert!(err != 0, "Failed to free heap memory: {}", + GetLastError()); + } else { + let header = get_header(ptr); + let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID); + debug_assert!(err != 0, "Failed to free heap memory: {}", + GetLastError()); + } + } + #[inline] + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + if layout.align() <= MIN_ALIGN { + HeapReAlloc(GetProcessHeap(), 0, ptr as LPVOID, new_size) as *mut u8 + } else { + self.realloc_fallback(ptr, layout, new_size) + } + } + } +} +// This is an implementation of a global allocator on the wasm32 platform when +// emscripten is not in use. In that situation there's no actual runtime for us +// to lean on for allocation, so instead we provide our own! +// +// The wasm32 instruction set has two instructions for getting the current +// amount of memory and growing the amount of memory. These instructions are the +// foundation on which we're able to build an allocator, so we do so! Note that +// the instructions are also pretty "global" and this is the "global" allocator +// after all! +// +// The current allocator here is the `dlmalloc` crate which we've got included +// in the rust-lang/rust repository as a submodule. The crate is a port of +// dlmalloc.c from C to Rust and is basically just so we can have "pure Rust" +// for now which is currently technically required (can't link with C yet). +// +// The crate itself provides a global allocator which on wasm has no +// synchronization as there are no threads! +#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] +mod platform { + extern crate dlmalloc; + use core::alloc::{GlobalAlloc, Layout}; + use System; + static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::DLMALLOC_INIT; + #[stable(feature = "alloc_system_type", since = "1.28.0")] + unsafe impl GlobalAlloc for System { + #[inline] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + let _lock = lock::lock(); + DLMALLOC.malloc(layout.size(), layout.align()) + } + #[inline] + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + let _lock = lock::lock(); + DLMALLOC.calloc(layout.size(), layout.align()) + } + #[inline] + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + let _lock = lock::lock(); + DLMALLOC.free(ptr, layout.size(), layout.align()) + } + #[inline] + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + let _lock = lock::lock(); + DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) + } + } + #[cfg(target_feature = "atomics")] + mod lock { + use core::arch::wasm32; + use core::sync::atomic::{AtomicI32, Ordering::SeqCst}; + static LOCKED: AtomicI32 = AtomicI32::new(0); + pub struct DropLock; + pub fn lock() -> DropLock { + loop { + if LOCKED.swap(1, SeqCst) == 0 { + return DropLock + } + unsafe { + let r = wasm32::atomic::wait_i32( + &LOCKED as *const AtomicI32 as *mut i32, + 1, // expected value + -1, // timeout + ); + debug_assert!(r == 0 || r == 1); + } + } + } + impl Drop for DropLock { + fn drop(&mut self) { + let r = LOCKED.swap(0, SeqCst); + debug_assert_eq!(r, 1); + unsafe { + wasm32::atomic::wake( + &LOCKED as *const AtomicI32 as *mut i32, + 1, // only one thread + ); + } + } + } + } + #[cfg(not(target_feature = "atomics"))] + mod lock { + #[inline] + pub fn lock() {} // no atomics, no threads, that's easy! + } +} diff --git a/prepare_libcore.sh b/prepare_libcore.sh index 409b7845238a4..ce13f80816f80 100755 --- a/prepare_libcore.sh +++ b/prepare_libcore.sh @@ -13,10 +13,15 @@ rm -rf $DST_DIR mkdir -p $DST_DIR/src cp -r $SRC_DIR/src $DST_DIR/ -cd $DST_DIR +pushd $DST_DIR git init git add . git commit -m "Initial commit" -q git apply ../../000*.patch +popd + +# `alloc_system` has been merged with libstd, which doesn't build yet. +# This copies the original source to the sysroot source dir to simplify building it +cp -r alloc_system $DST_DIR/src/liballoc_system echo "Successfully prepared libcore for building" diff --git a/xargo/Xargo.toml b/xargo/Xargo.toml index 57feaa9000870..2fef2be4c0283 100644 --- a/xargo/Xargo.toml +++ b/xargo/Xargo.toml @@ -4,4 +4,4 @@ alloc = {} alloc_system = {} # Disabled due to missing support for many things (intrinsics, etc) in rustc_codegen_cranelift -#std = {features = ["force_alloc_system"]} +#std = {} From a3263bafe0543cb72749cb03de61f26ba1ea4f19 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Nov 2018 17:58:42 +0100 Subject: [PATCH 0342/1566] Change some unimplemented! to unimpl! --- src/abi.rs | 4 +++- src/base.rs | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 597e288d6033d..e50aa9ff63d48 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -75,7 +75,9 @@ pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( fn_ty: Ty<'tcx>, ) -> Signature { let sig = ty_fn_sig(tcx, fn_ty); - assert!(!sig.variadic, "Variadic function are not yet supported"); + if sig.variadic { + unimpl!("Variadic function are not yet supported"); + } let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::Fast, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), diff --git a/src/base.rs b/src/base.rs index 00e80dfa8ca46..3f0222ca6ae31 100644 --- a/src/base.rs +++ b/src/base.rs @@ -264,7 +264,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) drop_place.write_place_ref(fx, arg_place); match ty.sty { ty::Dynamic(..) => { - unimplemented!("Drop for trait object"); + unimpl!("Drop for trait object"); } _ => { let drop_fn_ty = drop_fn.ty(fx.tcx); @@ -1061,7 +1061,7 @@ pub fn trans_place<'a, 'tcx: 'a>( offset, min_length: _, from_end: false, - } => unimplemented!( + } => unimpl!( "projection const index {:?} offset {:?} not from end", projection.base, offset @@ -1070,12 +1070,12 @@ pub fn trans_place<'a, 'tcx: 'a>( offset, min_length: _, from_end: true, - } => unimplemented!( + } => unimpl!( "projection const index {:?} offset {:?} from end", projection.base, offset ), - ProjectionElem::Subslice { from, to } => unimplemented!( + ProjectionElem::Subslice { from, to } => unimpl!( "projection subslice {:?} from {} to {}", projection.base, from, From e5ab49e76251a2c4075f331a47c8d450592b65b3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Nov 2018 18:25:21 +0100 Subject: [PATCH 0343/1566] Rustup to rustc 1.32.0-nightly (65204a97d 2018-11-12) --- 0002-Disable-u128-and-i128-in-libcore.patch | 74 ++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/0002-Disable-u128-and-i128-in-libcore.patch index 8b837400468bf..a8f2005a64c6c 100644 --- a/0002-Disable-u128-and-i128-in-libcore.patch +++ b/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,27 +1,27 @@ -From 13b3aab50eec5bd0ae22ebb76eba4d0ccb90ae14 Mon Sep 17 00:00:00 2001 +From 7a466d258ff8c795fa52274e0627a39becb3bdf3 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 10 Nov 2018 10:49:26 +0100 +Date: Tue, 13 Nov 2018 18:11:23 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- src/libcore/clone.rs | 4 +- - src/libcore/cmp.rs | 6 +- + src/libcore/cmp.rs | 6 +-- src/libcore/default.rs | 2 - - src/libcore/fmt/num.rs | 6 +- - src/libcore/hash/mod.rs | 20 ------ + src/libcore/fmt/num.rs | 6 +-- + src/libcore/hash/mod.rs | 20 ------- src/libcore/iter/range.rs | 1 - src/libcore/iter/traits.rs | 2 +- src/libcore/lib.rs | 2 - src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 99 ++++++++------------------- - src/libcore/num/wrapping.rs | 14 ++-- - src/libcore/ops/arith.rs | 22 +++--- - src/libcore/ops/bit.rs | 30 +++------ - src/libcore/sync/atomic.rs | 28 -------- - src/libcore/tests/iter.rs | 15 ----- - src/libcore/tests/num/mod.rs | 18 ----- - src/libcore/time.rs | 126 ----------------------------------- + src/libcore/num/mod.rs | 99 +++++++++------------------------- + src/libcore/num/wrapping.rs | 14 ++--- + src/libcore/ops/arith.rs | 22 ++++---- + src/libcore/ops/bit.rs | 30 ++++------- + src/libcore/sync/atomic.rs | 28 ---------- + src/libcore/tests/iter.rs | 15 ------ + src/libcore/tests/num/mod.rs | 18 ------- + src/libcore/time.rs | 126 ------------------------------------------- 18 files changed, 62 insertions(+), 339 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs @@ -214,10 +214,10 @@ index f95f8e7..549d832 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 3e7db7a..1217d4a 100644 +index 1fec2e5..04266ee 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -153,14 +153,12 @@ mod uint_macros; +@@ -152,14 +152,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -248,7 +248,7 @@ index 662a8dd..856878e 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 1d0b194..cf15fda 100644 +index d4b7094..3b5a197 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -162,12 +162,10 @@ pub fn forget(t: T) { @@ -265,7 +265,7 @@ index 1d0b194..cf15fda 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index c6cbeea..08ef46c 100644 +index 30b7b45..88a294a 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -112,7 +112,6 @@ nonzero_integers! { @@ -295,7 +295,7 @@ index c6cbeea..08ef46c 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4337,17 +4324,6 @@ impl u64 { +@@ -4349,17 +4336,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -313,7 +313,7 @@ index c6cbeea..08ef46c 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4431,7 +4407,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4443,7 +4419,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -322,7 +322,7 @@ index c6cbeea..08ef46c 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4547,30 +4523,25 @@ macro_rules! rev { +@@ -4559,30 +4535,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -357,7 +357,7 @@ index c6cbeea..08ef46c 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4582,21 +4553,21 @@ mod ptr_try_from_impls { +@@ -4594,21 +4565,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -387,7 +387,7 @@ index c6cbeea..08ef46c 100644 } #[cfg(target_pointer_width = "32")] -@@ -4605,24 +4576,24 @@ mod ptr_try_from_impls { +@@ -4617,24 +4588,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -420,7 +420,7 @@ index c6cbeea..08ef46c 100644 } #[cfg(target_pointer_width = "64")] -@@ -4631,24 +4602,20 @@ mod ptr_try_from_impls { +@@ -4643,24 +4614,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -449,7 +449,7 @@ index c6cbeea..08ef46c 100644 } #[doc(hidden)] -@@ -4683,7 +4650,7 @@ macro_rules! doit { +@@ -4695,7 +4662,7 @@ macro_rules! doit { } })*) } @@ -458,7 +458,7 @@ index c6cbeea..08ef46c 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4851,52 +4818,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4863,52 +4830,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -512,7 +512,7 @@ index c6cbeea..08ef46c 100644 // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs -index 1c826c2..0779e31 100644 +index 00134a5..ea15481 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -112,19 +112,17 @@ macro_rules! sh_impl_all { @@ -886,11 +886,10 @@ index 2476c07..2075670 100644 #[derive(Clone)] struct Test(Bigger); -@@ -1877,19 +1875,6 @@ fn test_step_replace_signed() { - assert_eq!(y, 5); +@@ -1878,19 +1876,6 @@ fn test_step_replace_signed() { } --#[test] + #[test] -fn test_step_replace_no_between() { - let mut x = 4u128; - let y = x.replace_zero(); @@ -903,9 +902,10 @@ index 2476c07..2075670 100644 - assert_eq!(y, 5); -} - - #[test] +-#[test] fn test_rev_try_folds() { let f = &|acc, x| i32::checked_add(2*acc, x); + assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index ab96d31..bb5c1d0 100644 --- a/src/libcore/tests/num/mod.rs @@ -976,7 +976,7 @@ index ab96d31..bb5c1d0 100644 test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index cfbd431..aee8065 100644 +index 938e975..2ba930d 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -30,7 +30,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; @@ -987,7 +987,7 @@ index cfbd431..aee8065 100644 /// A `Duration` type to represent a span of time, typically used for system /// timeouts. -@@ -273,57 +272,6 @@ impl Duration { +@@ -269,57 +268,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } @@ -1004,7 +1004,7 @@ index cfbd431..aee8065 100644 - /// ``` - #[unstable(feature = "duration_as_u128", issue = "50202")] - #[inline] -- pub fn as_millis(&self) -> u128 { +- pub const fn as_millis(&self) -> u128 { - self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 - } - @@ -1021,7 +1021,7 @@ index cfbd431..aee8065 100644 - /// ``` - #[unstable(feature = "duration_as_u128", issue = "50202")] - #[inline] -- pub fn as_micros(&self) -> u128 { +- pub const fn as_micros(&self) -> u128 { - self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128 - } - @@ -1038,14 +1038,14 @@ index cfbd431..aee8065 100644 - /// ``` - #[unstable(feature = "duration_as_u128", issue = "50202")] - #[inline] -- pub fn as_nanos(&self) -> u128 { +- pub const fn as_nanos(&self) -> u128 { - self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128 - } - /// Checked `Duration` addition. Computes `self + other`, returning [`None`] /// if overflow occurred. /// -@@ -482,80 +430,6 @@ impl Duration { +@@ -478,80 +426,6 @@ impl Duration { (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) } @@ -1127,5 +1127,5 @@ index cfbd431..aee8065 100644 /// /// # Examples -- -2.17.2 (Apple Git-113) +2.11.0 From 127e080f62d557f0ea94b7f5b7f6cea2604b3122 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Nov 2018 18:28:10 +0100 Subject: [PATCH 0344/1566] Implement ProjectionElem::ConstantIndex --- ...alloc-Disable-some-unsupported-stuff.patch | 44 +-------------- src/base.rs | 56 ++++++++++--------- 2 files changed, 32 insertions(+), 68 deletions(-) diff --git a/0006-alloc-Disable-some-unsupported-stuff.patch b/0006-alloc-Disable-some-unsupported-stuff.patch index ca336859109d8..1342bdd4e0c5e 100644 --- a/0006-alloc-Disable-some-unsupported-stuff.patch +++ b/0006-alloc-Disable-some-unsupported-stuff.patch @@ -5,7 +5,6 @@ Subject: [PATCH] [alloc] Disable some unsupported stuff --- src/liballoc/boxed.rs | 6 ------ - src/liballoc/str.rs | 4 ++++ src/liballoc/vec.rs | 2 -- 3 files changed, 4 insertions(+), 8 deletions(-) @@ -33,42 +32,6 @@ index f989e70..597dd15 100644 fn write_isize(&mut self, i: isize) { (**self).write_isize(i) } -diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs -index 2af8956..23dbb79 100644 ---- a/src/liballoc/str.rs -+++ b/src/liballoc/str.rs -@@ -361,6 +361,7 @@ impl str { - #[stable(feature = "unicode_case_mapping", since = "1.2.0")] - pub fn to_lowercase(&self) -> String { - let mut s = String::with_capacity(self.len()); -+ /* - for (i, c) in self[..].char_indices() { - if c == 'Σ' { - // Σ maps to σ, except at the end of a word where it maps to ς. -@@ -384,6 +385,7 @@ impl str { - } - } - } -+ */ - return s; - - fn map_uppercase_sigma(from: &str, i: usize, to: &mut String) { -@@ -435,6 +437,7 @@ impl str { - #[stable(feature = "unicode_case_mapping", since = "1.2.0")] - pub fn to_uppercase(&self) -> String { - let mut s = String::with_capacity(self.len()); -+ /* - for c in self[..].chars() { - match conversions::to_upper(c) { - [a, '\0', _] => s.push(a), -@@ -449,6 +452,7 @@ impl str { - } - } - } -+ */ - return s; - } - diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 2bc037e..2fe8894 100644 --- a/src/liballoc/vec.rs @@ -79,14 +42,13 @@ index 2bc037e..2fe8894 100644 impl_is_zero!(i64, |x| x == 0); -impl_is_zero!(i128, |x| x == 0); impl_is_zero!(isize, |x| x == 0); - + impl_is_zero!(u16, |x| x == 0); impl_is_zero!(u32, |x| x == 0); impl_is_zero!(u64, |x| x == 0); -impl_is_zero!(u128, |x| x == 0); impl_is_zero!(usize, |x| x == 0); - + impl_is_zero!(char, |x| x == '\0'); --- +-- 2.17.1 (Apple Git-112) - diff --git a/src/base.rs b/src/base.rs index 3f0222ca6ae31..402420644cd1c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -588,18 +588,7 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::Len(place) => { let place = trans_place(fx, place); let usize_layout = fx.layout_of(fx.tcx.types.usize); - let len = match place.layout().ty.sty { - ty::Array(_elem_ty, len) => { - let len = crate::constant::force_eval_const(fx, len) - .unwrap_usize(fx.tcx) as i64; - fx.bcx.ins().iconst(fx.pointer_type, len) - } - ty::Slice(_elem_ty) => match place { - CPlace::Addr(_, size, _) => size.unwrap(), - CPlace::Var(_, _) => unreachable!(), - }, - _ => bug!("Rvalue::Len({:?})", place), - }; + let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::ByVal(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { @@ -660,6 +649,24 @@ fn trans_stmt<'a, 'tcx: 'a>( } } +fn codegen_array_len<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + place: CPlace<'tcx>, +) -> Value { + match place.layout().ty.sty { + ty::Array(_elem_ty, len) => { + let len = crate::constant::force_eval_const(fx, len) + .unwrap_usize(fx.tcx) as i64; + fx.bcx.ins().iconst(fx.pointer_type, len) + } + ty::Slice(_elem_ty) => match place { + CPlace::Addr(_, size, _) => size.unwrap(), + CPlace::Var(_, _) => unreachable!(), + }, + _ => bug!("Rvalue::Len({:?})", place), + } +} + pub fn trans_get_discriminant<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value: CValue<'tcx>, @@ -1060,21 +1067,16 @@ pub fn trans_place<'a, 'tcx: 'a>( ProjectionElem::ConstantIndex { offset, min_length: _, - from_end: false, - } => unimpl!( - "projection const index {:?} offset {:?} not from end", - projection.base, - offset - ), - ProjectionElem::ConstantIndex { - offset, - min_length: _, - from_end: true, - } => unimpl!( - "projection const index {:?} offset {:?} from end", - projection.base, - offset - ), + from_end, + } => { + let index = if !from_end { + fx.bcx.ins().iconst(fx.pointer_type, offset as i64) + } else { + let len = codegen_array_len(fx, base); + fx.bcx.ins().iadd_imm(len, -(offset as i64)) + }; + base.place_index(fx, index) + }, ProjectionElem::Subslice { from, to } => unimpl!( "projection subslice {:?} from {} to {}", projection.base, From b906adfffe775f5b34b7705f5a594b14191009a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Nov 2018 18:38:10 +0100 Subject: [PATCH 0345/1566] Implement some missing CastKind::Misc casts --- src/base.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/base.rs b/src/base.rs index 402420644cd1c..b9356d40f3352 100644 --- a/src/base.rs +++ b/src/base.rs @@ -479,11 +479,15 @@ fn trans_stmt<'a, 'tcx: 'a>( (ty::Ref(..), ty::Ref(..)) | (ty::Ref(..), ty::RawPtr(..)) | (ty::RawPtr(..), ty::Ref(..)) - | (ty::RawPtr(..), ty::RawPtr(..)) => { + | (ty::RawPtr(..), ty::RawPtr(..)) + | (ty::FnPtr(..), ty::RawPtr(..)) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } - (ty::RawPtr(..), ty::Uint(_)) | (ty::FnPtr(..), ty::Uint(_)) - if to_ty.sty == fx.tcx.types.usize.sty => + (ty::RawPtr(..), ty::Uint(_)) + | (ty::RawPtr(..), ty::Int(_)) + | (ty::FnPtr(..), ty::Uint(_)) + if to_ty.sty == fx.tcx.types.usize.sty + || to_ty.sty == fx.tcx.types.isize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } @@ -655,8 +659,7 @@ fn codegen_array_len<'a, 'tcx: 'a>( ) -> Value { match place.layout().ty.sty { ty::Array(_elem_ty, len) => { - let len = crate::constant::force_eval_const(fx, len) - .unwrap_usize(fx.tcx) as i64; + let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => match place { @@ -1076,7 +1079,7 @@ pub fn trans_place<'a, 'tcx: 'a>( fx.bcx.ins().iadd_imm(len, -(offset as i64)) }; base.place_index(fx, index) - }, + } ProjectionElem::Subslice { from, to } => unimpl!( "projection subslice {:?} from {} to {}", projection.base, From ea113ec82e68164242f576c5af43a3dfc1f92c8b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Nov 2018 18:50:45 +0100 Subject: [PATCH 0346/1566] Implement intrinsic "exact_div" --- src/intrinsics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 427ed7c1e5da6..1efc6936498b8 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -194,9 +194,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); ret.write_cvalue(fx, type_id); }; - _ if intrinsic.starts_with("unchecked_"), (c x, c y) { + _ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) { let bin_op = match intrinsic { - "unchecked_div" => BinOp::Div, + "unchecked_div" | "exact_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, "unchecked_shl" => BinOp::Shl, "unchecked_shr" => BinOp::Shr, From 72c34be9752050c1ebacf319d908b98bf2984aa4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Nov 2018 18:57:59 +0100 Subject: [PATCH 0347/1566] Implement raw ptr -> int of native pointer size cast --- src/base.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index b9356d40f3352..09e78b47f8c9a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -487,7 +487,8 @@ fn trans_stmt<'a, 'tcx: 'a>( | (ty::RawPtr(..), ty::Int(_)) | (ty::FnPtr(..), ty::Uint(_)) if to_ty.sty == fx.tcx.types.usize.sty - || to_ty.sty == fx.tcx.types.isize.sty => + || to_ty.sty == fx.tcx.types.isize.sty + || fx.clif_type(to_ty).unwrap() == pointer_ty(fx.tcx) => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } From 0fa5c0f4faf6f3b87159d343f485bbe460549b57 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Nov 2018 14:31:42 +0100 Subject: [PATCH 0348/1566] Rustup to rustc 1.32.0-nightly (9fefb6766 2018-11-13) --- src/base.rs | 14 +++++++------- src/common.rs | 2 +- src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/base.rs b/src/base.rs index 09e78b47f8c9a..40955f2cd3d0e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -373,7 +373,7 @@ fn trans_stmt<'a, 'tcx: 'a>( if *variant_index != dataful_variant { let niche = place.place_field(fx, mir::Field::new(0)); //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); - let niche_value = ((variant_index - *niche_variants.start()) as u128) + let niche_value = ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) .wrapping_add(niche_start); // FIXME(eddyb) Check the actual primitive type here. let niche_llval = if niche_value == 0 { @@ -683,7 +683,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( } match layout.variants { layout::Variants::Single { index } => { - let discr_val = layout.ty.ty_adt_def().map_or(index as u128, |def| { + let discr_val = layout.ty.ty_adt_def().map_or(index.as_u32() as u128, |def| { def.discriminant_for_variant(fx.tcx, index).val }); return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); @@ -720,29 +720,29 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let if_true = fx .bcx .ins() - .iconst(dest_clif_ty, *niche_variants.start() as u64 as i64); + .iconst(dest_clif_ty, niche_variants.start().as_u32() as i64); let if_false = fx .bcx .ins() - .iconst(dest_clif_ty, dataful_variant as u64 as i64); + .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } else { // Rebase from niche values to discriminant values. - let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); + let delta = niche_start.wrapping_sub(niche_variants.start().as_u32() as u128); let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); let lldiscr = fx.bcx.ins().isub(lldiscr, delta); let b = fx.bcx.ins().icmp_imm( IntCC::UnsignedLessThanOrEqual, lldiscr, - *niche_variants.end() as u64 as i64, + niche_variants.end().as_u32() as i64, ); let if_true = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false); let if_false = fx .bcx .ins() - .iconst(dest_clif_ty, dataful_variant as u64 as i64); + .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } diff --git a/src/common.rs b/src/common.rs index d024cb49e4fba..77376182756a5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -561,7 +561,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx, impl Backend>, variant: usize) -> Self { + pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx, impl Backend>, variant: VariantIdx) -> Self { let layout = self.layout().for_variant(fx, variant); self.unchecked_cast_to(layout) } diff --git a/src/lib.rs b/src/lib.rs index f5415584eff0b..b4d7d0e2f46d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,7 +96,7 @@ mod prelude { config::{CrateType, Lto}, Session, }; - pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; + pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout, VariantIdx}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, From 77784aa0de6705f37cc08be7283d8969537770c2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 14 Nov 2018 13:34:34 +0000 Subject: [PATCH 0349/1566] Bump ar from 0.6.0 to 0.6.1 Bumps [ar](https://github.com/mdsteele/rust-ar) from 0.6.0 to 0.6.1. - [Release notes](https://github.com/mdsteele/rust-ar/releases) - [Commits](https://github.com/mdsteele/rust-ar/compare/v0.6.0...v0.6.1) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb14d457f37cf..3b8376248d504 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ dependencies = [ [[package]] name = "ar" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -479,7 +479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -738,7 +738,7 @@ dependencies = [ [metadata] "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "095515608290b62ac2427084f9ac3cfeb5dc76067f7d94564db9db1c46cc0a85" +"checksum ar 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b66b66d06e6bb6a8c6866d31ac48fc225ef2823d29940165c8084b4f120d2b3" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" diff --git a/Cargo.toml b/Cargo.toml index cc71244fc4d2f..61cd7707c69a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.2.0" #goblin = "0.0.17" faerie = "0.6.0" -ar = "0.6.0" +ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.6" cc = "1.0.25" From 1717cc42ef6c5ec0e7d652f6b51cd7fc64990a71 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Nov 2018 15:04:20 +0100 Subject: [PATCH 0350/1566] Fix allocator shim abi --- src/allocator.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index d84838634e798..2474e01467004 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -39,18 +39,24 @@ pub fn codegen(module: &mut Module, kind: AllocatorKind) } }; - let sig = Signature { + let mut sig = Signature { call_conv: CallConv::Fast, params: arg_tys.iter().cloned().map(AbiParam::new).collect(), returns: output.into_iter().map(AbiParam::new).collect(), }; + let caller_name = format!("__rust_{}", method.name); + let callee_name = kind.fn_name(method.name); + //eprintln!("Codegen allocator shim {} -> {} ({:?} -> {:?})", caller_name, callee_name, sig.params, sig.returns); + + sig.call_conv = CallConv::Fast; // "rust" abi let func_id = module - .declare_function(&format!("__rust_{}", method.name), Linkage::Export, &sig) + .declare_function(&caller_name, Linkage::Export, &sig) .unwrap(); + sig.call_conv = CallConv::SystemV; // "C" abi let callee_func_id = module - .declare_function(&kind.fn_name(method.name), Linkage::Import, &sig) + .declare_function(&callee_name, Linkage::Import, &sig) .unwrap(); let mut ctx = Context::new(); From 59ae13f65f7b65d3157b00f021b73b047c7fa004 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 14 Nov 2018 14:06:55 +0000 Subject: [PATCH 0351/1566] Bump cranelift from `28fb8e1` to `fe081d3` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `28fb8e1` to `fe081d3`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/28fb8e14011c3d79fb10d88bf1ea363136bdc9af...fe081d3a4710e4f1393ecad17fcb988f01ac5ef0) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b8376248d504..2b50f7f16eb5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" [[package]] name = "cranelift-faerie" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#28fb8e14011c3d79fb10d88bf1ea363136bdc9af" +source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", From 41ee6781f943fa72ac8fb90e7656150b6d78ecd3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 15 Nov 2018 06:20:40 +0000 Subject: [PATCH 0352/1566] Bump cranelift from `fe081d3` to `606eee5` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `fe081d3` to `606eee5`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/fe081d3a4710e4f1393ecad17fcb988f01ac5ef0...606eee5a6c4835b7cbbf5d8f05b83d62331fa61e) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b50f7f16eb5e..ced3e68bcd6d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" [[package]] name = "cranelift-faerie" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fe081d3a4710e4f1393ecad17fcb988f01ac5ef0" +source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", From 4a69f55758bb71fc7fb163050bbdc563bdf0558b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Nov 2018 10:55:40 +0100 Subject: [PATCH 0353/1566] Update for cranelift change --- src/pretty_clif.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 53e0d5cd1cefc..efaf200fa1a45 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -10,6 +10,26 @@ use crate::prelude::*; pub struct CommentWriter(pub HashMap); impl FuncWriter for CommentWriter { + fn write_preamble( + &mut self, + w: &mut dyn fmt::Write, + func: &Function, + reg_info: Option<&isa::RegInfo>, + ) -> Result { + PlainWriter.write_preamble(w, func, reg_info) + } + + fn write_ebb_header( + &mut self, + w: &mut dyn fmt::Write, + func: &Function, + isa: Option<&dyn isa::TargetIsa>, + ebb: Ebb, + indent: usize, + ) -> fmt::Result { + PlainWriter.write_ebb_header(w, func, isa, ebb, indent) + } + fn write_instruction( &mut self, w: &mut dyn fmt::Write, @@ -25,15 +45,6 @@ impl FuncWriter for CommentWriter { } Ok(()) } - - fn write_preamble( - &mut self, - w: &mut dyn fmt::Write, - func: &Function, - reg_info: Option<&isa::RegInfo>, - ) -> Result { - PlainWriter.write_preamble(w, func, reg_info) - } } impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { From 43552c9cb9a5378d2bcbafe0e74114d51981513c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Nov 2018 11:47:19 +0100 Subject: [PATCH 0354/1566] Replace some variadic function calls in libstd with unimplemented!() --- ...iadic-function-calls-with-unimplemen.patch | 211 ++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 0008-Replace-some-variadic-function-calls-with-unimplemen.patch diff --git a/0008-Replace-some-variadic-function-calls-with-unimplemen.patch b/0008-Replace-some-variadic-function-calls-with-unimplemen.patch new file mode 100644 index 0000000000000..a46bf1dd60a39 --- /dev/null +++ b/0008-Replace-some-variadic-function-calls-with-unimplemen.patch @@ -0,0 +1,211 @@ +From 96aefe8fdd28704d903d585f5be6a667d2485582 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Thu, 15 Nov 2018 11:41:06 +0100 +Subject: [PATCH] Replace some variadic function calls with unimplemented!() + +--- + src/libstd/sys/unix/fd.rs | 18 ++++++++++++++++++ + src/libstd/sys/unix/fs.rs | 9 +++++++++ + src/libstd/sys/unix/net.rs | 3 +++ + src/libstd/sys/unix/rand.rs | 3 +++ + src/libstd/sys/unix/thread.rs | 3 +++ + 5 files changed, 36 insertions(+) + +diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs +index af33d26..2433ae4 100644 +--- a/src/libstd/sys/unix/fd.rs ++++ b/src/libstd/sys/unix/fd.rs +@@ -156,9 +156,12 @@ impl FileDesc { + + #[cfg(target_os = "linux")] + pub fn get_cloexec(&self) -> io::Result { ++ /* + unsafe { + Ok((cvt(libc::fcntl(self.fd, libc::F_GETFD))? & libc::FD_CLOEXEC) != 0) + } ++ */ ++ unimplemented!(); + } + + #[cfg(not(any(target_env = "newlib", +@@ -168,10 +171,13 @@ impl FileDesc { + target_os = "l4re", + target_os = "haiku")))] + pub fn set_cloexec(&self) -> io::Result<()> { ++ /* + unsafe { + cvt(libc::ioctl(self.fd, libc::FIOCLEX))?; + Ok(()) + } ++ */ ++ unimplemented!(); + } + #[cfg(any(target_env = "newlib", + target_os = "solaris", +@@ -180,6 +186,7 @@ impl FileDesc { + target_os = "l4re", + target_os = "haiku"))] + pub fn set_cloexec(&self) -> io::Result<()> { ++ /* + unsafe { + let previous = cvt(libc::fcntl(self.fd, libc::F_GETFD))?; + let new = previous | libc::FD_CLOEXEC; +@@ -188,19 +195,25 @@ impl FileDesc { + } + Ok(()) + } ++ */ ++ unimplemented!(); + } + + #[cfg(target_os = "linux")] + pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { ++ /* + unsafe { + let v = nonblocking as c_int; + cvt(libc::ioctl(self.fd, libc::FIONBIO, &v))?; + Ok(()) + } ++ */ ++ unimplemented!(); + } + + #[cfg(not(target_os = "linux"))] + pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { ++ /* + unsafe { + let previous = cvt(libc::fcntl(self.fd, libc::F_GETFL))?; + let new = if nonblocking { +@@ -213,9 +226,12 @@ impl FileDesc { + } + Ok(()) + } ++ */ ++ unimplemented!(); + } + + pub fn duplicate(&self) -> io::Result { ++ /* + // We want to atomically duplicate this file descriptor and set the + // CLOEXEC flag, and currently that's done via F_DUPFD_CLOEXEC. This + // flag, however, isn't supported on older Linux kernels (earlier than +@@ -263,6 +279,8 @@ impl FileDesc { + } + } + cvt(unsafe { libc::fcntl(fd, libc::F_DUPFD, 0) }).and_then(make_filedesc) ++ */ ++ unimplemented!(); + } + } + +diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs +index add06ae..e0d3f84 100644 +--- a/src/libstd/sys/unix/fs.rs ++++ b/src/libstd/sys/unix/fs.rs +@@ -465,6 +465,7 @@ impl File { + } + + pub fn open_c(path: &CStr, opts: &OpenOptions) -> io::Result { ++ /* + let flags = libc::O_CLOEXEC | + opts.get_access_mode()? | + opts.get_creation_mode()? | +@@ -519,6 +520,8 @@ impl File { + + ensure_cloexec(&fd)?; + Ok(File(fd)) ++ */ ++ unimplemented!(); + } + + pub fn file_attr(&self) -> io::Result { +@@ -667,6 +670,7 @@ impl fmt::Debug for File { + + #[cfg(any(target_os = "linux", target_os = "macos"))] + fn get_mode(fd: c_int) -> Option<(bool, bool)> { ++ /* + let mode = unsafe { libc::fcntl(fd, libc::F_GETFL) }; + if mode == -1 { + return None; +@@ -677,6 +681,8 @@ impl fmt::Debug for File { + libc::O_WRONLY => Some((false, true)), + _ => None + } ++ */ ++ unimplemented!(); + } + + #[cfg(not(any(target_os = "linux", target_os = "macos")))] +@@ -868,6 +874,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { + len: libc::size_t, + flags: libc::c_uint, + ) -> libc::c_long { ++ /* + libc::syscall( + libc::SYS_copy_file_range, + fd_in, +@@ -877,6 +884,8 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { + len, + flags, + ) ++ */ ++ unimplemented!(); + } + + if !from.is_file() { +diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs +index 2d10541..19e96c4 100644 +--- a/src/libstd/sys/unix/net.rs ++++ b/src/libstd/sys/unix/net.rs +@@ -339,8 +339,11 @@ impl Socket { + } + + pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { ++ /* + let mut nonblocking = nonblocking as libc::c_int; + cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(|_| ()) ++ */ ++ unimplemented!(); + } + + pub fn take_error(&self) -> io::Result> { +diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs +index 371e58a..28d4c68 100644 +--- a/src/libstd/sys/unix/rand.rs ++++ b/src/libstd/sys/unix/rand.rs +@@ -34,9 +34,12 @@ mod imp { + + #[cfg(any(target_os = "linux", target_os = "android"))] + fn getrandom(buf: &mut [u8]) -> libc::c_long { ++ /* + unsafe { + libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr(), buf.len(), libc::GRND_NONBLOCK) + } ++ */ ++ unimplemented!(); + } + + #[cfg(not(any(target_os = "linux", target_os = "android")))] +diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs +index f3a45d2..1c2f0ce 100644 +--- a/src/libstd/sys/unix/thread.rs ++++ b/src/libstd/sys/unix/thread.rs +@@ -100,12 +100,15 @@ impl Thread { + #[cfg(any(target_os = "linux", + target_os = "android"))] + pub fn set_name(name: &CStr) { ++ /* + const PR_SET_NAME: libc::c_int = 15; + // pthread wrapper only appeared in glibc 2.12, so we use syscall + // directly. + unsafe { + libc::prctl(PR_SET_NAME, name.as_ptr() as libc::c_ulong, 0, 0, 0); + } ++ */ ++ unimplemented!(); + } + + #[cfg(any(target_os = "freebsd", +-- +2.11.0 + From e1811533aebba7ea1f95a776028086425b3c3fe6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 17:05:59 +0100 Subject: [PATCH 0355/1566] Update Readme.md for the current state and add some links to tracking issues --- Readme.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Readme.md b/Readme.md index 741142b869a33..f43f909e9c7a9 100644 --- a/Readme.md +++ b/Readme.md @@ -7,33 +7,32 @@ ```bash $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift -$ rustup override set nightly -$ cargo install xargo -$ git submodule update --init +$ rustup override set nightly # This uses unstable api's which will never be stabilized +$ cargo install xargo # Used for building the sysroot +$ cargo install hyperfine # Used for benchmarking in build.sh $ cargo build ``` ## Usage ```bash -$ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_crate.rs --crate-type lib -Og +$ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_crate.rs ``` -## Building libcore +## Build sysroot and test ```bash -$ rustup component add rust-src -$ ./prepare_libcore.sh +$ rustup component add rust-src # Make sure the sysroot source is availablr +$ ./prepare_libcore.sh # Patch the sysroot source for some not yet supported things $ ./build.sh ``` ## Not yet supported -* Checked binops -* Drop glue - -* Other call abi's -* Sub slice - -* Inline assembly -* Custom sections +* Good non-rust abi support ([non scalars are not yet supported for the "C" abi](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) +* Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) +* Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444)) +* Varargs ([no cranelift support](https://github.com/CraneStation/cranelift/issues/212)) +* libstd (needs varargs and some other stuff) ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/146)) +* u128 and i128 ([no cranelift support](https://github.com/CraneStation/cranelift/issues/354)) +* SIMD (huge amount of work to get all intrinsics implemented, so may never be supported) From faf974b2e626c28c03a2dc9368a7df486cfd04b8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 17:20:00 +0100 Subject: [PATCH 0356/1566] Rustup to rustc 1.32.0-nightly (6b9b97bd9 2018-11-15) --- src/base.rs | 3 ++- src/constant.rs | 9 --------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/base.rs b/src/base.rs index 40955f2cd3d0e..b40c38390037f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -648,7 +648,8 @@ fn trans_stmt<'a, 'tcx: 'a>( | StatementKind::FakeRead(..) | StatementKind::EndRegion(_) | StatementKind::Retag { .. } - | StatementKind::AscribeUserType(..) => {} + | StatementKind::AscribeUserType(..) + | StatementKind::EscapeToRaw(..) => {} StatementKind::InlineAsm { .. } => unimpl!("Inline assembly is not supported"), } diff --git a/src/constant.rs b/src/constant.rs index 0fc1b52b2f2d6..984dbf5e0f4cf 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -283,7 +283,6 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { type AllocExtra = (); type MemoryMap = FxHashMap, Allocation<()>)>; const STATIC_KIND: Option = None; - const ENABLE_PTR_TRACKING_HOOKS: bool = false; fn enforce_validity(_: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool { false @@ -334,14 +333,6 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn tag_reference( - _: &mut EvalContext<'a, 'mir, 'tcx, Self>, - _: MPlaceTy<'tcx>, - _: Option<::rustc::hir::Mutability>, - ) -> EvalResult<'tcx, Scalar> { - panic!() - } - fn tag_dereference( _: &EvalContext<'a, 'mir, 'tcx, Self>, _: MPlaceTy<'tcx>, From 7b1af5b6f663d1cf2f0d1c8f15022c49cef8c161 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 16 Nov 2018 06:35:25 +0000 Subject: [PATCH 0357/1566] Bump cranelift from `606eee5` to `af045c1` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `606eee5` to `af045c1`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/606eee5a6c4835b7cbbf5d8f05b83d62331fa61e...af045c1c1705919285877173b0fdca54db29f54d) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ced3e68bcd6d9..9597858021f0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" [[package]] name = "cranelift-faerie" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#606eee5a6c4835b7cbbf5d8f05b83d62331fa61e" +source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", From e83da7533cdabb4ac99e53495686135233b23f9d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 17:35:47 +0100 Subject: [PATCH 0358/1566] Move trapping to trap_code.rs --- src/abi.rs | 2 +- src/base.rs | 6 +++--- src/intrinsics.rs | 6 +++--- src/lib.rs | 2 ++ src/trap.rs | 12 ++++++++++++ 5 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/trap.rs diff --git a/src/abi.rs b/src/abi.rs index e50aa9ff63d48..ea00dd790eba2 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -504,7 +504,7 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { - fx.bcx.ins().trap(TrapCode::User(!0)); + trap_unreachable(&mut fx.bcx); } } diff --git a/src/base.rs b/src/base.rs index b40c38390037f..ab3dc7aa5bab9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -202,7 +202,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } else { fx.bcx.ins().brz(cond, target, &[]); }; - fx.bcx.ins().trap(TrapCode::User(!0)); + trap_panic(&mut fx.bcx); } TerminatorKind::SwitchInt { @@ -230,7 +230,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) crate::abi::codegen_terminator_call(fx, func, args, destination); } TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { - fx.bcx.ins().trap(TrapCode::User(!0)); + trap_unreachable(&mut fx.bcx); } TerminatorKind::Yield { .. } | TerminatorKind::FalseEdges { .. } @@ -680,7 +680,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let layout = value.layout(); if layout.abi == layout::Abi::Uninhabited { - fx.bcx.ins().trap(TrapCode::User(!0)); + trap_unreachable(&mut fx.bcx); } match layout.variants { layout::Variants::Single { index } => { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 1efc6936498b8..fde28eb3e36d9 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -101,10 +101,10 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // Insert non returning intrinsics here match intrinsic { "abort" => { - fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + trap_panic(&mut fx.bcx); } "unreachable" => { - fx.bcx.ins().trap(TrapCode::User(!0 - 1)); + trap_unreachable(&mut fx.bcx); } _ => unimplemented!("unsupported instrinsic {}", intrinsic), } @@ -423,6 +423,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { - fx.bcx.ins().trap(TrapCode::User(!0)); + trap_unreachable(&mut fx.bcx); } } diff --git a/src/lib.rs b/src/lib.rs index b4d7d0e2f46d2..95cd7704e20c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,6 +81,7 @@ mod link_copied; mod main_shim; mod metadata; mod pretty_clif; +mod trap; mod vtable; mod prelude { @@ -121,6 +122,7 @@ mod prelude { pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; pub use crate::common::*; + pub use crate::trap::*; pub use crate::{Caches, CodegenResults, CrateInfo}; } diff --git a/src/trap.rs b/src/trap.rs new file mode 100644 index 0000000000000..1d264b209986e --- /dev/null +++ b/src/trap.rs @@ -0,0 +1,12 @@ +use cranelift::prelude::*; +use cranelift::codegen::ir::TrapCode; + +/// Trap code: user0 +pub fn trap_panic(bcx: &mut FunctionBuilder) { + bcx.ins().trap(TrapCode::User(0)); +} + +/// Trap code: user65535 +pub fn trap_unreachable(bcx: &mut FunctionBuilder) { + bcx.ins().trap(TrapCode::User(!0)); +} From e6634506a2b953869df294f915ee368fa94b8887 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 17:54:57 +0100 Subject: [PATCH 0359/1566] Update Cargo.lock --- Cargo.lock | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9597858021f0e..cbfe536eaf70c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" [[package]] name = "cranelift-faerie" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,17 +176,17 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#af045c1c1705919285877173b0fdca54db29f54d" +source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -260,9 +260,9 @@ name = "failure_derive" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -364,7 +364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.21" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -380,7 +380,7 @@ name = "quote" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -410,7 +410,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "raw-cpuid" -version = "6.0.0" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -448,7 +448,7 @@ name = "regex-syntax" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -503,7 +503,7 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -520,9 +520,9 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -549,7 +549,7 @@ version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -581,17 +581,17 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.18" +version = "0.15.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -601,9 +601,9 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -666,7 +666,7 @@ dependencies = [ [[package]] name = "ucd-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -778,13 +778,13 @@ dependencies = [ "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.21 (registry+https://github.com/rust-lang/crates.io-index)" = "ab2fc21ba78ac73e4ff6b3818ece00be4e175ffbef4d0a717d978b48b24150c4" +"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" "checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" -"checksum raw-cpuid 6.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41219962ecab392f1e68db9e7ebd972800d4045a128cc23462b384e8c312cde1" +"checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" @@ -793,7 +793,7 @@ dependencies = [ "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" +"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -804,7 +804,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "41c4a2479a078509940d82773d90ff824a8c89533ab3b59cd3ce8b0c0e369c02" "checksum structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5352090cfae7a2c85e1a31146268b53396106c88ca5d6ccee2e3fae83b6e35c2" -"checksum syn 0.15.18 (registry+https://github.com/rust-lang/crates.io-index)" = "90c39a061e2f412a9f869540471ab679e85e50c6b05604daf28bc3060f75c430" +"checksum syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)" = "816b7af21405b011a23554ea2dc3f6576dc86ca557047c34098c1d741f10f823" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" "checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" @@ -812,7 +812,7 @@ dependencies = [ "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum ucd-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0f8bfa9ff0cadcd210129ad9d2c5f145c13e9ced3d3e5d948a6213487d52444" +"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" From 8233ade78996f687932011b6faf514719386882f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 18:13:43 +0100 Subject: [PATCH 0360/1566] Set cranelift opt_level based on -Copt-level --- build.sh | 2 +- src/lib.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 4917dff7ce6e1..f7b1f9b846d71 100755 --- a/build.sh +++ b/build.sh @@ -63,7 +63,7 @@ rm -r target || true time RUSTFLAGS="-Zmir-opt-level=3 $RUSTFLAGS" xargo build popd -$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 --crate-name mod_bench_inline +$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -Og --crate-name mod_bench_inline rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort diff --git a/src/lib.rs b/src/lib.rs index 95cd7704e20c7..ba930f2553cc4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -329,6 +329,21 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); + + use rustc::session::config::OptLevel; + match tcx.sess.opts.optimize { + OptLevel::No => { + flags_builder.set("opt_level", "fastest").unwrap(); + }, + OptLevel::Less | OptLevel::Default => {}, + OptLevel::Aggressive => { + flags_builder.set("opt_level", "best").unwrap(); + }, + OptLevel::Size | OptLevel::SizeMin => { + tcx.sess.warn("Optimizing for size is not supported. Just ignoring the request"); + } + } + let flags = settings::Flags::new(flags_builder); let isa = cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) From 7466741bf0a66edbe7f6ce327e9b4076e694ec0a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 18:39:31 +0100 Subject: [PATCH 0361/1566] Benchmark compilations speed cc #133 --- build.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index f7b1f9b846d71..afe32828e4b27 100755 --- a/build.sh +++ b/build.sh @@ -63,12 +63,15 @@ rm -r target || true time RUSTFLAGS="-Zmir-opt-level=3 $RUSTFLAGS" xargo build popd -$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -Og --crate-name mod_bench_inline +COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -Og --crate-name mod_bench_inline" +COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" +COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" +COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" +COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort" + +# Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow +hyperfine --runs 100 "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3" -rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort -rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort -rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort -rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort echo echo "[Bench] mod_bench" hyperfine ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* From b2a8996f886d157904063cca4e3e2082dd27b5e5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 19:50:02 +0100 Subject: [PATCH 0362/1566] Implement rotate_{left,right} intrinsics --- src/intrinsics.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index fde28eb3e36d9..b59e1c6631b4d 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -281,6 +281,16 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, res); }; + rotate_left, (v x, v y) { + let layout = fx.layout_of(T); + let res = fx.bcx.ins().rotl(x, y); + ret.write_cvalue(fx, CValue::ByVal(res, layout)); + }; + rotate_right, (v x, v y) { + let layout = fx.layout_of(T); + let res = fx.bcx.ins().rotr(x, y); + ret.write_cvalue(fx, CValue::ByVal(res, layout)); + }; offset, (v base, v offset) { let res = fx.bcx.ins().iadd(base, offset); ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); From 2c38313403f47500981d5831f7c3c81b02320dfe Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 19:53:27 +0100 Subject: [PATCH 0363/1566] Move unimpl! macro to unimpl.rs --- src/base.rs | 6 ++++-- src/lib.rs | 30 ++++++------------------------ src/unimpl.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 src/unimpl.rs diff --git a/src/base.rs b/src/base.rs index ab3dc7aa5bab9..1be7942c84b98 100644 --- a/src/base.rs +++ b/src/base.rs @@ -104,8 +104,10 @@ fn trans_fn<'a, 'tcx: 'a>( }; // Step 6. Codegen function - crate::abi::codegen_fn_prelude(&mut fx, start_ebb); - codegen_fn_content(&mut fx); + with_unimpl_span(fx.mir.span, || { + crate::abi::codegen_fn_prelude(&mut fx, start_ebb); + codegen_fn_content(&mut fx); + }); // Step 7. Write function to file for debugging let mut writer = crate::pretty_clif::CommentWriter(fx.comments); diff --git a/src/lib.rs b/src/lib.rs index ba930f2553cc4..5b25861838eef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,8 @@ rustc_private, macro_at_most_once_rep, never_type, - extern_crate_item_prelude + extern_crate_item_prelude, + decl_macro, )] #![allow(intra_doc_link_resolution_failure)] @@ -34,7 +35,6 @@ extern crate target_lexicon; use std::any::Any; use std::fs::File; -use std::io::Write; use std::sync::mpsc; use syntax::symbol::Symbol; @@ -60,14 +60,6 @@ use cranelift_faerie::*; use crate::constant::ConstantCx; use crate::prelude::*; -struct NonFatal(pub String); - -macro_rules! unimpl { - ($($tt:tt)*) => { - panic!(crate::NonFatal(format!($($tt)*))); - }; -} - mod abi; mod allocator; mod analyze; @@ -82,6 +74,7 @@ mod main_shim; mod metadata; mod pretty_clif; mod trap; +mod unimpl; mod vtable; mod prelude { @@ -123,6 +116,7 @@ mod prelude { pub use crate::base::{trans_operand, trans_place}; pub use crate::common::*; pub use crate::trap::*; + pub use crate::unimpl::{unimpl, with_unimpl_span}; pub use crate::{Caches, CodegenResults, CrateInfo}; } @@ -482,21 +476,9 @@ fn codegen_mono_items<'a, 'tcx: 'a>( println!("[codegen mono items] start"); for (&mono_item, &(_linkage, _vis)) in mono_items { - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { + unimpl::try_unimpl(tcx, log, || { base::trans_mono_item(tcx, module, &mut caches, &mut ccx, mono_item); - })); - - if let Err(err) = res { - match err.downcast::() { - Ok(non_fatal) => { - if cfg!(debug_assertions) { - writeln!(log.as_mut().unwrap(), "{}", &non_fatal.0).unwrap(); - } - tcx.sess.err(&non_fatal.0) - } - Err(err) => ::std::panic::resume_unwind(err), - } - } + }); } crate::main_shim::maybe_create_entry_wrapper(tcx, module); diff --git a/src/unimpl.rs b/src/unimpl.rs new file mode 100644 index 0000000000000..771897fa4b076 --- /dev/null +++ b/src/unimpl.rs @@ -0,0 +1,50 @@ +//! The unimpl! macro is defined here. It is used to generate +//! a non-fatal error on not yet implemented things. + +use std::cell::RefCell; +use std::fs::File; +use std::io::Write; + +use syntax::source_map::Span; + +use rustc::ty::TyCtxt; + +thread_local! { + static SPAN_STACK: RefCell> = RefCell::new(vec![]); +} + +// Just public, because of the unimpl macro +pub struct NonFatal(pub String); + +pub macro unimpl($($tt:tt)*) { + panic!(NonFatal(format!($($tt)*))); +} + +pub fn try_unimpl(tcx: TyCtxt, log: &mut Option, f: impl FnOnce()) { + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { + f() + })); + + if let Err(err) = res { + SPAN_STACK.with(|span_stack| { + match err.downcast::() { + Ok(non_fatal) => { + if cfg!(debug_assertions) { + writeln!(log.as_mut().unwrap(), "{} at {:?}", &non_fatal.0, span_stack.borrow()).unwrap(); + } + tcx.sess.err(&non_fatal.0) + } + Err(err) => ::std::panic::resume_unwind(err), + } + span_stack.borrow_mut().clear(); + }); + } +} + +pub fn with_unimpl_span(span: Span, f: impl FnOnce()) { + SPAN_STACK.with(|span_stack| { + span_stack.borrow_mut().push(span); + f(); + span_stack.borrow_mut().pop(); + }); +} From 10ad950130db2e78e70ae2439f3bba965329ea4f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Nov 2018 20:37:45 +0100 Subject: [PATCH 0364/1566] Fix static linkage --- src/constant.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 984dbf5e0f4cf..3a27b1abdbbeb 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -45,7 +45,7 @@ pub fn codegen_static_ref<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, static_: &Static<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fx.tcx, fx.module, static_.def_id); + let data_id = data_id_for_static(fx.tcx, fx.module, static_.def_id, Linkage::Import); cplace_for_dataid(fx, static_.ty, data_id) } @@ -158,6 +158,7 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, def_id: DefId, + linkage: Linkage, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); let is_mutable = if let ::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { @@ -167,7 +168,7 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) }; module - .declare_data(&*symbol_name, Linkage::Export, is_mutable) + .declare_data(&*symbol_name, linkage, is_mutable) .unwrap() } @@ -212,7 +213,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( _ => bug!("static const eval returned {:#?}", const_), }; - let data_id = data_id_for_static(tcx, module, def_id); + let data_id = data_id_for_static(tcx, module, def_id, Linkage::Export); (data_id, alloc) } }; @@ -251,7 +252,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( } AllocType::Static(def_id) => { cx.todo.insert(TodoItem::Static(def_id)); - data_id_for_static(tcx, module, def_id) + data_id_for_static(tcx, module, def_id, Linkage::Import) } }; From 158294de5ca26e80de243da5f3aa3fcf82eb0ca3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 17 Nov 2018 11:51:49 +0100 Subject: [PATCH 0365/1566] Update libstd patches for latest nightly and macOS --- 0007-Fix-libstd-building.patch | 49 ++++++++++++---- ...iadic-function-calls-with-unimplemen.patch | 58 +++++++++++++++---- 2 files changed, 84 insertions(+), 23 deletions(-) diff --git a/0007-Fix-libstd-building.patch b/0007-Fix-libstd-building.patch index be930ae302279..bbbbaab9ff10d 100644 --- a/0007-Fix-libstd-building.patch +++ b/0007-Fix-libstd-building.patch @@ -1,20 +1,21 @@ -From 40c86527fe92b608a65cc1187901035ebc56b281 Mon Sep 17 00:00:00 2001 +From d8bb60cc115960702f73f83866cde65dcdcf1cb4 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 6 Oct 2018 13:21:15 +0200 +Date: Sat, 17 Nov 2018 11:08:10 +0100 Subject: [PATCH] Fix libstd building --- src/libstd/lib.rs | 6 ------ src/libstd/net/ip.rs | 20 -------------------- src/libstd/num.rs | 2 +- + src/libstd/panic.rs | 6 ------ src/libstd/primitive_docs.rs | 16 ---------------- - 4 files changed, 1 insertion(+), 43 deletions(-) + 5 files changed, 1 insertion(+), 49 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 4768e8b..c89f99a 100644 +index 6110b05..8b0c897 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -257,7 +257,6 @@ +@@ -255,7 +255,6 @@ #![feature(const_cstr_unchecked)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] @@ -22,7 +23,7 @@ index 4768e8b..c89f99a 100644 #![feature(exact_size_is_empty)] #![feature(external_doc)] #![feature(fixed_size_array)] -@@ -287,7 +286,6 @@ +@@ -286,7 +285,6 @@ #![feature(rustc_attrs)] #![feature(rustc_const_unstable)] #![feature(std_internals)] @@ -30,7 +31,7 @@ index 4768e8b..c89f99a 100644 #![feature(shrink_to)] #![feature(slice_concat_ext)] #![feature(slice_internals)] -@@ -410,8 +408,6 @@ pub use core::i16; +@@ -402,8 +400,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -39,7 +40,7 @@ index 4768e8b..c89f99a 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -444,8 +440,6 @@ pub use alloc_crate::string; +@@ -436,8 +432,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -49,10 +50,10 @@ index 4768e8b..c89f99a 100644 pub use core::hint; diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index d45a66e..b25b862 100644 +index 8685cb7..c4bf4d2 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs -@@ -1393,26 +1393,6 @@ impl FromInner for Ipv6Addr { +@@ -1392,26 +1392,6 @@ impl FromInner for Ipv6Addr { } } @@ -92,8 +93,32 @@ index 3f90c1f..85aab83 100644 #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; +diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs +index 4bc18a5..5c87035 100644 +--- a/src/libstd/panic.rs ++++ b/src/libstd/panic.rs +@@ -264,9 +264,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} + #[cfg(target_has_atomic = "64")] + #[unstable(feature = "integer_atomics", issue = "32976")] + impl RefUnwindSafe for atomic::AtomicI64 {} +-#[cfg(all(not(stage0), target_has_atomic = "128"))] +-#[unstable(feature = "integer_atomics", issue = "32976")] +-impl RefUnwindSafe for atomic::AtomicI128 {} + + #[cfg(target_has_atomic = "ptr")] + #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] +@@ -283,9 +280,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {} + #[cfg(target_has_atomic = "64")] + #[unstable(feature = "integer_atomics", issue = "32976")] + impl RefUnwindSafe for atomic::AtomicU64 {} +-#[cfg(all(not(stage0), target_has_atomic = "128"))] +-#[unstable(feature = "integer_atomics", issue = "32976")] +-impl RefUnwindSafe for atomic::AtomicU128 {} + + #[cfg(target_has_atomic = "8")] + #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs -index 8d54728..c36893c 100644 +index c2a1612..99824c5 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -809,14 +809,6 @@ mod prim_i32 { } @@ -127,5 +152,5 @@ index 8d54728..c36893c 100644 // /// The pointer-sized signed integer type. -- -2.17.1 (Apple Git-112) +2.17.2 (Apple Git-113) diff --git a/0008-Replace-some-variadic-function-calls-with-unimplemen.patch b/0008-Replace-some-variadic-function-calls-with-unimplemen.patch index a46bf1dd60a39..44edafcfcc3cb 100644 --- a/0008-Replace-some-variadic-function-calls-with-unimplemen.patch +++ b/0008-Replace-some-variadic-function-calls-with-unimplemen.patch @@ -1,18 +1,18 @@ -From 96aefe8fdd28704d903d585f5be6a667d2485582 Mon Sep 17 00:00:00 2001 +From d1d5c0e5272a8c3f78e9c4eb97c38d8f5d5a6d87 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Thu, 15 Nov 2018 11:41:06 +0100 +Date: Sat, 17 Nov 2018 11:13:19 +0100 Subject: [PATCH] Replace some variadic function calls with unimplemented!() --- src/libstd/sys/unix/fd.rs | 18 ++++++++++++++++++ - src/libstd/sys/unix/fs.rs | 9 +++++++++ + src/libstd/sys/unix/fs.rs | 17 ++++++++++++++++- src/libstd/sys/unix/net.rs | 3 +++ src/libstd/sys/unix/rand.rs | 3 +++ src/libstd/sys/unix/thread.rs | 3 +++ - 5 files changed, 36 insertions(+) + 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs -index af33d26..2433ae4 100644 +index 5a81d6d..919f9d1 100644 --- a/src/libstd/sys/unix/fd.rs +++ b/src/libstd/sys/unix/fd.rs @@ -156,9 +156,12 @@ impl FileDesc { @@ -99,7 +99,7 @@ index af33d26..2433ae4 100644 } diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs -index add06ae..e0d3f84 100644 +index add06ae..1a392fc 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -465,6 +465,7 @@ impl File { @@ -119,7 +119,43 @@ index add06ae..e0d3f84 100644 } pub fn file_attr(&self) -> io::Result { -@@ -667,6 +670,7 @@ impl fmt::Debug for File { +@@ -535,6 +538,7 @@ impl File { + } + + pub fn datasync(&self) -> io::Result<()> { ++ /* + cvt_r(|| unsafe { os_datasync(self.0.raw()) })?; + return Ok(()); + +@@ -547,7 +551,9 @@ impl File { + #[cfg(not(any(target_os = "macos", + target_os = "ios", + target_os = "linux")))] +- unsafe fn os_datasync(fd: c_int) -> c_int { libc::fsync(fd) } ++ unsafe fn os_datasync(fd: c_int) -> c_int { libc::fsync(fd) }] ++ */ ++ unimplemented!(); + } + + pub fn truncate(&self, size: u64) -> io::Result<()> { +@@ -643,6 +649,7 @@ impl fmt::Debug for File { + + #[cfg(target_os = "macos")] + fn get_path(fd: c_int) -> Option { ++ /* + // FIXME: The use of PATH_MAX is generally not encouraged, but it + // is inevitable in this case because macOS defines `fcntl` with + // `F_GETPATH` in terms of `MAXPATHLEN`, and there are no +@@ -657,6 +664,8 @@ impl fmt::Debug for File { + buf.truncate(l as usize); + buf.shrink_to_fit(); + Some(PathBuf::from(OsString::from_vec(buf))) ++ */ ++ unimplemented!(); + } + + #[cfg(not(any(target_os = "linux", target_os = "macos")))] +@@ -667,6 +676,7 @@ impl fmt::Debug for File { #[cfg(any(target_os = "linux", target_os = "macos"))] fn get_mode(fd: c_int) -> Option<(bool, bool)> { @@ -127,7 +163,7 @@ index add06ae..e0d3f84 100644 let mode = unsafe { libc::fcntl(fd, libc::F_GETFL) }; if mode == -1 { return None; -@@ -677,6 +681,8 @@ impl fmt::Debug for File { +@@ -677,6 +687,8 @@ impl fmt::Debug for File { libc::O_WRONLY => Some((false, true)), _ => None } @@ -136,7 +172,7 @@ index add06ae..e0d3f84 100644 } #[cfg(not(any(target_os = "linux", target_os = "macos")))] -@@ -868,6 +874,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { +@@ -868,6 +880,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { len: libc::size_t, flags: libc::c_uint, ) -> libc::c_long { @@ -144,7 +180,7 @@ index add06ae..e0d3f84 100644 libc::syscall( libc::SYS_copy_file_range, fd_in, -@@ -877,6 +884,8 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { +@@ -877,6 +890,8 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { len, flags, ) @@ -207,5 +243,5 @@ index f3a45d2..1c2f0ce 100644 #[cfg(any(target_os = "freebsd", -- -2.11.0 +2.17.2 (Apple Git-113) From b2f7386f7ed34f24f293c201779a89cbc08f8243 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 17 Nov 2018 11:41:20 +0100 Subject: [PATCH 0366/1566] Fix fn(&T) -> for<'l> fn(&'l T) write --- src/common.rs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/common.rs b/src/common.rs index 77376182756a5..e3f13260e8b1b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -370,8 +370,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { - match (&self.layout().ty.sty, &from.layout().ty.sty) { - (ty::Ref(_, t, dest_mut), ty::Ref(_, u, src_mut)) + let from_ty = from.layout().ty; + let to_ty = self.layout().ty; + match (&from_ty.sty, &to_ty.sty) { + (ty::Ref(_, t, src_mut), ty::Ref(_, u, dest_mut)) if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable && src_mut != dest_mut { @@ -385,13 +387,26 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { // &mut T -> &T is allowed // &'a T -> &'b T is allowed } + (ty::FnPtr(_), ty::FnPtr(_)) => { + let from_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &from_ty.fn_sig(fx.tcx)); + let to_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &to_ty.fn_sig(fx.tcx)); + assert_eq!( + from_sig, + to_sig, + "Can't write fn ptr with incompatible sig {:?} to place with sig {:?}\n\n{:#?}", + from_sig, + to_sig, + fx, + ); + // fn(&T) -> for<'l> fn(&'l T) is allowed + } _ => { assert_eq!( - self.layout().ty, - from.layout().ty, - "Can't write value of incompatible type to place {:?} {:?}\n\n{:#?}", - self.layout().ty.sty, - from.layout().ty.sty, + from_ty, + to_ty, + "Can't write value with incompatible type {:?} to place with type {:?}\n\n{:#?}", + from_ty.sty, + to_ty.sty, fx, ); } From e3bbef764c6d2b8655a8d2f8540b5aaffa1924ef Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 17 Nov 2018 12:24:35 +0100 Subject: [PATCH 0367/1566] Some changes to Readme.md `rustup override set nightly` is not needed, because there is a `rust-toolchain` file. cc #165 --- Readme.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index f43f909e9c7a9..85f7bd9a72f73 100644 --- a/Readme.md +++ b/Readme.md @@ -22,7 +22,7 @@ $ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_c ## Build sysroot and test ```bash -$ rustup component add rust-src # Make sure the sysroot source is availablr +$ rustup component add rust-src # Make sure the sysroot source is available $ ./prepare_libcore.sh # Patch the sysroot source for some not yet supported things $ ./build.sh ``` @@ -36,3 +36,13 @@ $ ./build.sh * libstd (needs varargs and some other stuff) ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/146)) * u128 and i128 ([no cranelift support](https://github.com/CraneStation/cranelift/issues/354)) * SIMD (huge amount of work to get all intrinsics implemented, so may never be supported) + +## Troubleshooting + +### Can't compile + +Try updating your nightly compiler. You can try to use an nightly a day or two older if updating rustc doesn't fix it. If you still can't compile it, please fill an issue. + +### error[E0463]: can't find crate for `std` while compiling a no_std crate + +If you use `RUSTFLAGS` to pass `-Zcodegen-backend` to rustc, cargo will compile `build-dependencies` with those flags too. Because this project doesn't support libstd yet, that will result in an error. I don't know of any way to fix this. :( From 16334be18e50be2a66675a860e4d600c288ff34c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 17 Nov 2018 15:02:57 +0100 Subject: [PATCH 0368/1566] Remove a workaround for icmp.i8/i16 not having an encoding --- example/mini_core.rs | 4 ++-- src/base.rs | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index b8504a147715b..83dd4f10f5e95 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,4 +1,4 @@ -#![feature(no_core, lang_items, intrinsics, unboxed_closures)] +#![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription)] #![no_core] #![allow(dead_code)] @@ -246,7 +246,7 @@ pub struct Box(*mut T); impl, U: ?Sized> CoerceUnsized> for Box {} -static mut MY_TINY_HEAP: [u8; 16] = [0; 16]; +static mut MY_TINY_HEAP: [u8; 16] = [0xff; 16]; #[lang = "exchange_malloc"] unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { diff --git a/src/base.rs b/src/base.rs index 1be7942c84b98..a4645ea7e0129 100644 --- a/src/base.rs +++ b/src/base.rs @@ -18,7 +18,9 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( ) { match mono_item { MonoItem::Fn(inst) => { - let _inst_guard = PrintOnPanic(|| format!("{:?}", inst)); + let _inst_guard = PrintOnPanic(|| { + format!("{:?} {}", inst, tcx.symbol_name(inst).as_str()) + }); let _mir_guard = PrintOnPanic(|| { match inst.def { InstanceDef::Item(_) @@ -761,14 +763,7 @@ macro_rules! binop_match { assert_eq!($fx.tcx.types.bool, $ret_ty); let ret_layout = $fx.layout_of($ret_ty); - // TODO HACK no encoding for icmp.i8 - use crate::common::clif_intcast; - let (lhs, rhs) = ( - clif_intcast($fx, $lhs, types::I64, $signed), - clif_intcast($fx, $rhs, types::I64, $signed), - ); - let b = $fx.bcx.ins().icmp(IntCC::$cc, lhs, rhs); - + let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); CValue::ByVal($fx.bcx.ins().bint(types::I8, b), ret_layout) }}; (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ From 06202c007c7000148ed2901b9f50dc99de9b1d30 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 17 Nov 2018 18:23:52 +0100 Subject: [PATCH 0369/1566] Fix some 2018 edition idioms --- src/allocator.rs | 2 +- src/analyze.rs | 2 +- src/base.rs | 2 +- src/common.rs | 2 +- src/lib.rs | 26 ++++++-------------------- src/link_copied.rs | 1 + src/metadata.rs | 1 + 7 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 2474e01467004..ba1eda7148fd0 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -63,7 +63,7 @@ pub fn codegen(module: &mut Module, kind: AllocatorKind) ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); { let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); + let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); let ebb = bcx.create_ebb(); bcx.switch_to_block(ebb); diff --git a/src/analyze.rs b/src/analyze.rs index 025fc1fecba67..d3cbe93b722bb 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -2,7 +2,7 @@ use crate::prelude::*; use rustc::mir::StatementKind::*; -bitflags! { +bitflags::bitflags! { pub struct Flags: u8 { const NOT_SSA = 0b00000001; } diff --git a/src/base.rs b/src/base.rs index a4645ea7e0129..5607df4883822 100644 --- a/src/base.rs +++ b/src/base.rs @@ -74,7 +74,7 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 3. Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut func, &mut func_ctx); + let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); // Step 4. Predefine ebb's let start_ebb = bcx.create_ebb(); diff --git a/src/common.rs b/src/common.rs index e3f13260e8b1b..02e04f0d3eb9e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -603,7 +603,7 @@ pub fn clif_intcast<'a, 'tcx: 'a>( } } -pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { +pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, pub pointer_type: Type, // Cached from module diff --git a/src/lib.rs b/src/lib.rs index 5b25861838eef..9f81cebccafa9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,32 +7,17 @@ )] #![allow(intra_doc_link_resolution_failure)] -extern crate byteorder; extern crate syntax; -#[macro_use] extern crate rustc; extern crate rustc_allocator; extern crate rustc_codegen_utils; extern crate rustc_incremental; extern crate rustc_mir; extern crate rustc_target; -#[macro_use] extern crate rustc_data_structures; extern crate rustc_fs_util; -#[macro_use] extern crate log; -extern crate ar; -#[macro_use] -extern crate bitflags; -extern crate faerie; -//extern crate goblin; -extern crate cranelift; -extern crate cranelift_faerie; -extern crate cranelift_module; -extern crate cranelift_simplejit; -extern crate target_lexicon; - use std::any::Any; use std::fs::File; use std::sync::mpsc; @@ -84,6 +69,7 @@ mod prelude { pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::source_map::DUMMY_SP; + pub use rustc::bug; pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; pub use rustc::mir::{self, interpret::AllocId, *}; pub use rustc::session::{ @@ -291,7 +277,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } } - fn metadata_loader(&self) -> Box { + fn metadata_loader(&self) -> Box { Box::new(crate::metadata::CraneliftMetadataLoader) } @@ -308,8 +294,8 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_crate<'a, 'tcx>( &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, - _rx: mpsc::Receiver>, - ) -> Box { + _rx: mpsc::Receiver>, + ) -> Box { if !tcx.sess.crate_types.get().contains(&CrateType::Executable) && std::env::var("SHOULD_RUN").is_ok() { @@ -436,7 +422,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn join_codegen_and_link( &self, - res: Box, + res: Box, sess: &Session, _dep_graph: &DepGraph, outputs: &OutputFilenames, @@ -512,6 +498,6 @@ fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { /// This is the entrypoint for a hot plugged rustc_codegen_cranelift #[no_mangle] -pub fn __rustc_codegen_backend() -> Box { +pub fn __rustc_codegen_backend() -> Box { Box::new(CraneliftCodegenBackend) } diff --git a/src/link_copied.rs b/src/link_copied.rs index 986fe71e906b3..2bec64612aaae 100644 --- a/src/link_copied.rs +++ b/src/link_copied.rs @@ -9,6 +9,7 @@ use std::path::{Path, PathBuf}; use std::process::{Output, Stdio}; use cc::windows_registry; +use log::info; use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; use rustc::middle::dependency_format::Linkage; diff --git a/src/metadata.rs b/src/metadata.rs index c70fdba35d848..c9cdb44d87d17 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,5 +1,6 @@ use rustc::middle::cstore::MetadataLoader; use rustc_data_structures::owning_ref::{self, OwningRef}; +use rustc_data_structures::rustc_erase_owner; use std::fs::File; use std::path::Path; From f4ae9a4dbb79758a2e3d16ff0854301ce5846ae1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 24 Nov 2018 11:23:49 +0100 Subject: [PATCH 0370/1566] Rustup to rustc 1.32.0-nightly (1f57e4841 2018-11-23) --- Cargo.lock | 1 - Cargo.toml | 1 - src/base.rs | 6 +- src/constant.rs | 10 +++- src/intrinsics.rs | 6 +- src/lib.rs | 139 +++---------------------------------------- src/link.rs | 5 +- src/link_copied.rs | 145 +-------------------------------------------- src/vtable.rs | 10 ++-- 9 files changed, 33 insertions(+), 290 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbfe536eaf70c..999353c4cfa3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -482,7 +482,6 @@ dependencies = [ "ar 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/Cargo.toml b/Cargo.toml index 61cd7707c69a4..ee7ea811ad320 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,6 @@ faerie = "0.6.0" ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.6" -cc = "1.0.25" libc = "0.2.43" tempfile = "3.0.4" diff --git a/src/base.rs b/src/base.rs index 5607df4883822..d7edf23af7fd8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -604,9 +604,9 @@ fn trans_stmt<'a, 'tcx: 'a>( use rustc::middle::lang_items::ExchangeMallocFnLangItem; let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); - let (size, align) = fx.layout_of(content_ty).size_and_align(); - let llsize = fx.bcx.ins().iconst(usize_type, size.bytes() as i64); - let llalign = fx.bcx.ins().iconst(usize_type, align.abi() as i64); + let layout = fx.layout_of(content_ty); + let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64); + let llalign = fx.bcx.ins().iconst(usize_type, layout.align.abi.bytes() as i64); let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty)); // Allocate space: diff --git a/src/constant.rs b/src/constant.rs index 3a27b1abdbbeb..d3c8a3b570487 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::Const; use rustc_mir::interpret::{ - EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, + EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, }; use cranelift_module::*; @@ -133,7 +133,13 @@ fn trans_const_place<'a, 'tcx: 'a>( ty::ParamEnv::reveal_all(), TransPlaceInterpreter, ); - let op = ecx.const_to_op(const_)?; + ecx.push_stack_frame(fx.instance, DUMMY_SP, fx.mir, None, StackPopCleanup::None { cleanup: false }).unwrap(); + let op = ecx.eval_operand(&Operand::Constant(Box::new(Constant { + span: DUMMY_SP, + ty: const_.ty, + user_ty: None, + literal: const_, + })), None)?; let ptr = ecx.allocate(op.layout, MemoryKind::Stack)?; ecx.copy_op(op, ptr.into())?; let alloc = ecx.memory().get(ptr.to_ptr()?.alloc_id)?; diff --git a/src/intrinsics.rs b/src/intrinsics.rs index b59e1c6631b4d..bb565ea38a51b 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -169,7 +169,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); }; min_align_of, () { - let min_align = fx.layout_of(T).align.abi(); + let min_align = fx.layout_of(T).align.abi.bytes(); let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); ret.write_cvalue(fx, min_align); }; @@ -179,9 +179,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if !layout.is_unsized() => fx .bcx .ins() - .iconst(fx.pointer_type, layout.align.abi() as i64), + .iconst(fx.pointer_type, layout.align.abi.bytes() as i64), ty::Slice(elem) => { - let align = fx.layout_of(elem).align.abi() as i64; + let align = fx.layout_of(elem).align.abi.bytes() as i64; fx.bcx.ins().iconst(fx.pointer_type, align) } ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, ptr), diff --git a/src/lib.rs b/src/lib.rs index 9f81cebccafa9..e1dcab738bc99 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,6 @@ rustc_private, macro_at_most_once_rep, never_type, - extern_crate_item_prelude, decl_macro, )] #![allow(intra_doc_link_resolution_failure)] @@ -10,6 +9,7 @@ extern crate syntax; extern crate rustc; extern crate rustc_allocator; +extern crate rustc_codegen_ssa; extern crate rustc_codegen_utils; extern crate rustc_incremental; extern crate rustc_mir; @@ -25,19 +25,16 @@ use std::sync::mpsc; use syntax::symbol::Symbol; use rustc::dep_graph::DepGraph; -use rustc::middle::cstore::{ - self, CrateSource, LibSource, LinkagePreference, MetadataLoader, NativeLibrary, -}; -use rustc::middle::lang_items::LangItem; -use rustc::middle::weak_lang_items; +use rustc::middle::cstore::MetadataLoader; use rustc::session::{ - config::{self, OutputFilenames, OutputType}, + config::{OutputFilenames, OutputType}, CompileIncomplete, }; use rustc::ty::query::Providers; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::out_filename; -use rustc_codegen_utils::linker::LinkerInfo; +use rustc_codegen_ssa::CrateInfo; +use rustc_codegen_ssa::back::linker::LinkerInfo; use cranelift::codegen::settings; use cranelift_faerie::*; @@ -81,7 +78,7 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; - pub use rustc_codegen_utils::{CompiledModule, ModuleKind}; + pub use rustc_codegen_ssa::{CompiledModule, ModuleKind}; pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, indexed_vec::Idx, @@ -103,7 +100,7 @@ mod prelude { pub use crate::common::*; pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; - pub use crate::{Caches, CodegenResults, CrateInfo}; + pub use crate::{Caches, CodegenResults}; } pub struct Caches<'tcx> { @@ -122,124 +119,6 @@ impl<'tcx> Caches<'tcx> { struct CraneliftCodegenBackend; -pub struct CrateInfo { - panic_runtime: Option, - compiler_builtins: Option, - profiler_runtime: Option, - sanitizer_runtime: Option, - is_no_builtins: FxHashSet, - native_libraries: FxHashMap>>, - crate_name: FxHashMap, - used_libraries: Lrc>, - link_args: Lrc>, - used_crate_source: FxHashMap>, - used_crates_static: Vec<(CrateNum, LibSource)>, - used_crates_dynamic: Vec<(CrateNum, LibSource)>, - wasm_imports: FxHashMap, - lang_item_to_crate: FxHashMap, - missing_lang_items: FxHashMap>, -} - -impl CrateInfo { - pub fn new(tcx: TyCtxt) -> CrateInfo { - let mut info = CrateInfo { - panic_runtime: None, - compiler_builtins: None, - profiler_runtime: None, - sanitizer_runtime: None, - is_no_builtins: Default::default(), - native_libraries: Default::default(), - used_libraries: tcx.native_libraries(LOCAL_CRATE), - link_args: tcx.link_args(LOCAL_CRATE), - crate_name: Default::default(), - used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic), - used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), - used_crate_source: Default::default(), - wasm_imports: Default::default(), - lang_item_to_crate: Default::default(), - missing_lang_items: Default::default(), - }; - let lang_items = tcx.lang_items(); - - let load_wasm_items = tcx - .sess - .crate_types - .borrow() - .iter() - .any(|c| *c != config::CrateType::Rlib) - && tcx.sess.opts.target_triple.triple() == "wasm32-unknown-unknown"; - - if load_wasm_items { - info.load_wasm_imports(tcx, LOCAL_CRATE); - } - - let crates = tcx.crates(); - - let n_crates = crates.len(); - info.native_libraries.reserve(n_crates); - info.crate_name.reserve(n_crates); - info.used_crate_source.reserve(n_crates); - info.missing_lang_items.reserve(n_crates); - - for &cnum in crates.iter() { - info.native_libraries - .insert(cnum, tcx.native_libraries(cnum)); - info.crate_name - .insert(cnum, tcx.crate_name(cnum).to_string()); - info.used_crate_source - .insert(cnum, tcx.used_crate_source(cnum)); - if tcx.is_panic_runtime(cnum) { - info.panic_runtime = Some(cnum); - } - if tcx.is_compiler_builtins(cnum) { - info.compiler_builtins = Some(cnum); - } - if tcx.is_profiler_runtime(cnum) { - info.profiler_runtime = Some(cnum); - } - if tcx.is_sanitizer_runtime(cnum) { - info.sanitizer_runtime = Some(cnum); - } - if tcx.is_no_builtins(cnum) { - info.is_no_builtins.insert(cnum); - } - if load_wasm_items { - info.load_wasm_imports(tcx, cnum); - } - let missing = tcx.missing_lang_items(cnum); - for &item in missing.iter() { - if let Ok(id) = lang_items.require(item) { - info.lang_item_to_crate.insert(item, id.krate); - } - } - - // No need to look for lang items that are whitelisted and don't - // actually need to exist. - let missing = missing - .iter() - .cloned() - .filter(|&l| !weak_lang_items::whitelisted(tcx, l)) - .collect(); - info.missing_lang_items.insert(cnum, missing); - } - - return info; - } - - fn load_wasm_imports(&mut self, tcx: TyCtxt, cnum: CrateNum) { - self.wasm_imports.extend( - tcx.wasm_import_module_map(cnum) - .iter() - .map(|(&id, module)| { - let instance = Instance::mono(tcx, id); - let import_name = tcx.symbol_name(instance); - - (import_name.to_string(), module.clone()) - }), - ); - } -} - pub struct CodegenResults { artifact: faerie::Artifact, modules: Vec, @@ -283,12 +162,12 @@ impl CodegenBackend for CraneliftCodegenBackend { fn provide(&self, providers: &mut Providers) { rustc_codegen_utils::symbol_names::provide(providers); - rustc_codegen_utils::symbol_export::provide(providers); + rustc_codegen_ssa::back::symbol_export::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| Lrc::new(Default::default()); } fn provide_extern(&self, providers: &mut Providers) { - rustc_codegen_utils::symbol_export::provide_extern(providers); + rustc_codegen_ssa::back::symbol_export::provide_extern(providers); } fn codegen_crate<'a, 'tcx>( diff --git a/src/link.rs b/src/link.rs index 5fccac4712380..28cc73797453e 100644 --- a/src/link.rs +++ b/src/link.rs @@ -8,8 +8,9 @@ use tempfile::Builder as TempFileBuilder; use rustc::session::config::{self, CrateType, DebugInfo, RUST_CGU_EXT}; use rustc::session::search_paths::PathKind; use rustc::session::Session; -use rustc_codegen_utils::command::Command; -use rustc_codegen_utils::linker::*; +use rustc_codegen_ssa::back::command::Command; +use rustc_codegen_ssa::back::linker::*; +use rustc_codegen_ssa::back::link::*; use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel}; diff --git a/src/link_copied.rs b/src/link_copied.rs index 2bec64612aaae..bf5be809a0e55 100644 --- a/src/link_copied.rs +++ b/src/link_copied.rs @@ -1,6 +1,5 @@ //! All functions here are copied from https://github.com/rust-lang/rust/blob/942864a000efd74b73e36bda5606b2cdb55ecf39/src/librustc_codegen_llvm/back/link.rs -use std::env; use std::fmt; use std::fs; use std::io; @@ -8,7 +7,6 @@ use std::iter; use std::path::{Path, PathBuf}; use std::process::{Output, Stdio}; -use cc::windows_registry; use log::info; use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; @@ -17,11 +15,11 @@ use rustc::session::config::{self, OutputType, RUST_CGU_EXT}; use rustc::session::search_paths::PathKind; use rustc::session::Session; use rustc::util::common::time; -use rustc_codegen_utils::command::Command; -use rustc_codegen_utils::linker::*; +use rustc_codegen_ssa::back::command::Command; +use rustc_codegen_ssa::back::linker::*; +use rustc_codegen_ssa::back::link::*; use rustc_data_structures::fx::FxHashSet; use rustc_fs_util::fix_windows_verbatim_for_gcc; -use rustc_target::spec::LinkerFlavor; use syntax::attr; use crate::prelude::*; @@ -52,125 +50,6 @@ fn archive_config<'a>(sess: &'a Session, } } -// The third parameter is for env vars, used on windows to set up the -// path for MSVC to find its DLLs, and gcc to find its bundled -// toolchain -pub fn get_linker(sess: &Session, linker: &Path, flavor: LinkerFlavor) -> (PathBuf, Command) { - let msvc_tool = windows_registry::find_tool(&sess.opts.target_triple.triple(), "link.exe"); - - // If our linker looks like a batch script on Windows then to execute this - // we'll need to spawn `cmd` explicitly. This is primarily done to handle - // emscripten where the linker is `emcc.bat` and needs to be spawned as - // `cmd /c emcc.bat ...`. - // - // This worked historically but is needed manually since #42436 (regression - // was tagged as #42791) and some more info can be found on #44443 for - // emscripten itself. - let mut cmd = match linker.to_str() { - Some(linker) if cfg!(windows) && linker.ends_with(".bat") => Command::bat_script(linker), - _ => match flavor { - LinkerFlavor::Lld(f) => Command::lld(linker, f), - LinkerFlavor::Msvc - if sess.opts.cg.linker.is_none() && sess.target.target.options.linker.is_none() => - { - Command::new(msvc_tool.as_ref().map(|t| t.path()).unwrap_or(linker)) - }, - _ => Command::new(linker), - } - }; - - // The compiler's sysroot often has some bundled tools, so add it to the - // PATH for the child. - let mut new_path = sess.host_filesearch(PathKind::All) - .get_tools_search_paths(); - let mut msvc_changed_path = false; - if sess.target.target.options.is_like_msvc { - if let Some(ref tool) = msvc_tool { - cmd.args(tool.args()); - for &(ref k, ref v) in tool.env() { - if k == "PATH" { - new_path.extend(env::split_paths(v)); - msvc_changed_path = true; - } else { - cmd.env(k, v); - } - } - } - } - - if !msvc_changed_path { - if let Some(path) = env::var_os("PATH") { - new_path.extend(env::split_paths(&path)); - } - } - cmd.env("PATH", env::join_paths(new_path).unwrap()); - - (linker.to_path_buf(), cmd) -} - -pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { - fn infer_from( - sess: &Session, - linker: Option, - flavor: Option, - ) -> Option<(PathBuf, LinkerFlavor)> { - match (linker, flavor) { - (Some(linker), Some(flavor)) => Some((linker, flavor)), - // only the linker flavor is known; use the default linker for the selected flavor - (None, Some(flavor)) => Some((PathBuf::from(match flavor { - LinkerFlavor::Em => if cfg!(windows) { "emcc.bat" } else { "emcc" }, - LinkerFlavor::Gcc => "cc", - LinkerFlavor::Ld => "ld", - LinkerFlavor::Msvc => "link.exe", - LinkerFlavor::Lld(_) => "lld", - }), flavor)), - (Some(linker), None) => { - let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { - sess.fatal("couldn't extract file stem from specified linker"); - }).to_owned(); - - let flavor = if stem == "emcc" { - LinkerFlavor::Em - } else if stem == "gcc" || stem.ends_with("-gcc") { - LinkerFlavor::Gcc - } else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") { - LinkerFlavor::Ld - } else if stem == "link" || stem == "lld-link" { - LinkerFlavor::Msvc - } else if stem == "lld" || stem == "rust-lld" { - LinkerFlavor::Lld(sess.target.target.options.lld_flavor) - } else { - // fall back to the value in the target spec - sess.target.target.linker_flavor - }; - - Some((linker, flavor)) - }, - (None, None) => None, - } - } - - // linker and linker flavor specified via command line have precedence over what the target - // specification specifies - if let Some(ret) = infer_from( - sess, - sess.opts.cg.linker.clone(), - sess.opts.debugging_opts.linker_flavor, - ) { - return ret; - } - - if let Some(ret) = infer_from( - sess, - sess.target.target.options.linker.clone().map(PathBuf::from), - Some(sess.target.target.linker_flavor), - ) { - return ret; - } - - bug!("Not enough information provided to determine how to invoke the linker"); -} - pub fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &Path) -> io::Result { @@ -739,24 +618,6 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker, } } -/// Returns a boolean indicating whether the specified crate should be ignored -/// during LTO. -/// -/// Crates ignored during LTO are not lumped together in the "massive object -/// file" that we create and are linked in their normal rlib states. See -/// comments below for what crates do not participate in LTO. -/// -/// It's unusual for a crate to not participate in LTO. Typically only -/// compiler-specific and unstable crates have a reason to not participate in -/// LTO. -fn ignored_for_lto(sess: &Session, info: &CrateInfo, cnum: CrateNum) -> bool { - // If our target enables builtin function lowering in LLVM then the - // crates providing these functions don't participate in LTO (e.g. - // no_builtins or compiler builtins crates). - !sess.target.target.options.no_builtins && - (info.is_no_builtins.contains(&cnum) || info.compiler_builtins == Some(cnum)) -} - fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { match lib.cfg { Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None), diff --git a/src/vtable.rs b/src/vtable.rs index d0ea60666d180..b9045a8eeba3f 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -75,10 +75,6 @@ fn build_vtable<'a, 'tcx: 'a>( let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; - let (size, align) = tcx - .layout_of(ParamEnv::reveal_all().and(ty)) - .unwrap() - .size_and_align(); let drop_in_place_fn = fx.get_function_id( crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty), ); @@ -101,8 +97,10 @@ fn build_vtable<'a, 'tcx: 'a>( .take(components.len() * usize_size) .collect::>() .into_boxed_slice(); - write_usize(fx.tcx, &mut data, SIZE_INDEX, size.bytes()); - write_usize(fx.tcx, &mut data, ALIGN_INDEX, align.abi()); + + let layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + write_usize(fx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); + write_usize(fx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); data_ctx.define(data); for (i, component) in components.into_iter().enumerate() { From 8e28d80a3db694e6e17d89988f74d36c316470a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Nov 2018 19:11:21 +0100 Subject: [PATCH 0371/1566] Better use of CodegenResults::modules --- src/lib.rs | 5 +---- src/link.rs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e1dcab738bc99..625256b0f533f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -120,7 +120,6 @@ impl<'tcx> Caches<'tcx> { struct CraneliftCodegenBackend; pub struct CodegenResults { - artifact: faerie::Artifact, modules: Vec, allocator_module: Option, metadata: Vec, @@ -281,19 +280,17 @@ impl CodegenBackend for CraneliftCodegenBackend { std::fs::write(&tmp_file, obj).unwrap(); return Box::new(CodegenResults { - artifact, metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), crate_info: CrateInfo::new(tcx), linker_info: LinkerInfo::new(tcx), modules: vec![CompiledModule { - name: "dummy".to_string(), + name: "dummy_name".to_string(), kind: ModuleKind::Regular, object: Some(tmp_file), bytecode: None, bytecode_compressed: None, }], - //modules: vec![], allocator_module: None, }); } diff --git a/src/link.rs b/src/link.rs index 28cc73797453e..7a13d7094cc4a 100644 --- a/src/link.rs +++ b/src/link.rs @@ -23,13 +23,17 @@ pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathB let mut builder = ar::Builder::new(file); // Add main object file - let obj = res.artifact.emit().unwrap(); - builder - .append( - &ar::Header::new(b"data.o".to_vec(), obj.len() as u64), - ::std::io::Cursor::new(obj), - ) - .unwrap(); + for module in &res.modules { + if let Some(ref object_path) = module.object { + let object = File::open(object_path).expect("Someone deleted our object file"); + let object_len = object.metadata().unwrap().len(); + builder.append( + &ar::Header::new((module.name.to_string() + RUST_CGU_EXT).into_bytes(), object_len), + object, + ) + .unwrap(); + } + } // Non object files need to be added after object files, because ranlib will // try to read the native architecture from the first file, even if it isn't @@ -63,10 +67,6 @@ pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_fil Err(err) => sess.fatal(&format!("couldn't create a temp dir: {}", err)), }; - // TODO: link executable - let obj = codegen_results.artifact.emit().unwrap(); - std::fs::write(tmpdir.path().join("out".to_string() + RUST_CGU_EXT), obj).unwrap(); - let (linker, flavor) = linker_and_flavor(sess); let (pname, mut cmd) = get_linker(sess, &linker, flavor); From 6559029b9d4037183a8d4b36eff2301bf67e5d05 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Nov 2018 19:17:25 +0100 Subject: [PATCH 0372/1566] Use rustc_codegen_ssa::CodegenResults --- src/lib.rs | 30 ++++++++++++++---------------- src/link.rs | 4 ++-- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 625256b0f533f..dbe3536ecfe5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,8 +22,6 @@ use std::any::Any; use std::fs::File; use std::sync::mpsc; -use syntax::symbol::Symbol; - use rustc::dep_graph::DepGraph; use rustc::middle::cstore::MetadataLoader; use rustc::session::{ @@ -78,7 +76,7 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; - pub use rustc_codegen_ssa::{CompiledModule, ModuleKind}; + pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, indexed_vec::Idx, @@ -100,7 +98,7 @@ mod prelude { pub use crate::common::*; pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; - pub use crate::{Caches, CodegenResults}; + pub use crate::Caches; } pub struct Caches<'tcx> { @@ -119,15 +117,6 @@ impl<'tcx> Caches<'tcx> { struct CraneliftCodegenBackend; -pub struct CodegenResults { - modules: Vec, - allocator_module: Option, - metadata: Vec, - crate_name: Symbol, - crate_info: CrateInfo, - linker_info: LinkerInfo, -} - impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { for cty in sess.opts.crate_types.iter() { @@ -280,10 +269,7 @@ impl CodegenBackend for CraneliftCodegenBackend { std::fs::write(&tmp_file, obj).unwrap(); return Box::new(CodegenResults { - metadata: metadata.raw_data, crate_name: tcx.crate_name(LOCAL_CRATE), - crate_info: CrateInfo::new(tcx), - linker_info: LinkerInfo::new(tcx), modules: vec![CompiledModule { name: "dummy_name".to_string(), kind: ModuleKind::Regular, @@ -292,6 +278,18 @@ impl CodegenBackend for CraneliftCodegenBackend { bytecode_compressed: None, }], allocator_module: None, + metadata_module: CompiledModule { + name: "dummy_metadata".to_string(), + kind: ModuleKind::Metadata, + object: None, + bytecode: None, + bytecode_compressed: None, + }, + crate_hash: tcx.crate_hash(LOCAL_CRATE), + metadata, + windows_subsystem: None, // Windows is not yet supported + linker_info: LinkerInfo::new(tcx), + crate_info: CrateInfo::new(tcx), }); } } diff --git a/src/link.rs b/src/link.rs index 7a13d7094cc4a..42e4b55f803af 100644 --- a/src/link.rs +++ b/src/link.rs @@ -42,9 +42,9 @@ pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathB .append( &ar::Header::new( crate::metadata::METADATA_FILENAME.as_bytes().to_vec(), - res.metadata.len() as u64, + res.metadata.raw_data.len() as u64, ), - ::std::io::Cursor::new(res.metadata.clone()), + ::std::io::Cursor::new(res.metadata.raw_data.clone()), ) .unwrap(); From 830522af6da7e70dad5a53bfcb2a9ba757b8b78f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 21 Nov 2018 16:01:33 +0100 Subject: [PATCH 0373/1566] Implement BackendTypes for FunctionCx --- src/common.rs | 10 ++++++++++ src/lib.rs | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index 02e04f0d3eb9e..5093f324a0c2c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,6 @@ use std::fmt; +use rustc_codegen_ssa::traits::BackendTypes; use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::Module; @@ -667,6 +668,15 @@ impl<'a, 'tcx, B: Backend + 'a> HasTargetSpec for FunctionCx<'a, 'tcx, B> { } } +impl<'a, 'tcx, B: Backend> BackendTypes for FunctionCx<'a, 'tcx, B> { + type Value = Value; + type BasicBlock = Ebb; + type Type = Type; + type Context = !; + type Funclet = !; + type DIScope = !; +} + impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { pub fn monomorphize(&self, value: &T) -> T where diff --git a/src/lib.rs b/src/lib.rs index dbe3536ecfe5b..cfd41ba06486b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,7 +76,6 @@ mod prelude { self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; - pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, indexed_vec::Idx, @@ -84,6 +83,9 @@ mod prelude { }; pub use rustc_mir::monomorphize::{collector, MonoItem}; + pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; + pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; + pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, }; From 89702b9917e183dbb3037abadee6da1773c68f98 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 23 Nov 2018 17:29:21 +0100 Subject: [PATCH 0374/1566] Update Cranelift, libc and redox_syscall --- Cargo.lock | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 999353c4cfa3f..0d5935b71f109 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -39,7 +39,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -50,7 +50,7 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" [[package]] name = "cranelift-faerie" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,13 +186,13 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#ede366644f3777d43448367df1af86e52c21660b" +source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -216,7 +216,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -226,7 +226,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -328,7 +328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.43" +version = "0.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -344,7 +344,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -353,7 +353,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -390,7 +390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -420,7 +420,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.40" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -428,7 +428,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -457,7 +457,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -487,7 +487,7 @@ dependencies = [ "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -622,9 +622,9 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -642,8 +642,8 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -772,7 +772,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" +"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" @@ -784,7 +784,7 @@ dependencies = [ "checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" -"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cf8fb82a4d1c9b28f1c26c574a5b541f5ffb4315f6c9a791fa47b6a04438fe93" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" "checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" From 95539518ec16a4b2599f8046d51bc0e36bc9e8b2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 24 Nov 2018 12:47:53 +0100 Subject: [PATCH 0375/1566] Rustfmt --- src/base.rs | 24 +++++++++++++++--------- src/common.rs | 23 +++++++++++++++-------- src/constant.rs | 24 +++++++++++++++++------- src/lib.rs | 30 +++++++++++++----------------- src/link.rs | 16 ++++++++++------ src/trap.rs | 1 + src/unimpl.rs | 12 ++++++++---- 7 files changed, 79 insertions(+), 51 deletions(-) diff --git a/src/base.rs b/src/base.rs index d7edf23af7fd8..97f97f255622a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -18,9 +18,8 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( ) { match mono_item { MonoItem::Fn(inst) => { - let _inst_guard = PrintOnPanic(|| { - format!("{:?} {}", inst, tcx.symbol_name(inst).as_str()) - }); + let _inst_guard = + PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).as_str())); let _mir_guard = PrintOnPanic(|| { match inst.def { InstanceDef::Item(_) @@ -377,8 +376,9 @@ fn trans_stmt<'a, 'tcx: 'a>( if *variant_index != dataful_variant { let niche = place.place_field(fx, mir::Field::new(0)); //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); - let niche_value = ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) - .wrapping_add(niche_start); + let niche_value = + ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) + .wrapping_add(niche_start); // FIXME(eddyb) Check the actual primitive type here. let niche_llval = if niche_value == 0 { CValue::const_val(fx, niche.layout().ty, 0) @@ -606,7 +606,10 @@ fn trans_stmt<'a, 'tcx: 'a>( let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); let layout = fx.layout_of(content_ty); let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64); - let llalign = fx.bcx.ins().iconst(usize_type, layout.align.abi.bytes() as i64); + let llalign = fx + .bcx + .ins() + .iconst(usize_type, layout.align.abi.bytes() as i64); let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty)); // Allocate space: @@ -688,9 +691,12 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( } match layout.variants { layout::Variants::Single { index } => { - let discr_val = layout.ty.ty_adt_def().map_or(index.as_u32() as u128, |def| { - def.discriminant_for_variant(fx.tcx, index).val - }); + let discr_val = layout + .ty + .ty_adt_def() + .map_or(index.as_u32() as u128, |def| { + def.discriminant_for_variant(fx.tcx, index).val + }); return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); } layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {} diff --git a/src/common.rs b/src/common.rs index 5093f324a0c2c..a74abc8ef24ca 100644 --- a/src/common.rs +++ b/src/common.rs @@ -389,15 +389,18 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { // &'a T -> &'b T is allowed } (ty::FnPtr(_), ty::FnPtr(_)) => { - let from_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &from_ty.fn_sig(fx.tcx)); - let to_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &to_ty.fn_sig(fx.tcx)); + let from_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &from_ty.fn_sig(fx.tcx), + ); + let to_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &to_ty.fn_sig(fx.tcx), + ); assert_eq!( - from_sig, - to_sig, + from_sig, to_sig, "Can't write fn ptr with incompatible sig {:?} to place with sig {:?}\n\n{:#?}", - from_sig, - to_sig, - fx, + from_sig, to_sig, fx, ); // fn(&T) -> for<'l> fn(&'l T) is allowed } @@ -577,7 +580,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx, impl Backend>, variant: VariantIdx) -> Self { + pub fn downcast_variant( + self, + fx: &FunctionCx<'a, 'tcx, impl Backend>, + variant: VariantIdx, + ) -> Self { let layout = self.layout().for_variant(fx, variant); self.unchecked_cast_to(layout) } diff --git a/src/constant.rs b/src/constant.rs index d3c8a3b570487..7fef96a39b4c2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -133,13 +133,23 @@ fn trans_const_place<'a, 'tcx: 'a>( ty::ParamEnv::reveal_all(), TransPlaceInterpreter, ); - ecx.push_stack_frame(fx.instance, DUMMY_SP, fx.mir, None, StackPopCleanup::None { cleanup: false }).unwrap(); - let op = ecx.eval_operand(&Operand::Constant(Box::new(Constant { - span: DUMMY_SP, - ty: const_.ty, - user_ty: None, - literal: const_, - })), None)?; + ecx.push_stack_frame( + fx.instance, + DUMMY_SP, + fx.mir, + None, + StackPopCleanup::None { cleanup: false }, + ) + .unwrap(); + let op = ecx.eval_operand( + &Operand::Constant(Box::new(Constant { + span: DUMMY_SP, + ty: const_.ty, + user_ty: None, + literal: const_, + })), + None, + )?; let ptr = ecx.allocate(op.layout, MemoryKind::Stack)?; ecx.copy_op(op, ptr.into())?; let alloc = ecx.memory().get(ptr.to_ptr()?.alloc_id)?; diff --git a/src/lib.rs b/src/lib.rs index cfd41ba06486b..04e0af9cc40a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,22 +1,17 @@ -#![feature( - rustc_private, - macro_at_most_once_rep, - never_type, - decl_macro, -)] +#![feature(rustc_private, macro_at_most_once_rep, never_type, decl_macro)] #![allow(intra_doc_link_resolution_failure)] -extern crate syntax; +extern crate log; extern crate rustc; extern crate rustc_allocator; extern crate rustc_codegen_ssa; extern crate rustc_codegen_utils; +extern crate rustc_data_structures; +extern crate rustc_fs_util; extern crate rustc_incremental; extern crate rustc_mir; extern crate rustc_target; -extern crate rustc_data_structures; -extern crate rustc_fs_util; -extern crate log; +extern crate syntax; use std::any::Any; use std::fs::File; @@ -29,10 +24,10 @@ use rustc::session::{ CompileIncomplete, }; use rustc::ty::query::Providers; +use rustc_codegen_ssa::back::linker::LinkerInfo; +use rustc_codegen_ssa::CrateInfo; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::out_filename; -use rustc_codegen_ssa::CrateInfo; -use rustc_codegen_ssa::back::linker::LinkerInfo; use cranelift::codegen::settings; use cranelift_faerie::*; @@ -83,8 +78,8 @@ mod prelude { }; pub use rustc_mir::monomorphize::{collector, MonoItem}; - pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; + pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, @@ -183,13 +178,14 @@ impl CodegenBackend for CraneliftCodegenBackend { match tcx.sess.opts.optimize { OptLevel::No => { flags_builder.set("opt_level", "fastest").unwrap(); - }, - OptLevel::Less | OptLevel::Default => {}, + } + OptLevel::Less | OptLevel::Default => {} OptLevel::Aggressive => { flags_builder.set("opt_level", "best").unwrap(); - }, + } OptLevel::Size | OptLevel::SizeMin => { - tcx.sess.warn("Optimizing for size is not supported. Just ignoring the request"); + tcx.sess + .warn("Optimizing for size is not supported. Just ignoring the request"); } } diff --git a/src/link.rs b/src/link.rs index 42e4b55f803af..6cc5e7b802e4d 100644 --- a/src/link.rs +++ b/src/link.rs @@ -9,8 +9,8 @@ use rustc::session::config::{self, CrateType, DebugInfo, RUST_CGU_EXT}; use rustc::session::search_paths::PathKind; use rustc::session::Session; use rustc_codegen_ssa::back::command::Command; -use rustc_codegen_ssa::back::linker::*; use rustc_codegen_ssa::back::link::*; +use rustc_codegen_ssa::back::linker::*; use rustc_fs_util::fix_windows_verbatim_for_gcc; use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel}; @@ -27,11 +27,15 @@ pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathB if let Some(ref object_path) = module.object { let object = File::open(object_path).expect("Someone deleted our object file"); let object_len = object.metadata().unwrap().len(); - builder.append( - &ar::Header::new((module.name.to_string() + RUST_CGU_EXT).into_bytes(), object_len), - object, - ) - .unwrap(); + builder + .append( + &ar::Header::new( + (module.name.to_string() + RUST_CGU_EXT).into_bytes(), + object_len, + ), + object, + ) + .unwrap(); } } diff --git a/src/trap.rs b/src/trap.rs index 1d264b209986e..d94a852153e45 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -1,4 +1,5 @@ use cranelift::prelude::*; + use cranelift::codegen::ir::TrapCode; /// Trap code: user0 diff --git a/src/unimpl.rs b/src/unimpl.rs index 771897fa4b076..8333cd1344c79 100644 --- a/src/unimpl.rs +++ b/src/unimpl.rs @@ -21,16 +21,20 @@ pub macro unimpl($($tt:tt)*) { } pub fn try_unimpl(tcx: TyCtxt, log: &mut Option, f: impl FnOnce()) { - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| { - f() - })); + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); if let Err(err) = res { SPAN_STACK.with(|span_stack| { match err.downcast::() { Ok(non_fatal) => { if cfg!(debug_assertions) { - writeln!(log.as_mut().unwrap(), "{} at {:?}", &non_fatal.0, span_stack.borrow()).unwrap(); + writeln!( + log.as_mut().unwrap(), + "{} at {:?}", + &non_fatal.0, + span_stack.borrow() + ) + .unwrap(); } tcx.sess.err(&non_fatal.0) } From d447f77f0399b6be7a4189222d6cbd0a291f03d2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 26 Nov 2018 17:51:28 +0100 Subject: [PATCH 0376/1566] Rustup to rustc 1.32.0-nightly (6acbb5b65 2018-11-25) --- src/base.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 97f97f255622a..0f6bbca78e64a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -653,7 +653,6 @@ fn trans_stmt<'a, 'tcx: 'a>( | StatementKind::StorageDead(_) | StatementKind::Nop | StatementKind::FakeRead(..) - | StatementKind::EndRegion(_) | StatementKind::Retag { .. } | StatementKind::AscribeUserType(..) | StatementKind::EscapeToRaw(..) => {} From 30f97e4ef0c17c11636d05bfb2fa7da74c3bd159 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 26 Nov 2018 05:39:25 +0000 Subject: [PATCH 0377/1566] Bump cranelift from `fc608d4` to `1f34401` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `fc608d4` to `1f34401`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/fc608d4b25cd7f8415274c3c9a9324c40e702ed4...1f3440174a8c69bd9428f6ad363bcb09f85b257d) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d5935b71f109..2e6c8778ded46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" [[package]] name = "cranelift-faerie" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#fc608d4b25cd7f8415274c3c9a9324c40e702ed4" +source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" dependencies = [ "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", From 5cda66151f92231a73c201b46d587ffbda8ee8d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 26 Nov 2018 17:16:39 +0000 Subject: [PATCH 0378/1566] Bump syn from 0.15.21 to 0.15.22 Bumps [syn](https://github.com/dtolnay/syn) from 0.15.21 to 0.15.22. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/0.15.21...0.15.22) Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e6c8778ded46..2d4ed979e24f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,7 +262,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -521,7 +521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -582,12 +582,12 @@ dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.21" +version = "0.15.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -602,7 +602,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -803,7 +803,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "41c4a2479a078509940d82773d90ff824a8c89533ab3b59cd3ce8b0c0e369c02" "checksum structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5352090cfae7a2c85e1a31146268b53396106c88ca5d6ccee2e3fae83b6e35c2" -"checksum syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)" = "816b7af21405b011a23554ea2dc3f6576dc86ca557047c34098c1d741f10f823" +"checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" "checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" From 36c04616542d8fcf5924979cc4f85f43e081ab99 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 27 Nov 2018 11:21:20 +0100 Subject: [PATCH 0379/1566] Update SIMD entry in Readme --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 85f7bd9a72f73..99e21e96e3962 100644 --- a/Readme.md +++ b/Readme.md @@ -35,7 +35,7 @@ $ ./build.sh * Varargs ([no cranelift support](https://github.com/CraneStation/cranelift/issues/212)) * libstd (needs varargs and some other stuff) ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/146)) * u128 and i128 ([no cranelift support](https://github.com/CraneStation/cranelift/issues/354)) -* SIMD (huge amount of work to get all intrinsics implemented, so may never be supported) +* SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171)) ## Troubleshooting From a16e85707d3c12272b0461923e79c5f04cd81a39 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Nov 2018 18:08:08 +0100 Subject: [PATCH 0380/1566] Rustup to rustc 1.32.0-nightly (3e90a12a8 2018-11-29) --- src/constant.rs | 18 ++++++++++++++++-- src/lib.rs | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 7fef96a39b4c2..add22389bfe73 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -298,6 +298,8 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { type MemoryKinds = !; type PointerTag = (); type AllocExtra = (); + type MemoryExtra = (); + type FrameExtra = (); type MemoryMap = FxHashMap, Allocation<()>)>; const STATIC_KIND: Option = None; @@ -329,8 +331,9 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { } fn find_foreign_static( - _: ::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, _: DefId, + _: ::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, + _: &(), ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } @@ -358,7 +361,10 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn adjust_static_allocation(alloc: &Allocation) -> Cow<'_, Allocation> { + fn adjust_static_allocation<'alloc>( + alloc: &'alloc Allocation, + _: &(), + ) -> Cow<'alloc, Allocation> { Cow::Borrowed(alloc) } @@ -369,4 +375,12 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { ) -> EvalResult<'tcx, Pointer> { Ok(ptr) } + + fn stack_push(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx>{ + Ok(()) + } + + fn stack_pop(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: ()) -> EvalResult<'tcx> { + Ok(()) + } } diff --git a/src/lib.rs b/src/lib.rs index 04e0af9cc40a9..69b11b73fa2f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, macro_at_most_once_rep, never_type, decl_macro)] +#![feature(rustc_private, never_type, decl_macro)] #![allow(intra_doc_link_resolution_failure)] extern crate log; From e49481d11227a88eabcc7e718d137f89333f286c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Nov 2018 18:12:08 +0100 Subject: [PATCH 0381/1566] Update Cargo.lock --- Cargo.lock | 180 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 112 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d4ed979e24f8..4e8f3531d7325 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,29 +97,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -128,24 +128,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" [[package]] name = "cranelift-faerie" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,43 +154,43 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.23.0" -source = "git+https://github.com/CraneStation/cranelift.git#1f3440174a8c69bd9428f6ad363bcb09f85b257d" +version = "0.25.0" +source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" dependencies = [ - "cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -204,7 +204,7 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -305,7 +305,7 @@ dependencies = [ [[package]] name = "humantime" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -385,22 +385,29 @@ dependencies = [ [[package]] name = "rand" -version = "0.5.5" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand_core" -version = "0.2.2" +name = "rand_chacha" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -408,6 +415,39 @@ name = "rand_core" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_pcg" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "raw-cpuid" version = "6.1.0" @@ -420,7 +460,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -428,7 +468,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -482,14 +522,14 @@ dependencies = [ "ar 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.23.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -618,13 +658,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -643,7 +683,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -747,16 +787,16 @@ dependencies = [ "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cranelift 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.23.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" @@ -768,7 +808,7 @@ dependencies = [ "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" -"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" +"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" @@ -780,11 +820,15 @@ dependencies = [ "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" -"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" -"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372" +"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a" +"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" +"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" +"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" -"checksum redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cf8fb82a4d1c9b28f1c26c574a5b541f5ffb4315f6c9a791fa47b6a04438fe93" +"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" "checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" @@ -806,7 +850,7 @@ dependencies = [ "checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" -"checksum tempfile 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "55c1195ef8513f3273d55ff59fe5da6940287a0d7a98331254397f464833675b" +"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" From 3f423c0933c056386fb547c33048600942d17c65 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Nov 2018 18:28:33 +0100 Subject: [PATCH 0382/1566] Implement cast C enum -> int --- ...me-more-unsupported-stuff-in-libcore.patch | 31 +------------------ src/base.rs | 4 +++ 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/0004-Disable-some-more-unsupported-stuff-in-libcore.patch b/0004-Disable-some-more-unsupported-stuff-in-libcore.patch index c265db96a26f3..1310b95749d43 100644 --- a/0004-Disable-some-more-unsupported-stuff-in-libcore.patch +++ b/0004-Disable-some-more-unsupported-stuff-in-libcore.patch @@ -4,37 +4,8 @@ Date: Thu, 23 Aug 2018 11:15:01 +0200 Subject: [PATCH] Disable some more unsupported stuff in libcore --- - src/libcore/cmp.rs | 5 ++++- src/libcore/num/mod.rs | 8 ++++++-- - 2 files changed, 9 insertions(+), 3 deletions(-) - -diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index a6e6496..f9374ea 100644 ---- a/src/libcore/cmp.rs -+++ b/src/libcore/cmp.rs -@@ -496,6 +496,7 @@ pub trait Ord: Eq + PartialOrd { - #[stable(feature = "rust1", since = "1.0.0")] - impl Eq for Ordering {} - -+/* - #[stable(feature = "rust1", since = "1.0.0")] - impl Ord for Ordering { - #[inline] -@@ -503,12 +504,14 @@ impl Ord for Ordering { - (*self as i32).cmp(&(*other as i32)) - } - } -+*/ - - #[stable(feature = "rust1", since = "1.0.0")] - impl PartialOrd for Ordering { - #[inline] - fn partial_cmp(&self, other: &Ordering) -> Option { -- (*self as i32).partial_cmp(&(*other as i32)) -+ //(*self as i32).partial_cmp(&(*other as i32)) -+ None - } - } + 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 5d00949..f077f1d 100644 diff --git a/src/base.rs b/src/base.rs index 0f6bbca78e64a..35fbf6454e9ac 100644 --- a/src/base.rs +++ b/src/base.rs @@ -571,6 +571,10 @@ fn trans_stmt<'a, 'tcx: 'a>( }; lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } + (ty::Adt(adt_def, _substs), ty::Uint(_)) | (ty::Adt(adt_def, _substs), ty::Int(_)) if adt_def.is_enum() => { + let discr = trans_get_discriminant(fx, operand, fx.layout_of(to_ty)); + lval.write_cvalue(fx, discr); + } _ => unimpl!("rval misc {:?} {:?}", from_ty, to_ty), } } From a8d52d13f41e4b563b2c46f21d05b24bda2948e7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 1 Dec 2018 11:49:44 +0100 Subject: [PATCH 0383/1566] Some small changes --- src/base.rs | 8 ++++---- src/common.rs | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/base.rs b/src/base.rs index 35fbf6454e9ac..66bd3e995234f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -20,6 +20,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( MonoItem::Fn(inst) => { let _inst_guard = PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).as_str())); + debug_assert!(!inst.substs.needs_infer()); let _mir_guard = PrintOnPanic(|| { match inst.def { InstanceDef::Item(_) @@ -88,15 +89,14 @@ fn trans_fn<'a, 'tcx: 'a>( tcx, module, pointer_type, + instance, mir, + bcx, - param_substs: { - assert!(!instance.substs.needs_infer()); - instance.substs - }, ebb_map, local_map: HashMap::new(), + comments: HashMap::new(), constants, caches, diff --git a/src/common.rs b/src/common.rs index a74abc8ef24ca..1eef977fa24b3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -615,12 +615,14 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, pub pointer_type: Type, // Cached from module + pub instance: Instance<'tcx>, pub mir: &'tcx Mir<'tcx>, - pub param_substs: &'tcx Substs<'tcx>, + pub bcx: FunctionBuilder<'a>, pub ebb_map: HashMap, pub local_map: HashMap>, + pub comments: HashMap, pub constants: &'a mut crate::constant::ConstantCx, pub caches: &'a mut Caches<'tcx>, @@ -631,7 +633,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - writeln!(f, "{:?}", self.param_substs)?; + writeln!(f, "{:?}", self.instance.substs)?; writeln!(f, "{:?}", self.local_map)?; let mut clif = String::new(); @@ -690,7 +692,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { T: TypeFoldable<'tcx>, { self.tcx.subst_and_normalize_erasing_regions( - self.param_substs, + self.instance.substs, ty::ParamEnv::reveal_all(), value, ) From b649180def667fcf9f4b3cef293630f70f8b6785 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 3 Dec 2018 18:00:09 +0100 Subject: [PATCH 0384/1566] Rustup to rustc 1.32.0-nightly (21f268495 2018-12-02) --- src/common.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index 1eef977fa24b3..8a6a40dff2a1f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -681,7 +681,6 @@ impl<'a, 'tcx, B: Backend> BackendTypes for FunctionCx<'a, 'tcx, B> { type Value = Value; type BasicBlock = Ebb; type Type = Type; - type Context = !; type Funclet = !; type DIScope = !; } From 3c364134ec1aa1b88ee9adec9e2c35e72a61061a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 3 Dec 2018 18:50:00 +0100 Subject: [PATCH 0385/1566] Restructure scripts and add flamegraph generator --- .travis.yml | 2 +- config.sh | 23 +++++++++++++++++ flamegraph.sh | 11 ++++++++ .../0001-Disable-stdsimd.patch | 0 ...002-Disable-u128-and-i128-in-libcore.patch | 0 ...le-inline-assembly-in-spin_loop_hint.patch | 0 ...me-more-unsupported-stuff-in-libcore.patch | 0 .../0005-Disable-compiler_builtins.patch | 0 ...alloc-Disable-some-unsupported-stuff.patch | 0 .../0007-Fix-libstd-building.patch | 0 ...iadic-function-calls-with-unimplemen.patch | 0 prepare_libcore.sh | 2 +- src/lib.rs | 5 ++++ build.sh => test.sh | 25 +------------------ 14 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 config.sh create mode 100755 flamegraph.sh rename 0001-Disable-stdsimd.patch => patches/0001-Disable-stdsimd.patch (100%) rename 0002-Disable-u128-and-i128-in-libcore.patch => patches/0002-Disable-u128-and-i128-in-libcore.patch (100%) rename 0003-Disable-inline-assembly-in-spin_loop_hint.patch => patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch (100%) rename 0004-Disable-some-more-unsupported-stuff-in-libcore.patch => patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch (100%) rename 0005-Disable-compiler_builtins.patch => patches/0005-Disable-compiler_builtins.patch (100%) rename 0006-alloc-Disable-some-unsupported-stuff.patch => patches/0006-alloc-Disable-some-unsupported-stuff.patch (100%) rename 0007-Fix-libstd-building.patch => patches/0007-Fix-libstd-building.patch (100%) rename 0008-Replace-some-variadic-function-calls-with-unimplemen.patch => patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch (100%) rename build.sh => test.sh (78%) diff --git a/.travis.yml b/.travis.yml index 5d07a2775f1d4..c14a09192a7a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ script: - cargo install xargo || echo "Skipping xargo install" - cargo install hyperfine || echo "Skipping hyperfine install" - ./prepare_libcore.sh - - ./build.sh + - ./test.sh env: - RUST_BACKTRACE=1 diff --git a/config.sh b/config.sh new file mode 100644 index 0000000000000..a2772d635d14d --- /dev/null +++ b/config.sh @@ -0,0 +1,23 @@ +set -e + +unamestr=`uname` +if [[ "$unamestr" == 'Linux' ]]; then + dylib_ext='so' +elif [[ "$unamestr" == 'Darwin' ]]; then + dylib_ext='dylib' +else + echo "Unsupported os" + exit 1 +fi + +if [[ "$1" == "--release" ]]; then + channel='release' + cargo build --release +else + channel='debug' + cargo build +fi + +export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext +export XARGO_RUST_SRC=$(pwd)'/target/libcore/src' +RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" diff --git a/flamegraph.sh b/flamegraph.sh new file mode 100755 index 0000000000000..4506c77371d4f --- /dev/null +++ b/flamegraph.sh @@ -0,0 +1,11 @@ +#!/bin/bash +source config.sh + +# These files grow really big (~1.4G) because of the sample frequency +rm perf.data* || true + +# Profile compiling libcore +perf record -F 9000 --call-graph dwarf -- $RUSTC --crate-type lib target/libcore/src/libcore/lib.rs --crate-name core + +# Generate the flamegraph +perf script | ../FlameGraph/stackcollapse-perf.pl | grep cranelift | ../FlameGraph/flamegraph.pl > abc.svg diff --git a/0001-Disable-stdsimd.patch b/patches/0001-Disable-stdsimd.patch similarity index 100% rename from 0001-Disable-stdsimd.patch rename to patches/0001-Disable-stdsimd.patch diff --git a/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch similarity index 100% rename from 0002-Disable-u128-and-i128-in-libcore.patch rename to patches/0002-Disable-u128-and-i128-in-libcore.patch diff --git a/0003-Disable-inline-assembly-in-spin_loop_hint.patch b/patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch similarity index 100% rename from 0003-Disable-inline-assembly-in-spin_loop_hint.patch rename to patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch diff --git a/0004-Disable-some-more-unsupported-stuff-in-libcore.patch b/patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch similarity index 100% rename from 0004-Disable-some-more-unsupported-stuff-in-libcore.patch rename to patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch diff --git a/0005-Disable-compiler_builtins.patch b/patches/0005-Disable-compiler_builtins.patch similarity index 100% rename from 0005-Disable-compiler_builtins.patch rename to patches/0005-Disable-compiler_builtins.patch diff --git a/0006-alloc-Disable-some-unsupported-stuff.patch b/patches/0006-alloc-Disable-some-unsupported-stuff.patch similarity index 100% rename from 0006-alloc-Disable-some-unsupported-stuff.patch rename to patches/0006-alloc-Disable-some-unsupported-stuff.patch diff --git a/0007-Fix-libstd-building.patch b/patches/0007-Fix-libstd-building.patch similarity index 100% rename from 0007-Fix-libstd-building.patch rename to patches/0007-Fix-libstd-building.patch diff --git a/0008-Replace-some-variadic-function-calls-with-unimplemen.patch b/patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch similarity index 100% rename from 0008-Replace-some-variadic-function-calls-with-unimplemen.patch rename to patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch diff --git a/prepare_libcore.sh b/prepare_libcore.sh index ce13f80816f80..b3a3723e2df78 100755 --- a/prepare_libcore.sh +++ b/prepare_libcore.sh @@ -17,7 +17,7 @@ pushd $DST_DIR git init git add . git commit -m "Initial commit" -q -git apply ../../000*.patch +git apply ../../patches/*.patch popd # `alloc_system` has been merged with libstd, which doesn't build yet. diff --git a/src/lib.rs b/src/lib.rs index 69b11b73fa2f3..f09c962a51580 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -173,6 +173,11 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); + flags_builder.set("enable_verifier", if cfg!(debug_assertions) { + "true" + } else { + "false" + }).unwrap(); use rustc::session::config::OptLevel; match tcx.sess.opts.optimize { diff --git a/build.sh b/test.sh similarity index 78% rename from build.sh rename to test.sh index afe32828e4b27..7c7f789084327 100755 --- a/build.sh +++ b/test.sh @@ -1,34 +1,11 @@ #!/bin/bash - -set -e - -unamestr=`uname` -if [[ "$unamestr" == 'Linux' ]]; then - dylib_ext='so' -elif [[ "$unamestr" == 'Darwin' ]]; then - dylib_ext='dylib' -else - echo "Unsupported os" - exit 1 -fi +source config.sh build_example_bin() { $RUSTC $2 --crate-name $1 --crate-type bin sh -c ./target/out/$1 || true } -if [[ "$1" == "--release" ]]; then - channel='release' - cargo build --release -else - channel='debug' - cargo build -fi - -export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext -export XARGO_RUST_SRC=$(pwd)'/target/libcore/src' -RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" - rm -r target/out || true mkdir -p target/out/clif From bcce08c0c08fc806aaf83ece9dac4b37b3e30429 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 4 Dec 2018 19:29:57 +0100 Subject: [PATCH 0386/1566] Update Cargo.lock --- Cargo.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e8f3531d7325..1cc117b0c102f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ dependencies = [ [[package]] name = "ar" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-bforest 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" [[package]] name = "cranelift-faerie" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#4a7229a69be0b394b9e605cdde99761e821da1c6" +source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -206,7 +206,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -473,19 +473,19 @@ dependencies = [ [[package]] name = "regex" -version = "1.0.6" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -519,7 +519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -777,7 +777,7 @@ dependencies = [ [metadata] "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2b66b66d06e6bb6a8c6866d31ac48fc225ef2823d29940165c8084b4f120d2b3" +"checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" @@ -830,8 +830,8 @@ dependencies = [ "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee84f70c8c08744ea9641a731c7fadb475bf2ecc52d7f627feb833e0b3990467" -"checksum regex-syntax 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fbc557aac2b708fe84121caf261346cc2eed71978024337e42eb46b8a252ac6e" +"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" +"checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cff177f64744f6f2a2054d231279383e59b0857b4d58dc2e8881e60b58aec8e5" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" From ad7c9a388b203e8db6da4b3053aa1ca4dbecff2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 7 Dec 2018 06:23:23 +0000 Subject: [PATCH 0387/1566] Bump cranelift from `077f0e4` to `5fc828a` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `077f0e4` to `5fc828a`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/077f0e4794ea115341fce052713a6fc61ed7a474...5fc828ab9b513006f9322ba03645eb5ac4da97ed) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1cc117b0c102f..1407208f1fbbe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-bforest 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" [[package]] name = "cranelift-faerie" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#077f0e4794ea115341fce052713a6fc61ed7a474" +source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", From 2cff2d3328af56413d6a84d32629db73b7e005c4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Dec 2018 10:48:35 +0100 Subject: [PATCH 0388/1566] Rustup to rustc 1.32.0-nightly (4a45578bc 2018-12-07) --- src/main_shim.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main_shim.rs b/src/main_shim.rs index 5b61ef24cf2e5..aec03838ce9e5 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -11,7 +11,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { Some((id, _, entry_ty)) => ( - tcx.hir.local_def_id(id), + tcx.hir().local_def_id(id), match entry_ty { EntryFnType::Main => true, EntryFnType::Start => false, From 3a86904575ca930f9dbd14ccc75140d13308b62c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 10 Dec 2018 07:18:59 +0000 Subject: [PATCH 0389/1566] Bump serde from 1.0.80 to 1.0.81 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.80 to 1.0.81. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.80...v1.0.81) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1407208f1fbbe..ce057cd6e6019 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -579,7 +579,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.80" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -589,7 +589,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -597,7 +597,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -841,7 +841,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" +"checksum serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)" = "c91eb5b0190ae87b4e2e39cbba6e3bed3ac6186935fe265f0426156c4c49961b" "checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" From bd4b307b42d516a6430dba9732c253e5b6dd032d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 10 Dec 2018 15:10:12 +0100 Subject: [PATCH 0390/1566] Support dylibs --- src/base.rs | 2 +- src/lib.rs | 4 +++- src/link.rs | 44 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/base.rs b/src/base.rs index 66bd3e995234f..9d5ab22a7c6b7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -267,7 +267,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) drop_place.write_place_ref(fx, arg_place); match ty.sty { ty::Dynamic(..) => { - unimpl!("Drop for trait object"); + fx.tcx.sess.warn("Drop for trait object"); } _ => { let drop_fn_ty = drop_fn.ty(fx.tcx); diff --git a/src/lib.rs b/src/lib.rs index f09c962a51580..132b9e8b74cb5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -312,7 +312,9 @@ impl CodegenBackend for CraneliftCodegenBackend { let output_name = out_filename(sess, crate_type, &outputs, &res.crate_name.as_str()); match crate_type { CrateType::Rlib => link::link_rlib(sess, &res, output_name), - CrateType::Executable => link::link_bin(sess, &res, &output_name), + CrateType::Dylib | CrateType::Executable => { + link::link_natively(sess, crate_type, &res, &output_name); + } _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), } } diff --git a/src/link.rs b/src/link.rs index 6cc5e7b802e4d..b600413fad232 100644 --- a/src/link.rs +++ b/src/link.rs @@ -1,7 +1,10 @@ +use std::ascii; +use std::char; use std::env; use std::fs::File; use std::io; use std::path::{Path, PathBuf}; +use std::str; use tempfile::Builder as TempFileBuilder; @@ -65,13 +68,20 @@ pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathB } } -pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_filename: &Path) { +pub(crate) fn link_natively( + sess: &Session, + crate_type: CrateType, + codegen_results: &CodegenResults, + out_filename: &Path, +) { let tmpdir = match TempFileBuilder::new().prefix("rustc").tempdir() { Ok(tmpdir) => tmpdir, Err(err) => sess.fatal(&format!("couldn't create a temp dir: {}", err)), }; let (linker, flavor) = linker_and_flavor(sess); + + // The invocations of cc share some flags across platforms let (pname, mut cmd) = get_linker(sess, &linker, flavor); let root = sess.target_filesearch(PathKind::Native).get_lib_path(); @@ -88,11 +98,16 @@ pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_fil } cmd.args(&sess.opts.debugging_opts.pre_link_arg); - for obj in &sess.target.target.options.pre_link_objects_exe { + let pre_link_objects = if crate_type == config::CrateType::Executable { + &sess.target.target.options.pre_link_objects_exe + } else { + &sess.target.target.options.pre_link_objects_dll + }; + for obj in pre_link_objects { cmd.arg(root.join(obj)); } - if sess.crt_static() { + if crate_type == config::CrateType::Executable && sess.crt_static() { for obj in &sess.target.target.options.pre_link_objects_exe_crt { cmd.arg(root.join(obj)); } @@ -108,9 +123,9 @@ pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_fil } { - let target_cpu = "x86_64-apple-darwin"; //::llvm_util::target_cpu(sess); - let mut linker = codegen_results.linker_info.to_linker(cmd, &sess, flavor, target_cpu); - link_args(&mut *linker, flavor, sess, CrateType::Executable, tmpdir.path(), + let target_cpu = ::target_lexicon::HOST.to_string(); + let mut linker = codegen_results.linker_info.to_linker(cmd, &sess, flavor, &target_cpu); + link_args(&mut *linker, flavor, sess, crate_type, tmpdir.path(), out_filename, codegen_results); cmd = linker.finalize(); } @@ -203,6 +218,16 @@ pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_fil match prog { Ok(prog) => { + fn escape_string(s: &[u8]) -> String { + str::from_utf8(s).map(|s| s.to_owned()) + .unwrap_or_else(|_| { + let mut x = "Non-UTF-8 output: ".to_string(); + x.extend(s.iter() + .flat_map(|&b| ascii::escape_default(b)) + .map(char::from)); + x + }) + } if !prog.status.success() { let mut output = prog.stderr.clone(); output.extend_from_slice(&prog.stdout); @@ -210,7 +235,7 @@ pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_fil pname.display(), prog.status)) .note(&format!("{:?}", &cmd)) - .note(&String::from_utf8_lossy(&output)) + .note(&escape_string(&output)) .emit(); sess.abort_if_errors(); } @@ -251,9 +276,8 @@ pub(crate) fn link_bin(sess: &Session, codegen_results: &CodegenResults, out_fil if sess.target.target.options.is_like_osx && sess.opts.debuginfo != DebugInfo::None { - match Command::new("dsymutil").arg(out_filename).output() { - Ok(..) => {} - Err(e) => sess.fatal(&format!("failed to run dsymutil: {}", e)), + if let Err(e) = Command::new("dsymutil").arg(out_filename).output() { + sess.fatal(&format!("failed to run dsymutil: {}", e)) } } } From 30bc8e7f001c72c194b3f4abd8834313b143294d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 11 Dec 2018 05:33:27 +0000 Subject: [PATCH 0391/1566] Bump cranelift from `5fc828a` to `9d17fc9` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `5fc828a` to `9d17fc9`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/5fc828ab9b513006f9322ba03645eb5ac4da97ed...9d17fc9ac1bd378c8d62eef491431708f43efdf5) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce057cd6e6019..234dbe6df00aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-bforest 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" [[package]] name = "cranelift-faerie" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#5fc828ab9b513006f9322ba03645eb5ac4da97ed" +source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" dependencies = [ "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", From eea2cee1c07d5c72360d3b8c27ed7b7ab017c2ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 11 Dec 2018 07:26:21 +0000 Subject: [PATCH 0392/1566] Bump structopt from 0.2.13 to 0.2.14 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.2.13 to 0.2.14. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.2.13...v0.2.14) Signed-off-by: dependabot[bot] --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 234dbe6df00aa..b266555976f7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,8 +241,8 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -607,16 +607,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -845,8 +845,8 @@ dependencies = [ "checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "41c4a2479a078509940d82773d90ff824a8c89533ab3b59cd3ce8b0c0e369c02" -"checksum structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5352090cfae7a2c85e1a31146268b53396106c88ca5d6ccee2e3fae83b6e35c2" +"checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" +"checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" "checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" From 0fbab055d473f0a6ccbb05152ff1fc52bc72e47c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 11 Dec 2018 10:45:03 +0000 Subject: [PATCH 0393/1566] Bump libc from 0.2.44 to 0.2.45 Bumps [libc](https://github.com/rust-lang/libc) from 0.2.44 to 0.2.45. - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.44...0.2.45) Signed-off-by: dependabot[bot] --- Cargo.lock | 30 +++++++++++++++--------------- Cargo.toml | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b266555976f7a..986582e5c4df6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -39,7 +39,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -50,7 +50,7 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -192,7 +192,7 @@ dependencies = [ "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -216,7 +216,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -226,7 +226,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -328,7 +328,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.44" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -344,7 +344,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -353,7 +353,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -390,7 +390,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -497,7 +497,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -527,7 +527,7 @@ dependencies = [ "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -662,7 +662,7 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -682,7 +682,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -812,7 +812,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" +"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" diff --git a/Cargo.toml b/Cargo.toml index ee7ea811ad320..7266c9b85d8b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ faerie = "0.6.0" ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.6" -libc = "0.2.43" +libc = "0.2.45" tempfile = "3.0.4" # Uncomment to use local checkout of cranelift From dc2f32f9854b9d6e0b68f75f0c0ca2324214284d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Dec 2018 15:13:45 +0100 Subject: [PATCH 0394/1566] Change the CallConv for "rust" abi functions to "SystemV" to match the "C" abi The allocator machinery seems to mix "rust" and "C" abi function defs and calls. --- src/abi.rs | 4 ++-- src/allocator.rs | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index ea00dd790eba2..c9559a6068913 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -79,7 +79,7 @@ pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( unimpl!("Variadic function are not yet supported"); } let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { - Abi::Rust => (CallConv::Fast, sig.inputs().to_vec(), sig.output()), + Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); @@ -89,7 +89,7 @@ pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( }; let mut inputs: Vec = vec![sig.inputs()[0]]; inputs.extend(extra_args.into_iter()); - (CallConv::Fast, inputs, sig.output()) + (CallConv::SystemV, inputs, sig.output()) } Abi::System => bug!("system abi should be selected elsewhere"), Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), diff --git a/src/allocator.rs b/src/allocator.rs index ba1eda7148fd0..8f2e7ca95699d 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -39,8 +39,8 @@ pub fn codegen(module: &mut Module, kind: AllocatorKind) } }; - let mut sig = Signature { - call_conv: CallConv::Fast, + let sig = Signature { + call_conv: CallConv::SystemV, params: arg_tys.iter().cloned().map(AbiParam::new).collect(), returns: output.into_iter().map(AbiParam::new).collect(), }; @@ -49,12 +49,10 @@ pub fn codegen(module: &mut Module, kind: AllocatorKind) let callee_name = kind.fn_name(method.name); //eprintln!("Codegen allocator shim {} -> {} ({:?} -> {:?})", caller_name, callee_name, sig.params, sig.returns); - sig.call_conv = CallConv::Fast; // "rust" abi let func_id = module .declare_function(&caller_name, Linkage::Export, &sig) .unwrap(); - sig.call_conv = CallConv::SystemV; // "C" abi let callee_func_id = module .declare_function(&callee_name, Linkage::Import, &sig) .unwrap(); From 0fa77732340e9a41ce2750c152d9fc3491dde7db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 12 Dec 2018 06:43:45 +0000 Subject: [PATCH 0395/1566] Bump cranelift from `9d17fc9` to `05b6226` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `9d17fc9` to `05b6226`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/9d17fc9ac1bd378c8d62eef491431708f43efdf5...05b62260ac5473914f7536f5393c5c629877aab1) Signed-off-by: dependabot[bot] --- Cargo.lock | 100 ++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 986582e5c4df6..02f0e4c3e42e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,29 +97,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-bforest 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -128,24 +128,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" [[package]] name = "cranelift-faerie" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,43 +154,43 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.25.0" -source = "git+https://github.com/CraneStation/cranelift.git#9d17fc9ac1bd378c8d62eef491431708f43efdf5" +version = "0.26.0" +source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" dependencies = [ - "cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -522,10 +522,10 @@ dependencies = [ "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.25.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -787,16 +787,16 @@ dependencies = [ "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cranelift 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.25.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 5538c15a436c7449f842ce207940f3248b8f5ec9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 12 Dec 2018 14:57:55 +0100 Subject: [PATCH 0396/1566] Update Cargo.lock --- Cargo.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02f0e4c3e42e4..1179227e97a4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "aho-corasick" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -34,7 +34,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,7 +251,7 @@ name = "failure" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -349,7 +349,7 @@ dependencies = [ [[package]] name = "memchr" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -460,7 +460,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -468,7 +468,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -477,7 +477,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -579,7 +579,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -589,7 +589,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -597,7 +597,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -664,7 +664,7 @@ dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -683,7 +683,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -779,7 +779,7 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" +"checksum backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "18b65ea1161bfb2dd6da6fade5edd4dbd08fba85012123dd333d2fd1b90b2782" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" @@ -815,7 +815,7 @@ dependencies = [ "checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" +"checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -828,7 +828,7 @@ dependencies = [ "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" "checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" -"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" +"checksum redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "a84bcd297b87a545980a2d25a0beb72a1f490c31f0a9fde52fca35bfbb1ceb70" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" @@ -841,7 +841,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)" = "c91eb5b0190ae87b4e2e39cbba6e3bed3ac6186935fe265f0426156c4c49961b" +"checksum serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "6fa52f19aee12441d5ad11c9a00459122bd8f98707cadf9778c540674f1935b6" "checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" From 94eac08a489181795c5780ad490a1afb3523f149 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 12 Dec 2018 15:11:15 +0100 Subject: [PATCH 0397/1566] Extract TargetIsa building to a separate function --- src/lib.rs | 60 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 132b9e8b74cb5..a2ebf470b3d44 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,35 +171,6 @@ impl CodegenBackend for CraneliftCodegenBackend { let metadata = tcx.encode_metadata(); - let mut flags_builder = settings::builder(); - flags_builder.enable("is_pic").unwrap(); - flags_builder.set("enable_verifier", if cfg!(debug_assertions) { - "true" - } else { - "false" - }).unwrap(); - - use rustc::session::config::OptLevel; - match tcx.sess.opts.optimize { - OptLevel::No => { - flags_builder.set("opt_level", "fastest").unwrap(); - } - OptLevel::Less | OptLevel::Default => {} - OptLevel::Aggressive => { - flags_builder.set("opt_level", "best").unwrap(); - } - OptLevel::Size | OptLevel::SizeMin => { - tcx.sess - .warn("Optimizing for size is not supported. Just ignoring the request"); - } - } - - let flags = settings::Flags::new(flags_builder); - let isa = - cranelift::codegen::isa::lookup(tcx.sess.target.target.llvm_target.parse().unwrap()) - .unwrap() - .finish(flags); - // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore save_incremental(tcx); tcx.sess.warn("Saved incremental data"); @@ -245,6 +216,7 @@ impl CodegenBackend for CraneliftCodegenBackend { jit_module.finish(); ::std::process::exit(0); } else { + let isa = build_isa(tcx.sess); let mut faerie_module: Module = Module::new( FaerieBuilder::new( isa, @@ -322,6 +294,36 @@ impl CodegenBackend for CraneliftCodegenBackend { } } +fn build_isa(sess: &Session) -> Box { + use rustc::session::config::OptLevel; + + let mut flags_builder = settings::builder(); + flags_builder.enable("is_pic").unwrap(); + flags_builder.set("enable_verifier", if cfg!(debug_assertions) { + "true" + } else { + "false" + }).unwrap(); + + match sess.opts.optimize { + OptLevel::No => { + flags_builder.set("opt_level", "fastest").unwrap(); + } + OptLevel::Less | OptLevel::Default => {} + OptLevel::Aggressive => { + flags_builder.set("opt_level", "best").unwrap(); + } + OptLevel::Size | OptLevel::SizeMin => { + sess.warn("Optimizing for size is not supported. Just ignoring the request"); + } + } + + let flags = settings::Flags::new(flags_builder); + cranelift::codegen::isa::lookup(sess.target.target.llvm_target.parse().unwrap()) + .unwrap() + .finish(flags) +} + fn codegen_mono_items<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, From 4d0dba944c3e103ddd59b7ab3df9ccd437985863 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 12 Dec 2018 16:01:34 +0100 Subject: [PATCH 0398/1566] Some refactorings for codegen_mono_items --- src/allocator.rs | 17 +++++++++++++++- src/common.rs | 1 - src/lib.rs | 50 +++++++++++++++++++++--------------------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 8f2e7ca95699d..9c444d8cfc51c 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -13,7 +13,22 @@ use crate::prelude::*; use rustc::middle::allocator::AllocatorKind; use rustc_allocator::{AllocatorTy, ALLOCATOR_METHODS}; -pub fn codegen(module: &mut Module, kind: AllocatorKind) { +pub fn codegen(sess: &Session, module: &mut Module) { + let any_dynamic_crate = sess + .dependency_formats + .borrow() + .iter() + .any(|(_, list)| { + use rustc::middle::dependency_format::Linkage; + list.iter().any(|&linkage| linkage == Linkage::Dynamic) + }); + if any_dynamic_crate { + } else if let Some(kind) = *sess.allocator_kind.get() { + codegen_inner(module, kind); + } +} + +pub fn codegen_inner(module: &mut Module, kind: AllocatorKind) { let usize_ty = module.target_config().pointer_type(); for method in ALLOCATOR_METHODS { diff --git a/src/common.rs b/src/common.rs index 8a6a40dff2a1f..1890caaf830a5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,6 +1,5 @@ use std::fmt; -use rustc_codegen_ssa::traits::BackendTypes; use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::Module; diff --git a/src/lib.rs b/src/lib.rs index a2ebf470b3d44..efedfbd1da373 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,6 +80,7 @@ mod prelude { pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; + pub use rustc_codegen_ssa::traits::*; pub use cranelift::codegen::ir::{ condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, @@ -200,6 +201,8 @@ impl CodegenBackend for CraneliftCodegenBackend { .unwrap(); codegen_mono_items(tcx, &mut jit_module, &mut log); + crate::allocator::codegen(tcx.sess, &mut jit_module); + jit_module.finalize_definitions(); tcx.sess.abort_if_errors(); println!("Compiled everything"); @@ -216,10 +219,9 @@ impl CodegenBackend for CraneliftCodegenBackend { jit_module.finish(); ::std::process::exit(0); } else { - let isa = build_isa(tcx.sess); let mut faerie_module: Module = Module::new( FaerieBuilder::new( - isa, + build_isa(tcx.sess), "some_file.o".to_string(), FaerieTrapCollection::Disabled, FaerieBuilder::default_libcall_names(), @@ -232,6 +234,8 @@ impl CodegenBackend for CraneliftCodegenBackend { ); codegen_mono_items(tcx, &mut faerie_module, &mut log); + crate::allocator::codegen(tcx.sess, &mut faerie_module); + faerie_module.finalize_definitions(); tcx.sess.abort_if_errors(); @@ -339,36 +343,26 @@ fn codegen_mono_items<'a, 'tcx: 'a>( .flatten() .collect::>(); - let before = ::std::time::Instant::now(); - println!("[codegen mono items] start"); - - for (&mono_item, &(_linkage, _vis)) in mono_items { - unimpl::try_unimpl(tcx, log, || { - base::trans_mono_item(tcx, module, &mut caches, &mut ccx, mono_item); - }); - } - - crate::main_shim::maybe_create_entry_wrapper(tcx, module); + time("codegen mono items", move || { + for (&mono_item, &(_linkage, _vis)) in mono_items { + unimpl::try_unimpl(tcx, log, || { + base::trans_mono_item(tcx, module, &mut caches, &mut ccx, mono_item); + }); + } - let any_dynamic_crate = tcx - .sess - .dependency_formats - .borrow() - .iter() - .any(|(_, list)| { - use rustc::middle::dependency_format::Linkage; - list.iter().any(|&linkage| linkage == Linkage::Dynamic) - }); - if any_dynamic_crate { - } else if let Some(kind) = *tcx.sess.allocator_kind.get() { - allocator::codegen(module, kind); - } + crate::main_shim::maybe_create_entry_wrapper(tcx, module); - ccx.finalize(tcx, module); - module.finalize_definitions(); + ccx.finalize(tcx, module); + }); +} +fn time(name: &str, f: impl FnOnce() -> R) -> R { + println!("[{}] start", name); + let before = ::std::time::Instant::now(); + let res = f(); let after = ::std::time::Instant::now(); - println!("[codegen mono items] end time: {:?}", after - before); + println!("[{}] end time: {:?}", name, after - before); + res } fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { From 870378c452a7b5220afa1a128293a9896f4c74cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 13 Dec 2018 05:45:53 +0000 Subject: [PATCH 0399/1566] Bump backtrace from 0.3.11 to 0.3.12 Bumps [backtrace](https://github.com/alexcrichton/backtrace-rs) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/alexcrichton/backtrace-rs/releases) - [Commits](https://github.com/alexcrichton/backtrace-rs/compare/0.3.11...0.3.12) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1179227e97a4c..536a2cdcd2b98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,7 +34,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,7 +251,7 @@ name = "failure" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -779,7 +779,7 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum backtrace 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "18b65ea1161bfb2dd6da6fade5edd4dbd08fba85012123dd333d2fd1b90b2782" +"checksum backtrace 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eff3830839471718ef8522b9025b399bfb713e25bc220da721364efb660d7d" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" From b1f1886dd59b641fd4fe6eaee3db57ffd1e30297 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 13 Dec 2018 07:30:37 +0000 Subject: [PATCH 0400/1566] Bump cc from 1.0.25 to 1.0.26 Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.25 to 1.0.26. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.25...1.0.26) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 536a2cdcd2b98..bc33cf97d7e17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ name = "backtrace-sys" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -454,7 +454,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -783,7 +783,7 @@ dependencies = [ "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" +"checksum cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "389803e36973d242e7fecb092b2de44a3d35ac62524b3b9339e51d577d668e02" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" From bc687ee99293163ff856aea9efee9c9cb27cb6d6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 13 Dec 2018 14:38:06 +0100 Subject: [PATCH 0401/1566] Prepare for emitting separate object files for each codegen unit --- src/lib.rs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index efedfbd1da373..dfe830b83b59d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,7 @@ use rustc::session::{ CompileIncomplete, }; use rustc::ty::query::Providers; +use rustc::mir::mono::{Linkage as RLinkage, Visibility}; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; use rustc_codegen_utils::codegen_backend::CodegenBackend; @@ -200,7 +201,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .declare_function("main", Linkage::Import, &sig) .unwrap(); - codegen_mono_items(tcx, &mut jit_module, &mut log); + codegen_cgus(tcx, &mut jit_module, &mut log); crate::allocator::codegen(tcx.sess, &mut jit_module); jit_module.finalize_definitions(); @@ -233,7 +234,7 @@ impl CodegenBackend for CraneliftCodegenBackend { faerie_module.target_config().pointer_type() ); - codegen_mono_items(tcx, &mut faerie_module, &mut log); + codegen_cgus(tcx, &mut faerie_module, &mut log); crate::allocator::codegen(tcx.sess, &mut faerie_module); faerie_module.finalize_definitions(); @@ -328,30 +329,40 @@ fn build_isa(sess: &Session) -> Box { .finish(flags) } -fn codegen_mono_items<'a, 'tcx: 'a>( +fn codegen_cgus<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, log: &mut Option, ) { - let mut caches = Caches::new(); - let mut ccx = ConstantCx::default(); - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); let mono_items = cgus .iter() .map(|cgu| cgu.items().iter()) .flatten() - .collect::>(); + .map(|(&mono_item, &(linkage, vis))| (mono_item, (linkage, vis))) + .collect::>(); + + codegen_mono_items(tcx, module, log, mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, module); +} + +fn codegen_mono_items<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + log: &mut Option, + mono_items: FxHashMap, (RLinkage, Visibility)>, +) { time("codegen mono items", move || { - for (&mono_item, &(_linkage, _vis)) in mono_items { + let mut caches = Caches::new(); + let mut ccx = ConstantCx::default(); + + for (mono_item, (_linkage, _vis)) in mono_items { unimpl::try_unimpl(tcx, log, || { base::trans_mono_item(tcx, module, &mut caches, &mut ccx, mono_item); }); } - crate::main_shim::maybe_create_entry_wrapper(tcx, module); - ccx.finalize(tcx, module); }); } From 978add369838ff5dda91508a892b6be0b87956dc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 13 Dec 2018 15:06:30 +0100 Subject: [PATCH 0402/1566] Convenience functions for creating and emitting faerie modules --- src/lib.rs | 64 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index dfe830b83b59d..bb7ff63b0a67e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,43 +220,51 @@ impl CodegenBackend for CraneliftCodegenBackend { jit_module.finish(); ::std::process::exit(0); } else { - let mut faerie_module: Module = Module::new( - FaerieBuilder::new( - build_isa(tcx.sess), - "some_file.o".to_string(), - FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names(), - ) - .unwrap(), - ); - assert_eq!( - pointer_ty(tcx), - faerie_module.target_config().pointer_type() - ); + let new_module = |name: String| { + let module: Module = Module::new( + FaerieBuilder::new( + build_isa(tcx.sess), + name + ".o", + FaerieTrapCollection::Disabled, + FaerieBuilder::default_libcall_names(), + ) + .unwrap(), + ); + assert_eq!( + pointer_ty(tcx), + module.target_config().pointer_type() + ); + module + }; + + let mut faerie_module = new_module("some_file".to_string()); codegen_cgus(tcx, &mut faerie_module, &mut log); crate::allocator::codegen(tcx.sess, &mut faerie_module); - faerie_module.finalize_definitions(); tcx.sess.abort_if_errors(); - let artifact = faerie_module.finish().artifact; - - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, None); - let obj = artifact.emit().unwrap(); - std::fs::write(&tmp_file, obj).unwrap(); - - return Box::new(CodegenResults { - crate_name: tcx.crate_name(LOCAL_CRATE), - modules: vec![CompiledModule { - name: "dummy_name".to_string(), - kind: ModuleKind::Regular, + let emit_module = |name: &str, kind: ModuleKind, mut module: Module| { + module.finalize_definitions(); + let artifact = module.finish().artifact; + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(name)); + let obj = artifact.emit().unwrap(); + std::fs::write(&tmp_file, obj).unwrap(); + CompiledModule { + name: name.to_string(), + kind, object: Some(tmp_file), bytecode: None, bytecode_compressed: None, - }], + } + }; + + return Box::new(CodegenResults { + crate_name: tcx.crate_name(LOCAL_CRATE), + modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module)], allocator_module: None, metadata_module: CompiledModule { name: "dummy_metadata".to_string(), From 77e36125812c257c68a89d56e6dad30e6c081ebe Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 13 Dec 2018 15:08:11 +0100 Subject: [PATCH 0403/1566] Move emit_module a bit up --- src/lib.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bb7ff63b0a67e..c7b328b5d8812 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -237,13 +237,6 @@ impl CodegenBackend for CraneliftCodegenBackend { module }; - let mut faerie_module = new_module("some_file".to_string()); - - codegen_cgus(tcx, &mut faerie_module, &mut log); - crate::allocator::codegen(tcx.sess, &mut faerie_module); - - tcx.sess.abort_if_errors(); - let emit_module = |name: &str, kind: ModuleKind, mut module: Module| { module.finalize_definitions(); let artifact = module.finish().artifact; @@ -262,6 +255,13 @@ impl CodegenBackend for CraneliftCodegenBackend { } }; + let mut faerie_module = new_module("some_file".to_string()); + + codegen_cgus(tcx, &mut faerie_module, &mut log); + crate::allocator::codegen(tcx.sess, &mut faerie_module); + + tcx.sess.abort_if_errors(); + return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module)], From c8d435aade4db3e51eb2414293a8e0d7934bd17a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 13 Dec 2018 15:16:46 +0100 Subject: [PATCH 0404/1566] Put allocator shim in a different object file --- src/allocator.rs | 7 ++++++- src/lib.rs | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 9c444d8cfc51c..1cc45a7d93bbd 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -13,7 +13,8 @@ use crate::prelude::*; use rustc::middle::allocator::AllocatorKind; use rustc_allocator::{AllocatorTy, ALLOCATOR_METHODS}; -pub fn codegen(sess: &Session, module: &mut Module) { +/// Returns whether an allocator shim was created +pub fn codegen(sess: &Session, module: &mut Module) -> bool { let any_dynamic_crate = sess .dependency_formats .borrow() @@ -23,8 +24,12 @@ pub fn codegen(sess: &Session, module: &mut Module) { list.iter().any(|&linkage| linkage == Linkage::Dynamic) }); if any_dynamic_crate { + false } else if let Some(kind) = *sess.allocator_kind.get() { codegen_inner(module, kind); + true + } else { + false } } diff --git a/src/lib.rs b/src/lib.rs index c7b328b5d8812..a1628b8b08db4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -258,14 +258,21 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut faerie_module = new_module("some_file".to_string()); codegen_cgus(tcx, &mut faerie_module, &mut log); - crate::allocator::codegen(tcx.sess, &mut faerie_module); tcx.sess.abort_if_errors(); + let mut allocator_module = new_module("allocator_shim.o".to_string()); + let created_alloc_shim = + crate::allocator::codegen(tcx.sess, &mut allocator_module); + return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module)], - allocator_module: None, + allocator_module: if created_alloc_shim { + Some(emit_module("allocator_shim", ModuleKind::Allocator, allocator_module)) + } else { + None + }, metadata_module: CompiledModule { name: "dummy_metadata".to_string(), kind: ModuleKind::Metadata, From 2d14dc9f1e02131d01906e8dcfa87861da8fe5f2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Dec 2018 13:42:26 +0100 Subject: [PATCH 0405/1566] Rustup cg_ssa to rustc 1.32.0-nightly (f4a421ee3 2018-12-13) --- src/constant.rs | 8 ++++---- src/link_copied.rs | 17 +++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index add22389bfe73..366b06a127660 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ - read_target_uint, AllocId, AllocType, Allocation, ConstValue, EvalResult, GlobalId, Scalar, + read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; use rustc::ty::Const; use rustc_mir::interpret::{ @@ -253,7 +253,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( }; let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { - AllocType::Function(instance) => { + AllocKind::Function(instance) => { let (func_name, sig) = crate::abi::get_function_name_and_sig(tcx, instance); let func_id = module .declare_function(&func_name, Linkage::Import, &sig) @@ -262,11 +262,11 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( data_ctx.write_function_addr(reloc_offset as u32, local_func_id); continue; } - AllocType::Memory(_) => { + AllocKind::Memory(_) => { cx.todo.insert(TodoItem::Alloc(reloc)); data_id_for_alloc_id(module, reloc) } - AllocType::Static(def_id) => { + AllocKind::Static(def_id) => { cx.todo.insert(TodoItem::Static(def_id)); data_id_for_static(tcx, module, def_id, Linkage::Import) } diff --git a/src/link_copied.rs b/src/link_copied.rs index bf5be809a0e55..c19a6eec7391d 100644 --- a/src/link_copied.rs +++ b/src/link_copied.rs @@ -32,11 +32,7 @@ use crate::metadata::METADATA_FILENAME; const RLIB_BYTECODE_EXTENSION: &str = ".cg_clif_bytecode_dummy"; fn archive_search_paths(sess: &Session) -> Vec { - let mut search = Vec::new(); - sess.target_filesearch(PathKind::Native).for_each_lib_search_path(|path, _| { - search.push(path.to_path_buf()); - }); - return search; + sess.target_filesearch(PathKind::Native).search_path_dirs() } fn archive_config<'a>(sess: &'a Session, @@ -526,12 +522,13 @@ pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, pub fn add_local_native_libraries(cmd: &mut dyn Linker, sess: &Session, codegen_results: &CodegenResults) { - sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, k| { - match k { - PathKind::Framework => { cmd.framework_path(path); } - _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(path)); } + let filesearch = sess.target_filesearch(PathKind::All); + for search_path in filesearch.search_paths() { + match search_path.kind { + PathKind::Framework => { cmd.framework_path(&search_path.dir); } + _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(&search_path.dir)); } } - }); + } let relevant_libs = codegen_results.crate_info.used_libraries.iter().filter(|l| { relevant_lib(sess, l) From 9351f1d0c7763ee8564e096eaa3ed607f089e5db Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Dec 2018 14:46:58 +0100 Subject: [PATCH 0406/1566] Rustup patches to rustc 1.33.0-nightly (96d1334e5 2018-12-14) --- patches/0001-Disable-stdsimd.patch | 45 +++++---- ...002-Disable-u128-and-i128-in-libcore.patch | 96 +++++++++---------- patches/0007-Fix-libstd-building.patch | 39 ++++---- 3 files changed, 94 insertions(+), 86 deletions(-) diff --git a/patches/0001-Disable-stdsimd.patch b/patches/0001-Disable-stdsimd.patch index bdd3615d6e4f6..fa713271f10e3 100644 --- a/patches/0001-Disable-stdsimd.patch +++ b/patches/0001-Disable-stdsimd.patch @@ -1,35 +1,44 @@ -From fd6acae580c2be9e8ba9c32b013df4e9547d936f Mon Sep 17 00:00:00 2001 +From 8bce7b9601aec46ee7704027dc173257d3e43492 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Mon, 12 Nov 2018 19:08:45 +0100 +Date: Fri, 14 Dec 2018 13:09:42 +0100 Subject: [PATCH] Disable stdsimd --- src/libcore/lib.rs | 2 ++ - src/libstd/lib.rs | 2 ++ - 2 files changed, 4 insertions(+) + src/libstd/lib.rs | 4 +++- + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index c69d444..1b7abad 100644 +index a51674f..313c173 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -228,6 +228,7 @@ mod nonzero; - mod tuple; - mod unit; - +@@ -248,6 +248,7 @@ macro_rules! test_v256 { ($item:item) => {}; } + macro_rules! test_v512 { ($item:item) => {}; } + #[allow(unused_macros)] + macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } } +/* - // Pull in the `coresimd` crate directly into libcore. This is where all the - // architecture-specific (and vendor-specific) intrinsics are defined. AKA - // things like SIMD and such. Note that the actual source for all this lies in a -@@ -256,3 +257,4 @@ mod coresimd; + #[path = "../stdsimd/coresimd/mod.rs"] + #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)] + #[unstable(feature = "stdsimd", issue = "48556")] +@@ -255,3 +256,4 @@ mod coresimd; + #[stable(feature = "simd_arch", since = "1.27.0")] - #[cfg(not(stage0))] pub use coresimd::arch; +*/ diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index f460d10..6110b05 100644 +index 90c8eaf..95541c3 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -493,6 +493,7 @@ mod memchr; +@@ -287,7 +287,7 @@ + #![feature(rustc_attrs)] + #![feature(rustc_const_unstable)] + #![feature(std_internals)] +-#![feature(stdsimd)] ++//#![feature(stdsimd)] + #![feature(shrink_to)] + #![feature(slice_concat_ext)] + #![feature(slice_internals)] +@@ -503,6 +503,7 @@ mod memchr; // compiler pub mod rt; @@ -37,9 +46,9 @@ index f460d10..6110b05 100644 // Pull in the `stdsimd` crate directly into libstd. This is the same as // libcore's arch/simd modules where the source of truth here is in a different // repository, but we pull things in here manually to get it into libstd. -@@ -517,6 +518,7 @@ mod coresimd { +@@ -526,6 +527,7 @@ mod coresimd { #[stable(feature = "simd_arch", since = "1.27.0")] - #[cfg(all(not(stage0), not(test)))] + #[cfg(not(test))] pub use stdsimd::arch; +*/ diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index a8f2005a64c6c..cd90c6ef1c145 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,31 +1,31 @@ -From 7a466d258ff8c795fa52274e0627a39becb3bdf3 Mon Sep 17 00:00:00 2001 +From a759066c5c2c63d945b23f1e9d35d0dd0489faf1 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Tue, 13 Nov 2018 18:11:23 +0100 +Date: Sat, 15 Dec 2018 11:28:12 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- src/libcore/clone.rs | 4 +- - src/libcore/cmp.rs | 6 +-- + src/libcore/cmp.rs | 6 +- src/libcore/default.rs | 2 - - src/libcore/fmt/num.rs | 6 +-- - src/libcore/hash/mod.rs | 20 ------- + src/libcore/fmt/num.rs | 6 +- + src/libcore/hash/mod.rs | 20 ------ src/libcore/iter/range.rs | 1 - src/libcore/iter/traits.rs | 2 +- src/libcore/lib.rs | 2 - src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 99 +++++++++------------------------- - src/libcore/num/wrapping.rs | 14 ++--- - src/libcore/ops/arith.rs | 22 ++++---- - src/libcore/ops/bit.rs | 30 ++++------- - src/libcore/sync/atomic.rs | 28 ---------- - src/libcore/tests/iter.rs | 15 ------ - src/libcore/tests/num/mod.rs | 18 ------- - src/libcore/time.rs | 126 ------------------------------------------- + src/libcore/num/mod.rs | 99 ++++++++------------------- + src/libcore/num/wrapping.rs | 14 ++-- + src/libcore/ops/arith.rs | 22 +++--- + src/libcore/ops/bit.rs | 30 +++------ + src/libcore/sync/atomic.rs | 28 -------- + src/libcore/tests/iter.rs | 15 ----- + src/libcore/tests/num/mod.rs | 18 ----- + src/libcore/time.rs | 126 ----------------------------------- 18 files changed, 62 insertions(+), 339 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs -index 46bb580..fcf9fa8 100644 +index 225ea3d..a7f2637 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -172,8 +172,8 @@ mod impls { @@ -130,7 +130,7 @@ index 51391fa..140255e 100644 impl_Display!(isize, usize: to_u16); #[cfg(target_pointer_width = "32")] diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs -index bbebadd..d6de656 100644 +index 3e59ee1..3f8d682 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -306,12 +306,6 @@ pub trait Hasher { @@ -189,7 +189,7 @@ index bbebadd..d6de656 100644 #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index 55addd8..6695cfe 100644 +index f0fd07b..72a3ec9 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -183,7 +183,6 @@ step_impl_signed!([i64: u64]); @@ -201,7 +201,7 @@ index 55addd8..6695cfe 100644 macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs -index f95f8e7..549d832 100644 +index 45e5b61..64a3038 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -843,7 +843,7 @@ macro_rules! float_sum_product { @@ -214,10 +214,10 @@ index f95f8e7..549d832 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 1fec2e5..04266ee 100644 +index 313c173..4315135 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -152,14 +152,12 @@ mod uint_macros; +@@ -154,14 +154,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -233,10 +233,10 @@ index 1fec2e5..04266ee 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 662a8dd..856878e 100644 +index d3d1612..f827f64 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs -@@ -673,8 +673,8 @@ mod copy_impls { +@@ -674,8 +674,8 @@ mod copy_impls { } impl_copy! { @@ -248,10 +248,10 @@ index 662a8dd..856878e 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index d4b7094..3b5a197 100644 +index afd9fcb..ad3362c 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs -@@ -162,12 +162,10 @@ pub fn forget(t: T) { +@@ -173,12 +173,10 @@ pub fn forget_unsized(t: T) { /// u16 | 2 /// u32 | 4 /// u64 | 8 @@ -265,7 +265,7 @@ index d4b7094..3b5a197 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 30b7b45..88a294a 100644 +index 4acf3a1..b5b3f54 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -112,7 +112,6 @@ nonzero_integers! { @@ -276,7 +276,7 @@ index 30b7b45..88a294a 100644 NonZeroUsize(usize); } -@@ -2087,18 +2086,6 @@ impl i64 { +@@ -2114,18 +2113,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -295,7 +295,7 @@ index 30b7b45..88a294a 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4349,17 +4336,6 @@ impl u64 { +@@ -4394,17 +4381,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -313,7 +313,7 @@ index 30b7b45..88a294a 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4443,7 +4419,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4488,7 +4464,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -322,7 +322,7 @@ index 30b7b45..88a294a 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4559,30 +4535,25 @@ macro_rules! rev { +@@ -4604,30 +4580,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -357,7 +357,7 @@ index 30b7b45..88a294a 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4594,21 +4565,21 @@ mod ptr_try_from_impls { +@@ -4639,21 +4610,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -387,7 +387,7 @@ index 30b7b45..88a294a 100644 } #[cfg(target_pointer_width = "32")] -@@ -4617,24 +4588,24 @@ mod ptr_try_from_impls { +@@ -4662,24 +4633,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -420,7 +420,7 @@ index 30b7b45..88a294a 100644 } #[cfg(target_pointer_width = "64")] -@@ -4643,24 +4614,20 @@ mod ptr_try_from_impls { +@@ -4688,24 +4659,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -449,7 +449,7 @@ index 30b7b45..88a294a 100644 } #[doc(hidden)] -@@ -4695,7 +4662,7 @@ macro_rules! doit { +@@ -4740,7 +4707,7 @@ macro_rules! doit { } })*) } @@ -458,7 +458,7 @@ index 30b7b45..88a294a 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4863,52 +4830,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4931,52 +4898,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -512,7 +512,7 @@ index 30b7b45..88a294a 100644 // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs -index 00134a5..ea15481 100644 +index 94dd657..fba1319 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -112,19 +112,17 @@ macro_rules! sh_impl_all { @@ -835,14 +835,14 @@ index 3900f36..66b7980 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index 56d3b42..34df75f 100644 +index 060983a..ade04a5 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs -@@ -1938,34 +1938,6 @@ atomic_int! { +@@ -1940,34 +1940,6 @@ atomic_int! { 8, u64 AtomicU64 ATOMIC_U64_INIT } --#[cfg(all(not(stage0), target_has_atomic = "128"))] +-#[cfg(target_has_atomic = "128")] -atomic_int! { - unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "32976"), @@ -856,7 +856,7 @@ index 56d3b42..34df75f 100644 - 16, - i128 AtomicI128 ATOMIC_I128_INIT -} --#[cfg(all(not(stage0), target_has_atomic = "128"))] +-#[cfg(target_has_atomic = "128")] -atomic_int! { - unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "integer_atomics", issue = "32976"), @@ -874,7 +874,7 @@ index 56d3b42..34df75f 100644 macro_rules! ptr_width { () => { 2 } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index 2476c07..2075670 100644 +index 4efa013..717bcdc 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -224,8 +224,6 @@ fn test_iterator_step_by_nth_overflow() { @@ -886,10 +886,11 @@ index 2476c07..2075670 100644 #[derive(Clone)] struct Test(Bigger); -@@ -1878,19 +1876,6 @@ fn test_step_replace_signed() { +@@ -1914,19 +1912,6 @@ fn test_step_replace_signed() { + assert_eq!(y, 5); } - #[test] +-#[test] -fn test_step_replace_no_between() { - let mut x = 4u128; - let y = x.replace_zero(); @@ -902,15 +903,14 @@ index 2476c07..2075670 100644 - assert_eq!(y, 5); -} - --#[test] + #[test] fn test_rev_try_folds() { let f = &|acc, x| i32::checked_add(2*acc, x); - assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs -index ab96d31..bb5c1d0 100644 +index 0928f75..34a5296 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs -@@ -196,12 +196,10 @@ test_impl_from! { test_boolu8, bool, u8 } +@@ -188,12 +188,10 @@ test_impl_from! { test_boolu8, bool, u8 } test_impl_from! { test_boolu16, bool, u16 } test_impl_from! { test_boolu32, bool, u32 } test_impl_from! { test_boolu64, bool, u64 } @@ -923,7 +923,7 @@ index ab96d31..bb5c1d0 100644 // Signed -> Float test_impl_from! { test_i8f32, i8, f32 } -@@ -283,51 +281,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } +@@ -275,51 +273,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } test_impl_try_from_always_ok! { test_try_u8u16, u8, u16 } test_impl_try_from_always_ok! { test_try_u8u32, u8, u32 } test_impl_try_from_always_ok! { test_try_u8u64, u8, u64 } @@ -976,7 +976,7 @@ index ab96d31..bb5c1d0 100644 test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index 938e975..2ba930d 100644 +index 475bb72..a8a9d42 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -30,7 +30,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; @@ -1127,5 +1127,5 @@ index 938e975..2ba930d 100644 /// /// # Examples -- -2.11.0 +2.17.2 (Apple Git-113) diff --git a/patches/0007-Fix-libstd-building.patch b/patches/0007-Fix-libstd-building.patch index bbbbaab9ff10d..ca566deba85e8 100644 --- a/patches/0007-Fix-libstd-building.patch +++ b/patches/0007-Fix-libstd-building.patch @@ -1,6 +1,6 @@ -From d8bb60cc115960702f73f83866cde65dcdcf1cb4 Mon Sep 17 00:00:00 2001 +From a99af7473c8b334ed6febe97294813298b6a3633 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 17 Nov 2018 11:08:10 +0100 +Date: Sat, 15 Dec 2018 14:32:15 +0100 Subject: [PATCH] Fix libstd building --- @@ -12,10 +12,17 @@ Subject: [PATCH] Fix libstd building 5 files changed, 1 insertion(+), 49 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 6110b05..8b0c897 100644 +index f3965f3..13e17b1 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -255,7 +255,6 @@ +@@ -249,14 +249,12 @@ + #![feature(cfg_target_thread_local)] + #![feature(cfg_target_vendor)] + #![feature(char_error_internals)] +-#![feature(compiler_builtins_lib)] + #![feature(const_int_ops)] + #![feature(const_ip)] + #![feature(const_raw_ptr_deref)] #![feature(const_cstr_unchecked)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] @@ -23,15 +30,7 @@ index 6110b05..8b0c897 100644 #![feature(exact_size_is_empty)] #![feature(external_doc)] #![feature(fixed_size_array)] -@@ -286,7 +285,6 @@ - #![feature(rustc_attrs)] - #![feature(rustc_const_unstable)] - #![feature(std_internals)] --#![cfg_attr(not(stage0), feature(stdsimd))] - #![feature(shrink_to)] - #![feature(slice_concat_ext)] - #![feature(slice_internals)] -@@ -402,8 +400,6 @@ pub use core::i16; +@@ -409,8 +407,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -40,7 +39,7 @@ index 6110b05..8b0c897 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -436,8 +432,6 @@ pub use alloc_crate::string; +@@ -443,8 +439,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -94,14 +93,14 @@ index 3f90c1f..85aab83 100644 #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs -index 4bc18a5..5c87035 100644 +index 3eacc7a..b518448 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -264,9 +264,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} #[cfg(target_has_atomic = "64")] #[unstable(feature = "integer_atomics", issue = "32976")] impl RefUnwindSafe for atomic::AtomicI64 {} --#[cfg(all(not(stage0), target_has_atomic = "128"))] +-#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicI128 {} @@ -111,17 +110,17 @@ index 4bc18a5..5c87035 100644 #[cfg(target_has_atomic = "64")] #[unstable(feature = "integer_atomics", issue = "32976")] impl RefUnwindSafe for atomic::AtomicU64 {} --#[cfg(all(not(stage0), target_has_atomic = "128"))] +-#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicU128 {} #[cfg(target_has_atomic = "8")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs -index c2a1612..99824c5 100644 +index 7c1654f..cc96271 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs -@@ -809,14 +809,6 @@ mod prim_i32 { } +@@ -808,14 +808,6 @@ mod prim_i32 { } #[stable(feature = "rust1", since = "1.0.0")] mod prim_i64 { } @@ -136,7 +135,7 @@ index c2a1612..99824c5 100644 #[doc(primitive = "u8")] // /// The 8-bit unsigned integer type. -@@ -849,14 +841,6 @@ mod prim_u32 { } +@@ -848,14 +840,6 @@ mod prim_u32 { } #[stable(feature = "rust1", since = "1.0.0")] mod prim_u64 { } From 1e5c6bc5b86c4ff61ef3de63a9748789d5b369b0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Dec 2018 13:58:33 +0100 Subject: [PATCH 0407/1566] Stop using xargo for building the sysroot It is currently broken. (see https://github.com/japaric/xargo/issues/227) This makes it easier to for example patch whole crates away. --- .gitignore | 3 ++ .travis.yml | 6 +--- alloc_system/Cargo.toml | 16 --------- build_sysroot/Cargo.toml | 15 +++++++++ build_sysroot/alloc_system/Cargo.toml | 13 ++++++++ .../alloc_system}/lib.rs | 0 build_sysroot/build_sysroot.sh | 33 +++++++++++++++++++ build_sysroot/compiler_builtins/Cargo.toml | 20 +++++++++++ build_sysroot/compiler_builtins/lib.rs | 3 ++ .../prepare_sysroot_src.sh | 18 ++++++---- build_sysroot/src/lib.rs | 1 + clean_all.sh | 4 +++ config.sh | 1 - flamegraph.sh | 3 +- patches/0005-Disable-compiler_builtins.patch | 29 ---------------- prepare.sh | 6 ++++ test.sh | 23 +++++-------- xargo/Cargo.lock | 4 --- xargo/Cargo.toml | 6 ---- xargo/Xargo.toml | 7 ---- xargo/src/lib.rs | 5 --- 21 files changed, 121 insertions(+), 95 deletions(-) delete mode 100644 alloc_system/Cargo.toml create mode 100644 build_sysroot/Cargo.toml create mode 100644 build_sysroot/alloc_system/Cargo.toml rename {alloc_system => build_sysroot/alloc_system}/lib.rs (100%) create mode 100755 build_sysroot/build_sysroot.sh create mode 100644 build_sysroot/compiler_builtins/Cargo.toml create mode 100644 build_sysroot/compiler_builtins/lib.rs rename prepare_libcore.sh => build_sysroot/prepare_sysroot_src.sh (55%) create mode 100644 build_sysroot/src/lib.rs create mode 100755 clean_all.sh delete mode 100644 patches/0005-Disable-compiler_builtins.patch create mode 100755 prepare.sh delete mode 100644 xargo/Cargo.lock delete mode 100644 xargo/Cargo.toml delete mode 100644 xargo/Xargo.toml delete mode 100644 xargo/src/lib.rs diff --git a/.gitignore b/.gitignore index cbb4eeafa3408..1290c0f78d61e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ target *.o perf.data perf.data.old +/build_sysroot/sysroot +/build_sysroot/sysroot_src +/build_sysroot/Cargo.lock diff --git a/.travis.yml b/.travis.yml index c14a09192a7a9..f32a95d2d46fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,7 @@ rust: - nightly script: - - rustup component add rust-src - - cargo install xargo || echo "Skipping xargo install" - - cargo install hyperfine || echo "Skipping hyperfine install" - - ./prepare_libcore.sh - - ./test.sh + - ./prepare.sh && ./test.sh env: - RUST_BACKTRACE=1 diff --git a/alloc_system/Cargo.toml b/alloc_system/Cargo.toml deleted file mode 100644 index ae146c48e3aac..0000000000000 --- a/alloc_system/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -authors = ["The Rust Project Developers", "bjorn3 (edited to be usable outside the rust source)"] -name = "alloc_system" -version = "0.0.0" -[lib] -name = "alloc_system" -path = "lib.rs" -test = false -doc = false -[dependencies] -core = { path = "../libcore" } -libc = { path = "../rustc/libc_shim" } -compiler_builtins = { path = "../rustc/compiler_builtins_shim" } -# See comments in the source for what this dependency is -[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies] -dlmalloc = { path = "../rustc/dlmalloc_shim" } diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml new file mode 100644 index 0000000000000..d4873602d4d48 --- /dev/null +++ b/build_sysroot/Cargo.toml @@ -0,0 +1,15 @@ +[package] +authors = ["bjorn3 "] +name = "sysroot" +version = "0.0.0" + +[dependencies] +core = { path = "./sysroot_src/src/libcore" } +compiler_builtins = "0.1" +alloc = { path = "./sysroot_src/src/liballoc" } + +alloc_system = { path = "./alloc_system" } + +[patch.crates-io] +rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } +compiler_builtins = { path = "./compiler_builtins" } diff --git a/build_sysroot/alloc_system/Cargo.toml b/build_sysroot/alloc_system/Cargo.toml new file mode 100644 index 0000000000000..221faab32bd83 --- /dev/null +++ b/build_sysroot/alloc_system/Cargo.toml @@ -0,0 +1,13 @@ +[package] +authors = ["The Rust Project Developers", "bjorn3 (edited to be usable outside the rust source)"] +name = "alloc_system" +version = "0.0.0" +[lib] +name = "alloc_system" +path = "lib.rs" +test = false +doc = false +[dependencies] +core = { path = "../sysroot_src/src/libcore" } +libc = { version = "0.2.43", features = ['rustc-dep-of-std'], default-features = false } +compiler_builtins = "0.1" diff --git a/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs similarity index 100% rename from alloc_system/lib.rs rename to build_sysroot/alloc_system/lib.rs diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh new file mode 100755 index 0000000000000..38608e02163b0 --- /dev/null +++ b/build_sysroot/build_sysroot.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -e +cd $(dirname "$0") + +# Cleanup for previous run +cargo clean +rm Cargo.lock 2>/dev/null || true +rm -r sysroot 2>/dev/null || true + +# FIXME find a better way to get the target triple +unamestr=`uname` +if [[ "$unamestr" == 'Linux' ]]; then + TARGET_TRIPLE='x86_64-unknown-linux-gnu' +elif [[ "$unamestr" == 'Darwin' ]]; then + TARGET_TRIPLE='x86_64-apple-darwin' +else + echo "Unsupported os" + exit 1 +fi + +# Build libs +export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked --sysroot ../" +if [[ "$1" == "--release" ]]; then + channel='release' + RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release +else + channel='debug' + cargo build --target $TARGET_TRIPLE +fi + +# Copy files to sysroot +mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/build_sysroot/compiler_builtins/Cargo.toml b/build_sysroot/compiler_builtins/Cargo.toml new file mode 100644 index 0000000000000..724a637a20135 --- /dev/null +++ b/build_sysroot/compiler_builtins/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "compiler_builtins" +# Make sure the `compiler_builtins` from crates.io doesn't take precedence over this +# replacement by specifying a higher version than the one on crates.io. +version = "0.1.100" +authors = ["bjorn3 "] +edition = "2018" + +[lib] +name = "compiler_builtins" +path = "lib.rs" +test = false +doc = false + +[dependencies] +core = { path = "../sysroot_src/src/libcore" } + +[features] +rustc-dep-of-std = [] +c = [] diff --git a/build_sysroot/compiler_builtins/lib.rs b/build_sysroot/compiler_builtins/lib.rs new file mode 100644 index 0000000000000..90a118deeef75 --- /dev/null +++ b/build_sysroot/compiler_builtins/lib.rs @@ -0,0 +1,3 @@ +#![feature(compiler_builtins)] +#![compiler_builtins] +#![no_std] diff --git a/prepare_libcore.sh b/build_sysroot/prepare_sysroot_src.sh similarity index 55% rename from prepare_libcore.sh rename to build_sysroot/prepare_sysroot_src.sh index b3a3723e2df78..fceccdb4deaa6 100755 --- a/prepare_libcore.sh +++ b/build_sysroot/prepare_sysroot_src.sh @@ -1,8 +1,9 @@ -#!/bin/bash --verbose +#!/bin/bash set -e +cd $(dirname "$0") SRC_DIR=$(dirname $(rustup which rustc))"/../lib/rustlib/src/rust/" -DST_DIR="target/libcore" +DST_DIR="sysroot_src" if [ ! -e $SRC_DIR ]; then echo "Please install rust-src component" @@ -14,14 +15,17 @@ mkdir -p $DST_DIR/src cp -r $SRC_DIR/src $DST_DIR/ pushd $DST_DIR +echo "[GIT] init" git init +echo "[GIT] add" git add . +echo "[GIT] commit" git commit -m "Initial commit" -q -git apply ../../patches/*.patch +for file in $(ls ../../patches/ | grep -v patcha); do +echo "[GIT] apply" $file +git apply ../../patches/$file +git commit -am "Patch $file" +done popd -# `alloc_system` has been merged with libstd, which doesn't build yet. -# This copies the original source to the sysroot source dir to simplify building it -cp -r alloc_system $DST_DIR/src/liballoc_system - echo "Successfully prepared libcore for building" diff --git a/build_sysroot/src/lib.rs b/build_sysroot/src/lib.rs new file mode 100644 index 0000000000000..0c9ac1ac8e4bd --- /dev/null +++ b/build_sysroot/src/lib.rs @@ -0,0 +1 @@ +#![no_std] diff --git a/clean_all.sh b/clean_all.sh new file mode 100755 index 0000000000000..f768bb50c73f6 --- /dev/null +++ b/clean_all.sh @@ -0,0 +1,4 @@ +#!/bin/bash --verbose +set -e + +rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/,Cargo.lock} perf.data{,.old} diff --git a/config.sh b/config.sh index a2772d635d14d..5508acf870cfa 100644 --- a/config.sh +++ b/config.sh @@ -19,5 +19,4 @@ else fi export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext -export XARGO_RUST_SRC=$(pwd)'/target/libcore/src' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" diff --git a/flamegraph.sh b/flamegraph.sh index 4506c77371d4f..ce095483ce93d 100755 --- a/flamegraph.sh +++ b/flamegraph.sh @@ -5,7 +5,8 @@ source config.sh rm perf.data* || true # Profile compiling libcore -perf record -F 9000 --call-graph dwarf -- $RUSTC --crate-type lib target/libcore/src/libcore/lib.rs --crate-name core +perf record -F 9000 --call-graph dwarf \ + -- $RUSTC --crate-type lib build_sysroot/sysroot_src/src/libcore/lib.rs --crate-name core # Generate the flamegraph perf script | ../FlameGraph/stackcollapse-perf.pl | grep cranelift | ../FlameGraph/flamegraph.pl > abc.svg diff --git a/patches/0005-Disable-compiler_builtins.patch b/patches/0005-Disable-compiler_builtins.patch deleted file mode 100644 index 8ffb00cff42c2..0000000000000 --- a/patches/0005-Disable-compiler_builtins.patch +++ /dev/null @@ -1,29 +0,0 @@ -From d873311b7bd16bac383d71d49f93d0448cfcb0b1 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sun, 30 Sep 2018 18:32:50 +0200 -Subject: [PATCH] Disable compiler_builtins - ---- - src/libcompiler_builtins/src/lib.rs | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/libcompiler_builtins/src/lib.rs b/src/libcompiler_builtins/src/lib.rs -index 9f1dd15..b1eed26 100644 ---- a/src/libcompiler_builtins/src/lib.rs -+++ b/src/libcompiler_builtins/src/lib.rs -@@ -34,6 +34,7 @@ - // that follow "x86 naming convention" (e.g. addsf3). Those aeabi intrinsics must adhere to the - // AAPCS calling convention (`extern "aapcs"`) because that's how LLVM will call them. - -+/* - #[cfg(test)] - extern crate core; - -@@ -68,3 +69,4 @@ pub mod x86; - pub mod x86_64; - - pub mod probestack; -+*/ --- -2.17.1 (Apple Git-112) - diff --git a/prepare.sh b/prepare.sh new file mode 100755 index 0000000000000..be3388aac555f --- /dev/null +++ b/prepare.sh @@ -0,0 +1,6 @@ +#!/bin/bash --verbose +set -e + +rustup component add rust-src +./build_sysroot/prepare_sysroot_src.sh +cargo install hyperfine || echo "Skipping hyperfine install" diff --git a/test.sh b/test.sh index 7c7f789084327..6c742298cf82d 100755 --- a/test.sh +++ b/test.sh @@ -21,26 +21,21 @@ SHOULD_RUN=1 $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" build_example_bin mini_core_hello_world example/mini_core_hello_world.rs -pushd xargo -rm -r ~/.xargo/HOST || true -rm -r target || true -time xargo build -popd +echo "[BUILD] sysroot" +time ./build_sysroot/build_sysroot.sh # TODO linux linker doesn't accept duplicate definitions -#$RUSTC --sysroot ~/.xargo/HOST example/alloc_example.rs --crate-type bin +# echo "[BUILD+RUN] alloc_example" +#$RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin #./target/out/alloc_example -$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin +echo "[BUILD] mod_bench" +$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -echo "[BUILD] RUSTFLAGS=-Zmir-opt-level=3" -pushd xargo -rm -r ~/.xargo/HOST || true -rm -r target || true -time RUSTFLAGS="-Zmir-opt-level=3 $RUSTFLAGS" xargo build -popd +echo "[BUILD] sysroot in release mode" +./build_sysroot/build_sysroot.sh --release -COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ~/.xargo/HOST example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -Og --crate-name mod_bench_inline" +COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -Og --crate-name mod_bench_inline" COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" diff --git a/xargo/Cargo.lock b/xargo/Cargo.lock deleted file mode 100644 index 6bcf3b8bc5285..0000000000000 --- a/xargo/Cargo.lock +++ /dev/null @@ -1,4 +0,0 @@ -[[package]] -name = "xargo" -version = "0.1.0" - diff --git a/xargo/Cargo.toml b/xargo/Cargo.toml deleted file mode 100644 index 9498cce26287f..0000000000000 --- a/xargo/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "xargo" -version = "0.1.0" -authors = ["bjorn3 "] - -[dependencies] diff --git a/xargo/Xargo.toml b/xargo/Xargo.toml deleted file mode 100644 index 2fef2be4c0283..0000000000000 --- a/xargo/Xargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[dependencies] -core = {} -alloc = {} -alloc_system = {} - -# Disabled due to missing support for many things (intrinsics, etc) in rustc_codegen_cranelift -#std = {} diff --git a/xargo/src/lib.rs b/xargo/src/lib.rs deleted file mode 100644 index 1b5eb57bb460a..0000000000000 --- a/xargo/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![feature(compiler_builtins)] - -#![no_std] -#![compiler_builtins] // Don't link to compiler builtins -// Just a dummy From 0530d5225f339af9d17590cb5bbe290960462a52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Dec 2018 17:16:56 +0100 Subject: [PATCH 0408/1566] Disable probestack --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index a1628b8b08db4..3f6f2dabb3e16 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -319,6 +319,7 @@ fn build_isa(sess: &Session) -> Box { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); + flags_builder.set("probestack_enabled", "false").unwrap(); // ___cranelift_probestack is not provided flags_builder.set("enable_verifier", if cfg!(debug_assertions) { "true" } else { From ea2c856319df5e2f089d66623450146d4ce3577f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 18 Dec 2018 06:32:15 +0000 Subject: [PATCH 0409/1566] Bump cranelift from `05b6226` to `328642f` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `05b6226` to `328642f`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/05b62260ac5473914f7536f5393c5c629877aab1...328642ffb2c095c8046ec4f17af1f49fbd9cdc24) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc33cf97d7e17..5981fc16d9a69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,7 +98,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -107,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -137,12 +137,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -176,7 +176,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#05b62260ac5473914f7536f5393c5c629877aab1" +source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From 4f32e703a8289df44e0df1ec4c9760064085efed Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 18 Dec 2018 15:20:24 +0100 Subject: [PATCH 0410/1566] Update Cargo.lock --- Cargo.lock | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5981fc16d9a69..b100c56acdc8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,21 +32,27 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "autocfg" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "backtrace" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", @@ -251,7 +257,7 @@ name = "failure" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -262,7 +268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -512,7 +518,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -561,7 +567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -622,12 +628,12 @@ dependencies = [ "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.22" +version = "0.15.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -642,7 +648,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -779,8 +785,9 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum backtrace 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a2eff3830839471718ef8522b9025b399bfb713e25bc220da721364efb660d7d" -"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" +"checksum autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e5f34df7a019573fb8bdc7e24a2bfebe51a2a1d6bfdbaeccedb3c41fc574727" +"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" +"checksum backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcce89e5ad5c8949caa9434501f7b55415b3e7ad5270cb88c75a8d35e8f1279" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" "checksum cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "389803e36973d242e7fecb092b2de44a3d35ac62524b3b9339e51d577d668e02" @@ -834,7 +841,7 @@ dependencies = [ "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cff177f64744f6f2a2054d231279383e59b0857b4d58dc2e8881e60b58aec8e5" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" +"checksum rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "01b90379b8664dd83460d59bdc5dd1fd3172b8913788db483ed1325171eab2f7" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" @@ -847,7 +854,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" "checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" -"checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" +"checksum syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9545a6a093a3f0bd59adb472700acc08cad3776f860f16a897dfce8c88721cbc" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" "checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" From 6fa3140222b7c475008b0087b8692c3a0523d36c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 18 Dec 2018 18:28:02 +0100 Subject: [PATCH 0411/1566] Introduce CodegenCx --- src/base.rs | 39 ++++++++++++++++++--------------------- src/common.rs | 1 + src/lib.rs | 36 ++++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/base.rs b/src/base.rs index 9d5ab22a7c6b7..24a46ef0a9883 100644 --- a/src/base.rs +++ b/src/base.rs @@ -9,13 +9,11 @@ impl String> Drop for PrintOnPanic { } } -pub fn trans_mono_item<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &mut Module, - caches: &mut Caches<'tcx>, - ccx: &mut crate::constant::ConstantCx, +pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( + cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, mono_item: MonoItem<'tcx>, ) { + let tcx = cx.tcx; match mono_item { MonoItem::Fn(inst) => { let _inst_guard = @@ -44,10 +42,10 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } }); - trans_fn(tcx, module, ccx, caches, inst); + trans_fn(cx, inst); } MonoItem::Static(def_id) => { - crate::constant::codegen_static(ccx, def_id); + crate::constant::codegen_static(&mut cx.ccx, def_id); } MonoItem::GlobalAsm(node_id) => tcx .sess @@ -55,19 +53,18 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( } } -fn trans_fn<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &mut Module, - constants: &mut crate::constant::ConstantCx, - caches: &mut Caches<'tcx>, +fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( + cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, instance: Instance<'tcx>, ) { + let tcx = cx.tcx; + // Step 1. Get mir let mir = tcx.instance_mir(instance.def); // Step 2. Declare function let (name, sig) = get_function_name_and_sig(tcx, instance); - let func_id = module + let func_id = cx.module .declare_function(&name, Linkage::Export, &sig) .unwrap(); @@ -84,10 +81,10 @@ fn trans_fn<'a, 'tcx: 'a>( } // Step 5. Make FunctionCx - let pointer_type = module.target_config().pointer_type(); + let pointer_type = cx.module.target_config().pointer_type(); let mut fx = FunctionCx { tcx, - module, + module: cx.module, pointer_type, instance, @@ -98,8 +95,8 @@ fn trans_fn<'a, 'tcx: 'a>( local_map: HashMap::new(), comments: HashMap::new(), - constants, - caches, + constants: &mut cx.ccx, + caches: &mut cx.caches, top_nop: None, }; @@ -132,11 +129,11 @@ fn trans_fn<'a, 'tcx: 'a>( verify_func(tcx, writer, &func); // Step 9. Define function - caches.context.func = func; - module - .define_function(func_id, &mut caches.context) + cx.caches.context.func = func; + cx.module + .define_function(func_id, &mut cx.caches.context) .unwrap(); - caches.context.clear(); + cx.caches.context.clear(); } fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Function) { diff --git a/src/common.rs b/src/common.rs index 1890caaf830a5..29d6522f23dd9 100644 --- a/src/common.rs +++ b/src/common.rs @@ -611,6 +611,7 @@ pub fn clif_intcast<'a, 'tcx: 'a>( } pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { + // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` pub tcx: TyCtxt<'a, 'tcx, 'tcx>, pub module: &'a mut Module, pub pointer_type: Type, // Cached from module diff --git a/src/lib.rs b/src/lib.rs index 3f6f2dabb3e16..ec916449d57fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,7 +97,7 @@ mod prelude { pub use crate::common::*; pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; - pub use crate::Caches; + pub use crate::{Caches, CodegenCx}; } pub struct Caches<'tcx> { @@ -105,8 +105,8 @@ pub struct Caches<'tcx> { pub vtables: HashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), DataId>, } -impl<'tcx> Caches<'tcx> { - fn new() -> Self { +impl<'tcx> Default for Caches<'tcx> { + fn default() -> Self { Caches { context: Context::new(), vtables: HashMap::new(), @@ -114,6 +114,28 @@ impl<'tcx> Caches<'tcx> { } } +pub struct CodegenCx<'a, 'clif, 'tcx, B: Backend + 'static> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &'clif mut Module, + ccx: ConstantCx, + caches: Caches<'tcx>, +} + +impl<'a, 'clif, 'tcx, B: Backend + 'static> CodegenCx<'a, 'clif, 'tcx, B> { + fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &'clif mut Module) -> Self { + CodegenCx { + tcx, + module, + ccx: ConstantCx::default(), + caches: Caches::default(), + } + } + + fn finalize(self) { + self.ccx.finalize(self.tcx, self.module); + } +} + struct CraneliftCodegenBackend; impl CodegenBackend for CraneliftCodegenBackend { @@ -369,17 +391,15 @@ fn codegen_mono_items<'a, 'tcx: 'a>( log: &mut Option, mono_items: FxHashMap, (RLinkage, Visibility)>, ) { + let mut cx = CodegenCx::new(tcx, module); time("codegen mono items", move || { - let mut caches = Caches::new(); - let mut ccx = ConstantCx::default(); - for (mono_item, (_linkage, _vis)) in mono_items { unimpl::try_unimpl(tcx, log, || { - base::trans_mono_item(tcx, module, &mut caches, &mut ccx, mono_item); + base::trans_mono_item(&mut cx, mono_item); }); } - ccx.finalize(tcx, module); + cx.finalize(); }); } From 1ec65937d6e4d6d055c3b9831f2648b594677b04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 19 Dec 2018 06:37:50 +0000 Subject: [PATCH 0412/1566] Bump cc from 1.0.26 to 1.0.27 Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.26 to 1.0.27. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.26...1.0.27) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b100c56acdc8e..dd19276711414 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ name = "backtrace-sys" version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -71,7 +71,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -460,7 +460,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -790,7 +790,7 @@ dependencies = [ "checksum backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcce89e5ad5c8949caa9434501f7b55415b3e7ad5270cb88c75a8d35e8f1279" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum cc 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "389803e36973d242e7fecb092b2de44a3d35ac62524b3b9339e51d577d668e02" +"checksum cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "155ed195f7bd722d1dfeb30365b9d0c1f6a078fa7ca4014497e5935d90993d6f" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" From 02b32f117dbfe9b7fcd55c518f3f6a93f268d28e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 20 Dec 2018 05:26:18 +0000 Subject: [PATCH 0413/1566] Bump heck from 0.3.0 to 0.3.1 Bumps [heck](https://github.com/withoutboats/heck) from 0.3.0 to 0.3.1. - [Release notes](https://github.com/withoutboats/heck/releases) - [Commits](https://github.com/withoutboats/heck/commits) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd19276711414..35158e3ef95b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,7 +303,7 @@ dependencies = [ [[package]] name = "heck" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -625,7 +625,7 @@ name = "structopt-derive" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", @@ -814,7 +814,7 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" -"checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" +"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" From d94fe1d717dd3a6e1b9c0da1d4788dafb6695c9d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 20 Dec 2018 14:57:21 +0100 Subject: [PATCH 0414/1566] Fix calling drop_in_place_real with empty drop glue fixes #209 --- src/abi.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index c9559a6068913..d07067930812d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -484,11 +484,26 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( .map(|&(ref place, bb)| (trans_place(fx, place), bb)); if let ty::FnDef(def_id, substs) = fn_ty.sty { - let sig = ty_fn_sig(fx.tcx, fn_ty); - - if sig.abi == Abi::RustIntrinsic { - crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination); - return; + let instance = ty::Instance::resolve( + fx.tcx, + ty::ParamEnv::reveal_all(), + def_id, + substs, + ).unwrap(); + + match instance.def { + InstanceDef::Intrinsic(_) => { + crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination); + return; + } + InstanceDef::DropGlue(_, None) => { + // empty drop glue - a nop. + let (_, dest) = destination.expect("Non terminating drop_in_place_real???"); + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + return; + } + _ => {} } } From 64d42573876407db4fa466bacf99fde85668fccf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 21 Dec 2018 13:45:06 +0100 Subject: [PATCH 0415/1566] Rustup to rustc 1.33.0-nightly (09d6ab90e 2018-12-20) --- src/base.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 24a46ef0a9883..ed04880f2edfd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -655,8 +655,7 @@ fn trans_stmt<'a, 'tcx: 'a>( | StatementKind::Nop | StatementKind::FakeRead(..) | StatementKind::Retag { .. } - | StatementKind::AscribeUserType(..) - | StatementKind::EscapeToRaw(..) => {} + | StatementKind::AscribeUserType(..) => {} StatementKind::InlineAsm { .. } => unimpl!("Inline assembly is not supported"), } From 6e5d9abe9cd0aba8e1c97528d4d91732f63dc58e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Dec 2018 10:54:38 +0100 Subject: [PATCH 0416/1566] Rustup to rustc 1.33.0-nightly (e40548bc4 2018-12-21) --- build_sysroot/compiler_builtins/lib.rs | 8 +++++++- patches/0007-Fix-libstd-building.patch | 28 +++++++++----------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/build_sysroot/compiler_builtins/lib.rs b/build_sysroot/compiler_builtins/lib.rs index 90a118deeef75..79a54a3a4b897 100644 --- a/build_sysroot/compiler_builtins/lib.rs +++ b/build_sysroot/compiler_builtins/lib.rs @@ -1,3 +1,9 @@ -#![feature(compiler_builtins)] +#![feature(compiler_builtins, staged_api)] #![compiler_builtins] #![no_std] + +#![unstable( + feature = "compiler_builtins_lib", + reason = "Compiler builtins. Will never become stable.", + issue = "0" +)] diff --git a/patches/0007-Fix-libstd-building.patch b/patches/0007-Fix-libstd-building.patch index ca566deba85e8..398a2b60ed16f 100644 --- a/patches/0007-Fix-libstd-building.patch +++ b/patches/0007-Fix-libstd-building.patch @@ -15,14 +15,7 @@ diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index f3965f3..13e17b1 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -249,14 +249,12 @@ - #![feature(cfg_target_thread_local)] - #![feature(cfg_target_vendor)] - #![feature(char_error_internals)] --#![feature(compiler_builtins_lib)] - #![feature(const_int_ops)] - #![feature(const_ip)] - #![feature(const_raw_ptr_deref)] +@@ -256,7 +256,6 @@ #![feature(const_cstr_unchecked)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] @@ -47,7 +40,7 @@ index f3965f3..13e17b1 100644 -pub use core::u128; #[stable(feature = "core_hint", since = "1.27.0")] pub use core::hint; - + diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 8685cb7..c4bf4d2 100644 --- a/src/libstd/net/ip.rs @@ -55,7 +48,7 @@ index 8685cb7..c4bf4d2 100644 @@ -1392,26 +1392,6 @@ impl FromInner for Ipv6Addr { } } - + -#[stable(feature = "i128", since = "1.26.0")] -impl From for u128 { - fn from(ip: Ipv6Addr) -> u128 { @@ -85,11 +78,11 @@ index 3f90c1f..85aab83 100644 +++ b/src/libstd/num.rs @@ -22,7 +22,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} pub use core::num::Wrapping; - + #[stable(feature = "nonzero", since = "1.28.0")] -pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; +pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; - + #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs @@ -103,7 +96,7 @@ index 3eacc7a..b518448 100644 -#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicI128 {} - + #[cfg(target_has_atomic = "ptr")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] @@ -283,9 +280,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {} @@ -113,7 +106,7 @@ index 3eacc7a..b518448 100644 -#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicU128 {} - + #[cfg(target_has_atomic = "8")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs @@ -123,7 +116,7 @@ index 7c1654f..cc96271 100644 @@ -808,14 +808,6 @@ mod prim_i32 { } #[stable(feature = "rust1", since = "1.0.0")] mod prim_i64 { } - + -#[doc(primitive = "i128")] -// -/// The 128-bit signed integer type. @@ -138,7 +131,7 @@ index 7c1654f..cc96271 100644 @@ -848,14 +840,6 @@ mod prim_u32 { } #[stable(feature = "rust1", since = "1.0.0")] mod prim_u64 { } - + -#[doc(primitive = "u128")] -// -/// The 128-bit unsigned integer type. @@ -150,6 +143,5 @@ index 7c1654f..cc96271 100644 #[doc(primitive = "isize")] // /// The pointer-sized signed integer type. --- +-- 2.17.2 (Apple Git-113) - From 988257649752a4b41a819ca415df363893f300be Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 21 Dec 2018 21:42:29 +0100 Subject: [PATCH 0417/1566] Improve debug messages in generated clif files --- src/abi.rs | 5 ++-- src/base.rs | 25 ++++------------ src/common.rs | 8 ++--- src/pretty_clif.rs | 73 ++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 77 insertions(+), 34 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index d07067930812d..1c589e679f840 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -70,7 +70,7 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( } } -pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( +fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<'tcx>, ) -> Signature { @@ -129,7 +129,7 @@ pub fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( } } -fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<'tcx> { +pub fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<'tcx> { let sig = match ty.sty { ty::FnDef(..) | // Shims currently have type TyFnPtr. Not sure this should remain. @@ -329,7 +329,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.bcx.switch_to_block(start_ebb); - fx.top_nop = Some(fx.bcx.ins().nop()); fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); for local in fx.mir.args_iter() { diff --git a/src/base.rs b/src/base.rs index ed04880f2edfd..46e47b99224d0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -82,6 +82,8 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 5. Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); + let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance); + let mut fx = FunctionCx { tcx, module: cx.module, @@ -94,11 +96,9 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( ebb_map, local_map: HashMap::new(), - comments: HashMap::new(), + clif_comments, constants: &mut cx.ccx, caches: &mut cx.caches, - - top_nop: None, }; // Step 6. Codegen function @@ -108,25 +108,12 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( }); // Step 7. Write function to file for debugging - let mut writer = crate::pretty_clif::CommentWriter(fx.comments); - - let mut clif = String::new(); if cfg!(debug_assertions) { - ::cranelift::codegen::write::decorate_function(&mut writer, &mut clif, &func, None) - .unwrap(); - let clif_file_name = format!( - "{}/{}__{}.clif", - concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), - tcx.crate_name(LOCAL_CRATE), - tcx.symbol_name(instance).as_str(), - ); - if let Err(e) = ::std::fs::write(clif_file_name, clif.as_bytes()) { - tcx.sess.warn(&format!("err writing clif file: {:?}", e)); - } + fx.write_clif_file(); } // Step 8. Verify function - verify_func(tcx, writer, &func); + verify_func(tcx, fx.clif_comments, &func); // Step 9. Define function cx.caches.context.func = func; @@ -145,7 +132,7 @@ fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Fu let pretty_error = ::cranelift::codegen::print_errors::pretty_verifier_error( &func, None, - Some(Box::new(writer)), + Some(Box::new(&writer)), err, ); tcx.sess diff --git a/src/common.rs b/src/common.rs index 29d6522f23dd9..62e4af90054ac 100644 --- a/src/common.rs +++ b/src/common.rs @@ -623,12 +623,9 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { pub ebb_map: HashMap, pub local_map: HashMap>, - pub comments: HashMap, + pub clif_comments: crate::pretty_clif::CommentWriter, pub constants: &'a mut crate::constant::ConstantCx, pub caches: &'a mut Caches<'tcx>, - - /// add_global_comment inserts a comment here - pub top_nop: Option, } impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { @@ -637,9 +634,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { writeln!(f, "{:?}", self.local_map)?; let mut clif = String::new(); - let mut writer = crate::pretty_clif::CommentWriter(self.comments.clone()); ::cranelift::codegen::write::decorate_function( - &mut writer, + &mut &self.clif_comments, &mut clif, &self.bcx.func, None, diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index efaf200fa1a45..0254090a2c67b 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -7,15 +7,47 @@ use cranelift::codegen::write::{FuncWriter, PlainWriter}; use crate::prelude::*; -pub struct CommentWriter(pub HashMap); +#[derive(Debug)] +pub struct CommentWriter { + global_comments: Vec, + inst_comments: HashMap +} + +impl CommentWriter { + pub fn new<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + instance: Instance<'tcx>, + ) -> Self { + CommentWriter { + global_comments: vec![ + format!("symbol {}", tcx.symbol_name(instance).as_str()), + format!("instance {:?}", instance), + format!("sig {:?}", crate::abi::ty_fn_sig(tcx, instance.ty(tcx))), + String::new(), + ], + inst_comments: HashMap::new(), + } + } +} -impl FuncWriter for CommentWriter { +impl<'a> FuncWriter for &'a CommentWriter { fn write_preamble( &mut self, w: &mut dyn fmt::Write, func: &Function, reg_info: Option<&isa::RegInfo>, ) -> Result { + for comment in &self.global_comments { + if !comment.is_empty() { + writeln!(w, "; {}", comment)?; + } else { + writeln!(w, "")?; + } + } + if !self.global_comments.is_empty() { + writeln!(w, "")?; + } + PlainWriter.write_preamble(w, func, reg_info) } @@ -40,7 +72,7 @@ impl FuncWriter for CommentWriter { indent: usize, ) -> fmt::Result { PlainWriter.write_instruction(w, func, aliases, isa, inst, indent)?; - if let Some(comment) = self.0.get(&inst) { + if let Some(comment) = self.inst_comments.get(&inst) { writeln!(w, "; {}", comment.replace('\n', "\n; "))?; } Ok(()) @@ -48,13 +80,13 @@ impl FuncWriter for CommentWriter { } impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { - pub fn add_global_comment<'s, S: Into>>(&mut self, comment: S) { - self.add_comment(self.top_nop.expect("fx.top_nop not yet set"), comment) + pub fn add_global_comment>(&mut self, comment: S) { + self.clif_comments.global_comments.push(comment.into()); } pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { use std::collections::hash_map::Entry; - match self.comments.entry(inst) { + match self.clif_comments.inst_comments.entry(inst) { Entry::Occupied(mut occ) => { occ.get_mut().push('\n'); occ.get_mut().push_str(comment.into().as_ref()); @@ -64,4 +96,33 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } } } + + pub fn write_clif_file(&mut self) { + use std::io::Write; + + let symbol_name = self.tcx.symbol_name(self.instance).as_str(); + let clif_file_name = format!( + "{}/{}__{}.clif", + concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), + self.tcx.crate_name(LOCAL_CRATE), + symbol_name, + ); + + let mut clif = String::new(); + ::cranelift::codegen::write::decorate_function(&mut &self.clif_comments, &mut clif, &self.bcx.func, None) + .unwrap(); + + match ::std::fs::File::create(clif_file_name) { + Ok(mut file) => { + let target_triple: ::target_lexicon::Triple = self.tcx.sess.target.target.llvm_target.parse().unwrap(); + writeln!(file, "test compile").unwrap(); + writeln!(file, "target {}", target_triple.architecture).unwrap(); + writeln!(file, "").unwrap(); + file.write(clif.as_bytes()).unwrap(); + } + Err(e) => { + self.tcx.sess.warn(&format!("err opening clif file: {:?}", e)); + } + } + } } From 0b4ede39e50aab5f8f262ddd5a821ae699cbd179 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Dec 2018 17:42:38 +0100 Subject: [PATCH 0418/1566] Add pretty param and local info comments to clif --- example/example.rs | 44 ++++++++++++++++----------------- src/abi.rs | 61 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 77 insertions(+), 28 deletions(-) diff --git a/example/example.rs b/example/example.rs index eebc8c126e9b6..220554550f179 100644 --- a/example/example.rs +++ b/example/example.rs @@ -18,7 +18,6 @@ fn bcd(b: bool, a: u8) -> u8 { } } -// FIXME make calls work fn call() { abc(42); } @@ -33,14 +32,12 @@ enum BoolOption { None, } -/* fn option_unwrap_or(o: BoolOption, d: bool) -> bool { match o { BoolOption::Some(b) => b, BoolOption::None => d, } } -*/ fn ret_42() -> u8 { 42 @@ -62,18 +59,18 @@ fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { a == b } -/*fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { +fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { ( a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, b as u32, ) -}*/ +} fn char_cast(c: char) -> u8 { c as u8 } -struct DebugTuple(()); +pub struct DebugTuple(()); fn debug_tuple() -> DebugTuple { DebugTuple(()) @@ -87,14 +84,14 @@ fn use_size_of() -> usize { size_of::() } -/*unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { +unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { intrinsics::copy::(src, dst, 1); -}*/ +} -/*unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { - let copy2 = ©::; +unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { + let copy2 = &intrinsics::copy::; copy2(src, dst, 1); -}*/ +} const Abc: u8 = 6 * 7; @@ -102,32 +99,36 @@ fn use_const() -> u8 { Abc } -fn call_closure_3arg() { +pub fn call_closure_3arg() { (|_, _, _| {})(0u8, 42u16, 0u8) } -fn call_closure_2arg() { +pub fn call_closure_2arg() { (|_, _| {})(0u8, 42u16) } struct IsNotEmpty; impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty { - type Output = bool; + type Output = (u8, u8); #[inline] - extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> bool { + extern "rust-call" fn call_once(mut self, arg: (&'a &'b [u16],)) -> (u8, u8) { self.call_mut(arg) } } impl<'a, 'b> FnMut<(&'a &'b [u16],)> for IsNotEmpty { #[inline] - extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16],)) -> bool { - true + extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16],)) -> (u8, u8) { + (0, 42) } } +pub fn call_is_not_empty() { + IsNotEmpty.call_once((&(&[0u16] as &[_]),)); +} + fn eq_char(a: char, b: char) -> bool { a == b } @@ -140,7 +141,6 @@ unsafe fn call_uninit() -> u8 { intrinsics::uninit() } -// TODO: enable when fat pointers are supported unsafe fn deref_str_ptr(s: *const str) -> &'static str { &*s } @@ -157,9 +157,9 @@ fn array_as_slice(arr: &[u8; 3]) -> &[u8] { arr } -/*unsafe fn use_ctlz_nonzero(a: u16) -> u16 { +unsafe fn use_ctlz_nonzero(a: u16) -> u16 { intrinsics::ctlz_nonzero(a) -}*/ +} fn ptr_as_usize(ptr: *const u8) -> usize { ptr as usize @@ -169,9 +169,9 @@ fn float_cast(a: f32, b: f64) -> (f64, f32) { (a as f64, b as f32) } -/*fn int_to_float(a: u8, b: i32) -> (f64, f32) { +fn int_to_float(a: u8, b: i32) -> (f64, f32) { (a as f64, b as f32) -}*/ +} fn make_array() -> [u8; 3] { [42, 0, 5] diff --git a/src/abi.rs b/src/abi.rs index 1c589e679f840..ae4eb7b1c9879 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow; use std::iter; use rustc::hir; @@ -270,6 +271,41 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } } +fn add_local_comment<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + msg: &str, + local: mir::Local, + local_field: Option, + param: Option, + pass_mode: Option, + ssa: crate::analyze::Flags, + ty: Ty<'tcx>, +) { + let local_field = if let Some(local_field) = local_field { + Cow::Owned(format!(".{}", local_field)) + } else { + Cow::Borrowed("") + }; + let param = if let Some(param) = param { + Cow::Owned(format!("= {:?}", param)) + } else { + Cow::Borrowed("-") + }; + let pass_mode = if let Some(pass_mode) = pass_mode { + Cow::Owned(format!("{:?}", pass_mode)) + } else { + Cow::Borrowed("-") + }; + fx.add_global_comment(format!( + "{msg:5} {local:>3}{local_field:<5} {param:10} {pass_mode:20} {ssa:10} {ty:?}", + msg=msg, local=format!("{:?}", local), local_field=local_field, param=param, pass_mode=pass_mode, ssa=format!("{:?}", ssa), ty=ty, + )); +} + +fn add_local_header_comment(fx: &mut FunctionCx) { + fx.add_global_comment(format!("msg loc.idx param pass mode ssa flags ty")); +} + pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, start_ebb: Ebb, @@ -331,12 +367,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); - for local in fx.mir.args_iter() { - let arg_ty = fx.monomorphize(&fx.mir.local_decls[local].ty); - let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false); - fx.add_global_comment(format!("pass {:?}: {:?} {:?}", local, arg_ty, pass_mode)); - } - match output_pass_mode { PassMode::NoPass => { let null = fx.bcx.ins().iconst(fx.pointer_type, 0); @@ -359,9 +389,26 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( } } + add_local_header_comment(fx); + add_local_comment(fx, "ret", RETURN_PLACE, None, ret_param, Some(output_pass_mode), ssa_analyzed[&RETURN_PLACE], ret_layout.ty); + for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); + match arg_kind { + ArgKind::Normal(ebb_param) => { + let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false); + add_local_comment(fx, "arg", local, None, Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], ty); + } + ArgKind::Spread(ref ebb_params) => { + for (i, &ebb_param) in ebb_params.iter().enumerate() { + let sub_layout = layout.field(fx, i); + let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, sub_layout.ty, false); + add_local_comment(fx, "arg", local, Some(i), Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], sub_layout.ty); + } + } + } + if let ArgKind::Normal(ebb_param) = arg_kind { if !ssa_analyzed .get(&local) @@ -422,6 +469,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let ty = fx.mir.local_decls[local].ty; let layout = fx.layout_of(ty); + add_local_comment(fx, "local", local, None, None, None, ssa_analyzed[&local], ty); + let place = if ssa_analyzed .get(&local) .unwrap() From 3d05ff922c62c581d6b5415ada478cdf76ccd0a0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 23 Dec 2018 19:11:17 +0100 Subject: [PATCH 0419/1566] Use the linkage and visibility produced by tcx.collect_and_partition_mono_itemscc #209 --- src/base.rs | 6 ++++-- src/lib.rs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index 46e47b99224d0..b3c87258a34e9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -12,6 +12,7 @@ impl String> Drop for PrintOnPanic { pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, mono_item: MonoItem<'tcx>, + linkage: Linkage, ) { let tcx = cx.tcx; match mono_item { @@ -42,7 +43,7 @@ pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( } }); - trans_fn(cx, inst); + trans_fn(cx, inst, linkage); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.ccx, def_id); @@ -56,6 +57,7 @@ pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, instance: Instance<'tcx>, + linkage: Linkage, ) { let tcx = cx.tcx; @@ -65,7 +67,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 2. Declare function let (name, sig) = get_function_name_and_sig(tcx, instance); let func_id = cx.module - .declare_function(&name, Linkage::Export, &sig) + .declare_function(&name, linkage, &sig) .unwrap(); // Step 3. Make FunctionBuilder diff --git a/src/lib.rs b/src/lib.rs index ec916449d57fb..8cbd597fd59be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -393,9 +393,17 @@ fn codegen_mono_items<'a, 'tcx: 'a>( ) { let mut cx = CodegenCx::new(tcx, module); time("codegen mono items", move || { - for (mono_item, (_linkage, _vis)) in mono_items { + for (mono_item, (linkage, vis)) in mono_items { unimpl::try_unimpl(tcx, log, || { - base::trans_mono_item(&mut cx, mono_item); + let linkage = match (linkage, vis) { + (RLinkage::External, Visibility::Default) => Linkage::Export, + (RLinkage::Internal, Visibility::Default) => Linkage::Local, + // FIXME this should get external linkage, but hidden visibility, + // not internal linkage and default visibility + | (RLinkage::External, Visibility::Hidden) => Linkage::Local, + _ => panic!("{:?} = {:?} {:?}", mono_item, linkage, vis), + }; + base::trans_mono_item(&mut cx, mono_item, linkage); }); } From 7ea7d021ca539241ad00dc7b481820f3b923a9ea Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 24 Dec 2018 14:50:18 +0100 Subject: [PATCH 0420/1566] Rustup to rustc 1.33.0-nightly (ddab10a69 2018-12-23) --- example/mini_core.rs | 7 +++++++ src/constant.rs | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 83dd4f10f5e95..24429555a5fd7 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -27,6 +27,13 @@ impl, U: ?Sized> DispatchFromDyn<*const U> for *const T {} // *mut T -> *mut U impl, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {} +#[lang = "receiver"] +pub trait Receiver {} + +impl Receiver for &T {} +impl Receiver for &mut T {} +impl Receiver for Box {} + #[lang = "copy"] pub unsafe trait Copy {} diff --git a/src/constant.rs b/src/constant.rs index 366b06a127660..1b3cd0c0b3609 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -150,7 +150,7 @@ fn trans_const_place<'a, 'tcx: 'a>( })), None, )?; - let ptr = ecx.allocate(op.layout, MemoryKind::Stack)?; + let ptr = ecx.allocate(op.layout, MemoryKind::Stack); ecx.copy_op(op, ptr.into())?; let alloc = ecx.memory().get(ptr.to_ptr()?.alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) @@ -372,8 +372,8 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { _: &mut EvalContext<'a, 'mir, 'tcx, Self>, ptr: Pointer, _: MemoryKind, - ) -> EvalResult<'tcx, Pointer> { - Ok(ptr) + ) -> Pointer { + ptr } fn stack_push(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx>{ From 7f449578e46009bb9f36f156021cd1c35ff49c77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 24 Dec 2018 14:14:13 +0000 Subject: [PATCH 0421/1566] Bump cc from 1.0.27 to 1.0.28 Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.27 to 1.0.28. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.27...1.0.28) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35158e3ef95b1..46856746d02f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,7 +55,7 @@ name = "backtrace-sys" version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -71,7 +71,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -460,7 +460,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -790,7 +790,7 @@ dependencies = [ "checksum backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcce89e5ad5c8949caa9434501f7b55415b3e7ad5270cb88c75a8d35e8f1279" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" -"checksum cc 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "155ed195f7bd722d1dfeb30365b9d0c1f6a078fa7ca4014497e5935d90993d6f" +"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" From e78a3766a96b9eef7a740baab795f413db2deada Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 24 Dec 2018 14:44:05 +0000 Subject: [PATCH 0422/1566] Bump backtrace-sys from 0.1.26 to 0.1.28 Bumps [backtrace-sys](https://github.com/alexcrichton/backtrace-rs) from 0.1.26 to 0.1.28. - [Release notes](https://github.com/alexcrichton/backtrace-rs/releases) - [Commits](https://github.com/alexcrichton/backtrace-rs/compare/backtrace-sys-0.1.26...backtrace-sys-0.1.28) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46856746d02f5..65fbf51ed8968 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.26" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", @@ -787,7 +787,7 @@ dependencies = [ "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e5f34df7a019573fb8bdc7e24a2bfebe51a2a1d6bfdbaeccedb3c41fc574727" "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" -"checksum backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcce89e5ad5c8949caa9434501f7b55415b3e7ad5270cb88c75a8d35e8f1279" +"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" "checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" From 2c25b29c9cabefa319e05d9797e3a98f301a4e08 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 25 Dec 2018 16:47:33 +0100 Subject: [PATCH 0423/1566] Simplify argument storage --- src/abi.rs | 119 ++++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 66 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index ae4eb7b1c9879..dcc33a6abfd61 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -6,7 +6,7 @@ use rustc_target::spec::abi::Abi; use crate::prelude::*; -#[derive(Debug)] +#[derive(Copy, Clone, Debug)] enum PassMode { NoPass, ByVal(Type), @@ -306,6 +306,37 @@ fn add_local_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(format!("msg loc.idx param pass mode ssa flags ty")); } +fn arg_place<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + local: Local, + layout: TyLayout<'tcx>, + is_ssa: bool, +) -> CPlace<'tcx> { + let place = if is_ssa { + fx.bcx.declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); + CPlace::Var(local, layout) + } else { + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + + CPlace::from_stack_slot(fx, stack_slot, layout.ty) + }; + + debug_assert!(fx.local_map.insert(local, place).is_none()); + fx.local_map[&local] +} + +fn param_to_cvalue<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, ebb_param: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + match get_pass_mode(fx.tcx, fx.self_sig().abi, layout.ty, false) { + PassMode::NoPass => unimplemented!("pass mode nopass"), + PassMode::ByVal(_) => CValue::ByVal(ebb_param, layout), + PassMode::ByRef => CValue::ByRef(ebb_param, layout), + } +} + pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, start_ebb: Ebb, @@ -344,19 +375,24 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( }; let mut ebb_params = Vec::new(); - for arg_ty in tupled_arg_tys.iter() { - let clif_type = - get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); - ebb_params.push(fx.bcx.append_ebb_param(start_ebb, clif_type)); + for (i, arg_ty) in tupled_arg_tys.iter().enumerate() { + let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false);; + let clif_type = pass_mode.get_param_ty(fx); + let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); + add_local_comment(fx, "arg", local, Some(i), Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], arg_ty); + ebb_params.push(ebb_param); } (local, ArgKind::Spread(ebb_params), arg_ty) } else { let clif_type = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); + let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); + let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false); + add_local_comment(fx, "arg", local, None, Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], arg_ty); ( local, - ArgKind::Normal(fx.bcx.append_ebb_param(start_ebb, clif_type)), + ArgKind::Normal(ebb_param), arg_ty, ) } @@ -370,7 +406,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( match output_pass_mode { PassMode::NoPass => { let null = fx.bcx.ins().iconst(fx.pointer_type, 0); - //unimplemented!("pass mode nopass"); fx.local_map.insert( RETURN_PLACE, CPlace::Addr(null, None, fx.layout_of(fx.return_type())), @@ -395,74 +430,26 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); + let is_ssa = !ssa_analyzed + .get(&local) + .unwrap() + .contains(crate::analyze::Flags::NOT_SSA); + match arg_kind { ArgKind::Normal(ebb_param) => { - let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false); - add_local_comment(fx, "arg", local, None, Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], ty); + let cvalue = param_to_cvalue(fx, ebb_param, layout); + arg_place(fx, local, layout, is_ssa).write_cvalue(fx, cvalue); } - ArgKind::Spread(ref ebb_params) => { - for (i, &ebb_param) in ebb_params.iter().enumerate() { - let sub_layout = layout.field(fx, i); - let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, sub_layout.ty, false); - add_local_comment(fx, "arg", local, Some(i), Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], sub_layout.ty); - } - } - } - - if let ArgKind::Normal(ebb_param) = arg_kind { - if !ssa_analyzed - .get(&local) - .unwrap() - .contains(crate::analyze::Flags::NOT_SSA) - { - fx.bcx - .declare_var(mir_var(local), fx.clif_type(ty).unwrap()); - match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => fx.bcx.def_var(mir_var(local), ebb_param), - PassMode::ByRef => { - let val = CValue::ByRef(ebb_param, fx.layout_of(ty)).load_value(fx); - fx.bcx.def_var(mir_var(local), val); - } - } - fx.local_map.insert(local, CPlace::Var(local, layout)); - continue; - } - } - - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - - let place = CPlace::from_stack_slot(fx, stack_slot, ty); - - match arg_kind { - ArgKind::Normal(ebb_param) => match get_pass_mode(fx.tcx, fx.self_sig().abi, ty, false) - { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => { - place.write_cvalue(fx, CValue::ByVal(ebb_param, place.layout())) - } - PassMode::ByRef => place.write_cvalue(fx, CValue::ByRef(ebb_param, place.layout())), - }, ArgKind::Spread(ebb_params) => { + let place = arg_place(fx, local, layout, is_ssa); + for (i, ebb_param) in ebb_params.into_iter().enumerate() { let sub_place = place.place_field(fx, mir::Field::new(i)); - match get_pass_mode(fx.tcx, fx.self_sig().abi, sub_place.layout().ty, false) { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => { - sub_place.write_cvalue(fx, CValue::ByVal(ebb_param, sub_place.layout())) - } - PassMode::ByRef => { - sub_place.write_cvalue(fx, CValue::ByRef(ebb_param, sub_place.layout())) - } - } + let cvalue = param_to_cvalue(fx, ebb_param, sub_place.layout()); + sub_place.write_cvalue(fx, cvalue); } } } - fx.local_map.insert(local, place); } for local in fx.mir.vars_and_temps_iter() { From 3c755858b92ce81169bdb54499d7a063cfb0262e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 26 Dec 2018 05:57:00 +0000 Subject: [PATCH 0424/1566] Bump cranelift from `328642f` to `9055dd1` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `328642f` to `9055dd1`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/328642ffb2c095c8046ec4f17af1f49fbd9cdc24...9055dd16ce925e95756d84a59b232e80d6efdb5f) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65fbf51ed8968..6341a9ebac5cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#328642ffb2c095c8046ec4f17af1f49fbd9cdc24" +source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From af78c9a10e0b90b60ce9738134f6b650c8832704 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 26 Dec 2018 11:15:42 +0100 Subject: [PATCH 0425/1566] Reduce duplication in abi.rs a bit --- src/abi.rs | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index dcc33a6abfd61..d3b2df8c73ffb 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -306,7 +306,7 @@ fn add_local_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(format!("msg loc.idx param pass mode ssa flags ty")); } -fn arg_place<'a, 'tcx: 'a>( +fn local_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, local: Local, layout: TyLayout<'tcx>, @@ -342,6 +342,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( start_ebb: Ebb, ) { let ssa_analyzed = crate::analyze::analyze(fx); + fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); let ret_layout = fx.layout_of(fx.return_type()); let output_pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true); @@ -401,8 +402,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.bcx.switch_to_block(start_ebb); - fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); - match output_pass_mode { PassMode::NoPass => { let null = fx.bcx.ins().iconst(fx.pointer_type, 0); @@ -435,14 +434,14 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( .unwrap() .contains(crate::analyze::Flags::NOT_SSA); + let place = local_place(fx, local, layout, is_ssa); + match arg_kind { ArgKind::Normal(ebb_param) => { let cvalue = param_to_cvalue(fx, ebb_param, layout); - arg_place(fx, local, layout, is_ssa).write_cvalue(fx, cvalue); + place.write_cvalue(fx, cvalue); } ArgKind::Spread(ebb_params) => { - let place = arg_place(fx, local, layout, is_ssa); - for (i, ebb_param) in ebb_params.into_iter().enumerate() { let sub_place = place.place_field(fx, mir::Field::new(i)); let cvalue = param_to_cvalue(fx, ebb_param, sub_place.layout()); @@ -458,24 +457,12 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( add_local_comment(fx, "local", local, None, None, None, ssa_analyzed[&local], ty); - let place = if ssa_analyzed + let is_ssa = !ssa_analyzed .get(&local) .unwrap() - .contains(crate::analyze::Flags::NOT_SSA) - { - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - CPlace::from_stack_slot(fx, stack_slot, ty) - } else { - fx.bcx - .declare_var(mir_var(local), fx.clif_type(ty).unwrap()); - CPlace::Var(local, layout) - }; + .contains(crate::analyze::Flags::NOT_SSA); - fx.local_map.insert(local, place); + local_place(fx, local, layout, is_ssa); } fx.bcx From 00dbbecf831d89d86989abe560518b94e6b039ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 27 Dec 2018 06:37:20 +0000 Subject: [PATCH 0426/1566] Bump cranelift from `9055dd1` to `c87da1a` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `9055dd1` to `c87da1a`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/9055dd16ce925e95756d84a59b232e80d6efdb5f...c87da1a42e3da7a403ee78c1bafd239f07f3da5a) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6341a9ebac5cd..e3a4fce4ed102 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#9055dd16ce925e95756d84a59b232e80d6efdb5f" +source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From 3e40f150d0c2d0c1a60edec304a6395c9b79e4c0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 27 Dec 2018 10:59:01 +0100 Subject: [PATCH 0427/1566] Add some more clif comments --- src/abi.rs | 85 ++++++++++++++++++++++--------------------- src/pretty_clif.rs | 90 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 133 insertions(+), 42 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index d3b2df8c73ffb..5fd7995332ad7 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -197,8 +197,10 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { let func_id = self.get_function_id(inst); - self.module - .declare_func_in_func(func_id, &mut self.bcx.func) + let func_ref = self.module + .declare_func_in_func(func_id, &mut self.bcx.func); + self.add_entity_comment(func_ref, format!("{:?}", inst)); + func_ref } fn lib_call( @@ -271,13 +273,13 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } } -fn add_local_comment<'a, 'tcx: 'a>( +fn add_arg_comment<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, msg: &str, local: mir::Local, local_field: Option, param: Option, - pass_mode: Option, + pass_mode: PassMode, ssa: crate::analyze::Flags, ty: Ty<'tcx>, ) { @@ -291,11 +293,7 @@ fn add_local_comment<'a, 'tcx: 'a>( } else { Cow::Borrowed("-") }; - let pass_mode = if let Some(pass_mode) = pass_mode { - Cow::Owned(format!("{:?}", pass_mode)) - } else { - Cow::Borrowed("-") - }; + let pass_mode = format!("{:?}", pass_mode); fx.add_global_comment(format!( "{msg:5} {local:>3}{local_field:<5} {param:10} {pass_mode:20} {ssa:10} {ty:?}", msg=msg, local=format!("{:?}", local), local_field=local_field, param=param, pass_mode=pass_mode, ssa=format!("{:?}", ssa), ty=ty, @@ -322,6 +320,13 @@ fn local_place<'a, 'tcx: 'a>( offset: None, }); + let TyLayout { ty, details } = layout; + let ty::layout::LayoutDetails { size, align, abi: _, variants: _, fields: _ } = details; + fx.add_entity_comment(stack_slot, format!( + "{:?}: {:?} size={} align={},{}", + local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), + )); + CPlace::from_stack_slot(fx, stack_slot, layout.ty) }; @@ -329,8 +334,20 @@ fn local_place<'a, 'tcx: 'a>( fx.local_map[&local] } -fn param_to_cvalue<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, ebb_param: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - match get_pass_mode(fx.tcx, fx.self_sig().abi, layout.ty, false) { +fn cvalue_for_param<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + start_ebb: Ebb, + local: mir::Local, + local_field: Option, + arg_ty: Ty<'tcx>, + ssa_flags: crate::analyze::Flags, +) -> CValue<'tcx> { + let layout = fx.layout_of(arg_ty); + let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false); + let clif_type = pass_mode.get_param_ty(fx); + let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); + add_arg_comment(fx, "arg", local, local_field, Some(ebb_param), pass_mode, ssa_flags, arg_ty); + match pass_mode { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(_) => CValue::ByVal(ebb_param, layout), PassMode::ByRef => CValue::ByRef(ebb_param, layout), @@ -352,9 +369,12 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, fx.pointer_type)), }; - enum ArgKind { - Normal(Value), - Spread(Vec), + add_local_header_comment(fx); + add_arg_comment(fx, "ret", RETURN_PLACE, None, ret_param, output_pass_mode, ssa_analyzed[&RETURN_PLACE], ret_layout.ty); + + enum ArgKind<'tcx> { + Normal(CValue<'tcx>), + Spread(Vec>), } let func_params = fx @@ -375,25 +395,18 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), }; - let mut ebb_params = Vec::new(); + let mut params = Vec::new(); for (i, arg_ty) in tupled_arg_tys.iter().enumerate() { - let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false);; - let clif_type = pass_mode.get_param_ty(fx); - let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); - add_local_comment(fx, "arg", local, Some(i), Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], arg_ty); - ebb_params.push(ebb_param); + let param = cvalue_for_param(fx, start_ebb, local, Some(i), arg_ty, ssa_analyzed[&local]); + params.push(param); } - (local, ArgKind::Spread(ebb_params), arg_ty) + (local, ArgKind::Spread(params), arg_ty) } else { - let clif_type = - get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false).get_param_ty(fx); - let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); - let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false); - add_local_comment(fx, "arg", local, None, Some(ebb_param), Some(pass_mode), ssa_analyzed[&local], arg_ty); + let param = cvalue_for_param(fx, start_ebb, local, None, arg_ty, ssa_analyzed[&local]); ( local, - ArgKind::Normal(ebb_param), + ArgKind::Normal(param), arg_ty, ) } @@ -423,9 +436,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( } } - add_local_header_comment(fx); - add_local_comment(fx, "ret", RETURN_PLACE, None, ret_param, Some(output_pass_mode), ssa_analyzed[&RETURN_PLACE], ret_layout.ty); - for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); @@ -437,15 +447,12 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let place = local_place(fx, local, layout, is_ssa); match arg_kind { - ArgKind::Normal(ebb_param) => { - let cvalue = param_to_cvalue(fx, ebb_param, layout); - place.write_cvalue(fx, cvalue); + ArgKind::Normal(param) => { + place.write_cvalue(fx, param); } - ArgKind::Spread(ebb_params) => { - for (i, ebb_param) in ebb_params.into_iter().enumerate() { - let sub_place = place.place_field(fx, mir::Field::new(i)); - let cvalue = param_to_cvalue(fx, ebb_param, sub_place.layout()); - sub_place.write_cvalue(fx, cvalue); + ArgKind::Spread(params) => { + for (i, param) in params.into_iter().enumerate() { + place.place_field(fx, mir::Field::new(i)).write_cvalue(fx, param); } } } @@ -455,8 +462,6 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let ty = fx.mir.local_decls[local].ty; let layout = fx.layout_of(ty); - add_local_comment(fx, "local", local, None, None, None, ssa_analyzed[&local], ty); - let is_ssa = !ssa_analyzed .get(&local) .unwrap() diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 0254090a2c67b..9687b21217a77 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -3,14 +3,70 @@ use std::collections::HashMap; use std::fmt; use cranelift::codegen::entity::SecondaryMap; +use cranelift::codegen::ir::entities::AnyEntity; use cranelift::codegen::write::{FuncWriter, PlainWriter}; use crate::prelude::*; +/// This module provides the [CommentWriter] which makes it possible +/// to add comments to the written cranelift ir. +/// +/// # Example +/// +/// ```clif +/// test compile +/// target x86_64 +/// +/// function u0:0(i64, i64, i64) system_v { +/// ; symbol _ZN119_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$u27$a$u20$$RF$$u27$b$u20$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17he85059d5e6a760a0E +/// ; instance Instance { def: Item(DefId(0/0:29 ~ example[8787]::{{impl}}[0]::call_once[0])), substs: [ReErased, ReErased] } +/// ; sig ([IsNotEmpty, (&&[u16],)]; variadic: false)->(u8, u8) +/// +/// ; ssa {_2: NOT_SSA, _4: NOT_SSA, _0: NOT_SSA, _3: (empty), _1: NOT_SSA} +/// ; msg loc.idx param pass mode ssa flags ty +/// ; ret _0 = v0 ByRef NOT_SSA (u8, u8) +/// ; arg _1 = v1 ByRef NOT_SSA IsNotEmpty +/// ; arg _2.0 = v2 ByVal(types::I64) NOT_SSA &&[u16] +/// +/// ss0 = explicit_slot 0 ; _1: IsNotEmpty size=0 align=1,8 +/// ss1 = explicit_slot 8 ; _2: (&&[u16],) size=8 align=8,8 +/// ss2 = explicit_slot 8 ; _4: (&&[u16],) size=8 align=8,8 +/// sig0 = (i64, i64, i64) system_v +/// sig1 = (i64, i64, i64) system_v +/// fn0 = colocated u0:6 sig1 ; Instance { def: Item(DefId(0/0:31 ~ example[8787]::{{impl}}[1]::call_mut[0])), substs: [ReErased, ReErased] } +/// +/// ebb0(v0: i64, v1: i64, v2: i64): +/// v3 = stack_addr.i64 ss0 +/// v4 = stack_addr.i64 ss1 +/// store v2, v4 +/// v5 = stack_addr.i64 ss2 +/// jump ebb1 +/// +/// ebb1: +/// nop +/// ; _3 = &mut _1 +/// ; _4 = _2 +/// v6 = load.i64 v4 +/// store v6, v5 +/// ; +/// ; _0 = const mini_core::FnMut::call_mut(move _3, move _4) +/// v7 = load.i64 v5 +/// call fn0(v0, v3, v7) +/// jump ebb2 +/// +/// ebb2: +/// nop +/// ; +/// ; return +/// return +/// } +/// ``` + #[derive(Debug)] pub struct CommentWriter { global_comments: Vec, - inst_comments: HashMap + entity_comments: HashMap, + inst_comments: HashMap, } impl CommentWriter { @@ -25,6 +81,7 @@ impl CommentWriter { format!("sig {:?}", crate::abi::ty_fn_sig(tcx, instance.ty(tcx))), String::new(), ], + entity_comments: HashMap::new(), inst_comments: HashMap::new(), } } @@ -48,7 +105,23 @@ impl<'a> FuncWriter for &'a CommentWriter { writeln!(w, "")?; } - PlainWriter.write_preamble(w, func, reg_info) + self.super_preamble(w, func, reg_info) + } + + fn write_entity_definition( + &mut self, + w: &mut dyn fmt::Write, + _func: &Function, + entity: AnyEntity, + value: &fmt::Display, + ) -> fmt::Result { + write!(w, " {} = {}", entity, value)?; + + if let Some(comment) = self.entity_comments.get(&entity) { + writeln!(w, " ; {}", comment.replace('\n', "\n; ")) + } else { + writeln!(w, "") + } } fn write_ebb_header( @@ -84,6 +157,19 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { self.clif_comments.global_comments.push(comment.into()); } + pub fn add_entity_comment<'s, S: Into>, E: Into>(&mut self, entity: E, comment: S) { + use std::collections::hash_map::Entry; + match self.clif_comments.entity_comments.entry(entity.into()) { + Entry::Occupied(mut occ) => { + occ.get_mut().push('\n'); + occ.get_mut().push_str(comment.into().as_ref()); + } + Entry::Vacant(vac) => { + vac.insert(comment.into().into_owned()); + } + } + } + pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { use std::collections::hash_map::Entry; match self.clif_comments.inst_comments.entry(inst) { From f13d9fd506eefd8efaa68175a984f12e4a89e9c4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 28 Dec 2018 10:44:32 +0100 Subject: [PATCH 0428/1566] Rustup to rustc 1.33.0-nightly (fb86d604b 2018-12-27) --- ...002-Disable-u128-and-i128-in-libcore.patch | 291 ++++++++++++------ patches/0007-Fix-libstd-building.patch | 147 --------- 2 files changed, 195 insertions(+), 243 deletions(-) delete mode 100644 patches/0007-Fix-libstd-building.patch diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index cd90c6ef1c145..a6f1a893b2705 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From a759066c5c2c63d945b23f1e9d35d0dd0489faf1 Mon Sep 17 00:00:00 2001 +From 84040eb5ffeecaeb13863ff6d4106d6e4e2daaa9 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 15 Dec 2018 11:28:12 +0100 +Date: Fri, 28 Dec 2018 10:31:59 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -14,21 +14,25 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/lib.rs | 2 - src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 99 ++++++++------------------- + src/libcore/num/mod.rs | 99 ++++++++-------------------- src/libcore/num/wrapping.rs | 14 ++-- - src/libcore/ops/arith.rs | 22 +++--- - src/libcore/ops/bit.rs | 30 +++------ + src/libcore/ops/arith.rs | 22 +++---- + src/libcore/ops/bit.rs | 30 ++++----- src/libcore/sync/atomic.rs | 28 -------- src/libcore/tests/iter.rs | 15 ----- src/libcore/tests/num/mod.rs | 18 ----- - src/libcore/time.rs | 126 ----------------------------------- - 18 files changed, 62 insertions(+), 339 deletions(-) + src/libcore/time.rs | 123 ----------------------------------- + src/libstd/lib.rs | 5 -- + src/libstd/net/ip.rs | 20 ------ + src/libstd/num.rs | 2 +- + src/libstd/panic.rs | 6 -- + 22 files changed, 63 insertions(+), 368 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs -index 225ea3d..a7f2637 100644 +index 74b3ce4..9617ed1 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs -@@ -172,8 +172,8 @@ mod impls { +@@ -162,8 +162,8 @@ mod impls { } impl_clone! { @@ -40,10 +44,10 @@ index 225ea3d..a7f2637 100644 bool char } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index 33881de..0e1e823 100644 +index 9336b13..8faa03f 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs -@@ -883,7 +883,7 @@ mod impls { +@@ -873,7 +873,7 @@ mod impls { } partial_eq_impl! { @@ -52,7 +56,7 @@ index 33881de..0e1e823 100644 } macro_rules! eq_impl { -@@ -893,7 +893,7 @@ mod impls { +@@ -883,7 +883,7 @@ mod impls { )*) } @@ -61,7 +65,7 @@ index 33881de..0e1e823 100644 macro_rules! partial_ord_impl { ($($t:ty)*) => ($( -@@ -982,7 +982,7 @@ mod impls { +@@ -972,7 +972,7 @@ mod impls { } } @@ -71,10 +75,10 @@ index 33881de..0e1e823 100644 #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/src/libcore/default.rs b/src/libcore/default.rs -index 638aceb..8b6ff80 100644 +index 0e47c2f..570b949 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs -@@ -145,14 +145,12 @@ default_impl! { u8, 0, "Returns the default value of `0`" } +@@ -135,14 +135,12 @@ default_impl! { u8, 0, "Returns the default value of `0`" } default_impl! { u16, 0, "Returns the default value of `0`" } default_impl! { u32, 0, "Returns the default value of `0`" } default_impl! { u64, 0, "Returns the default value of `0`" } @@ -90,10 +94,10 @@ index 638aceb..8b6ff80 100644 default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs -index 51391fa..140255e 100644 +index c7c8fc5..689d611 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs -@@ -29,7 +29,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + +@@ -19,7 +19,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + fn to_u16(&self) -> u16; fn to_u32(&self) -> u32; fn to_u64(&self) -> u64; @@ -101,7 +105,7 @@ index 51391fa..140255e 100644 } macro_rules! doit { -@@ -40,10 +39,9 @@ macro_rules! doit { +@@ -30,10 +29,9 @@ macro_rules! doit { fn to_u16(&self) -> u16 { *self as u16 } fn to_u32(&self) -> u32 { *self as u32 } fn to_u64(&self) -> u64 { *self as u64 } @@ -113,7 +117,7 @@ index 51391fa..140255e 100644 /// A type that represents a specific radix #[doc(hidden)] -@@ -184,7 +182,6 @@ integer! { i8, u8 } +@@ -174,7 +172,6 @@ integer! { i8, u8 } integer! { i16, u16 } integer! { i32, u32 } integer! { i64, u64 } @@ -121,7 +125,7 @@ index 51391fa..140255e 100644 const DEC_DIGITS_LUT: &'static[u8] = b"0001020304050607080910111213141516171819\ -@@ -260,7 +257,6 @@ macro_rules! impl_Display { +@@ -250,7 +247,6 @@ macro_rules! impl_Display { impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); impl_Display!(i64, u64: to_u64); @@ -130,10 +134,10 @@ index 51391fa..140255e 100644 impl_Display!(isize, usize: to_u16); #[cfg(target_pointer_width = "32")] diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs -index 3e59ee1..3f8d682 100644 +index d5d29c9..f98f382 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs -@@ -306,12 +306,6 @@ pub trait Hasher { +@@ -296,12 +296,6 @@ pub trait Hasher { fn write_u64(&mut self, i: u64) { self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) }) } @@ -146,7 +150,7 @@ index 3e59ee1..3f8d682 100644 /// Writes a single `usize` into this hasher. #[inline] #[stable(feature = "hasher_write", since = "1.3.0")] -@@ -346,12 +340,6 @@ pub trait Hasher { +@@ -336,12 +330,6 @@ pub trait Hasher { fn write_i64(&mut self, i: i64) { self.write_u64(i as u64) } @@ -159,7 +163,7 @@ index 3e59ee1..3f8d682 100644 /// Writes a single `isize` into this hasher. #[inline] #[stable(feature = "hasher_write", since = "1.3.0")] -@@ -380,9 +368,6 @@ impl Hasher for &mut H { +@@ -370,9 +358,6 @@ impl Hasher for &mut H { fn write_u64(&mut self, i: u64) { (**self).write_u64(i) } @@ -169,7 +173,7 @@ index 3e59ee1..3f8d682 100644 fn write_usize(&mut self, i: usize) { (**self).write_usize(i) } -@@ -398,9 +383,6 @@ impl Hasher for &mut H { +@@ -388,9 +373,6 @@ impl Hasher for &mut H { fn write_i64(&mut self, i: i64) { (**self).write_i64(i) } @@ -179,7 +183,7 @@ index 3e59ee1..3f8d682 100644 fn write_isize(&mut self, i: isize) { (**self).write_isize(i) } -@@ -587,8 +569,6 @@ mod impls { +@@ -577,8 +559,6 @@ mod impls { (i32, write_i32), (i64, write_i64), (isize, write_isize), @@ -189,10 +193,10 @@ index 3e59ee1..3f8d682 100644 #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index f0fd07b..72a3ec9 100644 +index 66c09a0..1b8c5c9 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs -@@ -183,7 +183,6 @@ step_impl_signed!([i64: u64]); +@@ -173,7 +173,6 @@ step_impl_signed!([i64: u64]); // assume here that it is less than 64-bits. #[cfg(not(target_pointer_width = "64"))] step_impl_no_between!(u64 i64); @@ -201,10 +205,10 @@ index f0fd07b..72a3ec9 100644 macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs -index 45e5b61..64a3038 100644 +index e8c6cd8..f58b446 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs -@@ -843,7 +843,7 @@ macro_rules! float_sum_product { +@@ -901,7 +901,7 @@ macro_rules! float_sum_product { )*) } @@ -214,10 +218,10 @@ index 45e5b61..64a3038 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 313c173..4315135 100644 +index 252d7da..3c13282 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -154,14 +154,12 @@ mod uint_macros; +@@ -145,14 +145,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -233,10 +237,10 @@ index 313c173..4315135 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index d3d1612..f827f64 100644 +index 53af924..243a4f3 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs -@@ -674,8 +674,8 @@ mod copy_impls { +@@ -663,8 +663,8 @@ mod copy_impls { } impl_copy! { @@ -248,10 +252,10 @@ index d3d1612..f827f64 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index afd9fcb..ad3362c 100644 +index c024868..e512596 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs -@@ -173,12 +173,10 @@ pub fn forget_unsized(t: T) { +@@ -163,12 +163,10 @@ pub fn forget_unsized(t: T) { /// u16 | 2 /// u32 | 4 /// u64 | 8 @@ -265,10 +269,10 @@ index afd9fcb..ad3362c 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 4acf3a1..b5b3f54 100644 +index e776513..6018aea 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs -@@ -112,7 +112,6 @@ nonzero_integers! { +@@ -102,7 +102,6 @@ nonzero_integers! { NonZeroU16(u16); NonZeroU32(u32); NonZeroU64(u64); @@ -276,7 +280,7 @@ index 4acf3a1..b5b3f54 100644 NonZeroUsize(usize); } -@@ -2114,18 +2113,6 @@ impl i64 { +@@ -2110,18 +2109,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -295,7 +299,7 @@ index 4acf3a1..b5b3f54 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4394,17 +4381,6 @@ impl u64 { +@@ -4393,17 +4380,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -313,7 +317,7 @@ index 4acf3a1..b5b3f54 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4488,7 +4464,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4487,7 +4463,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -322,7 +326,7 @@ index 4acf3a1..b5b3f54 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4604,30 +4580,25 @@ macro_rules! rev { +@@ -4603,30 +4579,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -357,7 +361,7 @@ index 4acf3a1..b5b3f54 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4639,21 +4610,21 @@ mod ptr_try_from_impls { +@@ -4638,21 +4609,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -387,7 +391,7 @@ index 4acf3a1..b5b3f54 100644 } #[cfg(target_pointer_width = "32")] -@@ -4662,24 +4633,24 @@ mod ptr_try_from_impls { +@@ -4661,24 +4632,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -420,7 +424,7 @@ index 4acf3a1..b5b3f54 100644 } #[cfg(target_pointer_width = "64")] -@@ -4688,24 +4659,20 @@ mod ptr_try_from_impls { +@@ -4687,24 +4658,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -449,7 +453,7 @@ index 4acf3a1..b5b3f54 100644 } #[doc(hidden)] -@@ -4740,7 +4707,7 @@ macro_rules! doit { +@@ -4739,7 +4706,7 @@ macro_rules! doit { } })*) } @@ -458,7 +462,7 @@ index 4acf3a1..b5b3f54 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4931,52 +4898,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4930,52 +4897,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -512,10 +516,10 @@ index 4acf3a1..b5b3f54 100644 // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs -index 94dd657..fba1319 100644 +index 50e189c..2da3b35 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs -@@ -112,19 +112,17 @@ macro_rules! sh_impl_all { +@@ -102,19 +102,17 @@ macro_rules! sh_impl_all { //sh_impl_unsigned! { $t, u16 } //sh_impl_unsigned! { $t, u32 } //sh_impl_unsigned! { $t, u64 } @@ -536,7 +540,7 @@ index 94dd657..fba1319 100644 // FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping macro_rules! wrapping_impl { -@@ -323,7 +321,7 @@ macro_rules! wrapping_impl { +@@ -313,7 +311,7 @@ macro_rules! wrapping_impl { )*) } @@ -545,7 +549,7 @@ index 94dd657..fba1319 100644 macro_rules! wrapping_int_impl { ($($t:ty)*) => ($( -@@ -685,7 +683,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); +@@ -675,7 +673,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); )*) } @@ -554,7 +558,7 @@ index 94dd657..fba1319 100644 macro_rules! wrapping_int_impl_signed { ($($t:ty)*) => ($( -@@ -814,7 +812,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); +@@ -804,7 +802,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); )*) } @@ -563,7 +567,7 @@ index 94dd657..fba1319 100644 macro_rules! wrapping_int_impl_unsigned { ($($t:ty)*) => ($( -@@ -891,7 +889,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); +@@ -881,7 +879,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); )*) } @@ -572,7 +576,7 @@ index 94dd657..fba1319 100644 mod shift_max { #![allow(non_upper_case_globals)] -@@ -918,13 +916,11 @@ mod shift_max { +@@ -908,13 +906,11 @@ mod shift_max { pub const i16: u32 = (1 << 4) - 1; pub const i32: u32 = (1 << 5) - 1; pub const i64: u32 = (1 << 6) - 1; @@ -587,10 +591,10 @@ index 94dd657..fba1319 100644 pub use self::platform::usize; } diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs -index a1bc546..38742be 100644 +index 7d8bf18..91fd879 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs -@@ -114,7 +114,7 @@ macro_rules! add_impl { +@@ -104,7 +104,7 @@ macro_rules! add_impl { )*) } @@ -599,7 +603,7 @@ index a1bc546..38742be 100644 /// The subtraction operator `-`. /// -@@ -212,7 +212,7 @@ macro_rules! sub_impl { +@@ -202,7 +202,7 @@ macro_rules! sub_impl { )*) } @@ -608,7 +612,7 @@ index a1bc546..38742be 100644 /// The multiplication operator `*`. /// -@@ -332,7 +332,7 @@ macro_rules! mul_impl { +@@ -322,7 +322,7 @@ macro_rules! mul_impl { )*) } @@ -617,7 +621,7 @@ index a1bc546..38742be 100644 /// The division operator `/`. /// -@@ -457,7 +457,7 @@ macro_rules! div_impl_integer { +@@ -447,7 +447,7 @@ macro_rules! div_impl_integer { )*) } @@ -626,7 +630,7 @@ index a1bc546..38742be 100644 macro_rules! div_impl_float { ($($t:ty)*) => ($( -@@ -542,7 +542,7 @@ macro_rules! rem_impl_integer { +@@ -532,7 +532,7 @@ macro_rules! rem_impl_integer { )*) } @@ -635,7 +639,7 @@ index a1bc546..38742be 100644 macro_rules! rem_impl_float { -@@ -641,7 +641,7 @@ macro_rules! neg_impl_unsigned { +@@ -631,7 +631,7 @@ macro_rules! neg_impl_unsigned { } // neg_impl_unsigned! { usize u8 u16 u32 u64 } @@ -644,7 +648,7 @@ index a1bc546..38742be 100644 /// The addition assignment operator `+=`. /// -@@ -697,7 +697,7 @@ macro_rules! add_assign_impl { +@@ -687,7 +687,7 @@ macro_rules! add_assign_impl { )+) } @@ -653,7 +657,7 @@ index a1bc546..38742be 100644 /// The subtraction assignment operator `-=`. /// -@@ -753,7 +753,7 @@ macro_rules! sub_assign_impl { +@@ -743,7 +743,7 @@ macro_rules! sub_assign_impl { )+) } @@ -662,7 +666,7 @@ index a1bc546..38742be 100644 /// The multiplication assignment operator `*=`. /// -@@ -800,7 +800,7 @@ macro_rules! mul_assign_impl { +@@ -790,7 +790,7 @@ macro_rules! mul_assign_impl { )+) } @@ -671,7 +675,7 @@ index a1bc546..38742be 100644 /// The division assignment operator `/=`. /// -@@ -846,7 +846,7 @@ macro_rules! div_assign_impl { +@@ -836,7 +836,7 @@ macro_rules! div_assign_impl { )+) } @@ -680,17 +684,17 @@ index a1bc546..38742be 100644 /// The remainder assignment operator `%=`. /// -@@ -896,4 +896,4 @@ macro_rules! rem_assign_impl { +@@ -886,4 +886,4 @@ macro_rules! rem_assign_impl { )+) } -rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs -index 3900f36..66b7980 100644 +index 2c9bf24..af2ab6f 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs -@@ -65,7 +65,7 @@ macro_rules! not_impl { +@@ -55,7 +55,7 @@ macro_rules! not_impl { )*) } @@ -699,7 +703,7 @@ index 3900f36..66b7980 100644 /// The bitwise AND operator `&`. /// -@@ -149,7 +149,7 @@ macro_rules! bitand_impl { +@@ -139,7 +139,7 @@ macro_rules! bitand_impl { )*) } @@ -708,7 +712,7 @@ index 3900f36..66b7980 100644 /// The bitwise OR operator `|`. /// -@@ -233,7 +233,7 @@ macro_rules! bitor_impl { +@@ -223,7 +223,7 @@ macro_rules! bitor_impl { )*) } @@ -717,7 +721,7 @@ index 3900f36..66b7980 100644 /// The bitwise XOR operator `^`. /// -@@ -320,7 +320,7 @@ macro_rules! bitxor_impl { +@@ -310,7 +310,7 @@ macro_rules! bitxor_impl { )*) } @@ -726,7 +730,7 @@ index 3900f36..66b7980 100644 /// The left shift operator `<<`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type -@@ -417,19 +417,17 @@ macro_rules! shl_impl_all { +@@ -407,19 +407,17 @@ macro_rules! shl_impl_all { shl_impl! { $t, u16 } shl_impl! { $t, u32 } shl_impl! { $t, u64 } @@ -747,7 +751,7 @@ index 3900f36..66b7980 100644 /// The right shift operator `>>`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type -@@ -526,19 +524,17 @@ macro_rules! shr_impl_all { +@@ -516,19 +514,17 @@ macro_rules! shr_impl_all { shr_impl! { $t, u16 } shr_impl! { $t, u32 } shr_impl! { $t, u64 } @@ -768,7 +772,7 @@ index 3900f36..66b7980 100644 /// The bitwise AND assignment operator `&=`. /// -@@ -626,7 +622,7 @@ macro_rules! bitand_assign_impl { +@@ -616,7 +612,7 @@ macro_rules! bitand_assign_impl { )+) } @@ -777,7 +781,7 @@ index 3900f36..66b7980 100644 /// The bitwise OR assignment operator `|=`. /// -@@ -675,7 +671,7 @@ macro_rules! bitor_assign_impl { +@@ -665,7 +661,7 @@ macro_rules! bitor_assign_impl { )+) } @@ -786,7 +790,7 @@ index 3900f36..66b7980 100644 /// The bitwise XOR assignment operator `^=`. /// -@@ -724,7 +720,7 @@ macro_rules! bitxor_assign_impl { +@@ -714,7 +710,7 @@ macro_rules! bitxor_assign_impl { )+) } @@ -795,7 +799,7 @@ index 3900f36..66b7980 100644 /// The left shift assignment operator `<<=`. /// -@@ -780,19 +776,17 @@ macro_rules! shl_assign_impl_all { +@@ -770,19 +766,17 @@ macro_rules! shl_assign_impl_all { shl_assign_impl! { $t, u16 } shl_assign_impl! { $t, u32 } shl_assign_impl! { $t, u64 } @@ -816,7 +820,7 @@ index 3900f36..66b7980 100644 /// The right shift assignment operator `>>=`. /// -@@ -848,16 +842,14 @@ macro_rules! shr_assign_impl_all { +@@ -838,16 +832,14 @@ macro_rules! shr_assign_impl_all { shr_assign_impl! { $t, u16 } shr_assign_impl! { $t, u32 } shr_assign_impl! { $t, u64 } @@ -835,10 +839,10 @@ index 3900f36..66b7980 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index 060983a..ade04a5 100644 +index 99e6365..d863e33 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs -@@ -1940,34 +1940,6 @@ atomic_int! { +@@ -1943,34 +1943,6 @@ atomic_int! { 8, u64 AtomicU64 ATOMIC_U64_INIT } @@ -874,10 +878,10 @@ index 060983a..ade04a5 100644 macro_rules! ptr_width { () => { 2 } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index 4efa013..717bcdc 100644 +index cf19851..6b4a72b 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs -@@ -224,8 +224,6 @@ fn test_iterator_step_by_nth_overflow() { +@@ -214,8 +214,6 @@ fn test_iterator_step_by_nth_overflow() { type Bigger = u32; #[cfg(target_pointer_width = "32")] type Bigger = u64; @@ -886,7 +890,7 @@ index 4efa013..717bcdc 100644 #[derive(Clone)] struct Test(Bigger); -@@ -1914,19 +1912,6 @@ fn test_step_replace_signed() { +@@ -1950,19 +1948,6 @@ fn test_step_replace_signed() { assert_eq!(y, 5); } @@ -907,10 +911,10 @@ index 4efa013..717bcdc 100644 fn test_rev_try_folds() { let f = &|acc, x| i32::checked_add(2*acc, x); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs -index 0928f75..34a5296 100644 +index a17c094..3c36d10 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs -@@ -188,12 +188,10 @@ test_impl_from! { test_boolu8, bool, u8 } +@@ -178,12 +178,10 @@ test_impl_from! { test_boolu8, bool, u8 } test_impl_from! { test_boolu16, bool, u16 } test_impl_from! { test_boolu32, bool, u32 } test_impl_from! { test_boolu64, bool, u64 } @@ -923,7 +927,7 @@ index 0928f75..34a5296 100644 // Signed -> Float test_impl_from! { test_i8f32, i8, f32 } -@@ -275,51 +273,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } +@@ -265,51 +263,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } test_impl_try_from_always_ok! { test_try_u8u16, u8, u16 } test_impl_try_from_always_ok! { test_try_u8u32, u8, u32 } test_impl_try_from_always_ok! { test_try_u8u64, u8, u64 } @@ -976,10 +980,10 @@ index 0928f75..34a5296 100644 test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index 475bb72..a8a9d42 100644 +index b12ee04..fe0faad 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs -@@ -30,7 +30,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; +@@ -21,7 +21,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; const NANOS_PER_MICRO: u32 = 1_000; const MILLIS_PER_SEC: u64 = 1_000; const MICROS_PER_SEC: u64 = 1_000_000; @@ -987,7 +991,7 @@ index 475bb72..a8a9d42 100644 /// A `Duration` type to represent a span of time, typically used for system /// timeouts. -@@ -269,57 +268,6 @@ impl Duration { +@@ -260,54 +259,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } @@ -996,13 +1000,12 @@ index 475bb72..a8a9d42 100644 - /// # Examples - /// - /// ``` -- /// # #![feature(duration_as_u128)] - /// use std::time::Duration; - /// - /// let duration = Duration::new(5, 730023852); - /// assert_eq!(duration.as_millis(), 5730); - /// ``` -- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[stable(feature = "duration_as_u128", since = "1.33.0")] - #[inline] - pub const fn as_millis(&self) -> u128 { - self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 @@ -1013,13 +1016,12 @@ index 475bb72..a8a9d42 100644 - /// # Examples - /// - /// ``` -- /// # #![feature(duration_as_u128)] - /// use std::time::Duration; - /// - /// let duration = Duration::new(5, 730023852); - /// assert_eq!(duration.as_micros(), 5730023); - /// ``` -- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[stable(feature = "duration_as_u128", since = "1.33.0")] - #[inline] - pub const fn as_micros(&self) -> u128 { - self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128 @@ -1030,13 +1032,12 @@ index 475bb72..a8a9d42 100644 - /// # Examples - /// - /// ``` -- /// # #![feature(duration_as_u128)] - /// use std::time::Duration; - /// - /// let duration = Duration::new(5, 730023852); - /// assert_eq!(duration.as_nanos(), 5730023852); - /// ``` -- #[unstable(feature = "duration_as_u128", issue = "50202")] +- #[stable(feature = "duration_as_u128", since = "1.33.0")] - #[inline] - pub const fn as_nanos(&self) -> u128 { - self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128 @@ -1045,7 +1046,7 @@ index 475bb72..a8a9d42 100644 /// Checked `Duration` addition. Computes `self + other`, returning [`None`] /// if overflow occurred. /// -@@ -478,80 +426,6 @@ impl Duration { +@@ -466,80 +417,6 @@ impl Duration { (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) } @@ -1126,6 +1127,104 @@ index 475bb72..a8a9d42 100644 /// Divide `Duration` by `Duration` and return `f64`. /// /// # Examples +diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs +index 3051100..61001a4 100644 +--- a/src/libstd/lib.rs ++++ b/src/libstd/lib.rs +@@ -248,7 +248,6 @@ + #![feature(const_cstr_unchecked)] + #![feature(core_intrinsics)] + #![feature(dropck_eyepatch)] +-#![cfg_attr(stage0, feature(duration_as_u128))] + #![feature(exact_size_is_empty)] + #![feature(external_doc)] + #![feature(fixed_size_array)] +@@ -404,8 +403,6 @@ pub use core::i16; + pub use core::i32; + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::i64; +-#[stable(feature = "i128", since = "1.26.0")] +-pub use core::i128; + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::usize; + #[stable(feature = "rust1", since = "1.0.0")] +@@ -438,8 +435,6 @@ pub use alloc_crate::string; + pub use alloc_crate::vec; + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::char; +-#[stable(feature = "i128", since = "1.26.0")] +-pub use core::u128; + #[stable(feature = "core_hint", since = "1.27.0")] + pub use core::hint; + +diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs +index 52a29f4..cafe50e 100644 +--- a/src/libstd/net/ip.rs ++++ b/src/libstd/net/ip.rs +@@ -1382,26 +1382,6 @@ impl FromInner for Ipv6Addr { + } + } + +-#[stable(feature = "i128", since = "1.26.0")] +-impl From for u128 { +- fn from(ip: Ipv6Addr) -> u128 { +- let ip = ip.segments(); +- ((ip[0] as u128) << 112) + ((ip[1] as u128) << 96) + ((ip[2] as u128) << 80) + +- ((ip[3] as u128) << 64) + ((ip[4] as u128) << 48) + ((ip[5] as u128) << 32) + +- ((ip[6] as u128) << 16) + (ip[7] as u128) +- } +-} +-#[stable(feature = "i128", since = "1.26.0")] +-impl From for Ipv6Addr { +- fn from(ip: u128) -> Ipv6Addr { +- Ipv6Addr::new( +- (ip >> 112) as u16, (ip >> 96) as u16, (ip >> 80) as u16, +- (ip >> 64) as u16, (ip >> 48) as u16, (ip >> 32) as u16, +- (ip >> 16) as u16, ip as u16, +- ) +- } +-} +- + #[stable(feature = "ipv6_from_octets", since = "1.9.0")] + impl From<[u8; 16]> for Ipv6Addr { + fn from(octets: [u8; 16]) -> Ipv6Addr { +diff --git a/src/libstd/num.rs b/src/libstd/num.rs +index c80b9a5..e32a6b3 100644 +--- a/src/libstd/num.rs ++++ b/src/libstd/num.rs +@@ -12,7 +12,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} + pub use core::num::Wrapping; + + #[stable(feature = "nonzero", since = "1.28.0")] +-pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; ++pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; + + #[cfg(test)] use fmt; + #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; +diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs +index d27f6ca..8ac2a44 100644 +--- a/src/libstd/panic.rs ++++ b/src/libstd/panic.rs +@@ -254,9 +254,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} + #[cfg(target_has_atomic = "64")] + #[unstable(feature = "integer_atomics", issue = "32976")] + impl RefUnwindSafe for atomic::AtomicI64 {} +-#[cfg(target_has_atomic = "128")] +-#[unstable(feature = "integer_atomics", issue = "32976")] +-impl RefUnwindSafe for atomic::AtomicI128 {} + + #[cfg(target_has_atomic = "ptr")] + #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] +@@ -273,9 +270,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {} + #[cfg(target_has_atomic = "64")] + #[unstable(feature = "integer_atomics", issue = "32976")] + impl RefUnwindSafe for atomic::AtomicU64 {} +-#[cfg(target_has_atomic = "128")] +-#[unstable(feature = "integer_atomics", issue = "32976")] +-impl RefUnwindSafe for atomic::AtomicU128 {} + + #[cfg(target_has_atomic = "8")] + #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] -- 2.17.2 (Apple Git-113) diff --git a/patches/0007-Fix-libstd-building.patch b/patches/0007-Fix-libstd-building.patch deleted file mode 100644 index 398a2b60ed16f..0000000000000 --- a/patches/0007-Fix-libstd-building.patch +++ /dev/null @@ -1,147 +0,0 @@ -From a99af7473c8b334ed6febe97294813298b6a3633 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 15 Dec 2018 14:32:15 +0100 -Subject: [PATCH] Fix libstd building - ---- - src/libstd/lib.rs | 6 ------ - src/libstd/net/ip.rs | 20 -------------------- - src/libstd/num.rs | 2 +- - src/libstd/panic.rs | 6 ------ - src/libstd/primitive_docs.rs | 16 ---------------- - 5 files changed, 1 insertion(+), 49 deletions(-) - -diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index f3965f3..13e17b1 100644 ---- a/src/libstd/lib.rs -+++ b/src/libstd/lib.rs -@@ -256,7 +256,6 @@ - #![feature(const_cstr_unchecked)] - #![feature(core_intrinsics)] - #![feature(dropck_eyepatch)] --#![feature(duration_as_u128)] - #![feature(exact_size_is_empty)] - #![feature(external_doc)] - #![feature(fixed_size_array)] -@@ -409,8 +407,6 @@ pub use core::i16; - pub use core::i32; - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::i64; --#[stable(feature = "i128", since = "1.26.0")] --pub use core::i128; - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::usize; - #[stable(feature = "rust1", since = "1.0.0")] -@@ -443,8 +439,6 @@ pub use alloc_crate::string; - pub use alloc_crate::vec; - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::char; --#[stable(feature = "i128", since = "1.26.0")] --pub use core::u128; - #[stable(feature = "core_hint", since = "1.27.0")] - pub use core::hint; - -diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index 8685cb7..c4bf4d2 100644 ---- a/src/libstd/net/ip.rs -+++ b/src/libstd/net/ip.rs -@@ -1392,26 +1392,6 @@ impl FromInner for Ipv6Addr { - } - } - --#[stable(feature = "i128", since = "1.26.0")] --impl From for u128 { -- fn from(ip: Ipv6Addr) -> u128 { -- let ip = ip.segments(); -- ((ip[0] as u128) << 112) + ((ip[1] as u128) << 96) + ((ip[2] as u128) << 80) + -- ((ip[3] as u128) << 64) + ((ip[4] as u128) << 48) + ((ip[5] as u128) << 32) + -- ((ip[6] as u128) << 16) + (ip[7] as u128) -- } --} --#[stable(feature = "i128", since = "1.26.0")] --impl From for Ipv6Addr { -- fn from(ip: u128) -> Ipv6Addr { -- Ipv6Addr::new( -- (ip >> 112) as u16, (ip >> 96) as u16, (ip >> 80) as u16, -- (ip >> 64) as u16, (ip >> 48) as u16, (ip >> 32) as u16, -- (ip >> 16) as u16, ip as u16, -- ) -- } --} -- - #[stable(feature = "ipv6_from_octets", since = "1.9.0")] - impl From<[u8; 16]> for Ipv6Addr { - fn from(octets: [u8; 16]) -> Ipv6Addr { -diff --git a/src/libstd/num.rs b/src/libstd/num.rs -index 3f90c1f..85aab83 100644 ---- a/src/libstd/num.rs -+++ b/src/libstd/num.rs -@@ -22,7 +22,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} - pub use core::num::Wrapping; - - #[stable(feature = "nonzero", since = "1.28.0")] --pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; -+pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; - - #[cfg(test)] use fmt; - #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; -diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs -index 3eacc7a..b518448 100644 ---- a/src/libstd/panic.rs -+++ b/src/libstd/panic.rs -@@ -264,9 +264,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} - #[cfg(target_has_atomic = "64")] - #[unstable(feature = "integer_atomics", issue = "32976")] - impl RefUnwindSafe for atomic::AtomicI64 {} --#[cfg(target_has_atomic = "128")] --#[unstable(feature = "integer_atomics", issue = "32976")] --impl RefUnwindSafe for atomic::AtomicI128 {} - - #[cfg(target_has_atomic = "ptr")] - #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] -@@ -283,9 +280,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {} - #[cfg(target_has_atomic = "64")] - #[unstable(feature = "integer_atomics", issue = "32976")] - impl RefUnwindSafe for atomic::AtomicU64 {} --#[cfg(target_has_atomic = "128")] --#[unstable(feature = "integer_atomics", issue = "32976")] --impl RefUnwindSafe for atomic::AtomicU128 {} - - #[cfg(target_has_atomic = "8")] - #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] -diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs -index 7c1654f..cc96271 100644 ---- a/src/libstd/primitive_docs.rs -+++ b/src/libstd/primitive_docs.rs -@@ -808,14 +808,6 @@ mod prim_i32 { } - #[stable(feature = "rust1", since = "1.0.0")] - mod prim_i64 { } - --#[doc(primitive = "i128")] --// --/// The 128-bit signed integer type. --/// --/// *[See also the `std::i128` module](i128/index.html).* --#[stable(feature = "i128", since="1.26.0")] --mod prim_i128 { } -- - #[doc(primitive = "u8")] - // - /// The 8-bit unsigned integer type. -@@ -848,14 +840,6 @@ mod prim_u32 { } - #[stable(feature = "rust1", since = "1.0.0")] - mod prim_u64 { } - --#[doc(primitive = "u128")] --// --/// The 128-bit unsigned integer type. --/// --/// *[See also the `std::u128` module](u128/index.html).* --#[stable(feature = "i128", since="1.26.0")] --mod prim_u128 { } -- - #[doc(primitive = "isize")] - // - /// The pointer-sized signed integer type. --- -2.17.2 (Apple Git-113) From 56133d1b18b5d60788146b6dd26201709b209a52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 28 Dec 2018 15:18:17 +0100 Subject: [PATCH 0429/1566] Fix release mode --- src/abi.rs | 3 ++- src/archive.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 5fd7995332ad7..87b96faeb30d6 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -330,7 +330,8 @@ fn local_place<'a, 'tcx: 'a>( CPlace::from_stack_slot(fx, stack_slot, layout.ty) }; - debug_assert!(fx.local_map.insert(local, place).is_none()); + let prev_place = fx.local_map.insert(local, place); + debug_assert!(prev_place.is_none()); fx.local_map[&local] } diff --git a/src/archive.rs b/src/archive.rs index 1e57ff0f2c41c..44d1fd2c6f296 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -56,8 +56,9 @@ impl<'a> ArchiveBuilder<'a> { } pub fn remove_file(&mut self, name: &str) { + let file = self.src_entries.remove(name); assert!( - self.src_entries.remove(name).is_some(), + file.is_some(), "Tried to remove file not existing in src archive", ); } From 8561349ece98ade3a848501d1b3c390f2b3e6911 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 28 Dec 2018 17:07:40 +0100 Subject: [PATCH 0430/1566] Only build clif comments in debug mode --- src/abi.rs | 32 ++++++++++++++++++++++++-------- src/base.rs | 25 ++++++++++++++----------- src/pretty_clif.rs | 3 ++- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 87b96faeb30d6..e859fe2a38f5b 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -199,7 +199,10 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { let func_id = self.get_function_id(inst); let func_ref = self.module .declare_func_in_func(func_id, &mut self.bcx.func); + + #[cfg(debug_assertions)] self.add_entity_comment(func_ref, format!("{:?}", inst)); + func_ref } @@ -273,6 +276,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } } +#[cfg(debug_assertions)] fn add_arg_comment<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, msg: &str, @@ -300,6 +304,7 @@ fn add_arg_comment<'a, 'tcx: 'a>( )); } +#[cfg(debug_assertions)] fn add_local_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(format!("msg loc.idx param pass mode ssa flags ty")); } @@ -320,12 +325,15 @@ fn local_place<'a, 'tcx: 'a>( offset: None, }); - let TyLayout { ty, details } = layout; - let ty::layout::LayoutDetails { size, align, abi: _, variants: _, fields: _ } = details; - fx.add_entity_comment(stack_slot, format!( - "{:?}: {:?} size={} align={},{}", - local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), - )); + #[cfg(debug_assertions)] + { + let TyLayout { ty, details } = layout; + let ty::layout::LayoutDetails { size, align, abi: _, variants: _, fields: _ } = details; + fx.add_entity_comment(stack_slot, format!( + "{:?}: {:?} size={} align={},{}", + local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), + )); + } CPlace::from_stack_slot(fx, stack_slot, layout.ty) }; @@ -347,7 +355,10 @@ fn cvalue_for_param<'a, 'tcx: 'a>( let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false); let clif_type = pass_mode.get_param_ty(fx); let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); + + #[cfg(debug_assertions)] add_arg_comment(fx, "arg", local, local_field, Some(ebb_param), pass_mode, ssa_flags, arg_ty); + match pass_mode { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(_) => CValue::ByVal(ebb_param, layout), @@ -360,6 +371,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( start_ebb: Ebb, ) { let ssa_analyzed = crate::analyze::analyze(fx); + + #[cfg(debug_assertions)] fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); let ret_layout = fx.layout_of(fx.return_type()); @@ -370,8 +383,11 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, fx.pointer_type)), }; - add_local_header_comment(fx); - add_arg_comment(fx, "ret", RETURN_PLACE, None, ret_param, output_pass_mode, ssa_analyzed[&RETURN_PLACE], ret_layout.ty); + #[cfg(debug_assertions)] + { + add_local_header_comment(fx); + add_arg_comment(fx, "ret", RETURN_PLACE, None, ret_param, output_pass_mode, ssa_analyzed[&RETURN_PLACE], ret_layout.ty); + } enum ArgKind<'tcx> { Normal(CValue<'tcx>), diff --git a/src/base.rs b/src/base.rs index b3c87258a34e9..18e45cf9c3608 100644 --- a/src/base.rs +++ b/src/base.rs @@ -110,9 +110,8 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( }); // Step 7. Write function to file for debugging - if cfg!(debug_assertions) { - fx.write_clif_file(); - } + #[cfg(debug_assertions)] + fx.write_clif_file(); // Step 8. Verify function verify_func(tcx, fx.clif_comments, &func); @@ -158,14 +157,17 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) trans_stmt(fx, ebb, stmt); } - let mut terminator_head = "\n".to_string(); - bb_data - .terminator() - .kind - .fmt_head(&mut terminator_head) - .unwrap(); - let inst = fx.bcx.func.layout.last_inst(ebb).unwrap(); - fx.add_comment(inst, terminator_head); + #[cfg(debug_assertions)] + { + let mut terminator_head = "\n".to_string(); + bb_data + .terminator() + .kind + .fmt_head(&mut terminator_head) + .unwrap(); + let inst = fx.bcx.func.layout.last_inst(ebb).unwrap(); + fx.add_comment(inst, terminator_head); + } match &bb_data.terminator().kind { TerminatorKind::Goto { target } => { @@ -320,6 +322,7 @@ fn trans_stmt<'a, 'tcx: 'a>( ) { let _print_guard = PrintOnPanic(|| format!("stmt {:?}", stmt)); + #[cfg(debug_assertions)] match &stmt.kind { StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful _ => { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 9687b21217a77..05d6b4e30f276 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -152,6 +152,7 @@ impl<'a> FuncWriter for &'a CommentWriter { } } +#[cfg(debug_assertions)] impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { pub fn add_global_comment>(&mut self, comment: S) { self.clif_comments.global_comments.push(comment.into()); @@ -202,7 +203,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { Ok(mut file) => { let target_triple: ::target_lexicon::Triple = self.tcx.sess.target.target.llvm_target.parse().unwrap(); writeln!(file, "test compile").unwrap(); - writeln!(file, "target {}", target_triple.architecture).unwrap(); + writeln!(file, "target {}", target_triple).unwrap(); writeln!(file, "").unwrap(); file.write(clif.as_bytes()).unwrap(); } From b105534f978ae5a1ffd098524f90366394c225cf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 28 Dec 2018 17:15:13 +0100 Subject: [PATCH 0431/1566] Misc build changes --- build_sysroot/build_sysroot.sh | 4 ++-- test.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 38608e02163b0..33da1e3dd6792 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -19,7 +19,8 @@ else fi # Build libs -export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked --sysroot ../" +mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked --sysroot sysroot" if [[ "$1" == "--release" ]]; then channel='release' RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release @@ -29,5 +30,4 @@ else fi # Copy files to sysroot -mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/test.sh b/test.sh index 6c742298cf82d..d03b48c96bce8 100755 --- a/test.sh +++ b/test.sh @@ -19,7 +19,8 @@ echo "[JIT] mini_core_hello_world" SHOULD_RUN=1 $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" -build_example_bin mini_core_hello_world example/mini_core_hello_world.rs +$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin +sh -c ./target/out/mini_core_hello_world || true echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh From bebaa83c4a05bfec1025447d37b3331c6de80ed4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 28 Dec 2018 18:48:47 +0100 Subject: [PATCH 0432/1566] Add 'set is_pic' to clif files --- src/pretty_clif.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 05d6b4e30f276..7107f62a27d67 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -203,6 +203,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { Ok(mut file) => { let target_triple: ::target_lexicon::Triple = self.tcx.sess.target.target.llvm_target.parse().unwrap(); writeln!(file, "test compile").unwrap(); + writeln!(file, "set is_pic"); writeln!(file, "target {}", target_triple).unwrap(); writeln!(file, "").unwrap(); file.write(clif.as_bytes()).unwrap(); From 65f6f62f912214973726d9dcfdc923e225f3296e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 28 Dec 2018 17:55:52 +0000 Subject: [PATCH 0433/1566] Bump serde from 1.0.82 to 1.0.83 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.82 to 1.0.83. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.82...v1.0.83) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e3a4fce4ed102..92b8b06bc9b2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -585,7 +585,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -595,7 +595,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -603,7 +603,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -848,7 +848,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "6fa52f19aee12441d5ad11c9a00459122bd8f98707cadf9778c540674f1935b6" +"checksum serde 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)" = "157e12af46859e968da75dea9845530e13d03bcab2009a41b9b7bb3cf4eb3ec2" "checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" From 8f2ca706c21fef0cdc22f218e95164a9266aa0f9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Dec 2018 12:04:35 +0100 Subject: [PATCH 0434/1566] Setup env_logger --- Cargo.lock | 14 ++++++++++++++ Cargo.toml | 1 + src/lib.rs | 1 + 3 files changed, 16 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 92b8b06bc9b2f..73547919e8af6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -216,6 +216,18 @@ dependencies = [ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "env_logger" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "errno" version = "0.2.4" @@ -532,6 +544,7 @@ dependencies = [ "cranelift-faerie 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -805,6 +818,7 @@ dependencies = [ "checksum cranelift-native 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" +"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f869e12bcad2b4ff6ac60e01c2354957312fbf0c10dc938f340d58932b3db52" diff --git a/Cargo.toml b/Cargo.toml index 7266c9b85d8b6..1a8797c0c6aee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ bitflags = "1.0.3" byteorder = "1.2.6" libc = "0.2.45" tempfile = "3.0.4" +env_logger = "0.6" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] diff --git a/src/lib.rs b/src/lib.rs index 8cbd597fd59be..c1ac678d70ffe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,6 +184,7 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx: TyCtxt<'a, 'tcx, 'tcx>, _rx: mpsc::Receiver>, ) -> Box { + env_logger::init(); if !tcx.sess.crate_types.get().contains(&CrateType::Executable) && std::env::var("SHOULD_RUN").is_ok() { From 16e43c9d212cc6c64f2213bf4c4bef0ae9860c0b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Dec 2018 15:33:34 +0100 Subject: [PATCH 0435/1566] Fix unsize coercions and the size_of_val and min_align_of_val intrinsics for custom dst's --- example/mini_core.rs | 1 + example/mini_core_hello_world.rs | 4 + src/common.rs | 64 +-------- src/intrinsics.rs | 33 ++--- src/lib.rs | 1 + src/unsize.rs | 221 +++++++++++++++++++++++++++++++ src/vtable.rs | 6 +- 7 files changed, 244 insertions(+), 86 deletions(-) create mode 100644 src/unsize.rs diff --git a/example/mini_core.rs b/example/mini_core.rs index 24429555a5fd7..a3ab762328737 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -12,6 +12,7 @@ pub trait Unsize {} pub trait CoerceUnsized {} impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} +impl<'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {} impl, U: ?Sized> CoerceUnsized<*const U> for *const T {} impl, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 4d9021ce04eda..c4140ceaf1ec6 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -151,6 +151,10 @@ fn main() { pointer: 0 as *const &str, _marker: PhantomData, } as Unique; + + struct MyDst(T); + + intrinsics::size_of_val(&MyDst([0u8; 4]) as &MyDst<[u8]>); } let _ = NoisyDrop { diff --git a/src/common.rs b/src/common.rs index 62e4af90054ac..433334aa41754 100644 --- a/src/common.rs +++ b/src/common.rs @@ -221,69 +221,7 @@ impl<'tcx> CValue<'tcx> { } pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - if self.layout().ty == dest.layout().ty { - dest.write_cvalue(fx, self); // FIXME this shouldn't happen (rust-lang/rust#53602) - return; - } - match &self.layout().ty.sty { - ty::Ref(_, ty, _) | ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { - let (ptr, extra) = match dest.layout().ty.builtin_deref(true).unwrap().ty.sty { - ty::Slice(slice_elem_ty) => match ty.sty { - ty::Array(array_elem_ty, size) => { - assert_eq!(slice_elem_ty, array_elem_ty); - let ptr = self.load_value(fx); - let extra = fx - .bcx - .ins() - .iconst(fx.pointer_type, size.unwrap_usize(fx.tcx) as i64); - (ptr, extra) - } - _ => bug!("unsize non array {:?} to slice", ty), - }, - ty::Dynamic(data, _) => match ty.sty { - ty::Dynamic(_, _) => self.load_value_pair(fx), - _ => { - let ptr = self.load_value(fx); - let vtable = crate::vtable::get_vtable(fx, ty, data.principal()); - (ptr, vtable) - } - }, - _ => bug!( - "unsize of type {:?} to {:?}", - self.layout().ty, - dest.layout().ty - ), - }; - dest.write_cvalue(fx, CValue::ByValPair(ptr, extra, dest.layout())); - } - _ => { - assert!(!self.layout().ty.is_enum(), "Tried to unsize enum"); - let field_count = self.layout().fields.count(); - let mut found_unsize_field = false; - for idx in 0..field_count { - let field_dest = dest.place_field(fx, mir::Field::new(idx)); - let field_src = self.value_field(fx, mir::Field::new(idx)); - if field_src.layout().ty.is_phantom_data() { - // Ignore PhantomData so for example `Unique<()>` can coerce to `Unique` - // - // ```rust - // struct Unique { - // pointer: NonZero<*const T>, - // _marker: PhantomData, - // } - // ``` - continue; - } - if field_src.layout().ty != field_dest.layout().ty { - assert!(!found_unsize_field); - found_unsize_field = true; - field_src.unsize_value(fx, field_dest); - } else { - field_dest.write_cvalue(fx, field_src); - } - } - } - } + crate::unsize::coerce_unsized_into(fx, self, dest); } pub fn const_val<'a>( diff --git a/src/intrinsics.rs b/src/intrinsics.rs index bb565ea38a51b..62800132dff5b 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -153,18 +153,15 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; size_of_val, (c ptr) { let layout = fx.layout_of(T); - let size = match &layout.ty.sty { - _ if !layout.is_unsized() => fx + let size = if layout.is_unsized() { + let (_ptr, info) = ptr.load_value_pair(fx); + let (size, _align) = crate::unsize::size_and_align_of_dst(fx, layout.ty, info); + size + } else { + fx .bcx .ins() - .iconst(fx.pointer_type, layout.size.bytes() as i64), - ty::Slice(elem) => { - let len = ptr.load_value_pair(fx).1; - let elem_size = fx.layout_of(elem).size.bytes(); - fx.bcx.ins().imul_imm(len, elem_size as i64) - } - ty::Dynamic(..) => crate::vtable::size_of_obj(fx, ptr), - ty => bug!("size_of_val for unknown unsized type {:?}", ty), + .iconst(fx.pointer_type, layout.size.bytes() as i64) }; ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); }; @@ -175,17 +172,15 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; min_align_of_val, (c ptr) { let layout = fx.layout_of(T); - let align = match &layout.ty.sty { - _ if !layout.is_unsized() => fx + let align = if layout.is_unsized() { + let (_ptr, info) = ptr.load_value_pair(fx); + let (_size, align) = crate::unsize::size_and_align_of_dst(fx, layout.ty, info); + align + } else { + fx .bcx .ins() - .iconst(fx.pointer_type, layout.align.abi.bytes() as i64), - ty::Slice(elem) => { - let align = fx.layout_of(elem).align.abi.bytes() as i64; - fx.bcx.ins().iconst(fx.pointer_type, align) - } - ty::Dynamic(..) => crate::vtable::min_align_of_obj(fx, ptr), - ty => unimplemented!("min_align_of_val for {:?}", ty), + .iconst(fx.pointer_type, layout.align.abi.bytes() as i64) }; ret.write_cvalue(fx, CValue::ByVal(align, usize_layout)); }; diff --git a/src/lib.rs b/src/lib.rs index c1ac678d70ffe..a9a6895d46b94 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,6 +51,7 @@ mod metadata; mod pretty_clif; mod trap; mod unimpl; +mod unsize; mod vtable; mod prelude { diff --git a/src/unsize.rs b/src/unsize.rs new file mode 100644 index 0000000000000..f8f918fa8aa26 --- /dev/null +++ b/src/unsize.rs @@ -0,0 +1,221 @@ +use crate::prelude::*; + +// Adapted from https://github.com/rust-lang/rust/blob/2a663555ddf36f6b041445894a8c175cd1bc718c/src/librustc_codegen_ssa/base.rs#L159-L307 + +/// Retrieve the information we are losing (making dynamic) in an unsizing +/// adjustment. +/// +/// The `old_info` argument is a bit funny. It is intended for use +/// in an upcast, where the new vtable for an object will be derived +/// from the old one. +pub fn unsized_info<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + source: Ty<'tcx>, + target: Ty<'tcx>, + old_info: Option, +) -> Value { + let (source, target) = fx.tcx.struct_lockstep_tails(source, target); + match (&source.sty, &target.sty) { + (&ty::Array(_, len), &ty::Slice(_)) => { + fx.bcx.ins().iconst(fx.pointer_type, len.unwrap_usize(fx.tcx) as i64) + } + (&ty::Dynamic(..), &ty::Dynamic(..)) => { + // For now, upcasts are limited to changes in marker + // traits, and hence never actually require an actual + // change to the vtable. + old_info.expect("unsized_info: missing old info for trait upcast") + } + (_, &ty::Dynamic(ref data, ..)) => { + crate::vtable::get_vtable(fx, source, data.principal()) + } + _ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", + source, + target), + } +} + +/// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer. +pub fn unsize_thin_ptr<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + src: Value, + src_ty: Ty<'tcx>, + dst_ty: Ty<'tcx> +) -> (Value, Value) { + match (&src_ty.sty, &dst_ty.sty) { + (&ty::Ref(_, a, _), + &ty::Ref(_, b, _)) | + (&ty::Ref(_, a, _), + &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | + (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), + &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { + assert!(!fx.layout_of(a).is_unsized()); + (src, unsized_info(fx, a, b, None)) + } + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => { + let (a, b) = (src_ty.boxed_ty(), dst_ty.boxed_ty()); + assert!(!fx.layout_of(a).is_unsized()); + (src, unsized_info(fx, a, b, None)) + } + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { + assert_eq!(def_a, def_b); + + let src_layout = fx.layout_of(src_ty); + let dst_layout = fx.layout_of(dst_ty); + let mut result = None; + for i in 0..src_layout.fields.count() { + let src_f = src_layout.field(fx, i); + assert_eq!(src_layout.fields.offset(i).bytes(), 0); + assert_eq!(dst_layout.fields.offset(i).bytes(), 0); + if src_f.is_zst() { + continue; + } + assert_eq!(src_layout.size, src_f.size); + + let dst_f = dst_layout.field(fx, i); + assert_ne!(src_f.ty, dst_f.ty); + assert_eq!(result, None); + result = Some(unsize_thin_ptr(fx, src, src_f.ty, dst_f.ty)); + } + result.unwrap() + } + _ => bug!("unsize_thin_ptr: called on bad types"), + } +} + +/// Coerce `src`, which is a reference to a value of type `src_ty`, +/// to a value of type `dst_ty` and store the result in `dst` +pub fn coerce_unsized_into<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + src: CValue<'tcx>, + dst: CPlace<'tcx>, +) { + let src_ty = src.layout().ty; + let dst_ty = dst.layout().ty; + let mut coerce_ptr = || { + let (base, info) = if fx.layout_of(src.layout().ty.builtin_deref(true).unwrap().ty).is_unsized() { + // fat-ptr to fat-ptr unsize preserves the vtable + // i.e., &'a fmt::Debug+Send => &'a fmt::Debug + src.load_value_pair(fx) + } else { + let base = src.load_value(fx); + unsize_thin_ptr(fx, base, src_ty, dst_ty) + }; + dst.write_cvalue(fx, CValue::ByValPair(base, info, dst.layout())); + }; + match (&src_ty.sty, &dst_ty.sty) { + (&ty::Ref(..), &ty::Ref(..)) | + (&ty::Ref(..), &ty::RawPtr(..)) | + (&ty::RawPtr(..), &ty::RawPtr(..)) => { + coerce_ptr() + } + (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { + assert_eq!(def_a, def_b); + + for i in 0..def_a.variants[VariantIdx::new(0)].fields.len() { + let src_f = src.value_field(fx, mir::Field::new(i)); + let dst_f = dst.place_field(fx, mir::Field::new(i)); + + if dst_f.layout().is_zst() { + continue; + } + + if src_f.layout().ty == dst_f.layout().ty { + dst_f.write_cvalue(fx, src_f); + } else { + coerce_unsized_into(fx, src_f, dst_f); + } + } + } + _ => bug!("coerce_unsized_into: invalid coercion {:?} -> {:?}", + src_ty, + dst_ty), + } +} + + +// Adapted from https://github.com/rust-lang/rust/blob/2a663555ddf36f6b041445894a8c175cd1bc718c/src/librustc_codegen_ssa/glue.rs + +pub fn size_and_align_of_dst<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ty: Ty<'tcx>, + info: Value, +) -> (Value, Value) { + let layout = fx.layout_of(ty); + if !layout.is_unsized() { + let size = fx.bcx.ins().iconst(fx.pointer_type, layout.size.bytes() as i64); + let align = fx.bcx.ins().iconst(fx.pointer_type, layout.align.abi.bytes() as i64); + return (size, align); + } + match ty.sty { + ty::Dynamic(..) => { + // load size/align from vtable + ( + crate::vtable::size_of_obj(fx, info), + crate::vtable::min_align_of_obj(fx, info), + ) + } + ty::Slice(_) | ty::Str => { + let unit = layout.field(fx, 0); + // The info in this case is the length of the str, so the size is that + // times the unit size. + (fx.bcx.ins().imul_imm(info, unit.size.bytes() as i64), + fx.bcx.ins().iconst(fx.pointer_type, unit.align.abi.bytes() as i64)) + } + _ => { + // First get the size of all statically known fields. + // Don't use size_of because it also rounds up to alignment, which we + // want to avoid, as the unsized field's alignment could be smaller. + assert!(!ty.is_simd()); + + let i = layout.fields.count() - 1; + let sized_size = layout.fields.offset(i).bytes(); + let sized_align = layout.align.abi.bytes(); + let sized_align = fx.bcx.ins().iconst(fx.pointer_type, sized_align as i64); + + // Recurse to get the size of the dynamically sized field (must be + // the last field). + let field_ty = layout.field(fx, i).ty; + let (unsized_size, mut unsized_align) = size_and_align_of_dst(fx, field_ty, info); + + // FIXME (#26403, #27023): We should be adding padding + // to `sized_size` (to accommodate the `unsized_align` + // required of the unsized field that follows) before + // summing it with `sized_size`. (Note that since #26403 + // is unfixed, we do not yet add the necessary padding + // here. But this is where the add would go.) + + // Return the sum of sizes and max of aligns. + let size = fx.bcx.ins().iadd_imm(unsized_size, sized_size as i64); + + // Packed types ignore the alignment of their fields. + if let ty::Adt(def, _) = ty.sty { + if def.repr.packed() { + unsized_align = sized_align; + } + } + + // Choose max of two known alignments (combined value must + // be aligned according to more restrictive of the two). + let cmp = fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, sized_align, unsized_align); + let align = fx.bcx.ins().select(cmp, sized_align, unsized_align); + + // Issue #27023: must add any necessary padding to `size` + // (to make it a multiple of `align`) before returning it. + // + // Namely, the returned size should be, in C notation: + // + // `size + ((size & (align-1)) ? align : 0)` + // + // emulated via the semi-standard fast bit trick: + // + // `(size + (align-1)) & -align` + let addend = fx.bcx.ins().iadd_imm(align, -1); + let add = fx.bcx.ins().iadd(size, addend); + let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); + let neg = fx.bcx.ins().isub(zero, align); + let size = fx.bcx.ins().band(add, neg); + + (size, align) + } + } +} diff --git a/src/vtable.rs b/src/vtable.rs index b9045a8eeba3f..bdf0c9e2f5448 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -8,9 +8,8 @@ const ALIGN_INDEX: usize = 2; pub fn size_of_obj<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - val: CValue<'tcx>, + vtable: Value, ) -> Value { - let (_ptr, vtable) = val.load_value_pair(fx); let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -22,9 +21,8 @@ pub fn size_of_obj<'a, 'tcx: 'a>( pub fn min_align_of_obj<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - val: CValue<'tcx>, + vtable: Value, ) -> Value { - let (_ptr, vtable) = val.load_value_pair(fx); let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), From f301b06bf4928dfafb68aa5c6673539daae3d34a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 30 Dec 2018 12:06:55 +0100 Subject: [PATCH 0436/1566] Rustup to rustc 1.33.0-nightly (59183180f 2018-12-29) --- ...002-Disable-u128-and-i128-in-libcore.patch | 265 +++++++++--------- 1 file changed, 128 insertions(+), 137 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index a6f1a893b2705..c060b7c188279 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -34,7 +34,7 @@ index 74b3ce4..9617ed1 100644 +++ b/src/libcore/clone.rs @@ -162,8 +162,8 @@ mod impls { } - + impl_clone! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -49,29 +49,29 @@ index 9336b13..8faa03f 100644 +++ b/src/libcore/cmp.rs @@ -873,7 +873,7 @@ mod impls { } - + partial_eq_impl! { - bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 + bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + macro_rules! eq_impl { @@ -883,7 +883,7 @@ mod impls { )*) } - + - eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! partial_ord_impl { ($($t:ty)*) => ($( @@ -972,7 +972,7 @@ mod impls { } } - + - ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/src/libcore/default.rs b/src/libcore/default.rs @@ -83,14 +83,14 @@ index 0e47c2f..570b949 100644 default_impl! { u32, 0, "Returns the default value of `0`" } default_impl! { u64, 0, "Returns the default value of `0`" } -default_impl! { u128, 0, "Returns the default value of `0`" } - + default_impl! { isize, 0, "Returns the default value of `0`" } default_impl! { i8, 0, "Returns the default value of `0`" } default_impl! { i16, 0, "Returns the default value of `0`" } default_impl! { i32, 0, "Returns the default value of `0`" } default_impl! { i64, 0, "Returns the default value of `0`" } -default_impl! { i128, 0, "Returns the default value of `0`" } - + default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs @@ -103,7 +103,7 @@ index c7c8fc5..689d611 100644 fn to_u64(&self) -> u64; - fn to_u128(&self) -> u128; } - + macro_rules! doit { @@ -30,10 +29,9 @@ macro_rules! doit { fn to_u16(&self) -> u16 { *self as u16 } @@ -114,7 +114,7 @@ index c7c8fc5..689d611 100644 } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + /// A type that represents a specific radix #[doc(hidden)] @@ -174,7 +172,6 @@ integer! { i8, u8 } @@ -122,11 +122,11 @@ index c7c8fc5..689d611 100644 integer! { i32, u32 } integer! { i64, u64 } -integer! { i128, u128 } - + const DEC_DIGITS_LUT: &'static[u8] = b"0001020304050607080910111213141516171819\ @@ -250,7 +247,6 @@ macro_rules! impl_Display { - + impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); impl_Display!(i64, u64: to_u64); -impl_Display!(i128, u128: to_u128); @@ -190,7 +190,7 @@ index d5d29c9..f98f382 100644 - (u128, write_u128), - (i128, write_i128), } - + #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 66c09a0..1b8c5c9 100644 @@ -201,7 +201,7 @@ index 66c09a0..1b8c5c9 100644 #[cfg(not(target_pointer_width = "64"))] step_impl_no_between!(u64 i64); -step_impl_no_between!(u128 i128); - + macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs @@ -211,11 +211,11 @@ index e8c6cd8..f58b446 100644 @@ -901,7 +901,7 @@ macro_rules! float_sum_product { )*) } - + -integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } float_sum_product! { f32 f64 } - + /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 252d7da..3c13282 100644 @@ -226,14 +226,14 @@ index 252d7da..3c13282 100644 #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; -#[path = "num/i128.rs"] pub mod i128; - + #[path = "num/usize.rs"] pub mod usize; #[path = "num/u8.rs"] pub mod u8; #[path = "num/u16.rs"] pub mod u16; #[path = "num/u32.rs"] pub mod u32; #[path = "num/u64.rs"] pub mod u64; -#[path = "num/u128.rs"] pub mod u128; - + #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs @@ -242,7 +242,7 @@ index 53af924..243a4f3 100644 +++ b/src/libcore/marker.rs @@ -663,8 +663,8 @@ mod copy_impls { } - + impl_copy! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -279,11 +279,11 @@ index e776513..6018aea 100644 - NonZeroU128(u128); NonZeroUsize(usize); } - + @@ -2110,18 +2109,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } - + -#[lang = "i128"] -impl i128 { - int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, @@ -302,7 +302,7 @@ index e776513..6018aea 100644 @@ -4393,17 +4380,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } - + -#[lang = "u128"] -impl u128 { - uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16, @@ -323,7 +323,7 @@ index e776513..6018aea 100644 } -from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } +from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } - + /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] @@ -4603,30 +4579,25 @@ macro_rules! rev { @@ -331,19 +331,19 @@ index e776513..6018aea 100644 try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); -try_from_upper_bounded!(u128, u64, u32, u16, u8); - + try_from_both_bounded!(i16, i8); try_from_both_bounded!(i32, i16, i8); try_from_both_bounded!(i64, i32, i16, i8); -try_from_both_bounded!(i128, i64, i32, i16, i8); - + // unsigned-to-signed try_from_upper_bounded!(u8, i8); try_from_upper_bounded!(u16, i8, i16); try_from_upper_bounded!(u32, i8, i16, i32); try_from_upper_bounded!(u64, i8, i16, i32, i64); -try_from_upper_bounded!(u128, i8, i16, i32, i64, i128); - + // signed-to-unsigned -try_from_lower_bounded!(i8, u8, u16, u32, u64, u128); -try_from_lower_bounded!(i16, u16, u32, u64, u128); @@ -358,63 +358,63 @@ index e776513..6018aea 100644 try_from_both_bounded!(i32, u16, u8); try_from_both_bounded!(i64, u32, u16, u8); -try_from_both_bounded!(i128, u64, u32, u16, u8); - + // usize/isize try_from_upper_bounded!(usize, isize); @@ -4638,21 +4609,21 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8); - try_from_unbounded!(usize, u16, u32, u64, u128); + try_from_unbounded!(usize, u16, u32, u64); try_from_upper_bounded!(usize, i8, i16); - try_from_unbounded!(usize, i32, i64, i128); + try_from_unbounded!(usize, i32, i64); - + try_from_both_bounded!(isize, u8); - try_from_lower_bounded!(isize, u16, u32, u64, u128); + try_from_lower_bounded!(isize, u16, u32, u64); try_from_both_bounded!(isize, i8); - try_from_unbounded!(isize, i16, i32, i64, i128); + try_from_unbounded!(isize, i16, i32, i64); - + - rev!(try_from_upper_bounded, usize, u32, u64, u128); + rev!(try_from_upper_bounded, usize, u32, u64); rev!(try_from_lower_bounded, usize, i8, i16); - rev!(try_from_both_bounded, usize, i32, i64, i128); + rev!(try_from_both_bounded, usize, i32, i64); - + - rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); - rev!(try_from_both_bounded, isize, i32, i64, i128); + rev!(try_from_upper_bounded, isize, u16, u32, u64); + rev!(try_from_both_bounded, isize, i32, i64); } - + #[cfg(target_pointer_width = "32")] @@ -4661,24 +4632,24 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8, u16); - try_from_unbounded!(usize, u32, u64, u128); + try_from_unbounded!(usize, u32, u64); try_from_upper_bounded!(usize, i8, i16, i32); - try_from_unbounded!(usize, i64, i128); + try_from_unbounded!(usize, i64); - + try_from_both_bounded!(isize, u8, u16); - try_from_lower_bounded!(isize, u32, u64, u128); + try_from_lower_bounded!(isize, u32, u64); try_from_both_bounded!(isize, i8, i16); - try_from_unbounded!(isize, i32, i64, i128); + try_from_unbounded!(isize, i32, i64); - + rev!(try_from_unbounded, usize, u32); - rev!(try_from_upper_bounded, usize, u64, u128); + rev!(try_from_upper_bounded, usize, u64); rev!(try_from_lower_bounded, usize, i8, i16, i32); - rev!(try_from_both_bounded, usize, i64, i128); + rev!(try_from_both_bounded, usize, i64); - + rev!(try_from_unbounded, isize, u16); - rev!(try_from_upper_bounded, isize, u32, u64, u128); + rev!(try_from_upper_bounded, isize, u32, u64); @@ -422,36 +422,36 @@ index e776513..6018aea 100644 - rev!(try_from_both_bounded, isize, i64, i128); + rev!(try_from_both_bounded, isize, i64); } - + #[cfg(target_pointer_width = "64")] @@ -4687,24 +4658,20 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8, u16, u32); - try_from_unbounded!(usize, u64, u128); + try_from_unbounded!(usize, u64); try_from_upper_bounded!(usize, i8, i16, i32, i64); - try_from_unbounded!(usize, i128); - + try_from_both_bounded!(isize, u8, u16, u32); - try_from_lower_bounded!(isize, u64, u128); + try_from_lower_bounded!(isize, u64); try_from_both_bounded!(isize, i8, i16, i32); - try_from_unbounded!(isize, i64, i128); + try_from_unbounded!(isize, i64); - + rev!(try_from_unbounded, usize, u32, u64); - rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); - rev!(try_from_both_bounded, usize, i128); - + rev!(try_from_unbounded, isize, u16, u32); - rev!(try_from_upper_bounded, isize, u64, u128); + rev!(try_from_upper_bounded, isize, u64); rev!(try_from_unbounded, isize, i32, i64); - rev!(try_from_both_bounded, isize, i128); } - + #[doc(hidden)] @@ -4739,7 +4706,7 @@ macro_rules! doit { } @@ -459,7 +459,7 @@ index e776513..6018aea 100644 } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; @@ -4930,52 +4897,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -474,7 +474,7 @@ index e776513..6018aea 100644 impl_from_bool! { i64, #[stable(feature = "from_bool", since = "1.28.0")] } -impl_from_bool! { i128, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { isize, #[stable(feature = "from_bool", since = "1.28.0")] } - + // Unsigned -> Unsigned impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -487,7 +487,7 @@ index e776513..6018aea 100644 impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] } - + // Signed -> Signed impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -500,7 +500,7 @@ index e776513..6018aea 100644 impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // Unsigned -> Signed impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -512,7 +512,7 @@ index e776513..6018aea 100644 impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs @@ -525,7 +525,7 @@ index 50e189c..2da3b35 100644 //sh_impl_unsigned! { $t, u64 } - //sh_impl_unsigned! { $t, u128 } sh_impl_unsigned! { $t, usize } - + //sh_impl_signed! { $t, i8 } //sh_impl_signed! { $t, i16 } //sh_impl_signed! { $t, i32 } @@ -534,46 +534,46 @@ index 50e189c..2da3b35 100644 //sh_impl_signed! { $t, isize } )*) } - + -sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + // FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping macro_rules! wrapping_impl { @@ -313,7 +311,7 @@ macro_rules! wrapping_impl { )*) } - + -wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl { ($($t:ty)*) => ($( @@ -675,7 +673,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); )*) } - + -wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_int_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_signed { ($($t:ty)*) => ($( @@ -804,7 +802,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); )*) } - + -wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 } +wrapping_int_impl_signed! { isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_unsigned { ($($t:ty)*) => ($( @@ -881,7 +879,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); )*) } - + -wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 u128 } +wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 } - + mod shift_max { #![allow(non_upper_case_globals)] @@ -908,13 +906,11 @@ mod shift_max { @@ -582,7 +582,7 @@ index 50e189c..2da3b35 100644 pub const i64: u32 = (1 << 6) - 1; - pub const i128: u32 = (1 << 7) - 1; pub use self::platform::isize; - + pub const u8: u32 = i8; pub const u16: u32 = i16; pub const u32: u32 = i32; @@ -597,97 +597,97 @@ index 7d8bf18..91fd879 100644 @@ -104,7 +104,7 @@ macro_rules! add_impl { )*) } - + -add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction operator `-`. /// @@ -202,7 +202,7 @@ macro_rules! sub_impl { )*) } - + -sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication operator `*`. /// @@ -322,7 +322,7 @@ macro_rules! mul_impl { )*) } - + -mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division operator `/`. /// @@ -447,7 +447,7 @@ macro_rules! div_impl_integer { )*) } - + -div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! div_impl_float { ($($t:ty)*) => ($( @@ -532,7 +532,7 @@ macro_rules! rem_impl_integer { )*) } - + -rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - + + macro_rules! rem_impl_float { @@ -631,7 +631,7 @@ macro_rules! neg_impl_unsigned { } - + // neg_impl_unsigned! { usize u8 u16 u32 u64 } -neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } +neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } - + /// The addition assignment operator `+=`. /// @@ -687,7 +687,7 @@ macro_rules! add_assign_impl { )+) } - + -add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction assignment operator `-=`. /// @@ -743,7 +743,7 @@ macro_rules! sub_assign_impl { )+) } - + -sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication assignment operator `*=`. /// @@ -790,7 +790,7 @@ macro_rules! mul_assign_impl { )+) } - + -mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division assignment operator `/=`. /// @@ -836,7 +836,7 @@ macro_rules! div_assign_impl { )+) } - + -div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The remainder assignment operator `%=`. /// @@ -886,4 +886,4 @@ macro_rules! rem_assign_impl { )+) } - + -rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs @@ -697,37 +697,37 @@ index 2c9bf24..af2ab6f 100644 @@ -55,7 +55,7 @@ macro_rules! not_impl { )*) } - + -not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise AND operator `&`. /// @@ -139,7 +139,7 @@ macro_rules! bitand_impl { )*) } - + -bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR operator `|`. /// @@ -223,7 +223,7 @@ macro_rules! bitor_impl { )*) } - + -bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR operator `^`. /// @@ -310,7 +310,7 @@ macro_rules! bitxor_impl { )*) } - + -bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift operator `<<`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -407,19 +407,17 @@ macro_rules! shl_impl_all { @@ -736,7 +736,7 @@ index 2c9bf24..af2ab6f 100644 shl_impl! { $t, u64 } - shl_impl! { $t, u128 } shl_impl! { $t, usize } - + shl_impl! { $t, i8 } shl_impl! { $t, i16 } shl_impl! { $t, i32 } @@ -745,10 +745,10 @@ index 2c9bf24..af2ab6f 100644 shl_impl! { $t, isize } )*) } - + -shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } +shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift operator `>>`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -516,19 +514,17 @@ macro_rules! shr_impl_all { @@ -757,7 +757,7 @@ index 2c9bf24..af2ab6f 100644 shr_impl! { $t, u64 } - shr_impl! { $t, u128 } shr_impl! { $t, usize } - + shr_impl! { $t, i8 } shr_impl! { $t, i16 } shr_impl! { $t, i32 } @@ -766,37 +766,37 @@ index 2c9bf24..af2ab6f 100644 shr_impl! { $t, isize } )*) } - + -shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The bitwise AND assignment operator `&=`. /// @@ -616,7 +612,7 @@ macro_rules! bitand_assign_impl { )+) } - + -bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR assignment operator `|=`. /// @@ -665,7 +661,7 @@ macro_rules! bitor_assign_impl { )+) } - + -bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR assignment operator `^=`. /// @@ -714,7 +710,7 @@ macro_rules! bitxor_assign_impl { )+) } - + -bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift assignment operator `<<=`. /// @@ -770,19 +766,17 @@ macro_rules! shl_assign_impl_all { @@ -805,7 +805,7 @@ index 2c9bf24..af2ab6f 100644 shl_assign_impl! { $t, u64 } - shl_assign_impl! { $t, u128 } shl_assign_impl! { $t, usize } - + shl_assign_impl! { $t, i8 } shl_assign_impl! { $t, i16 } shl_assign_impl! { $t, i32 } @@ -814,10 +814,10 @@ index 2c9bf24..af2ab6f 100644 shl_assign_impl! { $t, isize } )*) } - + -shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift assignment operator `>>=`. /// @@ -838,16 +832,14 @@ macro_rules! shr_assign_impl_all { @@ -826,7 +826,7 @@ index 2c9bf24..af2ab6f 100644 shr_assign_impl! { $t, u64 } - shr_assign_impl! { $t, u128 } shr_assign_impl! { $t, usize } - + shr_assign_impl! { $t, i8 } shr_assign_impl! { $t, i16 } shr_assign_impl! { $t, i32 } @@ -835,7 +835,7 @@ index 2c9bf24..af2ab6f 100644 shr_assign_impl! { $t, isize } )*) } - + -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs @@ -887,13 +887,13 @@ index cf19851..6b4a72b 100644 type Bigger = u64; - #[cfg(target_pointer_width = "64")] - type Bigger = u128; - + #[derive(Clone)] struct Test(Bigger); @@ -1950,19 +1948,6 @@ fn test_step_replace_signed() { assert_eq!(y, 5); } - + -#[test] -fn test_step_replace_no_between() { - let mut x = 4u128; @@ -924,7 +924,7 @@ index a17c094..3c36d10 100644 test_impl_from! { test_booli32, bool, i32 } test_impl_from! { test_booli64, bool, i64 } -test_impl_from! { test_booli128, bool, i128 } - + // Signed -> Float test_impl_from! { test_i8f32, i8, f32 } @@ -265,51 +263,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } @@ -936,7 +936,7 @@ index a17c094..3c36d10 100644 test_impl_try_from_always_ok! { test_try_u8i32, u8, i32 } test_impl_try_from_always_ok! { test_try_u8i64, u8, i64 } -test_impl_try_from_always_ok! { test_try_u8i128, u8, i128 } - + test_impl_try_from_always_ok! { test_try_u16u16, u16, u16 } test_impl_try_from_always_ok! { test_try_u16u32, u16, u32 } test_impl_try_from_always_ok! { test_try_u16u64, u16, u64 } @@ -944,39 +944,39 @@ index a17c094..3c36d10 100644 test_impl_try_from_always_ok! { test_try_u16i32, u16, i32 } test_impl_try_from_always_ok! { test_try_u16i64, u16, i64 } -test_impl_try_from_always_ok! { test_try_u16i128, u16, i128 } - + test_impl_try_from_always_ok! { test_try_u32u32, u32, u32 } test_impl_try_from_always_ok! { test_try_u32u64, u32, u64 } -test_impl_try_from_always_ok! { test_try_u32u128, u32, u128 } test_impl_try_from_always_ok! { test_try_u32i64, u32, i64 } -test_impl_try_from_always_ok! { test_try_u32i128, u32, i128 } - + test_impl_try_from_always_ok! { test_try_u64u64, u64, u64 } -test_impl_try_from_always_ok! { test_try_u64u128, u64, u128 } -test_impl_try_from_always_ok! { test_try_u64i128, u64, i128 } - -test_impl_try_from_always_ok! { test_try_u128u128, u128, u128 } - + test_impl_try_from_always_ok! { test_try_i8i8, i8, i8 } test_impl_try_from_always_ok! { test_try_i8i16, i8, i16 } test_impl_try_from_always_ok! { test_try_i8i32, i8, i32 } test_impl_try_from_always_ok! { test_try_i8i64, i8, i64 } -test_impl_try_from_always_ok! { test_try_i8i128, i8, i128 } - + test_impl_try_from_always_ok! { test_try_i16i16, i16, i16 } test_impl_try_from_always_ok! { test_try_i16i32, i16, i32 } test_impl_try_from_always_ok! { test_try_i16i64, i16, i64 } -test_impl_try_from_always_ok! { test_try_i16i128, i16, i128 } - + test_impl_try_from_always_ok! { test_try_i32i32, i32, i32 } test_impl_try_from_always_ok! { test_try_i32i64, i32, i64 } -test_impl_try_from_always_ok! { test_try_i32i128, i32, i128 } - + test_impl_try_from_always_ok! { test_try_i64i64, i64, i64 } -test_impl_try_from_always_ok! { test_try_i64i128, i64, i128 } - -test_impl_try_from_always_ok! { test_try_i128i128, i128, i128 } - + test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs @@ -988,13 +988,13 @@ index b12ee04..fe0faad 100644 const MILLIS_PER_SEC: u64 = 1_000; const MICROS_PER_SEC: u64 = 1_000_000; -const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; - + /// A `Duration` type to represent a span of time, typically used for system /// timeouts. @@ -260,54 +259,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } - + - /// Returns the total number of whole milliseconds contained by this `Duration`. - /// - /// # Examples @@ -1049,7 +1049,7 @@ index b12ee04..fe0faad 100644 @@ -466,80 +417,6 @@ impl Duration { (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) } - + - /// Creates a new `Duration` from the specified number of seconds. - /// - /// # Panics @@ -1131,14 +1131,6 @@ diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 3051100..61001a4 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -248,7 +248,6 @@ - #![feature(const_cstr_unchecked)] - #![feature(core_intrinsics)] - #![feature(dropck_eyepatch)] --#![cfg_attr(stage0, feature(duration_as_u128))] - #![feature(exact_size_is_empty)] - #![feature(external_doc)] - #![feature(fixed_size_array)] @@ -404,8 +403,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] @@ -1156,7 +1148,7 @@ index 3051100..61001a4 100644 -pub use core::u128; #[stable(feature = "core_hint", since = "1.27.0")] pub use core::hint; - + diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 52a29f4..cafe50e 100644 --- a/src/libstd/net/ip.rs @@ -1164,7 +1156,7 @@ index 52a29f4..cafe50e 100644 @@ -1382,26 +1382,6 @@ impl FromInner for Ipv6Addr { } } - + -#[stable(feature = "i128", since = "1.26.0")] -impl From for u128 { - fn from(ip: Ipv6Addr) -> u128 { @@ -1194,11 +1186,11 @@ index c80b9a5..e32a6b3 100644 +++ b/src/libstd/num.rs @@ -12,7 +12,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} pub use core::num::Wrapping; - + #[stable(feature = "nonzero", since = "1.28.0")] -pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; +pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; - + #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs @@ -1212,7 +1204,7 @@ index d27f6ca..8ac2a44 100644 -#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicI128 {} - + #[cfg(target_has_atomic = "ptr")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] @@ -273,9 +270,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {} @@ -1222,9 +1214,8 @@ index d27f6ca..8ac2a44 100644 -#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicU128 {} - + #[cfg(target_has_atomic = "8")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] --- +-- 2.17.2 (Apple Git-113) - From 33a9cdfe85a627b7b74b46522b42401235fa86d8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 2 Jan 2019 11:55:02 +0100 Subject: [PATCH 0437/1566] Update Cargo.lock --- Cargo.lock | 75 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 1 - 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73547919e8af6..49aac7daf8fc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,13 +121,13 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,17 +143,17 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,18 +171,18 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c87da1a42e3da7a403ee78c1bafd239f07f3da5a" +source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -249,11 +249,11 @@ dependencies = [ [[package]] name = "faerie" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -266,16 +266,16 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -478,7 +478,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.44" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -486,7 +486,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -545,7 +545,6 @@ dependencies = [ "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -598,17 +597,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.83" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -616,7 +615,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -670,9 +669,9 @@ name = "target-lexicon" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -683,7 +682,7 @@ dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -702,7 +701,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -821,9 +820,9 @@ dependencies = [ "checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f869e12bcad2b4ff6ac60e01c2354957312fbf0c10dc938f340d58932b3db52" -"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7" -"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" +"checksum faerie 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0a95b10aca344ac134ebcd5e664ed7a904fed6852916006c66964fece6795cd8" +"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" +"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" @@ -849,7 +848,7 @@ dependencies = [ "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" "checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" -"checksum redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "a84bcd297b87a545980a2d25a0beb72a1f490c31f0a9fde52fca35bfbb1ceb70" +"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" @@ -862,8 +861,8 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.83 (registry+https://github.com/rust-lang/crates.io-index)" = "157e12af46859e968da75dea9845530e13d03bcab2009a41b9b7bb3cf4eb3ec2" -"checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" +"checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" +"checksum serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "bdf540260cfee6da923831f4776ddc495ada940c30117977c70f1313a6130545" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" diff --git a/Cargo.toml b/Cargo.toml index 1a8797c0c6aee..be43b8376087e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.2.0" #goblin = "0.0.17" -faerie = "0.6.0" ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.6" From c7101bbfd478cc63d867297190d4c7c8859a1058 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 2 Jan 2019 12:20:32 +0100 Subject: [PATCH 0438/1566] Some cleanup of abi.rs --- ripgrep | 1 + src/abi.rs | 48 ++++++++++++++++++++++++++---------------------- src/constant.rs | 5 +---- src/main_shim.rs | 6 +----- src/vtable.rs | 8 ++++++-- 5 files changed, 35 insertions(+), 33 deletions(-) create mode 160000 ripgrep diff --git a/ripgrep b/ripgrep new file mode 160000 index 0000000000000..118b950085ff6 --- /dev/null +++ b/ripgrep @@ -0,0 +1 @@ +Subproject commit 118b950085ff674c1c7142bc5e171dd2b4688934 diff --git a/src/abi.rs b/src/abi.rs index e859fe2a38f5b..50daf0090574f 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -71,14 +71,10 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( } } -fn clif_sig_from_fn_ty<'a, 'tcx: 'a>( +fn clif_sig_from_fn_sig<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - fn_ty: Ty<'tcx>, + sig: FnSig<'tcx>, ) -> Signature { - let sig = ty_fn_sig(tcx, fn_ty); - if sig.variadic { - unimpl!("Variadic function are not yet supported"); - } let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), @@ -181,22 +177,30 @@ pub fn get_function_name_and_sig<'a, 'tcx>( ) -> (String, Signature) { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_ty = inst.ty(tcx); - let sig = clif_sig_from_fn_ty(tcx, fn_ty); + let fn_sig = ty_fn_sig(tcx, fn_ty); + if fn_sig.variadic { + unimpl!("Variadic functions are not yet supported"); + } + let sig = clif_sig_from_fn_sig(tcx, fn_sig); (tcx.symbol_name(inst).as_str().to_string(), sig) } -impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { - /// Instance must be monomorphized - pub fn get_function_id(&mut self, inst: Instance<'tcx>) -> FuncId { - let (name, sig) = get_function_name_and_sig(self.tcx, inst); - self.module - .declare_function(&name, Linkage::Import, &sig) - .unwrap() - } +/// Instance must be monomorphized +pub fn import_function<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + inst: Instance<'tcx>, +) -> FuncId { + let (name, sig) = get_function_name_and_sig(tcx, inst); + module + .declare_function(&name, Linkage::Import, &sig) + .unwrap() +} +impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let func_id = self.get_function_id(inst); + let func_id = import_function(self.tcx, self.module, inst); let func_ref = self.module .declare_func_in_func(func_id, &mut self.bcx.func); @@ -574,11 +578,11 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( args: Vec>, ret_place: Option>, ) { - let sig = ty_fn_sig(fx.tcx, fn_ty); + let fn_sig = ty_fn_sig(fx.tcx, fn_ty); - let ret_layout = fx.layout_of(sig.output()); + let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fx.tcx, sig.abi, sig.output(), true); + let output_pass_mode = get_pass_mode(fx.tcx, fn_sig.abi, fn_sig.output(), true); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { @@ -614,7 +618,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( None }; - args.get(0).map(|arg| adjust_arg_for_abi(fx, sig, *arg)) + args.get(0).map(|arg| adjust_arg_for_abi(fx, fn_sig, *arg)) } .into_iter() }; @@ -625,12 +629,12 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( .chain( args.into_iter() .skip(1) - .map(|arg| adjust_arg_for_abi(fx, sig, arg)), + .map(|arg| adjust_arg_for_abi(fx, fn_sig, arg)), ) .collect::>(); - let sig = fx.bcx.import_signature(clif_sig_from_fn_ty(fx.tcx, fn_ty)); let call_inst = if let Some(func_ref) = func_ref { + let sig = fx.bcx.import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); fx.bcx.ins().call_indirect(sig, func_ref, &call_args) } else { let func_ref = fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); diff --git a/src/constant.rs b/src/constant.rs index 1b3cd0c0b3609..56900a4fa020c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -254,10 +254,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { AllocKind::Function(instance) => { - let (func_name, sig) = crate::abi::get_function_name_and_sig(tcx, instance); - let func_id = module - .declare_function(&func_name, Linkage::Import, &sig) - .unwrap(); + let func_id = crate::abi::import_function(tcx, module, instance); let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx); data_ctx.write_function_addr(reloc_offset as u32, local_func_id); continue; diff --git a/src/main_shim.rs b/src/main_shim.rs index aec03838ce9e5..ab0422e211b20 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -81,11 +81,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( tcx.intern_substs(&[main_ret_ty.into()]), ) .unwrap(); - - let (start_name, start_sig) = get_function_name_and_sig(tcx, start_instance); - let start_func_id = m - .declare_function(&start_name, Linkage::Import, &start_sig) - .unwrap(); + let start_func_id = import_function(tcx, m, start_instance); let main_val = bcx .ins() diff --git a/src/vtable.rs b/src/vtable.rs index bdf0c9e2f5448..2944330fbe606 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -73,7 +73,9 @@ fn build_vtable<'a, 'tcx: 'a>( let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; - let drop_in_place_fn = fx.get_function_id( + let drop_in_place_fn = import_function( + tcx, + fx.module, crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty), ); @@ -83,7 +85,9 @@ fn build_vtable<'a, 'tcx: 'a>( let methods = tcx.vtable_methods(trait_ref); let methods = methods.iter().cloned().map(|opt_mth| { opt_mth.map_or(None, |(def_id, substs)| { - Some(fx.get_function_id( + Some(import_function( + tcx, + fx.module, Instance::resolve(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), )) }) From a15af1ccba0564073514d04f804ff9d2ed8d8172 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 2 Jan 2019 13:37:56 +0100 Subject: [PATCH 0439/1566] Rename load_value to load_scalar and make it support all Abi::Scalar types --- src/abi.rs | 39 ++++++++++++++++++++++++++++++--------- src/base.rs | 30 +++++++++++++++--------------- src/common.rs | 24 +++++++++--------------- src/intrinsics.rs | 4 ++-- src/unsize.rs | 2 +- 5 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 50daf0090574f..d3bf41e79951e 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::iter; use rustc::hir; +use rustc::ty::layout::{Scalar, Primitive, Integer, FloatTy}; use rustc_target::spec::abi::Abi; use crate::prelude::*; @@ -23,6 +24,23 @@ impl PassMode { } } +pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { + match scalar.value { + Primitive::Int(int, _sign) => match int { + Integer::I8 => types::I8, + Integer::I16 => types::I16, + Integer::I32 => types::I32, + Integer::I64 => types::I64, + Integer::I128 => unimpl!("u/i128"), + } + Primitive::Float(flt) => match flt { + FloatTy::F32 => types::F32, + FloatTy::F64 => types::F64, + } + Primitive::Pointer => pointer_ty(tcx), + } +} + fn get_pass_mode<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, abi: Abi, @@ -66,7 +84,7 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( ) -> Value { match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => arg.load_value(fx), + PassMode::ByVal(_) => arg.load_scalar(fx), PassMode::ByRef => arg.force_stack(fx), } } @@ -251,7 +269,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { .map(|arg| { ( self.clif_type(arg.layout().ty).unwrap(), - arg.load_value(self), + arg.load_scalar(self), ) }) .unzip(); @@ -441,13 +459,16 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let null = fx.bcx.ins().iconst(fx.pointer_type, 0); fx.local_map.insert( RETURN_PLACE, - CPlace::Addr(null, None, fx.layout_of(fx.return_type())), + CPlace::Addr(null, None, ret_layout), ); } - PassMode::ByVal(ret_ty) => { - fx.bcx.declare_var(mir_var(RETURN_PLACE), ret_ty); - fx.local_map - .insert(RETURN_PLACE, CPlace::Var(RETURN_PLACE, ret_layout)); + PassMode::ByVal(_) => { + let is_ssa = !ssa_analyzed + .get(&RETURN_PLACE) + .unwrap() + .contains(crate::analyze::Flags::NOT_SSA); + + local_place(fx, RETURN_PLACE, ret_layout, is_ssa); } PassMode::ByRef => { fx.local_map.insert( @@ -613,7 +634,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( } else { func_ref = if instance.is_none() { let func = trans_operand(fx, func.expect("indirect call without func Operand")); - Some(func.load_value(fx)) + Some(func.load_scalar(fx)) } else { None }; @@ -660,7 +681,7 @@ pub fn codegen_return(fx: &mut FunctionCx) { } PassMode::ByVal(_) => { let place = fx.get_local_place(RETURN_PLACE); - let ret_val = place.to_cvalue(fx).load_value(fx); + let ret_val = place.to_cvalue(fx).load_scalar(fx); fx.bcx.ins().return_(&[ret_val]); } } diff --git a/src/base.rs b/src/base.rs index 18e45cf9c3608..f780a86515a9d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -184,7 +184,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) target, cleanup: _, } => { - let cond = trans_operand(fx, cond).load_value(fx); + let cond = trans_operand(fx, cond).load_scalar(fx); // TODO HACK brz/brnz for i8/i16 is not yet implemented let cond = fx.bcx.ins().uextend(types::I32, cond); let target = fx.get_ebb(*target); @@ -202,7 +202,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) values, targets, } => { - let discr = trans_operand(fx, discr).load_value(fx); + let discr = trans_operand(fx, discr).load_scalar(fx); let mut switch = ::cranelift::frontend::Switch::new(); for (i, value) in values.iter().enumerate() { let ebb = fx.get_ebb(targets[i]); @@ -430,7 +430,7 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::UnaryOp(un_op, operand) => { let operand = trans_operand(fx, operand); let layout = operand.layout(); - let val = operand.load_value(fx); + let val = operand.load_scalar(fx); let res = match un_op { UnOp::Not => { match layout.ty.sty { @@ -492,7 +492,7 @@ fn trans_stmt<'a, 'tcx: 'a>( | (ty::Uint(_), ty::Char) | (ty::Uint(_), ty::Int(_)) | (ty::Uint(_), ty::Uint(_)) => { - let from = operand.load_value(fx); + let from = operand.load_scalar(fx); let res = crate::common::clif_intcast( fx, from, @@ -502,7 +502,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Int(_), ty::Int(_)) | (ty::Int(_), ty::Uint(_)) => { - let from = operand.load_value(fx); + let from = operand.load_scalar(fx); let res = crate::common::clif_intcast( fx, from, @@ -512,7 +512,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Float(from_flt), ty::Float(to_flt)) => { - let from = operand.load_value(fx); + let from = operand.load_scalar(fx); let res = match (from_flt, to_flt) { (FloatTy::F32, FloatTy::F64) => { fx.bcx.ins().fpromote(types::F64, from) @@ -526,7 +526,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } (ty::Int(_), ty::Float(_)) => { let from_ty = fx.clif_type(from_ty).unwrap(); - let from = operand.load_value(fx); + let from = operand.load_scalar(fx); // FIXME missing encoding for fcvt_from_sint.f32.i8 let from = if from_ty == types::I8 || from_ty == types::I16 { fx.bcx.ins().sextend(types::I32, from) @@ -539,7 +539,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } (ty::Uint(_), ty::Float(_)) => { let from_ty = fx.clif_type(from_ty).unwrap(); - let from = operand.load_value(fx); + let from = operand.load_scalar(fx); // FIXME missing encoding for fcvt_from_uint.f32.i8 let from = if from_ty == types::I8 || from_ty == types::I16 { fx.bcx.ins().uextend(types::I32, from) @@ -552,7 +552,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } (ty::Bool, ty::Uint(_)) | (ty::Bool, ty::Int(_)) => { let to_ty = fx.clif_type(to_ty).unwrap(); - let from = operand.load_value(fx); + let from = operand.load_scalar(fx); let res = if to_ty != types::I8 { fx.bcx.ins().uextend(to_ty, from) } else { @@ -695,7 +695,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let discr = value.value_field(fx, mir::Field::new(0)); let discr_ty = discr.layout().ty; - let lldiscr = discr.load_value(fx); + let lldiscr = discr.load_scalar(fx); match layout.variants { layout::Variants::Single { .. } => bug!(), layout::Variants::Tagged { ref tag, .. } => { @@ -782,8 +782,8 @@ macro_rules! binop_match { $var:ident ($sign:pat) $name:tt $( ( $($next:tt)* ) )? ; )* ) => {{ - let lhs = $lhs.load_value($fx); - let rhs = $rhs.load_value($fx); + let lhs = $lhs.load_scalar($fx); + let rhs = $rhs.load_scalar($fx); match ($bin_op, $signed) { $( (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, $signed, lhs, rhs, $ret_ty, $name $( ( $($next)* ) )?), @@ -887,8 +887,8 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( ); } - let lhs = in_lhs.load_value(fx); - let rhs = in_rhs.load_value(fx); + let lhs = in_lhs.load_scalar(fx); + let rhs = in_rhs.load_scalar(fx); let res = match bin_op { BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), @@ -1060,7 +1060,7 @@ pub fn trans_place<'a, 'tcx: 'a>( ProjectionElem::Deref => base.place_deref(fx), ProjectionElem::Field(field, _ty) => base.place_field(fx, field), ProjectionElem::Index(local) => { - let index = fx.get_local_place(local).to_cvalue(fx).load_value(fx); + let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx); base.place_index(fx, index) } ProjectionElem::ConstantIndex { diff --git a/src/common.rs b/src/common.rs index 433334aa41754..dad252d008ab4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -151,24 +151,18 @@ impl<'tcx> CValue<'tcx> { } } - pub fn load_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value + /// Load a value with layout.abi of scalar + pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value where 'tcx: 'a, { match self { CValue::ByRef(addr, layout) => { - let clif_ty = fx.clif_type(layout.ty).unwrap_or_else(|| { - if layout.ty.is_box() - && !fx - .layout_of(layout.ty.builtin_deref(true).unwrap().ty) - .is_unsized() - { - // Consider sized box to be a ptr - pointer_ty(fx.tcx) - } else { - panic!("load_value of type {:?}", layout.ty); - } - }); + let scalar = match layout.abi { + layout::Abi::Scalar(ref scalar) => scalar.clone(), + _ => unreachable!(), + }; + let clif_ty = crate::abi::scalar_to_clif_type(fx.tcx, scalar); fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, @@ -355,7 +349,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match self { CPlace::Var(var, _) => { - let data = from.load_value(fx); + let data = from.load_scalar(fx); fx.bcx.def_var(mir_var(var), data) } CPlace::Addr(addr, None, dst_layout) => { @@ -454,7 +448,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn place_deref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); if !inner_layout.is_unsized() { - CPlace::Addr(self.to_cvalue(fx).load_value(fx), None, inner_layout) + CPlace::Addr(self.to_cvalue(fx).load_scalar(fx), None, inner_layout) } else { match self.layout().abi { Abi::ScalarPair(ref a, ref b) => { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 62800132dff5b..a487012f96a55 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -14,7 +14,7 @@ macro_rules! intrinsic_arg { $arg }; (v $fx:expr, $arg:ident) => { - $arg.load_value($fx) + $arg.load_scalar($fx) }; } @@ -358,7 +358,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("atomic_load"), (c ptr) { let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); - let val = CValue::ByRef(ptr.load_value(fx), inner_layout); + let val = CValue::ByRef(ptr.load_scalar(fx), inner_layout); ret.write_cvalue(fx, val); }; _ if intrinsic.starts_with("atomic_store"), (v ptr, c val) { diff --git a/src/unsize.rs b/src/unsize.rs index f8f918fa8aa26..6837754a55246 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -97,7 +97,7 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a>( // i.e., &'a fmt::Debug+Send => &'a fmt::Debug src.load_value_pair(fx) } else { - let base = src.load_value(fx); + let base = src.load_scalar(fx); unsize_thin_ptr(fx, base, src_ty, dst_ty) }; dst.write_cvalue(fx, CValue::ByValPair(base, info, dst.layout())); From 144ff955d61597371e927850e3fb5ccf7ec3da02 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 2 Jan 2019 14:03:56 +0100 Subject: [PATCH 0440/1566] Use layout.abi --- src/abi.rs | 59 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index d3bf41e79951e..864fc26927f65 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -43,46 +43,45 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { fn get_pass_mode<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - abi: Abi, ty: Ty<'tcx>, is_return: bool, ) -> PassMode { - assert!(!tcx + let layout = tcx .layout_of(ParamEnv::reveal_all().and(ty)) - .unwrap() - .is_unsized()); - if let ty::Never = ty.sty { - if is_return { - PassMode::NoPass - } else { - PassMode::ByRef - } - } else if ty.sty == tcx.mk_unit().sty { + .unwrap(); + assert!(!layout.is_unsized()); + + if layout.size.bytes() == 0 { if is_return { PassMode::NoPass } else { PassMode::ByRef } - } else if let Some(ret_ty) = crate::common::clif_type_from_ty(tcx, ty) { - PassMode::ByVal(ret_ty) } else { - if abi == Abi::C { - unimpl!( - "Non scalars are not yet supported for \"C\" abi ({:?}) is_return: {:?}", - ty, - is_return - ); + match &layout.abi { + layout::Abi::Uninhabited => { + if is_return { + PassMode::NoPass + } else { + PassMode::ByRef + } + } + layout::Abi::Scalar(scalar) => PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())), + + // FIXME implement ScalarPair and Vector Abi in a cg_llvm compatible way + layout::Abi::ScalarPair(_, _) => PassMode::ByRef, + layout::Abi::Vector { .. } => PassMode::ByRef, + + layout::Abi::Aggregate { .. } => PassMode::ByRef, } - PassMode::ByRef } } fn adjust_arg_for_abi<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - sig: FnSig<'tcx>, arg: CValue<'tcx>, ) -> Value { - match get_pass_mode(fx.tcx, sig.abi, arg.layout().ty, false) { + match get_pass_mode(fx.tcx, arg.layout().ty, false) { PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByVal(_) => arg.load_scalar(fx), PassMode::ByRef => arg.force_stack(fx), @@ -113,13 +112,13 @@ fn clif_sig_from_fn_sig<'a, 'tcx: 'a>( let inputs = inputs .into_iter() - .filter_map(|ty| match get_pass_mode(tcx, sig.abi, ty, false) { + .filter_map(|ty| match get_pass_mode(tcx, ty, false) { PassMode::ByVal(clif_ty) => Some(clif_ty), PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByRef => Some(pointer_ty(tcx)), }); - let (params, returns) = match get_pass_mode(tcx, sig.abi, output, true) { + let (params, returns) = match get_pass_mode(tcx, output, true) { PassMode::NoPass => (inputs.map(AbiParam::new).collect(), vec![]), PassMode::ByVal(ret_ty) => ( inputs.map(AbiParam::new).collect(), @@ -374,7 +373,7 @@ fn cvalue_for_param<'a, 'tcx: 'a>( ssa_flags: crate::analyze::Flags, ) -> CValue<'tcx> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, arg_ty, false); + let pass_mode = get_pass_mode(fx.tcx, arg_ty, false); let clif_type = pass_mode.get_param_ty(fx); let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); @@ -398,7 +397,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); let ret_layout = fx.layout_of(fx.return_type()); - let output_pass_mode = get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true); + let output_pass_mode = get_pass_mode(fx.tcx, fx.return_type(), true); let ret_param = match output_pass_mode { PassMode::NoPass => None, PassMode::ByVal(_) => None, @@ -603,7 +602,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fx.tcx, fn_sig.abi, fn_sig.output(), true); + let output_pass_mode = get_pass_mode(fx.tcx, fn_sig.output(), true); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { @@ -639,7 +638,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( None }; - args.get(0).map(|arg| adjust_arg_for_abi(fx, fn_sig, *arg)) + args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)) } .into_iter() }; @@ -650,7 +649,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( .chain( args.into_iter() .skip(1) - .map(|arg| adjust_arg_for_abi(fx, fn_sig, arg)), + .map(|arg| adjust_arg_for_abi(fx, arg)), ) .collect::>(); @@ -675,7 +674,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( } pub fn codegen_return(fx: &mut FunctionCx) { - match get_pass_mode(fx.tcx, fx.self_sig().abi, fx.return_type(), true) { + match get_pass_mode(fx.tcx, fx.return_type(), true) { PassMode::NoPass | PassMode::ByRef => { fx.bcx.ins().return_(&[]); } From 705e06c1bdef022847a10cff9d5897bcecb0da79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 3 Jan 2019 06:15:01 +0000 Subject: [PATCH 0441/1566] Bump cranelift from `c00d8ae` to `aaf819d` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `c00d8ae` to `aaf819d`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/c00d8ae6e04190d39db44b020e284b978b18ef09...aaf819d6b162e1000957217efc131a6ad9ee18eb) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 49aac7daf8fc9..916b887a81b1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#c00d8ae6e04190d39db44b020e284b978b18ef09" +source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From 28ab957afa5b265cefe5c279aa704ced4c50a640 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 3 Jan 2019 18:10:58 +0100 Subject: [PATCH 0442/1566] Remove accidentially included submodule ripgrep --- ripgrep | 1 - 1 file changed, 1 deletion(-) delete mode 160000 ripgrep diff --git a/ripgrep b/ripgrep deleted file mode 160000 index 118b950085ff6..0000000000000 --- a/ripgrep +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 118b950085ff674c1c7142bc5e171dd2b4688934 From 284a5aac383e44e99de96b35cb5d506024950993 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 4 Jan 2019 05:33:27 +0000 Subject: [PATCH 0443/1566] Bump cranelift from `aaf819d` to `48ec9dc` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `aaf819d` to `48ec9dc`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/aaf819d6b162e1000957217efc131a6ad9ee18eb...48ec9dc0b667b7f9741ccf42e1843e2b762b77d4) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 916b887a81b1e..fd6ce4ae65832 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#aaf819d6b162e1000957217efc131a6ad9ee18eb" +source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From 8a586eb6cb7609a055273b2e5fd105157fd2c124 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Jan 2019 15:27:20 +0100 Subject: [PATCH 0444/1566] Rustup to rustc 1.33.0-nightly (68fe5182c 2019-01-05) --- src/constant.rs | 19 +++++++++---------- src/intrinsics.rs | 5 +++++ src/lib.rs | 2 +- src/vtable.rs | 15 ++++++++++----- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 56900a4fa020c..a4177552cb3a0 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; -use rustc::ty::Const; +use rustc::ty::{Const, LazyConst}; use rustc_mir::interpret::{ EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, }; @@ -61,7 +61,6 @@ pub fn trans_promoted<'a, 'tcx: 'a>( })) .unwrap(); - let const_ = force_eval_const(fx, const_); trans_const_place(fx, const_) } @@ -76,10 +75,10 @@ pub fn trans_constant<'a, 'tcx: 'a>( pub fn force_eval_const<'a, 'tcx: 'a>( fx: &FunctionCx<'a, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, -) -> &'tcx Const<'tcx> { - match const_.val { - ConstValue::Unevaluated(def_id, ref substs) => { + const_: &'tcx LazyConst<'tcx>, +) -> Const<'tcx> { + match *const_ { + LazyConst::Unevaluated(def_id, ref substs) => { let param_env = ParamEnv::reveal_all(); let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap(); let cid = GlobalId { @@ -88,13 +87,13 @@ pub fn force_eval_const<'a, 'tcx: 'a>( }; fx.tcx.const_eval(param_env.and(cid)).unwrap() } - _ => const_, + LazyConst::Evaluated(const_) => const_, } } fn trans_const_value<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, + const_: Const<'tcx>, ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); @@ -124,7 +123,7 @@ fn trans_const_value<'a, 'tcx: 'a>( fn trans_const_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, + const_: Const<'tcx>, ) -> CPlace<'tcx> { // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 let result = || -> EvalResult<'tcx, &'tcx Allocation> { @@ -146,7 +145,7 @@ fn trans_const_place<'a, 'tcx: 'a>( span: DUMMY_SP, ty: const_.ty, user_ty: None, - literal: const_, + literal: fx.tcx.intern_lazy_const(LazyConst::Evaluated(const_)), })), None, )?; diff --git a/src/intrinsics.rs b/src/intrinsics.rs index a487012f96a55..2b0c44c2f6f53 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -352,6 +352,11 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); ret.write_cvalue(fx, needs_drop); }; + panic_if_uninhabited, () { + if fx.layout_of(T).abi.is_uninhabited() { + crate::trap::trap_panic(&mut fx.bcx); + } + }; _ if intrinsic.starts_with("atomic_fence"), () {}; _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; diff --git a/src/lib.rs b/src/lib.rs index a9a6895d46b94..7df9b6ae42eeb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,7 +103,7 @@ mod prelude { pub struct Caches<'tcx> { pub context: Context, - pub vtables: HashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), DataId>, + pub vtables: HashMap<(Ty<'tcx>, Option>), DataId>, } impl<'tcx> Default for Caches<'tcx> { diff --git a/src/vtable.rs b/src/vtable.rs index 2944330fbe606..61455c6a70a09 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -51,7 +51,7 @@ pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( pub fn get_vtable<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, - trait_ref: ty::PolyExistentialTraitRef<'tcx>, + trait_ref: Option>, ) -> Value { let data_id = if let Some(data_id) = fx.caches.vtables.get(&(ty, trait_ref)) { *data_id @@ -68,7 +68,7 @@ pub fn get_vtable<'a, 'tcx: 'a>( fn build_vtable<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, - trait_ref: ty::PolyExistentialTraitRef<'tcx>, + trait_ref: Option>, ) -> DataId { let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; @@ -81,9 +81,14 @@ fn build_vtable<'a, 'tcx: 'a>( let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; - let trait_ref = trait_ref.with_self_ty(tcx, ty); - let methods = tcx.vtable_methods(trait_ref); - let methods = methods.iter().cloned().map(|opt_mth| { + let methods_root; + let methods = if let Some(trait_ref) = trait_ref { + methods_root = tcx.vtable_methods(trait_ref.with_self_ty(tcx, ty)); + methods_root.iter() + } else { + (&[]).iter() + }; + let methods = methods.cloned().map(|opt_mth| { opt_mth.map_or(None, |(def_id, substs)| { Some(import_function( tcx, From 5e6ac305355e7df7becdd23e7e225d1717bf705d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 8 Jan 2019 15:08:46 +0100 Subject: [PATCH 0445/1566] Rustup to rustc 1.33.0-nightly (8e2063d02 2019-01-07) --- patches/0002-Disable-u128-and-i128-in-libcore.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index c060b7c188279..81622ec9f4363 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -989,8 +989,8 @@ index b12ee04..fe0faad 100644 const MICROS_PER_SEC: u64 = 1_000_000; -const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; - /// A `Duration` type to represent a span of time, typically used for system - /// timeouts. + /// The duration of one second. + #[unstable(feature = "duration_constants", issue = "57391")] @@ -260,54 +259,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } From 9b0a340af1c17aeb79dbe012fef221e62352fef2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 8 Jan 2019 14:57:37 +0000 Subject: [PATCH 0446/1566] Bump cranelift from `48ec9dc` to `4b698c2` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `48ec9dc` to `4b698c2`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/48ec9dc0b667b7f9741ccf42e1843e2b762b77d4...4b698c2b3b5ec4702a5494c6636a723d5b6df466) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd6ce4ae65832..1b41c71e28311 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#48ec9dc0b667b7f9741ccf42e1843e2b762b77d4" +source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From 5a931acb48bb9a8e1b638c494d3d05b6daa428cb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 12 Jan 2019 12:37:12 +0100 Subject: [PATCH 0447/1566] Improve global name for anonymous allocations --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index a4177552cb3a0..861526653c0c9 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -165,7 +165,7 @@ fn trans_const_place<'a, 'tcx: 'a>( fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) -> DataId { module - .declare_data(&alloc_id.0.to_string(), Linkage::Local, false) + .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false) .unwrap() } From 72b01d6b772f72705c093ca2e08d28a269a30321 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 13 Jan 2019 11:15:38 +0100 Subject: [PATCH 0448/1566] Rustup to rustc 1.33.0-nightly (75a369c5b 2019-01-12) --- ...me-more-unsupported-stuff-in-libcore.patch | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch diff --git a/patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch b/patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch deleted file mode 100644 index 1310b95749d43..0000000000000 --- a/patches/0004-Disable-some-more-unsupported-stuff-in-libcore.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3d1907db6e349aa7e6cfe3dd490a9d10db669872 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Thu, 23 Aug 2018 11:15:01 +0200 -Subject: [PATCH] Disable some more unsupported stuff in libcore - ---- - src/libcore/num/mod.rs | 8 ++++++-- - 1 files changed, 8 insertions(+), 2 deletions(-) - -diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 5d00949..f077f1d 100644 ---- a/src/libcore/num/mod.rs -+++ b/src/libcore/num/mod.rs -@@ -2273,7 +2273,9 @@ assert_eq!(m, ", $swapped, "); - #[rustc_const_unstable(feature = "const_int_ops")] - #[inline] - pub const fn swap_bytes(self) -> Self { -- unsafe { intrinsics::bswap(self as $ActualT) as Self } -+ // TODO support bswap -+ //unsafe { intrinsics::bswap(self as $ActualT) as Self } -+ 0 - } - } - --- -2.11.0 From 335dd707a411b9309c3d4d88720a7c9ce380ddc7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 14 Jan 2019 06:34:33 +0000 Subject: [PATCH 0449/1566] Bump faerie from 0.7.0 to 0.7.1 Bumps [faerie](https://github.com/m4b/faerie) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/m4b/faerie/releases) - [Commits](https://github.com/m4b/faerie/commits) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b41c71e28311..1b49c6abb23d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,7 +152,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a54 dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -249,7 +249,7 @@ dependencies = [ [[package]] name = "faerie" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -820,7 +820,7 @@ dependencies = [ "checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0a95b10aca344ac134ebcd5e664ed7a904fed6852916006c66964fece6795cd8" +"checksum faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "142ee8f6d2864117a92855815e710b03087763df41ab3c6a97ca25e00e178b98" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" From 8aee796013d94a81d71274cdda349e265368de07 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 15 Jan 2019 20:35:49 +0100 Subject: [PATCH 0450/1566] Update Cargo.lock and use emit_small_memcpy --- Cargo.lock | 122 +++++++++++++++++++++++++++++--------------------- src/common.rs | 29 +++--------- 2 files changed, 77 insertions(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b49c6abb23d1..a4d04525c46fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -45,8 +45,8 @@ dependencies = [ "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -56,7 +56,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,13 +192,13 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#4b698c2b3b5ec4702a5494c6636a723d5b6df466" +source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -234,7 +234,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -244,7 +244,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -280,7 +280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -346,7 +346,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.45" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -362,7 +362,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -371,7 +371,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -403,29 +403,28 @@ dependencies = [ [[package]] name = "rand" -version = "0.6.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_chacha" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -449,6 +448,19 @@ dependencies = [ "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_os" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_pcg" version = "0.1.1" @@ -460,7 +472,7 @@ dependencies = [ [[package]] name = "rand_xorshift" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -476,6 +488,14 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "redox_syscall" version = "0.1.50" @@ -515,7 +535,7 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -530,7 +550,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -545,7 +565,7 @@ dependencies = [ "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -579,7 +599,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -602,7 +622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -640,12 +660,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.23" +version = "0.15.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -660,7 +680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -671,7 +691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -680,8 +700,8 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -700,7 +720,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -832,7 +852,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74" +"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" @@ -840,21 +860,23 @@ dependencies = [ "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" -"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a" -"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a" +"checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" +"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +"checksum rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46fbd5550acf75b0c2730f5dd1873751daf9beb8f11b44027778fae50d7feca" "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" -"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3" +"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cff177f64744f6f2a2054d231279383e59b0857b4d58dc2e8881e60b58aec8e5" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "01b90379b8664dd83460d59bdc5dd1fd3172b8913788db483ed1325171eab2f7" +"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" @@ -862,12 +884,12 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" -"checksum serde_json 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "bdf540260cfee6da923831f4776ddc495ada940c30117977c70f1313a6130545" +"checksum serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "dfb1277d4d0563e4593e0b8b5d23d744d277b55d2bc0bf1c38d0d8a6589d38aa" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" "checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" -"checksum syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9545a6a093a3f0bd59adb472700acc08cad3776f860f16a897dfce8c88721cbc" +"checksum syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)" = "71b7693d9626935a362a3d1d4e59380800a919ebfa478d77a4f49e2a6d2c3ad5" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" "checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" diff --git a/src/common.rs b/src/common.rs index dad252d008ab4..d5e07be302c46 100644 --- a/src/common.rs +++ b/src/common.rs @@ -363,30 +363,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); } - CValue::ByRef(from, _src_layout) => { - let size = dst_layout.size.bytes() as i32; - // FIXME emit_small_memcpy has a bug as of commit CraneStation/cranelift@b2281ed - // fx.bcx.emit_small_memcpy(fx.module.target_config(), addr, from, size, layout.align.abi() as u8, src_layout.align.abi() as u8); - - let mut offset = 0; - while size - offset >= 8 { - let byte = - fx.bcx - .ins() - .load(fx.pointer_type, MemFlags::new(), from, offset); - fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); - offset += 8; - } - while size - offset >= 4 { - let byte = fx.bcx.ins().load(types::I32, MemFlags::new(), from, offset); - fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); - offset += 4; - } - while offset < size { - let byte = fx.bcx.ins().load(types::I8, MemFlags::new(), from, offset); - fx.bcx.ins().store(MemFlags::new(), byte, addr, offset); - offset += 1; - } + CValue::ByRef(from, src_layout) => { + let size = dst_layout.size.bytes(); + let src_align = src_layout.align.abi.bytes() as u8; + let dst_align = dst_layout.align.abi.bytes() as u8; + fx.bcx.emit_small_memcpy(fx.module.target_config(), addr, from, size, dst_align, src_align); } } } From 5fe65b0e3ae46feb9c3999b51cb3cfeae8a045ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 16 Jan 2019 05:53:57 +0000 Subject: [PATCH 0451/1566] Bump syn from 0.15.25 to 0.15.26 Bumps [syn](https://github.com/dtolnay/syn) from 0.15.25 to 0.15.26. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/0.15.25...0.15.26) Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4d04525c46fc..9c2ba59bf2fce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,7 +280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -599,7 +599,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -660,12 +660,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.25" +version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -680,7 +680,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -889,7 +889,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" "checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" -"checksum syn 0.15.25 (registry+https://github.com/rust-lang/crates.io-index)" = "71b7693d9626935a362a3d1d4e59380800a919ebfa478d77a4f49e2a6d2c3ad5" +"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" "checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" From 2c4d27450a5fc9e9e7d942242dd388acc19ac249 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Jan 2019 18:21:20 +0100 Subject: [PATCH 0452/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c2ba59bf2fce..2babd02e6234c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#990e1a427691002ebeeaa06ce433970894608b27" +source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From ede81e7ee218abee7bce443fa873d32c00296b52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 17 Jan 2019 06:48:53 +0000 Subject: [PATCH 0453/1566] Bump cranelift from `78b2535` to `a7ea916` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `78b2535` to `a7ea916`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/78b2535947c249f9c1181e158f12aa3e9c88d76b...a7ea916dcd8e2849f9271324ce3814db36fd43e9) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2babd02e6234c..3ebbdb7f3ed73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -143,12 +143,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" [[package]] name = "cranelift-faerie" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -182,7 +182,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#78b2535947c249f9c1181e158f12aa3e9c88d76b" +source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" dependencies = [ "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", From 4dcb5f4399e59ec4829e6d699c960ea8198b23eb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 18 Jan 2019 17:42:48 +0100 Subject: [PATCH 0454/1566] Update Cargo.lock --- Cargo.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ebbdb7f3ed73..eef2313262164 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,7 +34,7 @@ dependencies = [ [[package]] name = "autocfg" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -42,7 +42,7 @@ name = "backtrace" version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", @@ -278,7 +278,7 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -382,7 +382,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.24" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -398,7 +398,7 @@ name = "quote" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -406,7 +406,7 @@ name = "rand" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -423,7 +423,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -597,7 +597,7 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -622,7 +622,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -658,7 +658,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -668,7 +668,7 @@ name = "syn" version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -678,7 +678,7 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -691,7 +691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -817,7 +817,7 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e5f34df7a019573fb8bdc7e24a2bfebe51a2a1d6bfdbaeccedb3c41fc574727" +"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" @@ -857,7 +857,7 @@ dependencies = [ "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" +"checksum proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)" = "d3797b7142c9aa74954e351fc089bbee7958cebbff6bf2815e7ffff0b19f547d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" @@ -884,7 +884,7 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" -"checksum serde_json 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "dfb1277d4d0563e4593e0b8b5d23d744d277b55d2bc0bf1c38d0d8a6589d38aa" +"checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" From c728530bd0b3a43bedaecc98f0f915df6a21c0b6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Jan 2019 11:47:56 +0100 Subject: [PATCH 0455/1566] Rustup to rustc 1.33.0-nightly (c76f3c374 2019-01-18) --- ...le-inline-assembly-in-hint-spin_loop.patch | 30 +++++++++++++++++ ...le-inline-assembly-in-spin_loop_hint.patch | 32 ------------------- 2 files changed, 30 insertions(+), 32 deletions(-) create mode 100644 patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch delete mode 100644 patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch diff --git a/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch b/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch new file mode 100644 index 0000000000000..700c48e493566 --- /dev/null +++ b/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch @@ -0,0 +1,30 @@ +From 50ce3e454d5721cb534a9e9bb73c82246b930bab Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 19 Jan 2019 11:46:43 +0100 +Subject: [PATCH] Disable inline assembly in hint::spin_loop + +--- + src/libcore/hint.rs | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs +index ad5a207..04712b8 100644 +--- a/src/libcore/hint.rs ++++ b/src/libcore/hint.rs +@@ -62,6 +62,7 @@ pub unsafe fn unreachable_unchecked() -> ! { + #[inline] + #[unstable(feature = "renamed_spin_loop", issue = "55002")] + pub fn spin_loop() { ++ /* + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + unsafe { + asm!("pause" ::: "memory" : "volatile"); +@@ -71,4 +72,5 @@ pub fn spin_loop() { + unsafe { + asm!("yield" ::: "memory" : "volatile"); + } ++ */ + } +-- +2.17.2 (Apple Git-113) + diff --git a/patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch b/patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch deleted file mode 100644 index e2e2406697471..0000000000000 --- a/patches/0003-Disable-inline-assembly-in-spin_loop_hint.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 6a5c292f9f9e28de4319f52b05744ed7d8863f76 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 6 Oct 2018 10:22:16 +0200 -Subject: [PATCH] Disable inline assembly in spin_loop_hint - ---- - src/libcore/sync/atomic.rs | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index f130dbf..31db7a2 100644 ---- a/src/libcore/sync/atomic.rs -+++ b/src/libcore/sync/atomic.rs -@@ -106,6 +106,7 @@ use fmt; - #[inline] - #[stable(feature = "spin_loop_hint", since = "1.24.0")] - pub fn spin_loop_hint() { -+ /* - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - unsafe { - asm!("pause" ::: "memory" : "volatile"); -@@ -115,6 +116,7 @@ pub fn spin_loop_hint() { - unsafe { - asm!("yield" ::: "memory" : "volatile"); - } -+ */ - } - - /// A boolean type which can be safely shared between threads. --- -2.17.1 (Apple Git-112) - From 9e609db886864cfc324fa54df98f04b006ec994b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 11:59:34 +0100 Subject: [PATCH 0456/1566] Rustup to rustc 1.33.0-nightly (bf669d1e3 2019-01-25) --- ...002-Disable-u128-and-i128-in-libcore.patch | 347 +++++++++--------- src/main_shim.rs | 6 +- 2 files changed, 180 insertions(+), 173 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 81622ec9f4363..64e5592f2a9f6 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From 84040eb5ffeecaeb13863ff6d4106d6e4e2daaa9 Mon Sep 17 00:00:00 2001 +From 76c92b0dcd7919dab3a48d707d615f260390b839 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Fri, 28 Dec 2018 10:31:59 +0100 +Date: Sat, 26 Jan 2019 11:50:08 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -14,7 +14,7 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/lib.rs | 2 - src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 99 ++++++++-------------------- + src/libcore/num/mod.rs | 100 ++++++++-------------------- src/libcore/num/wrapping.rs | 14 ++-- src/libcore/ops/arith.rs | 22 +++---- src/libcore/ops/bit.rs | 30 ++++----- @@ -22,19 +22,19 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/tests/iter.rs | 15 ----- src/libcore/tests/num/mod.rs | 18 ----- src/libcore/time.rs | 123 ----------------------------------- - src/libstd/lib.rs | 5 -- + src/libstd/lib.rs | 4 -- src/libstd/net/ip.rs | 20 ------ src/libstd/num.rs | 2 +- src/libstd/panic.rs | 6 -- 22 files changed, 63 insertions(+), 368 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs -index 74b3ce4..9617ed1 100644 +index ed90b7d..1739f91 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs -@@ -162,8 +162,8 @@ mod impls { +@@ -173,8 +173,8 @@ mod impls { } - + impl_clone! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -44,34 +44,34 @@ index 74b3ce4..9617ed1 100644 bool char } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index 9336b13..8faa03f 100644 +index d43a5c1..268e5f1 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs -@@ -873,7 +873,7 @@ mod impls { +@@ -876,7 +876,7 @@ mod impls { } - + partial_eq_impl! { - bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 + bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + macro_rules! eq_impl { -@@ -883,7 +883,7 @@ mod impls { +@@ -886,7 +886,7 @@ mod impls { )*) } - + - eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! partial_ord_impl { ($($t:ty)*) => ($( -@@ -972,7 +972,7 @@ mod impls { +@@ -975,7 +975,7 @@ mod impls { } } - + - ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } + ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/src/libcore/default.rs b/src/libcore/default.rs @@ -83,14 +83,14 @@ index 0e47c2f..570b949 100644 default_impl! { u32, 0, "Returns the default value of `0`" } default_impl! { u64, 0, "Returns the default value of `0`" } -default_impl! { u128, 0, "Returns the default value of `0`" } - + default_impl! { isize, 0, "Returns the default value of `0`" } default_impl! { i8, 0, "Returns the default value of `0`" } default_impl! { i16, 0, "Returns the default value of `0`" } default_impl! { i32, 0, "Returns the default value of `0`" } default_impl! { i64, 0, "Returns the default value of `0`" } -default_impl! { i128, 0, "Returns the default value of `0`" } - + default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs @@ -103,7 +103,7 @@ index c7c8fc5..689d611 100644 fn to_u64(&self) -> u64; - fn to_u128(&self) -> u128; } - + macro_rules! doit { @@ -30,10 +29,9 @@ macro_rules! doit { fn to_u16(&self) -> u16 { *self as u16 } @@ -114,7 +114,7 @@ index c7c8fc5..689d611 100644 } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + /// A type that represents a specific radix #[doc(hidden)] @@ -174,7 +172,6 @@ integer! { i8, u8 } @@ -122,11 +122,11 @@ index c7c8fc5..689d611 100644 integer! { i32, u32 } integer! { i64, u64 } -integer! { i128, u128 } - + const DEC_DIGITS_LUT: &'static[u8] = b"0001020304050607080910111213141516171819\ @@ -250,7 +247,6 @@ macro_rules! impl_Display { - + impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); impl_Display!(i64, u64: to_u64); -impl_Display!(i128, u128: to_u128); @@ -190,7 +190,7 @@ index d5d29c9..f98f382 100644 - (u128, write_u128), - (i128, write_i128), } - + #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 66c09a0..1b8c5c9 100644 @@ -201,7 +201,7 @@ index 66c09a0..1b8c5c9 100644 #[cfg(not(target_pointer_width = "64"))] step_impl_no_between!(u64 i64); -step_impl_no_between!(u128 i128); - + macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs @@ -211,38 +211,38 @@ index e8c6cd8..f58b446 100644 @@ -901,7 +901,7 @@ macro_rules! float_sum_product { )*) } - + -integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } float_sum_product! { f32 f64 } - + /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 252d7da..3c13282 100644 +index 74a7115..634df60 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -145,14 +145,12 @@ mod uint_macros; +@@ -149,14 +149,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; -#[path = "num/i128.rs"] pub mod i128; - + #[path = "num/usize.rs"] pub mod usize; #[path = "num/u8.rs"] pub mod u8; #[path = "num/u16.rs"] pub mod u16; #[path = "num/u32.rs"] pub mod u32; #[path = "num/u64.rs"] pub mod u64; -#[path = "num/u128.rs"] pub mod u128; - + #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 53af924..243a4f3 100644 +index 65752ba..d3b797a 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -663,8 +663,8 @@ mod copy_impls { } - + impl_copy! { - usize u8 u16 u32 u64 u128 - isize i8 i16 i32 i64 i128 @@ -252,7 +252,7 @@ index 53af924..243a4f3 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index c024868..e512596 100644 +index 8fcbb73..0e20b88 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -163,12 +163,10 @@ pub fn forget_unsized(t: T) { @@ -269,21 +269,27 @@ index c024868..e512596 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index e776513..6018aea 100644 +index 423b800..b2b3f90 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs -@@ -102,7 +102,6 @@ nonzero_integers! { - NonZeroU16(u16); - NonZeroU32(u32); - NonZeroU64(u64); -- NonZeroU128(u128); - NonZeroUsize(usize); +@@ -102,13 +102,11 @@ nonzero_integers! { + #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16); + #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32); + #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU64(u64); +- #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU128(u128); + #[stable(feature = "nonzero", since = "1.28.0")] NonZeroUsize(usize); + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI8(i8); + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI16(i16); + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI32(i32); + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI64(i64); +- #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI128(i128); + #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); } - -@@ -2110,18 +2109,6 @@ impl i64 { + +@@ -2125,18 +2123,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } - + -#[lang = "i128"] -impl i128 { - int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, @@ -299,10 +305,10 @@ index e776513..6018aea 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4393,17 +4380,6 @@ impl u64 { +@@ -4440,17 +4426,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } - + -#[lang = "u128"] -impl u128 { - uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16, @@ -317,33 +323,33 @@ index e776513..6018aea 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4487,7 +4463,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4534,7 +4509,7 @@ macro_rules! from_str_radix_int_impl { } )*} } -from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } +from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } - + /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4603,30 +4579,25 @@ macro_rules! rev { +@@ -4650,30 +4625,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); -try_from_upper_bounded!(u128, u64, u32, u16, u8); - + try_from_both_bounded!(i16, i8); try_from_both_bounded!(i32, i16, i8); try_from_both_bounded!(i64, i32, i16, i8); -try_from_both_bounded!(i128, i64, i32, i16, i8); - + // unsigned-to-signed try_from_upper_bounded!(u8, i8); try_from_upper_bounded!(u16, i8, i16); try_from_upper_bounded!(u32, i8, i16, i32); try_from_upper_bounded!(u64, i8, i16, i32, i64); -try_from_upper_bounded!(u128, i8, i16, i32, i64, i128); - + // signed-to-unsigned -try_from_lower_bounded!(i8, u8, u16, u32, u64, u128); -try_from_lower_bounded!(i16, u16, u32, u64, u128); @@ -358,63 +364,63 @@ index e776513..6018aea 100644 try_from_both_bounded!(i32, u16, u8); try_from_both_bounded!(i64, u32, u16, u8); -try_from_both_bounded!(i128, u64, u32, u16, u8); - + // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4638,21 +4609,21 @@ mod ptr_try_from_impls { +@@ -4685,21 +4655,21 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8); - try_from_unbounded!(usize, u16, u32, u64, u128); + try_from_unbounded!(usize, u16, u32, u64); try_from_upper_bounded!(usize, i8, i16); - try_from_unbounded!(usize, i32, i64, i128); + try_from_unbounded!(usize, i32, i64); - + try_from_both_bounded!(isize, u8); - try_from_lower_bounded!(isize, u16, u32, u64, u128); + try_from_lower_bounded!(isize, u16, u32, u64); try_from_both_bounded!(isize, i8); - try_from_unbounded!(isize, i16, i32, i64, i128); + try_from_unbounded!(isize, i16, i32, i64); - + - rev!(try_from_upper_bounded, usize, u32, u64, u128); + rev!(try_from_upper_bounded, usize, u32, u64); rev!(try_from_lower_bounded, usize, i8, i16); - rev!(try_from_both_bounded, usize, i32, i64, i128); + rev!(try_from_both_bounded, usize, i32, i64); - + - rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); - rev!(try_from_both_bounded, isize, i32, i64, i128); + rev!(try_from_upper_bounded, isize, u16, u32, u64); + rev!(try_from_both_bounded, isize, i32, i64); } - + #[cfg(target_pointer_width = "32")] -@@ -4661,24 +4632,24 @@ mod ptr_try_from_impls { +@@ -4708,24 +4678,24 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8, u16); - try_from_unbounded!(usize, u32, u64, u128); + try_from_unbounded!(usize, u32, u64); try_from_upper_bounded!(usize, i8, i16, i32); - try_from_unbounded!(usize, i64, i128); + try_from_unbounded!(usize, i64); - + try_from_both_bounded!(isize, u8, u16); - try_from_lower_bounded!(isize, u32, u64, u128); + try_from_lower_bounded!(isize, u32, u64); try_from_both_bounded!(isize, i8, i16); - try_from_unbounded!(isize, i32, i64, i128); + try_from_unbounded!(isize, i32, i64); - + rev!(try_from_unbounded, usize, u32); - rev!(try_from_upper_bounded, usize, u64, u128); + rev!(try_from_upper_bounded, usize, u64); rev!(try_from_lower_bounded, usize, i8, i16, i32); - rev!(try_from_both_bounded, usize, i64, i128); + rev!(try_from_both_bounded, usize, i64); - + rev!(try_from_unbounded, isize, u16); - rev!(try_from_upper_bounded, isize, u32, u64, u128); + rev!(try_from_upper_bounded, isize, u32, u64); @@ -422,47 +428,47 @@ index e776513..6018aea 100644 - rev!(try_from_both_bounded, isize, i64, i128); + rev!(try_from_both_bounded, isize, i64); } - + #[cfg(target_pointer_width = "64")] -@@ -4687,24 +4658,20 @@ mod ptr_try_from_impls { +@@ -4734,24 +4704,20 @@ mod ptr_try_from_impls { use convert::TryFrom; - + try_from_upper_bounded!(usize, u8, u16, u32); - try_from_unbounded!(usize, u64, u128); + try_from_unbounded!(usize, u64); try_from_upper_bounded!(usize, i8, i16, i32, i64); - try_from_unbounded!(usize, i128); - + try_from_both_bounded!(isize, u8, u16, u32); - try_from_lower_bounded!(isize, u64, u128); + try_from_lower_bounded!(isize, u64); try_from_both_bounded!(isize, i8, i16, i32); - try_from_unbounded!(isize, i64, i128); + try_from_unbounded!(isize, i64); - + rev!(try_from_unbounded, usize, u32, u64); - rev!(try_from_upper_bounded, usize, u128); rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); - rev!(try_from_both_bounded, usize, i128); - + rev!(try_from_unbounded, isize, u16, u32); - rev!(try_from_upper_bounded, isize, u64, u128); + rev!(try_from_upper_bounded, isize, u64); rev!(try_from_unbounded, isize, i32, i64); - rev!(try_from_both_bounded, isize, i128); } - + #[doc(hidden)] -@@ -4739,7 +4706,7 @@ macro_rules! doit { +@@ -4786,7 +4752,7 @@ macro_rules! doit { } })*) } -doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } +doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - + fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4930,52 +4897,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4977,52 +4943,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -474,7 +480,7 @@ index e776513..6018aea 100644 impl_from_bool! { i64, #[stable(feature = "from_bool", since = "1.28.0")] } -impl_from_bool! { i128, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { isize, #[stable(feature = "from_bool", since = "1.28.0")] } - + // Unsigned -> Unsigned impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -487,7 +493,7 @@ index e776513..6018aea 100644 impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] } - + // Signed -> Signed impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -500,7 +506,7 @@ index e776513..6018aea 100644 impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // Unsigned -> Signed impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } @@ -512,7 +518,7 @@ index e776513..6018aea 100644 impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } -impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] } -impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] } - + // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs @@ -525,7 +531,7 @@ index 50e189c..2da3b35 100644 //sh_impl_unsigned! { $t, u64 } - //sh_impl_unsigned! { $t, u128 } sh_impl_unsigned! { $t, usize } - + //sh_impl_signed! { $t, i8 } //sh_impl_signed! { $t, i16 } //sh_impl_signed! { $t, i32 } @@ -534,46 +540,46 @@ index 50e189c..2da3b35 100644 //sh_impl_signed! { $t, isize } )*) } - + -sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + // FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping macro_rules! wrapping_impl { @@ -313,7 +311,7 @@ macro_rules! wrapping_impl { )*) } - + -wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl { ($($t:ty)*) => ($( @@ -675,7 +673,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); )*) } - + -wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +wrapping_int_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_signed { ($($t:ty)*) => ($( @@ -804,7 +802,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); )*) } - + -wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 } +wrapping_int_impl_signed! { isize i8 i16 i32 i64 } - + macro_rules! wrapping_int_impl_unsigned { ($($t:ty)*) => ($( @@ -881,7 +879,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); )*) } - + -wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 u128 } +wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 } - + mod shift_max { #![allow(non_upper_case_globals)] @@ -908,13 +906,11 @@ mod shift_max { @@ -582,7 +588,7 @@ index 50e189c..2da3b35 100644 pub const i64: u32 = (1 << 6) - 1; - pub const i128: u32 = (1 << 7) - 1; pub use self::platform::isize; - + pub const u8: u32 = i8; pub const u16: u32 = i16; pub const u32: u32 = i32; @@ -597,97 +603,97 @@ index 7d8bf18..91fd879 100644 @@ -104,7 +104,7 @@ macro_rules! add_impl { )*) } - + -add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction operator `-`. /// @@ -202,7 +202,7 @@ macro_rules! sub_impl { )*) } - + -sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication operator `*`. /// @@ -322,7 +322,7 @@ macro_rules! mul_impl { )*) } - + -mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division operator `/`. /// @@ -447,7 +447,7 @@ macro_rules! div_impl_integer { )*) } - + -div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + macro_rules! div_impl_float { ($($t:ty)*) => ($( @@ -532,7 +532,7 @@ macro_rules! rem_impl_integer { )*) } - + -rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - + + macro_rules! rem_impl_float { @@ -631,7 +631,7 @@ macro_rules! neg_impl_unsigned { } - + // neg_impl_unsigned! { usize u8 u16 u32 u64 } -neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } +neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } - + /// The addition assignment operator `+=`. /// @@ -687,7 +687,7 @@ macro_rules! add_assign_impl { )+) } - + -add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The subtraction assignment operator `-=`. /// @@ -743,7 +743,7 @@ macro_rules! sub_assign_impl { )+) } - + -sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The multiplication assignment operator `*=`. /// @@ -790,7 +790,7 @@ macro_rules! mul_assign_impl { )+) } - + -mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The division assignment operator `/=`. /// @@ -836,7 +836,7 @@ macro_rules! div_assign_impl { )+) } - + -div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - + /// The remainder assignment operator `%=`. /// @@ -886,4 +886,4 @@ macro_rules! rem_assign_impl { )+) } - + -rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } +rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs @@ -697,37 +703,37 @@ index 2c9bf24..af2ab6f 100644 @@ -55,7 +55,7 @@ macro_rules! not_impl { )*) } - + -not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise AND operator `&`. /// @@ -139,7 +139,7 @@ macro_rules! bitand_impl { )*) } - + -bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR operator `|`. /// @@ -223,7 +223,7 @@ macro_rules! bitor_impl { )*) } - + -bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR operator `^`. /// @@ -310,7 +310,7 @@ macro_rules! bitxor_impl { )*) } - + -bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift operator `<<`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -407,19 +407,17 @@ macro_rules! shl_impl_all { @@ -736,7 +742,7 @@ index 2c9bf24..af2ab6f 100644 shl_impl! { $t, u64 } - shl_impl! { $t, u128 } shl_impl! { $t, usize } - + shl_impl! { $t, i8 } shl_impl! { $t, i16 } shl_impl! { $t, i32 } @@ -745,10 +751,10 @@ index 2c9bf24..af2ab6f 100644 shl_impl! { $t, isize } )*) } - + -shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } +shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift operator `>>`. Note that because this trait is implemented /// for all integer types with multiple right-hand-side types, Rust's type @@ -516,19 +514,17 @@ macro_rules! shr_impl_all { @@ -757,7 +763,7 @@ index 2c9bf24..af2ab6f 100644 shr_impl! { $t, u64 } - shr_impl! { $t, u128 } shr_impl! { $t, usize } - + shr_impl! { $t, i8 } shr_impl! { $t, i16 } shr_impl! { $t, i32 } @@ -766,37 +772,37 @@ index 2c9bf24..af2ab6f 100644 shr_impl! { $t, isize } )*) } - + -shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The bitwise AND assignment operator `&=`. /// @@ -616,7 +612,7 @@ macro_rules! bitand_assign_impl { )+) } - + -bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise OR assignment operator `|=`. /// @@ -665,7 +661,7 @@ macro_rules! bitor_assign_impl { )+) } - + -bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The bitwise XOR assignment operator `^=`. /// @@ -714,7 +710,7 @@ macro_rules! bitxor_assign_impl { )+) } - + -bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } +bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - + /// The left shift assignment operator `<<=`. /// @@ -770,19 +766,17 @@ macro_rules! shl_assign_impl_all { @@ -805,7 +811,7 @@ index 2c9bf24..af2ab6f 100644 shl_assign_impl! { $t, u64 } - shl_assign_impl! { $t, u128 } shl_assign_impl! { $t, usize } - + shl_assign_impl! { $t, i8 } shl_assign_impl! { $t, i16 } shl_assign_impl! { $t, i32 } @@ -814,10 +820,10 @@ index 2c9bf24..af2ab6f 100644 shl_assign_impl! { $t, isize } )*) } - + -shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - + /// The right shift assignment operator `>>=`. /// @@ -838,16 +832,14 @@ macro_rules! shr_assign_impl_all { @@ -826,7 +832,7 @@ index 2c9bf24..af2ab6f 100644 shr_assign_impl! { $t, u64 } - shr_assign_impl! { $t, u128 } shr_assign_impl! { $t, usize } - + shr_assign_impl! { $t, i8 } shr_assign_impl! { $t, i16 } shr_assign_impl! { $t, i32 } @@ -835,14 +841,14 @@ index 2c9bf24..af2ab6f 100644 shr_assign_impl! { $t, isize } )*) } - + -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index 99e6365..d863e33 100644 +index 8992e51..c1babcd 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs -@@ -1943,34 +1943,6 @@ atomic_int! { +@@ -1937,34 +1937,6 @@ atomic_int! { 8, u64 AtomicU64 ATOMIC_U64_INIT } @@ -878,22 +884,22 @@ index 99e6365..d863e33 100644 macro_rules! ptr_width { () => { 2 } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index cf19851..6b4a72b 100644 +index 0fa9974..75b44b1 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs -@@ -214,8 +214,6 @@ fn test_iterator_step_by_nth_overflow() { +@@ -215,8 +215,6 @@ fn test_iterator_step_by_nth_overflow() { type Bigger = u32; #[cfg(target_pointer_width = "32")] type Bigger = u64; - #[cfg(target_pointer_width = "64")] - type Bigger = u128; - + #[derive(Clone)] struct Test(Bigger); -@@ -1950,19 +1948,6 @@ fn test_step_replace_signed() { +@@ -1968,19 +1966,6 @@ fn test_step_replace_signed() { assert_eq!(y, 5); } - + -#[test] -fn test_step_replace_no_between() { - let mut x = 4u128; @@ -924,7 +930,7 @@ index a17c094..3c36d10 100644 test_impl_from! { test_booli32, bool, i32 } test_impl_from! { test_booli64, bool, i64 } -test_impl_from! { test_booli128, bool, i128 } - + // Signed -> Float test_impl_from! { test_i8f32, i8, f32 } @@ -265,51 +263,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } @@ -936,7 +942,7 @@ index a17c094..3c36d10 100644 test_impl_try_from_always_ok! { test_try_u8i32, u8, i32 } test_impl_try_from_always_ok! { test_try_u8i64, u8, i64 } -test_impl_try_from_always_ok! { test_try_u8i128, u8, i128 } - + test_impl_try_from_always_ok! { test_try_u16u16, u16, u16 } test_impl_try_from_always_ok! { test_try_u16u32, u16, u32 } test_impl_try_from_always_ok! { test_try_u16u64, u16, u64 } @@ -944,43 +950,43 @@ index a17c094..3c36d10 100644 test_impl_try_from_always_ok! { test_try_u16i32, u16, i32 } test_impl_try_from_always_ok! { test_try_u16i64, u16, i64 } -test_impl_try_from_always_ok! { test_try_u16i128, u16, i128 } - + test_impl_try_from_always_ok! { test_try_u32u32, u32, u32 } test_impl_try_from_always_ok! { test_try_u32u64, u32, u64 } -test_impl_try_from_always_ok! { test_try_u32u128, u32, u128 } test_impl_try_from_always_ok! { test_try_u32i64, u32, i64 } -test_impl_try_from_always_ok! { test_try_u32i128, u32, i128 } - + test_impl_try_from_always_ok! { test_try_u64u64, u64, u64 } -test_impl_try_from_always_ok! { test_try_u64u128, u64, u128 } -test_impl_try_from_always_ok! { test_try_u64i128, u64, i128 } - -test_impl_try_from_always_ok! { test_try_u128u128, u128, u128 } - + test_impl_try_from_always_ok! { test_try_i8i8, i8, i8 } test_impl_try_from_always_ok! { test_try_i8i16, i8, i16 } test_impl_try_from_always_ok! { test_try_i8i32, i8, i32 } test_impl_try_from_always_ok! { test_try_i8i64, i8, i64 } -test_impl_try_from_always_ok! { test_try_i8i128, i8, i128 } - + test_impl_try_from_always_ok! { test_try_i16i16, i16, i16 } test_impl_try_from_always_ok! { test_try_i16i32, i16, i32 } test_impl_try_from_always_ok! { test_try_i16i64, i16, i64 } -test_impl_try_from_always_ok! { test_try_i16i128, i16, i128 } - + test_impl_try_from_always_ok! { test_try_i32i32, i32, i32 } test_impl_try_from_always_ok! { test_try_i32i64, i32, i64 } -test_impl_try_from_always_ok! { test_try_i32i128, i32, i128 } - + test_impl_try_from_always_ok! { test_try_i64i64, i64, i64 } -test_impl_try_from_always_ok! { test_try_i64i128, i64, i128 } - -test_impl_try_from_always_ok! { test_try_i128i128, i128, i128 } - + test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index b12ee04..fe0faad 100644 +index a751965..5d162cb 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -21,7 +21,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; @@ -988,13 +994,13 @@ index b12ee04..fe0faad 100644 const MILLIS_PER_SEC: u64 = 1_000; const MICROS_PER_SEC: u64 = 1_000_000; -const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; - + /// The duration of one second. #[unstable(feature = "duration_constants", issue = "57391")] -@@ -260,54 +259,6 @@ impl Duration { +@@ -276,54 +275,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } - + - /// Returns the total number of whole milliseconds contained by this `Duration`. - /// - /// # Examples @@ -1046,10 +1052,10 @@ index b12ee04..fe0faad 100644 /// Checked `Duration` addition. Computes `self + other`, returning [`None`] /// if overflow occurred. /// -@@ -466,80 +417,6 @@ impl Duration { +@@ -482,80 +433,6 @@ impl Duration { (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) } - + - /// Creates a new `Duration` from the specified number of seconds. - /// - /// # Panics @@ -1128,10 +1134,10 @@ index b12ee04..fe0faad 100644 /// /// # Examples diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 3051100..61001a4 100644 +index f395813..d81f80b 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -404,8 +403,6 @@ pub use core::i16; +@@ -401,8 +401,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -1140,7 +1146,7 @@ index 3051100..61001a4 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -438,8 +435,6 @@ pub use alloc_crate::string; +@@ -435,8 +433,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -1148,15 +1154,15 @@ index 3051100..61001a4 100644 -pub use core::u128; #[stable(feature = "core_hint", since = "1.27.0")] pub use core::hint; - + diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index 52a29f4..cafe50e 100644 +index f98113e..6c41e4e 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -1382,26 +1382,6 @@ impl FromInner for Ipv6Addr { } } - + -#[stable(feature = "i128", since = "1.26.0")] -impl From for u128 { - fn from(ip: Ipv6Addr) -> u128 { @@ -1186,11 +1192,11 @@ index c80b9a5..e32a6b3 100644 +++ b/src/libstd/num.rs @@ -12,7 +12,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} pub use core::num::Wrapping; - + #[stable(feature = "nonzero", since = "1.28.0")] -pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; +pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; - + #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs @@ -1204,7 +1210,7 @@ index d27f6ca..8ac2a44 100644 -#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicI128 {} - + #[cfg(target_has_atomic = "ptr")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] @@ -273,9 +270,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {} @@ -1214,8 +1220,9 @@ index d27f6ca..8ac2a44 100644 -#[cfg(target_has_atomic = "128")] -#[unstable(feature = "integer_atomics", issue = "32976")] -impl RefUnwindSafe for atomic::AtomicU128 {} - + #[cfg(target_has_atomic = "8")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] --- +-- 2.17.2 (Apple Git-113) + diff --git a/src/main_shim.rs b/src/main_shim.rs index ab0422e211b20..446089fc9a161 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -9,9 +9,9 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( use rustc::middle::lang_items::StartFnLangItem; use rustc::session::config::EntryFnType; - let (main_def_id, use_start_lang_item) = match *tcx.sess.entry_fn.borrow() { - Some((id, _, entry_ty)) => ( - tcx.hir().local_def_id(id), + let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) { + Some((def_id, entry_ty)) => ( + def_id, match entry_ty { EntryFnType::Main => true, EntryFnType::Start => false, From 09c4569c87f813773f00d30ad3ce4df94416e56f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 17 Jan 2019 18:07:27 +0100 Subject: [PATCH 0457/1566] Implement line debuginfo --- Cargo.lock | 42 +++ Cargo.toml | 7 +- abc.cpp | 35 ++ example/mini_core_hello_world.rs | 11 + mini_core_hello_world | Bin 0 -> 25736 bytes src/base.rs | 20 +- src/common.rs | 8 + src/debuginfo.rs | 529 +++++++++++++++++++++++++++++++ src/lib.rs | 50 ++- test.sh | 8 +- 10 files changed, 691 insertions(+), 19 deletions(-) create mode 100644 abc.cpp create mode 100755 mini_core_hello_world create mode 100644 src/debuginfo.rs diff --git a/Cargo.lock b/Cargo.lock index eef2313262164..c4f89330377fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,6 +22,14 @@ dependencies = [ "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "arrayvec" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.11" @@ -284,6 +292,11 @@ dependencies = [ "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fallible-iterator" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -303,6 +316,18 @@ name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "gimli" +version = "0.16.1" +source = "git+https://github.com/bjorn3/gimli.git?branch=impl_range_write#ff96c190bbb7a41623f009c969cb7ecd7a2716f4" +dependencies = [ + "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "goblin" version = "0.0.19" @@ -375,6 +400,11 @@ dependencies = [ "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nodrop" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "plain" version = "0.2.3" @@ -565,6 +595,8 @@ dependencies = [ "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "gimli 0.16.1 (git+https://github.com/bjorn3/gimli.git?branch=impl_range_write)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -630,6 +662,11 @@ dependencies = [ "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "stable_deref_trait" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "string-interner" version = "0.6.3" @@ -816,6 +853,7 @@ dependencies = [ "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" +"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" @@ -843,9 +881,11 @@ dependencies = [ "checksum faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "142ee8f6d2864117a92855815e710b03087763df41ab3c6a97ca25e00e178b98" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +"checksum fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eb7217124812dc5672b7476d0c2d20cfe9f7c0f1ba0904b674a9762a0212f72e" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum gimli 0.16.1 (git+https://github.com/bjorn3/gimli.git?branch=impl_range_write)" = "" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" @@ -856,6 +896,7 @@ dependencies = [ "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" +"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)" = "d3797b7142c9aa74954e351fc089bbee7958cebbff6bf2815e7ffff0b19f547d" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -885,6 +926,7 @@ dependencies = [ "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" "checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" +"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" diff --git a/Cargo.toml b/Cargo.toml index be43b8376087e..30824626feb26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,10 +23,12 @@ target-lexicon = "0.2.0" #goblin = "0.0.17" ar = "0.6.1" bitflags = "1.0.3" -byteorder = "1.2.6" +byteorder = "1.2.7" libc = "0.2.45" tempfile = "3.0.4" env_logger = "0.6" +gimli = { git = "https://github.com/gimli-rs/gimli.git" } +faerie = "0.7.1" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] @@ -35,5 +37,8 @@ env_logger = "0.6" #cranelift-simplejit = { path = "../cranelift/lib/simplejit" } #cranelift-faerie = { path = "../cranelift/lib/faerie" } +[patch."https://github.com/gimli-rs/gimli.git"] +gimli = { git = "https://github.com/bjorn3/gimli.git", branch = "impl_range_write" } + [profile.dev.overrides."*"] opt-level = 3 diff --git a/abc.cpp b/abc.cpp new file mode 100644 index 0000000000000..7f131fdd8fd78 --- /dev/null +++ b/abc.cpp @@ -0,0 +1,35 @@ +// compile using g++ -std=c++11 -g -c abc.cpp -o abc.o + +struct Opaque; + +struct MyType { + unsigned int field_a; + int field_b; + void* field_c; + float field_d; + //double field_e; + //long long field_f; + bool field_g; + char field_h; + Opaque* field_i; +}; + +MyType bcd(int x, MyType a) { + MyType b = a; + MyType c = b; + MyType d = c; + MyType e = d; + MyType f = e; + MyType g = f; + MyType h = g; + MyType i = h; + MyType j = i; + MyType k = j; + MyType l = k; + MyType m = l; + return b; +} +int main() { + bcd(42, {}); + return 0; +} diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index c4140ceaf1ec6..638db7d24ef95 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -115,7 +115,18 @@ struct Unique { impl CoerceUnsized> for Unique where T: Unsize {} +fn take_f32(f: f32) {} +fn take_unique(u: Unique<()>) {} + fn main() { + take_unique(Unique { + pointer: 0 as *const (), + _marker: PhantomData, + }); + take_f32(0.1); + + //return; + unsafe { let hello: &[u8] = b"Hello\0" as &[u8; 6]; let ptr: *const u8 = hello as *const [u8] as *const u8; diff --git a/mini_core_hello_world b/mini_core_hello_world new file mode 100755 index 0000000000000000000000000000000000000000..f7f7af4b14465a76582bda46c9483476c13a1032 GIT binary patch literal 25736 zcmeHv3wT@AmF_-1maO<8%XxqyKu$me2Z$ocmMn+79PA+HIw1`XHi01Yv<-e?Ng<)M zq)DK0LWTfoZ(2HS=KDHBX39*{7CN-$Ym?KRbQXcb7=lkyc*tX8vd+oK>UVH7=IeYDM?r-m0S*B@%gD#c|N*!>RnB^*C=LQu4 zSS~_h8mWYN}{jp%v!hyts zf&QWF<^`KW!3Du4PkPwnm-Qz3M0>-U^|B8?z!T(yV8R%e^*f_VX%UIUH%B9>{-NkV|Gh~hDL<0VL`O4` z!D#=Gh;($VjwF(!$=?2SCOO)*`uc(4p=4JyHbB(9gTq6LIwB$)*0c=v5A{dl!=uSi zbYNgO9?c|u&3!(}a^$fa<=g1y{_3yFZS)UOL z{%s{^s|C;U_gnDqD#IVN;4e~x;u#B`sAY%>Gxakt&0Aj1<&+{EqJCsX2CQ4@i~S4ipRe& z3h|tFS?~^(KCI->+)v|*!wY$M9)py3EDulfFNat1@Vur_-gq89f89NqhtFSkPUqn( zSU6yK``eE2Zd>v~LxdkVoGF_)7T*4xKOp`iAL!w+li?%d%fj0C z!!Li3sfVzyC}Gv6Fq7XZZ|jmHAQRcE!rPa8l49#2FH;@fy<{6w<24f#6XRiAHh$l> z9|-N8srqQsq4f4;B3t$5?VvREM)~tWPquuML{1#r_~vrt!p`-F>|d!k^?L2zBd3mN zJKNl~*(JMhE!S!vRT!tlIP)+y5>vC&_U7aVE5SWCu1M0 ztpetACT4IFv&+QXsxY;4wvs{DhQ}7W!@KFXY+}~U5ZiNf(%PxLh55k}`FoZemhF7O zlzh~;Av|`U+Z7(mxa-4XU2bEd%k3I}_k)Rvu{L-0Zv4XW7s6vNpe_wZ_kzCso!Yu` zH`?om!Xe+ZY1l-yk#Zv9&^@FpAh5 zetw60D@c(BIU&Y&xOd9Lvl33sx_zc0zT*Pw+cfV@%t|30-V-R7BAySAdBe{ychGPN zk3H+&D_M6a2-Ncvvo0lu-DWxABgcW<;dYUpz)1*2?x4c&*m-2@AMBawXrfjZc=p&{ z!f-Yl&Gu`kPn`Qz2@)cGfYPYNK|qj5sT4;^Wkg@EN|F#I^-xJYJC7VH|ElfOFKYLG z_tbZ_ot^G(bhevoANXs`H|TKPyE@%BhhC7X*iBWIO{%h^)_`&~vnXTiA@?CF4JADz zOMli(qi&R*Sc}odS<4+nW+;UughF9bC`?s%$?|?ArQ3dt8BSImb!z|%ikEexI5pjJ zVp~pZ<&y0?CfoizHZMqN{v-`3PHZ7!3lUqHWIJTCMf2D~Af=`zHi{FQm)N{JkC3I8 z=koW-IIOo&c3z?}b{^T)T$aa>G8w+07)ZmzD1!pU*MdvhZjbGcfYbuVRMsni zv^0kIJS%bI-vTXq-Ba&lkbrKS@?ZoBA2?jQ??~;}UmiO~_Hbn{JAphz!rR9+!Z@;( zC&VEQ^|Q2lhMNWfu zd=wW+`g4=?yG;68_!H0dAVCvbdyN$HH!3eh^F#eEn}=!{|1k*O{&%WJhUS+ag?D3S zp$T>TL10_Q4!4aRmNVq!ghu?Bj~2V7I-wH-a@Gm&#(Z;Er`sXI+6&>`h=jKvL5(Rg z_Wbx}sv7Lz2ww+dWPWhs$29%8WVb_v`jI&CuQU^3Ahgjehs*d1#Z^ySM&{E*fnq2x zM`fINZBjS6-pTnkZ@!ahnxDrX{o}+$&(Xvs&Uu_ls%=HCjxyats zMhyRFhOmPlB{J{^FL}PJIisa_#;K)F7VeWY-(wD>oQRJTC(Sd|# zG#$-kl7k}|BQtCaW(P9;BLiEEd-^kd#_*=(Xlh{io}45zl1Cp+BnnA8hK7=(M(=RO zNQ@4Tj3g6tMVJZ`-Bj3I(La>}Ni%09i7MyFOq66uq)|-e$28N@F$Y?g5iHwXUGnp*_5StuLdq%dv z{@QH)IvVRv{ARv4G4ULr8}MzwCcu4wiBl63<(Q4$1#|<>{QbnlV!$TAF2F9p0l*!A zI{^0qeh%=9fKL&`%=8n$=P>`i4cPRjiHRo6Br_qKf_CpZp>1|)v#To{d$kG|;V;2& z|GN_t*ARgU#p$6h@`*kSdb*(zPS;9j{i@okdmLNEvWu^~y3u_(p^3i@KQHLy1V%^% z;=K*O9@KY?5N%GQY>m^=ibEb^yM*L*d^=@+9!`xdr9615f%^!;a&?f1o3AgY$Tq{)SE(A6It0 z7WpsyVPYbHY^u))_^9q}z#qdbnk4)Rr|aRe70&v<(A%BHp7IsWhKFonr}sg7*csYh zvD&$O)ER1ZdRv_hE1U-CK)*ui^$_Hoh8z_4VffGjA6no;3w&sS|IaPJ``*0I&DG`o z;kk@Z`@e=t)A~%$W4y0T>z52A=y*R{uH_))wVL;{dH;I862tqKhDtxI;Mw$g40Ma| zR=MaTQm*Orh+ejEzC553Mz3TwHa zQ+VEg=612teO}S=zVlTj#tvAG_)mS{m~&K=xOwL z7x+TgB$Ba~tZ%-FF#KL$vp3)iif=-g*{+wtJTas``q6$oW`FEs;_qQ#>8}g}yJr3B z$h!8GVk3~5=v~Q3s?jeNni+yLD*99|XpR_;-IEed@OT`0RMs}$G?rc)@f@w54GCZ0QKZUNFGSX8Dr1%4VWr8&S7RTdR9cylhgxg!!ir0{v?2C-x zxp$b{)tN2gDR5&uMEq~SbT%fw0+NyFP=8$93k)_^#2Ub%;fz>?oS~$pDzp`ryj$#$ zdDL)1Tnz2-kKllg^jz6W03l`qc|DA4*(12@N2hC)47j-3Aplq#pQ>Tu~D0* zvzP5HAj_6Qum8P(b$?rdv5l*Fki`c32V8(9ybSr#OV4*5$>O zl(b1D*O{sMO){nOjQeEjHsm>|78-t{;-nHtPsmz#7`UyJw~0!wkqk*m$I~>;zFPMf zaNi@kdx-8aNw*bRi)k)3ozoMv*8MWBQl%}Gdy!kEKXO|9L{e{m2w9bPn8=;l0y4F> zV>*!4|6Pe7qk&_u_E(5#+OEGtrl|Cq*!|jDQqCh^BRRkk=>dg&^k*dJF}3o27P66f zNV@`kUDH1G1Su**&0@%KIh?Zq-UZenoYdR4APSz^7~(>!c@eQHPL1#vreb91azZx_fN_-9p9F=YqGqv|G+R{g)JRh)U|evKUZRnU3g3cG)g<@?MM&&>6d}zFvI#7Y|JO(mel#_&1Ue1dn=s9-Z(2cUJo4m$FlXvynM zTDwWBQWZUzQZ$WHR?Y@+-9?<4bLU(t%Nz#R)5N*G$1KxfmZ?%MvrI}&mN{Q?egj-( zSZ%b&rq&Gg)J)F8dR`?t9pI9jj~8-oGBv0z%{c(hr>M*)3OVmry2qr2C^f0AS>`{2 zYl1lc?%X*Wq_$<4mt~oU3ORQclu4<{GEL4-aLO{jcJ7>XU!iq>8l11*;iPIJ1brRm}wlZU1YstKkGStd;vReu2%tZrJJcBONMO?SF3ob7yS#YJ`6`U_Eq z7EQ-3h2A7|XUB|1Ro7LO)eiwtK8e_=)tWe)2QsGHmxDle5^2W_w3JPh)lViXtTa$& zq3D=Fg-o;N-HAr2tde?EHAyijiv?F#$jWrHG!z zeAb%5fMgf0i;YcSH_ND)EW?pkhiQ2=t<0+r8gWvSYOYPqWDU=vU9K%{s&TFAcFb4? zli3QJ(q4?}lNtysJi^)$mR%%s92Op%DS4V%?aIk&%LK|B>MA$bs_hw@&E8jrgS3>rm9v)=%|5`{-xHdx z8tk^0nDa1a{WG%4D;1ceEl@=uF9;f+`d9gyp%Lq<4OIikn6I)Xw&p*+iaEkz2Mt!bG>gXcU)$x z3E12Z*lJ#v39ZT2qIYjAn~o-+$JKIiKdw_d+gTuv5Mq9Ks};+ zio8c9o#Pf;EfkZKQ+4~SNizdIBUOs#ZzRo&=*J-GL4mhSsp8+Bo#e|?NmQfc4E5Es zle`3yX_b$_);;=D7=`)|w7t-1iOul|u0P*h>Elw|hBDk9P(R5P^IPD{D;M%q!Z%U+ z_AQAD!Kd5*J@P2xmbK1=;KR=(IU?@O-FV%zP zQ+@v%pCoZuKd!WvSir?SOk(8Myx3DRDz01N7@6{o(`BpW|8@cHM@KkETBaelM< zPh{zU+vJWibPF~{+?`!+cjsESdmVmR zztGXkYYn^ALb%pVLUd`;gP1B-hD@Xb( z&atpWz#B|9HiiN%Ex~xG8C|673>_mN-7nD5mu&V0VyR#%8uN#IzCgQ}bjy0A{t2fgYA=UqtXI=J}JTU`#^}-8%PCPg25)A-u|Gll{fs97;GERP*>7BLJ)NAH3BsKPRM&m{?FE@tBb%10+H)Hl}# z`7?B0Z&3cjvy>7GdK1ZjuQ}vP#%ZEC-%{W%q*gh1oG2y+C2F&|!B-LR&yMNYG^;o*T2v)h_sIe|CA@kl}vsTkIa zsJ9UdM=Y9Zmkvo1)GP&MLnXwl&JNIo+z3A=#Khp}3?<`@jozllq`$ct(*yjQ=OCsv zk&t4*4>2i!ED-WyEp3dqM5DAAlLHlEn!KhqG?GdvbW=7aCBfASNxqP;CFE~RMVk__ z#^z89CSSNPm7o(Svp|ZK8m28T&cpthyI?#SMiSj4!hQ`g! zv8F&U8f}ipQ!UXL#&q)T^A|Nl??*Rz{a(xs39q*);Ex6{vf-*Gtpd`JH0zaUks^A9 z0*NT@m6EAM%?U$`Euqw!WUuTdL&;uL zF51%4;*B=Pn&aMIMYY#s9aJa$;~69cnf|YiTB@!lGxP1$clLJ^WoE@jb zdA#!$Q}VOsXa)JD^Oj5U`(j-r&oHl%gykjO;EY@@KGh0`1a&McmHwto; zN{f*zckp&@QRp_7q9qS>_ zzIjVQM9ERv&(oLZ$u3%Qn{3Hf+TBa=hX9F*h|q_!cymaHz~ zG)#Kcv1Qp zx$nmm($CC&Kc)~rOB|eSwM1Mswa^T%l@ES1X z;&&6)3|b{Loc6Z13+=m>;X6skEd7lvMtB!*=qiC8g}1&x(FVMhXMfUz!cF*Tc*~H_ zvr8l{bUu~j^ZOW#e-IH3Z(8vAc*g%VBE{+7Az#O z2pbjtfJM&t6rPuHLsH{ZAMm7)wI5EyksxYB>->2M@EYEN;P)noih>__`VQFvWneUu z3@d=2n>RmSuJ9?~4HeG^+oYU)j2Yjjr&G`m&lSe#?h}r+QiCKVCx4)4+4vDb*!#kbF_(ejq-Y zNoTUDln49FkyY2Pi*$C})P>F7$xqBhGJ}ygePoWlPL~*t^bQQiq63ixUKdD5qS?(N zK1`oh$RrbIW~Et5`wvRUyBH&Fx2$Ph-EsXHM%Njff7C(# zD}0k@Y2K+Wlmb&q7bThopD2yAhgExp+t!K54V^cxXzh&LxN_x9?OlA4~FLILX&RcI63nUZX^;*ql)xlQqwP5^b?|I z?&DM4aFGZ;Xv%}7} zdWW)}ShgSEx$RE~52gB|=|15}Y#D+)6T;&wbJWR?fQJqLW1>PTHh_@FC0+p2?b|I0^&--W$`MH&OIL+{3 z3qS9-F=Tz2-mc)3+as#@t@dBuY;ruU_EDK17m96){vR#De_HY1Z4tob zvb^0T`1@Cy6noENf0Ab*F&R5dP_Np59+LkJKeivQ|CDV}Q8L!658u4Z16N|rv8JLD T)Zto;|4lV;KVzw|B`N+d>q|}! literal 0 HcmV?d00001 diff --git a/src/base.rs b/src/base.rs index f780a86515a9d..698a31312fc54 100644 --- a/src/base.rs +++ b/src/base.rs @@ -69,6 +69,13 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( let func_id = cx.module .declare_function(&name, linkage, &sig) .unwrap(); + let mut debug_context = cx.debug_context.as_mut().map(|debug_context| FunctionDebugContext::new( + tcx, + debug_context, + mir, + &name, + &sig, + )); // Step 3. Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); @@ -101,6 +108,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( clif_comments, constants: &mut cx.ccx, caches: &mut cx.caches, + spans: Vec::new(), }; // Step 6. Codegen function @@ -108,6 +116,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( crate::abi::codegen_fn_prelude(&mut fx, start_ebb); codegen_fn_content(&mut fx); }); + let spans = fx.spans.clone(); // Step 7. Write function to file for debugging #[cfg(debug_assertions)] @@ -119,8 +128,12 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 9. Define function cx.caches.context.func = func; cx.module - .define_function(func_id, &mut cx.caches.context) + .define_function_peek_compiled(func_id, &mut cx.caches.context, |size, context, isa| { + debug_context.as_mut().map(|x| x.define(tcx, size, context, isa, &spans[..])); + }) .unwrap(); + //let module = &mut cx.module; + //let caches = &cx.caches; cx.caches.context.clear(); } @@ -154,6 +167,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) fx.bcx.ins().nop(); for stmt in &bb_data.statements { + fx.set_debug_loc(stmt.source_info); trans_stmt(fx, ebb, stmt); } @@ -169,6 +183,8 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) fx.add_comment(inst, terminator_head); } + fx.set_debug_loc(bb_data.terminator().source_info); + match &bb_data.terminator().kind { TerminatorKind::Goto { target } => { let ebb = fx.get_ebb(*target); @@ -322,6 +338,8 @@ fn trans_stmt<'a, 'tcx: 'a>( ) { let _print_guard = PrintOnPanic(|| format!("stmt {:?}", stmt)); + fx.set_debug_loc(stmt.source_info); + #[cfg(debug_assertions)] match &stmt.kind { StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful diff --git a/src/common.rs b/src/common.rs index d5e07be302c46..ded45af6d5e98 100644 --- a/src/common.rs +++ b/src/common.rs @@ -539,6 +539,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { pub clif_comments: crate::pretty_clif::CommentWriter, pub constants: &'a mut crate::constant::ConstantCx, pub caches: &'a mut Caches<'tcx>, + pub spans: Vec, } impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { @@ -617,4 +618,11 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { *self.local_map.get(&local).unwrap() } + + pub fn set_debug_loc(&mut self, source_info: mir::SourceInfo) { + // FIXME: record scope too + let index = self.spans.len() as u32; + self.spans.push(source_info.span); + self.bcx.set_srcloc(SourceLoc::new(index)); + } } diff --git a/src/debuginfo.rs b/src/debuginfo.rs new file mode 100644 index 0000000000000..f4744f6b7becd --- /dev/null +++ b/src/debuginfo.rs @@ -0,0 +1,529 @@ +extern crate gimli; + +use crate::prelude::*; + +use std::marker::PhantomData; + +use gimli::write::{ + Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, + DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, + RangeList, RangesTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, Writer, +}; +use gimli::Format; + +// FIXME: use target endian +use byteorder::ByteOrder; +use gimli::RunTimeEndian; + +use faerie::*; + +fn target_endian(tcx: TyCtxt) -> RunTimeEndian { + use rustc::ty::layout::Endian; + + match tcx.data_layout.endian { + Endian::Big => RunTimeEndian::Big, + Endian::Little => RunTimeEndian::Little, + } +} +struct DebugReloc { + offset: u32, + size: u8, + name: String, + addend: i64, +} + +pub struct DebugContext<'tcx> { + endian: RunTimeEndian, + format: Format, + version: u16, + address_size: u8, + + strings: StringTable, + units: UnitTable, + unit_id: UnitId, + line_programs: LineProgramTable, + global_line_program: LineProgramId, + ranges: RangesTable, + unit_ranges: RangeList, + symbol_names: Vec, + + _dummy: PhantomData<&'tcx ()>, +} + +impl<'a, 'tcx: 'a> DebugContext<'tcx> { + pub fn new(tcx: TyCtxt, address_size: u8) -> Self { + // TODO: this should be configurable + let version = 4; + let format = Format::Dwarf32; + + // FIXME: how to get version when building out of tree? + // Normally this would use option_env!("CFG_VERSION"). + let producer = format!("cranelift fn (rustc version {})", "unknown version"); + let comp_dir = tcx.sess.working_dir.0.to_string_lossy().into_owned(); + let name = match tcx.sess.local_crate_source_file { + Some(ref path) => path.to_string_lossy().into_owned(), + None => tcx.crate_name(LOCAL_CRATE).to_string(), + }; + + let mut units = UnitTable::default(); + let mut strings = StringTable::default(); + let mut line_programs = LineProgramTable::default(); + let ranges = RangesTable::default(); + + let global_line_program = line_programs.add(LineProgram::new( + version, + address_size, + format, + 1, + 1, + -5, + 14, + comp_dir.as_bytes(), + name.as_bytes(), + None, + )); + + let unit_id = units.add(CompilationUnit::new(version, address_size, format)); + { + let name = strings.add(&*name); + let comp_dir = strings.add(&*comp_dir); + + let unit = units.get_mut(unit_id); + let root = unit.root(); + let root = unit.get_mut(root); + root.set( + gimli::DW_AT_producer, + AttributeValue::StringRef(strings.add(producer)), + ); + root.set( + gimli::DW_AT_language, + AttributeValue::Language(gimli::DW_LANG_Rust), + ); + root.set(gimli::DW_AT_name, AttributeValue::StringRef(name)); + root.set(gimli::DW_AT_comp_dir, AttributeValue::StringRef(comp_dir)); + root.set( + gimli::DW_AT_stmt_list, + AttributeValue::LineProgramRef(global_line_program), + ); + root.set( + gimli::DW_AT_low_pc, + AttributeValue::Address(Address::Absolute(0)), + ); + } + + DebugContext { + endian: target_endian(tcx), + format, + version, + address_size, + + strings, + units, + unit_id, + line_programs, + global_line_program, + ranges, + unit_ranges: RangeList(Vec::new()), + symbol_names: Vec::new(), + _dummy: PhantomData, + } + } + + fn emit_location(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, entry_id: UnitEntryId, span: Span) { + let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + + let unit = self.units.get_mut(self.unit_id); + let entry = unit.get_mut(entry_id); + + let file_id = self.strings.add(loc.file.name.to_string()); + entry.set(gimli::DW_AT_decl_file, AttributeValue::StringRef(file_id)); + entry.set( + gimli::DW_AT_decl_line, + AttributeValue::Udata(loc.line as u64), + ); + // FIXME: probably omit this + entry.set( + gimli::DW_AT_decl_column, + AttributeValue::Udata(loc.col.to_usize() as u64), + ); + } + + pub fn emit(&mut self, artifact: &mut Artifact) { + let unit_range_id = self.ranges.add(self.unit_ranges.clone()); + let unit = self.units.get_mut(self.unit_id); + let root = unit.root(); + let root = unit.get_mut(root); + root.set( + gimli::DW_AT_ranges, + AttributeValue::RangeListsRef(unit_range_id), + ); + + let mut debug_abbrev = DebugAbbrev::from(WriterRelocate::new(self)); + let mut debug_info = DebugInfo::from(WriterRelocate::new(self)); + let mut debug_str = DebugStr::from(WriterRelocate::new(self)); + let mut debug_line = DebugLine::from(WriterRelocate::new(self)); + let mut debug_ranges = DebugRanges::from(WriterRelocate::new(self)); + let mut debug_rnglists = DebugRngLists::from(WriterRelocate::new(self)); + + let debug_line_offsets = self.line_programs.write(&mut debug_line).unwrap(); + let debug_str_offsets = self.strings.write(&mut debug_str).unwrap(); + let (debug_ranges_offsets, debug_rnglists_offsets) = self + .ranges + .write( + &mut debug_ranges, + &mut debug_rnglists, + self.format, + self.version, + self.address_size, + ) + .unwrap(); + self.units + .write( + &mut debug_abbrev, + &mut debug_info, + &debug_line_offsets, + &debug_ranges_offsets, + &debug_rnglists_offsets, + &debug_str_offsets, + ) + .unwrap(); + + artifact + .declare_with( + SectionId::DebugAbbrev.name(), + Decl::DebugSection, + debug_abbrev.0.writer.into_vec(), + ) + .unwrap(); + artifact + .declare_with( + SectionId::DebugInfo.name(), + Decl::DebugSection, + debug_info.0.writer.into_vec(), + ) + .unwrap(); + artifact + .declare_with( + SectionId::DebugStr.name(), + Decl::DebugSection, + debug_str.0.writer.into_vec(), + ) + .unwrap(); + artifact + .declare_with( + SectionId::DebugLine.name(), + Decl::DebugSection, + debug_line.0.writer.into_vec(), + ) + .unwrap(); + artifact + .declare_with( + SectionId::DebugRanges.name(), + Decl::DebugSection, + debug_ranges.0.writer.into_vec(), + ) + .unwrap(); + artifact + .declare_with( + SectionId::DebugRngLists.name(), + Decl::DebugSection, + debug_rnglists.0.writer.into_vec(), + ) + .unwrap(); + + for reloc in debug_abbrev.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugAbbrev.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } + + for reloc in debug_info.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugInfo.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } + + for reloc in debug_str.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugStr.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } + + for reloc in debug_line.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugLine.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } + + for reloc in debug_ranges.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugRanges.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } + + for reloc in debug_rnglists.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugRngLists.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } + } + + fn section_name(&self, id: SectionId) -> String { + id.name().to_string() + } +} + +pub struct FunctionDebugContext<'a, 'tcx> { + debug_context: &'a mut DebugContext<'tcx>, + entry_id: UnitEntryId, + symbol: usize, +} + +impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { + pub fn new( + tcx: TyCtxt<'b, 'tcx, 'tcx>, + debug_context: &'a mut DebugContext<'tcx>, + mir: &Mir, + name: &str, + _sig: &Signature, + ) -> Self { + let symbol = debug_context.symbol_names.len(); + debug_context.symbol_names.push(name.to_string()); + + let unit = debug_context.units.get_mut(debug_context.unit_id); + // FIXME: add to appropriate scope intead of root + let scope = unit.root(); + + let entry_id = unit.add(scope, gimli::DW_TAG_subprogram); + let entry = unit.get_mut(entry_id); + let name_id = debug_context.strings.add(name); + entry.set( + gimli::DW_AT_linkage_name, + AttributeValue::StringRef(name_id), + ); + + entry.set( + gimli::DW_AT_low_pc, + AttributeValue::Address(Address::Relative { symbol, addend: 0 }), + ); + + debug_context.emit_location(tcx, entry_id, mir.span); + + FunctionDebugContext { + debug_context, + entry_id, + symbol, + } + } + + pub fn define( + &mut self, + tcx: TyCtxt, + //module: &mut Module, + size: u32, + context: &Context, + isa: &cranelift::codegen::isa::TargetIsa, + spans: &[Span], + ) { + let unit = self.debug_context.units.get_mut(self.debug_context.unit_id); + // FIXME: add to appropriate scope intead of root + let entry = unit.get_mut(self.entry_id); + let mut size_array = [0; 8]; + byteorder::LittleEndian::write_u64(&mut size_array, size as u64); + entry.set(gimli::DW_AT_high_pc, AttributeValue::Data8(size_array)); + + self.debug_context.unit_ranges.0.push(Range { + begin: Address::Relative { + symbol: self.symbol, + addend: 0, + }, + end: Address::Relative { + symbol: self.symbol, + addend: size as i64, + }, + }); + + let line_program = self + .debug_context + .line_programs + .get_mut(self.debug_context.global_line_program); + + line_program.begin_sequence(Some(Address::Relative { + symbol: self.symbol, + addend: 0, + })); + + let encinfo = isa.encoding_info(); + let func = &context.func; + let mut ebbs = func.layout.ebbs().collect::>(); + ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase + for ebb in ebbs { + for (offset, inst, _size) in func.inst_offsets(ebb, &encinfo) { + let srcloc = func.srclocs[inst]; + if !srcloc.is_default() { + let span = spans[srcloc.bits() as usize]; + let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + let file = loc.file.name.to_string(); + let file = ::std::path::Path::new(&file); + let dir_id = line_program + .add_directory(file.parent().unwrap().to_str().unwrap().as_bytes()); + let file_id = line_program.add_file( + file.file_name().unwrap().to_str().unwrap().as_bytes(), + dir_id, + None, + ); + line_program.row().file = file_id; + //tcx.sess + // .warn(&format!("srcloc {} {}:{}:{}", offset, file, loc.line, loc.col.to_usize())); + line_program.row().address_offset = offset as u64; + line_program.row().line = loc.line as u64; + line_program.generate_row(); + } + } + } + + let address_offset = line_program.row().address_offset; + line_program.end_sequence(address_offset); + } +} + +struct WriterRelocate<'a, 'tcx> { + ctx: &'a DebugContext<'tcx>, + relocs: Vec, + writer: EndianVec, +} + +impl<'a, 'tcx> WriterRelocate<'a, 'tcx> { + fn new(ctx: &'a DebugContext<'tcx>) -> Self { + WriterRelocate { + ctx, + relocs: Vec::new(), + writer: EndianVec::new(ctx.endian), + } + } +} + +impl<'a, 'tcx> Writer for WriterRelocate<'a, 'tcx> { + type Endian = RunTimeEndian; + + fn endian(&self) -> Self::Endian { + self.writer.endian() + } + + fn len(&self) -> usize { + self.writer.len() + } + + fn write(&mut self, bytes: &[u8]) -> Result<()> { + self.writer.write(bytes) + } + + fn write_at(&mut self, offset: usize, bytes: &[u8]) -> Result<()> { + self.writer.write_at(offset, bytes) + } + + fn write_address(&mut self, address: Address, size: u8) -> Result<()> { + match address { + Address::Absolute(val) => self.write_word(val, size), + Address::Relative { symbol, addend } => { + let offset = self.len() as u64; + self.relocs.push(DebugReloc { + offset: offset as u32, + size, + name: self.ctx.symbol_names[symbol].clone(), + addend: addend as i64, + }); + self.write_word(0, size) + } + } + } + + fn write_offset(&mut self, val: usize, section: SectionId, size: u8) -> Result<()> { + let offset = self.len() as u32; + let name = self.ctx.section_name(section); + self.relocs.push(DebugReloc { + offset, + size, + name, + addend: val as i64, + }); + self.write_word(0, size) + } + + fn write_offset_at( + &mut self, + offset: usize, + val: usize, + section: SectionId, + size: u8, + ) -> Result<()> { + let name = self.ctx.section_name(section); + self.relocs.push(DebugReloc { + offset: offset as u32, + size, + name, + addend: val as i64, + }); + self.write_word_at(offset, 0, size) + } +} diff --git a/src/lib.rs b/src/lib.rs index 7df9b6ae42eeb..7b0e4d231d6dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ use std::sync::mpsc; use rustc::dep_graph::DepGraph; use rustc::middle::cstore::MetadataLoader; use rustc::session::{ - config::{OutputFilenames, OutputType}, + config::{DebugInfo, OutputFilenames, OutputType}, CompileIncomplete, }; use rustc::ty::query::Providers; @@ -43,6 +43,7 @@ mod archive; mod base; mod common; mod constant; +mod debuginfo; mod intrinsics; mod link; mod link_copied; @@ -59,7 +60,7 @@ mod prelude { pub use std::collections::{HashMap, HashSet}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; - pub use syntax::source_map::DUMMY_SP; + pub use syntax::source_map::{DUMMY_SP, Span, Pos}; pub use rustc::bug; pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -85,17 +86,21 @@ mod prelude { pub use rustc_codegen_ssa::traits::*; pub use cranelift::codegen::ir::{ - condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, + condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, SourceLoc, }; pub use cranelift::codegen::isa::CallConv; pub use cranelift::codegen::Context; pub use cranelift::prelude::*; - pub use cranelift_module::{Backend, DataContext, DataId, FuncId, Linkage, Module}; + pub use cranelift_module::{ + self, Backend, DataContext, DataId, FuncId, FuncOrDataId, Linkage, + Module, + }; pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; pub use crate::common::*; + pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; pub use crate::{Caches, CodegenCx}; @@ -120,15 +125,21 @@ pub struct CodegenCx<'a, 'clif, 'tcx, B: Backend + 'static> { module: &'clif mut Module, ccx: ConstantCx, caches: Caches<'tcx>, + debug_context: Option<&'clif mut DebugContext<'tcx>>, } impl<'a, 'clif, 'tcx, B: Backend + 'static> CodegenCx<'a, 'clif, 'tcx, B> { - fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &'clif mut Module) -> Self { + fn new( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &'clif mut Module, + debug_context: Option<&'clif mut DebugContext<'tcx>>, + ) -> Self { CodegenCx { tcx, module, ccx: ConstantCx::default(), caches: Caches::default(), + debug_context, } } @@ -225,7 +236,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .declare_function("main", Linkage::Import, &sig) .unwrap(); - codegen_cgus(tcx, &mut jit_module, &mut log); + codegen_cgus(tcx, &mut jit_module, &mut None, &mut log); crate::allocator::codegen(tcx.sess, &mut jit_module); jit_module.finalize_definitions(); @@ -261,9 +272,13 @@ impl CodegenBackend for CraneliftCodegenBackend { module }; - let emit_module = |name: &str, kind: ModuleKind, mut module: Module| { + let emit_module = |name: &str, kind: ModuleKind, mut module: Module, debug: Option| { module.finalize_definitions(); - let artifact = module.finish().artifact; + let mut artifact = module.finish().artifact; + + if let Some(mut debug) = debug { + debug.emit(&mut artifact); + } let tmp_file = tcx .output_filenames(LOCAL_CRATE) @@ -281,7 +296,14 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut faerie_module = new_module("some_file".to_string()); - codegen_cgus(tcx, &mut faerie_module, &mut log); + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let debug = DebugContext::new(tcx, faerie_module.target_config().pointer_type().bytes() as u8); + Some(debug) + } else { + None + }; + + codegen_cgus(tcx, &mut faerie_module, &mut debug, &mut log); tcx.sess.abort_if_errors(); @@ -291,9 +313,9 @@ impl CodegenBackend for CraneliftCodegenBackend { return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), - modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module)], + modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module, debug)], allocator_module: if created_alloc_shim { - Some(emit_module("allocator_shim", ModuleKind::Allocator, allocator_module)) + Some(emit_module("allocator_shim", ModuleKind::Allocator, allocator_module, None)) } else { None }, @@ -372,6 +394,7 @@ fn build_isa(sess: &Session) -> Box { fn codegen_cgus<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, + debug: &mut Option>, log: &mut Option, ) { let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); @@ -382,7 +405,7 @@ fn codegen_cgus<'a, 'tcx: 'a>( .map(|(&mono_item, &(linkage, vis))| (mono_item, (linkage, vis))) .collect::>(); - codegen_mono_items(tcx, module, log, mono_items); + codegen_mono_items(tcx, module, debug.as_mut(), log, mono_items); crate::main_shim::maybe_create_entry_wrapper(tcx, module); } @@ -390,10 +413,11 @@ fn codegen_cgus<'a, 'tcx: 'a>( fn codegen_mono_items<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, + debug_context: Option<&mut DebugContext<'tcx>>, log: &mut Option, mono_items: FxHashMap, (RLinkage, Visibility)>, ) { - let mut cx = CodegenCx::new(tcx, module); + let mut cx = CodegenCx::new(tcx, module, debug_context); time("codegen mono items", move || { for (mono_item, (linkage, vis)) in mono_items { unimpl::try_unimpl(tcx, log, || { diff --git a/test.sh b/test.sh index d03b48c96bce8..1782df6113ddd 100755 --- a/test.sh +++ b/test.sh @@ -10,16 +10,16 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib -g echo "[BUILD] example" -$RUSTC example/example.rs --crate-type lib +$RUSTC example/example.rs --crate-type lib -g echo "[JIT] mini_core_hello_world" SHOULD_RUN=1 $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" -$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin +$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g sh -c ./target/out/mini_core_hello_world || true echo "[BUILD] sysroot" @@ -31,7 +31,7 @@ time ./build_sysroot/build_sysroot.sh #./target/out/alloc_example echo "[BUILD] mod_bench" -$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin +$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -g echo "[BUILD] sysroot in release mode" ./build_sysroot/build_sysroot.sh --release From d61ceeca7c028f4abbeb31976587d2ac32198496 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 17 Jan 2019 18:33:54 +0100 Subject: [PATCH 0458/1566] Generate lineinfo for default srcloc --- src/debuginfo.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index f4744f6b7becd..5024c7eec7f7f 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -337,6 +337,7 @@ pub struct FunctionDebugContext<'a, 'tcx> { debug_context: &'a mut DebugContext<'tcx>, entry_id: UnitEntryId, symbol: usize, + mir_span: Span, } impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { @@ -373,6 +374,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { debug_context, entry_id, symbol, + mir_span: mir.span, } } @@ -419,9 +421,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase for ebb in ebbs { for (offset, inst, _size) in func.inst_offsets(ebb, &encinfo) { - let srcloc = func.srclocs[inst]; - if !srcloc.is_default() { - let span = spans[srcloc.bits() as usize]; + fn create_row_for_span(tcx: TyCtxt, line_program: &mut LineProgram, offset: u64, span: Span) { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); let file = loc.file.name.to_string(); let file = ::std::path::Path::new(&file); @@ -435,10 +435,18 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { line_program.row().file = file_id; //tcx.sess // .warn(&format!("srcloc {} {}:{}:{}", offset, file, loc.line, loc.col.to_usize())); - line_program.row().address_offset = offset as u64; + line_program.row().address_offset = offset; line_program.row().line = loc.line as u64; line_program.generate_row(); } + + let srcloc = func.srclocs[inst]; + if !srcloc.is_default() { + let span = spans[srcloc.bits() as usize]; + create_row_for_span(tcx, line_program, offset as u64, span); + } else { + create_row_for_span(tcx, line_program, offset as u64, self.mir_span); + } } } From 8bddc783e0bf4281a47f30002f6e7f4de1e21ea5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Jan 2019 12:00:51 +0100 Subject: [PATCH 0459/1566] Update gimli --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/debuginfo.rs | 25 ++++++++++++------------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4f89330377fc..828d4bb631ff5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -319,7 +319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/bjorn3/gimli.git?branch=impl_range_write#ff96c190bbb7a41623f009c969cb7ecd7a2716f4" +source = "git+https://github.com/gimli-rs/gimli.git#9930c6166487e9195e6ba31002685686001f906a" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -596,7 +596,7 @@ dependencies = [ "cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gimli 0.16.1 (git+https://github.com/bjorn3/gimli.git?branch=impl_range_write)", + "gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -885,7 +885,7 @@ dependencies = [ "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.16.1 (git+https://github.com/bjorn3/gimli.git?branch=impl_range_write)" = "" +"checksum gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" diff --git a/Cargo.toml b/Cargo.toml index 30824626feb26..48714bd22c020 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,8 +37,8 @@ faerie = "0.7.1" #cranelift-simplejit = { path = "../cranelift/lib/simplejit" } #cranelift-faerie = { path = "../cranelift/lib/faerie" } -[patch."https://github.com/gimli-rs/gimli.git"] -gimli = { git = "https://github.com/bjorn3/gimli.git", branch = "impl_range_write" } +#[patch."https://github.com/gimli-rs/gimli.git"] +#gimli = { path = "../" } [profile.dev.overrides."*"] opt-level = 3 diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 5024c7eec7f7f..d4e8510cd614d 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -7,7 +7,7 @@ use std::marker::PhantomData; use gimli::write::{ Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, - RangeList, RangesTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, Writer, + RangeList, RangeListTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, Writer, }; use gimli::Format; @@ -43,8 +43,8 @@ pub struct DebugContext<'tcx> { unit_id: UnitId, line_programs: LineProgramTable, global_line_program: LineProgramId, - ranges: RangesTable, - unit_ranges: RangeList, + range_lists: RangeListTable, + unit_range_list: RangeList, symbol_names: Vec, _dummy: PhantomData<&'tcx ()>, @@ -68,7 +68,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let mut units = UnitTable::default(); let mut strings = StringTable::default(); let mut line_programs = LineProgramTable::default(); - let ranges = RangesTable::default(); + let range_lists = RangeListTable::default(); let global_line_program = line_programs.add(LineProgram::new( version, @@ -122,8 +122,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { unit_id, line_programs, global_line_program, - ranges, - unit_ranges: RangeList(Vec::new()), + range_lists, + unit_range_list: RangeList(Vec::new()), symbol_names: Vec::new(), _dummy: PhantomData, } @@ -149,13 +149,13 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { } pub fn emit(&mut self, artifact: &mut Artifact) { - let unit_range_id = self.ranges.add(self.unit_ranges.clone()); + let unit_range_list_id = self.range_lists.add(self.unit_range_list.clone()); let unit = self.units.get_mut(self.unit_id); let root = unit.root(); let root = unit.get_mut(root); root.set( gimli::DW_AT_ranges, - AttributeValue::RangeListsRef(unit_range_id), + AttributeValue::RangeListRef(unit_range_list_id), ); let mut debug_abbrev = DebugAbbrev::from(WriterRelocate::new(self)); @@ -167,8 +167,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let debug_line_offsets = self.line_programs.write(&mut debug_line).unwrap(); let debug_str_offsets = self.strings.write(&mut debug_str).unwrap(); - let (debug_ranges_offsets, debug_rnglists_offsets) = self - .ranges + let range_list_offsets = self + .range_lists .write( &mut debug_ranges, &mut debug_rnglists, @@ -182,8 +182,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { &mut debug_abbrev, &mut debug_info, &debug_line_offsets, - &debug_ranges_offsets, - &debug_rnglists_offsets, + &range_list_offsets, &debug_str_offsets, ) .unwrap(); @@ -394,7 +393,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { byteorder::LittleEndian::write_u64(&mut size_array, size as u64); entry.set(gimli::DW_AT_high_pc, AttributeValue::Data8(size_array)); - self.debug_context.unit_ranges.0.push(Range { + self.debug_context.unit_range_list.0.push(Range { begin: Address::Relative { symbol: self.symbol, addend: 0, From 6b5cbc540d294f437785eeb678867ee753c6243b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Jan 2019 12:07:42 +0100 Subject: [PATCH 0460/1566] Use gimli's byteorder in debuginfo.rs --- src/debuginfo.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index d4e8510cd614d..585271bb3cdbd 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -4,16 +4,13 @@ use crate::prelude::*; use std::marker::PhantomData; +use gimli::{Endianity, Format, RunTimeEndian}; use gimli::write::{ Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, RangeList, RangeListTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, Writer, }; -use gimli::Format; -// FIXME: use target endian -use byteorder::ByteOrder; -use gimli::RunTimeEndian; use faerie::*; @@ -25,6 +22,7 @@ fn target_endian(tcx: TyCtxt) -> RunTimeEndian { Endian::Little => RunTimeEndian::Little, } } + struct DebugReloc { offset: u32, size: u8, @@ -390,7 +388,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { // FIXME: add to appropriate scope intead of root let entry = unit.get_mut(self.entry_id); let mut size_array = [0; 8]; - byteorder::LittleEndian::write_u64(&mut size_array, size as u64); + target_endian(tcx).write_u64(&mut size_array, size as u64); entry.set(gimli::DW_AT_high_pc, AttributeValue::Data8(size_array)); self.debug_context.unit_range_list.0.push(Range { From a12eef4d863aa7ba43f145c41f1a16cf7032ce6d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Jan 2019 12:18:39 +0100 Subject: [PATCH 0461/1566] Use IndexSet and keep full source info in set_debug_loc --- Cargo.lock | 1 + Cargo.toml | 1 + src/base.rs | 6 +++--- src/common.rs | 8 +++----- src/debuginfo.rs | 28 ++++++++++++++++------------ 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 828d4bb631ff5..c7d619dd36a83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -597,6 +597,7 @@ dependencies = [ "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)", + "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 48714bd22c020..75f12add11900 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ tempfile = "3.0.4" env_logger = "0.6" gimli = { git = "https://github.com/gimli-rs/gimli.git" } faerie = "0.7.1" +indexmap = "1.0.2" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] diff --git a/src/base.rs b/src/base.rs index 698a31312fc54..0d130bb8a1b8d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -108,7 +108,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( clif_comments, constants: &mut cx.ccx, caches: &mut cx.caches, - spans: Vec::new(), + source_info_set: indexmap::IndexSet::new(), }; // Step 6. Codegen function @@ -116,7 +116,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( crate::abi::codegen_fn_prelude(&mut fx, start_ebb); codegen_fn_content(&mut fx); }); - let spans = fx.spans.clone(); + let source_info_set = fx.source_info_set.clone(); // Step 7. Write function to file for debugging #[cfg(debug_assertions)] @@ -129,7 +129,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( cx.caches.context.func = func; cx.module .define_function_peek_compiled(func_id, &mut cx.caches.context, |size, context, isa| { - debug_context.as_mut().map(|x| x.define(tcx, size, context, isa, &spans[..])); + debug_context.as_mut().map(|x| x.define(tcx, size, context, isa, &source_info_set)); }) .unwrap(); //let module = &mut cx.module; diff --git a/src/common.rs b/src/common.rs index ded45af6d5e98..b88d439932a4a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -539,7 +539,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { pub clif_comments: crate::pretty_clif::CommentWriter, pub constants: &'a mut crate::constant::ConstantCx, pub caches: &'a mut Caches<'tcx>, - pub spans: Vec, + pub source_info_set: indexmap::IndexSet, } impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { @@ -620,9 +620,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } pub fn set_debug_loc(&mut self, source_info: mir::SourceInfo) { - // FIXME: record scope too - let index = self.spans.len() as u32; - self.spans.push(source_info.span); - self.bcx.set_srcloc(SourceLoc::new(index)); + let (index, _) = self.source_info_set.insert_full(source_info); + self.bcx.set_srcloc(SourceLoc::new(index as u32)); } } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 585271bb3cdbd..e86abcac0d68a 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -36,14 +36,16 @@ pub struct DebugContext<'tcx> { version: u16, address_size: u8, + symbols: indexmap::IndexSet, + strings: StringTable, units: UnitTable, - unit_id: UnitId, line_programs: LineProgramTable, - global_line_program: LineProgramId, range_lists: RangeListTable, + + unit_id: UnitId, + global_line_program: LineProgramId, unit_range_list: RangeList, - symbol_names: Vec, _dummy: PhantomData<&'tcx ()>, } @@ -115,14 +117,17 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { version, address_size, + symbols: indexmap::IndexSet::new(), + strings, units, - unit_id, line_programs, - global_line_program, range_lists, + + unit_id, + global_line_program, unit_range_list: RangeList(Vec::new()), - symbol_names: Vec::new(), + _dummy: PhantomData, } } @@ -345,8 +350,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { name: &str, _sig: &Signature, ) -> Self { - let symbol = debug_context.symbol_names.len(); - debug_context.symbol_names.push(name.to_string()); + let (symbol, _) = debug_context.symbols.insert_full(name.to_string()); let unit = debug_context.units.get_mut(debug_context.unit_id); // FIXME: add to appropriate scope intead of root @@ -382,7 +386,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { size: u32, context: &Context, isa: &cranelift::codegen::isa::TargetIsa, - spans: &[Span], + source_info_set: &indexmap::IndexSet, ) { let unit = self.debug_context.units.get_mut(self.debug_context.unit_id); // FIXME: add to appropriate scope intead of root @@ -439,8 +443,8 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let srcloc = func.srclocs[inst]; if !srcloc.is_default() { - let span = spans[srcloc.bits() as usize]; - create_row_for_span(tcx, line_program, offset as u64, span); + let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); + create_row_for_span(tcx, line_program, offset as u64, source_info.span); } else { create_row_for_span(tcx, line_program, offset as u64, self.mir_span); } @@ -495,7 +499,7 @@ impl<'a, 'tcx> Writer for WriterRelocate<'a, 'tcx> { self.relocs.push(DebugReloc { offset: offset as u32, size, - name: self.ctx.symbol_names[symbol].clone(), + name: self.ctx.symbols.get_index(symbol).unwrap().clone(), addend: addend as i64, }); self.write_word(0, size) From cf7ee00afd8d3a206fa2c83baaadcf8dd6c5c9bc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Jan 2019 16:16:30 +0100 Subject: [PATCH 0462/1566] Improve it a bit --- src/debuginfo.rs | 77 +++++++++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index e86abcac0d68a..44e52bdd00942 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -4,13 +4,13 @@ use crate::prelude::*; use std::marker::PhantomData; -use gimli::{Endianity, Format, RunTimeEndian}; use gimli::write::{ Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, - RangeList, RangeListTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, Writer, + RangeList, RangeListTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, + Writer, }; - +use gimli::{Endianity, Format, RunTimeEndian}; use faerie::*; @@ -71,7 +71,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let range_lists = RangeListTable::default(); let global_line_program = line_programs.add(LineProgram::new( - version, + 3, // FIXME https://github.com/gimli-rs/gimli/issues/363 address_size, format, 1, @@ -383,7 +383,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { &mut self, tcx: TyCtxt, //module: &mut Module, - size: u32, + code_size: u32, context: &Context, isa: &cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet, @@ -392,7 +392,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { // FIXME: add to appropriate scope intead of root let entry = unit.get_mut(self.entry_id); let mut size_array = [0; 8]; - target_endian(tcx).write_u64(&mut size_array, size as u64); + target_endian(tcx).write_u64(&mut size_array, code_size as u64); entry.set(gimli::DW_AT_high_pc, AttributeValue::Data8(size_array)); self.debug_context.unit_range_list.0.push(Range { @@ -402,7 +402,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { }, end: Address::Relative { symbol: self.symbol, - addend: size as i64, + addend: code_size as i64, }, }); @@ -420,39 +420,54 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let func = &context.func; let mut ebbs = func.layout.ebbs().collect::>(); ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase - for ebb in ebbs { - for (offset, inst, _size) in func.inst_offsets(ebb, &encinfo) { - fn create_row_for_span(tcx: TyCtxt, line_program: &mut LineProgram, offset: u64, span: Span) { - let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); - let file = loc.file.name.to_string(); - let file = ::std::path::Path::new(&file); - let dir_id = line_program - .add_directory(file.parent().unwrap().to_str().unwrap().as_bytes()); - let file_id = line_program.add_file( - file.file_name().unwrap().to_str().unwrap().as_bytes(), - dir_id, - None, - ); - line_program.row().file = file_id; - //tcx.sess - // .warn(&format!("srcloc {} {}:{}:{}", offset, file, loc.line, loc.col.to_usize())); - line_program.row().address_offset = offset; - line_program.row().line = loc.line as u64; - line_program.generate_row(); - } + let create_row_for_span = |line_program: &mut LineProgram, span: Span| { + let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + let file = loc.file.name.to_string(); + let file = ::std::path::Path::new(&file); + let dir_id = + line_program.add_directory(file.parent().unwrap().to_str().unwrap().as_bytes()); + let file_id = line_program.add_file( + file.file_name().unwrap().to_str().unwrap().as_bytes(), + dir_id, + None, + ); + + /*println!( + "srcloc {:>04X} {}:{}:{}", + line_program.row().address_offset, + file.display(), + loc.line, + loc.col.to_u32() + );*/ + + line_program.row().file = file_id; + line_program.row().line = loc.line as u64; + line_program.row().column = loc.col.to_u32() as u64 + 1; + line_program.generate_row(); + }; + + let mut end = 0; + for ebb in ebbs { + for (offset, inst, size) in func.inst_offsets(ebb, &encinfo) { let srcloc = func.srclocs[inst]; + line_program.row().address_offset = offset as u64; if !srcloc.is_default() { let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); - create_row_for_span(tcx, line_program, offset as u64, source_info.span); + create_row_for_span(line_program, source_info.span); } else { - create_row_for_span(tcx, line_program, offset as u64, self.mir_span); + create_row_for_span(line_program, self.mir_span); } + end = offset + size; } } - let address_offset = line_program.row().address_offset; - line_program.end_sequence(address_offset); + if code_size != end { + line_program.row().address_offset = end as u64; + create_row_for_span(line_program, self.mir_span); + } + + line_program.end_sequence(code_size as u64); } } From 36f6e2f5080bbc62a2fd6667c20bdbb6de9db822 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 12:28:54 +0100 Subject: [PATCH 0463/1566] Use FileIndex for DW_AT_decl_file and omit .debug_ranges and .debug_rnglists when empty --- src/debuginfo.rs | 130 +++++++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 56 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 44e52bdd00942..005a39a388474 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -2,13 +2,14 @@ extern crate gimli; use crate::prelude::*; +use std::path::Path; use std::marker::PhantomData; use gimli::write::{ Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, RangeList, RangeListTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, - Writer, + Writer, FileId, }; use gimli::{Endianity, Format, RunTimeEndian}; @@ -23,6 +24,17 @@ fn target_endian(tcx: TyCtxt) -> RunTimeEndian { } } +fn line_program_add_file>(line_program: &mut LineProgram, file: P) -> FileId { + let file = file.as_ref(); + let dir_id = + line_program.add_directory(file.parent().unwrap().to_str().unwrap().as_bytes()); + line_program.add_file( + file.file_name().unwrap().to_str().unwrap().as_bytes(), + dir_id, + None, + ) +} + struct DebugReloc { offset: u32, size: u8, @@ -53,7 +65,7 @@ pub struct DebugContext<'tcx> { impl<'a, 'tcx: 'a> DebugContext<'tcx> { pub fn new(tcx: TyCtxt, address_size: u8) -> Self { // TODO: this should be configurable - let version = 4; + let version = 3; // macOS doesn't seem to support DWARF > 3 let format = Format::Dwarf32; // FIXME: how to get version when building out of tree? @@ -71,7 +83,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let range_lists = RangeListTable::default(); let global_line_program = line_programs.add(LineProgram::new( - 3, // FIXME https://github.com/gimli-rs/gimli/issues/363 + version, address_size, format, 1, @@ -135,11 +147,13 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { fn emit_location(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, entry_id: UnitEntryId, span: Span) { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + let line_program = self.line_programs.get_mut(self.global_line_program); + let file_id = line_program_add_file(line_program, loc.file.name.to_string()); + let unit = self.units.get_mut(self.unit_id); let entry = unit.get_mut(entry_id); - let file_id = self.strings.add(loc.file.name.to_string()); - entry.set(gimli::DW_AT_decl_file, AttributeValue::StringRef(file_id)); + entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(file_id)); entry.set( gimli::DW_AT_decl_line, AttributeValue::Udata(loc.line as u64), @@ -218,20 +232,28 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { debug_line.0.writer.into_vec(), ) .unwrap(); - artifact - .declare_with( - SectionId::DebugRanges.name(), - Decl::DebugSection, - debug_ranges.0.writer.into_vec(), - ) - .unwrap(); - artifact - .declare_with( - SectionId::DebugRngLists.name(), - Decl::DebugSection, - debug_rnglists.0.writer.into_vec(), - ) - .unwrap(); + + let debug_ranges_not_empty = !debug_ranges.0.writer.slice().is_empty(); + if debug_ranges_not_empty { + artifact + .declare_with( + SectionId::DebugRanges.name(), + Decl::DebugSection, + debug_ranges.0.writer.into_vec(), + ) + .unwrap(); + } + + let debug_rnglists_not_empty = !debug_rnglists.0.writer.slice().is_empty(); + if debug_rnglists_not_empty { + artifact + .declare_with( + SectionId::DebugRngLists.name(), + Decl::DebugSection, + debug_rnglists.0.writer.into_vec(), + ) + .unwrap(); + } for reloc in debug_abbrev.0.relocs { artifact @@ -297,36 +319,40 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { .expect("faerie relocation error"); } - for reloc in debug_ranges.0.relocs { - artifact - .link_with( - faerie::Link { - from: SectionId::DebugRanges.name(), - to: &reloc.name, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); + if debug_ranges_not_empty { + for reloc in debug_ranges.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugRanges.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } } - for reloc in debug_rnglists.0.relocs { - artifact - .link_with( - faerie::Link { - from: SectionId::DebugRngLists.name(), - to: &reloc.name, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); + if debug_rnglists_not_empty { + for reloc in debug_rnglists.0.relocs { + artifact + .link_with( + faerie::Link { + from: SectionId::DebugRngLists.name(), + to: &reloc.name, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } } } @@ -423,15 +449,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let create_row_for_span = |line_program: &mut LineProgram, span: Span| { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); - let file = loc.file.name.to_string(); - let file = ::std::path::Path::new(&file); - let dir_id = - line_program.add_directory(file.parent().unwrap().to_str().unwrap().as_bytes()); - let file_id = line_program.add_file( - file.file_name().unwrap().to_str().unwrap().as_bytes(), - dir_id, - None, - ); + let file_id = line_program_add_file(line_program, loc.file.name.to_string()); /*println!( "srcloc {:>04X} {}:{}:{}", From ddbbb267b63bf51b813be1d9b151563474c7e8d8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 12:37:49 +0100 Subject: [PATCH 0464/1566] Update gimli --- Cargo.lock | 2 +- src/debuginfo.rs | 34 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7d619dd36a83..e5346109a7354 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -319,7 +319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#9930c6166487e9195e6ba31002685686001f906a" +source = "git+https://github.com/gimli-rs/gimli.git#bedf4f00e460e2229f40bbbad78a6d6974640ba6" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 005a39a388474..79460ff714ec8 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -11,7 +11,7 @@ use gimli::write::{ RangeList, RangeListTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, Writer, FileId, }; -use gimli::{Endianity, Format, RunTimeEndian}; +use gimli::{Encoding, Format, RunTimeEndian}; use faerie::*; @@ -43,10 +43,8 @@ struct DebugReloc { } pub struct DebugContext<'tcx> { + encoding: Encoding, endian: RunTimeEndian, - format: Format, - version: u16, - address_size: u8, symbols: indexmap::IndexSet, @@ -64,9 +62,13 @@ pub struct DebugContext<'tcx> { impl<'a, 'tcx: 'a> DebugContext<'tcx> { pub fn new(tcx: TyCtxt, address_size: u8) -> Self { - // TODO: this should be configurable - let version = 3; // macOS doesn't seem to support DWARF > 3 - let format = Format::Dwarf32; + let encoding = Encoding { + format: Format::Dwarf32, + // TODO: this should be configurable + // macOS doesn't seem to support DWARF > 3 + version: 3, + address_size, + }; // FIXME: how to get version when building out of tree? // Normally this would use option_env!("CFG_VERSION"). @@ -83,9 +85,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let range_lists = RangeListTable::default(); let global_line_program = line_programs.add(LineProgram::new( - version, - address_size, - format, + encoding, 1, 1, -5, @@ -95,7 +95,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { None, )); - let unit_id = units.add(CompilationUnit::new(version, address_size, format)); + let unit_id = units.add(CompilationUnit::new(encoding)); { let name = strings.add(&*name); let comp_dir = strings.add(&*comp_dir); @@ -124,10 +124,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { } DebugContext { + encoding, endian: target_endian(tcx), - format, - version, - address_size, symbols: indexmap::IndexSet::new(), @@ -189,9 +187,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { .write( &mut debug_ranges, &mut debug_rnglists, - self.format, - self.version, - self.address_size, + self.encoding ) .unwrap(); self.units @@ -417,9 +413,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let unit = self.debug_context.units.get_mut(self.debug_context.unit_id); // FIXME: add to appropriate scope intead of root let entry = unit.get_mut(self.entry_id); - let mut size_array = [0; 8]; - target_endian(tcx).write_u64(&mut size_array, code_size as u64); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Data8(size_array)); + entry.set(gimli::DW_AT_high_pc, AttributeValue::Data8(code_size as u64)); self.debug_context.unit_range_list.0.push(Range { begin: Address::Relative { From c4d010b8a505ddbc4ad5b2ef6453924c11a3d71c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 12:49:33 +0100 Subject: [PATCH 0465/1566] Deduplicate debug section defining and linking --- src/debuginfo.rs | 147 +++++++++-------------------------------------- 1 file changed, 26 insertions(+), 121 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 79460ff714ec8..7dd9a47bd05fe 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -200,127 +200,37 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { ) .unwrap(); - artifact - .declare_with( - SectionId::DebugAbbrev.name(), - Decl::DebugSection, - debug_abbrev.0.writer.into_vec(), - ) - .unwrap(); - artifact - .declare_with( - SectionId::DebugInfo.name(), - Decl::DebugSection, - debug_info.0.writer.into_vec(), - ) - .unwrap(); - artifact - .declare_with( - SectionId::DebugStr.name(), - Decl::DebugSection, - debug_str.0.writer.into_vec(), - ) - .unwrap(); - artifact - .declare_with( - SectionId::DebugLine.name(), - Decl::DebugSection, - debug_line.0.writer.into_vec(), - ) - .unwrap(); - - let debug_ranges_not_empty = !debug_ranges.0.writer.slice().is_empty(); - if debug_ranges_not_empty { + macro decl_section($section:ident = $name:ident) { artifact .declare_with( - SectionId::DebugRanges.name(), + SectionId::$section.name(), Decl::DebugSection, - debug_ranges.0.writer.into_vec(), + $name.0.writer.into_vec(), ) .unwrap(); } - let debug_rnglists_not_empty = !debug_rnglists.0.writer.slice().is_empty(); - if debug_rnglists_not_empty { - artifact - .declare_with( - SectionId::DebugRngLists.name(), - Decl::DebugSection, - debug_rnglists.0.writer.into_vec(), - ) - .unwrap(); - } - - for reloc in debug_abbrev.0.relocs { - artifact - .link_with( - faerie::Link { - from: SectionId::DebugAbbrev.name(), - to: &reloc.name, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); - } - - for reloc in debug_info.0.relocs { - artifact - .link_with( - faerie::Link { - from: SectionId::DebugInfo.name(), - to: &reloc.name, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); - } + decl_section!(DebugAbbrev = debug_abbrev); + decl_section!(DebugInfo = debug_info); + decl_section!(DebugStr = debug_str); + decl_section!(DebugLine = debug_line); - for reloc in debug_str.0.relocs { - artifact - .link_with( - faerie::Link { - from: SectionId::DebugStr.name(), - to: &reloc.name, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); + let debug_ranges_not_empty = !debug_ranges.0.writer.slice().is_empty(); + if debug_ranges_not_empty { + decl_section!(DebugRanges = debug_ranges); } - for reloc in debug_line.0.relocs { - artifact - .link_with( - faerie::Link { - from: SectionId::DebugLine.name(), - to: &reloc.name, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); + let debug_rnglists_not_empty = !debug_rnglists.0.writer.slice().is_empty(); + if debug_rnglists_not_empty { + decl_section!(DebugRngLists = debug_rnglists); } - if debug_ranges_not_empty { - for reloc in debug_ranges.0.relocs { + macro sect_relocs($section:ident = $name:ident) { + for reloc in $name.0.relocs { artifact .link_with( faerie::Link { - from: SectionId::DebugRanges.name(), + from: SectionId::$section.name(), to: &reloc.name, at: u64::from(reloc.offset), }, @@ -333,22 +243,17 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { } } + sect_relocs!(DebugAbbrev = debug_abbrev); + sect_relocs!(DebugInfo = debug_info); + sect_relocs!(DebugStr = debug_str); + sect_relocs!(DebugLine = debug_line); + + if debug_ranges_not_empty { + sect_relocs!(DebugRanges = debug_ranges); + } + if debug_rnglists_not_empty { - for reloc in debug_rnglists.0.relocs { - artifact - .link_with( - faerie::Link { - from: SectionId::DebugRngLists.name(), - to: &reloc.name, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); - } + sect_relocs!(DebugRngLists = debug_rnglists); } } From 400acefcada4b3152bb70babe926c4d782713dcd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 26 Jan 2019 12:12:45 +0000 Subject: [PATCH 0466/1566] Bump cranelift from `a7ea916` to `4e096e2` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `a7ea916` to `4e096e2`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/a7ea916dcd8e2849f9271324ce3814db36fd43e9...4e096e29cecc762e345cfc62c34e3113ba5777d7) Signed-off-by: dependabot[bot] --- Cargo.lock | 106 ++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5346109a7354..e799ceaa132c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,29 +111,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -142,24 +142,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" [[package]] name = "cranelift-faerie" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -168,46 +168,46 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.26.0" -source = "git+https://github.com/CraneStation/cranelift.git#a7ea916dcd8e2849f9271324ce3814db36fd43e9" +version = "0.28.0" +source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" dependencies = [ - "cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -561,7 +561,7 @@ dependencies = [ [[package]] name = "region" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -590,10 +590,10 @@ dependencies = [ "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)", @@ -865,16 +865,16 @@ dependencies = [ "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cranelift 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.26.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" @@ -916,7 +916,7 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" -"checksum region 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cff177f64744f6f2a2054d231279383e59b0857b4d58dc2e8881e60b58aec8e5" +"checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" From 4fbff29a4a0bbd8362958d20e4ca8fba185330cb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 14:06:02 +0100 Subject: [PATCH 0467/1566] Misc debuginfo change --- src/debuginfo.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 7dd9a47bd05fe..f7ebaefff8e23 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -316,9 +316,8 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, ) { let unit = self.debug_context.units.get_mut(self.debug_context.unit_id); - // FIXME: add to appropriate scope intead of root let entry = unit.get_mut(self.entry_id); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Data8(code_size as u64)); + entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(code_size as u64)); self.debug_context.unit_range_list.0.push(Range { begin: Address::Relative { From 4bca86c236c7ebb35811491d1a1c64e9050b27c0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 15:10:21 +0100 Subject: [PATCH 0468/1566] Use malloc in mini_core::allocate --- example/mini_core.rs | 56 +++++++++++++++++++++++++++++--- example/mini_core_hello_world.rs | 16 +++------ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index a3ab762328737..8b21d62ea5407 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -51,6 +51,7 @@ unsafe impl Copy for isize {} unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl Copy for *const T {} +unsafe impl Copy for *mut T {} #[lang = "sync"] pub unsafe trait Sync {} @@ -118,6 +119,14 @@ impl Add for u8 { } } +impl Add for usize { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + #[lang = "sub"] pub trait Sub { type Output; @@ -172,6 +181,33 @@ impl PartialEq for u8 { } } +impl PartialEq for u16 { + fn eq(&self, other: &u16) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u16) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for u32 { + fn eq(&self, other: &u32) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u32) -> bool { + (*self) != (*other) + } +} + +impl PartialEq for usize { + fn eq(&self, other: &usize) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &usize) -> bool { + (*self) != (*other) + } +} + impl PartialEq for char { fn eq(&self, other: &char) -> bool { (*self) == (*other) @@ -230,7 +266,7 @@ pub trait FnMut: FnOnce { } #[lang = "panic"] -pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! { +pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! { unsafe { intrinsics::abort(); } @@ -254,11 +290,12 @@ pub struct Box(*mut T); impl, U: ?Sized> CoerceUnsized> for Box {} -static mut MY_TINY_HEAP: [u8; 16] = [0xff; 16]; - #[lang = "exchange_malloc"] +// Make it available to jited mini_core_hello_world +// FIXME remove next line when jit supports linking rlibs +#[inline(always)] unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { - &mut MY_TINY_HEAP as *mut [u8; 16] as *mut u8 + libc::malloc(size) } #[lang = "drop"] @@ -281,6 +318,17 @@ pub mod intrinsics { } } +pub mod libc { + #[link(name = "c")] + extern "C" { + pub fn puts(s: *const u8); + pub fn malloc(size: usize) -> *mut u8; + pub fn memcpy(dst: *mut u8, src: *const u8, size: usize); + pub fn memmove(dst: *mut u8, src: *const u8, size: usize); + pub fn strncpy(dst: *mut u8, src: *const u8, size: usize); + } +} + #[lang = "index"] pub trait Index { type Output: ?Sized; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 638db7d24ef95..1ddd203e02886 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -7,11 +7,7 @@ extern crate mini_core; use mini_core::*; - -#[link(name = "c")] -extern "C" { - fn puts(s: *const u8); -} +use mini_core::libc::*; unsafe extern "C" fn my_puts(s: *const u8) { puts(s); @@ -132,13 +128,9 @@ fn main() { let ptr: *const u8 = hello as *const [u8] as *const u8; puts(ptr); - // TODO remove when jit supports linking rlibs - #[cfg(not(jit))] - { - let world: Box<&str> = box "World!\0"; - puts(*world as *const str as *const u8); - world as Box; - } + let world: Box<&str> = box "World!\0"; + puts(*world as *const str as *const u8); + world as Box; assert_eq!(intrinsics::size_of_val(hello) as u8, 6); From 4eb0c0787acea41a7079582563f4d2c8ca0cc33a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 15:14:39 +0100 Subject: [PATCH 0469/1566] Print a message when panicking from mini_core --- example/mini_core.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/example/mini_core.rs b/example/mini_core.rs index 8b21d62ea5407..ebd35f7bdcdbb 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -268,6 +268,7 @@ pub trait FnMut: FnOnce { #[lang = "panic"] pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! { unsafe { + libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort(); } } From 33bdb7e91994b779097723b05cc45c3b6c634d7e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 15:16:58 +0100 Subject: [PATCH 0470/1566] Use mini_core::panic with jit --- example/mini_core.rs | 3 +++ example/mini_core_hello_world.rs | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index ebd35f7bdcdbb..74daedb1df4f0 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -266,6 +266,9 @@ pub trait FnMut: FnOnce { } #[lang = "panic"] +// Make it available to jited mini_core_hello_world +// FIXME remove next line when jit supports linking rlibs +#[inline(always)] pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 1ddd203e02886..2e39a3aae8692 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -13,14 +13,6 @@ unsafe extern "C" fn my_puts(s: *const u8) { puts(s); } -// TODO remove when jit supports linking rlibs -#[cfg(jit)] -extern "C" fn panic(_: T) -> ! { - unsafe { - intrinsics::abort(); - } -} - #[lang = "termination"] trait Termination { fn report(self) -> i32; From efb64ea24264b8e672b1962a5d42bff1ffa2c49c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 15:19:27 +0100 Subject: [PATCH 0471/1566] Remove accidentially checked in file --- mini_core_hello_world | Bin 25736 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 mini_core_hello_world diff --git a/mini_core_hello_world b/mini_core_hello_world deleted file mode 100755 index f7f7af4b14465a76582bda46c9483476c13a1032..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25736 zcmeHv3wT@AmF_-1maO<8%XxqyKu$me2Z$ocmMn+79PA+HIw1`XHi01Yv<-e?Ng<)M zq)DK0LWTfoZ(2HS=KDHBX39*{7CN-$Ym?KRbQXcb7=lkyc*tX8vd+oK>UVH7=IeYDM?r-m0S*B@%gD#c|N*!>RnB^*C=LQu4 zSS~_h8mWYN}{jp%v!hyts zf&QWF<^`KW!3Du4PkPwnm-Qz3M0>-U^|B8?z!T(yV8R%e^*f_VX%UIUH%B9>{-NkV|Gh~hDL<0VL`O4` z!D#=Gh;($VjwF(!$=?2SCOO)*`uc(4p=4JyHbB(9gTq6LIwB$)*0c=v5A{dl!=uSi zbYNgO9?c|u&3!(}a^$fa<=g1y{_3yFZS)UOL z{%s{^s|C;U_gnDqD#IVN;4e~x;u#B`sAY%>Gxakt&0Aj1<&+{EqJCsX2CQ4@i~S4ipRe& z3h|tFS?~^(KCI->+)v|*!wY$M9)py3EDulfFNat1@Vur_-gq89f89NqhtFSkPUqn( zSU6yK``eE2Zd>v~LxdkVoGF_)7T*4xKOp`iAL!w+li?%d%fj0C z!!Li3sfVzyC}Gv6Fq7XZZ|jmHAQRcE!rPa8l49#2FH;@fy<{6w<24f#6XRiAHh$l> z9|-N8srqQsq4f4;B3t$5?VvREM)~tWPquuML{1#r_~vrt!p`-F>|d!k^?L2zBd3mN zJKNl~*(JMhE!S!vRT!tlIP)+y5>vC&_U7aVE5SWCu1M0 ztpetACT4IFv&+QXsxY;4wvs{DhQ}7W!@KFXY+}~U5ZiNf(%PxLh55k}`FoZemhF7O zlzh~;Av|`U+Z7(mxa-4XU2bEd%k3I}_k)Rvu{L-0Zv4XW7s6vNpe_wZ_kzCso!Yu` zH`?om!Xe+ZY1l-yk#Zv9&^@FpAh5 zetw60D@c(BIU&Y&xOd9Lvl33sx_zc0zT*Pw+cfV@%t|30-V-R7BAySAdBe{ychGPN zk3H+&D_M6a2-Ncvvo0lu-DWxABgcW<;dYUpz)1*2?x4c&*m-2@AMBawXrfjZc=p&{ z!f-Yl&Gu`kPn`Qz2@)cGfYPYNK|qj5sT4;^Wkg@EN|F#I^-xJYJC7VH|ElfOFKYLG z_tbZ_ot^G(bhevoANXs`H|TKPyE@%BhhC7X*iBWIO{%h^)_`&~vnXTiA@?CF4JADz zOMli(qi&R*Sc}odS<4+nW+;UughF9bC`?s%$?|?ArQ3dt8BSImb!z|%ikEexI5pjJ zVp~pZ<&y0?CfoizHZMqN{v-`3PHZ7!3lUqHWIJTCMf2D~Af=`zHi{FQm)N{JkC3I8 z=koW-IIOo&c3z?}b{^T)T$aa>G8w+07)ZmzD1!pU*MdvhZjbGcfYbuVRMsni zv^0kIJS%bI-vTXq-Ba&lkbrKS@?ZoBA2?jQ??~;}UmiO~_Hbn{JAphz!rR9+!Z@;( zC&VEQ^|Q2lhMNWfu zd=wW+`g4=?yG;68_!H0dAVCvbdyN$HH!3eh^F#eEn}=!{|1k*O{&%WJhUS+ag?D3S zp$T>TL10_Q4!4aRmNVq!ghu?Bj~2V7I-wH-a@Gm&#(Z;Er`sXI+6&>`h=jKvL5(Rg z_Wbx}sv7Lz2ww+dWPWhs$29%8WVb_v`jI&CuQU^3Ahgjehs*d1#Z^ySM&{E*fnq2x zM`fINZBjS6-pTnkZ@!ahnxDrX{o}+$&(Xvs&Uu_ls%=HCjxyats zMhyRFhOmPlB{J{^FL}PJIisa_#;K)F7VeWY-(wD>oQRJTC(Sd|# zG#$-kl7k}|BQtCaW(P9;BLiEEd-^kd#_*=(Xlh{io}45zl1Cp+BnnA8hK7=(M(=RO zNQ@4Tj3g6tMVJZ`-Bj3I(La>}Ni%09i7MyFOq66uq)|-e$28N@F$Y?g5iHwXUGnp*_5StuLdq%dv z{@QH)IvVRv{ARv4G4ULr8}MzwCcu4wiBl63<(Q4$1#|<>{QbnlV!$TAF2F9p0l*!A zI{^0qeh%=9fKL&`%=8n$=P>`i4cPRjiHRo6Br_qKf_CpZp>1|)v#To{d$kG|;V;2& z|GN_t*ARgU#p$6h@`*kSdb*(zPS;9j{i@okdmLNEvWu^~y3u_(p^3i@KQHLy1V%^% z;=K*O9@KY?5N%GQY>m^=ibEb^yM*L*d^=@+9!`xdr9615f%^!;a&?f1o3AgY$Tq{)SE(A6It0 z7WpsyVPYbHY^u))_^9q}z#qdbnk4)Rr|aRe70&v<(A%BHp7IsWhKFonr}sg7*csYh zvD&$O)ER1ZdRv_hE1U-CK)*ui^$_Hoh8z_4VffGjA6no;3w&sS|IaPJ``*0I&DG`o z;kk@Z`@e=t)A~%$W4y0T>z52A=y*R{uH_))wVL;{dH;I862tqKhDtxI;Mw$g40Ma| zR=MaTQm*Orh+ejEzC553Mz3TwHa zQ+VEg=612teO}S=zVlTj#tvAG_)mS{m~&K=xOwL z7x+TgB$Ba~tZ%-FF#KL$vp3)iif=-g*{+wtJTas``q6$oW`FEs;_qQ#>8}g}yJr3B z$h!8GVk3~5=v~Q3s?jeNni+yLD*99|XpR_;-IEed@OT`0RMs}$G?rc)@f@w54GCZ0QKZUNFGSX8Dr1%4VWr8&S7RTdR9cylhgxg!!ir0{v?2C-x zxp$b{)tN2gDR5&uMEq~SbT%fw0+NyFP=8$93k)_^#2Ub%;fz>?oS~$pDzp`ryj$#$ zdDL)1Tnz2-kKllg^jz6W03l`qc|DA4*(12@N2hC)47j-3Aplq#pQ>Tu~D0* zvzP5HAj_6Qum8P(b$?rdv5l*Fki`c32V8(9ybSr#OV4*5$>O zl(b1D*O{sMO){nOjQeEjHsm>|78-t{;-nHtPsmz#7`UyJw~0!wkqk*m$I~>;zFPMf zaNi@kdx-8aNw*bRi)k)3ozoMv*8MWBQl%}Gdy!kEKXO|9L{e{m2w9bPn8=;l0y4F> zV>*!4|6Pe7qk&_u_E(5#+OEGtrl|Cq*!|jDQqCh^BRRkk=>dg&^k*dJF}3o27P66f zNV@`kUDH1G1Su**&0@%KIh?Zq-UZenoYdR4APSz^7~(>!c@eQHPL1#vreb91azZx_fN_-9p9F=YqGqv|G+R{g)JRh)U|evKUZRnU3g3cG)g<@?MM&&>6d}zFvI#7Y|JO(mel#_&1Ue1dn=s9-Z(2cUJo4m$FlXvynM zTDwWBQWZUzQZ$WHR?Y@+-9?<4bLU(t%Nz#R)5N*G$1KxfmZ?%MvrI}&mN{Q?egj-( zSZ%b&rq&Gg)J)F8dR`?t9pI9jj~8-oGBv0z%{c(hr>M*)3OVmry2qr2C^f0AS>`{2 zYl1lc?%X*Wq_$<4mt~oU3ORQclu4<{GEL4-aLO{jcJ7>XU!iq>8l11*;iPIJ1brRm}wlZU1YstKkGStd;vReu2%tZrJJcBONMO?SF3ob7yS#YJ`6`U_Eq z7EQ-3h2A7|XUB|1Ro7LO)eiwtK8e_=)tWe)2QsGHmxDle5^2W_w3JPh)lViXtTa$& zq3D=Fg-o;N-HAr2tde?EHAyijiv?F#$jWrHG!z zeAb%5fMgf0i;YcSH_ND)EW?pkhiQ2=t<0+r8gWvSYOYPqWDU=vU9K%{s&TFAcFb4? zli3QJ(q4?}lNtysJi^)$mR%%s92Op%DS4V%?aIk&%LK|B>MA$bs_hw@&E8jrgS3>rm9v)=%|5`{-xHdx z8tk^0nDa1a{WG%4D;1ceEl@=uF9;f+`d9gyp%Lq<4OIikn6I)Xw&p*+iaEkz2Mt!bG>gXcU)$x z3E12Z*lJ#v39ZT2qIYjAn~o-+$JKIiKdw_d+gTuv5Mq9Ks};+ zio8c9o#Pf;EfkZKQ+4~SNizdIBUOs#ZzRo&=*J-GL4mhSsp8+Bo#e|?NmQfc4E5Es zle`3yX_b$_);;=D7=`)|w7t-1iOul|u0P*h>Elw|hBDk9P(R5P^IPD{D;M%q!Z%U+ z_AQAD!Kd5*J@P2xmbK1=;KR=(IU?@O-FV%zP zQ+@v%pCoZuKd!WvSir?SOk(8Myx3DRDz01N7@6{o(`BpW|8@cHM@KkETBaelM< zPh{zU+vJWibPF~{+?`!+cjsESdmVmR zztGXkYYn^ALb%pVLUd`;gP1B-hD@Xb( z&atpWz#B|9HiiN%Ex~xG8C|673>_mN-7nD5mu&V0VyR#%8uN#IzCgQ}bjy0A{t2fgYA=UqtXI=J}JTU`#^}-8%PCPg25)A-u|Gll{fs97;GERP*>7BLJ)NAH3BsKPRM&m{?FE@tBb%10+H)Hl}# z`7?B0Z&3cjvy>7GdK1ZjuQ}vP#%ZEC-%{W%q*gh1oG2y+C2F&|!B-LR&yMNYG^;o*T2v)h_sIe|CA@kl}vsTkIa zsJ9UdM=Y9Zmkvo1)GP&MLnXwl&JNIo+z3A=#Khp}3?<`@jozllq`$ct(*yjQ=OCsv zk&t4*4>2i!ED-WyEp3dqM5DAAlLHlEn!KhqG?GdvbW=7aCBfASNxqP;CFE~RMVk__ z#^z89CSSNPm7o(Svp|ZK8m28T&cpthyI?#SMiSj4!hQ`g! zv8F&U8f}ipQ!UXL#&q)T^A|Nl??*Rz{a(xs39q*);Ex6{vf-*Gtpd`JH0zaUks^A9 z0*NT@m6EAM%?U$`Euqw!WUuTdL&;uL zF51%4;*B=Pn&aMIMYY#s9aJa$;~69cnf|YiTB@!lGxP1$clLJ^WoE@jb zdA#!$Q}VOsXa)JD^Oj5U`(j-r&oHl%gykjO;EY@@KGh0`1a&McmHwto; zN{f*zckp&@QRp_7q9qS>_ zzIjVQM9ERv&(oLZ$u3%Qn{3Hf+TBa=hX9F*h|q_!cymaHz~ zG)#Kcv1Qp zx$nmm($CC&Kc)~rOB|eSwM1Mswa^T%l@ES1X z;&&6)3|b{Loc6Z13+=m>;X6skEd7lvMtB!*=qiC8g}1&x(FVMhXMfUz!cF*Tc*~H_ zvr8l{bUu~j^ZOW#e-IH3Z(8vAc*g%VBE{+7Az#O z2pbjtfJM&t6rPuHLsH{ZAMm7)wI5EyksxYB>->2M@EYEN;P)noih>__`VQFvWneUu z3@d=2n>RmSuJ9?~4HeG^+oYU)j2Yjjr&G`m&lSe#?h}r+QiCKVCx4)4+4vDb*!#kbF_(ejq-Y zNoTUDln49FkyY2Pi*$C})P>F7$xqBhGJ}ygePoWlPL~*t^bQQiq63ixUKdD5qS?(N zK1`oh$RrbIW~Et5`wvRUyBH&Fx2$Ph-EsXHM%Njff7C(# zD}0k@Y2K+Wlmb&q7bThopD2yAhgExp+t!K54V^cxXzh&LxN_x9?OlA4~FLILX&RcI63nUZX^;*ql)xlQqwP5^b?|I z?&DM4aFGZ;Xv%}7} zdWW)}ShgSEx$RE~52gB|=|15}Y#D+)6T;&wbJWR?fQJqLW1>PTHh_@FC0+p2?b|I0^&--W$`MH&OIL+{3 z3qS9-F=Tz2-mc)3+as#@t@dBuY;ruU_EDK17m96){vR#De_HY1Z4tob zvb^0T`1@Cy6noENf0Ab*F&R5dP_Np59+LkJKeivQ|CDV}Q8L!658u4Z16N|rv8JLD T)Zto;|4lV;KVzw|B`N+d>q|}! From 52a43e963961d1e78cc8d272044e1d23cada19f0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 17:03:35 +0100 Subject: [PATCH 0472/1566] Update Readme.md --- Readme.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Readme.md b/Readme.md index 99e21e96e3962..230a08191ff5b 100644 --- a/Readme.md +++ b/Readme.md @@ -7,29 +7,29 @@ ```bash $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift -$ rustup override set nightly # This uses unstable api's which will never be stabilized -$ cargo install xargo # Used for building the sysroot -$ cargo install hyperfine # Used for benchmarking in build.sh -$ cargo build +$ ./prepare.sh # downloads and patches sysroot src and installs hyperfine for benchmarking +$ ./test.sh ``` ## Usage +`$cg_clif_dir` is the directory you cloned this repo into in the following instruction. + +### Rustc + ```bash -$ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_crate.rs +$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.so my_crate.rs ``` -## Build sysroot and test +### Cargo ```bash -$ rustup component add rust-src # Make sure the sysroot source is available -$ ./prepare_libcore.sh # Patch the sysroot source for some not yet supported things -$ ./build.sh +$ RUSTFLAGS="-Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.dylib --sysroot $cg_clif_dir/build_sysroot/sysroot" cargo run ``` ## Not yet supported -* Good non-rust abi support ([non scalars are not yet supported for the "C" abi](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) +* Good non-rust abi support ([scalar pair and vector are passed by-ref](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) * Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) * Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444)) * Varargs ([no cranelift support](https://github.com/CraneStation/cranelift/issues/212)) From 35d470587fdda3ec6e27618237136ce2847cc0fa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Jan 2019 17:17:17 +0100 Subject: [PATCH 0473/1566] Update Cargo.lock --- Cargo.lock | 140 +++++++++++++++++++++++++++-------------------------- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e799ceaa132c3..f114524a18102 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "aho-corasick" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -19,7 +19,7 @@ name = "ar" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -35,7 +35,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -53,7 +53,7 @@ dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -64,7 +64,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -74,7 +74,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.2.7" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -206,7 +206,7 @@ dependencies = [ "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -242,7 +242,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -252,7 +252,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -286,8 +286,8 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -322,7 +322,7 @@ version = "0.16.1" source = "git+https://github.com/gimli-rs/gimli.git#bedf4f00e460e2229f40bbbad78a6d6974640ba6" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -371,7 +371,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.47" +version = "0.2.48" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -387,17 +387,16 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -412,7 +411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -425,10 +424,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -437,9 +436,9 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -454,12 +453,20 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.3.0" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -467,7 +474,7 @@ name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -475,7 +482,7 @@ name = "rand_isaac" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -485,8 +492,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -496,7 +503,7 @@ name = "rand_pcg" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -505,7 +512,7 @@ name = "rand_xorshift" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -523,12 +530,12 @@ name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.50" +version = "0.1.51" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -536,7 +543,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -545,7 +552,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -565,7 +572,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -589,7 +596,7 @@ version = "0.1.0" dependencies = [ "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -598,7 +605,7 @@ dependencies = [ "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -630,8 +637,8 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -650,17 +657,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -673,7 +680,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -696,8 +703,8 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -706,8 +713,8 @@ name = "syn" version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -716,8 +723,8 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -729,7 +736,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -738,9 +745,9 @@ version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -758,8 +765,8 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -809,11 +816,6 @@ name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.6" @@ -860,7 +862,7 @@ dependencies = [ "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" +"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -893,18 +895,19 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" +"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" +"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.25 (registry+https://github.com/rust-lang/crates.io-index)" = "d3797b7142c9aa74954e351fc089bbee7958cebbff6bf2815e7ffff0b19f547d" +"checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" +"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" "checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46fbd5550acf75b0c2730f5dd1873751daf9beb8f11b44027778fae50d7feca" @@ -912,7 +915,7 @@ dependencies = [ "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" +"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" @@ -925,8 +928,8 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.84 (registry+https://github.com/rust-lang/crates.io-index)" = "0e732ed5a5592c17d961555e3b552985baf98d50ce418b7b655f31f6ba7eb1b7" -"checksum serde_json 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "574378d957d6dcdf1bbb5d562a15cbd5e644159432f84634b94e485267abbcc7" +"checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" +"checksum serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "4b90a9fbe1211e57d3e1c15670f1cb00802988fb23a1a4aad7a2b63544f1920e" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" @@ -946,7 +949,6 @@ dependencies = [ "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" From 00e6462334d49bf9211e71da588b11ed5ae550b5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Jan 2019 17:51:21 +0100 Subject: [PATCH 0474/1566] Fix offset addend mixup --- src/constant.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 861526653c0c9..6411e3d8563bd 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -243,7 +243,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( data_ctx.define(alloc.bytes.to_vec().into_boxed_slice()); for &(offset, (_tag, reloc)) in alloc.relocations.iter() { - let reloc_offset = { + let addend = { let endianness = tcx.data_layout.endian; let offset = offset.bytes() as usize; let ptr_size = tcx.data_layout.pointer_size; @@ -253,9 +253,10 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { AllocKind::Function(instance) => { + assert_eq!(addend, 0); let func_id = crate::abi::import_function(tcx, module, instance); let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx); - data_ctx.write_function_addr(reloc_offset as u32, local_func_id); + data_ctx.write_function_addr(offset.bytes() as u32, local_func_id); continue; } AllocKind::Memory(_) => { @@ -269,7 +270,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( }; let global_value = module.declare_data_in_data(data_id, &mut data_ctx); - data_ctx.write_data_addr(reloc_offset as u32, global_value, 0); + data_ctx.write_data_addr(offset.bytes() as u32, global_value, addend as i64); } module.define_data(data_id, &data_ctx).unwrap(); From bdf13205081c6222cc275eb025b4f62a9f4ee967 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Jan 2019 18:11:30 +0100 Subject: [PATCH 0475/1566] Fix panic_if_uninhabited intrinsic --- src/intrinsics.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 2b0c44c2f6f53..eee3a04fd1b44 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -355,6 +355,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( panic_if_uninhabited, () { if fx.layout_of(T).abi.is_uninhabited() { crate::trap::trap_panic(&mut fx.bcx); + return; } }; From f6ad4198b3648c984c74d5f5e2090391a209d1b5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Jan 2019 20:28:04 +0100 Subject: [PATCH 0476/1566] Rustup to rustc 1.34.0-nightly (d8a0dd7ae 2019-01-28) --- Cargo.lock | 2 + ...002-Disable-u128-and-i128-in-libcore.patch | 112 +++++++++--------- 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f114524a18102..5d47fc8df35fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "aho-corasick" version = "0.6.9" diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 64e5592f2a9f6..5c922a753d2aa 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,31 +1,31 @@ -From 76c92b0dcd7919dab3a48d707d615f260390b839 Mon Sep 17 00:00:00 2001 +From e56a552cfe6d51ec4db5ea69aff1c46c0090f470 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 26 Jan 2019 11:50:08 +0100 +Date: Tue, 29 Jan 2019 20:19:01 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- - src/libcore/clone.rs | 4 +- - src/libcore/cmp.rs | 6 +- - src/libcore/default.rs | 2 - - src/libcore/fmt/num.rs | 6 +- - src/libcore/hash/mod.rs | 20 ------ - src/libcore/iter/range.rs | 1 - - src/libcore/iter/traits.rs | 2 +- - src/libcore/lib.rs | 2 - - src/libcore/marker.rs | 4 +- - src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 100 ++++++++-------------------- - src/libcore/num/wrapping.rs | 14 ++-- - src/libcore/ops/arith.rs | 22 +++---- - src/libcore/ops/bit.rs | 30 ++++----- - src/libcore/sync/atomic.rs | 28 -------- - src/libcore/tests/iter.rs | 15 ----- - src/libcore/tests/num/mod.rs | 18 ----- - src/libcore/time.rs | 123 ----------------------------------- - src/libstd/lib.rs | 4 -- - src/libstd/net/ip.rs | 20 ------ - src/libstd/num.rs | 2 +- - src/libstd/panic.rs | 6 -- + src/libcore/clone.rs | 4 +- + src/libcore/cmp.rs | 6 +- + src/libcore/default.rs | 2 - + src/libcore/fmt/num.rs | 6 +- + src/libcore/hash/mod.rs | 20 ------- + src/libcore/iter/range.rs | 1 - + src/libcore/iter/traits/accum.rs | 2 +- + src/libcore/lib.rs | 2 - + src/libcore/marker.rs | 4 +- + src/libcore/mem.rs | 2 - + src/libcore/num/mod.rs | 100 +++++++++---------------------- + src/libcore/num/wrapping.rs | 14 ++--- + src/libcore/ops/arith.rs | 22 +++---- + src/libcore/ops/bit.rs | 30 ++++------ + src/libcore/sync/atomic.rs | 28 --------- + src/libcore/tests/iter.rs | 15 ----- + src/libcore/tests/num/mod.rs | 18 ------ + src/libcore/time.rs | 123 --------------------------------------- + src/libstd/lib.rs | 4 -- + src/libstd/net/ip.rs | 20 ------- + src/libstd/num.rs | 2 +- + src/libstd/panic.rs | 6 -- 22 files changed, 63 insertions(+), 368 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs @@ -204,11 +204,11 @@ index 66c09a0..1b8c5c9 100644 macro_rules! range_exact_iter_impl { ($($t:ty)*) => ($( -diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs -index e8c6cd8..f58b446 100644 ---- a/src/libcore/iter/traits.rs -+++ b/src/libcore/iter/traits.rs -@@ -901,7 +901,7 @@ macro_rules! float_sum_product { +diff --git a/src/libcore/iter/traits/accum.rs b/src/libcore/iter/traits/accum.rs +index dfe1d2a..06cc578 100644 +--- a/src/libcore/iter/traits/accum.rs ++++ b/src/libcore/iter/traits/accum.rs +@@ -111,7 +111,7 @@ macro_rules! float_sum_product { )*) } @@ -218,10 +218,10 @@ index e8c6cd8..f58b446 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 74a7115..634df60 100644 +index cde7e7c..094e1fb 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -149,14 +149,12 @@ mod uint_macros; +@@ -146,14 +146,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -237,10 +237,10 @@ index 74a7115..634df60 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 65752ba..d3b797a 100644 +index 457d556..91425fb 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs -@@ -663,8 +663,8 @@ mod copy_impls { +@@ -664,8 +664,8 @@ mod copy_impls { } impl_copy! { @@ -252,7 +252,7 @@ index 65752ba..d3b797a 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 8fcbb73..0e20b88 100644 +index 0eeac5e..d8277ef 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -163,12 +163,10 @@ pub fn forget_unsized(t: T) { @@ -269,7 +269,7 @@ index 8fcbb73..0e20b88 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 423b800..b2b3f90 100644 +index 7cf2317..f928d40 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -102,13 +102,11 @@ nonzero_integers! { @@ -286,7 +286,7 @@ index 423b800..b2b3f90 100644 #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); } -@@ -2125,18 +2123,6 @@ impl i64 { +@@ -2074,18 +2072,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -305,7 +305,7 @@ index 423b800..b2b3f90 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4440,17 +4426,6 @@ impl u64 { +@@ -4316,17 +4302,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -323,7 +323,7 @@ index 423b800..b2b3f90 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4534,7 +4509,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4410,7 +4385,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -332,7 +332,7 @@ index 423b800..b2b3f90 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4650,30 +4625,25 @@ macro_rules! rev { +@@ -4526,30 +4501,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -367,7 +367,7 @@ index 423b800..b2b3f90 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4685,21 +4655,21 @@ mod ptr_try_from_impls { +@@ -4561,21 +4531,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -397,7 +397,7 @@ index 423b800..b2b3f90 100644 } #[cfg(target_pointer_width = "32")] -@@ -4708,24 +4678,24 @@ mod ptr_try_from_impls { +@@ -4584,24 +4554,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -430,7 +430,7 @@ index 423b800..b2b3f90 100644 } #[cfg(target_pointer_width = "64")] -@@ -4734,24 +4704,20 @@ mod ptr_try_from_impls { +@@ -4610,24 +4580,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -459,7 +459,7 @@ index 423b800..b2b3f90 100644 } #[doc(hidden)] -@@ -4786,7 +4752,7 @@ macro_rules! doit { +@@ -4662,7 +4628,7 @@ macro_rules! doit { } })*) } @@ -468,7 +468,7 @@ index 423b800..b2b3f90 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4977,52 +4943,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4853,52 +4819,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -845,10 +845,10 @@ index 2c9bf24..af2ab6f 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index 8992e51..c1babcd 100644 +index bcedff5..a388e78 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs -@@ -1937,34 +1937,6 @@ atomic_int! { +@@ -1978,34 +1978,6 @@ atomic_int! { 8, u64 AtomicU64 ATOMIC_U64_INIT } @@ -896,11 +896,10 @@ index 0fa9974..75b44b1 100644 #[derive(Clone)] struct Test(Bigger); -@@ -1968,19 +1966,6 @@ fn test_step_replace_signed() { - assert_eq!(y, 5); +@@ -1969,19 +1967,6 @@ fn test_step_replace_signed() { } --#[test] + #[test] -fn test_step_replace_no_between() { - let mut x = 4u128; - let y = x.replace_zero(); @@ -913,9 +912,10 @@ index 0fa9974..75b44b1 100644 - assert_eq!(y, 5); -} - - #[test] +-#[test] fn test_rev_try_folds() { let f = &|acc, x| i32::checked_add(2*acc, x); + assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index a17c094..3c36d10 100644 --- a/src/libcore/tests/num/mod.rs @@ -1134,10 +1134,10 @@ index a751965..5d162cb 100644 /// /// # Examples diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index f395813..d81f80b 100644 +index 137ec65..4d1386c 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -401,8 +401,6 @@ pub use core::i16; +@@ -398,8 +398,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -1146,7 +1146,7 @@ index f395813..d81f80b 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -435,8 +433,6 @@ pub use alloc_crate::string; +@@ -432,8 +430,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -1156,10 +1156,10 @@ index f395813..d81f80b 100644 pub use core::hint; diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index f98113e..6c41e4e 100644 +index f45cd8b..cf5ba85 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs -@@ -1382,26 +1382,6 @@ impl FromInner for Ipv6Addr { +@@ -1381,26 +1381,6 @@ impl FromInner for Ipv6Addr { } } @@ -1224,5 +1224,5 @@ index d27f6ca..8ac2a44 100644 #[cfg(target_has_atomic = "8")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] -- -2.17.2 (Apple Git-113) +2.11.0 From a9c38b417a54a4d25fe241d973e59e1ebe86c2c2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Jan 2019 20:28:57 +0100 Subject: [PATCH 0477/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d47fc8df35fc..dc476ebd816db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4e096e29cecc762e345cfc62c34e3113ba5777d7" +source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", From 805af227b6e3c817df59aa068bdfc594a8ded0e3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 30 Jan 2019 14:56:25 +0100 Subject: [PATCH 0478/1566] Fix line debuginfo malformness in presence of macros --- src/debuginfo.rs | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index f7ebaefff8e23..b623d45a5b1d8 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -2,9 +2,10 @@ extern crate gimli; use crate::prelude::*; -use std::path::Path; use std::marker::PhantomData; +use syntax::source_map::FileName; + use gimli::write::{ Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, @@ -24,15 +25,28 @@ fn target_endian(tcx: TyCtxt) -> RunTimeEndian { } } -fn line_program_add_file>(line_program: &mut LineProgram, file: P) -> FileId { - let file = file.as_ref(); - let dir_id = - line_program.add_directory(file.parent().unwrap().to_str().unwrap().as_bytes()); - line_program.add_file( - file.file_name().unwrap().to_str().unwrap().as_bytes(), - dir_id, - None, - ) +fn line_program_add_file(line_program: &mut LineProgram, file: &FileName) -> FileId { + match file { + FileName::Real(path) => { + let dir_id = + line_program.add_directory(path.parent().unwrap().to_str().unwrap().as_bytes()); + line_program.add_file( + path.file_name().unwrap().to_str().unwrap().as_bytes(), + dir_id, + None, + ) + } + // FIXME give more appropriate file names + _ => { + let dir_id = line_program.default_directory(); + line_program.add_file( + file.to_string().as_bytes(), + dir_id, + None, + ) + } + } + } struct DebugReloc { @@ -146,7 +160,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); let line_program = self.line_programs.get_mut(self.global_line_program); - let file_id = line_program_add_file(line_program, loc.file.name.to_string()); + let file_id = line_program_add_file(line_program, &loc.file.name); let unit = self.units.get_mut(self.unit_id); let entry = unit.get_mut(entry_id); @@ -347,7 +361,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let create_row_for_span = |line_program: &mut LineProgram, span: Span| { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); - let file_id = line_program_add_file(line_program, loc.file.name.to_string()); + let file_id = line_program_add_file(line_program, &loc.file.name); /*println!( "srcloc {:>04X} {}:{}:{}", From 410d397bcdfa7898cfb1696eb97c976a30005281 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 30 Jan 2019 19:01:07 +0100 Subject: [PATCH 0479/1566] Rustup to rustc 1.34.0-nightly (c1c3c4e95 2019-01-29) --- patches/0001-Disable-stdsimd.patch | 57 +++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/patches/0001-Disable-stdsimd.patch b/patches/0001-Disable-stdsimd.patch index fa713271f10e3..9a869343deaab 100644 --- a/patches/0001-Disable-stdsimd.patch +++ b/patches/0001-Disable-stdsimd.patch @@ -1,55 +1,64 @@ -From 8bce7b9601aec46ee7704027dc173257d3e43492 Mon Sep 17 00:00:00 2001 +From 096dee5742ccd90df2e0edfe8b6bda87a63d99cf Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Fri, 14 Dec 2018 13:09:42 +0100 +Date: Wed, 30 Jan 2019 18:55:58 +0100 Subject: [PATCH] Disable stdsimd --- src/libcore/lib.rs | 2 ++ - src/libstd/lib.rs | 4 +++- - 2 files changed, 5 insertions(+), 1 deletion(-) + src/libstd/lib.rs | 6 ++---- + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index a51674f..313c173 100644 +index 6f364eb..69f0914 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -248,6 +248,7 @@ macro_rules! test_v256 { ($item:item) => {}; } - macro_rules! test_v512 { ($item:item) => {}; } - #[allow(unused_macros)] - macro_rules! vector_impl { ($([$f:ident, $($args:tt)*]),*) => { $($f!($($args)*);)* } } +@@ -221,6 +221,7 @@ pub mod alloc; + mod tuple; + mod unit; + +/* - #[path = "../stdsimd/coresimd/mod.rs"] - #[allow(missing_docs, missing_debug_implementations, dead_code, unused_imports)] - #[unstable(feature = "stdsimd", issue = "48556")] -@@ -255,3 +256,4 @@ mod coresimd; + // Pull in the `core_arch` crate directly into libcore. The contents of + // `core_arch` are in a different repository: rust-lang-nursery/stdsimd. + // +@@ -248,3 +249,4 @@ mod core_arch; #[stable(feature = "simd_arch", since = "1.27.0")] - pub use coresimd::arch; + pub use core_arch::arch; +*/ diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 90c8eaf..95541c3 100644 +index 244caf2..f269fda 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -287,7 +287,7 @@ +@@ -271,7 +271,6 @@ #![feature(rustc_attrs)] #![feature(rustc_const_unstable)] #![feature(std_internals)] -#![feature(stdsimd)] -+//#![feature(stdsimd)] #![feature(shrink_to)] #![feature(slice_concat_ext)] #![feature(slice_internals)] -@@ -503,6 +503,7 @@ mod memchr; +@@ -358,9 +357,6 @@ pub mod prelude; + // Public module declarations and re-exports + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::any; +-#[stable(feature = "simd_arch", since = "1.27.0")] +-#[doc(no_inline)] +-pub use core::arch; + #[stable(feature = "rust1", since = "1.0.0")] + pub use core::cell; + #[stable(feature = "rust1", since = "1.0.0")] +@@ -492,6 +488,7 @@ mod memchr; // compiler pub mod rt; +/* - // Pull in the `stdsimd` crate directly into libstd. This is the same as - // libcore's arch/simd modules where the source of truth here is in a different - // repository, but we pull things in here manually to get it into libstd. -@@ -526,6 +527,7 @@ mod coresimd { - #[stable(feature = "simd_arch", since = "1.27.0")] + // Pull in the `std_detect` crate directly into libstd. The contents of + // `std_detect` are in a different repository: rust-lang-nursery/stdsimd. + // +@@ -508,6 +505,7 @@ mod std_detect; + #[unstable(feature = "stdsimd", issue = "48556")] #[cfg(not(test))] - pub use stdsimd::arch; + pub use std_detect::detect; +*/ // Include a number of private modules that exist solely to provide From 99e43822b44e3a499493ee2797e5b501437d1815 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 Feb 2019 19:31:26 +0100 Subject: [PATCH 0480/1566] Misc debuginfo.rs changes --- src/debuginfo.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index b623d45a5b1d8..63cb7b028e53f 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -46,7 +46,6 @@ fn line_program_add_file(line_program: &mut LineProgram, file: &FileName) -> Fil ) } } - } struct DebugReloc { @@ -57,16 +56,20 @@ struct DebugReloc { } pub struct DebugContext<'tcx> { + // Encoding info encoding: Encoding, endian: RunTimeEndian, - symbols: indexmap::IndexSet, - strings: StringTable, + // Main data units: UnitTable, line_programs: LineProgramTable, + + // Side tables + strings: StringTable, range_lists: RangeListTable, + // Global ids unit_id: UnitId, global_line_program: LineProgramId, unit_range_list: RangeList, @@ -93,11 +96,12 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { None => tcx.crate_name(LOCAL_CRATE).to_string(), }; - let mut units = UnitTable::default(); let mut strings = StringTable::default(); - let mut line_programs = LineProgramTable::default(); let range_lists = RangeListTable::default(); + let mut units = UnitTable::default(); + let mut line_programs = LineProgramTable::default(); + let global_line_program = line_programs.add(LineProgram::new( encoding, 1, @@ -140,13 +144,13 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { DebugContext { encoding, endian: target_endian(tcx), - symbols: indexmap::IndexSet::new(), strings, + range_lists, + units, line_programs, - range_lists, unit_id, global_line_program, @@ -194,8 +198,10 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let mut debug_ranges = DebugRanges::from(WriterRelocate::new(self)); let mut debug_rnglists = DebugRngLists::from(WriterRelocate::new(self)); - let debug_line_offsets = self.line_programs.write(&mut debug_line).unwrap(); let debug_str_offsets = self.strings.write(&mut debug_str).unwrap(); + + let debug_line_offsets = self.line_programs.write(&mut debug_line).unwrap(); + let range_list_offsets = self .range_lists .write( From 189ba8352d0df1b0ad08229dc1736b10dab1ee0b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 2 Feb 2019 11:43:42 +0100 Subject: [PATCH 0481/1566] Rustup to rustc 1.34.0-nightly (852701ad6 2019-02-01) --- ...002-Disable-u128-and-i128-in-libcore.patch | 58 ++++++------- ...issing-saturating_sub-intrinsic-impl.patch | 82 +++++++++++++++++++ 2 files changed, 112 insertions(+), 28 deletions(-) create mode 100644 patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 5c922a753d2aa..16dcacacb4857 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From e56a552cfe6d51ec4db5ea69aff1c46c0090f470 Mon Sep 17 00:00:00 2001 +From d723688cb9f94c7c90617eb96b1d64fd968a02c3 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Tue, 29 Jan 2019 20:19:01 +0100 +Date: Sat, 2 Feb 2019 11:30:28 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -18,7 +18,7 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/num/wrapping.rs | 14 ++--- src/libcore/ops/arith.rs | 22 +++---- src/libcore/ops/bit.rs | 30 ++++------ - src/libcore/sync/atomic.rs | 28 --------- + src/libcore/sync/atomic.rs | 30 ---------- src/libcore/tests/iter.rs | 15 ----- src/libcore/tests/num/mod.rs | 18 ------ src/libcore/time.rs | 123 --------------------------------------- @@ -26,7 +26,7 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libstd/net/ip.rs | 20 ------- src/libstd/num.rs | 2 +- src/libstd/panic.rs | 6 -- - 22 files changed, 63 insertions(+), 368 deletions(-) + 22 files changed, 63 insertions(+), 370 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index ed90b7d..1739f91 100644 @@ -94,10 +94,10 @@ index 0e47c2f..570b949 100644 default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs -index c7c8fc5..689d611 100644 +index 3a81233..f889d57 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs -@@ -19,7 +19,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + +@@ -17,7 +17,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + fn to_u16(&self) -> u16; fn to_u32(&self) -> u32; fn to_u64(&self) -> u64; @@ -105,7 +105,7 @@ index c7c8fc5..689d611 100644 } macro_rules! doit { -@@ -30,10 +29,9 @@ macro_rules! doit { +@@ -28,10 +27,9 @@ macro_rules! doit { fn to_u16(&self) -> u16 { *self as u16 } fn to_u32(&self) -> u32 { *self as u32 } fn to_u64(&self) -> u64 { *self as u64 } @@ -117,7 +117,7 @@ index c7c8fc5..689d611 100644 /// A type that represents a specific radix #[doc(hidden)] -@@ -174,7 +172,6 @@ integer! { i8, u8 } +@@ -176,7 +174,6 @@ integer! { i8, u8 } integer! { i16, u16 } integer! { i32, u32 } integer! { i64, u64 } @@ -125,7 +125,7 @@ index c7c8fc5..689d611 100644 const DEC_DIGITS_LUT: &'static[u8] = b"0001020304050607080910111213141516171819\ -@@ -250,7 +247,6 @@ macro_rules! impl_Display { +@@ -252,7 +249,6 @@ macro_rules! impl_Display { impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); impl_Display!(i64, u64: to_u64); @@ -218,10 +218,10 @@ index dfe1d2a..06cc578 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index cde7e7c..094e1fb 100644 +index 97b07aa..9e1e9a6 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -146,14 +146,12 @@ mod uint_macros; +@@ -149,14 +149,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -252,7 +252,7 @@ index 457d556..91425fb 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 0eeac5e..d8277ef 100644 +index 8b6d9d8..8023dc1 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -163,12 +163,10 @@ pub fn forget_unsized(t: T) { @@ -269,7 +269,7 @@ index 0eeac5e..d8277ef 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 7cf2317..f928d40 100644 +index f80f839..eed1241 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -102,13 +102,11 @@ nonzero_integers! { @@ -286,7 +286,7 @@ index 7cf2317..f928d40 100644 #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); } -@@ -2074,18 +2072,6 @@ impl i64 { +@@ -2084,18 +2082,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -305,7 +305,7 @@ index 7cf2317..f928d40 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4316,17 +4302,6 @@ impl u64 { +@@ -4336,17 +4322,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -323,7 +323,7 @@ index 7cf2317..f928d40 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4410,7 +4385,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4430,7 +4405,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -332,7 +332,7 @@ index 7cf2317..f928d40 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4526,30 +4501,25 @@ macro_rules! rev { +@@ -4546,30 +4521,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -367,7 +367,7 @@ index 7cf2317..f928d40 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4561,21 +4531,21 @@ mod ptr_try_from_impls { +@@ -4581,21 +4551,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -397,7 +397,7 @@ index 7cf2317..f928d40 100644 } #[cfg(target_pointer_width = "32")] -@@ -4584,24 +4554,24 @@ mod ptr_try_from_impls { +@@ -4604,24 +4574,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -430,7 +430,7 @@ index 7cf2317..f928d40 100644 } #[cfg(target_pointer_width = "64")] -@@ -4610,24 +4580,20 @@ mod ptr_try_from_impls { +@@ -4630,24 +4600,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -459,7 +459,7 @@ index 7cf2317..f928d40 100644 } #[doc(hidden)] -@@ -4662,7 +4628,7 @@ macro_rules! doit { +@@ -4682,7 +4648,7 @@ macro_rules! doit { } })*) } @@ -468,7 +468,7 @@ index 7cf2317..f928d40 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4853,52 +4819,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4873,52 +4839,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -845,11 +845,11 @@ index 2c9bf24..af2ab6f 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index bcedff5..a388e78 100644 +index 8c5dde7..8122120 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs -@@ -1978,34 +1978,6 @@ atomic_int! { - 8, +@@ -2003,36 +2003,6 @@ atomic_int! { + "AtomicU64::new(0)", u64 AtomicU64 ATOMIC_U64_INIT } -#[cfg(target_has_atomic = "128")] @@ -864,6 +864,7 @@ index bcedff5..a388e78 100644 - "#![feature(integer_atomics)]\n\n", - atomic_min, atomic_max, - 16, +- "AtomicI128::new(0)", - i128 AtomicI128 ATOMIC_I128_INIT -} -#[cfg(target_has_atomic = "128")] @@ -878,6 +879,7 @@ index bcedff5..a388e78 100644 - "#![feature(integer_atomics)]\n\n", - atomic_umin, atomic_umax, - 16, +- "AtomicU128::new(0)", - u128 AtomicU128 ATOMIC_U128_INIT -} #[cfg(target_pointer_width = "16")] @@ -1134,10 +1136,10 @@ index a751965..5d162cb 100644 /// /// # Examples diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 137ec65..4d1386c 100644 +index f269fda..07c3680 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -398,8 +398,6 @@ pub use core::i16; +@@ -397,8 +397,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -1146,7 +1148,7 @@ index 137ec65..4d1386c 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -432,8 +430,6 @@ pub use alloc_crate::string; +@@ -431,8 +429,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; diff --git a/patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch b/patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch new file mode 100644 index 0000000000000..36b8f071aea69 --- /dev/null +++ b/patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch @@ -0,0 +1,82 @@ +From 725a1e7b487e32b5f2e90049c8b37fed1a957003 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 2 Feb 2019 11:39:22 +0100 +Subject: [PATCH] Workaround missing saturating_sub intrinsic impl + +--- + src/libcore/num/mod.rs | 20 -------------------- + 1 file changed, 20 deletions(-) + +diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs +index eed1241..f928d40 100644 +--- a/src/libcore/num/mod.rs ++++ b/src/libcore/num/mod.rs +@@ -881,16 +881,11 @@ $EndFeature, " + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn saturating_add(self, rhs: Self) -> Self { +- #[cfg(stage0)] + match self.checked_add(rhs) { + Some(x) => x, + None if rhs >= 0 => Self::max_value(), + None => Self::min_value(), + } +- #[cfg(not(stage0))] +- { +- intrinsics::saturating_add(self, rhs) +- } + } + } + +@@ -911,16 +906,11 @@ $EndFeature, " + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn saturating_sub(self, rhs: Self) -> Self { +- #[cfg(stage0)] + match self.checked_sub(rhs) { + Some(x) => x, + None if rhs >= 0 => Self::min_value(), + None => Self::max_value(), + } +- #[cfg(not(stage0))] +- { +- intrinsics::saturating_sub(self, rhs) +- } + } + } + +@@ -2740,15 +2730,10 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn saturating_add(self, rhs: Self) -> Self { +- #[cfg(stage0)] + match self.checked_add(rhs) { + Some(x) => x, + None => Self::max_value(), + } +- #[cfg(not(stage0))] +- { +- intrinsics::saturating_add(self, rhs) +- } + } + } + +@@ -2767,15 +2752,10 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub fn saturating_sub(self, rhs: Self) -> Self { +- #[cfg(stage0)] + match self.checked_sub(rhs) { + Some(x) => x, + None => Self::min_value(), + } +- #[cfg(not(stage0))] +- { +- intrinsics::saturating_sub(self, rhs) +- } + } + } + +-- +2.11.0 + From 849f7f70413d0f0786e23aaaf8fa40f3744c375a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 Feb 2019 19:48:09 +0100 Subject: [PATCH 0482/1566] Update gimli --- Cargo.lock | 2 +- src/debuginfo.rs | 63 +++++++++++++++++++++++------------------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc476ebd816db..cb70e83703bdf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -321,7 +321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#bedf4f00e460e2229f40bbbad78a6d6974640ba6" +source = "git+https://github.com/gimli-rs/gimli.git#89442c242d7e51b1cbd67103918dc42552527aa1" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 63cb7b028e53f..21cea157250ab 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -9,8 +9,8 @@ use syntax::source_map::FileName; use gimli::write::{ Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, - RangeList, RangeListTable, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, - Writer, FileId, + RangeList, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, + Writer, FileId, LineStringTable, DebugLineStr, LineString, }; use gimli::{Encoding, Format, RunTimeEndian}; @@ -25,13 +25,15 @@ fn target_endian(tcx: TyCtxt) -> RunTimeEndian { } } -fn line_program_add_file(line_program: &mut LineProgram, file: &FileName) -> FileId { +fn line_program_add_file(line_program: &mut LineProgram, line_strings: &mut LineStringTable, file: &FileName) -> FileId { match file { FileName::Real(path) => { + let dir_name = LineString::new(path.parent().unwrap().to_str().unwrap().as_bytes(), line_program.encoding(), line_strings); let dir_id = - line_program.add_directory(path.parent().unwrap().to_str().unwrap().as_bytes()); + line_program.add_directory(dir_name); + let file_name = LineString::new(path.file_name().unwrap().to_str().unwrap().as_bytes(), line_program.encoding(), line_strings); line_program.add_file( - path.file_name().unwrap().to_str().unwrap().as_bytes(), + file_name, dir_id, None, ) @@ -39,8 +41,9 @@ fn line_program_add_file(line_program: &mut LineProgram, file: &FileName) -> Fil // FIXME give more appropriate file names _ => { let dir_id = line_program.default_directory(); + let dummy_file_name = LineString::new(file.to_string().into_bytes(), line_program.encoding(), line_strings); line_program.add_file( - file.to_string().as_bytes(), + dummy_file_name, dir_id, None, ) @@ -57,7 +60,6 @@ struct DebugReloc { pub struct DebugContext<'tcx> { // Encoding info - encoding: Encoding, endian: RunTimeEndian, symbols: indexmap::IndexSet, @@ -67,7 +69,7 @@ pub struct DebugContext<'tcx> { // Side tables strings: StringTable, - range_lists: RangeListTable, + line_strings: LineStringTable, // Global ids unit_id: UnitId, @@ -97,7 +99,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { }; let mut strings = StringTable::default(); - let range_lists = RangeListTable::default(); + let mut line_strings = LineStringTable::default(); let mut units = UnitTable::default(); let mut line_programs = LineProgramTable::default(); @@ -108,8 +110,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { 1, -5, 14, - comp_dir.as_bytes(), - name.as_bytes(), + LineString::new(comp_dir.as_bytes(), encoding, &mut line_strings), + LineString::new(name.as_bytes(), encoding, &mut line_strings), None, )); @@ -141,13 +143,12 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { ); } - DebugContext { - encoding, + DebugContext { endian: target_endian(tcx), symbols: indexmap::IndexSet::new(), strings, - range_lists, + line_strings, units, line_programs, @@ -164,7 +165,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); let line_program = self.line_programs.get_mut(self.global_line_program); - let file_id = line_program_add_file(line_program, &loc.file.name); + let file_id = line_program_add_file(line_program, &mut self.line_strings, &loc.file.name); let unit = self.units.get_mut(self.unit_id); let entry = unit.get_mut(entry_id); @@ -182,8 +183,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { } pub fn emit(&mut self, artifact: &mut Artifact) { - let unit_range_list_id = self.range_lists.add(self.unit_range_list.clone()); let unit = self.units.get_mut(self.unit_id); + let unit_range_list_id = unit.ranges.add(self.unit_range_list.clone()); let root = unit.root(); let root = unit.get_mut(root); root.set( @@ -194,28 +195,24 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let mut debug_abbrev = DebugAbbrev::from(WriterRelocate::new(self)); let mut debug_info = DebugInfo::from(WriterRelocate::new(self)); let mut debug_str = DebugStr::from(WriterRelocate::new(self)); + let mut debug_line_str = DebugLineStr::from(WriterRelocate::new(self)); let mut debug_line = DebugLine::from(WriterRelocate::new(self)); let mut debug_ranges = DebugRanges::from(WriterRelocate::new(self)); let mut debug_rnglists = DebugRngLists::from(WriterRelocate::new(self)); let debug_str_offsets = self.strings.write(&mut debug_str).unwrap(); + let debug_line_str_offsets = self.line_strings.write(&mut debug_line_str).unwrap(); - let debug_line_offsets = self.line_programs.write(&mut debug_line).unwrap(); + let debug_line_offsets = self.line_programs.write(&mut debug_line, &debug_line_str_offsets, &debug_str_offsets).unwrap(); - let range_list_offsets = self - .range_lists - .write( - &mut debug_ranges, - &mut debug_rnglists, - self.encoding - ) - .unwrap(); self.units .write( &mut debug_abbrev, &mut debug_info, + &mut debug_ranges, + &mut debug_rnglists, &debug_line_offsets, - &range_list_offsets, + &debug_line_str_offsets, &debug_str_offsets, ) .unwrap(); @@ -234,6 +231,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { decl_section!(DebugInfo = debug_info); decl_section!(DebugStr = debug_str); decl_section!(DebugLine = debug_line); + decl_section!(DebugLineStr = debug_line_str); let debug_ranges_not_empty = !debug_ranges.0.writer.slice().is_empty(); if debug_ranges_not_empty { @@ -267,6 +265,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { sect_relocs!(DebugInfo = debug_info); sect_relocs!(DebugStr = debug_str); sect_relocs!(DebugLine = debug_line); + sect_relocs!(DebugLineStr = debug_line_str); if debug_ranges_not_empty { sect_relocs!(DebugRanges = debug_ranges); @@ -339,15 +338,12 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let entry = unit.get_mut(self.entry_id); entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(code_size as u64)); - self.debug_context.unit_range_list.0.push(Range { + self.debug_context.unit_range_list.0.push(Range::StartLength { begin: Address::Relative { symbol: self.symbol, addend: 0, }, - end: Address::Relative { - symbol: self.symbol, - addend: code_size as i64, - }, + length: code_size as u64, }); let line_program = self @@ -365,9 +361,10 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let mut ebbs = func.layout.ebbs().collect::>(); ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase - let create_row_for_span = |line_program: &mut LineProgram, span: Span| { + let line_strings = &mut self.debug_context.line_strings; + let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); - let file_id = line_program_add_file(line_program, &loc.file.name); + let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); /*println!( "srcloc {:>04X} {}:{}:{}", From 13efc0676638ad77e29dfed7c044472374c09ea8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Sat, 2 Feb 2019 13:29:23 +0000 Subject: [PATCH 0483/1566] Bump proc-macro2 from 0.4.26 to 0.4.27 Bumps [proc-macro2](https://github.com/alexcrichton/proc-macro2) from 0.4.26 to 0.4.27. - [Release notes](https://github.com/alexcrichton/proc-macro2/releases) - [Commits](https://github.com/alexcrichton/proc-macro2/compare/0.4.26...0.4.27) Signed-off-by: dependabot[bot] --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb70e83703bdf..701fe6196e958 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -288,7 +288,7 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -413,7 +413,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -429,7 +429,7 @@ name = "quote" version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -639,7 +639,7 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -705,7 +705,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -715,7 +715,7 @@ name = "syn" version = "0.15.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -725,7 +725,7 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -903,7 +903,7 @@ dependencies = [ "checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.26 (registry+https://github.com/rust-lang/crates.io-index)" = "38fddd23d98b2144d197c0eca5705632d4fe2667d14a6be5df8934f8d74f1978" +"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" "checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" From 3308daae9d28603d52f753171883fa79d8b5d7a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Feb 2019 11:08:25 +0100 Subject: [PATCH 0484/1566] Update Cargo.lock --- Cargo.lock | 74 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 701fe6196e958..04e23c01eaadb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,17 +300,8 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" +name = "fuchsia-cprng" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -321,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#89442c242d7e51b1cbd67103918dc42552527aa1" +source = "git+https://github.com/gimli-rs/gimli.git#9ed8d7bce40613c9c9b5b511d9c5ead24492d7e1" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -434,16 +425,17 @@ dependencies = [ [[package]] name = "rand" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -487,15 +479,25 @@ dependencies = [ "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_jitter" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand_os" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -555,14 +557,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -659,17 +661,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -682,7 +684,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -738,7 +740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -748,7 +750,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -834,7 +836,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -851,7 +853,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] @@ -887,8 +889,7 @@ dependencies = [ "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eb7217124812dc5672b7476d0c2d20cfe9f7c0f1ba0904b674a9762a0212f72e" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81f7f8eb465745ea9b02e2704612a9946a59fa40572086c6fd49d6ddcf30bf31" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" @@ -906,13 +907,14 @@ dependencies = [ "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" -"checksum rand 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3906503e80ac6cbcacb2c2973fa8e473f24d7e2747c8c92bb230c2441cad96b5" +"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_os 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f46fbd5550acf75b0c2730f5dd1873751daf9beb8f11b44027778fae50d7feca" +"checksum rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "080723c6145e37503a2224f801f252e14ac5531cb450f4502698542d188cb3c0" +"checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d" "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" @@ -920,7 +922,7 @@ dependencies = [ "checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" -"checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" +"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" "checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" @@ -930,8 +932,8 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" -"checksum serde_json 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "4b90a9fbe1211e57d3e1c15670f1cb00802988fb23a1a4aad7a2b63544f1920e" +"checksum serde 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)" = "52ab457c27b091c27b887eef7181b3ea11ab4f92f66e3a99b2e556b77f9cc6bd" +"checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" @@ -953,6 +955,6 @@ dependencies = [ "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" +"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" From ed9528a104bf5a18dc37f1da5f4c2a1edf33ce49 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Feb 2019 11:25:56 +0100 Subject: [PATCH 0485/1566] Misc changes --- build_sysroot/Cargo.toml | 3 +++ build_sysroot/build_sysroot.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index d4873602d4d48..725c0b40d89b9 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -13,3 +13,6 @@ alloc_system = { path = "./alloc_system" } [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } compiler_builtins = { path = "./compiler_builtins" } + +[profile.release] +debug = true diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 33da1e3dd6792..2e332be7e6087 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -6,6 +6,7 @@ cd $(dirname "$0") cargo clean rm Cargo.lock 2>/dev/null || true rm -r sysroot 2>/dev/null || true +rm -r target 2>/dev/null || true # FIXME find a better way to get the target triple unamestr=`uname` From 07c693b7646ed57fc7a061cc5b13886815527a8d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Feb 2019 11:26:44 +0100 Subject: [PATCH 0486/1566] Add some patches for libstd --- patches/0013-Patch-away-bswap-usage.patch | 25 ++++++++++ patches/0014-Don-t-use-OS-TLS.patch | 57 +++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 patches/0013-Patch-away-bswap-usage.patch create mode 100644 patches/0014-Don-t-use-OS-TLS.patch diff --git a/patches/0013-Patch-away-bswap-usage.patch b/patches/0013-Patch-away-bswap-usage.patch new file mode 100644 index 0000000000000..14d05a325835d --- /dev/null +++ b/patches/0013-Patch-away-bswap-usage.patch @@ -0,0 +1,25 @@ +From da996dae0b95f986de46a916aca00e03257ba4f9 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Wed, 30 Jan 2019 14:51:57 +0100 +Subject: [PATCH] Patch away bswap usage + +--- + src/libcore/num/mod.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs +index f928d40..6a146f5 100644 +--- a/src/libcore/num/mod.rs ++++ b/src/libcore/num/mod.rs +@@ -2303,7 +2303,7 @@ assert_eq!(m, ", $swapped, "); + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] + pub const fn swap_bytes(self) -> Self { +- intrinsics::bswap(self as $ActualT) as Self ++ 0 // bswap is unsupported by cg_clif + } + } + +-- +2.11.0 + diff --git a/patches/0014-Don-t-use-OS-TLS.patch b/patches/0014-Don-t-use-OS-TLS.patch new file mode 100644 index 0000000000000..01c959c8ae838 --- /dev/null +++ b/patches/0014-Don-t-use-OS-TLS.patch @@ -0,0 +1,57 @@ +From 1ad7a849f9ff845f676d4625ba71d1060039c0de Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Thu, 31 Jan 2019 20:11:56 +0100 +Subject: [PATCH] Don't use OS TLS + +--- + src/libstd/thread/local.rs | 4 ++-- + src/libstd/thread/mod.rs | 1 - + 2 files changed, 2 insertions(+), 3 deletions(-) + +diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs +index 5d2eb5f..39513b6 100644 +--- a/src/libstd/thread/local.rs ++++ b/src/libstd/thread/local.rs +@@ -160,10 +160,10 @@ macro_rules! __thread_local_inner { + &'static $crate::cell::UnsafeCell< + $crate::option::Option<$t>>> + { +- #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] + static __KEY: $crate::thread::__StaticLocalKeyInner<$t> = + $crate::thread::__StaticLocalKeyInner::new(); + ++ /* + #[thread_local] + #[cfg(all( + target_thread_local, +@@ -178,6 +178,7 @@ macro_rules! __thread_local_inner { + ))] + static __KEY: $crate::thread::__OsLocalKeyInner<$t> = + $crate::thread::__OsLocalKeyInner::new(); ++ */ + + __KEY.get() + } +@@ -304,7 +305,6 @@ impl LocalKey { + /// On some platforms like wasm32 there's no threads, so no need to generate + /// thread locals and we can instead just use plain statics! + #[doc(hidden)] +-#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] + pub mod statik { + use cell::UnsafeCell; + use fmt; +diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs +index eb8e0c1..b44d737 100644 +--- a/src/libstd/thread/mod.rs ++++ b/src/libstd/thread/mod.rs +@@ -195,7 +195,6 @@ pub use self::local::{LocalKey, AccessError}; + // where available, but both are needed. + + #[unstable(feature = "libstd_thread_internals", issue = "0")] +-#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] + #[doc(hidden)] pub use self::local::statik::Key as __StaticLocalKeyInner; + #[unstable(feature = "libstd_thread_internals", issue = "0")] + #[cfg(target_thread_local)] +-- +2.11.0 + From 0d16dcfce11ef524f34f8179352d2dc701808cfc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Feb 2019 13:29:04 +0100 Subject: [PATCH 0487/1566] Don't try to store func_addr for FnDef in trans_const_value This would crash, because the place provides 0 bytes of space for FnDef --- src/base.rs | 12 ++++++++++-- src/constant.rs | 11 +++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/base.rs b/src/base.rs index 0d130bb8a1b8d..ef96b89f79953 100644 --- a/src/base.rs +++ b/src/base.rs @@ -474,9 +474,17 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, layout)); } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { - let operand = trans_operand(fx, operand); let layout = fx.layout_of(ty); - lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); + match fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)).sty { + ty::FnDef(def_id, substs) => { + let func_ref = fx.get_function_ref( + Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + ); + let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); + lval.write_cvalue(fx, CValue::ByVal(func_addr, layout)); + } + _ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", ty), + } } Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { let operand = trans_operand(fx, operand); diff --git a/src/constant.rs b/src/constant.rs index 6411e3d8563bd..1af5a28688193 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -110,12 +110,11 @@ fn trans_const_value<'a, 'tcx: 'a>( let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as i128 as i64) } - ty::FnDef(def_id, substs) => { - let func_ref = fx.get_function_ref( - Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), - ); - let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); - CValue::ByVal(func_addr, layout) + ty::FnDef(_def_id, _substs) => { + CValue::ByRef( + fx.bcx.ins().iconst(fx.pointer_type, 0), + layout + ) } _ => trans_const_place(fx, const_).to_cvalue(fx), } From 3e24c1212fe58539038733eb01fce42804b37d80 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 4 Feb 2019 19:18:39 +0100 Subject: [PATCH 0488/1566] Refactor CPlace address handling --- src/abi.rs | 2 +- src/base.rs | 7 ++- src/common.rs | 137 +++++++++++++++++++++++++------------------------- 3 files changed, 72 insertions(+), 74 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 864fc26927f65..450e32011d749 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -606,7 +606,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { - Some(ret_place) => Some(ret_place.expect_addr()), + Some(ret_place) => Some(ret_place.cplace_to_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 0)), }, PassMode::ByVal(_) => None, diff --git a/src/base.rs b/src/base.rs index ef96b89f79953..3ac41393c6a10 100644 --- a/src/base.rs +++ b/src/base.rs @@ -688,10 +688,9 @@ fn codegen_array_len<'a, 'tcx: 'a>( let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } - ty::Slice(_elem_ty) => match place { - CPlace::Addr(_, size, _) => size.unwrap(), - CPlace::Var(_, _) => unreachable!(), - }, + ty::Slice(_elem_ty) => { + place.to_addr_maybe_unsized(fx).1.expect("Length metadata for slice place") + } _ => bug!("Rvalue::Len({:?})", place), } } diff --git a/src/common.rs b/src/common.rs index b88d439932a4a..12102175213f0 100644 --- a/src/common.rs +++ b/src/common.rs @@ -293,10 +293,19 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn expect_addr(self) -> Value { + pub fn cplace_to_addr(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { + match self.to_addr_maybe_unsized(fx) { + (addr, None) => addr, + (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), + } + } + + pub fn to_addr_maybe_unsized( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ) -> (Value, Option) { match self { - CPlace::Addr(addr, None, _layout) => addr, - CPlace::Addr(_, _, _) => bug!("Expected sized CPlace::Addr, found {:?}", self), + CPlace::Addr(addr, extra, _layout) => (addr, extra), CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } @@ -347,31 +356,32 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - match self { + let (addr, dst_layout) = match self { CPlace::Var(var, _) => { let data = from.load_scalar(fx); - fx.bcx.def_var(mir_var(var), data) - } - CPlace::Addr(addr, None, dst_layout) => { - match from { - CValue::ByVal(val, _src_layout) => { - fx.bcx.ins().store(MemFlags::new(), val, addr, 0); - } - CValue::ByValPair(val1, val2, _src_layout) => { - let val1_offset = dst_layout.fields.offset(0).bytes() as i32; - let val2_offset = dst_layout.fields.offset(1).bytes() as i32; - fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); - fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); - } - CValue::ByRef(from, src_layout) => { - let size = dst_layout.size.bytes(); - let src_align = src_layout.align.abi.bytes() as u8; - let dst_align = dst_layout.align.abi.bytes() as u8; - fx.bcx.emit_small_memcpy(fx.module.target_config(), addr, from, size, dst_align, src_align); - } - } + fx.bcx.def_var(mir_var(var), data); + return; } + CPlace::Addr(addr, None, dst_layout) => (addr, dst_layout), CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), + }; + + match from { + CValue::ByVal(val, _src_layout) => { + fx.bcx.ins().store(MemFlags::new(), val, addr, 0); + } + CValue::ByValPair(val1, val2, _src_layout) => { + let val1_offset = dst_layout.fields.offset(0).bytes() as i32; + let val2_offset = dst_layout.fields.offset(1).bytes() as i32; + fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); + fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); + } + CValue::ByRef(from, src_layout) => { + let size = dst_layout.size.bytes(); + let src_align = src_layout.align.abi.bytes() as u8; + let dst_align = dst_layout.align.abi.bytes() as u8; + fx.bcx.emit_small_memcpy(fx.module.target_config(), addr, from, size, dst_align, src_align); + } } } @@ -380,25 +390,17 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { fx: &mut FunctionCx<'a, 'tcx, impl Backend>, field: mir::Field, ) -> CPlace<'tcx> { - match self { - CPlace::Var(var, layout) => { - bug!( - "Tried to project {:?}, which is put in SSA var {:?}", - layout.ty, - var - ); - } - CPlace::Addr(base, extra, layout) => { - let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); - let extra = if field_layout.is_unsized() { - assert!(extra.is_some()); - extra - } else { - None - }; - CPlace::Addr(field_ptr, extra, field_layout) - } - } + let layout = self.layout(); + let (base, extra) = self.to_addr_maybe_unsized(fx); + + let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + let extra = if field_layout.is_unsized() { + assert!(extra.is_some()); + extra + } else { + None + }; + CPlace::Addr(field_ptr, extra, field_layout) } pub fn place_index( @@ -407,13 +409,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { index: Value, ) -> CPlace<'tcx> { let (elem_layout, addr) = match self.layout().ty.sty { - ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.expect_addr()), + ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.cplace_to_addr(fx)), ty::Slice(elem_ty) => ( fx.layout_of(elem_ty), - match self { - CPlace::Addr(addr, _, _) => addr, - CPlace::Var(_, _) => bug!("Expected CPlace::Addr found CPlace::Var"), - }, + self.to_addr_maybe_unsized(fx).0, ), _ => bug!("place_index({:?})", self.layout().ty), }; @@ -433,7 +432,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } else { match self.layout().abi { Abi::ScalarPair(ref a, ref b) => { - let addr = self.expect_addr(); + let addr = self.cplace_to_addr(fx); let ptr = fx.bcx .ins() @@ -456,28 +455,28 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_place_ref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if !self.layout().is_unsized() { - let ptr = CValue::ByVal(self.expect_addr(), dest.layout()); + let ptr = CValue::ByVal(self.cplace_to_addr(fx), dest.layout()); dest.write_cvalue(fx, ptr); } else { - match self { - CPlace::Var(_, _) => bug!("expected CPlace::Addr found CPlace::Var"), - CPlace::Addr(value, extra, _) => match dest.layout().abi { - Abi::ScalarPair(ref a, _) => { - fx.bcx - .ins() - .store(MemFlags::new(), value, dest.expect_addr(), 0); - fx.bcx.ins().store( - MemFlags::new(), - extra.expect("unsized type without metadata"), - dest.expect_addr(), - a.value.size(&fx.tcx).bytes() as u32 as i32, - ); - } - _ => bug!( - "Non ScalarPair abi {:?} in write_place_ref dest", - dest.layout().abi - ), - }, + let (value, extra) = self.to_addr_maybe_unsized(fx); + + match dest.layout().abi { + Abi::ScalarPair(ref a, _) => { + let dest_addr = dest.cplace_to_addr(fx); + fx.bcx + .ins() + .store(MemFlags::new(), value, dest_addr, 0); + fx.bcx.ins().store( + MemFlags::new(), + extra.expect("unsized type without metadata"), + dest_addr, + a.value.size(&fx.tcx).bytes() as u32 as i32, + ); + } + _ => bug!( + "Non ScalarPair abi {:?} in write_place_ref dest", + dest.layout().abi + ), } } } From feec354d6584cb3d5a7a13f12e6ee3834bd01628 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 4 Feb 2019 19:27:58 +0100 Subject: [PATCH 0489/1566] Introduce CPlace::Stack --- src/abi.rs | 14 ++++++------- src/base.rs | 4 ++-- src/common.rs | 50 +++++++++++++++++++++++------------------------ src/intrinsics.rs | 22 +++++---------------- 4 files changed, 38 insertions(+), 52 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 450e32011d749..bbe2609863e87 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -340,23 +340,23 @@ fn local_place<'a, 'tcx: 'a>( fx.bcx.declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); CPlace::Var(local, layout) } else { - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); + let place = CPlace::new_stack_slot(fx, layout.ty); #[cfg(debug_assertions)] { let TyLayout { ty, details } = layout; let ty::layout::LayoutDetails { size, align, abi: _, variants: _, fields: _ } = details; + let stack_slot = match place { + CPlace::Stack(stack_slot, _) => stack_slot, + _ => unreachable!(), + }; fx.add_entity_comment(stack_slot, format!( "{:?}: {:?} size={} align={},{}", local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), )); } - CPlace::from_stack_slot(fx, stack_slot, layout.ty) + place }; let prev_place = fx.local_map.insert(local, place); @@ -606,7 +606,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { - Some(ret_place) => Some(ret_place.cplace_to_addr(fx)), + Some(ret_place) => Some(ret_place.to_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 0)), }, PassMode::ByVal(_) => None, diff --git a/src/base.rs b/src/base.rs index 3ac41393c6a10..8914addadad4f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -258,7 +258,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) // we don't actually need to drop anything } else { let drop_place = trans_place(fx, location); - let arg_place = CPlace::temp( + let arg_place = CPlace::new_stack_slot( fx, fx.tcx.mk_ref( &ty::RegionKind::ReErased, @@ -937,7 +937,7 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( // TODO: check for overflow let has_overflow = fx.bcx.ins().iconst(types::I8, 0); - let out_place = CPlace::temp(fx, out_ty); + let out_place = CPlace::new_stack_slot(fx, out_ty); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::ByValPair(res, has_overflow, out_layout)); diff --git a/src/common.rs b/src/common.rs index 12102175213f0..248878a4be36b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -245,16 +245,19 @@ impl<'tcx> CValue<'tcx> { pub enum CPlace<'tcx> { Var(Local, TyLayout<'tcx>), Addr(Value, Option, TyLayout<'tcx>), + Stack(StackSlot, TyLayout<'tcx>), } impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { - CPlace::Var(_, layout) | CPlace::Addr(_, _, layout) => layout, + CPlace::Var(_, layout) + | CPlace::Addr(_, _, layout) + | CPlace::Stack(_, layout) => layout, } } - pub fn temp(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> CPlace<'tcx> { + pub fn new_stack_slot(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> CPlace<'tcx> { let layout = fx.layout_of(ty); assert!(!layout.is_unsized()); let stack_slot = fx.bcx.create_stack_slot(StackSlotData { @@ -262,25 +265,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - CPlace::Addr( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), - None, - layout, - ) - } - - pub fn from_stack_slot( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - stack_slot: StackSlot, - ty: Ty<'tcx>, - ) -> CPlace<'tcx> { - let layout = fx.layout_of(ty); - assert!(!layout.is_unsized()); - CPlace::Addr( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), - None, - layout, - ) + CPlace::Stack(stack_slot, layout) } pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { @@ -290,10 +275,13 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { assert!(extra.is_none(), "unsized values are not yet supported"); CValue::ByRef(addr, layout) } + CPlace::Stack(stack_slot, layout) => { + CValue::ByRef(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), layout) + } } } - pub fn cplace_to_addr(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { + pub fn to_addr(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { match self.to_addr_maybe_unsized(fx) { (addr, None) => addr, (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), @@ -306,6 +294,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ) -> (Value, Option) { match self { CPlace::Addr(addr, extra, _layout) => (addr, extra), + CPlace::Stack(stack_slot, _layout) => { + (fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None) + } CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } @@ -363,6 +354,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { return; } CPlace::Addr(addr, None, dst_layout) => (addr, dst_layout), + CPlace::Stack(stack_slot, dst_layout) => { + (fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), dst_layout) + } CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), }; @@ -409,7 +403,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { index: Value, ) -> CPlace<'tcx> { let (elem_layout, addr) = match self.layout().ty.sty { - ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.cplace_to_addr(fx)), + ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_addr(fx)), ty::Slice(elem_ty) => ( fx.layout_of(elem_ty), self.to_addr_maybe_unsized(fx).0, @@ -432,7 +426,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } else { match self.layout().abi { Abi::ScalarPair(ref a, ref b) => { - let addr = self.cplace_to_addr(fx); + let addr = self.to_addr(fx); let ptr = fx.bcx .ins() @@ -455,14 +449,14 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_place_ref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if !self.layout().is_unsized() { - let ptr = CValue::ByVal(self.cplace_to_addr(fx), dest.layout()); + let ptr = CValue::ByVal(self.to_addr(fx), dest.layout()); dest.write_cvalue(fx, ptr); } else { let (value, extra) = self.to_addr_maybe_unsized(fx); match dest.layout().abi { Abi::ScalarPair(ref a, _) => { - let dest_addr = dest.cplace_to_addr(fx); + let dest_addr = dest.to_addr(fx); fx.bcx .ins() .store(MemFlags::new(), value, dest_addr, 0); @@ -488,6 +482,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { assert!(!layout.is_unsized()); CPlace::Addr(addr, extra, layout) } + CPlace::Stack(stack_slot, _) => { + assert!(!layout.is_unsized()); + CPlace::Stack(stack_slot, layout) + } } } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index eee3a04fd1b44..a00ab64d889ba 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -298,32 +298,20 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; init, () { let layout = fx.layout_of(T); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let addr = fx.bcx.ins().stack_addr(pointer_ty(fx.tcx), stack_slot, 0); + let inited_place = CPlace::new_stack_slot(fx, T); + let addr = inited_place.to_addr(fx); let zero_val = fx.bcx.ins().iconst(types::I8, 0); let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); fx.bcx.call_memset(fx.module.target_config(), addr, zero_val, len_val); - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, T); - let uninit_val = uninit_place.to_cvalue(fx); - ret.write_cvalue(fx, uninit_val); + let inited_val = inited_place.to_cvalue(fx); + ret.write_cvalue(fx, inited_val); }; write_bytes, (v dst, v val, v count) { fx.bcx.call_memset(fx.module.target_config(), dst, val, count); }; uninit, () { - let layout = fx.layout_of(T); - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - - let uninit_place = CPlace::from_stack_slot(fx, stack_slot, T); + let uninit_place = CPlace::new_stack_slot(fx, T); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); }; From d0c81d259a54f162d48fe3c06164ba456ca27945 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 4 Feb 2019 19:44:16 +0100 Subject: [PATCH 0490/1566] Take stack_addr in advance for locals to avoid many duplicate instructions --- src/abi.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index bbe2609863e87..062e55a5ea8e1 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -356,7 +356,8 @@ fn local_place<'a, 'tcx: 'a>( )); } - place + // Take stack_addr in advance to avoid many duplicate instructions + CPlace::Addr(place.to_addr(fx), None, layout) }; let prev_place = fx.local_map.insert(local, place); From e1620402e0a38aeedae5c3a180c092fe12f330c7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 4 Feb 2019 19:58:07 +0100 Subject: [PATCH 0491/1566] Introduce CPlace::NoPlace for zst's --- src/abi.rs | 22 +++++++++++----------- src/common.rs | 24 +++++++++++++++++++++--- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 062e55a5ea8e1..0045866dfdd3f 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -346,14 +346,18 @@ fn local_place<'a, 'tcx: 'a>( { let TyLayout { ty, details } = layout; let ty::layout::LayoutDetails { size, align, abi: _, variants: _, fields: _ } = details; - let stack_slot = match place { - CPlace::Stack(stack_slot, _) => stack_slot, + match place { + CPlace::Stack(stack_slot, _) => fx.add_entity_comment(stack_slot, format!( + "{:?}: {:?} size={} align={},{}", + local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), + )), + CPlace::NoPlace(_) => fx.add_global_comment(format!( + "zst {:?}: {:?} size={} align={}, {}", + local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), + )), _ => unreachable!(), }; - fx.add_entity_comment(stack_slot, format!( - "{:?}: {:?} size={} align={},{}", - local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), - )); + } // Take stack_addr in advance to avoid many duplicate instructions @@ -456,11 +460,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( match output_pass_mode { PassMode::NoPass => { - let null = fx.bcx.ins().iconst(fx.pointer_type, 0); - fx.local_map.insert( - RETURN_PLACE, - CPlace::Addr(null, None, ret_layout), - ); + fx.local_map.insert(RETURN_PLACE, CPlace::NoPlace(ret_layout)); } PassMode::ByVal(_) => { let is_ssa = !ssa_analyzed diff --git a/src/common.rs b/src/common.rs index 248878a4be36b..9723072364bd5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -246,6 +246,7 @@ pub enum CPlace<'tcx> { Var(Local, TyLayout<'tcx>), Addr(Value, Option, TyLayout<'tcx>), Stack(StackSlot, TyLayout<'tcx>), + NoPlace(TyLayout<'tcx>) } impl<'a, 'tcx: 'a> CPlace<'tcx> { @@ -253,13 +254,18 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match *self { CPlace::Var(_, layout) | CPlace::Addr(_, _, layout) - | CPlace::Stack(_, layout) => layout, + | CPlace::Stack(_, layout) + | CPlace::NoPlace(layout) => layout, } } pub fn new_stack_slot(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> CPlace<'tcx> { let layout = fx.layout_of(ty); assert!(!layout.is_unsized()); + if layout.size.bytes() == 0 { + return CPlace::NoPlace(layout); + } + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -278,6 +284,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Stack(stack_slot, layout) => { CValue::ByRef(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), layout) } + CPlace::NoPlace(layout) => { + CValue::ByRef(fx.bcx.ins().iconst(fx.pointer_type, 0), layout) + } } } @@ -297,6 +306,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Stack(stack_slot, _layout) => { (fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None) } + CPlace::NoPlace(_) => (fx.bcx.ins().iconst(fx.pointer_type, 0), None), CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } @@ -357,6 +367,11 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Stack(stack_slot, dst_layout) => { (fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), dst_layout) } + CPlace::NoPlace(layout) => { + assert!(layout.size.bytes() == 0); + assert!(from.layout().size.bytes() == 0); + return; + } CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), }; @@ -476,16 +491,19 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + assert!(!self.layout().is_unsized()); match self { CPlace::Var(var, _) => CPlace::Var(var, layout), CPlace::Addr(addr, extra, _) => { - assert!(!layout.is_unsized()); CPlace::Addr(addr, extra, layout) } CPlace::Stack(stack_slot, _) => { - assert!(!layout.is_unsized()); CPlace::Stack(stack_slot, layout) } + CPlace::NoPlace(_) => { + assert!(layout.size.bytes() == 0); + CPlace::NoPlace(layout) + } } } From 82540cd429515da59a49cdb47093805f24291bc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 5 Feb 2019 05:19:56 +0000 Subject: [PATCH 0492/1566] Bump serde from 1.0.86 to 1.0.87 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.86 to 1.0.87. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.86...v1.0.87) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04e23c01eaadb..ee1a3ca5a8a94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -661,7 +661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -671,7 +671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -684,7 +684,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -932,7 +932,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.86 (registry+https://github.com/rust-lang/crates.io-index)" = "52ab457c27b091c27b887eef7181b3ea11ab4f92f66e3a99b2e556b77f9cc6bd" +"checksum serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "2e20fde37801e83c891a2dc4ebd3b81f0da4d1fb67a9e0a2a3b921e2536a58ee" "checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" From 93217dbae6040f6ca66db42db1bed4899e12f6ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 6 Feb 2019 06:06:44 +0000 Subject: [PATCH 0493/1566] Bump fuchsia-cprng from 0.1.0 to 0.1.1 Bumps fuchsia-cprng from 0.1.0 to 0.1.1. Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee1a3ca5a8a94..d4e737ac493b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -301,7 +301,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fuchsia-cprng" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -495,7 +495,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -889,7 +889,7 @@ dependencies = [ "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eb7217124812dc5672b7476d0c2d20cfe9f7c0f1ba0904b674a9762a0212f72e" -"checksum fuchsia-cprng 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81f7f8eb465745ea9b02e2704612a9946a59fa40572086c6fd49d6ddcf30bf31" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" From f10f918348775642a40b506ff5797fd6a1ab80d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 6 Feb 2019 06:06:48 +0000 Subject: [PATCH 0494/1566] Bump cc from 1.0.28 to 1.0.29 Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.28 to 1.0.29. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.28...1.0.29) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee1a3ca5a8a94..dd0b8e3826ec3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -525,7 +525,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -867,7 +867,7 @@ dependencies = [ "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" +"checksum cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "4390a3b5f4f6bce9c1d0c00128379df433e53777fdd30e92f16a529332baec4e" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" From 059b589407186dbf17f25ab0eaa81dddb5b125f9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 6 Feb 2019 18:44:02 +0100 Subject: [PATCH 0495/1566] Implement dynamic dispatch for self: Box --- src/vtable.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vtable.rs b/src/vtable.rs index 61455c6a70a09..562fbab4361a8 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -37,6 +37,13 @@ pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( arg: CValue<'tcx>, idx: usize, ) -> (Value, Value) { + let arg = if arg.layout().ty.is_box() { + // Cast `Box` to `*mut T` so `load_value_pair` works + arg.unchecked_cast_to(fx.layout_of(fx.tcx.mk_mut_ptr(arg.layout().ty.boxed_ty()))) + } else { + arg + }; + let (ptr, vtable) = arg.load_value_pair(fx); let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( From 43f4dc622054d7794c0e86cf8203ec294534c66c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 6 Feb 2019 18:49:59 +0100 Subject: [PATCH 0496/1566] Fix some warnings --- example/example.rs | 8 ++++---- example/mini_core_hello_world.rs | 4 ++-- src/pretty_clif.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example/example.rs b/example/example.rs index 220554550f179..d7fbb932240e2 100644 --- a/example/example.rs +++ b/example/example.rs @@ -77,7 +77,7 @@ fn debug_tuple() -> DebugTuple { } fn size_of() -> usize { - unsafe { intrinsics::size_of::() } + intrinsics::size_of::() } fn use_size_of() -> usize { @@ -93,10 +93,10 @@ unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { copy2(src, dst, 1); } -const Abc: u8 = 6 * 7; +const ABC: u8 = 6 * 7; fn use_const() -> u8 { - Abc + ABC } pub fn call_closure_3arg() { @@ -120,7 +120,7 @@ impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty { impl<'a, 'b> FnMut<(&'a &'b [u16],)> for IsNotEmpty { #[inline] - extern "rust-call" fn call_mut(&mut self, arg: (&'a &'b [u16],)) -> (u8, u8) { + extern "rust-call" fn call_mut(&mut self, _arg: (&'a &'b [u16],)) -> (u8, u8) { (0, 42) } } diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 2e39a3aae8692..e486afdbaa0c9 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -103,8 +103,8 @@ struct Unique { impl CoerceUnsized> for Unique where T: Unsize {} -fn take_f32(f: f32) {} -fn take_unique(u: Unique<()>) {} +fn take_f32(_f: f32) {} +fn take_unique(_u: Unique<()>) {} fn main() { take_unique(Unique { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 7107f62a27d67..a7a9c7a3306bd 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -203,7 +203,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { Ok(mut file) => { let target_triple: ::target_lexicon::Triple = self.tcx.sess.target.target.llvm_target.parse().unwrap(); writeln!(file, "test compile").unwrap(); - writeln!(file, "set is_pic"); + writeln!(file, "set is_pic").unwrap(); writeln!(file, "target {}", target_triple).unwrap(); writeln!(file, "").unwrap(); file.write(clif.as_bytes()).unwrap(); From c6bf784d39bbc782137a6c79a672d18ea5235029 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 6 Feb 2019 19:07:21 +0100 Subject: [PATCH 0497/1566] Misc changes --- build_sysroot/build_sysroot.sh | 1 - src/abi.rs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 2e332be7e6087..33da1e3dd6792 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -6,7 +6,6 @@ cd $(dirname "$0") cargo clean rm Cargo.lock 2>/dev/null || true rm -r sysroot 2>/dev/null || true -rm -r target 2>/dev/null || true # FIXME find a better way to get the target triple unamestr=`uname` diff --git a/src/abi.rs b/src/abi.rs index 0045866dfdd3f..3093ad69eb9ac 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -356,8 +356,7 @@ fn local_place<'a, 'tcx: 'a>( local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), )), _ => unreachable!(), - }; - + } } // Take stack_addr in advance to avoid many duplicate instructions From f2b67e12bb964d45213fa0ec428bfcb1bf2dd834 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 6 Feb 2019 19:22:01 +0100 Subject: [PATCH 0498/1566] Remove 0008-Replace-some-variadic-function-calls-with-unimplemen.patch --- ...iadic-function-calls-with-unimplemen.patch | 247 ------------------ 1 file changed, 247 deletions(-) delete mode 100644 patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch diff --git a/patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch b/patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch deleted file mode 100644 index 44edafcfcc3cb..0000000000000 --- a/patches/0008-Replace-some-variadic-function-calls-with-unimplemen.patch +++ /dev/null @@ -1,247 +0,0 @@ -From d1d5c0e5272a8c3f78e9c4eb97c38d8f5d5a6d87 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 17 Nov 2018 11:13:19 +0100 -Subject: [PATCH] Replace some variadic function calls with unimplemented!() - ---- - src/libstd/sys/unix/fd.rs | 18 ++++++++++++++++++ - src/libstd/sys/unix/fs.rs | 17 ++++++++++++++++- - src/libstd/sys/unix/net.rs | 3 +++ - src/libstd/sys/unix/rand.rs | 3 +++ - src/libstd/sys/unix/thread.rs | 3 +++ - 5 files changed, 43 insertions(+), 1 deletion(-) - -diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs -index 5a81d6d..919f9d1 100644 ---- a/src/libstd/sys/unix/fd.rs -+++ b/src/libstd/sys/unix/fd.rs -@@ -156,9 +156,12 @@ impl FileDesc { - - #[cfg(target_os = "linux")] - pub fn get_cloexec(&self) -> io::Result { -+ /* - unsafe { - Ok((cvt(libc::fcntl(self.fd, libc::F_GETFD))? & libc::FD_CLOEXEC) != 0) - } -+ */ -+ unimplemented!(); - } - - #[cfg(not(any(target_env = "newlib", -@@ -168,10 +171,13 @@ impl FileDesc { - target_os = "l4re", - target_os = "haiku")))] - pub fn set_cloexec(&self) -> io::Result<()> { -+ /* - unsafe { - cvt(libc::ioctl(self.fd, libc::FIOCLEX))?; - Ok(()) - } -+ */ -+ unimplemented!(); - } - #[cfg(any(target_env = "newlib", - target_os = "solaris", -@@ -180,6 +186,7 @@ impl FileDesc { - target_os = "l4re", - target_os = "haiku"))] - pub fn set_cloexec(&self) -> io::Result<()> { -+ /* - unsafe { - let previous = cvt(libc::fcntl(self.fd, libc::F_GETFD))?; - let new = previous | libc::FD_CLOEXEC; -@@ -188,19 +195,25 @@ impl FileDesc { - } - Ok(()) - } -+ */ -+ unimplemented!(); - } - - #[cfg(target_os = "linux")] - pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { -+ /* - unsafe { - let v = nonblocking as c_int; - cvt(libc::ioctl(self.fd, libc::FIONBIO, &v))?; - Ok(()) - } -+ */ -+ unimplemented!(); - } - - #[cfg(not(target_os = "linux"))] - pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { -+ /* - unsafe { - let previous = cvt(libc::fcntl(self.fd, libc::F_GETFL))?; - let new = if nonblocking { -@@ -213,9 +226,12 @@ impl FileDesc { - } - Ok(()) - } -+ */ -+ unimplemented!(); - } - - pub fn duplicate(&self) -> io::Result { -+ /* - // We want to atomically duplicate this file descriptor and set the - // CLOEXEC flag, and currently that's done via F_DUPFD_CLOEXEC. This - // flag, however, isn't supported on older Linux kernels (earlier than -@@ -263,6 +279,8 @@ impl FileDesc { - } - } - cvt(unsafe { libc::fcntl(fd, libc::F_DUPFD, 0) }).and_then(make_filedesc) -+ */ -+ unimplemented!(); - } - } - -diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs -index add06ae..1a392fc 100644 ---- a/src/libstd/sys/unix/fs.rs -+++ b/src/libstd/sys/unix/fs.rs -@@ -465,6 +465,7 @@ impl File { - } - - pub fn open_c(path: &CStr, opts: &OpenOptions) -> io::Result { -+ /* - let flags = libc::O_CLOEXEC | - opts.get_access_mode()? | - opts.get_creation_mode()? | -@@ -519,6 +520,8 @@ impl File { - - ensure_cloexec(&fd)?; - Ok(File(fd)) -+ */ -+ unimplemented!(); - } - - pub fn file_attr(&self) -> io::Result { -@@ -535,6 +538,7 @@ impl File { - } - - pub fn datasync(&self) -> io::Result<()> { -+ /* - cvt_r(|| unsafe { os_datasync(self.0.raw()) })?; - return Ok(()); - -@@ -547,7 +551,9 @@ impl File { - #[cfg(not(any(target_os = "macos", - target_os = "ios", - target_os = "linux")))] -- unsafe fn os_datasync(fd: c_int) -> c_int { libc::fsync(fd) } -+ unsafe fn os_datasync(fd: c_int) -> c_int { libc::fsync(fd) }] -+ */ -+ unimplemented!(); - } - - pub fn truncate(&self, size: u64) -> io::Result<()> { -@@ -643,6 +649,7 @@ impl fmt::Debug for File { - - #[cfg(target_os = "macos")] - fn get_path(fd: c_int) -> Option { -+ /* - // FIXME: The use of PATH_MAX is generally not encouraged, but it - // is inevitable in this case because macOS defines `fcntl` with - // `F_GETPATH` in terms of `MAXPATHLEN`, and there are no -@@ -657,6 +664,8 @@ impl fmt::Debug for File { - buf.truncate(l as usize); - buf.shrink_to_fit(); - Some(PathBuf::from(OsString::from_vec(buf))) -+ */ -+ unimplemented!(); - } - - #[cfg(not(any(target_os = "linux", target_os = "macos")))] -@@ -667,6 +676,7 @@ impl fmt::Debug for File { - - #[cfg(any(target_os = "linux", target_os = "macos"))] - fn get_mode(fd: c_int) -> Option<(bool, bool)> { -+ /* - let mode = unsafe { libc::fcntl(fd, libc::F_GETFL) }; - if mode == -1 { - return None; -@@ -677,6 +687,8 @@ impl fmt::Debug for File { - libc::O_WRONLY => Some((false, true)), - _ => None - } -+ */ -+ unimplemented!(); - } - - #[cfg(not(any(target_os = "linux", target_os = "macos")))] -@@ -868,6 +880,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { - len: libc::size_t, - flags: libc::c_uint, - ) -> libc::c_long { -+ /* - libc::syscall( - libc::SYS_copy_file_range, - fd_in, -@@ -877,6 +890,8 @@ pub fn copy(from: &Path, to: &Path) -> io::Result { - len, - flags, - ) -+ */ -+ unimplemented!(); - } - - if !from.is_file() { -diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs -index 2d10541..19e96c4 100644 ---- a/src/libstd/sys/unix/net.rs -+++ b/src/libstd/sys/unix/net.rs -@@ -339,8 +339,11 @@ impl Socket { - } - - pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { -+ /* - let mut nonblocking = nonblocking as libc::c_int; - cvt(unsafe { libc::ioctl(*self.as_inner(), libc::FIONBIO, &mut nonblocking) }).map(|_| ()) -+ */ -+ unimplemented!(); - } - - pub fn take_error(&self) -> io::Result> { -diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs -index 371e58a..28d4c68 100644 ---- a/src/libstd/sys/unix/rand.rs -+++ b/src/libstd/sys/unix/rand.rs -@@ -34,9 +34,12 @@ mod imp { - - #[cfg(any(target_os = "linux", target_os = "android"))] - fn getrandom(buf: &mut [u8]) -> libc::c_long { -+ /* - unsafe { - libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr(), buf.len(), libc::GRND_NONBLOCK) - } -+ */ -+ unimplemented!(); - } - - #[cfg(not(any(target_os = "linux", target_os = "android")))] -diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs -index f3a45d2..1c2f0ce 100644 ---- a/src/libstd/sys/unix/thread.rs -+++ b/src/libstd/sys/unix/thread.rs -@@ -100,12 +100,15 @@ impl Thread { - #[cfg(any(target_os = "linux", - target_os = "android"))] - pub fn set_name(name: &CStr) { -+ /* - const PR_SET_NAME: libc::c_int = 15; - // pthread wrapper only appeared in glibc 2.12, so we use syscall - // directly. - unsafe { - libc::prctl(PR_SET_NAME, name.as_ptr() as libc::c_ulong, 0, 0, 0); - } -+ */ -+ unimplemented!(); - } - - #[cfg(any(target_os = "freebsd", --- -2.17.2 (Apple Git-113) - From 226aa363738fe2a80091e0472398ab7c65f1d613 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 7 Feb 2019 06:21:48 +0000 Subject: [PATCH 0499/1566] Bump gimli from `9ed8d7b` to `955c33e` Bumps [gimli](https://github.com/gimli-rs/gimli) from `9ed8d7b` to `955c33e`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/9ed8d7bce40613c9c9b5b511d9c5ead24492d7e1...955c33ed0056374ab349b1a175f743db3f571e0d) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f84b699b0e374..ef25faadfddb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#9ed8d7bce40613c9c9b5b511d9c5ead24492d7e1" +source = "git+https://github.com/gimli-rs/gimli.git#955c33ed0056374ab349b1a175f743db3f571e0d" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 2970dd7af5b14e714cb7b8fbd9a0c9974e7ef9ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 7 Feb 2019 06:22:17 +0000 Subject: [PATCH 0500/1566] Bump rand_jitter from 0.1.2 to 0.1.3 Bumps [rand_jitter](https://github.com/rust-random/rand) from 0.1.2 to 0.1.3. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/rand_jitter-0.1.2...rand_jitter-0.1.3) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f84b699b0e374..09126e04868e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -434,7 +434,7 @@ dependencies = [ "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -481,7 +481,7 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", @@ -913,7 +913,7 @@ dependencies = [ "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "080723c6145e37503a2224f801f252e14ac5531cb450f4502698542d188cb3c0" +"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" "checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d" "checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" From bbfcecc312cb898bad6f9b6d917197f3b3f474ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 7 Feb 2019 07:26:33 +0000 Subject: [PATCH 0501/1566] Bump cranelift from `c47ca7b` to `0a04fb6` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `c47ca7b` to `0a04fb6`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2...0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef25faadfddb5..479980b53d322 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#c47ca7bafc8fc48358f1baa72360e61fc1f7a0f2" +source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", From c8f19f1cb2639677e314b292658e271b1e024b16 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 7 Feb 2019 20:28:55 +0100 Subject: [PATCH 0502/1566] Make codegen_call_inner a bit more readable --- src/abi.rs | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 3093ad69eb9ac..4a7943d3c4e6d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -619,28 +619,26 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( _ => None, }; - let func_ref: Option; // Indirect call target - - let first_arg = { - if let Some(Instance { + // | Indirect call target + // v v the first argument to be passed + let (func_ref, first_arg) = match instance { + // Trait object call + Some(Instance { def: InstanceDef::Virtual(_, idx), .. - }) = instance - { + }) => { let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0], idx); - func_ref = Some(method); - Some(ptr) - } else { - func_ref = if instance.is_none() { - let func = trans_operand(fx, func.expect("indirect call without func Operand")); - Some(func.load_scalar(fx)) - } else { - None - }; + (Some(method), Some(ptr)) + } - args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)) + // Normal call + Some(_) => (None, args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg))), + + // Indirect call + None => { + let func = trans_operand(fx, func.expect("indirect call without func Operand")).load_scalar(fx); + (Some(func), args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg))) } - .into_iter() }; let call_args: Vec = return_ptr From d3995bc5f6192acf2b32c007834de5e5a241c5ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 8 Feb 2019 05:37:43 +0000 Subject: [PATCH 0503/1566] Bump cranelift from `0a04fb6` to `4d92022` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `0a04fb6` to `4d92022`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc...4d92022a0b1b0bef82a933057005f598d6e48bfc) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 479980b53d322..7148f8bd47683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0a04fb6ad0b3acb165b9b4dc1aeab5abf061a9fc" +source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", From 1eba7e5f5e80e085cea33fbac94c4238a297cf59 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 7 Feb 2019 20:45:15 +0100 Subject: [PATCH 0504/1566] Implement drop for trait objects --- example/mini_core.rs | 13 +++++++ example/mini_core_hello_world.rs | 10 +++-- src/abi.rs | 19 ++++++++++ src/base.rs | 63 ++++++++------------------------ src/vtable.rs | 13 +++++++ 5 files changed, 67 insertions(+), 51 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 74daedb1df4f0..0ddd3ade40178 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -294,6 +294,12 @@ pub struct Box(*mut T); impl, U: ?Sized> CoerceUnsized> for Box {} +impl Drop for Box { + fn drop(&mut self) { + // drop is currently performed by compiler. + } +} + #[lang = "exchange_malloc"] // Make it available to jited mini_core_hello_world // FIXME remove next line when jit supports linking rlibs @@ -302,6 +308,12 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { libc::malloc(size) } +#[lang = "box_free"] +#[inline(always)] +unsafe fn box_free(ptr: *mut T) { + libc::free(ptr as *mut u8); +} + #[lang = "drop"] pub trait Drop { fn drop(&mut self); @@ -327,6 +339,7 @@ pub mod libc { extern "C" { pub fn puts(s: *const u8); pub fn malloc(size: usize) -> *mut u8; + pub fn free(ptr: *mut u8); pub fn memcpy(dst: *mut u8, src: *const u8, size: usize); pub fn memmove(dst: *mut u8, src: *const u8, size: usize); pub fn strncpy(dst: *mut u8, src: *const u8, size: usize); diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index e486afdbaa0c9..293ab8bfbff12 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -62,6 +62,10 @@ impl Drop for NoisyDropInner { } } +impl SomeTrait for NoisyDrop { + fn object_safe(&self) {} +} + enum Ordering { Less = -1, Equal = 0, @@ -152,10 +156,10 @@ fn main() { intrinsics::size_of_val(&MyDst([0u8; 4]) as &MyDst<[u8]>); } - let _ = NoisyDrop { - text: "Outer got dropped!\0", + let _ = box NoisyDrop { + text: "Boxed outer got dropped!\0", inner: NoisyDropInner, - }; + } as Box; const FUNC_REF: Option = Some(main); match FUNC_REF { diff --git a/src/abi.rs b/src/abi.rs index 4a7943d3c4e6d..70e94db93ae17 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -671,6 +671,25 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( } } +pub fn codegen_drop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + drop_place: CPlace<'tcx>, + drop_fn_ty: Ty<'tcx>, +) { + let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); + let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); + + let fn_sig = ty_fn_sig(fx.tcx, drop_fn_ty); + + match get_pass_mode(fx.tcx, fn_sig.output(), true) { + PassMode::NoPass => {}, + _ => unreachable!(), + }; + + let sig = fx.bcx.import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); + fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); +} + pub fn codegen_return(fx: &mut FunctionCx) { match get_pass_mode(fx.tcx, fx.return_type(), true) { PassMode::NoPass | PassMode::ByRef => { diff --git a/src/base.rs b/src/base.rs index 8914addadad4f..94598c65672ac 100644 --- a/src/base.rs +++ b/src/base.rs @@ -242,7 +242,8 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) TerminatorKind::Yield { .. } | TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } - | TerminatorKind::DropAndReplace { .. } => { + | TerminatorKind::DropAndReplace { .. } + | TerminatorKind::GeneratorDrop => { bug!("shouldn't exist at trans {:?}", bb_data.terminator()); } TerminatorKind::Drop { @@ -258,23 +259,23 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) // we don't actually need to drop anything } else { let drop_place = trans_place(fx, location); - let arg_place = CPlace::new_stack_slot( - fx, - fx.tcx.mk_ref( - &ty::RegionKind::ReErased, - TypeAndMut { - ty, - mutbl: crate::rustc::hir::Mutability::MutMutable, - }, - ), - ); - drop_place.write_place_ref(fx, arg_place); + let drop_fn_ty = drop_fn.ty(fx.tcx); match ty.sty { ty::Dynamic(..) => { - fx.tcx.sess.warn("Drop for trait object"); + crate::abi::codegen_drop(fx, drop_place, drop_fn_ty); } _ => { - let drop_fn_ty = drop_fn.ty(fx.tcx); + let arg_place = CPlace::new_stack_slot( + fx, + fx.tcx.mk_ref( + &ty::RegionKind::ReErased, + TypeAndMut { + ty, + mutbl: crate::rustc::hir::Mutability::MutMutable, + }, + ), + ); + drop_place.write_place_ref(fx, arg_place); let arg_value = arg_place.to_cvalue(fx); crate::abi::codegen_call_inner( fx, @@ -285,45 +286,11 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) ); } } - /* - let (args1, args2); - /*let mut args = if let Some(llextra) = place.llextra { - args2 = [place.llval, llextra]; - &args2[..] - } else { - args1 = [place.llval]; - &args1[..] - };*/ - let (drop_fn, fn_ty) = match ty.sty { - ty::Dynamic(..) => { - let fn_ty = drop_fn.ty(bx.cx.tcx); - let sig = common::ty_fn_sig(bx.cx, fn_ty); - let sig = bx.tcx().normalize_erasing_late_bound_regions( - ty::ParamEnv::reveal_all(), - &sig, - ); - let fn_ty = FnType::new_vtable(bx.cx, sig, &[]); - let vtable = args[1]; - args = &args[..1]; - (meth::DESTRUCTOR.get_fn(&bx, vtable, &fn_ty), fn_ty) - } - _ => { - let value = place.to_cvalue(fx); - (callee::get_fn(bx.cx, drop_fn), - FnType::of_instance(bx.cx, &drop_fn)) - } - }; - do_call(self, bx, fn_ty, drop_fn, args, - Some((ReturnDest::Nothing, target)), - unwind);*/ } let target_ebb = fx.get_ebb(*target); fx.bcx.ins().jump(target_ebb, &[]); } - TerminatorKind::GeneratorDrop => { - unimplemented!("terminator GeneratorDrop"); - } }; } diff --git a/src/vtable.rs b/src/vtable.rs index 562fbab4361a8..720582b7caed0 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -6,6 +6,19 @@ const DROP_FN_INDEX: usize = 0; const SIZE_INDEX: usize = 1; const ALIGN_INDEX: usize = 2; +pub fn drop_fn_of_obj<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + vtable: Value, +) -> Value { + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + fx.bcx.ins().load( + pointer_ty(fx.tcx), + MemFlags::new(), + vtable, + (DROP_FN_INDEX * usize_size) as i32, + ) +} + pub fn size_of_obj<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, vtable: Value, From e2a869e166154c3ca9873b41c6ab8af1621704e7 Mon Sep 17 00:00:00 2001 From: Philip Craig Date: Sat, 9 Feb 2019 17:15:15 +1000 Subject: [PATCH 0505/1566] Update gimli --- Cargo.lock | 2 +- src/debuginfo.rs | 227 ++++++++++++++++------------------------------- 2 files changed, 79 insertions(+), 150 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7148f8bd47683..a12bb2f63dc35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#955c33ed0056374ab349b1a175f743db3f571e0d" +source = "git+https://github.com/gimli-rs/gimli.git#1278ccb7b6eaa8eea3b9c082f18a282d3c48703b" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 21cea157250ab..70622d4bd4957 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -7,10 +7,9 @@ use std::marker::PhantomData; use syntax::source_map::FileName; use gimli::write::{ - Address, AttributeValue, CompilationUnit, DebugAbbrev, DebugInfo, DebugLine, DebugRanges, - DebugRngLists, DebugStr, EndianVec, LineProgram, LineProgramId, LineProgramTable, Range, - RangeList, Result, SectionId, StringTable, UnitEntryId, UnitId, UnitTable, - Writer, FileId, LineStringTable, DebugLineStr, LineString, + Address, AttributeValue, DwarfUnit, EndianVec, LineProgram, Range, + RangeList, Result, SectionId, UnitEntryId, + Writer, FileId, LineStringTable, LineString, Sections, }; use gimli::{Encoding, Format, RunTimeEndian}; @@ -51,29 +50,34 @@ fn line_program_add_file(line_program: &mut LineProgram, line_strings: &mut Line } } +#[derive(Clone)] struct DebugReloc { offset: u32, size: u8, - name: String, + name: DebugRelocName, addend: i64, } +#[derive(Clone)] +enum DebugRelocName { + Section(SectionId), + Symbol(usize), +} + +impl DebugReloc { + fn name<'a>(&self, ctx: &'a DebugContext) -> &'a str { + match self.name { + DebugRelocName::Section(id) => id.name(), + DebugRelocName::Symbol(index) => ctx.symbols.get_index(index).unwrap(), + } + } +} + pub struct DebugContext<'tcx> { - // Encoding info endian: RunTimeEndian, symbols: indexmap::IndexSet, - // Main data - units: UnitTable, - line_programs: LineProgramTable, - - // Side tables - strings: StringTable, - line_strings: LineStringTable, - - // Global ids - unit_id: UnitId, - global_line_program: LineProgramId, + dwarf: DwarfUnit, unit_range_list: RangeList, _dummy: PhantomData<&'tcx ()>, @@ -89,6 +93,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { address_size, }; + let mut dwarf = DwarfUnit::new(encoding); + // FIXME: how to get version when building out of tree? // Normally this would use option_env!("CFG_VERSION"). let producer = format!("cranelift fn (rustc version {})", "unknown version"); @@ -98,34 +104,27 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { None => tcx.crate_name(LOCAL_CRATE).to_string(), }; - let mut strings = StringTable::default(); - let mut line_strings = LineStringTable::default(); - - let mut units = UnitTable::default(); - let mut line_programs = LineProgramTable::default(); - - let global_line_program = line_programs.add(LineProgram::new( + let line_program = LineProgram::new( encoding, 1, 1, -5, 14, - LineString::new(comp_dir.as_bytes(), encoding, &mut line_strings), - LineString::new(name.as_bytes(), encoding, &mut line_strings), + LineString::new(comp_dir.as_bytes(), encoding, &mut dwarf.line_strings), + LineString::new(name.as_bytes(), encoding, &mut dwarf.line_strings), None, - )); + ); + dwarf.unit.line_program = line_program; - let unit_id = units.add(CompilationUnit::new(encoding)); { - let name = strings.add(&*name); - let comp_dir = strings.add(&*comp_dir); + let name = dwarf.strings.add(&*name); + let comp_dir = dwarf.strings.add(&*comp_dir); - let unit = units.get_mut(unit_id); - let root = unit.root(); - let root = unit.get_mut(root); + let root = dwarf.unit.root(); + let root = dwarf.unit.get_mut(root); root.set( gimli::DW_AT_producer, - AttributeValue::StringRef(strings.add(producer)), + AttributeValue::StringRef(dwarf.strings.add(producer)), ); root.set( gimli::DW_AT_language, @@ -133,10 +132,6 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { ); root.set(gimli::DW_AT_name, AttributeValue::StringRef(name)); root.set(gimli::DW_AT_comp_dir, AttributeValue::StringRef(comp_dir)); - root.set( - gimli::DW_AT_stmt_list, - AttributeValue::LineProgramRef(global_line_program), - ); root.set( gimli::DW_AT_low_pc, AttributeValue::Address(Address::Absolute(0)), @@ -147,14 +142,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { endian: target_endian(tcx), symbols: indexmap::IndexSet::new(), - strings, - line_strings, - - units, - line_programs, - - unit_id, - global_line_program, + dwarf, unit_range_list: RangeList(Vec::new()), _dummy: PhantomData, @@ -164,11 +152,13 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { fn emit_location(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, entry_id: UnitEntryId, span: Span) { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); - let line_program = self.line_programs.get_mut(self.global_line_program); - let file_id = line_program_add_file(line_program, &mut self.line_strings, &loc.file.name); + let file_id = line_program_add_file( + &mut self.dwarf.unit.line_program, + &mut self.dwarf.line_strings, + &loc.file.name, + ); - let unit = self.units.get_mut(self.unit_id); - let entry = unit.get_mut(entry_id); + let entry = self.dwarf.unit.get_mut(entry_id); entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(file_id)); entry.set( @@ -183,73 +173,37 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { } pub fn emit(&mut self, artifact: &mut Artifact) { - let unit = self.units.get_mut(self.unit_id); - let unit_range_list_id = unit.ranges.add(self.unit_range_list.clone()); - let root = unit.root(); - let root = unit.get_mut(root); + let unit_range_list_id = self.dwarf.unit.ranges.add(self.unit_range_list.clone()); + let root = self.dwarf.unit.root(); + let root = self.dwarf.unit.get_mut(root); root.set( gimli::DW_AT_ranges, AttributeValue::RangeListRef(unit_range_list_id), ); - let mut debug_abbrev = DebugAbbrev::from(WriterRelocate::new(self)); - let mut debug_info = DebugInfo::from(WriterRelocate::new(self)); - let mut debug_str = DebugStr::from(WriterRelocate::new(self)); - let mut debug_line_str = DebugLineStr::from(WriterRelocate::new(self)); - let mut debug_line = DebugLine::from(WriterRelocate::new(self)); - let mut debug_ranges = DebugRanges::from(WriterRelocate::new(self)); - let mut debug_rnglists = DebugRngLists::from(WriterRelocate::new(self)); - - let debug_str_offsets = self.strings.write(&mut debug_str).unwrap(); - let debug_line_str_offsets = self.line_strings.write(&mut debug_line_str).unwrap(); - - let debug_line_offsets = self.line_programs.write(&mut debug_line, &debug_line_str_offsets, &debug_str_offsets).unwrap(); - - self.units - .write( - &mut debug_abbrev, - &mut debug_info, - &mut debug_ranges, - &mut debug_rnglists, - &debug_line_offsets, - &debug_line_str_offsets, - &debug_str_offsets, - ) - .unwrap(); - - macro decl_section($section:ident = $name:ident) { - artifact - .declare_with( - SectionId::$section.name(), - Decl::DebugSection, - $name.0.writer.into_vec(), - ) - .unwrap(); - } - - decl_section!(DebugAbbrev = debug_abbrev); - decl_section!(DebugInfo = debug_info); - decl_section!(DebugStr = debug_str); - decl_section!(DebugLine = debug_line); - decl_section!(DebugLineStr = debug_line_str); + let mut sections = Sections::new(WriterRelocate::new(self)); + self.dwarf.write(&mut sections).unwrap(); - let debug_ranges_not_empty = !debug_ranges.0.writer.slice().is_empty(); - if debug_ranges_not_empty { - decl_section!(DebugRanges = debug_ranges); - } - - let debug_rnglists_not_empty = !debug_rnglists.0.writer.slice().is_empty(); - if debug_rnglists_not_empty { - decl_section!(DebugRngLists = debug_rnglists); - } + let _: Result<()> = sections.for_each_mut(|id, section| { + if !section.writer.slice().is_empty() { + artifact + .declare_with( + id.name(), + Decl::DebugSection, + section.writer.take(), + ) + .unwrap(); + } + Ok(()) + }); - macro sect_relocs($section:ident = $name:ident) { - for reloc in $name.0.relocs { + let _: Result<()> = sections.for_each(|id, section| { + for reloc in §ion.relocs { artifact .link_with( faerie::Link { - from: SectionId::$section.name(), - to: &reloc.name, + from: id.name(), + to: reloc.name(self), at: u64::from(reloc.offset), }, faerie::Reloc::Debug { @@ -259,25 +213,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { ) .expect("faerie relocation error"); } - } - - sect_relocs!(DebugAbbrev = debug_abbrev); - sect_relocs!(DebugInfo = debug_info); - sect_relocs!(DebugStr = debug_str); - sect_relocs!(DebugLine = debug_line); - sect_relocs!(DebugLineStr = debug_line_str); - - if debug_ranges_not_empty { - sect_relocs!(DebugRanges = debug_ranges); - } - - if debug_rnglists_not_empty { - sect_relocs!(DebugRngLists = debug_rnglists); - } - } - - fn section_name(&self, id: SectionId) -> String { - id.name().to_string() + Ok(()) + }); } } @@ -298,13 +235,12 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { ) -> Self { let (symbol, _) = debug_context.symbols.insert_full(name.to_string()); - let unit = debug_context.units.get_mut(debug_context.unit_id); // FIXME: add to appropriate scope intead of root - let scope = unit.root(); + let scope = debug_context.dwarf.unit.root(); - let entry_id = unit.add(scope, gimli::DW_TAG_subprogram); - let entry = unit.get_mut(entry_id); - let name_id = debug_context.strings.add(name); + let entry_id = debug_context.dwarf.unit.add(scope, gimli::DW_TAG_subprogram); + let entry = debug_context.dwarf.unit.get_mut(entry_id); + let name_id = debug_context.dwarf.strings.add(name); entry.set( gimli::DW_AT_linkage_name, AttributeValue::StringRef(name_id), @@ -334,8 +270,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { isa: &cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet, ) { - let unit = self.debug_context.units.get_mut(self.debug_context.unit_id); - let entry = unit.get_mut(self.entry_id); + let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(code_size as u64)); self.debug_context.unit_range_list.0.push(Range::StartLength { @@ -346,10 +281,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { length: code_size as u64, }); - let line_program = self - .debug_context - .line_programs - .get_mut(self.debug_context.global_line_program); + let line_program = &mut self.debug_context.dwarf.unit.line_program; line_program.begin_sequence(Some(Address::Relative { symbol: self.symbol, @@ -361,7 +293,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let mut ebbs = func.layout.ebbs().collect::>(); ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase - let line_strings = &mut self.debug_context.line_strings; + let line_strings = &mut self.debug_context.dwarf.line_strings; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); @@ -404,23 +336,22 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { } } -struct WriterRelocate<'a, 'tcx> { - ctx: &'a DebugContext<'tcx>, +#[derive(Clone)] +struct WriterRelocate { relocs: Vec, writer: EndianVec, } -impl<'a, 'tcx> WriterRelocate<'a, 'tcx> { - fn new(ctx: &'a DebugContext<'tcx>) -> Self { +impl WriterRelocate { + fn new(ctx: & DebugContext) -> Self { WriterRelocate { - ctx, relocs: Vec::new(), writer: EndianVec::new(ctx.endian), } } } -impl<'a, 'tcx> Writer for WriterRelocate<'a, 'tcx> { +impl Writer for WriterRelocate { type Endian = RunTimeEndian; fn endian(&self) -> Self::Endian { @@ -447,7 +378,7 @@ impl<'a, 'tcx> Writer for WriterRelocate<'a, 'tcx> { self.relocs.push(DebugReloc { offset: offset as u32, size, - name: self.ctx.symbols.get_index(symbol).unwrap().clone(), + name: DebugRelocName::Symbol(symbol), addend: addend as i64, }); self.write_word(0, size) @@ -457,11 +388,10 @@ impl<'a, 'tcx> Writer for WriterRelocate<'a, 'tcx> { fn write_offset(&mut self, val: usize, section: SectionId, size: u8) -> Result<()> { let offset = self.len() as u32; - let name = self.ctx.section_name(section); self.relocs.push(DebugReloc { offset, size, - name, + name: DebugRelocName::Section(section), addend: val as i64, }); self.write_word(0, size) @@ -474,11 +404,10 @@ impl<'a, 'tcx> Writer for WriterRelocate<'a, 'tcx> { section: SectionId, size: u8, ) -> Result<()> { - let name = self.ctx.section_name(section); self.relocs.push(DebugReloc { offset: offset as u32, size, - name, + name: DebugRelocName::Section(section), addend: val as i64, }); self.write_word_at(offset, 0, size) From 19f9810a0f28e0597c3f5c3ec3be1b1017a7087c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Feb 2019 15:05:26 +0100 Subject: [PATCH 0506/1566] Rustup to rustc 1.34.0-nightly (0b7af2668 2019-02-10) --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 1af5a28688193..d5d850c7b089c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -144,7 +144,7 @@ fn trans_const_place<'a, 'tcx: 'a>( span: DUMMY_SP, ty: const_.ty, user_ty: None, - literal: fx.tcx.intern_lazy_const(LazyConst::Evaluated(const_)), + literal: fx.tcx.mk_lazy_const(LazyConst::Evaluated(const_)), })), None, )?; From a272efa0309f9ef52cf064f685c754fb75e65634 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Feb 2019 15:28:56 +0100 Subject: [PATCH 0507/1566] Fix alloc_example --- src/lib.rs | 2 +- test.sh | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7b0e4d231d6dd..370a022a92bdf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -426,7 +426,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( (RLinkage::Internal, Visibility::Default) => Linkage::Local, // FIXME this should get external linkage, but hidden visibility, // not internal linkage and default visibility - | (RLinkage::External, Visibility::Hidden) => Linkage::Local, + | (RLinkage::External, Visibility::Hidden) => Linkage::Export, _ => panic!("{:?} = {:?} {:?}", mono_item, linkage, vis), }; base::trans_mono_item(&mut cx, mono_item, linkage); diff --git a/test.sh b/test.sh index 1782df6113ddd..006f488790e33 100755 --- a/test.sh +++ b/test.sh @@ -25,10 +25,9 @@ sh -c ./target/out/mini_core_hello_world || true echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh -# TODO linux linker doesn't accept duplicate definitions -# echo "[BUILD+RUN] alloc_example" -#$RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin -#./target/out/alloc_example +echo "[BUILD+RUN] alloc_example" +$RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin -g +./target/out/alloc_example echo "[BUILD] mod_bench" $RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -g From 91385ba0fcafeaa195c562b77f423167bf36d298 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Feb 2019 15:42:28 +0100 Subject: [PATCH 0508/1566] Cleanup config.sh --- config.sh | 2 +- example/mini_core_hello_world.rs | 3 ++- test.sh | 19 +++++++------------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/config.sh b/config.sh index 5508acf870cfa..c73a75a008212 100644 --- a/config.sh +++ b/config.sh @@ -18,5 +18,5 @@ else cargo build fi -export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext +export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 293ab8bfbff12..1254d91718943 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -78,7 +78,8 @@ fn start( _argc: isize, _argv: *const *const u8, ) -> isize { - main().report() as isize + main().report(); + 0 } static mut NUM: u8 = 6 * 7; diff --git a/test.sh b/test.sh index 006f488790e33..8cc4b0ff817ac 100755 --- a/test.sh +++ b/test.sh @@ -1,41 +1,36 @@ #!/bin/bash source config.sh -build_example_bin() { - $RUSTC $2 --crate-name $1 --crate-type bin - sh -c ./target/out/$1 || true -} - rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib -g +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib echo "[BUILD] example" -$RUSTC example/example.rs --crate-type lib -g +$RUSTC example/example.rs --crate-type lib echo "[JIT] mini_core_hello_world" SHOULD_RUN=1 $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" -$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g -sh -c ./target/out/mini_core_hello_world || true +$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin +sh -c ./target/out/mini_core_hello_world echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh echo "[BUILD+RUN] alloc_example" -$RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin -g +$RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin ./target/out/alloc_example echo "[BUILD] mod_bench" -$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -g +$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin echo "[BUILD] sysroot in release mode" ./build_sysroot/build_sysroot.sh --release -COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -Og --crate-name mod_bench_inline" +COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" From 5b3867430ff4490830a8cd735af93a92984a54ea Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Feb 2019 18:49:59 +0100 Subject: [PATCH 0509/1566] Fix "offset" intrinsic It didn't multiply the offset given by the pointee type size. --- src/intrinsics.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index a00ab64d889ba..22302c0b6a262 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -127,6 +127,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( likely | unlikely, (c a) { ret.write_cvalue(fx, a); }; + breakpoint, () { + fx.bcx.ins().debugtrap(); + }; copy | copy_nonoverlapping, (v src, v dst, v count) { let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); let elem_size = fx @@ -286,8 +289,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let res = fx.bcx.ins().rotr(x, y); ret.write_cvalue(fx, CValue::ByVal(res, layout)); }; - offset, (v base, v offset) { - let res = fx.bcx.ins().iadd(base, offset); + offset, (c base, v offset) { + let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; + let pointee_size = fx.layout_of(pointee_ty).size.bytes(); + let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); + let base_val = base.load_scalar(fx); + let res = fx.bcx.ins().iadd(base_val, ptr_diff); ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); }; transmute, (c from) { From 4bb8bfca94aa704b2f57f33d2f6be121ee88e3fa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Feb 2019 19:11:55 +0100 Subject: [PATCH 0510/1566] Disable macOS debuginfo and on all platforms optimizations --- src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 370a022a92bdf..5863f730bcace 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -296,7 +296,9 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut faerie_module = new_module("some_file".to_string()); - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None + && !tcx.sess.target.target.options.is_like_osx // macOS debuginfo doesn't work yet (see #303) + { let debug = DebugContext::new(tcx, faerie_module.target_config().pointer_type().bytes() as u8); Some(debug) } else { @@ -372,7 +374,8 @@ fn build_isa(sess: &Session) -> Box { "false" }).unwrap(); - match sess.opts.optimize { + // FIXME enable again when https://github.com/CraneStation/cranelift/issues/664 is fixed + /*match sess.opts.optimize { OptLevel::No => { flags_builder.set("opt_level", "fastest").unwrap(); } @@ -383,7 +386,7 @@ fn build_isa(sess: &Session) -> Box { OptLevel::Size | OptLevel::SizeMin => { sess.warn("Optimizing for size is not supported. Just ignoring the request"); } - } + }*/ let flags = settings::Flags::new(flags_builder); cranelift::codegen::isa::lookup(sess.target.target.llvm_target.parse().unwrap()) From c68e76c33bf8b8e3fc0dabb3f7d9133328a7ea6d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Feb 2019 19:18:52 +0100 Subject: [PATCH 0511/1566] Implement variadic function calling --- example/mini_core.rs | 1 + example/mini_core_hello_world.rs | 2 ++ src/abi.rs | 24 +++++++++++++++++++++--- src/base.rs | 2 +- src/main_shim.rs | 3 +-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 0ddd3ade40178..4da661ebb8d86 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -338,6 +338,7 @@ pub mod libc { #[link(name = "c")] extern "C" { pub fn puts(s: *const u8); + pub fn printf(format: *const char, ...) -> i32; pub fn malloc(size: usize) -> *mut u8; pub fn free(ptr: *mut u8); pub fn memcpy(dst: *mut u8, src: *const u8, size: usize); diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 1254d91718943..17c64ffe09fc5 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -121,6 +121,8 @@ fn main() { //return; unsafe { + printf("Hello %s\n\0" as *const str as *const char, "printf\0" as *const str as *const char); + let hello: &[u8] = b"Hello\0" as &[u8; 6]; let ptr: *const u8 = hello as *const [u8] as *const u8; puts(ptr); diff --git a/src/abi.rs b/src/abi.rs index 70e94db93ae17..aa85349b9b8c3 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -191,12 +191,13 @@ pub fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnS pub fn get_function_name_and_sig<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>, + support_vararg: bool ) -> (String, Signature) { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_ty = inst.ty(tcx); let fn_sig = ty_fn_sig(tcx, fn_ty); - if fn_sig.variadic { - unimpl!("Variadic functions are not yet supported"); + if fn_sig.variadic && !support_vararg { + unimpl!("Variadic function definitions are not yet supported"); } let sig = clif_sig_from_fn_sig(tcx, fn_sig); (tcx.symbol_name(inst).as_str().to_string(), sig) @@ -208,7 +209,7 @@ pub fn import_function<'a, 'tcx: 'a>( module: &mut Module, inst: Instance<'tcx>, ) -> FuncId { - let (name, sig) = get_function_name_and_sig(tcx, inst); + let (name, sig) = get_function_name_and_sig(tcx, inst, true); module .declare_function(&name, Linkage::Import, &sig) .unwrap() @@ -659,6 +660,23 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( fx.bcx.ins().call(func_ref, &call_args) }; + // FIXME find a cleaner way to support varargs + if fn_sig.variadic { + if fn_sig.abi != Abi::C { + unimpl!("Variadic call for non-C abi {:?}", fn_sig.abi); + } + let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); + let abi_params = call_args.into_iter().map(|arg| { + let ty = fx.bcx.func.dfg.value_type(arg); + if !ty.is_int() { + // FIXME set %al to upperbound on float args once floats are supported + unimpl!("Non int ty {:?} for variadic call", ty); + } + AbiParam::new(ty) + }).collect::>(); + fx.bcx.func.dfg.signatures[sig_ref].params = abi_params; + } + match output_pass_mode { PassMode::NoPass => {} PassMode::ByVal(_) => { diff --git a/src/base.rs b/src/base.rs index 94598c65672ac..d2f31de71d198 100644 --- a/src/base.rs +++ b/src/base.rs @@ -65,7 +65,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( let mir = tcx.instance_mir(instance.def); // Step 2. Declare function - let (name, sig) = get_function_name_and_sig(tcx, instance); + let (name, sig) = get_function_name_and_sig(tcx, instance, false); let func_id = cx.module .declare_function(&name, linkage, &sig) .unwrap(); diff --git a/src/main_shim.rs b/src/main_shim.rs index 446089fc9a161..20d792912961c 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -53,8 +53,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( let instance = Instance::mono(tcx, rust_main_def_id); - let (main_name, main_sig) = get_function_name_and_sig(tcx, instance); - + let (main_name, main_sig) = get_function_name_and_sig(tcx, instance, false); let main_func_id = m .declare_function(&main_name, Linkage::Import, &main_sig) .unwrap(); From 223611dcb24a361d642244af8966a868ca952df3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Feb 2019 19:40:07 +0100 Subject: [PATCH 0512/1566] Fix and enable libstd building --- build_sysroot/Cargo.toml | 1 + example/std_example.rs | 9 +++++++ .../0011-Workaround-for-libstd-crash.patch | 25 +++++++++++++++++++ test.sh | 9 +++++-- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 example/std_example.rs create mode 100644 patches/0011-Workaround-for-libstd-crash.patch diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 725c0b40d89b9..3ba06fcb0f613 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -7,6 +7,7 @@ version = "0.0.0" core = { path = "./sysroot_src/src/libcore" } compiler_builtins = "0.1" alloc = { path = "./sysroot_src/src/liballoc" } +std = { path = "./sysroot_src/src/libstd" } alloc_system = { path = "./alloc_system" } diff --git a/example/std_example.rs b/example/std_example.rs new file mode 100644 index 0000000000000..dceb68bcdf475 --- /dev/null +++ b/example/std_example.rs @@ -0,0 +1,9 @@ +use std::io::Write; + +fn main() { + let _ = ::std::iter::repeat('a' as u8).take(10).collect::>(); + let stderr = ::std::io::stderr(); + let mut stderr = stderr.lock(); + + writeln!(stderr, "some {} text", "").unwrap(); +} diff --git a/patches/0011-Workaround-for-libstd-crash.patch b/patches/0011-Workaround-for-libstd-crash.patch new file mode 100644 index 0000000000000..46712718decfa --- /dev/null +++ b/patches/0011-Workaround-for-libstd-crash.patch @@ -0,0 +1,25 @@ +From 2bc2ef06e118c6fba0626c0e9bf24fed873405b2 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 29 Dec 2018 12:37:34 +0100 +Subject: [PATCH] Workaround for libstd crash + +I think this is related to the use of TLS inside those functions +--- + src/libstd/rt.rs | 2 +- + 1 file changed, 1 insertions(+), 1 deletions(-) + +diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs +index 5ddb66b..6a0d0b5 100644 +--- a/src/libstd/rt.rs ++++ b/src/libstd/rt.rs +@@ -51,7 +51,7 @@ fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe), + #[cfg(not(feature = "backtrace"))] + let exit_code = panic::catch_unwind(move || main()); + +- sys_common::cleanup(); ++ //sys_common::cleanup(); + exit_code.unwrap_or(101) as isize + } + } +-- +2.17.2 (Apple Git-113) diff --git a/test.sh b/test.sh index 8cc4b0ff817ac..8cc5b2d186ecc 100755 --- a/test.sh +++ b/test.sh @@ -24,11 +24,16 @@ echo "[BUILD+RUN] alloc_example" $RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin ./target/out/alloc_example +echo "[BUILD+RUN] std_example" +$RUSTC --sysroot ./build_sysroot/sysroot example/std_example.rs --crate-type bin +./target/out/std_example + echo "[BUILD] mod_bench" $RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -echo "[BUILD] sysroot in release mode" -./build_sysroot/build_sysroot.sh --release +# FIXME linker gives multiple definitions error on Linux +#echo "[BUILD] sysroot in release mode" +#./build_sysroot/build_sysroot.sh --release COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" From 130fbe2574d7ed33b9077dd0a9f84727ba054726 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Feb 2019 08:24:32 +0100 Subject: [PATCH 0513/1566] *const char -> *const i8 --- example/mini_core.rs | 2 +- example/mini_core_hello_world.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 4da661ebb8d86..66314ab3e5d3e 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -338,7 +338,7 @@ pub mod libc { #[link(name = "c")] extern "C" { pub fn puts(s: *const u8); - pub fn printf(format: *const char, ...) -> i32; + pub fn printf(format: *const i8, ...) -> i32; pub fn malloc(size: usize) -> *mut u8; pub fn free(ptr: *mut u8); pub fn memcpy(dst: *mut u8, src: *const u8, size: usize); diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 17c64ffe09fc5..871aebddee9c7 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -121,7 +121,7 @@ fn main() { //return; unsafe { - printf("Hello %s\n\0" as *const str as *const char, "printf\0" as *const str as *const char); + printf("Hello %s\n\0" as *const str as *const i8, "printf\0" as *const str as *const i8); let hello: &[u8] = b"Hello\0" as &[u8; 6]; let ptr: *const u8 = hello as *const [u8] as *const u8; From b05c4572572fb9eee1d0c54a7a0ed604ac39ed7b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 13 Feb 2019 14:32:30 +0100 Subject: [PATCH 0514/1566] Use correct alignment for CValue::ByRef for a ZST --- src/abi.rs | 4 ++-- src/common.rs | 4 ++-- src/constant.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index aa85349b9b8c3..97f539d3a68cf 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -285,7 +285,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { CValue::ByVal(val, return_layout) } else { - CValue::ByRef(self.bcx.ins().iconst(self.pointer_type, 0), return_layout) + CValue::ByRef(self.bcx.ins().iconst(self.pointer_type, self.pointer_type.bytes() as i64), return_layout) } } @@ -608,7 +608,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( PassMode::NoPass => None, PassMode::ByRef => match ret_place { Some(ret_place) => Some(ret_place.to_addr(fx)), - None => Some(fx.bcx.ins().iconst(fx.pointer_type, 0)), + None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), }, PassMode::ByVal(_) => None, }; diff --git a/src/common.rs b/src/common.rs index 9723072364bd5..00d5aab1722a6 100644 --- a/src/common.rs +++ b/src/common.rs @@ -285,7 +285,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CValue::ByRef(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), layout) } CPlace::NoPlace(layout) => { - CValue::ByRef(fx.bcx.ins().iconst(fx.pointer_type, 0), layout) + CValue::ByRef(fx.bcx.ins().iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), layout) } } } @@ -306,7 +306,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Stack(stack_slot, _layout) => { (fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None) } - CPlace::NoPlace(_) => (fx.bcx.ins().iconst(fx.pointer_type, 0), None), + CPlace::NoPlace(_) => (fx.bcx.ins().iconst(fx.pointer_type, 45), None), CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } diff --git a/src/constant.rs b/src/constant.rs index d5d850c7b089c..8f05df353c9e7 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -112,7 +112,7 @@ fn trans_const_value<'a, 'tcx: 'a>( } ty::FnDef(_def_id, _substs) => { CValue::ByRef( - fx.bcx.ins().iconst(fx.pointer_type, 0), + fx.bcx.ins().iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), layout ) } From 444fdf150f6a00a35bc3ebc27fc9e98841e0174d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 13 Feb 2019 14:55:09 +0100 Subject: [PATCH 0515/1566] Rustup to rustc 1.34.0-nightly (b244f61b7 2019-02-12) --- ...002-Disable-u128-and-i128-in-libcore.patch | 66 +++---- ...ng-saturating_-add-sub-intrinsic-imp.patch | 166 ++++++++++++++++++ ...issing-saturating_sub-intrinsic-impl.patch | 82 --------- 3 files changed, 199 insertions(+), 115 deletions(-) create mode 100644 patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch delete mode 100644 patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 16dcacacb4857..ab41edd6ed52b 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From d723688cb9f94c7c90617eb96b1d64fd968a02c3 Mon Sep 17 00:00:00 2001 +From 1119ae3f160d7e89064583f1d9d6685bc2e6928b Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 2 Feb 2019 11:30:28 +0100 +Date: Wed, 13 Feb 2019 14:37:22 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -44,7 +44,7 @@ index ed90b7d..1739f91 100644 bool char } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index d43a5c1..268e5f1 100644 +index 81fcdee..749134c 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -876,7 +876,7 @@ mod impls { @@ -75,7 +75,7 @@ index d43a5c1..268e5f1 100644 #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { diff --git a/src/libcore/default.rs b/src/libcore/default.rs -index 0e47c2f..570b949 100644 +index 5ad05b3..1b5a1d1 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -135,14 +135,12 @@ default_impl! { u8, 0, "Returns the default value of `0`" } @@ -193,7 +193,7 @@ index d5d29c9..f98f382 100644 #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index 66c09a0..1b8c5c9 100644 +index a3e9cfa..31b6ca4 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -173,7 +173,6 @@ step_impl_signed!([i64: u64]); @@ -218,10 +218,10 @@ index dfe1d2a..06cc578 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 97b07aa..9e1e9a6 100644 +index 9b37104..787b10b 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -149,14 +149,12 @@ mod uint_macros; +@@ -147,14 +147,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -252,10 +252,10 @@ index 457d556..91425fb 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 8b6d9d8..8023dc1 100644 +index 2a493e8..a7dba54 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs -@@ -163,12 +163,10 @@ pub fn forget_unsized(t: T) { +@@ -164,12 +164,10 @@ pub fn forget_unsized(t: T) { /// u16 | 2 /// u32 | 4 /// u64 | 8 @@ -269,7 +269,7 @@ index 8b6d9d8..8023dc1 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index f80f839..eed1241 100644 +index 6fb67ea..6440490 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -102,13 +102,11 @@ nonzero_integers! { @@ -286,7 +286,7 @@ index f80f839..eed1241 100644 #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); } -@@ -2084,18 +2082,6 @@ impl i64 { +@@ -2124,18 +2122,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -305,7 +305,7 @@ index f80f839..eed1241 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4336,17 +4322,6 @@ impl u64 { +@@ -4411,17 +4397,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -323,7 +323,7 @@ index f80f839..eed1241 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4430,7 +4405,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4505,7 +4480,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -332,7 +332,7 @@ index f80f839..eed1241 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4546,30 +4521,25 @@ macro_rules! rev { +@@ -4621,30 +4596,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -367,7 +367,7 @@ index f80f839..eed1241 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4581,21 +4551,21 @@ mod ptr_try_from_impls { +@@ -4656,21 +4626,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -397,7 +397,7 @@ index f80f839..eed1241 100644 } #[cfg(target_pointer_width = "32")] -@@ -4604,24 +4574,24 @@ mod ptr_try_from_impls { +@@ -4679,24 +4649,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -430,7 +430,7 @@ index f80f839..eed1241 100644 } #[cfg(target_pointer_width = "64")] -@@ -4630,24 +4600,20 @@ mod ptr_try_from_impls { +@@ -4705,24 +4675,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -459,7 +459,7 @@ index f80f839..eed1241 100644 } #[doc(hidden)] -@@ -4682,7 +4648,7 @@ macro_rules! doit { +@@ -4757,7 +4723,7 @@ macro_rules! doit { } })*) } @@ -468,7 +468,7 @@ index f80f839..eed1241 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4873,52 +4839,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4948,52 +4914,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -597,7 +597,7 @@ index 50e189c..2da3b35 100644 pub use self::platform::usize; } diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs -index 7d8bf18..91fd879 100644 +index 0252ede..cb8ab3d 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -104,7 +104,7 @@ macro_rules! add_impl { @@ -886,10 +886,10 @@ index 8c5dde7..8122120 100644 macro_rules! ptr_width { () => { 2 } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index 0fa9974..75b44b1 100644 +index 51a6017..e6631db 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs -@@ -215,8 +215,6 @@ fn test_iterator_step_by_nth_overflow() { +@@ -217,8 +217,6 @@ fn test_iterator_step_by_nth_overflow() { type Bigger = u32; #[cfg(target_pointer_width = "32")] type Bigger = u64; @@ -898,7 +898,7 @@ index 0fa9974..75b44b1 100644 #[derive(Clone)] struct Test(Bigger); -@@ -1969,19 +1967,6 @@ fn test_step_replace_signed() { +@@ -1977,19 +1975,6 @@ fn test_step_replace_signed() { } #[test] @@ -919,10 +919,10 @@ index 0fa9974..75b44b1 100644 let f = &|acc, x| i32::checked_add(2*acc, x); assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs -index a17c094..3c36d10 100644 +index ab638e0..4a2aa4c 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs -@@ -178,12 +178,10 @@ test_impl_from! { test_boolu8, bool, u8 } +@@ -180,12 +180,10 @@ test_impl_from! { test_boolu8, bool, u8 } test_impl_from! { test_boolu16, bool, u16 } test_impl_from! { test_boolu32, bool, u32 } test_impl_from! { test_boolu64, bool, u64 } @@ -935,7 +935,7 @@ index a17c094..3c36d10 100644 // Signed -> Float test_impl_from! { test_i8f32, i8, f32 } -@@ -265,51 +263,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } +@@ -267,51 +265,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } test_impl_try_from_always_ok! { test_try_u8u16, u8, u16 } test_impl_try_from_always_ok! { test_try_u8u32, u8, u32 } test_impl_try_from_always_ok! { test_try_u8u64, u8, u64 } @@ -988,7 +988,7 @@ index a17c094..3c36d10 100644 test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index a751965..5d162cb 100644 +index ac7e117..0dfd856 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -21,7 +21,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; @@ -1091,7 +1091,7 @@ index a751965..5d162cb 100644 - } - } - -- /// Multiply `Duration` by `f64`. +- /// Multiplies `Duration` by `f64`. - /// - /// # Panics - /// This method will panic if result is not finite, negative or overflows `Duration`. @@ -1136,10 +1136,10 @@ index a751965..5d162cb 100644 /// /// # Examples diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index f269fda..07c3680 100644 +index 3c358dc..2dd5699 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -397,8 +397,6 @@ pub use core::i16; +@@ -395,8 +395,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -1148,7 +1148,7 @@ index f269fda..07c3680 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -431,8 +429,6 @@ pub use alloc_crate::string; +@@ -429,8 +427,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -1158,10 +1158,10 @@ index f269fda..07c3680 100644 pub use core::hint; diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index f45cd8b..cf5ba85 100644 +index d19cc48..aeae69a 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs -@@ -1381,26 +1381,6 @@ impl FromInner for Ipv6Addr { +@@ -1380,26 +1380,6 @@ impl FromInner for Ipv6Addr { } } diff --git a/patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch b/patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch new file mode 100644 index 0000000000000..9d6221b426ba2 --- /dev/null +++ b/patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch @@ -0,0 +1,166 @@ +From a84d00b816c1b771f3990ad5f7ba78981ab9c151 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Wed, 13 Feb 2019 14:54:20 +0100 +Subject: [PATCH] Workaround missing saturating_{add,sub} intrinsic impl + +--- + src/libcore/num/mod.rs | 94 -------------------------------------------------- + 1 file changed, 94 deletions(-) + +diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs +index 4871b2e..5d5cd61 100644 +--- a/src/libcore/num/mod.rs ++++ b/src/libcore/num/mod.rs +@@ -880,7 +880,6 @@ $EndFeature, " + ```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] +- #[cfg(stage0)] + pub fn saturating_add(self, rhs: Self) -> Self { + match self.checked_add(rhs) { + Some(x) => x, +@@ -892,30 +891,6 @@ $EndFeature, " + } + + doc_comment! { +- concat!("Saturating integer addition. Computes `self + rhs`, saturating at the numeric +-bounds instead of overflowing. +- +-# Examples +- +-Basic usage: +- +-``` +-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); +-assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT), +-"::max_value());", +-$EndFeature, " +-```"), +- +- #[stable(feature = "rust1", since = "1.0.0")] +- #[rustc_const_unstable(feature = "const_saturating_int_methods")] +- #[inline] +- #[cfg(not(stage0))] +- pub const fn saturating_add(self, rhs: Self) -> Self { +- intrinsics::saturating_add(self, rhs) +- } +- } +- +- doc_comment! { + concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the + numeric bounds instead of overflowing. + +@@ -931,7 +906,6 @@ $EndFeature, " + ```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] +- #[cfg(stage0)] + pub fn saturating_sub(self, rhs: Self) -> Self { + match self.checked_sub(rhs) { + Some(x) => x, +@@ -942,29 +916,6 @@ $EndFeature, " + } + + doc_comment! { +- concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the +-numeric bounds instead of overflowing. +- +-# Examples +- +-Basic usage: +- +-``` +-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27); +-assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT), +-"::min_value());", +-$EndFeature, " +-```"), +- #[stable(feature = "rust1", since = "1.0.0")] +- #[rustc_const_unstable(feature = "const_saturating_int_methods")] +- #[inline] +- #[cfg(not(stage0))] +- pub const fn saturating_sub(self, rhs: Self) -> Self { +- intrinsics::saturating_sub(self, rhs) +- } +- } +- +- doc_comment! { + concat!("Saturating integer multiplication. Computes `self * rhs`, saturating at the + numeric bounds instead of overflowing. + +@@ -2779,7 +2730,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " + ```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] +- #[cfg(stage0)] + pub fn saturating_add(self, rhs: Self) -> Self { + match self.checked_add(rhs) { + Some(x) => x, +@@ -2789,28 +2739,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " + } + + doc_comment! { +- concat!("Saturating integer addition. Computes `self + rhs`, saturating at +-the numeric bounds instead of overflowing. +- +-# Examples +- +-Basic usage: +- +-``` +-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); +-assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " +-```"), +- +- #[stable(feature = "rust1", since = "1.0.0")] +- #[rustc_const_unstable(feature = "const_saturating_int_methods")] +- #[inline] +- #[cfg(not(stage0))] +- pub const fn saturating_add(self, rhs: Self) -> Self { +- intrinsics::saturating_add(self, rhs) +- } +- } +- +- doc_comment! { + concat!("Saturating integer subtraction. Computes `self - rhs`, saturating + at the numeric bounds instead of overflowing. + +@@ -2824,7 +2752,6 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " + ```"), + #[stable(feature = "rust1", since = "1.0.0")] + #[inline] +- #[cfg(stage0)] + pub fn saturating_sub(self, rhs: Self) -> Self { + match self.checked_sub(rhs) { + Some(x) => x, +@@ -2834,27 +2761,6 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " + } + + doc_comment! { +- concat!("Saturating integer subtraction. Computes `self - rhs`, saturating +-at the numeric bounds instead of overflowing. +- +-# Examples +- +-Basic usage: +- +-``` +-", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(27), 73); +-assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " +-```"), +- #[stable(feature = "rust1", since = "1.0.0")] +- #[rustc_const_unstable(feature = "const_saturating_int_methods")] +- #[inline] +- #[cfg(not(stage0))] +- pub const fn saturating_sub(self, rhs: Self) -> Self { +- intrinsics::saturating_sub(self, rhs) +- } +- } +- +- doc_comment! { + concat!("Saturating integer multiplication. Computes `self * rhs`, + saturating at the numeric bounds instead of overflowing. + +-- +2.11.0 + diff --git a/patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch b/patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch deleted file mode 100644 index 36b8f071aea69..0000000000000 --- a/patches/0009-Workaround-missing-saturating_sub-intrinsic-impl.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 725a1e7b487e32b5f2e90049c8b37fed1a957003 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 2 Feb 2019 11:39:22 +0100 -Subject: [PATCH] Workaround missing saturating_sub intrinsic impl - ---- - src/libcore/num/mod.rs | 20 -------------------- - 1 file changed, 20 deletions(-) - -diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index eed1241..f928d40 100644 ---- a/src/libcore/num/mod.rs -+++ b/src/libcore/num/mod.rs -@@ -881,16 +881,11 @@ $EndFeature, " - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn saturating_add(self, rhs: Self) -> Self { -- #[cfg(stage0)] - match self.checked_add(rhs) { - Some(x) => x, - None if rhs >= 0 => Self::max_value(), - None => Self::min_value(), - } -- #[cfg(not(stage0))] -- { -- intrinsics::saturating_add(self, rhs) -- } - } - } - -@@ -911,16 +906,11 @@ $EndFeature, " - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn saturating_sub(self, rhs: Self) -> Self { -- #[cfg(stage0)] - match self.checked_sub(rhs) { - Some(x) => x, - None if rhs >= 0 => Self::min_value(), - None => Self::max_value(), - } -- #[cfg(not(stage0))] -- { -- intrinsics::saturating_sub(self, rhs) -- } - } - } - -@@ -2740,15 +2730,10 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn saturating_add(self, rhs: Self) -> Self { -- #[cfg(stage0)] - match self.checked_add(rhs) { - Some(x) => x, - None => Self::max_value(), - } -- #[cfg(not(stage0))] -- { -- intrinsics::saturating_add(self, rhs) -- } - } - } - -@@ -2767,15 +2752,10 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub fn saturating_sub(self, rhs: Self) -> Self { -- #[cfg(stage0)] - match self.checked_sub(rhs) { - Some(x) => x, - None => Self::min_value(), - } -- #[cfg(not(stage0))] -- { -- intrinsics::saturating_sub(self, rhs) -- } - } - } - --- -2.11.0 - From cbf09a98642bf07b7453afa1996c4bacf7adf407 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 13 Feb 2019 16:59:20 +0000 Subject: [PATCH 0516/1566] Bump cranelift from `4d92022` to `2145dd3` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `4d92022` to `2145dd3`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/4d92022a0b1b0bef82a933057005f598d6e48bfc...2145dd3ffaedaea4db1bc4f238550beae3f0492e) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a12bb2f63dc35..28a0e914b851d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#4d92022a0b1b0bef82a933057005f598d6e48bfc" +source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", From 408f27badeb210f9cd824b98627c9b0ced73ed0b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 12:21:22 +0100 Subject: [PATCH 0517/1566] Libstd and varargs are now supported. --- Readme.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Readme.md b/Readme.md index 230a08191ff5b..e6b6f68bfac1b 100644 --- a/Readme.md +++ b/Readme.md @@ -32,8 +32,6 @@ $ RUSTFLAGS="-Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_ * Good non-rust abi support ([scalar pair and vector are passed by-ref](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) * Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) * Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444)) -* Varargs ([no cranelift support](https://github.com/CraneStation/cranelift/issues/212)) -* libstd (needs varargs and some other stuff) ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/146)) * u128 and i128 ([no cranelift support](https://github.com/CraneStation/cranelift/issues/354)) * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171)) @@ -42,7 +40,3 @@ $ RUSTFLAGS="-Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_ ### Can't compile Try updating your nightly compiler. You can try to use an nightly a day or two older if updating rustc doesn't fix it. If you still can't compile it, please fill an issue. - -### error[E0463]: can't find crate for `std` while compiling a no_std crate - -If you use `RUSTFLAGS` to pass `-Zcodegen-backend` to rustc, cargo will compile `build-dependencies` with those flags too. Because this project doesn't support libstd yet, that will result in an error. I don't know of any way to fix this. :( From 06dd020446f690b21683f93edd3124d7ef0c07c1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 12:35:45 +0100 Subject: [PATCH 0518/1566] Rustup to rustc 1.34.0-nightly (a9410cd1a 2019-02-15) --- ...002-Disable-u128-and-i128-in-libcore.patch | 78 +++++++++-------- src/base.rs | 85 ++++++++++--------- src/constant.rs | 8 +- src/link.rs | 23 ++++- src/link_copied.rs | 10 +-- 5 files changed, 108 insertions(+), 96 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index ab41edd6ed52b..0d1507d9eff1a 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,32 +1,32 @@ -From 1119ae3f160d7e89064583f1d9d6685bc2e6928b Mon Sep 17 00:00:00 2001 +From 8080d322c8396b7b234cc92eb675f697c55f7298 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Wed, 13 Feb 2019 14:37:22 +0100 +Date: Sat, 16 Feb 2019 12:09:42 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- src/libcore/clone.rs | 4 +- src/libcore/cmp.rs | 6 +- src/libcore/default.rs | 2 - - src/libcore/fmt/num.rs | 6 +- - src/libcore/hash/mod.rs | 20 ------- + src/libcore/fmt/num.rs | 8 +- + src/libcore/hash/mod.rs | 20 ----- src/libcore/iter/range.rs | 1 - src/libcore/iter/traits/accum.rs | 2 +- src/libcore/lib.rs | 2 - src/libcore/marker.rs | 4 +- src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 100 +++++++++---------------------- - src/libcore/num/wrapping.rs | 14 ++--- - src/libcore/ops/arith.rs | 22 +++---- - src/libcore/ops/bit.rs | 30 ++++------ - src/libcore/sync/atomic.rs | 30 ---------- - src/libcore/tests/iter.rs | 15 ----- - src/libcore/tests/num/mod.rs | 18 ------ - src/libcore/time.rs | 123 --------------------------------------- - src/libstd/lib.rs | 4 -- - src/libstd/net/ip.rs | 20 ------- + src/libcore/num/mod.rs | 100 +++++++------------------ + src/libcore/num/wrapping.rs | 14 ++-- + src/libcore/ops/arith.rs | 22 +++--- + src/libcore/ops/bit.rs | 30 +++----- + src/libcore/sync/atomic.rs | 30 -------- + src/libcore/tests/iter.rs | 15 ---- + src/libcore/tests/num/mod.rs | 18 ----- + src/libcore/time.rs | 123 ------------------------------- + src/libstd/lib.rs | 4 - + src/libstd/net/ip.rs | 20 ----- src/libstd/num.rs | 2 +- src/libstd/panic.rs | 6 -- - 22 files changed, 63 insertions(+), 370 deletions(-) + 22 files changed, 63 insertions(+), 372 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index ed90b7d..1739f91 100644 @@ -94,7 +94,7 @@ index 5ad05b3..1b5a1d1 100644 default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs -index 3a81233..f889d57 100644 +index b9fa364..cd9ee01 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -17,7 +17,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + @@ -117,22 +117,21 @@ index 3a81233..f889d57 100644 /// A type that represents a specific radix #[doc(hidden)] -@@ -176,7 +174,6 @@ integer! { i8, u8 } +@@ -176,8 +174,6 @@ integer! { i8, u8 } integer! { i16, u16 } integer! { i32, u32 } integer! { i64, u64 } -integer! { i128, u128 } +- - const DEC_DIGITS_LUT: &'static[u8] = + static DEC_DIGITS_LUT: &[u8; 200] = b"0001020304050607080910111213141516171819\ -@@ -252,7 +249,6 @@ macro_rules! impl_Display { - - impl_Display!(i8, u8, i16, u16, i32, u32: to_u32); - impl_Display!(i64, u64: to_u64); --impl_Display!(i128, u128: to_u128); - #[cfg(target_pointer_width = "16")] - impl_Display!(isize, usize: to_u16); - #[cfg(target_pointer_width = "32")] +@@ -274,5 +270,3 @@ mod imp { + impl_Display!(i8, u8, i16, u16, i32, u32, isize, usize as u32 via to_u32 named fmt_u32); + impl_Display!(i64, u64 as u64 via to_u64 named fmt_u64); + } +- +-impl_Display!(i128, u128 as u128 via to_u128 named fmt_u128); diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index d5d29c9..f98f382 100644 --- a/src/libcore/hash/mod.rs @@ -218,10 +217,10 @@ index dfe1d2a..06cc578 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 9b37104..787b10b 100644 +index cd88d3e..532d680 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -147,14 +147,12 @@ mod uint_macros; +@@ -148,14 +148,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -237,7 +236,7 @@ index 9b37104..787b10b 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 457d556..91425fb 100644 +index c4b41f1..0ade53b 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -664,8 +664,8 @@ mod copy_impls { @@ -252,7 +251,7 @@ index 457d556..91425fb 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 2a493e8..a7dba54 100644 +index 3f7455a..7a0c44a 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -164,12 +164,10 @@ pub fn forget_unsized(t: T) { @@ -898,10 +897,11 @@ index 51a6017..e6631db 100644 #[derive(Clone)] struct Test(Bigger); -@@ -1977,19 +1975,6 @@ fn test_step_replace_signed() { +@@ -1976,19 +1974,6 @@ fn test_step_replace_signed() { + assert_eq!(y, 5); } - #[test] +-#[test] -fn test_step_replace_no_between() { - let mut x = 4u128; - let y = x.replace_zero(); @@ -914,10 +914,9 @@ index 51a6017..e6631db 100644 - assert_eq!(y, 5); -} - --#[test] + #[test] fn test_rev_try_folds() { let f = &|acc, x| i32::checked_add(2*acc, x); - assert_eq!((1..10).rev().try_fold(7, f), (1..10).try_rfold(7, f)); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index ab638e0..4a2aa4c 100644 --- a/src/libcore/tests/num/mod.rs @@ -1136,10 +1135,10 @@ index ac7e117..0dfd856 100644 /// /// # Examples diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 3c358dc..2dd5699 100644 +index 9a4232d..592fea0 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -395,8 +395,6 @@ pub use core::i16; +@@ -392,8 +392,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -1148,7 +1147,7 @@ index 3c358dc..2dd5699 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -429,8 +427,6 @@ pub use alloc_crate::string; +@@ -426,8 +424,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -1202,7 +1201,7 @@ index c80b9a5..e32a6b3 100644 #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs -index d27f6ca..8ac2a44 100644 +index 862fdf0..171ebeb 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -254,9 +254,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} @@ -1226,5 +1225,4 @@ index d27f6ca..8ac2a44 100644 #[cfg(target_has_atomic = "8")] #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] -- -2.11.0 - +2.17.2 (Apple Git-113) diff --git a/src/base.rs b/src/base.rs index d2f31de71d198..844c2479fd5f8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -392,6 +392,7 @@ fn trans_stmt<'a, 'tcx: 'a>( ty::Float(_) => trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), ty::Char => trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), ty::RawPtr(..) => trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), + ty::FnPtr(..) => trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), _ => unimplemented!("binop {:?} for {:?}", bin_op, ty), }; lval.write_cvalue(fx, res); @@ -992,49 +993,49 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( rhs: CValue<'tcx>, ret_ty: Ty<'tcx>, ) -> CValue<'tcx> { - match lhs.layout().ty.sty { - ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { - if ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { - binop_match! { - fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) iadd; - } - } else { - let lhs = lhs.load_value_pair(fx).0; - let rhs = rhs.load_value_pair(fx).0; - let res = match bin_op { - BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs), - BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs), - _ => unimplemented!( - "trans_ptr_binop({:?}, , ) not implemented", - bin_op - ), - }; - - assert_eq!(fx.tcx.types.bool, ret_ty); - let ret_layout = fx.layout_of(ret_ty); - CValue::ByVal(fx.bcx.ins().bint(types::I8, res), ret_layout) - } - } + let not_fat = match lhs.layout().ty.sty { + ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()), + ty::FnPtr(..) => true, _ => bug!("trans_ptr_binop on non ptr"), + }; + if not_fat { + binop_match! { + fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) iadd; + } + } else { + let lhs = lhs.load_value_pair(fx).0; + let rhs = rhs.load_value_pair(fx).0; + let res = match bin_op { + BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs), + BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs), + _ => unimplemented!( + "trans_ptr_binop({:?}, , ) not implemented", + bin_op + ), + }; + + assert_eq!(fx.tcx.types.bool, ret_ty); + let ret_layout = fx.layout_of(ret_ty); + CValue::ByVal(fx.bcx.ins().bint(types::I8, res), ret_layout) } } diff --git a/src/constant.rs b/src/constant.rs index 8f05df353c9e7..29c5a0f38e455 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::{Const, LazyConst}; use rustc_mir::interpret::{ - EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, + EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, ImmTy, }; use cranelift_module::*; @@ -337,10 +337,8 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { fn ptr_op( _: &EvalContext<'a, 'mir, 'tcx, Self>, _: mir::BinOp, - _: Scalar, - _: TyLayout<'tcx>, - _: Scalar, - _: TyLayout<'tcx>, + _: ImmTy<'tcx>, + _: ImmTy<'tcx>, ) -> EvalResult<'tcx, (Scalar, bool)> { panic!(); } diff --git a/src/link.rs b/src/link.rs index b600413fad232..ca349de4848d9 100644 --- a/src/link.rs +++ b/src/link.rs @@ -291,7 +291,7 @@ fn link_args(cmd: &mut dyn Linker, codegen_results: &CodegenResults) { // Linker plugins should be specified early in the list of arguments - cmd.cross_lang_lto(); + cmd.linker_plugin_lto(); // The default library location, we need this to find the runtime. // The location of crates will be determined as needed. @@ -306,6 +306,13 @@ fn link_args(cmd: &mut dyn Linker, } cmd.output_filename(out_filename); + if crate_type == config::CrateType::Executable && + sess.target.target.options.is_like_windows { + if let Some(ref s) = codegen_results.windows_subsystem { + cmd.subsystem(s); + } + } + // If we're building a dynamic library then some platforms need to make sure // that all symbols are exported correctly from the dynamic library. if crate_type != config::CrateType::Executable || @@ -313,6 +320,16 @@ fn link_args(cmd: &mut dyn Linker, cmd.export_symbols(tmpdir, crate_type); } + // When linking a dynamic library, we put the metadata into a section of the + // executable. This metadata is in a separate object file from the main + // object file, so we link that in here. + if crate_type == config::CrateType::Dylib || + crate_type == config::CrateType::ProcMacro { + if let Some(obj) = codegen_results.metadata_module.object.as_ref() { + cmd.add_object(obj); + } + } + let obj = codegen_results.allocator_module .as_ref() .and_then(|m| m.object.as_ref()); @@ -409,7 +426,7 @@ fn link_args(cmd: &mut dyn Linker, // // The rationale behind this ordering is that those items lower down in the // list can't depend on items higher up in the list. For example nothing can - // depend on what we just generated (e.g. that'd be a circular dependency). + // depend on what we just generated (e.g., that'd be a circular dependency). // Upstream rust libraries are not allowed to depend on our local native // libraries as that would violate the structure of the DAG, in that // scenario they are required to link to them as well in a shared fashion. @@ -418,7 +435,7 @@ fn link_args(cmd: &mut dyn Linker, // well, but they also can't depend on what we just started to add to the // link line. And finally upstream native libraries can't depend on anything // in this DAG so far because they're only dylibs and dylibs can only depend - // on other dylibs (e.g. other native deps). + // on other dylibs (e.g., other native deps). add_local_native_libraries(cmd, sess, codegen_results); add_upstream_rust_crates(cmd, sess, codegen_results, crate_type, tmpdir); add_upstream_native_libraries(cmd, sess, codegen_results, crate_type); diff --git a/src/link_copied.rs b/src/link_copied.rs index c19a6eec7391d..517455e927522 100644 --- a/src/link_copied.rs +++ b/src/link_copied.rs @@ -177,8 +177,7 @@ pub fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdi // ensure the line is interpreted as one whole argument. for c in self.arg.chars() { match c { - '\\' | - ' ' => write!(f, "\\{}", c)?, + '\\' | ' ' => write!(f, "\\{}", c)?, c => write!(f, "{}", c)?, } } @@ -298,7 +297,7 @@ pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, // compiler-builtins are always placed last to ensure that they're // linked correctly. // We must always link the `compiler_builtins` crate statically. Even if it - // was already "included" in a dylib (e.g. `libstd` when `-C prefer-dynamic` + // was already "included" in a dylib (e.g., `libstd` when `-C prefer-dynamic` // is used) if let Some(cnum) = compiler_builtins { add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); @@ -345,7 +344,6 @@ pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, for f in archive.src_files() { if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { archive.remove_file(&f); - continue } } @@ -479,7 +477,7 @@ pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, // because a `dylib` can be reused as an intermediate artifact. // // Note, though, that we don't want to include the whole of a - // compiler-builtins crate (e.g. compiler-rt) because it'll get + // compiler-builtins crate (e.g., compiler-rt) because it'll get // repeatedly linked anyway. if crate_type == config::CrateType::Dylib && codegen_results.crate_info.compiler_builtins != Some(cnum) { @@ -628,7 +626,7 @@ fn are_upstream_rust_objects_already_included(sess: &Session) -> bool { Lto::Thin => { // If we defer LTO to the linker, we haven't run LTO ourselves, so // any upstream object files have not been copied yet. - !sess.opts.debugging_opts.cross_lang_lto.enabled() + !sess.opts.cg.linker_plugin_lto.enabled() } Lto::No | Lto::ThinLocal => false, From 6acfee8978e47aa21e7c816550db4c4507444c75 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 12:37:33 +0100 Subject: [PATCH 0519/1566] Remove unnecessary stuff from patch 0002-Disable-u128-and-i128-in-libcore --- ...002-Disable-u128-and-i128-in-libcore.patch | 104 ------------------ 1 file changed, 104 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 0d1507d9eff1a..468f9f9d00cd8 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -19,8 +19,6 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/ops/arith.rs | 22 +++--- src/libcore/ops/bit.rs | 30 +++----- src/libcore/sync/atomic.rs | 30 -------- - src/libcore/tests/iter.rs | 15 ---- - src/libcore/tests/num/mod.rs | 18 ----- src/libcore/time.rs | 123 ------------------------------- src/libstd/lib.rs | 4 - src/libstd/net/ip.rs | 20 ----- @@ -884,108 +882,6 @@ index 8c5dde7..8122120 100644 #[cfg(target_pointer_width = "16")] macro_rules! ptr_width { () => { 2 } -diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index 51a6017..e6631db 100644 ---- a/src/libcore/tests/iter.rs -+++ b/src/libcore/tests/iter.rs -@@ -217,8 +217,6 @@ fn test_iterator_step_by_nth_overflow() { - type Bigger = u32; - #[cfg(target_pointer_width = "32")] - type Bigger = u64; -- #[cfg(target_pointer_width = "64")] -- type Bigger = u128; - - #[derive(Clone)] - struct Test(Bigger); -@@ -1976,19 +1974,6 @@ fn test_step_replace_signed() { - assert_eq!(y, 5); - } - --#[test] --fn test_step_replace_no_between() { -- let mut x = 4u128; -- let y = x.replace_zero(); -- assert_eq!(x, 0); -- assert_eq!(y, 4); -- -- x = 5; -- let y = x.replace_one(); -- assert_eq!(x, 1); -- assert_eq!(y, 5); --} -- - #[test] - fn test_rev_try_folds() { - let f = &|acc, x| i32::checked_add(2*acc, x); -diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs -index ab638e0..4a2aa4c 100644 ---- a/src/libcore/tests/num/mod.rs -+++ b/src/libcore/tests/num/mod.rs -@@ -180,12 +180,10 @@ test_impl_from! { test_boolu8, bool, u8 } - test_impl_from! { test_boolu16, bool, u16 } - test_impl_from! { test_boolu32, bool, u32 } - test_impl_from! { test_boolu64, bool, u64 } --test_impl_from! { test_boolu128, bool, u128 } - test_impl_from! { test_booli8, bool, i8 } - test_impl_from! { test_booli16, bool, i16 } - test_impl_from! { test_booli32, bool, i32 } - test_impl_from! { test_booli64, bool, i64 } --test_impl_from! { test_booli128, bool, i128 } - - // Signed -> Float - test_impl_from! { test_i8f32, i8, f32 } -@@ -267,51 +265,35 @@ test_impl_try_from_always_ok! { test_try_u8u8, u8, u8 } - test_impl_try_from_always_ok! { test_try_u8u16, u8, u16 } - test_impl_try_from_always_ok! { test_try_u8u32, u8, u32 } - test_impl_try_from_always_ok! { test_try_u8u64, u8, u64 } --test_impl_try_from_always_ok! { test_try_u8u128, u8, u128 } - test_impl_try_from_always_ok! { test_try_u8i16, u8, i16 } - test_impl_try_from_always_ok! { test_try_u8i32, u8, i32 } - test_impl_try_from_always_ok! { test_try_u8i64, u8, i64 } --test_impl_try_from_always_ok! { test_try_u8i128, u8, i128 } - - test_impl_try_from_always_ok! { test_try_u16u16, u16, u16 } - test_impl_try_from_always_ok! { test_try_u16u32, u16, u32 } - test_impl_try_from_always_ok! { test_try_u16u64, u16, u64 } --test_impl_try_from_always_ok! { test_try_u16u128, u16, u128 } - test_impl_try_from_always_ok! { test_try_u16i32, u16, i32 } - test_impl_try_from_always_ok! { test_try_u16i64, u16, i64 } --test_impl_try_from_always_ok! { test_try_u16i128, u16, i128 } - - test_impl_try_from_always_ok! { test_try_u32u32, u32, u32 } - test_impl_try_from_always_ok! { test_try_u32u64, u32, u64 } --test_impl_try_from_always_ok! { test_try_u32u128, u32, u128 } - test_impl_try_from_always_ok! { test_try_u32i64, u32, i64 } --test_impl_try_from_always_ok! { test_try_u32i128, u32, i128 } - - test_impl_try_from_always_ok! { test_try_u64u64, u64, u64 } --test_impl_try_from_always_ok! { test_try_u64u128, u64, u128 } --test_impl_try_from_always_ok! { test_try_u64i128, u64, i128 } -- --test_impl_try_from_always_ok! { test_try_u128u128, u128, u128 } - - test_impl_try_from_always_ok! { test_try_i8i8, i8, i8 } - test_impl_try_from_always_ok! { test_try_i8i16, i8, i16 } - test_impl_try_from_always_ok! { test_try_i8i32, i8, i32 } - test_impl_try_from_always_ok! { test_try_i8i64, i8, i64 } --test_impl_try_from_always_ok! { test_try_i8i128, i8, i128 } - - test_impl_try_from_always_ok! { test_try_i16i16, i16, i16 } - test_impl_try_from_always_ok! { test_try_i16i32, i16, i32 } - test_impl_try_from_always_ok! { test_try_i16i64, i16, i64 } --test_impl_try_from_always_ok! { test_try_i16i128, i16, i128 } - - test_impl_try_from_always_ok! { test_try_i32i32, i32, i32 } - test_impl_try_from_always_ok! { test_try_i32i64, i32, i64 } --test_impl_try_from_always_ok! { test_try_i32i128, i32, i128 } - - test_impl_try_from_always_ok! { test_try_i64i64, i64, i64 } --test_impl_try_from_always_ok! { test_try_i64i128, i64, i128 } -- --test_impl_try_from_always_ok! { test_try_i128i128, i128, i128 } - - test_impl_try_from_always_ok! { test_try_usizeusize, usize, usize } - test_impl_try_from_always_ok! { test_try_isizeisize, isize, isize } diff --git a/src/libcore/time.rs b/src/libcore/time.rs index ac7e117..0dfd856 100644 --- a/src/libcore/time.rs From 4c94251f95206e0361a829fb424a5d9d8c724e11 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 13:49:42 +0100 Subject: [PATCH 0520/1566] Several fixes --- src/base.rs | 16 ++++++++++++---- src/intrinsics.rs | 19 +++++++++++-------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/base.rs b/src/base.rs index 844c2479fd5f8..684e5acdbc2ef 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1022,11 +1022,19 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( Offset (_) iadd; } } else { - let lhs = lhs.load_value_pair(fx).0; - let rhs = rhs.load_value_pair(fx).0; + let (lhs_ptr, lhs_extra) = lhs.load_value_pair(fx); + let (rhs_ptr, rhs_extra) = rhs.load_value_pair(fx); let res = match bin_op { - BinOp::Eq => fx.bcx.ins().icmp(IntCC::Equal, lhs, rhs), - BinOp::Ne => fx.bcx.ins().icmp(IntCC::NotEqual, lhs, rhs), + BinOp::Eq => { + let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); + let extra_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_extra, rhs_extra); + fx.bcx.ins().band(ptr_eq, extra_eq) + } + BinOp::Ne => { + let ptr_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_ptr, rhs_ptr); + let extra_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_extra, rhs_extra); + fx.bcx.ins().bor(ptr_ne, extra_ne) + } _ => unimplemented!( "trans_ptr_binop({:?}, , ) not implemented", bin_op diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 22302c0b6a262..3eaa7c06a767f 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -119,11 +119,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx, intrinsic, substs, args, assume, (c _a) {}; - arith_offset, (v base, v offset) { - let res = fx.bcx.ins().iadd(base, offset); - let res = CValue::ByVal(res, ret.layout()); - ret.write_cvalue(fx, res); - }; likely | unlikely, (c a) { ret.write_cvalue(fx, a); }; @@ -289,7 +284,10 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let res = fx.bcx.ins().rotr(x, y); ret.write_cvalue(fx, CValue::ByVal(res, layout)); }; - offset, (c base, v offset) { + + // The only difference between offset and arith_offset is regarding UB. Because Cranelift + // doesn't have UB both are codegen'ed the same way + offset | arith_offset, (c base, v offset) { let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; let pointee_size = fx.layout_of(pointee_ty).size.bytes(); let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); @@ -297,6 +295,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let res = fx.bcx.ins().iadd(base_val, ptr_diff); ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); }; + transmute, (c from) { assert_eq!(from.layout().ty, src_ty); let addr = from.force_stack(fx); @@ -314,8 +313,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let inited_val = inited_place.to_cvalue(fx); ret.write_cvalue(fx, inited_val); }; - write_bytes, (v dst, v val, v count) { - fx.bcx.call_memset(fx.module.target_config(), dst, val, count); + write_bytes, (c dst, v val, v count) { + let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty; + let pointee_size = fx.layout_of(pointee_ty).size.bytes(); + let count = fx.bcx.ins().imul_imm(count, pointee_size as i64); + let dst_ptr = dst.load_scalar(fx); + fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); }; uninit, () { let uninit_place = CPlace::new_stack_slot(fx, T); From 5721542164389b66830c2497a582c1589abf70dd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 14:02:15 +0100 Subject: [PATCH 0521/1566] Fix BinOp::Offset fixes #341 --- example/std_example.rs | 2 ++ src/base.rs | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/example/std_example.rs b/example/std_example.rs index dceb68bcdf475..2f1fba590fdb4 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -6,4 +6,6 @@ fn main() { let mut stderr = stderr.lock(); writeln!(stderr, "some {} text", "").unwrap(); + + std::process::Command::new("true").env("c", "d").spawn(); } diff --git a/src/base.rs b/src/base.rs index 684e5acdbc2ef..f4766a1fc64a8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -999,6 +999,16 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( _ => bug!("trans_ptr_binop on non ptr"), }; if not_fat { + if let BinOp::Offset = bin_op { + let (base, offset) = (lhs, rhs.load_scalar(fx)); + let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; + let pointee_size = fx.layout_of(pointee_ty).size.bytes(); + let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); + let base_val = base.load_scalar(fx); + let res = fx.bcx.ins().iadd(base_val, ptr_diff); + return CValue::ByVal(res, base.layout()); + } + binop_match! { fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; Add (_) bug; @@ -1019,7 +1029,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( Ge (_) icmp(UnsignedGreaterThanOrEqual); Gt (_) icmp(UnsignedGreaterThan); - Offset (_) iadd; + Offset (_) bug; // Handled above } } else { let (lhs_ptr, lhs_extra) = lhs.load_value_pair(fx); From 26289edf1a167a465a424fbf9e97be31a908ff26 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 15:42:20 +0100 Subject: [PATCH 0522/1566] Fix cttz{,_nonzero} intrinsics --- example/std_example.rs | 6 +++++- src/intrinsics.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 2f1fba590fdb4..fcc4ed3aa804b 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,3 +1,5 @@ +#![feature(core_intrinsics)] + use std::io::Write; fn main() { @@ -7,5 +9,7 @@ fn main() { writeln!(stderr, "some {} text", "").unwrap(); - std::process::Command::new("true").env("c", "d").spawn(); + let _ = std::process::Command::new("true").env("c", "d").spawn(); + + println!("cargo:rustc-link-lib=z"); } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 3eaa7c06a767f..624a929326bdd 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -330,7 +330,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, res); }; cttz | cttz_nonzero, (v arg) { - let res = CValue::ByVal(fx.bcx.ins().clz(arg), fx.layout_of(T)); + let res = CValue::ByVal(fx.bcx.ins().ctz(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; ctpop, (v arg) { From de94b62ba4e27dc0798dbf787a04ed61f0791552 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 16:24:03 +0100 Subject: [PATCH 0523/1566] Fix atomic_xchg* intrinsics --- example/std_example.rs | 3 +++ src/intrinsics.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/example/std_example.rs b/example/std_example.rs index fcc4ed3aa804b..cd0a88c85fc92 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -12,4 +12,7 @@ fn main() { let _ = std::process::Command::new("true").env("c", "d").spawn(); println!("cargo:rustc-link-lib=z"); + + static ONCE: std::sync::Once = std::sync::ONCE_INIT; + ONCE.call_once(|| {}); } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 624a929326bdd..18c261c990334 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -386,7 +386,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // Compare let is_eq = fx.bcx.ins().icmp(IntCC::Equal, old, test_old); - let new = crate::common::codegen_select(&mut fx.bcx, is_eq, old, new); // Keep old if not equal to test_old + let new = crate::common::codegen_select(&mut fx.bcx, is_eq, new, old); // Keep old if not equal to test_old // Write new fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); From 4ecbee2f091cb22ebf191950cc15094a993605df Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 16:24:38 +0100 Subject: [PATCH 0524/1566] Implement float -> int/uint cast --- src/base.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/base.rs b/src/base.rs index f4766a1fc64a8..dfa5827e03ffd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -518,6 +518,18 @@ fn trans_stmt<'a, 'tcx: 'a>( }; lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } + (ty::Float(_), ty::Int(_)) => { + let from = operand.load_scalar(fx); + let i_type = fx.clif_type(to_ty).unwrap(); + let res = fx.bcx.ins().fcvt_to_sint_sat(i_type, from); + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } + (ty::Float(_), ty::Uint(_)) => { + let from = operand.load_scalar(fx); + let i_type = fx.clif_type(to_ty).unwrap(); + let res = fx.bcx.ins().fcvt_to_uint_sat(i_type, from); + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } (ty::Int(_), ty::Float(_)) => { let from_ty = fx.clif_type(from_ty).unwrap(); let from = operand.load_scalar(fx); From ccf07adbfb51cd1d98c3ab70488bb6a880ba63e2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 16:37:30 +0100 Subject: [PATCH 0525/1566] Implement isize -> raw-ptr cast --- src/base.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/base.rs b/src/base.rs index dfa5827e03ffd..556e01aa3a219 100644 --- a/src/base.rs +++ b/src/base.rs @@ -482,6 +482,9 @@ fn trans_stmt<'a, 'tcx: 'a>( (ty::Uint(_), ty::RawPtr(..)) if from_ty.sty == fx.tcx.types.usize.sty => { lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } + (ty::Int(_), ty::RawPtr(..)) if from_ty.sty == fx.tcx.types.isize.sty => { + lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); + } (ty::Char, ty::Uint(_)) | (ty::Uint(_), ty::Char) | (ty::Uint(_), ty::Int(_)) From bab8113954bd24e63a1e51f00088d761560ddd98 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Feb 2019 17:18:38 +0100 Subject: [PATCH 0526/1566] Fix discriminant_value intrinsic Fixes #349 --- example/std_example.rs | 8 ++++++++ src/base.rs | 12 +++++++----- src/intrinsics.rs | 4 +++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index cd0a88c85fc92..ce74efee8a884 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -15,4 +15,12 @@ fn main() { static ONCE: std::sync::Once = std::sync::ONCE_INIT; ONCE.call_once(|| {}); + + LoopState::Continue(()) == LoopState::Break(()); +} + +#[derive(PartialEq)] +enum LoopState { + Continue(()), + Break(()) } diff --git a/src/base.rs b/src/base.rs index 556e01aa3a219..5eb1819e3ccc7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -570,7 +570,9 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } (ty::Adt(adt_def, _substs), ty::Uint(_)) | (ty::Adt(adt_def, _substs), ty::Int(_)) if adt_def.is_enum() => { - let discr = trans_get_discriminant(fx, operand, fx.layout_of(to_ty)); + // FIXME avoid forcing to stack + let place = CPlace::Addr(operand.force_stack(fx), None, operand.layout()); + let discr = trans_get_discriminant(fx, place, fx.layout_of(to_ty)); lval.write_cvalue(fx, discr); } _ => unimpl!("rval misc {:?} {:?}", from_ty, to_ty), @@ -584,7 +586,7 @@ fn trans_stmt<'a, 'tcx: 'a>( operand.unsize_value(fx, lval); } Rvalue::Discriminant(place) => { - let place = trans_place(fx, place).to_cvalue(fx); + let place = trans_place(fx, place); let discr = trans_get_discriminant(fx, place, dest_layout); lval.write_cvalue(fx, discr); } @@ -680,10 +682,10 @@ fn codegen_array_len<'a, 'tcx: 'a>( pub fn trans_get_discriminant<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - value: CValue<'tcx>, + place: CPlace<'tcx>, dest_layout: TyLayout<'tcx>, ) -> CValue<'tcx> { - let layout = value.layout(); + let layout = place.layout(); if layout.abi == layout::Abi::Uninhabited { trap_unreachable(&mut fx.bcx); @@ -701,7 +703,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {} } - let discr = value.value_field(fx, mir::Field::new(0)); + let discr = place.place_field(fx, mir::Field::new(0)).to_cvalue(fx); let discr_ty = discr.layout().ty; let lldiscr = discr.load_scalar(fx); match layout.variants { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 18c261c990334..2068bd9e508e6 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -141,7 +141,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( } }; discriminant_value, (c val) { - let discr = crate::base::trans_get_discriminant(fx, val, ret.layout()); + let pointee_layout = fx.layout_of(val.layout().ty.builtin_deref(true).unwrap().ty); + let place = CPlace::Addr(val.load_scalar(fx), None, pointee_layout); + let discr = crate::base::trans_get_discriminant(fx, place, ret.layout()); ret.write_cvalue(fx, discr); }; size_of, () { From 13c20fc8033b3925abee3743f76f3679547ee413 Mon Sep 17 00:00:00 2001 From: Milkey Mouse Date: Sun, 17 Feb 2019 17:42:12 -0800 Subject: [PATCH 0527/1566] Don't sign commits from patches in sysroot This is really annoying when commit.gpgSign is enabled globally. --- build_sysroot/prepare_sysroot_src.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_sysroot/prepare_sysroot_src.sh b/build_sysroot/prepare_sysroot_src.sh index fceccdb4deaa6..c96c3b36ba203 100755 --- a/build_sysroot/prepare_sysroot_src.sh +++ b/build_sysroot/prepare_sysroot_src.sh @@ -24,7 +24,7 @@ git commit -m "Initial commit" -q for file in $(ls ../../patches/ | grep -v patcha); do echo "[GIT] apply" $file git apply ../../patches/$file -git commit -am "Patch $file" +git commit --no-gpg-sign -am "Patch $file" done popd From b8164a073c24a901b46d18c00e91a2f3f811130d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 18 Feb 2019 08:42:23 +0000 Subject: [PATCH 0528/1566] Bump serde from 1.0.87 to 1.0.88 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.87 to 1.0.88. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.87...v1.0.88) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28a0e914b851d..7fa4e0ad65579 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -661,7 +661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -671,7 +671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -684,7 +684,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -932,7 +932,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)" = "2e20fde37801e83c891a2dc4ebd3b81f0da4d1fb67a9e0a2a3b921e2536a58ee" +"checksum serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "9f301d728f2b94c9a7691c90f07b0b4e8a4517181d9461be94c04bddeb4bd850" "checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" From edb6488bcb12fbef5f2b47eb790f79b9d46ea685 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 18 Feb 2019 08:42:27 +0000 Subject: [PATCH 0529/1566] Bump tempfile from 3.0.5 to 3.0.7 Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.0.5 to 3.0.7. - [Release notes](https://github.com/Stebalien/tempfile/releases) - [Changelog](https://github.com/Stebalien/tempfile/blob/master/NEWS) - [Commits](https://github.com/Stebalien/tempfile/compare/v3.0.5...v3.0.7) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28a0e914b851d..668e4a4f863b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -611,7 +611,7 @@ dependencies = [ "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -745,7 +745,7 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.0.5" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -942,7 +942,7 @@ dependencies = [ "checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" -"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2" +"checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" diff --git a/Cargo.toml b/Cargo.toml index 75f12add11900..64dfa96d3ac1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.7" libc = "0.2.45" -tempfile = "3.0.4" +tempfile = "3.0.7" env_logger = "0.6" gimli = { git = "https://github.com/gimli-rs/gimli.git" } faerie = "0.7.1" From beef28b44c895c7239b9f89918072d6c43d55373 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 18 Feb 2019 08:42:31 +0000 Subject: [PATCH 0530/1566] Bump aho-corasick from 0.6.9 to 0.6.10 Bumps [aho-corasick](https://github.com/BurntSushi/aho-corasick) from 0.6.9 to 0.6.10. - [Release notes](https://github.com/BurntSushi/aho-corasick/releases) - [Commits](https://github.com/BurntSushi/aho-corasick/compare/0.6.9...0.6.10) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28a0e914b851d..d0d315f4abaed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ # It is not intended for manual editing. [[package]] name = "aho-corasick" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -555,7 +555,7 @@ name = "regex" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -857,7 +857,7 @@ dependencies = [ ] [metadata] -"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e" +"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" From 33df91bccd014cb7a365632bd714d2394371971b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 18 Feb 2019 14:29:00 +0000 Subject: [PATCH 0531/1566] Bump memchr from 2.1.3 to 2.2.0 Bumps [memchr](https://github.com/BurntSushi/rust-memchr) from 2.1.3 to 2.2.0. - [Release notes](https://github.com/BurntSushi/rust-memchr/releases) - [Commits](https://github.com/BurntSushi/rust-memchr/compare/2.1.3...2.2.0) Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abb3fda94f8e6..f5107c50f8a52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,7 +5,7 @@ name = "aho-corasick" version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -385,12 +385,8 @@ dependencies = [ [[package]] name = "memchr" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "nodrop" @@ -556,7 +552,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -901,7 +897,7 @@ dependencies = [ "checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum memchr 2.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e1dd4eaac298c32ce07eb6ed9242eda7d82955b9170b7d6db59b2e02cc63fcb8" +"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" From ea10842d95ff3b080c26a02bf8626d9d0956481b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Feb 2019 18:26:59 +0100 Subject: [PATCH 0532/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- src/base.rs | 15 ++++++++------- src/debuginfo.rs | 29 +++++++++++------------------ 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2402cec1f2b23..23bb51844f5bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2145dd3ffaedaea4db1bc4f238550beae3f0492e" +source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/src/base.rs b/src/base.rs index 5eb1819e3ccc7..f76b3cd8593d0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -127,13 +127,14 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 9. Define function cx.caches.context.func = func; - cx.module - .define_function_peek_compiled(func_id, &mut cx.caches.context, |size, context, isa| { - debug_context.as_mut().map(|x| x.define(tcx, size, context, isa, &source_info_set)); - }) - .unwrap(); - //let module = &mut cx.module; - //let caches = &cx.caches; + cx.module.define_function(func_id, &mut cx.caches.context).unwrap(); + + // Step 10. Define debuginfo for function + let context = &cx.caches.context; + let isa = cx.module.isa(); + debug_context.as_mut().map(|x| x.define(tcx, context, isa, &source_info_set)); + + // Step 11. Clear context to make it usable for the next function cx.caches.context.clear(); } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 70622d4bd4957..9fab9c612e1b4 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -264,23 +264,10 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { pub fn define( &mut self, tcx: TyCtxt, - //module: &mut Module, - code_size: u32, context: &Context, isa: &cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet, ) { - let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(code_size as u64)); - - self.debug_context.unit_range_list.0.push(Range::StartLength { - begin: Address::Relative { - symbol: self.symbol, - addend: 0, - }, - length: code_size as u64, - }); - let line_program = &mut self.debug_context.dwarf.unit.line_program; line_program.begin_sequence(Some(Address::Relative { @@ -327,12 +314,18 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { } } - if code_size != end { - line_program.row().address_offset = end as u64; - create_row_for_span(line_program, self.mir_span); - } + line_program.end_sequence(end as u64); + + let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); + entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64)); - line_program.end_sequence(code_size as u64); + self.debug_context.unit_range_list.0.push(Range::StartLength { + begin: Address::Relative { + symbol: self.symbol, + addend: 0, + }, + length: end as u64, + }); } } From b7f2a722c92d92902eaa4d136e35500d797f10a7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Feb 2019 18:32:40 +0100 Subject: [PATCH 0533/1566] Update gimli --- Cargo.lock | 2 +- src/debuginfo.rs | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23bb51844f5bf..4de759e55a897 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#1278ccb7b6eaa8eea3b9c082f18a282d3c48703b" +source = "git+https://github.com/gimli-rs/gimli.git#8f47f3183d4125673b2c7f06833cf3e9e847ddd0" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 9fab9c612e1b4..bb350cc988afd 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -1,5 +1,3 @@ -extern crate gimli; - use crate::prelude::*; use std::marker::PhantomData; @@ -11,7 +9,7 @@ use gimli::write::{ RangeList, Result, SectionId, UnitEntryId, Writer, FileId, LineStringTable, LineString, Sections, }; -use gimli::{Encoding, Format, RunTimeEndian}; +use gimli::{Encoding, Format, RunTimeEndian, LineEncoding}; use faerie::*; @@ -106,10 +104,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let line_program = LineProgram::new( encoding, - 1, - 1, - -5, - 14, + LineEncoding::default(), LineString::new(comp_dir.as_bytes(), encoding, &mut dwarf.line_strings), LineString::new(name.as_bytes(), encoding, &mut dwarf.line_strings), None, @@ -160,7 +155,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let entry = self.dwarf.unit.get_mut(entry_id); - entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(file_id)); + entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id))); entry.set( gimli::DW_AT_decl_line, AttributeValue::Udata(loc.line as u64), From b4eff78a9e86de492544e38c8f2267e4d11eb837 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Feb 2019 18:53:18 +0100 Subject: [PATCH 0534/1566] Pass command-line arguments to JITed function Cherry-picked from f1f35405e15ca1b77425514b04b96b2749231899 by @milkey-mouse --- example/mini_core.rs | 17 +++++++++++++++++ example/mini_core_hello_world.rs | 10 ++++++++-- src/lib.rs | 23 ++++++++++++++++------- test.sh | 4 ++-- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 66314ab3e5d3e..b7277f5ee9f48 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -104,6 +104,14 @@ impl Mul for u8 { } } +impl Mul for usize { + type Output = Self; + + fn mul(self, rhs: Self) -> Self::Output { + self * rhs + } +} + #[lang = "add"] pub trait Add { type Output; @@ -208,6 +216,15 @@ impl PartialEq for usize { } } +impl PartialEq for isize { + fn eq(&self, other: &isize) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &isize) -> bool { + (*self) != (*other) + } +} + impl PartialEq for char { fn eq(&self, other: &char) -> bool { (*self) == (*other) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 871aebddee9c7..5ab7575252b07 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -75,9 +75,15 @@ enum Ordering { #[lang = "start"] fn start( main: fn() -> T, - _argc: isize, - _argv: *const *const u8, + argc: isize, + argv: *const *const u8, ) -> isize { + if argc == 3 { + unsafe { puts(*argv); } + unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const u8)); } + unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const u8)); } + } + main().report(); 0 } diff --git a/src/lib.rs b/src/lib.rs index 5863f730bcace..ead24921652d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,8 @@ extern crate syntax; use std::any::Any; use std::fs::File; use std::sync::mpsc; +use std::os::raw::{c_char, c_int}; +use std::ffi::CString; use rustc::dep_graph::DepGraph; use rustc::middle::cstore::MetadataLoader; @@ -241,19 +243,26 @@ impl CodegenBackend for CraneliftCodegenBackend { jit_module.finalize_definitions(); tcx.sess.abort_if_errors(); - println!("Compiled everything"); - println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); - println!("🎉 Finalized everything"); - let f: extern "C" fn(isize, *const *const u8) -> isize = + println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); + + let f: extern "C" fn(c_int, *const *const c_char) -> c_int = unsafe { ::std::mem::transmute(finalized_main) }; - let res = f(0, 0 as *const _); - tcx.sess.warn(&format!("🚀 main returned {}", res)); + + let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_|String::new()); + let args = args + .split(" ") + .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) + .map(|arg| CString::new(arg).unwrap()).collect::>(); + let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); + // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end + + let ret = f(args.len() as c_int, argv.as_ptr()); jit_module.finish(); - ::std::process::exit(0); + std::process::exit(ret); } else { let new_module = |name: String| { let module: Module = Module::new( diff --git a/test.sh b/test.sh index 8cc5b2d186ecc..0ea592778181a 100755 --- a/test.sh +++ b/test.sh @@ -11,11 +11,11 @@ echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib echo "[JIT] mini_core_hello_world" -SHOULD_RUN=1 $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit +SHOULD_RUN=1 JIT_ARGS="abc bcd" $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -sh -c ./target/out/mini_core_hello_world +./target/out/mini_core_hello_world abc bcd echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh From a7f4dc8b1d88ff2600cd4add93ac434d1adc14d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 20 Feb 2019 07:06:56 +0000 Subject: [PATCH 0535/1566] Bump gimli from `8f47f31` to `e2529c0` Bumps [gimli](https://github.com/gimli-rs/gimli) from `8f47f31` to `e2529c0`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/8f47f3183d4125673b2c7f06833cf3e9e847ddd0...e2529c0bf06b4197df3ddbc76bda5adf2cc0659f) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 4de759e55a897..23c575686685b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#8f47f3183d4125673b2c7f06833cf3e9e847ddd0" +source = "git+https://github.com/gimli-rs/gimli.git#e2529c0bf06b4197df3ddbc76bda5adf2cc0659f" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From a58fb2fd29e378c83d14954a26b570334314f0da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 20 Feb 2019 07:06:59 +0000 Subject: [PATCH 0536/1566] Bump backtrace from 0.3.13 to 0.3.14 Bumps [backtrace](https://github.com/alexcrichton/backtrace-rs) from 0.3.13 to 0.3.14. - [Release notes](https://github.com/alexcrichton/backtrace-rs/releases) - [Commits](https://github.com/alexcrichton/backtrace-rs/compare/0.3.13...0.3.14) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4de759e55a897..81abc3c6ac9bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,7 +49,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -279,7 +279,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -859,7 +859,7 @@ dependencies = [ "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" +"checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" From cffa1b07317987bca552c2f2ea453fec2005c586 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 20 Feb 2019 07:07:22 +0000 Subject: [PATCH 0537/1566] Bump cranelift from `50c66ae` to `2f61600` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `50c66ae` to `2f61600`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/50c66ae4788ff9a1715f220d2331df575017fa17...2f61600a4f45d1624e85ddbace5b33c74017719f) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4de759e55a897..21b8a2ed49efa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#50c66ae4788ff9a1715f220d2331df575017fa17" +source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", From f02490d960ecff8fc17272453f4eb8a6837b5a18 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 21 Feb 2019 15:06:09 +0100 Subject: [PATCH 0538/1566] Rustfmt --- src/abi.rs | 167 +++++++++++++++++++++++++++++++-------------- src/allocator.rs | 12 ++-- src/base.rs | 50 ++++++++------ src/common.rs | 65 ++++++++++-------- src/constant.rs | 17 ++--- src/debuginfo.rs | 83 ++++++++++++---------- src/lib.rs | 59 +++++++++------- src/pretty_clif.rs | 27 +++++--- src/unsize.rs | 79 ++++++++++++--------- 9 files changed, 340 insertions(+), 219 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 97f539d3a68cf..b4de8aeea1969 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use std::iter; use rustc::hir; -use rustc::ty::layout::{Scalar, Primitive, Integer, FloatTy}; +use rustc::ty::layout::{FloatTy, Integer, Primitive, Scalar}; use rustc_target::spec::abi::Abi; use crate::prelude::*; @@ -32,11 +32,11 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { Integer::I32 => types::I32, Integer::I64 => types::I64, Integer::I128 => unimpl!("u/i128"), - } + }, Primitive::Float(flt) => match flt { FloatTy::F32 => types::F32, FloatTy::F64 => types::F64, - } + }, Primitive::Pointer => pointer_ty(tcx), } } @@ -46,9 +46,7 @@ fn get_pass_mode<'a, 'tcx: 'a>( ty: Ty<'tcx>, is_return: bool, ) -> PassMode { - let layout = tcx - .layout_of(ParamEnv::reveal_all().and(ty)) - .unwrap(); + let layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); assert!(!layout.is_unsized()); if layout.size.bytes() == 0 { @@ -66,7 +64,9 @@ fn get_pass_mode<'a, 'tcx: 'a>( PassMode::ByRef } } - layout::Abi::Scalar(scalar) => PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())), + layout::Abi::Scalar(scalar) => { + PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) + } // FIXME implement ScalarPair and Vector Abi in a cg_llvm compatible way layout::Abi::ScalarPair(_, _) => PassMode::ByRef, @@ -88,10 +88,7 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( } } -fn clif_sig_from_fn_sig<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - sig: FnSig<'tcx>, -) -> Signature { +fn clif_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: FnSig<'tcx>) -> Signature { let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), @@ -191,7 +188,7 @@ pub fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnS pub fn get_function_name_and_sig<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>, - support_vararg: bool + support_vararg: bool, ) -> (String, Signature) { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_ty = inst.ty(tcx); @@ -219,7 +216,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { let func_id = import_function(self.tcx, self.module, inst); - let func_ref = self.module + let func_ref = self + .module .declare_func_in_func(func_id, &mut self.bcx.func); #[cfg(debug_assertions)] @@ -285,7 +283,12 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { CValue::ByVal(val, return_layout) } else { - CValue::ByRef(self.bcx.ins().iconst(self.pointer_type, self.pointer_type.bytes() as i64), return_layout) + CValue::ByRef( + self.bcx + .ins() + .iconst(self.pointer_type, self.pointer_type.bytes() as i64), + return_layout, + ) } } @@ -322,13 +325,21 @@ fn add_arg_comment<'a, 'tcx: 'a>( let pass_mode = format!("{:?}", pass_mode); fx.add_global_comment(format!( "{msg:5} {local:>3}{local_field:<5} {param:10} {pass_mode:20} {ssa:10} {ty:?}", - msg=msg, local=format!("{:?}", local), local_field=local_field, param=param, pass_mode=pass_mode, ssa=format!("{:?}", ssa), ty=ty, + msg = msg, + local = format!("{:?}", local), + local_field = local_field, + param = param, + pass_mode = pass_mode, + ssa = format!("{:?}", ssa), + ty = ty, )); } #[cfg(debug_assertions)] fn add_local_header_comment(fx: &mut FunctionCx) { - fx.add_global_comment(format!("msg loc.idx param pass mode ssa flags ty")); + fx.add_global_comment(format!( + "msg loc.idx param pass mode ssa flags ty" + )); } fn local_place<'a, 'tcx: 'a>( @@ -338,7 +349,8 @@ fn local_place<'a, 'tcx: 'a>( is_ssa: bool, ) -> CPlace<'tcx> { let place = if is_ssa { - fx.bcx.declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); + fx.bcx + .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); CPlace::Var(local, layout) } else { let place = CPlace::new_stack_slot(fx, layout.ty); @@ -346,15 +358,32 @@ fn local_place<'a, 'tcx: 'a>( #[cfg(debug_assertions)] { let TyLayout { ty, details } = layout; - let ty::layout::LayoutDetails { size, align, abi: _, variants: _, fields: _ } = details; + let ty::layout::LayoutDetails { + size, + align, + abi: _, + variants: _, + fields: _, + } = details; match place { - CPlace::Stack(stack_slot, _) => fx.add_entity_comment(stack_slot, format!( - "{:?}: {:?} size={} align={},{}", - local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), - )), + CPlace::Stack(stack_slot, _) => fx.add_entity_comment( + stack_slot, + format!( + "{:?}: {:?} size={} align={},{}", + local, + ty, + size.bytes(), + align.abi.bytes(), + align.pref.bytes(), + ), + ), CPlace::NoPlace(_) => fx.add_global_comment(format!( "zst {:?}: {:?} size={} align={}, {}", - local, ty, size.bytes(), align.abi.bytes(), align.pref.bytes(), + local, + ty, + size.bytes(), + align.abi.bytes(), + align.pref.bytes(), )), _ => unreachable!(), } @@ -383,7 +412,16 @@ fn cvalue_for_param<'a, 'tcx: 'a>( let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); #[cfg(debug_assertions)] - add_arg_comment(fx, "arg", local, local_field, Some(ebb_param), pass_mode, ssa_flags, arg_ty); + add_arg_comment( + fx, + "arg", + local, + local_field, + Some(ebb_param), + pass_mode, + ssa_flags, + arg_ty, + ); match pass_mode { PassMode::NoPass => unimplemented!("pass mode nopass"), @@ -412,7 +450,16 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( #[cfg(debug_assertions)] { add_local_header_comment(fx); - add_arg_comment(fx, "ret", RETURN_PLACE, None, ret_param, output_pass_mode, ssa_analyzed[&RETURN_PLACE], ret_layout.ty); + add_arg_comment( + fx, + "ret", + RETURN_PLACE, + None, + ret_param, + output_pass_mode, + ssa_analyzed[&RETURN_PLACE], + ret_layout.ty, + ); } enum ArgKind<'tcx> { @@ -440,18 +487,22 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( let mut params = Vec::new(); for (i, arg_ty) in tupled_arg_tys.iter().enumerate() { - let param = cvalue_for_param(fx, start_ebb, local, Some(i), arg_ty, ssa_analyzed[&local]); + let param = cvalue_for_param( + fx, + start_ebb, + local, + Some(i), + arg_ty, + ssa_analyzed[&local], + ); params.push(param); } (local, ArgKind::Spread(params), arg_ty) } else { - let param = cvalue_for_param(fx, start_ebb, local, None, arg_ty, ssa_analyzed[&local]); - ( - local, - ArgKind::Normal(param), - arg_ty, - ) + let param = + cvalue_for_param(fx, start_ebb, local, None, arg_ty, ssa_analyzed[&local]); + (local, ArgKind::Normal(param), arg_ty) } }) .collect::>(); @@ -460,7 +511,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( match output_pass_mode { PassMode::NoPass => { - fx.local_map.insert(RETURN_PLACE, CPlace::NoPlace(ret_layout)); + fx.local_map + .insert(RETURN_PLACE, CPlace::NoPlace(ret_layout)); } PassMode::ByVal(_) => { let is_ssa = !ssa_analyzed @@ -494,7 +546,9 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( } ArgKind::Spread(params) => { for (i, param) in params.into_iter().enumerate() { - place.place_field(fx, mir::Field::new(i)).write_cvalue(fx, param); + place + .place_field(fx, mir::Field::new(i)) + .write_cvalue(fx, param); } } } @@ -553,12 +607,8 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( .map(|&(ref place, bb)| (trans_place(fx, place), bb)); if let ty::FnDef(def_id, substs) = fn_ty.sty { - let instance = ty::Instance::resolve( - fx.tcx, - ty::ParamEnv::reveal_all(), - def_id, - substs, - ).unwrap(); + let instance = + ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap(); match instance.def { InstanceDef::Intrinsic(_) => { @@ -637,8 +687,12 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( // Indirect call None => { - let func = trans_operand(fx, func.expect("indirect call without func Operand")).load_scalar(fx); - (Some(func), args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg))) + let func = trans_operand(fx, func.expect("indirect call without func Operand")) + .load_scalar(fx); + ( + Some(func), + args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)), + ) } }; @@ -653,7 +707,9 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( .collect::>(); let call_inst = if let Some(func_ref) = func_ref { - let sig = fx.bcx.import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); + let sig = fx + .bcx + .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); fx.bcx.ins().call_indirect(sig, func_ref, &call_args) } else { let func_ref = fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); @@ -666,14 +722,17 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( unimpl!("Variadic call for non-C abi {:?}", fn_sig.abi); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); - let abi_params = call_args.into_iter().map(|arg| { - let ty = fx.bcx.func.dfg.value_type(arg); - if !ty.is_int() { - // FIXME set %al to upperbound on float args once floats are supported - unimpl!("Non int ty {:?} for variadic call", ty); - } - AbiParam::new(ty) - }).collect::>(); + let abi_params = call_args + .into_iter() + .map(|arg| { + let ty = fx.bcx.func.dfg.value_type(arg); + if !ty.is_int() { + // FIXME set %al to upperbound on float args once floats are supported + unimpl!("Non int ty {:?} for variadic call", ty); + } + AbiParam::new(ty) + }) + .collect::>(); fx.bcx.func.dfg.signatures[sig_ref].params = abi_params; } @@ -700,11 +759,13 @@ pub fn codegen_drop<'a, 'tcx: 'a>( let fn_sig = ty_fn_sig(fx.tcx, drop_fn_ty); match get_pass_mode(fx.tcx, fn_sig.output(), true) { - PassMode::NoPass => {}, + PassMode::NoPass => {} _ => unreachable!(), }; - let sig = fx.bcx.import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); + let sig = fx + .bcx + .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); } diff --git a/src/allocator.rs b/src/allocator.rs index 1cc45a7d93bbd..cfc071612e71f 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -15,14 +15,10 @@ use rustc_allocator::{AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created pub fn codegen(sess: &Session, module: &mut Module) -> bool { - let any_dynamic_crate = sess - .dependency_formats - .borrow() - .iter() - .any(|(_, list)| { - use rustc::middle::dependency_format::Linkage; - list.iter().any(|&linkage| linkage == Linkage::Dynamic) - }); + let any_dynamic_crate = sess.dependency_formats.borrow().iter().any(|(_, list)| { + use rustc::middle::dependency_format::Linkage; + list.iter().any(|&linkage| linkage == Linkage::Dynamic) + }); if any_dynamic_crate { false } else if let Some(kind) = *sess.allocator_kind.get() { diff --git a/src/base.rs b/src/base.rs index f76b3cd8593d0..62b0bf1ac0434 100644 --- a/src/base.rs +++ b/src/base.rs @@ -66,16 +66,11 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 2. Declare function let (name, sig) = get_function_name_and_sig(tcx, instance, false); - let func_id = cx.module - .declare_function(&name, linkage, &sig) - .unwrap(); - let mut debug_context = cx.debug_context.as_mut().map(|debug_context| FunctionDebugContext::new( - tcx, - debug_context, - mir, - &name, - &sig, - )); + let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); + let mut debug_context = cx + .debug_context + .as_mut() + .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig)); // Step 3. Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); @@ -127,12 +122,16 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 9. Define function cx.caches.context.func = func; - cx.module.define_function(func_id, &mut cx.caches.context).unwrap(); + cx.module + .define_function(func_id, &mut cx.caches.context) + .unwrap(); // Step 10. Define debuginfo for function let context = &cx.caches.context; let isa = cx.module.isa(); - debug_context.as_mut().map(|x| x.define(tcx, context, isa, &source_info_set)); + debug_context + .as_mut() + .map(|x| x.define(tcx, context, isa, &source_info_set)); // Step 11. Clear context to make it usable for the next function cx.caches.context.clear(); @@ -444,10 +443,14 @@ fn trans_stmt<'a, 'tcx: 'a>( } Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { let layout = fx.layout_of(ty); - match fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)).sty { + match fx + .monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)) + .sty + { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( - Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs) + .unwrap(), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::ByVal(func_addr, layout)); @@ -570,9 +573,13 @@ fn trans_stmt<'a, 'tcx: 'a>( }; lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } - (ty::Adt(adt_def, _substs), ty::Uint(_)) | (ty::Adt(adt_def, _substs), ty::Int(_)) if adt_def.is_enum() => { + (ty::Adt(adt_def, _substs), ty::Uint(_)) + | (ty::Adt(adt_def, _substs), ty::Int(_)) + if adt_def.is_enum() => + { // FIXME avoid forcing to stack - let place = CPlace::Addr(operand.force_stack(fx), None, operand.layout()); + let place = + CPlace::Addr(operand.force_stack(fx), None, operand.layout()); let discr = trans_get_discriminant(fx, place, fx.layout_of(to_ty)); lval.write_cvalue(fx, discr); } @@ -674,9 +681,10 @@ fn codegen_array_len<'a, 'tcx: 'a>( let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } - ty::Slice(_elem_ty) => { - place.to_addr_maybe_unsized(fx).1.expect("Length metadata for slice place") - } + ty::Slice(_elem_ty) => place + .to_addr_maybe_unsized(fx) + .1 + .expect("Length metadata for slice place"), _ => bug!("Rvalue::Len({:?})", place), } } @@ -1012,7 +1020,9 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( ret_ty: Ty<'tcx>, ) -> CValue<'tcx> { let not_fat = match lhs.layout().ty.sty { - ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()), + ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { + ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) + } ty::FnPtr(..) => true, _ => bug!("trans_ptr_binop on non ptr"), }; diff --git a/src/common.rs b/src/common.rs index 00d5aab1722a6..1faa6a8514c94 100644 --- a/src/common.rs +++ b/src/common.rs @@ -246,7 +246,7 @@ pub enum CPlace<'tcx> { Var(Local, TyLayout<'tcx>), Addr(Value, Option, TyLayout<'tcx>), Stack(StackSlot, TyLayout<'tcx>), - NoPlace(TyLayout<'tcx>) + NoPlace(TyLayout<'tcx>), } impl<'a, 'tcx: 'a> CPlace<'tcx> { @@ -255,11 +255,14 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Var(_, layout) | CPlace::Addr(_, _, layout) | CPlace::Stack(_, layout) - | CPlace::NoPlace(layout) => layout, + | CPlace::NoPlace(layout) => layout, } } - pub fn new_stack_slot(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> CPlace<'tcx> { + pub fn new_stack_slot( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ty: Ty<'tcx>, + ) -> CPlace<'tcx> { let layout = fx.layout_of(ty); assert!(!layout.is_unsized()); if layout.size.bytes() == 0 { @@ -281,12 +284,16 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { assert!(extra.is_none(), "unsized values are not yet supported"); CValue::ByRef(addr, layout) } - CPlace::Stack(stack_slot, layout) => { - CValue::ByRef(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), layout) - } - CPlace::NoPlace(layout) => { - CValue::ByRef(fx.bcx.ins().iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), layout) - } + CPlace::Stack(stack_slot, layout) => CValue::ByRef( + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + layout, + ), + CPlace::NoPlace(layout) => CValue::ByRef( + fx.bcx + .ins() + .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), + layout, + ), } } @@ -303,9 +310,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ) -> (Value, Option) { match self { CPlace::Addr(addr, extra, _layout) => (addr, extra), - CPlace::Stack(stack_slot, _layout) => { - (fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None) - } + CPlace::Stack(stack_slot, _layout) => ( + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + None, + ), CPlace::NoPlace(_) => (fx.bcx.ins().iconst(fx.pointer_type, 45), None), CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), } @@ -364,9 +372,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { return; } CPlace::Addr(addr, None, dst_layout) => (addr, dst_layout), - CPlace::Stack(stack_slot, dst_layout) => { - (fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), dst_layout) - } + CPlace::Stack(stack_slot, dst_layout) => ( + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + dst_layout, + ), CPlace::NoPlace(layout) => { assert!(layout.size.bytes() == 0); assert!(from.layout().size.bytes() == 0); @@ -389,7 +398,14 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { let size = dst_layout.size.bytes(); let src_align = src_layout.align.abi.bytes() as u8; let dst_align = dst_layout.align.abi.bytes() as u8; - fx.bcx.emit_small_memcpy(fx.module.target_config(), addr, from, size, dst_align, src_align); + fx.bcx.emit_small_memcpy( + fx.module.target_config(), + addr, + from, + size, + dst_align, + src_align, + ); } } } @@ -419,10 +435,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { ) -> CPlace<'tcx> { let (elem_layout, addr) = match self.layout().ty.sty { ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_addr(fx)), - ty::Slice(elem_ty) => ( - fx.layout_of(elem_ty), - self.to_addr_maybe_unsized(fx).0, - ), + ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_addr_maybe_unsized(fx).0), _ => bug!("place_index({:?})", self.layout().ty), }; @@ -472,9 +485,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match dest.layout().abi { Abi::ScalarPair(ref a, _) => { let dest_addr = dest.to_addr(fx); - fx.bcx - .ins() - .store(MemFlags::new(), value, dest_addr, 0); + fx.bcx.ins().store(MemFlags::new(), value, dest_addr, 0); fx.bcx.ins().store( MemFlags::new(), extra.expect("unsized type without metadata"), @@ -494,12 +505,8 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { assert!(!self.layout().is_unsized()); match self { CPlace::Var(var, _) => CPlace::Var(var, layout), - CPlace::Addr(addr, extra, _) => { - CPlace::Addr(addr, extra, layout) - } - CPlace::Stack(stack_slot, _) => { - CPlace::Stack(stack_slot, layout) - } + CPlace::Addr(addr, extra, _) => CPlace::Addr(addr, extra, layout), + CPlace::Stack(stack_slot, _) => CPlace::Stack(stack_slot, layout), CPlace::NoPlace(_) => { assert!(layout.size.bytes() == 0); CPlace::NoPlace(layout) diff --git a/src/constant.rs b/src/constant.rs index 29c5a0f38e455..0216eb80a53f7 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,8 @@ use rustc::mir::interpret::{ }; use rustc::ty::{Const, LazyConst}; use rustc_mir::interpret::{ - EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, ImmTy, + EvalContext, ImmTy, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, + StackPopCleanup, }; use cranelift_module::*; @@ -110,12 +111,12 @@ fn trans_const_value<'a, 'tcx: 'a>( let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits as i128 as i64) } - ty::FnDef(_def_id, _substs) => { - CValue::ByRef( - fx.bcx.ins().iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), - layout - ) - } + ty::FnDef(_def_id, _substs) => CValue::ByRef( + fx.bcx + .ins() + .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), + layout, + ), _ => trans_const_place(fx, const_).to_cvalue(fx), } } @@ -370,7 +371,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { ptr } - fn stack_push(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx>{ + fn stack_push(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { Ok(()) } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index bb350cc988afd..35b8369d8a5c9 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -5,11 +5,10 @@ use std::marker::PhantomData; use syntax::source_map::FileName; use gimli::write::{ - Address, AttributeValue, DwarfUnit, EndianVec, LineProgram, Range, - RangeList, Result, SectionId, UnitEntryId, - Writer, FileId, LineStringTable, LineString, Sections, + Address, AttributeValue, DwarfUnit, EndianVec, FileId, LineProgram, LineString, + LineStringTable, Range, RangeList, Result, SectionId, Sections, UnitEntryId, Writer, }; -use gimli::{Encoding, Format, RunTimeEndian, LineEncoding}; +use gimli::{Encoding, Format, LineEncoding, RunTimeEndian}; use faerie::*; @@ -22,28 +21,35 @@ fn target_endian(tcx: TyCtxt) -> RunTimeEndian { } } -fn line_program_add_file(line_program: &mut LineProgram, line_strings: &mut LineStringTable, file: &FileName) -> FileId { +fn line_program_add_file( + line_program: &mut LineProgram, + line_strings: &mut LineStringTable, + file: &FileName, +) -> FileId { match file { FileName::Real(path) => { - let dir_name = LineString::new(path.parent().unwrap().to_str().unwrap().as_bytes(), line_program.encoding(), line_strings); - let dir_id = - line_program.add_directory(dir_name); - let file_name = LineString::new(path.file_name().unwrap().to_str().unwrap().as_bytes(), line_program.encoding(), line_strings); - line_program.add_file( - file_name, - dir_id, - None, - ) + let dir_name = LineString::new( + path.parent().unwrap().to_str().unwrap().as_bytes(), + line_program.encoding(), + line_strings, + ); + let dir_id = line_program.add_directory(dir_name); + let file_name = LineString::new( + path.file_name().unwrap().to_str().unwrap().as_bytes(), + line_program.encoding(), + line_strings, + ); + line_program.add_file(file_name, dir_id, None) } // FIXME give more appropriate file names _ => { let dir_id = line_program.default_directory(); - let dummy_file_name = LineString::new(file.to_string().into_bytes(), line_program.encoding(), line_strings); - line_program.add_file( - dummy_file_name, - dir_id, - None, - ) + let dummy_file_name = LineString::new( + file.to_string().into_bytes(), + line_program.encoding(), + line_strings, + ); + line_program.add_file(dummy_file_name, dir_id, None) } } } @@ -133,7 +139,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { ); } - DebugContext { + DebugContext { endian: target_endian(tcx), symbols: indexmap::IndexSet::new(), @@ -155,7 +161,10 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let entry = self.dwarf.unit.get_mut(entry_id); - entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id))); + entry.set( + gimli::DW_AT_decl_file, + AttributeValue::FileIndex(Some(file_id)), + ); entry.set( gimli::DW_AT_decl_line, AttributeValue::Udata(loc.line as u64), @@ -182,11 +191,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { artifact - .declare_with( - id.name(), - Decl::DebugSection, - section.writer.take(), - ) + .declare_with(id.name(), Decl::DebugSection, section.writer.take()) .unwrap(); } Ok(()) @@ -233,7 +238,10 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { // FIXME: add to appropriate scope intead of root let scope = debug_context.dwarf.unit.root(); - let entry_id = debug_context.dwarf.unit.add(scope, gimli::DW_TAG_subprogram); + let entry_id = debug_context + .dwarf + .unit + .add(scope, gimli::DW_TAG_subprogram); let entry = debug_context.dwarf.unit.get_mut(entry_id); let name_id = debug_context.dwarf.strings.add(name); entry.set( @@ -314,13 +322,16 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64)); - self.debug_context.unit_range_list.0.push(Range::StartLength { - begin: Address::Relative { - symbol: self.symbol, - addend: 0, - }, - length: end as u64, - }); + self.debug_context + .unit_range_list + .0 + .push(Range::StartLength { + begin: Address::Relative { + symbol: self.symbol, + addend: 0, + }, + length: end as u64, + }); } } @@ -331,7 +342,7 @@ struct WriterRelocate { } impl WriterRelocate { - fn new(ctx: & DebugContext) -> Self { + fn new(ctx: &DebugContext) -> Self { WriterRelocate { relocs: Vec::new(), writer: EndianVec::new(ctx.endian), diff --git a/src/lib.rs b/src/lib.rs index ead24921652d3..483bcb51c646f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,19 +14,19 @@ extern crate rustc_target; extern crate syntax; use std::any::Any; +use std::ffi::CString; use std::fs::File; -use std::sync::mpsc; use std::os::raw::{c_char, c_int}; -use std::ffi::CString; +use std::sync::mpsc; use rustc::dep_graph::DepGraph; use rustc::middle::cstore::MetadataLoader; +use rustc::mir::mono::{Linkage as RLinkage, Visibility}; use rustc::session::{ config::{DebugInfo, OutputFilenames, OutputType}, CompileIncomplete, }; use rustc::ty::query::Providers; -use rustc::mir::mono::{Linkage as RLinkage, Visibility}; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; use rustc_codegen_utils::codegen_backend::CodegenBackend; @@ -62,7 +62,7 @@ mod prelude { pub use std::collections::{HashMap, HashSet}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; - pub use syntax::source_map::{DUMMY_SP, Span, Pos}; + pub use syntax::source_map::{Pos, Span, DUMMY_SP}; pub use rustc::bug; pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -84,18 +84,17 @@ mod prelude { pub use rustc_mir::monomorphize::{collector, MonoItem}; pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; - pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; pub use rustc_codegen_ssa::traits::*; + pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; pub use cranelift::codegen::ir::{ - condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, StackSlot, SourceLoc, + condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, SourceLoc, StackSlot, }; pub use cranelift::codegen::isa::CallConv; pub use cranelift::codegen::Context; pub use cranelift::prelude::*; pub use cranelift_module::{ - self, Backend, DataContext, DataId, FuncId, FuncOrDataId, Linkage, - Module, + self, Backend, DataContext, DataId, FuncId, FuncOrDataId, Linkage, Module, }; pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; @@ -251,11 +250,12 @@ impl CodegenBackend for CraneliftCodegenBackend { let f: extern "C" fn(c_int, *const *const c_char) -> c_int = unsafe { ::std::mem::transmute(finalized_main) }; - let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_|String::new()); + let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_| String::new()); let args = args .split(" ") .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) - .map(|arg| CString::new(arg).unwrap()).collect::>(); + .map(|arg| CString::new(arg).unwrap()) + .collect::>(); let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end @@ -274,14 +274,14 @@ impl CodegenBackend for CraneliftCodegenBackend { ) .unwrap(), ); - assert_eq!( - pointer_ty(tcx), - module.target_config().pointer_type() - ); + assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); module }; - let emit_module = |name: &str, kind: ModuleKind, mut module: Module, debug: Option| { + let emit_module = |name: &str, + kind: ModuleKind, + mut module: Module, + debug: Option| { module.finalize_definitions(); let mut artifact = module.finish().artifact; @@ -306,9 +306,13 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut faerie_module = new_module("some_file".to_string()); let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None - && !tcx.sess.target.target.options.is_like_osx // macOS debuginfo doesn't work yet (see #303) + // macOS debuginfo doesn't work yet (see #303) + && !tcx.sess.target.target.options.is_like_osx { - let debug = DebugContext::new(tcx, faerie_module.target_config().pointer_type().bytes() as u8); + let debug = DebugContext::new( + tcx, + faerie_module.target_config().pointer_type().bytes() as u8, + ); Some(debug) } else { None @@ -319,14 +323,23 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.abort_if_errors(); let mut allocator_module = new_module("allocator_shim.o".to_string()); - let created_alloc_shim = - crate::allocator::codegen(tcx.sess, &mut allocator_module); + let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), - modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module, debug)], + modules: vec![emit_module( + "dummy_name", + ModuleKind::Regular, + faerie_module, + debug, + )], allocator_module: if created_alloc_shim { - Some(emit_module("allocator_shim", ModuleKind::Allocator, allocator_module, None)) + Some(emit_module( + "allocator_shim", + ModuleKind::Allocator, + allocator_module, + None, + )) } else { None }, @@ -377,7 +390,7 @@ fn build_isa(sess: &Session) -> Box { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); flags_builder.set("probestack_enabled", "false").unwrap(); // ___cranelift_probestack is not provided - flags_builder.set("enable_verifier", if cfg!(debug_assertions) { + flags_builder.set("enable_verifier", if cfg!(debug_assertions) { "true" } else { "false" @@ -438,7 +451,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( (RLinkage::Internal, Visibility::Default) => Linkage::Local, // FIXME this should get external linkage, but hidden visibility, // not internal linkage and default visibility - | (RLinkage::External, Visibility::Hidden) => Linkage::Export, + (RLinkage::External, Visibility::Hidden) => Linkage::Export, _ => panic!("{:?} = {:?} {:?}", mono_item, linkage, vis), }; base::trans_mono_item(&mut cx, mono_item, linkage); diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index a7a9c7a3306bd..aab6e341a09a4 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -70,10 +70,7 @@ pub struct CommentWriter { } impl CommentWriter { - pub fn new<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - instance: Instance<'tcx>, - ) -> Self { + pub fn new<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) -> Self { CommentWriter { global_comments: vec![ format!("symbol {}", tcx.symbol_name(instance).as_str()), @@ -158,7 +155,11 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { self.clif_comments.global_comments.push(comment.into()); } - pub fn add_entity_comment<'s, S: Into>, E: Into>(&mut self, entity: E, comment: S) { + pub fn add_entity_comment<'s, S: Into>, E: Into>( + &mut self, + entity: E, + comment: S, + ) { use std::collections::hash_map::Entry; match self.clif_comments.entity_comments.entry(entity.into()) { Entry::Occupied(mut occ) => { @@ -196,12 +197,18 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { ); let mut clif = String::new(); - ::cranelift::codegen::write::decorate_function(&mut &self.clif_comments, &mut clif, &self.bcx.func, None) - .unwrap(); + ::cranelift::codegen::write::decorate_function( + &mut &self.clif_comments, + &mut clif, + &self.bcx.func, + None, + ) + .unwrap(); match ::std::fs::File::create(clif_file_name) { Ok(mut file) => { - let target_triple: ::target_lexicon::Triple = self.tcx.sess.target.target.llvm_target.parse().unwrap(); + let target_triple: ::target_lexicon::Triple = + self.tcx.sess.target.target.llvm_target.parse().unwrap(); writeln!(file, "test compile").unwrap(); writeln!(file, "set is_pic").unwrap(); writeln!(file, "target {}", target_triple).unwrap(); @@ -209,7 +216,9 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { file.write(clif.as_bytes()).unwrap(); } Err(e) => { - self.tcx.sess.warn(&format!("err opening clif file: {:?}", e)); + self.tcx + .sess + .warn(&format!("err opening clif file: {:?}", e)); } } } diff --git a/src/unsize.rs b/src/unsize.rs index 6837754a55246..09dead7e85e84 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -16,21 +16,22 @@ pub fn unsized_info<'a, 'tcx: 'a>( ) -> Value { let (source, target) = fx.tcx.struct_lockstep_tails(source, target); match (&source.sty, &target.sty) { - (&ty::Array(_, len), &ty::Slice(_)) => { - fx.bcx.ins().iconst(fx.pointer_type, len.unwrap_usize(fx.tcx) as i64) - } + (&ty::Array(_, len), &ty::Slice(_)) => fx + .bcx + .ins() + .iconst(fx.pointer_type, len.unwrap_usize(fx.tcx) as i64), (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker // traits, and hence never actually require an actual // change to the vtable. old_info.expect("unsized_info: missing old info for trait upcast") } - (_, &ty::Dynamic(ref data, ..)) => { - crate::vtable::get_vtable(fx, source, data.principal()) - } - _ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", - source, - target), + (_, &ty::Dynamic(ref data, ..)) => crate::vtable::get_vtable(fx, source, data.principal()), + _ => bug!( + "unsized_info: invalid unsizing {:?} -> {:?}", + source, + target + ), } } @@ -39,15 +40,12 @@ pub fn unsize_thin_ptr<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, src: Value, src_ty: Ty<'tcx>, - dst_ty: Ty<'tcx> + dst_ty: Ty<'tcx>, ) -> (Value, Value) { match (&src_ty.sty, &dst_ty.sty) { - (&ty::Ref(_, a, _), - &ty::Ref(_, b, _)) | - (&ty::Ref(_, a, _), - &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | - (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), - &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { + (&ty::Ref(_, a, _), &ty::Ref(_, b, _)) + | (&ty::Ref(_, a, _), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) + | (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { assert!(!fx.layout_of(a).is_unsized()); (src, unsized_info(fx, a, b, None)) } @@ -88,11 +86,14 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, src: CValue<'tcx>, dst: CPlace<'tcx>, -) { +) { let src_ty = src.layout().ty; let dst_ty = dst.layout().ty; let mut coerce_ptr = || { - let (base, info) = if fx.layout_of(src.layout().ty.builtin_deref(true).unwrap().ty).is_unsized() { + let (base, info) = if fx + .layout_of(src.layout().ty.builtin_deref(true).unwrap().ty) + .is_unsized() + { // fat-ptr to fat-ptr unsize preserves the vtable // i.e., &'a fmt::Debug+Send => &'a fmt::Debug src.load_value_pair(fx) @@ -103,11 +104,9 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a>( dst.write_cvalue(fx, CValue::ByValPair(base, info, dst.layout())); }; match (&src_ty.sty, &dst_ty.sty) { - (&ty::Ref(..), &ty::Ref(..)) | - (&ty::Ref(..), &ty::RawPtr(..)) | - (&ty::RawPtr(..), &ty::RawPtr(..)) => { - coerce_ptr() - } + (&ty::Ref(..), &ty::Ref(..)) + | (&ty::Ref(..), &ty::RawPtr(..)) + | (&ty::RawPtr(..), &ty::RawPtr(..)) => coerce_ptr(), (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); @@ -126,13 +125,14 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a>( } } } - _ => bug!("coerce_unsized_into: invalid coercion {:?} -> {:?}", - src_ty, - dst_ty), + _ => bug!( + "coerce_unsized_into: invalid coercion {:?} -> {:?}", + src_ty, + dst_ty + ), } } - // Adapted from https://github.com/rust-lang/rust/blob/2a663555ddf36f6b041445894a8c175cd1bc718c/src/librustc_codegen_ssa/glue.rs pub fn size_and_align_of_dst<'a, 'tcx: 'a>( @@ -142,8 +142,14 @@ pub fn size_and_align_of_dst<'a, 'tcx: 'a>( ) -> (Value, Value) { let layout = fx.layout_of(ty); if !layout.is_unsized() { - let size = fx.bcx.ins().iconst(fx.pointer_type, layout.size.bytes() as i64); - let align = fx.bcx.ins().iconst(fx.pointer_type, layout.align.abi.bytes() as i64); + let size = fx + .bcx + .ins() + .iconst(fx.pointer_type, layout.size.bytes() as i64); + let align = fx + .bcx + .ins() + .iconst(fx.pointer_type, layout.align.abi.bytes() as i64); return (size, align); } match ty.sty { @@ -158,8 +164,12 @@ pub fn size_and_align_of_dst<'a, 'tcx: 'a>( let unit = layout.field(fx, 0); // The info in this case is the length of the str, so the size is that // times the unit size. - (fx.bcx.ins().imul_imm(info, unit.size.bytes() as i64), - fx.bcx.ins().iconst(fx.pointer_type, unit.align.abi.bytes() as i64)) + ( + fx.bcx.ins().imul_imm(info, unit.size.bytes() as i64), + fx.bcx + .ins() + .iconst(fx.pointer_type, unit.align.abi.bytes() as i64), + ) } _ => { // First get the size of all statically known fields. @@ -196,7 +206,10 @@ pub fn size_and_align_of_dst<'a, 'tcx: 'a>( // Choose max of two known alignments (combined value must // be aligned according to more restrictive of the two). - let cmp = fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, sized_align, unsized_align); + let cmp = fx + .bcx + .ins() + .icmp(IntCC::UnsignedGreaterThan, sized_align, unsized_align); let align = fx.bcx.ins().select(cmp, sized_align, unsized_align); // Issue #27023: must add any necessary padding to `size` @@ -212,7 +225,7 @@ pub fn size_and_align_of_dst<'a, 'tcx: 'a>( let addend = fx.bcx.ins().iadd_imm(align, -1); let add = fx.bcx.ins().iadd(size, addend); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); - let neg = fx.bcx.ins().isub(zero, align); + let neg = fx.bcx.ins().isub(zero, align); let size = fx.bcx.ins().band(add, neg); (size, align) From b77d5b6d1d90e0347cc86b4d9f6b24341288ce51 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 21 Feb 2019 15:12:37 +0100 Subject: [PATCH 0539/1566] Rustup to rustc 1.34.0-nightly (f66e4697a 2019-02-20) --- ...002-Disable-u128-and-i128-in-libcore.patch | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 468f9f9d00cd8..fef4a802c7fa4 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1053,30 +1053,52 @@ index 9a4232d..592fea0 100644 pub use core::hint; diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index d19cc48..aeae69a 100644 +index c856129..2bfe9cb 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs -@@ -1380,26 +1380,6 @@ impl FromInner for Ipv6Addr { +@@ -1391,48 +1391,6 @@ impl FromInner for Ipv6Addr { } } -#[stable(feature = "i128", since = "1.26.0")] -impl From for u128 { +- /// Convert an `Ipv6Addr` into a host byte order `u128`. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::net::Ipv6Addr; +- /// +- /// let addr = Ipv6Addr::new( +- /// 0x1020, 0x3040, 0x5060, 0x7080, +- /// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D, +- /// ); +- /// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr)); +- /// ``` - fn from(ip: Ipv6Addr) -> u128 { -- let ip = ip.segments(); -- ((ip[0] as u128) << 112) + ((ip[1] as u128) << 96) + ((ip[2] as u128) << 80) + -- ((ip[3] as u128) << 64) + ((ip[4] as u128) << 48) + ((ip[5] as u128) << 32) + -- ((ip[6] as u128) << 16) + (ip[7] as u128) +- let ip = ip.octets(); +- u128::from_be_bytes(ip) - } -} -#[stable(feature = "i128", since = "1.26.0")] -impl From for Ipv6Addr { +- /// Convert a host byte order `u128` into an `Ipv6Addr`. +- /// +- /// # Examples +- /// +- /// ``` +- /// use std::net::Ipv6Addr; +- /// +- /// let addr = Ipv6Addr::from(0x102030405060708090A0B0C0D0E0F00D_u128); +- /// assert_eq!( +- /// Ipv6Addr::new( +- /// 0x1020, 0x3040, 0x5060, 0x7080, +- /// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D, +- /// ), +- /// addr); +- /// ``` - fn from(ip: u128) -> Ipv6Addr { -- Ipv6Addr::new( -- (ip >> 112) as u16, (ip >> 96) as u16, (ip >> 80) as u16, -- (ip >> 64) as u16, (ip >> 48) as u16, (ip >> 32) as u16, -- (ip >> 16) as u16, ip as u16, -- ) +- Ipv6Addr::from(ip.to_be_bytes()) - } -} - From 2edfb5ddeb1bb7b90a96a142f0abb22837c767f6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 21 Feb 2019 15:24:39 +0100 Subject: [PATCH 0540/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9136f64f3fa0..bdf575ea28b06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#2f61600a4f45d1624e85ddbace5b33c74017719f" +source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", From af274db7b677dc315d3dc8353b5bbc9a5324d457 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 21 Feb 2019 15:34:03 +0100 Subject: [PATCH 0541/1566] Update gimli --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdf575ea28b06..97c482a743712 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -311,8 +311,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" -version = "0.16.1" -source = "git+https://github.com/gimli-rs/gimli.git#e2529c0bf06b4197df3ddbc76bda5adf2cc0659f" +version = "0.17.0" +source = "git+https://github.com/gimli-rs/gimli.git#b0141dd637d66f7c89ab47b899d628bae3896f1d" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -603,7 +603,7 @@ dependencies = [ "cranelift-simplejit 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)", + "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -887,7 +887,7 @@ dependencies = [ "checksum fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eb7217124812dc5672b7476d0c2d20cfe9f7c0f1ba0904b674a9762a0212f72e" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.16.1 (git+https://github.com/gimli-rs/gimli.git)" = "" +"checksum gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" From 14cc82bdff58bad23bfd0e362102ab3933e68fd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 22 Feb 2019 05:46:14 +0000 Subject: [PATCH 0542/1566] Bump gimli from `b0141dd` to `2c7fcfe` Bumps [gimli](https://github.com/gimli-rs/gimli) from `b0141dd` to `2c7fcfe`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/b0141dd637d66f7c89ab47b899d628bae3896f1d...2c7fcfee8035fe6787c166191fdd8d38bf1d9f35) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 97c482a743712..c76988d8caba4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#b0141dd637d66f7c89ab47b899d628bae3896f1d" +source = "git+https://github.com/gimli-rs/gimli.git#2c7fcfee8035fe6787c166191fdd8d38bf1d9f35" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 14750ece1a8cc5b6b02438b7bdd07c848d584c3b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Feb 2019 10:30:15 +0100 Subject: [PATCH 0543/1566] Use Instance::resolve_for_vtable instead of Instance::resolve for vtables --- src/vtable.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vtable.rs b/src/vtable.rs index 720582b7caed0..d525f939120ac 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -113,7 +113,7 @@ fn build_vtable<'a, 'tcx: 'a>( Some(import_function( tcx, fx.module, - Instance::resolve(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), )) }) }); From f54a2cc2e477c2b94a8dd6f337c0fdf3262e1c72 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Feb 2019 10:41:34 +0100 Subject: [PATCH 0544/1566] Update cranelift and add a test for bitreverse Fixes #168 using CraneStation/cranelift#683 --- Cargo.lock | 20 ++++++++++---------- example/mini_core.rs | 1 + example/mini_core_hello_world.rs | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c76988d8caba4..39c6e2b109fd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3a9226f77c54ec792356fd016c98cc5f40917db" +source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/example/mini_core.rs b/example/mini_core.rs index b7277f5ee9f48..19044e1fea547 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -348,6 +348,7 @@ pub mod intrinsics { pub fn uninit() -> T; pub fn ctlz_nonzero(x: T) -> T; pub fn needs_drop() -> bool; + pub fn bitreverse(x: T) -> T; } } diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 5ab7575252b07..4fa08391f5a87 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -137,6 +137,8 @@ fn main() { puts(*world as *const str as *const u8); world as Box; + assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8); + assert_eq!(intrinsics::size_of_val(hello) as u8, 6); let chars = &['C', 'h', 'a', 'r', 's']; From bf0cd819ed74ff6df54d6ab69f935a8e5b17ce03 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Feb 2019 14:10:49 +0100 Subject: [PATCH 0545/1566] Rustup to rustc 1.34.0-nightly (e1c6d0057 2019-02-22) --- ...002-Disable-u128-and-i128-in-libcore.patch | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index fef4a802c7fa4..423dbe5592cad 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -841,47 +841,6 @@ index 2c9bf24..af2ab6f 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } -diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index 8c5dde7..8122120 100644 ---- a/src/libcore/sync/atomic.rs -+++ b/src/libcore/sync/atomic.rs -@@ -2003,36 +2003,6 @@ atomic_int! { - "AtomicU64::new(0)", - u64 AtomicU64 ATOMIC_U64_INIT - } --#[cfg(target_has_atomic = "128")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "i128", "../../../std/primitive.i128.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_min, atomic_max, -- 16, -- "AtomicI128::new(0)", -- i128 AtomicI128 ATOMIC_I128_INIT --} --#[cfg(target_has_atomic = "128")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "u128", "../../../std/primitive.u128.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_umin, atomic_umax, -- 16, -- "AtomicU128::new(0)", -- u128 AtomicU128 ATOMIC_U128_INIT --} - #[cfg(target_pointer_width = "16")] - macro_rules! ptr_width { - () => { 2 } diff --git a/src/libcore/time.rs b/src/libcore/time.rs index ac7e117..0dfd856 100644 --- a/src/libcore/time.rs From 5d1701fb093e3b2fd8ab1d876a5534c94baec6f9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Feb 2019 11:17:30 +0100 Subject: [PATCH 0546/1566] Add rust to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1290c0f78d61e..9a9df1021e5f3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ perf.data.old /build_sysroot/sysroot /build_sysroot/sysroot_src /build_sysroot/Cargo.lock +/rust From 55623b2f54b59d03ebd5a12a24a79fc82b92889b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Feb 2019 12:37:44 +0100 Subject: [PATCH 0547/1566] Rustup to rustc 1.34.0-nightly (aadbc459b 2019-02-23) --- patches/0001-Disable-stdsimd.patch | 33 +++--- ...002-Disable-u128-and-i128-in-libcore.patch | 103 +++++++++++++----- ...alloc-Disable-some-unsupported-stuff.patch | 26 ++--- 3 files changed, 102 insertions(+), 60 deletions(-) diff --git a/patches/0001-Disable-stdsimd.patch b/patches/0001-Disable-stdsimd.patch index 9a869343deaab..343b618be73c3 100644 --- a/patches/0001-Disable-stdsimd.patch +++ b/patches/0001-Disable-stdsimd.patch @@ -1,6 +1,6 @@ -From 096dee5742ccd90df2e0edfe8b6bda87a63d99cf Mon Sep 17 00:00:00 2001 +From 95157a64120faffebc2cc67baf65f45f992e167e Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Wed, 30 Jan 2019 18:55:58 +0100 +Date: Sun, 24 Feb 2019 11:27:11 +0100 Subject: [PATCH] Disable stdsimd --- @@ -9,10 +9,10 @@ Subject: [PATCH] Disable stdsimd 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 6f364eb..69f0914 100644 +index f2165c6..cdb42c1 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -221,6 +221,7 @@ pub mod alloc; +@@ -222,6 +222,7 @@ pub mod alloc; mod tuple; mod unit; @@ -20,24 +20,24 @@ index 6f364eb..69f0914 100644 // Pull in the `core_arch` crate directly into libcore. The contents of // `core_arch` are in a different repository: rust-lang-nursery/stdsimd. // -@@ -248,3 +249,4 @@ mod core_arch; +@@ -235,3 +236,4 @@ mod core_arch; #[stable(feature = "simd_arch", since = "1.27.0")] pub use core_arch::arch; +*/ diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 244caf2..f269fda 100644 +index 6dd3a6c..c7401e2 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -271,7 +271,6 @@ - #![feature(rustc_attrs)] - #![feature(rustc_const_unstable)] +@@ -291,7 +291,6 @@ + #![feature(slice_patterns)] + #![feature(staged_api)] #![feature(std_internals)] -#![feature(stdsimd)] - #![feature(shrink_to)] - #![feature(slice_concat_ext)] - #![feature(slice_internals)] -@@ -358,9 +357,6 @@ pub mod prelude; + #![feature(stmt_expr_attributes)] + #![feature(str_internals)] + #![feature(thread_local)] +@@ -357,9 +356,6 @@ pub mod prelude; // Public module declarations and re-exports #[stable(feature = "rust1", since = "1.0.0")] pub use core::any; @@ -47,7 +47,7 @@ index 244caf2..f269fda 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::cell; #[stable(feature = "rust1", since = "1.0.0")] -@@ -492,6 +488,7 @@ mod memchr; +@@ -489,6 +485,7 @@ mod memchr; // compiler pub mod rt; @@ -55,7 +55,7 @@ index 244caf2..f269fda 100644 // Pull in the `std_detect` crate directly into libstd. The contents of // `std_detect` are in a different repository: rust-lang-nursery/stdsimd. // -@@ -508,6 +505,7 @@ mod std_detect; +@@ -505,6 +502,7 @@ mod std_detect; #[unstable(feature = "stdsimd", issue = "48556")] #[cfg(not(test))] pub use std_detect::detect; @@ -64,5 +64,4 @@ index 244caf2..f269fda 100644 // Include a number of private modules that exist solely to provide // the rustdoc documentation for primitive types. Using `include!` -- -2.11.0 - +2.17.2 (Apple Git-113) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 423dbe5592cad..94744b41daefd 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From 8080d322c8396b7b234cc92eb675f697c55f7298 Mon Sep 17 00:00:00 2001 +From 61a7d6cc7809c89a8d2d046946dd0cb7cb1cd1b5 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 16 Feb 2019 12:09:42 +0100 +Date: Sun, 24 Feb 2019 11:27:11 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -18,13 +18,13 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libcore/num/wrapping.rs | 14 ++-- src/libcore/ops/arith.rs | 22 +++--- src/libcore/ops/bit.rs | 30 +++----- - src/libcore/sync/atomic.rs | 30 -------- + src/libcore/sync/atomic.rs | 32 -------- src/libcore/time.rs | 123 ------------------------------- src/libstd/lib.rs | 4 - - src/libstd/net/ip.rs | 20 ----- + src/libstd/net/ip.rs | 42 ----------- src/libstd/num.rs | 2 +- src/libstd/panic.rs | 6 -- - 22 files changed, 63 insertions(+), 372 deletions(-) + 20 files changed, 63 insertions(+), 363 deletions(-) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index ed90b7d..1739f91 100644 @@ -190,7 +190,7 @@ index d5d29c9..f98f382 100644 #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index a3e9cfa..31b6ca4 100644 +index e7efd97..78e0da7 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -173,7 +173,6 @@ step_impl_signed!([i64: u64]); @@ -215,10 +215,10 @@ index dfe1d2a..06cc578 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index cd88d3e..532d680 100644 +index cdb42c1..75743ee 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -148,14 +148,12 @@ mod uint_macros; +@@ -149,14 +149,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -234,10 +234,10 @@ index cd88d3e..532d680 100644 #[path = "num/f32.rs"] pub mod f32; #[path = "num/f64.rs"] pub mod f64; diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index c4b41f1..0ade53b 100644 +index 29606cb..160cca1 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs -@@ -664,8 +664,8 @@ mod copy_impls { +@@ -673,8 +673,8 @@ mod copy_impls { } impl_copy! { @@ -249,7 +249,7 @@ index c4b41f1..0ade53b 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 3f7455a..7a0c44a 100644 +index 43afc9a..fc5366b 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -164,12 +164,10 @@ pub fn forget_unsized(t: T) { @@ -266,7 +266,7 @@ index 3f7455a..7a0c44a 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 6fb67ea..6440490 100644 +index 5b7d5f4..0cfb96c 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -102,13 +102,11 @@ nonzero_integers! { @@ -283,7 +283,7 @@ index 6fb67ea..6440490 100644 #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); } -@@ -2124,18 +2122,6 @@ impl i64 { +@@ -2120,18 +2118,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -302,7 +302,7 @@ index 6fb67ea..6440490 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4411,17 +4397,6 @@ impl u64 { +@@ -4407,17 +4393,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -320,7 +320,7 @@ index 6fb67ea..6440490 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4505,7 +4480,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4501,7 +4476,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -329,7 +329,7 @@ index 6fb67ea..6440490 100644 /// The error type returned when a checked integral type conversion fails. #[unstable(feature = "try_from", issue = "33417")] -@@ -4621,30 +4596,25 @@ macro_rules! rev { +@@ -4617,30 +4592,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -364,7 +364,7 @@ index 6fb67ea..6440490 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4656,21 +4626,21 @@ mod ptr_try_from_impls { +@@ -4652,21 +4622,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -394,7 +394,7 @@ index 6fb67ea..6440490 100644 } #[cfg(target_pointer_width = "32")] -@@ -4679,24 +4649,24 @@ mod ptr_try_from_impls { +@@ -4675,24 +4645,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -427,7 +427,7 @@ index 6fb67ea..6440490 100644 } #[cfg(target_pointer_width = "64")] -@@ -4705,24 +4675,20 @@ mod ptr_try_from_impls { +@@ -4701,24 +4671,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -456,7 +456,7 @@ index 6fb67ea..6440490 100644 } #[doc(hidden)] -@@ -4757,7 +4723,7 @@ macro_rules! doit { +@@ -4753,7 +4719,7 @@ macro_rules! doit { } })*) } @@ -465,7 +465,7 @@ index 6fb67ea..6440490 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4948,52 +4914,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4944,52 +4910,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -841,8 +841,51 @@ index 2c9bf24..af2ab6f 100644 -shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } +shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } +diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs +index d0ee5fa..d02c454 100644 +--- a/src/libcore/sync/atomic.rs ++++ b/src/libcore/sync/atomic.rs +@@ -2012,38 +2012,6 @@ atomic_int! { + "AtomicU64::new(0)", + u64 AtomicU64 ATOMIC_U64_INIT + } +-#[cfg(target_has_atomic = "128")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "i128", "../../../std/primitive.i128.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_min, atomic_max, +- 16, +- "AtomicI128::new(0)", +- i128 AtomicI128 ATOMIC_I128_INIT +-} +-#[cfg(target_has_atomic = "128")] +-atomic_int! { +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- unstable(feature = "integer_atomics", issue = "32976"), +- "u128", "../../../std/primitive.u128.html", +- "#![feature(integer_atomics)]\n\n", +- atomic_umin, atomic_umax, +- 16, +- "AtomicU128::new(0)", +- u128 AtomicU128 ATOMIC_U128_INIT +-} + #[cfg(target_pointer_width = "16")] + macro_rules! ptr_width { + () => { 2 } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index ac7e117..0dfd856 100644 +index 91161ca..759497f 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs @@ -21,7 +21,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; @@ -851,9 +894,9 @@ index ac7e117..0dfd856 100644 const MICROS_PER_SEC: u64 = 1_000_000; -const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; - /// The duration of one second. - #[unstable(feature = "duration_constants", issue = "57391")] -@@ -276,54 +275,6 @@ impl Duration { + /// A `Duration` type to represent a span of time, typically used for system + /// timeouts. +@@ -312,54 +311,6 @@ impl Duration { #[inline] pub const fn subsec_nanos(&self) -> u32 { self.nanos } @@ -908,7 +951,7 @@ index ac7e117..0dfd856 100644 /// Checked `Duration` addition. Computes `self + other`, returning [`None`] /// if overflow occurred. /// -@@ -482,80 +433,6 @@ impl Duration { +@@ -518,80 +469,6 @@ impl Duration { (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) } @@ -990,10 +1033,10 @@ index ac7e117..0dfd856 100644 /// /// # Examples diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 9a4232d..592fea0 100644 +index c7401e2..3dff42a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -392,8 +392,6 @@ pub use core::i16; +@@ -396,8 +396,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -1002,7 +1045,7 @@ index 9a4232d..592fea0 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -426,8 +424,6 @@ pub use alloc_crate::string; +@@ -430,8 +428,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -1078,7 +1121,7 @@ index c80b9a5..e32a6b3 100644 #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs -index 862fdf0..171ebeb 100644 +index daeac71..717ee82 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -254,9 +254,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} diff --git a/patches/0006-alloc-Disable-some-unsupported-stuff.patch b/patches/0006-alloc-Disable-some-unsupported-stuff.patch index 1342bdd4e0c5e..18911113f19df 100644 --- a/patches/0006-alloc-Disable-some-unsupported-stuff.patch +++ b/patches/0006-alloc-Disable-some-unsupported-stuff.patch @@ -1,18 +1,18 @@ -From a65665bae4e5ad6ef76a365b7cdff8bdfbd3db67 Mon Sep 17 00:00:00 2001 +From 610096e32cc7cfba58358219a1cf25ff72123208 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sat, 6 Oct 2018 11:03:00 +0200 +Date: Sun, 24 Feb 2019 11:27:11 +0100 Subject: [PATCH] [alloc] Disable some unsupported stuff --- src/liballoc/boxed.rs | 6 ------ src/liballoc/vec.rs | 2 -- - 3 files changed, 4 insertions(+), 8 deletions(-) + 2 files changed, 8 deletions(-) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs -index f989e70..597dd15 100644 +index 0cd2373..696535a 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs -@@ -410,9 +410,6 @@ impl Hasher for Box { +@@ -423,9 +423,6 @@ impl Hasher for Box { fn write_u64(&mut self, i: u64) { (**self).write_u64(i) } @@ -22,7 +22,7 @@ index f989e70..597dd15 100644 fn write_usize(&mut self, i: usize) { (**self).write_usize(i) } -@@ -428,9 +425,6 @@ impl Hasher for Box { +@@ -441,9 +438,6 @@ impl Hasher for Box { fn write_i64(&mut self, i: i64) { (**self).write_i64(i) } @@ -33,22 +33,22 @@ index f989e70..597dd15 100644 (**self).write_isize(i) } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs -index 2bc037e..2fe8894 100644 +index 229dafc..944856e 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs -@@ -1569,13 +1569,11 @@ impl_is_zero!(i8, |x| x == 0); +@@ -1601,13 +1601,11 @@ impl_is_zero!(i8, |x| x == 0); impl_is_zero!(i16, |x| x == 0); impl_is_zero!(i32, |x| x == 0); impl_is_zero!(i64, |x| x == 0); -impl_is_zero!(i128, |x| x == 0); impl_is_zero!(isize, |x| x == 0); - + impl_is_zero!(u16, |x| x == 0); impl_is_zero!(u32, |x| x == 0); impl_is_zero!(u64, |x| x == 0); -impl_is_zero!(u128, |x| x == 0); impl_is_zero!(usize, |x| x == 0); - - impl_is_zero!(char, |x| x == '\0'); --- -2.17.1 (Apple Git-112) + + impl_is_zero!(bool, |x| x == false); +-- +2.17.2 (Apple Git-113) From c8b51653f34008de5fa6143de001062d002fe5ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Feb 2019 11:34:38 +0100 Subject: [PATCH 0548/1566] Rustup to rustc 1.34.0-nightly (00aae71f5 2019-02-25) --- patches/0002-Disable-u128-and-i128-in-libcore.patch | 4 ++-- src/constant.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 94744b41daefd..b3f98c68dae29 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -320,7 +320,7 @@ index 5b7d5f4..0cfb96c 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4501,7 +4476,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4376,7 +4376,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -328,7 +328,7 @@ index 5b7d5f4..0cfb96c 100644 +from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } /// The error type returned when a checked integral type conversion fails. - #[unstable(feature = "try_from", issue = "33417")] + #[stable(feature = "try_from", since = "1.34.0")] @@ -4617,30 +4592,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); diff --git a/src/constant.rs b/src/constant.rs index 0216eb80a53f7..74a16b3bf2ad2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -224,7 +224,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( let const_ = tcx.const_eval(ParamEnv::reveal_all().and(cid)).unwrap(); let alloc = match const_.val { - ConstValue::ByRef(_alloc_id, alloc, n) if n.bytes() == 0 => alloc, + ConstValue::ByRef(ptr, alloc) if ptr.offset.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", const_), }; From 3fe454a3bd42ea54fc4c91a4a6b4240469101b3a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Feb 2019 11:37:36 +0100 Subject: [PATCH 0549/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 39c6e2b109fd7..dec3c66a450d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" [[package]] name = "cranelift-faerie" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d180cfc7f93c724d47ac77f0180c095768bc4fd" +source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" dependencies = [ "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", From 041c07e2a467daf1db5bcf61a445c81f7e941244 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 27 Feb 2019 05:28:23 +0000 Subject: [PATCH 0550/1566] Bump lazy_static from 1.2.0 to 1.3.0 Bumps [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/rust-lang-nursery/lazy-static.rs/releases) - [Commits](https://github.com/rust-lang-nursery/lazy-static.rs/compare/1.2.0...1.3.0) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dec3c66a450d8..02cff498a7d91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -359,7 +359,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -783,7 +783,7 @@ name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -893,7 +893,7 @@ dependencies = [ "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" +"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" From 6384b12604bd5c46205296e9aa7523877d814737 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 27 Feb 2019 09:35:15 +0000 Subject: [PATCH 0551/1566] Bump libc from 0.2.48 to 0.2.49 Bumps [libc](https://github.com/rust-lang/libc) from 0.2.48 to 0.2.49. - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.48...0.2.49) Signed-off-by: dependabot[bot] --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 02cff498a7d91..dd73697f803ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,7 +55,7 @@ dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -66,7 +66,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -208,7 +208,7 @@ dependencies = [ "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -244,7 +244,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -254,7 +254,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -364,7 +364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.48" +version = "0.2.49" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -380,7 +380,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -425,7 +425,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -480,7 +480,7 @@ name = "rand_jitter" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -492,7 +492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -572,7 +572,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -605,7 +605,7 @@ dependencies = [ "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -745,7 +745,7 @@ version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -765,7 +765,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -894,7 +894,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" +"checksum libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)" = "413f3dfc802c5dc91dc570b05125b6cda9855edfaa9825c9849807876376e70e" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" diff --git a/Cargo.toml b/Cargo.toml index 64dfa96d3ac1f..fd9f438a56a7a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ target-lexicon = "0.2.0" ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.7" -libc = "0.2.45" +libc = "0.2.49" tempfile = "3.0.7" env_logger = "0.6" gimli = { git = "https://github.com/gimli-rs/gimli.git" } From 9c0e861920d04d0fcf0f0e993c8ca4de42ed95ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 27 Feb 2019 15:33:45 +0000 Subject: [PATCH 0552/1566] Bump rand_pcg from 0.1.1 to 0.1.2 Bumps [rand_pcg](https://github.com/rust-random/rand) from 0.1.1 to 0.1.2. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.1.1...rand_pcg-0.1.2) Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd73697f803ee..46b6e448ed4fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -432,7 +432,7 @@ dependencies = [ "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -500,11 +500,11 @@ dependencies = [ [[package]] name = "rand_pcg" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -911,7 +911,7 @@ dependencies = [ "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" "checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d" -"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05" +"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" From 54ebc15d81196715f829b3e0dba14e7f2049a76f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 27 Feb 2019 15:34:08 +0000 Subject: [PATCH 0553/1566] Bump gimli from `2c7fcfe` to `7b828cb` Bumps [gimli](https://github.com/gimli-rs/gimli) from `2c7fcfe` to `7b828cb`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/2c7fcfee8035fe6787c166191fdd8d38bf1d9f35...7b828cb40e07e2ea8c403f864aa9ffa9f15b2df4) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index dd73697f803ee..2e12c614170f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#2c7fcfee8035fe6787c166191fdd8d38bf1d9f35" +source = "git+https://github.com/gimli-rs/gimli.git#7b828cb40e07e2ea8c403f864aa9ffa9f15b2df4" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 6c88af343883d535ba92fbfb00146f9d01b436ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Feb 2019 10:55:21 +0100 Subject: [PATCH 0554/1566] Rustup to rustc 1.34.0-nightly (7e001e5c6 2019-02-27) --- src/intrinsics.rs | 4 +++- src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 2068bd9e508e6..c57c9d8cb9dba 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1,5 +1,7 @@ use crate::prelude::*; +use rustc::ty::subst::SubstsRef; + macro_rules! intrinsic_pat { (_) => { _ @@ -88,7 +90,7 @@ macro_rules! atomic_minmax { pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, def_id: DefId, - substs: &'tcx Substs, + substs: SubstsRef<'tcx>, args: Vec>, destination: Option<(CPlace<'tcx>, BasicBlock)>, ) { diff --git a/src/lib.rs b/src/lib.rs index 483bcb51c646f..bad8c6043eaa2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,7 +73,7 @@ mod prelude { }; pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout, VariantIdx}; pub use rustc::ty::{ - self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, + self, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; pub use rustc_data_structures::{ From 3d81b7656609acba57fccc378ed5f449896557d2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 Mar 2019 18:55:20 +0100 Subject: [PATCH 0555/1566] Rustup to rustc 1.34.0-nightly (350674b71 2019-02-28) --- example/mini_core.rs | 10 +++- ...002-Disable-u128-and-i128-in-libcore.patch | 56 +++++++++---------- patches/0014-Don-t-use-OS-TLS.patch | 21 ++++--- src/abi.rs | 6 +- src/pretty_clif.rs | 2 +- 5 files changed, 51 insertions(+), 44 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 19044e1fea547..1045e7f0cec59 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,4 +1,4 @@ -#![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription)] +#![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types)] #![no_core] #![allow(dead_code)] @@ -386,3 +386,11 @@ impl Index for [T] { &self[index] } } + +extern { + type VaListImpl; +} + +#[lang = "va_list"] +#[repr(transparent)] +pub struct VaList<'a>(&'a mut VaListImpl); diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index b3f98c68dae29..0f4781f24a97c 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -1,6 +1,6 @@ -From 61a7d6cc7809c89a8d2d046946dd0cb7cb1cd1b5 Mon Sep 17 00:00:00 2001 +From e87977477e8507a5749e64ea49ee503e706d7178 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Sun, 24 Feb 2019 11:27:11 +0100 +Date: Fri, 1 Mar 2019 18:36:21 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- @@ -215,10 +215,10 @@ index dfe1d2a..06cc578 100644 /// An iterator adapter that produces output as long as the underlying diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index cdb42c1..75743ee 100644 +index 9516c02..9d91885 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs -@@ -149,14 +149,12 @@ mod uint_macros; +@@ -148,14 +148,12 @@ mod uint_macros; #[path = "num/i16.rs"] pub mod i16; #[path = "num/i32.rs"] pub mod i32; #[path = "num/i64.rs"] pub mod i64; @@ -249,7 +249,7 @@ index 29606cb..160cca1 100644 bool char } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index 43afc9a..fc5366b 100644 +index f41d293..71b5e09 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -164,12 +164,10 @@ pub fn forget_unsized(t: T) { @@ -266,7 +266,7 @@ index 43afc9a..fc5366b 100644 /// f64 | 8 /// char | 4 diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 5b7d5f4..0cfb96c 100644 +index 6708a19..4066b0c 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -102,13 +102,11 @@ nonzero_integers! { @@ -283,7 +283,7 @@ index 5b7d5f4..0cfb96c 100644 #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); } -@@ -2120,18 +2118,6 @@ impl i64 { +@@ -2117,18 +2115,6 @@ impl i64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -302,7 +302,7 @@ index 5b7d5f4..0cfb96c 100644 #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { -@@ -4407,17 +4393,6 @@ impl u64 { +@@ -4401,17 +4387,6 @@ impl u64 { "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } } @@ -320,7 +320,7 @@ index 5b7d5f4..0cfb96c 100644 #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { -@@ -4376,7 +4376,7 @@ macro_rules! from_str_radix_int_impl { +@@ -4495,7 +4470,7 @@ macro_rules! from_str_radix_int_impl { } )*} } @@ -329,7 +329,7 @@ index 5b7d5f4..0cfb96c 100644 /// The error type returned when a checked integral type conversion fails. #[stable(feature = "try_from", since = "1.34.0")] -@@ -4617,30 +4592,25 @@ macro_rules! rev { +@@ -4621,30 +4596,25 @@ macro_rules! rev { try_from_upper_bounded!(u16, u8); try_from_upper_bounded!(u32, u16, u8); try_from_upper_bounded!(u64, u32, u16, u8); @@ -364,7 +364,7 @@ index 5b7d5f4..0cfb96c 100644 // usize/isize try_from_upper_bounded!(usize, isize); -@@ -4652,21 +4622,21 @@ mod ptr_try_from_impls { +@@ -4656,21 +4626,21 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8); @@ -394,7 +394,7 @@ index 5b7d5f4..0cfb96c 100644 } #[cfg(target_pointer_width = "32")] -@@ -4675,24 +4645,24 @@ mod ptr_try_from_impls { +@@ -4679,24 +4649,24 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16); @@ -427,7 +427,7 @@ index 5b7d5f4..0cfb96c 100644 } #[cfg(target_pointer_width = "64")] -@@ -4701,24 +4671,20 @@ mod ptr_try_from_impls { +@@ -4705,24 +4675,20 @@ mod ptr_try_from_impls { use convert::TryFrom; try_from_upper_bounded!(usize, u8, u16, u32); @@ -456,7 +456,7 @@ index 5b7d5f4..0cfb96c 100644 } #[doc(hidden)] -@@ -4753,7 +4719,7 @@ macro_rules! doit { +@@ -4757,7 +4723,7 @@ macro_rules! doit { } })*) } @@ -465,7 +465,7 @@ index 5b7d5f4..0cfb96c 100644 fn from_str_radix(src: &str, radix: u32) -> Result { use self::IntErrorKind::*; -@@ -4944,52 +4910,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } +@@ -4948,52 +4914,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } @@ -519,7 +519,7 @@ index 5b7d5f4..0cfb96c 100644 // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX // which imply that pointer-sized integers must be at least 16 bits: diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs -index 50e189c..2da3b35 100644 +index 9cd5108..26c8abc 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -102,19 +102,17 @@ macro_rules! sh_impl_all { @@ -552,7 +552,7 @@ index 50e189c..2da3b35 100644 macro_rules! wrapping_int_impl { ($($t:ty)*) => ($( -@@ -675,7 +673,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); +@@ -677,7 +675,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); )*) } @@ -561,7 +561,7 @@ index 50e189c..2da3b35 100644 macro_rules! wrapping_int_impl_signed { ($($t:ty)*) => ($( -@@ -804,7 +802,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); +@@ -806,7 +804,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); )*) } @@ -570,7 +570,7 @@ index 50e189c..2da3b35 100644 macro_rules! wrapping_int_impl_unsigned { ($($t:ty)*) => ($( -@@ -881,7 +879,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); +@@ -883,7 +881,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); )*) } @@ -579,7 +579,7 @@ index 50e189c..2da3b35 100644 mod shift_max { #![allow(non_upper_case_globals)] -@@ -908,13 +906,11 @@ mod shift_max { +@@ -910,13 +908,11 @@ mod shift_max { pub const i16: u32 = (1 << 4) - 1; pub const i32: u32 = (1 << 5) - 1; pub const i64: u32 = (1 << 6) - 1; @@ -1033,10 +1033,10 @@ index 91161ca..759497f 100644 /// /// # Examples diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index c7401e2..3dff42a 100644 +index 2b62b5b..c6515bc 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs -@@ -396,8 +396,6 @@ pub use core::i16; +@@ -393,8 +393,6 @@ pub use core::i16; pub use core::i32; #[stable(feature = "rust1", since = "1.0.0")] pub use core::i64; @@ -1045,7 +1045,7 @@ index c7401e2..3dff42a 100644 #[stable(feature = "rust1", since = "1.0.0")] pub use core::usize; #[stable(feature = "rust1", since = "1.0.0")] -@@ -430,8 +428,6 @@ pub use alloc_crate::string; +@@ -427,8 +425,6 @@ pub use alloc_crate::string; pub use alloc_crate::vec; #[stable(feature = "rust1", since = "1.0.0")] pub use core::char; @@ -1055,7 +1055,7 @@ index c7401e2..3dff42a 100644 pub use core::hint; diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index c856129..2bfe9cb 100644 +index fa256ce..42b0aa2 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -1391,48 +1391,6 @@ impl FromInner for Ipv6Addr { @@ -1108,7 +1108,7 @@ index c856129..2bfe9cb 100644 impl From<[u8; 16]> for Ipv6Addr { fn from(octets: [u8; 16]) -> Ipv6Addr { diff --git a/src/libstd/num.rs b/src/libstd/num.rs -index c80b9a5..e32a6b3 100644 +index 828d572..bc04fb1 100644 --- a/src/libstd/num.rs +++ b/src/libstd/num.rs @@ -12,7 +12,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} @@ -1118,10 +1118,10 @@ index c80b9a5..e32a6b3 100644 -pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; +pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; - #[cfg(test)] use fmt; - #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; + #[cfg(test)] use crate::fmt; + #[cfg(test)] use crate::ops::{Add, Sub, Mul, Div, Rem}; diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs -index daeac71..717ee82 100644 +index 6a16414..f027102 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -254,9 +254,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} diff --git a/patches/0014-Don-t-use-OS-TLS.patch b/patches/0014-Don-t-use-OS-TLS.patch index 01c959c8ae838..1ee7069262749 100644 --- a/patches/0014-Don-t-use-OS-TLS.patch +++ b/patches/0014-Don-t-use-OS-TLS.patch @@ -1,6 +1,6 @@ -From 1ad7a849f9ff845f676d4625ba71d1060039c0de Mon Sep 17 00:00:00 2001 +From 0c7406a33e3a40427760e6955188be193fd568a8 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Thu, 31 Jan 2019 20:11:56 +0100 +Date: Fri, 1 Mar 2019 18:36:22 +0100 Subject: [PATCH] Don't use OS TLS --- @@ -9,10 +9,10 @@ Subject: [PATCH] Don't use OS TLS 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs -index 5d2eb5f..39513b6 100644 +index d1f5373..ce83b3b 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs -@@ -160,10 +160,10 @@ macro_rules! __thread_local_inner { +@@ -164,10 +164,10 @@ macro_rules! __thread_local_inner { &'static $crate::cell::UnsafeCell< $crate::option::Option<$t>>> { @@ -24,7 +24,7 @@ index 5d2eb5f..39513b6 100644 #[thread_local] #[cfg(all( target_thread_local, -@@ -178,6 +178,7 @@ macro_rules! __thread_local_inner { +@@ -182,6 +182,7 @@ macro_rules! __thread_local_inner { ))] static __KEY: $crate::thread::__OsLocalKeyInner<$t> = $crate::thread::__OsLocalKeyInner::new(); @@ -32,16 +32,16 @@ index 5d2eb5f..39513b6 100644 __KEY.get() } -@@ -304,7 +305,6 @@ impl LocalKey { +@@ -308,7 +309,6 @@ impl LocalKey { /// On some platforms like wasm32 there's no threads, so no need to generate /// thread locals and we can instead just use plain statics! #[doc(hidden)] -#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] pub mod statik { - use cell::UnsafeCell; - use fmt; + use crate::cell::UnsafeCell; + use crate::fmt; diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs -index eb8e0c1..b44d737 100644 +index 08f0aa2..eff3126 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -195,7 +195,6 @@ pub use self::local::{LocalKey, AccessError}; @@ -53,5 +53,4 @@ index eb8e0c1..b44d737 100644 #[unstable(feature = "libstd_thread_internals", issue = "0")] #[cfg(target_thread_local)] -- -2.11.0 - +2.17.2 (Apple Git-113) diff --git a/src/abi.rs b/src/abi.rs index b4de8aeea1969..45c2c6d3719c0 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -152,7 +152,7 @@ pub fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnS sig.map_bound(|sig| tcx.mk_fn_sig( iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), sig.output(), - sig.variadic, + sig.c_variadic, sig.unsafety, sig.abi )) @@ -193,7 +193,7 @@ pub fn get_function_name_and_sig<'a, 'tcx>( assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_ty = inst.ty(tcx); let fn_sig = ty_fn_sig(tcx, fn_ty); - if fn_sig.variadic && !support_vararg { + if fn_sig.c_variadic && !support_vararg { unimpl!("Variadic function definitions are not yet supported"); } let sig = clif_sig_from_fn_sig(tcx, fn_sig); @@ -717,7 +717,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( }; // FIXME find a cleaner way to support varargs - if fn_sig.variadic { + if fn_sig.c_variadic { if fn_sig.abi != Abi::C { unimpl!("Variadic call for non-C abi {:?}", fn_sig.abi); } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index aab6e341a09a4..31ca4168d242c 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -20,7 +20,7 @@ use crate::prelude::*; /// function u0:0(i64, i64, i64) system_v { /// ; symbol _ZN119_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$u27$a$u20$$RF$$u27$b$u20$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17he85059d5e6a760a0E /// ; instance Instance { def: Item(DefId(0/0:29 ~ example[8787]::{{impl}}[0]::call_once[0])), substs: [ReErased, ReErased] } -/// ; sig ([IsNotEmpty, (&&[u16],)]; variadic: false)->(u8, u8) +/// ; sig ([IsNotEmpty, (&&[u16],)]; c_variadic: false)->(u8, u8) /// /// ; ssa {_2: NOT_SSA, _4: NOT_SSA, _0: NOT_SSA, _3: (empty), _1: NOT_SSA} /// ; msg loc.idx param pass mode ssa flags ty From 99eb418f19fdd0cb902e75c8586a231e5e476b25 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 2 Mar 2019 12:18:41 +0100 Subject: [PATCH 0556/1566] Rustup to rustc 1.34.0-nightly (c1d2d83ca 2019-03-01) --- src/analyze.rs | 2 +- src/base.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index d3cbe93b722bb..1c3f52d50afff 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -48,7 +48,7 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap fn analyze_non_ssa_place(flag_map: &mut HashMap, place: &Place) { match place { - Place::Local(local) => not_ssa(flag_map, local), + Place::Base(PlaceBase::Local(local)) => not_ssa(flag_map, local), _ => {} } } diff --git a/src/base.rs b/src/base.rs index 62b0bf1ac0434..75ad1099d537a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1090,9 +1090,11 @@ pub fn trans_place<'a, 'tcx: 'a>( place: &Place<'tcx>, ) -> CPlace<'tcx> { match place { - Place::Local(local) => fx.get_local_place(*local), - Place::Promoted(promoted) => crate::constant::trans_promoted(fx, promoted.0), - Place::Static(static_) => crate::constant::codegen_static_ref(fx, static_), + Place::Base(base) => match base { + PlaceBase::Local(local) => fx.get_local_place(*local), + PlaceBase::Promoted(promoted) => crate::constant::trans_promoted(fx, promoted.0), + PlaceBase::Static(static_) => crate::constant::codegen_static_ref(fx, static_), + } Place::Projection(projection) => { let base = trans_place(fx, &projection.base); match projection.elem { From 25f3ef5ff998eea060e73be04bfe88cbedf57dc9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Feb 2019 12:38:06 +0100 Subject: [PATCH 0557/1566] Implement ProjectionElem::Subslice --- example/mini_core_hello_world.rs | 8 +++++++- src/base.rs | 34 ++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 4fa08391f5a87..d550ccbf61a24 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -1,6 +1,6 @@ // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs -#![feature(no_core, unboxed_closures, start, lang_items, box_syntax)] +#![feature(no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns)] #![no_core] #![allow(dead_code)] @@ -184,4 +184,10 @@ fn main() { } [NoisyDropInner, NoisyDropInner]; + + let x = &[0u32, 42u32] as &[u32]; + match x { + [] => assert_eq!(0u32, 1), + [_, ref y..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize), + } } diff --git a/src/base.rs b/src/base.rs index 75ad1099d537a..6427c756ac880 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1117,12 +1117,34 @@ pub fn trans_place<'a, 'tcx: 'a>( }; base.place_index(fx, index) } - ProjectionElem::Subslice { from, to } => unimpl!( - "projection subslice {:?} from {} to {}", - projection.base, - from, - to - ), + ProjectionElem::Subslice { from, to } => { + // These indices are generated by slice patterns. + // slice[from:-to] in Python terms. + + match base.layout().ty.sty { + ty::Array(elem_ty, len) => { + let elem_layout = fx.layout_of(elem_ty); + let ptr = base.to_addr(fx); + let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx); + CPlace::Addr( + fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + None, + fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), + ) + } + ty::Slice(elem_ty) => { + let elem_layout = fx.layout_of(elem_ty); + let (ptr, len) = base.to_addr_maybe_unsized(fx); + let len = len.unwrap(); + CPlace::Addr( + fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + Some(fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64))), + base.layout(), + ) + } + _ => unreachable!(), + } + } ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant), } } From 89666d9818fab0bf970403d41848c22985f55d76 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Feb 2019 18:15:23 +0100 Subject: [PATCH 0558/1566] Implement CastKind::ClosureFnPointer --- example/mini_core_hello_world.rs | 2 ++ src/base.rs | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index d550ccbf61a24..e07dcf6ba9e7d 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -190,4 +190,6 @@ fn main() { [] => assert_eq!(0u32, 1), [_, ref y..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize), } + + assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); } diff --git a/src/base.rs b/src/base.rs index 6427c756ac880..0c78613c2450c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -586,8 +586,24 @@ fn trans_stmt<'a, 'tcx: 'a>( _ => unimpl!("rval misc {:?} {:?}", from_ty, to_ty), } } - Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => { - unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty) + Rvalue::Cast(CastKind::ClosureFnPointer, operand, _ty) => { + let operand = trans_operand(fx, operand); + match operand.layout().ty.sty { + ty::Closure(def_id, substs) => { + let instance = rustc_mir::monomorphize::resolve_closure( + fx.tcx, + def_id, + substs, + ty::ClosureKind::FnOnce, + ); + let func_ref = fx.get_function_ref(instance); + let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); + lval.write_cvalue(fx, CValue::ByVal(func_addr, lval.layout())); + } + _ => { + bug!("{} cannot be cast to a fn ptr", operand.layout().ty) + } + } } Rvalue::Cast(CastKind::Unsize, operand, _ty) => { let operand = trans_operand(fx, operand); From be377f9eb271e460bec4051dec5b9e3e507d98a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 2 Mar 2019 20:24:39 +0100 Subject: [PATCH 0559/1566] Fix cranelift patch paths --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fd9f438a56a7a..3384436fe998a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,10 +33,10 @@ indexmap = "1.0.2" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] -#cranelift = { path = "../cranelift/lib/umbrella" } -#cranelift-module = { path = "../cranelift/lib/module" } -#cranelift-simplejit = { path = "../cranelift/lib/simplejit" } -#cranelift-faerie = { path = "../cranelift/lib/faerie" } +#cranelift = { path = "../cranelift/cranelift-umbrella" } +#cranelift-module = { path = "../cranelift/cranelift-module" } +#cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } +#cranelift-faerie = { path = "../cranelift/cranelift-faerie" } #[patch."https://github.com/gimli-rs/gimli.git"] #gimli = { path = "../" } From 23a9dcd947ee91af63fd3771ee9b94980d884484 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Feb 2019 17:25:13 +0100 Subject: [PATCH 0560/1566] Make CastKind::Misc handling more clean and general --- src/base.rs | 180 +++++++++++++++++++++------------------------------- 1 file changed, 74 insertions(+), 106 deletions(-) diff --git a/src/base.rs b/src/base.rs index 0c78613c2450c..5e508afc9271f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -466,124 +466,92 @@ fn trans_stmt<'a, 'tcx: 'a>( Rvalue::Cast(CastKind::Misc, operand, to_ty) => { let operand = trans_operand(fx, operand); let from_ty = operand.layout().ty; - match (&from_ty.sty, &to_ty.sty) { - (ty::Ref(..), ty::Ref(..)) - | (ty::Ref(..), ty::RawPtr(..)) - | (ty::RawPtr(..), ty::Ref(..)) - | (ty::RawPtr(..), ty::RawPtr(..)) - | (ty::FnPtr(..), ty::RawPtr(..)) => { - lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); - } - (ty::RawPtr(..), ty::Uint(_)) - | (ty::RawPtr(..), ty::Int(_)) - | (ty::FnPtr(..), ty::Uint(_)) - if to_ty.sty == fx.tcx.types.usize.sty - || to_ty.sty == fx.tcx.types.isize.sty - || fx.clif_type(to_ty).unwrap() == pointer_ty(fx.tcx) => - { - lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); - } - (ty::Uint(_), ty::RawPtr(..)) if from_ty.sty == fx.tcx.types.usize.sty => { - lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); - } - (ty::Int(_), ty::RawPtr(..)) if from_ty.sty == fx.tcx.types.isize.sty => { + + fn is_fat_ptr<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> bool { + ty + .builtin_deref(true) + .map(|ty::TypeAndMut {ty: pointee_ty, mutbl: _ }| fx.layout_of(pointee_ty).is_unsized()) + .unwrap_or(false) + } + + if is_fat_ptr(fx, from_ty) { + if is_fat_ptr(fx, to_ty) { + // fat-ptr -> fat-ptr lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); + } else { + // fat-ptr -> thin-ptr + let (ptr, _extra) = operand.load_value_pair(fx); + lval.write_cvalue(fx, CValue::ByVal(ptr, dest_layout)) } - (ty::Char, ty::Uint(_)) - | (ty::Uint(_), ty::Char) - | (ty::Uint(_), ty::Int(_)) - | (ty::Uint(_), ty::Uint(_)) => { - let from = operand.load_scalar(fx); - let res = crate::common::clif_intcast( - fx, - from, - fx.clif_type(to_ty).unwrap(), - false, - ); - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + } else if let ty::Adt(adt_def, _substs) = from_ty.sty { + // enum -> discriminant value + assert!(adt_def.is_enum()); + match to_ty.sty { + ty::Uint(_) | ty::Int(_) => {}, + _ => unreachable!("cast adt {} -> {}", from_ty, to_ty), } - (ty::Int(_), ty::Int(_)) | (ty::Int(_), ty::Uint(_)) => { - let from = operand.load_scalar(fx); - let res = crate::common::clif_intcast( + + // FIXME avoid forcing to stack + let place = + CPlace::Addr(operand.force_stack(fx), None, operand.layout()); + let discr = trans_get_discriminant(fx, place, fx.layout_of(to_ty)); + lval.write_cvalue(fx, discr); + } else { + let from_clif_ty = fx.clif_type(from_ty).unwrap(); + let to_clif_ty = fx.clif_type(to_ty).unwrap(); + let from = operand.load_scalar(fx); + + let signed = match from_ty.sty { + ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) | ty::Char | ty::Uint(..) | ty::Bool => false, + ty::Int(..) => true, + ty::Float(..) => false, // `signed` is unused for floats + _ => panic!("{}", from_ty), + }; + + let res = if from_clif_ty.is_int() && to_clif_ty.is_int() { + // int-like -> int-like + crate::common::clif_intcast( fx, from, - fx.clif_type(to_ty).unwrap(), - true, - ); - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); - } - (ty::Float(from_flt), ty::Float(to_flt)) => { - let from = operand.load_scalar(fx); - let res = match (from_flt, to_flt) { - (FloatTy::F32, FloatTy::F64) => { - fx.bcx.ins().fpromote(types::F64, from) - } - (FloatTy::F64, FloatTy::F32) => { - fx.bcx.ins().fdemote(types::F32, from) - } - _ => from, - }; - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); - } - (ty::Float(_), ty::Int(_)) => { - let from = operand.load_scalar(fx); - let i_type = fx.clif_type(to_ty).unwrap(); - let res = fx.bcx.ins().fcvt_to_sint_sat(i_type, from); - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); - } - (ty::Float(_), ty::Uint(_)) => { - let from = operand.load_scalar(fx); - let i_type = fx.clif_type(to_ty).unwrap(); - let res = fx.bcx.ins().fcvt_to_uint_sat(i_type, from); - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); - } - (ty::Int(_), ty::Float(_)) => { - let from_ty = fx.clif_type(from_ty).unwrap(); - let from = operand.load_scalar(fx); + to_clif_ty, + signed, + ) + } else if from_clif_ty.is_int() && to_clif_ty.is_float() { + // int-like -> float // FIXME missing encoding for fcvt_from_sint.f32.i8 - let from = if from_ty == types::I8 || from_ty == types::I16 { - fx.bcx.ins().sextend(types::I32, from) - } else { - from - }; - let f_type = fx.clif_type(to_ty).unwrap(); - let res = fx.bcx.ins().fcvt_from_sint(f_type, from); - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); - } - (ty::Uint(_), ty::Float(_)) => { - let from_ty = fx.clif_type(from_ty).unwrap(); - let from = operand.load_scalar(fx); - // FIXME missing encoding for fcvt_from_uint.f32.i8 - let from = if from_ty == types::I8 || from_ty == types::I16 { + let from = if from_clif_ty == types::I8 || from_clif_ty == types::I16 { fx.bcx.ins().uextend(types::I32, from) } else { from }; - let f_type = fx.clif_type(to_ty).unwrap(); - let res = fx.bcx.ins().fcvt_from_uint(f_type, from); - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); - } - (ty::Bool, ty::Uint(_)) | (ty::Bool, ty::Int(_)) => { - let to_ty = fx.clif_type(to_ty).unwrap(); + if signed { + fx.bcx.ins().fcvt_from_sint(to_clif_ty, from) + } else { + fx.bcx.ins().fcvt_from_uint(to_clif_ty, from) + } + } else if from_clif_ty.is_float() && to_clif_ty.is_int() { + // float -> int-like let from = operand.load_scalar(fx); - let res = if to_ty != types::I8 { - fx.bcx.ins().uextend(to_ty, from) + if signed { + fx.bcx.ins().fcvt_to_sint_sat(to_clif_ty, from) } else { - from - }; - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); - } - (ty::Adt(adt_def, _substs), ty::Uint(_)) - | (ty::Adt(adt_def, _substs), ty::Int(_)) - if adt_def.is_enum() => - { - // FIXME avoid forcing to stack - let place = - CPlace::Addr(operand.force_stack(fx), None, operand.layout()); - let discr = trans_get_discriminant(fx, place, fx.layout_of(to_ty)); - lval.write_cvalue(fx, discr); - } - _ => unimpl!("rval misc {:?} {:?}", from_ty, to_ty), + fx.bcx.ins().fcvt_to_uint_sat(to_clif_ty, from) + } + } else if from_clif_ty.is_float() && to_clif_ty.is_float() { + // float -> float + match (from_clif_ty, to_clif_ty) { + (types::F32, types::F64) => { + fx.bcx.ins().fpromote(types::F64, from) + } + (types::F64, types::F32) => { + fx.bcx.ins().fdemote(types::F32, from) + } + _ => from, + } + } else { + unimpl!("rval misc {:?} {:?}", from_ty, to_ty) + }; + lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } } Rvalue::Cast(CastKind::ClosureFnPointer, operand, _ty) => { From e77f1185a1b65a8c802cd84627e70a19f00e7001 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Mar 2019 11:02:32 +0100 Subject: [PATCH 0561/1566] Improve unimpl! docs --- src/unimpl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/unimpl.rs b/src/unimpl.rs index 8333cd1344c79..81fc5b125c497 100644 --- a/src/unimpl.rs +++ b/src/unimpl.rs @@ -14,8 +14,12 @@ thread_local! { } // Just public, because of the unimpl macro +#[doc(hidden)] pub struct NonFatal(pub String); +/// Use when something in the current function is unimplemented. +/// +/// This will emit an error and continue codegen at a different function. pub macro unimpl($($tt:tt)*) { panic!(NonFatal(format!($($tt)*))); } From 57feadcc13bbf32c599e79c811162f576de0efd1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Mar 2019 11:45:52 +0100 Subject: [PATCH 0562/1566] Replace functions taking or returning u128 or i128 with a trap This makes it possible to remove most of 0002-Disable-u128-and-i128-in-libcore.patch. The rest has to be kept because of u128 and i128 only being used in the function body. --- ...002-Disable-u128-and-i128-in-libcore.patch | 969 ------------------ src/base.rs | 77 +- 2 files changed, 67 insertions(+), 979 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 0f4781f24a97c..b4cd2f54be5f2 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -4,843 +4,12 @@ Date: Fri, 1 Mar 2019 18:36:21 +0100 Subject: [PATCH] Disable u128 and i128 in libcore --- - src/libcore/clone.rs | 4 +- - src/libcore/cmp.rs | 6 +- - src/libcore/default.rs | 2 - - src/libcore/fmt/num.rs | 8 +- - src/libcore/hash/mod.rs | 20 ----- - src/libcore/iter/range.rs | 1 - - src/libcore/iter/traits/accum.rs | 2 +- - src/libcore/lib.rs | 2 - - src/libcore/marker.rs | 4 +- - src/libcore/mem.rs | 2 - - src/libcore/num/mod.rs | 100 +++++++------------------ - src/libcore/num/wrapping.rs | 14 ++-- - src/libcore/ops/arith.rs | 22 +++--- - src/libcore/ops/bit.rs | 30 +++----- src/libcore/sync/atomic.rs | 32 -------- src/libcore/time.rs | 123 ------------------------------- - src/libstd/lib.rs | 4 - - src/libstd/net/ip.rs | 42 ----------- src/libstd/num.rs | 2 +- src/libstd/panic.rs | 6 -- 20 files changed, 63 insertions(+), 363 deletions(-) -diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs -index ed90b7d..1739f91 100644 ---- a/src/libcore/clone.rs -+++ b/src/libcore/clone.rs -@@ -173,8 +173,8 @@ mod impls { - } - - impl_clone! { -- usize u8 u16 u32 u64 u128 -- isize i8 i16 i32 i64 i128 -+ usize u8 u16 u32 u64 -+ isize i8 i16 i32 i64 - f32 f64 - bool char - } -diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs -index 81fcdee..749134c 100644 ---- a/src/libcore/cmp.rs -+++ b/src/libcore/cmp.rs -@@ -876,7 +876,7 @@ mod impls { - } - - partial_eq_impl! { -- bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 -+ bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 - } - - macro_rules! eq_impl { -@@ -886,7 +886,7 @@ mod impls { - )*) - } - -- eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+ eq_impl! { () bool char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - macro_rules! partial_ord_impl { - ($($t:ty)*) => ($( -@@ -975,7 +975,7 @@ mod impls { - } - } - -- ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+ ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - #[unstable(feature = "never_type", issue = "35121")] - impl PartialEq for ! { -diff --git a/src/libcore/default.rs b/src/libcore/default.rs -index 5ad05b3..1b5a1d1 100644 ---- a/src/libcore/default.rs -+++ b/src/libcore/default.rs -@@ -135,14 +135,12 @@ default_impl! { u8, 0, "Returns the default value of `0`" } - default_impl! { u16, 0, "Returns the default value of `0`" } - default_impl! { u32, 0, "Returns the default value of `0`" } - default_impl! { u64, 0, "Returns the default value of `0`" } --default_impl! { u128, 0, "Returns the default value of `0`" } - - default_impl! { isize, 0, "Returns the default value of `0`" } - default_impl! { i8, 0, "Returns the default value of `0`" } - default_impl! { i16, 0, "Returns the default value of `0`" } - default_impl! { i32, 0, "Returns the default value of `0`" } - default_impl! { i64, 0, "Returns the default value of `0`" } --default_impl! { i128, 0, "Returns the default value of `0`" } - - default_impl! { f32, 0.0f32, "Returns the default value of `0.0`" } - default_impl! { f64, 0.0f64, "Returns the default value of `0.0`" } -diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs -index b9fa364..cd9ee01 100644 ---- a/src/libcore/fmt/num.rs -+++ b/src/libcore/fmt/num.rs -@@ -17,7 +17,6 @@ trait Int: PartialEq + PartialOrd + Div + Rem + - fn to_u16(&self) -> u16; - fn to_u32(&self) -> u32; - fn to_u64(&self) -> u64; -- fn to_u128(&self) -> u128; - } - - macro_rules! doit { -@@ -28,10 +27,9 @@ macro_rules! doit { - fn to_u16(&self) -> u16 { *self as u16 } - fn to_u32(&self) -> u32 { *self as u32 } - fn to_u64(&self) -> u64 { *self as u64 } -- fn to_u128(&self) -> u128 { *self as u128 } - })*) - } --doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } -+doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - - /// A type that represents a specific radix - #[doc(hidden)] -@@ -176,8 +174,6 @@ integer! { i8, u8 } - integer! { i16, u16 } - integer! { i32, u32 } - integer! { i64, u64 } --integer! { i128, u128 } -- - - static DEC_DIGITS_LUT: &[u8; 200] = - b"0001020304050607080910111213141516171819\ -@@ -274,5 +270,3 @@ mod imp { - impl_Display!(i8, u8, i16, u16, i32, u32, isize, usize as u32 via to_u32 named fmt_u32); - impl_Display!(i64, u64 as u64 via to_u64 named fmt_u64); - } -- --impl_Display!(i128, u128 as u128 via to_u128 named fmt_u128); -diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs -index d5d29c9..f98f382 100644 ---- a/src/libcore/hash/mod.rs -+++ b/src/libcore/hash/mod.rs -@@ -296,12 +296,6 @@ pub trait Hasher { - fn write_u64(&mut self, i: u64) { - self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) }) - } -- /// Writes a single `u128` into this hasher. -- #[inline] -- #[stable(feature = "i128", since = "1.26.0")] -- fn write_u128(&mut self, i: u128) { -- self.write(&unsafe { mem::transmute::<_, [u8; 16]>(i) }) -- } - /// Writes a single `usize` into this hasher. - #[inline] - #[stable(feature = "hasher_write", since = "1.3.0")] -@@ -336,12 +330,6 @@ pub trait Hasher { - fn write_i64(&mut self, i: i64) { - self.write_u64(i as u64) - } -- /// Writes a single `i128` into this hasher. -- #[inline] -- #[stable(feature = "i128", since = "1.26.0")] -- fn write_i128(&mut self, i: i128) { -- self.write_u128(i as u128) -- } - /// Writes a single `isize` into this hasher. - #[inline] - #[stable(feature = "hasher_write", since = "1.3.0")] -@@ -370,9 +358,6 @@ impl Hasher for &mut H { - fn write_u64(&mut self, i: u64) { - (**self).write_u64(i) - } -- fn write_u128(&mut self, i: u128) { -- (**self).write_u128(i) -- } - fn write_usize(&mut self, i: usize) { - (**self).write_usize(i) - } -@@ -388,9 +373,6 @@ impl Hasher for &mut H { - fn write_i64(&mut self, i: i64) { - (**self).write_i64(i) - } -- fn write_i128(&mut self, i: i128) { -- (**self).write_i128(i) -- } - fn write_isize(&mut self, i: isize) { - (**self).write_isize(i) - } -@@ -577,8 +559,6 @@ mod impls { - (i32, write_i32), - (i64, write_i64), - (isize, write_isize), -- (u128, write_u128), -- (i128, write_i128), - } - - #[stable(feature = "rust1", since = "1.0.0")] -diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs -index e7efd97..78e0da7 100644 ---- a/src/libcore/iter/range.rs -+++ b/src/libcore/iter/range.rs -@@ -173,7 +173,6 @@ step_impl_signed!([i64: u64]); - // assume here that it is less than 64-bits. - #[cfg(not(target_pointer_width = "64"))] - step_impl_no_between!(u64 i64); --step_impl_no_between!(u128 i128); - - macro_rules! range_exact_iter_impl { - ($($t:ty)*) => ($( -diff --git a/src/libcore/iter/traits/accum.rs b/src/libcore/iter/traits/accum.rs -index dfe1d2a..06cc578 100644 ---- a/src/libcore/iter/traits/accum.rs -+++ b/src/libcore/iter/traits/accum.rs -@@ -111,7 +111,7 @@ macro_rules! float_sum_product { - )*) - } - --integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } -+integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - float_sum_product! { f32 f64 } - - /// An iterator adapter that produces output as long as the underlying -diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index 9516c02..9d91885 100644 ---- a/src/libcore/lib.rs -+++ b/src/libcore/lib.rs -@@ -148,14 +148,12 @@ mod uint_macros; - #[path = "num/i16.rs"] pub mod i16; - #[path = "num/i32.rs"] pub mod i32; - #[path = "num/i64.rs"] pub mod i64; --#[path = "num/i128.rs"] pub mod i128; - - #[path = "num/usize.rs"] pub mod usize; - #[path = "num/u8.rs"] pub mod u8; - #[path = "num/u16.rs"] pub mod u16; - #[path = "num/u32.rs"] pub mod u32; - #[path = "num/u64.rs"] pub mod u64; --#[path = "num/u128.rs"] pub mod u128; - - #[path = "num/f32.rs"] pub mod f32; - #[path = "num/f64.rs"] pub mod f64; -diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs -index 29606cb..160cca1 100644 ---- a/src/libcore/marker.rs -+++ b/src/libcore/marker.rs -@@ -673,8 +673,8 @@ mod copy_impls { - } - - impl_copy! { -- usize u8 u16 u32 u64 u128 -- isize i8 i16 i32 i64 i128 -+ usize u8 u16 u32 u64 -+ isize i8 i16 i32 i64 - f32 f64 - bool char - } -diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs -index f41d293..71b5e09 100644 ---- a/src/libcore/mem.rs -+++ b/src/libcore/mem.rs -@@ -164,12 +164,10 @@ pub fn forget_unsized(t: T) { - /// u16 | 2 - /// u32 | 4 - /// u64 | 8 --/// u128 | 16 - /// i8 | 1 - /// i16 | 2 - /// i32 | 4 - /// i64 | 8 --/// i128 | 16 - /// f32 | 4 - /// f64 | 8 - /// char | 4 -diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 6708a19..4066b0c 100644 ---- a/src/libcore/num/mod.rs -+++ b/src/libcore/num/mod.rs -@@ -102,13 +102,11 @@ nonzero_integers! { - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU16(u16); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU32(u32); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU64(u64); -- #[stable(feature = "nonzero", since = "1.28.0")] NonZeroU128(u128); - #[stable(feature = "nonzero", since = "1.28.0")] NonZeroUsize(usize); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI8(i8); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI16(i16); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI32(i32); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI64(i64); -- #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroI128(i128); - #[stable(feature = "signed_nonzero", since = "1.34.0")] NonZeroIsize(isize); - } - -@@ -2117,18 +2115,6 @@ impl i64 { - "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } - } - --#[lang = "i128"] --impl i128 { -- int_impl! { i128, i128, u128, 128, -170141183460469231731687303715884105728, -- 170141183460469231731687303715884105727, "", "", 16, -- "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", -- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48", -- "[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \ -- 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", -- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \ -- 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" } --} -- - #[cfg(target_pointer_width = "16")] - #[lang = "isize"] - impl isize { -@@ -4401,17 +4387,6 @@ impl u64 { - "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56]" } - } - --#[lang = "u128"] --impl u128 { -- uint_impl! { u128, u128, 128, 340282366920938463463374607431768211455, "", "", 16, -- "0x13f40000000000000000000000004f76", "0x4f7613f4", "0x12345678901234567890123456789012", -- "0x12907856341290785634129078563412", "0x48091e6a2c48091e6a2c48091e6a2c48", -- "[0x12, 0x90, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, \ -- 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", -- "[0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, \ -- 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12]" } --} -- - #[cfg(target_pointer_width = "16")] - #[lang = "usize"] - impl usize { -@@ -4495,7 +4470,7 @@ macro_rules! from_str_radix_int_impl { - } - )*} - } --from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 } -+from_str_radix_int_impl! { isize i8 i16 i32 i64 usize u8 u16 u32 u64 } - - /// The error type returned when a checked integral type conversion fails. - #[stable(feature = "try_from", since = "1.34.0")] -@@ -4621,30 +4596,25 @@ macro_rules! rev { - try_from_upper_bounded!(u16, u8); - try_from_upper_bounded!(u32, u16, u8); - try_from_upper_bounded!(u64, u32, u16, u8); --try_from_upper_bounded!(u128, u64, u32, u16, u8); - - try_from_both_bounded!(i16, i8); - try_from_both_bounded!(i32, i16, i8); - try_from_both_bounded!(i64, i32, i16, i8); --try_from_both_bounded!(i128, i64, i32, i16, i8); - - // unsigned-to-signed - try_from_upper_bounded!(u8, i8); - try_from_upper_bounded!(u16, i8, i16); - try_from_upper_bounded!(u32, i8, i16, i32); - try_from_upper_bounded!(u64, i8, i16, i32, i64); --try_from_upper_bounded!(u128, i8, i16, i32, i64, i128); - - // signed-to-unsigned --try_from_lower_bounded!(i8, u8, u16, u32, u64, u128); --try_from_lower_bounded!(i16, u16, u32, u64, u128); --try_from_lower_bounded!(i32, u32, u64, u128); --try_from_lower_bounded!(i64, u64, u128); --try_from_lower_bounded!(i128, u128); -+try_from_lower_bounded!(i8, u8, u16, u32, u64); -+try_from_lower_bounded!(i16, u16, u32, u64); -+try_from_lower_bounded!(i32, u32, u64); -+try_from_lower_bounded!(i64, u64); - try_from_both_bounded!(i16, u8); - try_from_both_bounded!(i32, u16, u8); - try_from_both_bounded!(i64, u32, u16, u8); --try_from_both_bounded!(i128, u64, u32, u16, u8); - - // usize/isize - try_from_upper_bounded!(usize, isize); -@@ -4656,21 +4626,21 @@ mod ptr_try_from_impls { - use convert::TryFrom; - - try_from_upper_bounded!(usize, u8); -- try_from_unbounded!(usize, u16, u32, u64, u128); -+ try_from_unbounded!(usize, u16, u32, u64); - try_from_upper_bounded!(usize, i8, i16); -- try_from_unbounded!(usize, i32, i64, i128); -+ try_from_unbounded!(usize, i32, i64); - - try_from_both_bounded!(isize, u8); -- try_from_lower_bounded!(isize, u16, u32, u64, u128); -+ try_from_lower_bounded!(isize, u16, u32, u64); - try_from_both_bounded!(isize, i8); -- try_from_unbounded!(isize, i16, i32, i64, i128); -+ try_from_unbounded!(isize, i16, i32, i64); - -- rev!(try_from_upper_bounded, usize, u32, u64, u128); -+ rev!(try_from_upper_bounded, usize, u32, u64); - rev!(try_from_lower_bounded, usize, i8, i16); -- rev!(try_from_both_bounded, usize, i32, i64, i128); -+ rev!(try_from_both_bounded, usize, i32, i64); - -- rev!(try_from_upper_bounded, isize, u16, u32, u64, u128); -- rev!(try_from_both_bounded, isize, i32, i64, i128); -+ rev!(try_from_upper_bounded, isize, u16, u32, u64); -+ rev!(try_from_both_bounded, isize, i32, i64); - } - - #[cfg(target_pointer_width = "32")] -@@ -4679,24 +4649,24 @@ mod ptr_try_from_impls { - use convert::TryFrom; - - try_from_upper_bounded!(usize, u8, u16); -- try_from_unbounded!(usize, u32, u64, u128); -+ try_from_unbounded!(usize, u32, u64); - try_from_upper_bounded!(usize, i8, i16, i32); -- try_from_unbounded!(usize, i64, i128); -+ try_from_unbounded!(usize, i64); - - try_from_both_bounded!(isize, u8, u16); -- try_from_lower_bounded!(isize, u32, u64, u128); -+ try_from_lower_bounded!(isize, u32, u64); - try_from_both_bounded!(isize, i8, i16); -- try_from_unbounded!(isize, i32, i64, i128); -+ try_from_unbounded!(isize, i32, i64); - - rev!(try_from_unbounded, usize, u32); -- rev!(try_from_upper_bounded, usize, u64, u128); -+ rev!(try_from_upper_bounded, usize, u64); - rev!(try_from_lower_bounded, usize, i8, i16, i32); -- rev!(try_from_both_bounded, usize, i64, i128); -+ rev!(try_from_both_bounded, usize, i64); - - rev!(try_from_unbounded, isize, u16); -- rev!(try_from_upper_bounded, isize, u32, u64, u128); -+ rev!(try_from_upper_bounded, isize, u32, u64); - rev!(try_from_unbounded, isize, i32); -- rev!(try_from_both_bounded, isize, i64, i128); -+ rev!(try_from_both_bounded, isize, i64); - } - - #[cfg(target_pointer_width = "64")] -@@ -4705,24 +4675,20 @@ mod ptr_try_from_impls { - use convert::TryFrom; - - try_from_upper_bounded!(usize, u8, u16, u32); -- try_from_unbounded!(usize, u64, u128); -+ try_from_unbounded!(usize, u64); - try_from_upper_bounded!(usize, i8, i16, i32, i64); -- try_from_unbounded!(usize, i128); - - try_from_both_bounded!(isize, u8, u16, u32); -- try_from_lower_bounded!(isize, u64, u128); -+ try_from_lower_bounded!(isize, u64); - try_from_both_bounded!(isize, i8, i16, i32); -- try_from_unbounded!(isize, i64, i128); -+ try_from_unbounded!(isize, i64); - - rev!(try_from_unbounded, usize, u32, u64); -- rev!(try_from_upper_bounded, usize, u128); - rev!(try_from_lower_bounded, usize, i8, i16, i32, i64); -- rev!(try_from_both_bounded, usize, i128); - - rev!(try_from_unbounded, isize, u16, u32); -- rev!(try_from_upper_bounded, isize, u64, u128); -+ rev!(try_from_upper_bounded, isize, u64); - rev!(try_from_unbounded, isize, i32, i64); -- rev!(try_from_both_bounded, isize, i128); - } - - #[doc(hidden)] -@@ -4757,7 +4723,7 @@ macro_rules! doit { - } - })*) - } --doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize } -+doit! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize } - - fn from_str_radix(src: &str, radix: u32) -> Result { - use self::IntErrorKind::*; -@@ -4948,52 +4914,38 @@ impl_from_bool! { u8, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { u16, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { u32, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { u64, #[stable(feature = "from_bool", since = "1.28.0")] } --impl_from_bool! { u128, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { usize, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { i8, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { i16, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { i32, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { i64, #[stable(feature = "from_bool", since = "1.28.0")] } --impl_from_bool! { i128, #[stable(feature = "from_bool", since = "1.28.0")] } - impl_from_bool! { isize, #[stable(feature = "from_bool", since = "1.28.0")] } - - // Unsigned -> Unsigned - impl_from! { u8, u16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { u8, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { u8, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { u8, u128, #[stable(feature = "i128", since = "1.26.0")] } - impl_from! { u8, usize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { u16, u32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { u16, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { u16, u128, #[stable(feature = "i128", since = "1.26.0")] } - impl_from! { u32, u64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { u32, u128, #[stable(feature = "i128", since = "1.26.0")] } --impl_from! { u64, u128, #[stable(feature = "i128", since = "1.26.0")] } - - // Signed -> Signed - impl_from! { i8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { i8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { i8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { i8, i128, #[stable(feature = "i128", since = "1.26.0")] } - impl_from! { i8, isize, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { i16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { i16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { i16, i128, #[stable(feature = "i128", since = "1.26.0")] } - impl_from! { i32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { i32, i128, #[stable(feature = "i128", since = "1.26.0")] } --impl_from! { i64, i128, #[stable(feature = "i128", since = "1.26.0")] } - - // Unsigned -> Signed - impl_from! { u8, i16, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { u8, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { u8, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { u8, i128, #[stable(feature = "i128", since = "1.26.0")] } - impl_from! { u16, i32, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } - impl_from! { u16, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { u16, i128, #[stable(feature = "i128", since = "1.26.0")] } - impl_from! { u32, i64, #[stable(feature = "lossless_int_conv", since = "1.5.0")] } --impl_from! { u32, i128, #[stable(feature = "i128", since = "1.26.0")] } --impl_from! { u64, i128, #[stable(feature = "i128", since = "1.26.0")] } - - // The C99 standard defines bounds on INTPTR_MIN, INTPTR_MAX, and UINTPTR_MAX - // which imply that pointer-sized integers must be at least 16 bits: -diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs -index 9cd5108..26c8abc 100644 ---- a/src/libcore/num/wrapping.rs -+++ b/src/libcore/num/wrapping.rs -@@ -102,19 +102,17 @@ macro_rules! sh_impl_all { - //sh_impl_unsigned! { $t, u16 } - //sh_impl_unsigned! { $t, u32 } - //sh_impl_unsigned! { $t, u64 } -- //sh_impl_unsigned! { $t, u128 } - sh_impl_unsigned! { $t, usize } - - //sh_impl_signed! { $t, i8 } - //sh_impl_signed! { $t, i16 } - //sh_impl_signed! { $t, i32 } - //sh_impl_signed! { $t, i64 } -- //sh_impl_signed! { $t, i128 } - //sh_impl_signed! { $t, isize } - )*) - } - --sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } -+sh_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - - // FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping - macro_rules! wrapping_impl { -@@ -313,7 +311,7 @@ macro_rules! wrapping_impl { - )*) - } - --wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - macro_rules! wrapping_int_impl { - ($($t:ty)*) => ($( -@@ -677,7 +675,7 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39)); - )*) - } - --wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+wrapping_int_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - macro_rules! wrapping_int_impl_signed { - ($($t:ty)*) => ($( -@@ -806,7 +804,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative()); - )*) - } - --wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 } -+wrapping_int_impl_signed! { isize i8 i16 i32 i64 } - - macro_rules! wrapping_int_impl_unsigned { - ($($t:ty)*) => ($( -@@ -883,7 +881,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0)); - )*) - } - --wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 u128 } -+wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 } - - mod shift_max { - #![allow(non_upper_case_globals)] -@@ -910,13 +908,11 @@ mod shift_max { - pub const i16: u32 = (1 << 4) - 1; - pub const i32: u32 = (1 << 5) - 1; - pub const i64: u32 = (1 << 6) - 1; -- pub const i128: u32 = (1 << 7) - 1; - pub use self::platform::isize; - - pub const u8: u32 = i8; - pub const u16: u32 = i16; - pub const u32: u32 = i32; - pub const u64: u32 = i64; -- pub const u128: u32 = i128; - pub use self::platform::usize; - } -diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs -index 0252ede..cb8ab3d 100644 ---- a/src/libcore/ops/arith.rs -+++ b/src/libcore/ops/arith.rs -@@ -104,7 +104,7 @@ macro_rules! add_impl { - )*) - } - --add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - - /// The subtraction operator `-`. - /// -@@ -202,7 +202,7 @@ macro_rules! sub_impl { - )*) - } - --sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+sub_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - - /// The multiplication operator `*`. - /// -@@ -322,7 +322,7 @@ macro_rules! mul_impl { - )*) - } - --mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+mul_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - - /// The division operator `/`. - /// -@@ -447,7 +447,7 @@ macro_rules! div_impl_integer { - )*) - } - --div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+div_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - macro_rules! div_impl_float { - ($($t:ty)*) => ($( -@@ -532,7 +532,7 @@ macro_rules! rem_impl_integer { - )*) - } - --rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - - macro_rules! rem_impl_float { -@@ -631,7 +631,7 @@ macro_rules! neg_impl_unsigned { - } - - // neg_impl_unsigned! { usize u8 u16 u32 u64 } --neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } -+neg_impl_numeric! { isize i8 i16 i32 i64 f32 f64 } - - /// The addition assignment operator `+=`. - /// -@@ -687,7 +687,7 @@ macro_rules! add_assign_impl { - )+) - } - --add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - - /// The subtraction assignment operator `-=`. - /// -@@ -743,7 +743,7 @@ macro_rules! sub_assign_impl { - )+) - } - --sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - - /// The multiplication assignment operator `*=`. - /// -@@ -790,7 +790,7 @@ macro_rules! mul_assign_impl { - )+) - } - --mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - - /// The division assignment operator `/=`. - /// -@@ -836,7 +836,7 @@ macro_rules! div_assign_impl { - )+) - } - --div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } - - /// The remainder assignment operator `%=`. - /// -@@ -886,4 +886,4 @@ macro_rules! rem_assign_impl { - )+) - } - --rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } -+rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } -diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs -index 2c9bf24..af2ab6f 100644 ---- a/src/libcore/ops/bit.rs -+++ b/src/libcore/ops/bit.rs -@@ -55,7 +55,7 @@ macro_rules! not_impl { - )*) - } - --not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+not_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - /// The bitwise AND operator `&`. - /// -@@ -139,7 +139,7 @@ macro_rules! bitand_impl { - )*) - } - --bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+bitand_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - /// The bitwise OR operator `|`. - /// -@@ -223,7 +223,7 @@ macro_rules! bitor_impl { - )*) - } - --bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+bitor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - /// The bitwise XOR operator `^`. - /// -@@ -310,7 +310,7 @@ macro_rules! bitxor_impl { - )*) - } - --bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+bitxor_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - /// The left shift operator `<<`. Note that because this trait is implemented - /// for all integer types with multiple right-hand-side types, Rust's type -@@ -407,19 +407,17 @@ macro_rules! shl_impl_all { - shl_impl! { $t, u16 } - shl_impl! { $t, u32 } - shl_impl! { $t, u64 } -- shl_impl! { $t, u128 } - shl_impl! { $t, usize } - - shl_impl! { $t, i8 } - shl_impl! { $t, i16 } - shl_impl! { $t, i32 } - shl_impl! { $t, i64 } -- shl_impl! { $t, i128 } - shl_impl! { $t, isize } - )*) - } - --shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } -+shl_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - - /// The right shift operator `>>`. Note that because this trait is implemented - /// for all integer types with multiple right-hand-side types, Rust's type -@@ -516,19 +514,17 @@ macro_rules! shr_impl_all { - shr_impl! { $t, u16 } - shr_impl! { $t, u32 } - shr_impl! { $t, u64 } -- shr_impl! { $t, u128 } - shr_impl! { $t, usize } - - shr_impl! { $t, i8 } - shr_impl! { $t, i16 } - shr_impl! { $t, i32 } - shr_impl! { $t, i64 } -- shr_impl! { $t, i128 } - shr_impl! { $t, isize } - )*) - } - --shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } -+shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - - /// The bitwise AND assignment operator `&=`. - /// -@@ -616,7 +612,7 @@ macro_rules! bitand_assign_impl { - )+) - } - --bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - /// The bitwise OR assignment operator `|=`. - /// -@@ -665,7 +661,7 @@ macro_rules! bitor_assign_impl { - )+) - } - --bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - /// The bitwise XOR assignment operator `^=`. - /// -@@ -714,7 +710,7 @@ macro_rules! bitxor_assign_impl { - )+) - } - --bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } -+bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } - - /// The left shift assignment operator `<<=`. - /// -@@ -770,19 +766,17 @@ macro_rules! shl_assign_impl_all { - shl_assign_impl! { $t, u16 } - shl_assign_impl! { $t, u32 } - shl_assign_impl! { $t, u64 } -- shl_assign_impl! { $t, u128 } - shl_assign_impl! { $t, usize } - - shl_assign_impl! { $t, i8 } - shl_assign_impl! { $t, i16 } - shl_assign_impl! { $t, i32 } - shl_assign_impl! { $t, i64 } -- shl_assign_impl! { $t, i128 } - shl_assign_impl! { $t, isize } - )*) - } - --shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } -+shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } - - /// The right shift assignment operator `>>=`. - /// -@@ -838,16 +832,14 @@ macro_rules! shr_assign_impl_all { - shr_assign_impl! { $t, u16 } - shr_assign_impl! { $t, u32 } - shr_assign_impl! { $t, u64 } -- shr_assign_impl! { $t, u128 } - shr_assign_impl! { $t, usize } - - shr_assign_impl! { $t, i8 } - shr_assign_impl! { $t, i16 } - shr_assign_impl! { $t, i32 } - shr_assign_impl! { $t, i64 } -- shr_assign_impl! { $t, i128 } - shr_assign_impl! { $t, isize } - )*) - } - --shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } -+shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index d0ee5fa..d02c454 100644 --- a/src/libcore/sync/atomic.rs @@ -888,69 +57,6 @@ diff --git a/src/libcore/time.rs b/src/libcore/time.rs index 91161ca..759497f 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs -@@ -21,7 +21,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000; - const NANOS_PER_MICRO: u32 = 1_000; - const MILLIS_PER_SEC: u64 = 1_000; - const MICROS_PER_SEC: u64 = 1_000_000; --const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; - - /// A `Duration` type to represent a span of time, typically used for system - /// timeouts. -@@ -312,54 +311,6 @@ impl Duration { - #[inline] - pub const fn subsec_nanos(&self) -> u32 { self.nanos } - -- /// Returns the total number of whole milliseconds contained by this `Duration`. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::time::Duration; -- /// -- /// let duration = Duration::new(5, 730023852); -- /// assert_eq!(duration.as_millis(), 5730); -- /// ``` -- #[stable(feature = "duration_as_u128", since = "1.33.0")] -- #[inline] -- pub const fn as_millis(&self) -> u128 { -- self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128 -- } -- -- /// Returns the total number of whole microseconds contained by this `Duration`. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::time::Duration; -- /// -- /// let duration = Duration::new(5, 730023852); -- /// assert_eq!(duration.as_micros(), 5730023); -- /// ``` -- #[stable(feature = "duration_as_u128", since = "1.33.0")] -- #[inline] -- pub const fn as_micros(&self) -> u128 { -- self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128 -- } -- -- /// Returns the total number of nanoseconds contained by this `Duration`. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::time::Duration; -- /// -- /// let duration = Duration::new(5, 730023852); -- /// assert_eq!(duration.as_nanos(), 5730023852); -- /// ``` -- #[stable(feature = "duration_as_u128", since = "1.33.0")] -- #[inline] -- pub const fn as_nanos(&self) -> u128 { -- self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128 -- } -- - /// Checked `Duration` addition. Computes `self + other`, returning [`None`] - /// if overflow occurred. - /// @@ -518,80 +469,6 @@ impl Duration { (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) } @@ -1032,81 +138,6 @@ index 91161ca..759497f 100644 /// Divide `Duration` by `Duration` and return `f64`. /// /// # Examples -diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 2b62b5b..c6515bc 100644 ---- a/src/libstd/lib.rs -+++ b/src/libstd/lib.rs -@@ -393,8 +393,6 @@ pub use core::i16; - pub use core::i32; - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::i64; --#[stable(feature = "i128", since = "1.26.0")] --pub use core::i128; - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::usize; - #[stable(feature = "rust1", since = "1.0.0")] -@@ -427,8 +425,6 @@ pub use alloc_crate::string; - pub use alloc_crate::vec; - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::char; --#[stable(feature = "i128", since = "1.26.0")] --pub use core::u128; - #[stable(feature = "core_hint", since = "1.27.0")] - pub use core::hint; - -diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs -index fa256ce..42b0aa2 100644 ---- a/src/libstd/net/ip.rs -+++ b/src/libstd/net/ip.rs -@@ -1391,48 +1391,6 @@ impl FromInner for Ipv6Addr { - } - } - --#[stable(feature = "i128", since = "1.26.0")] --impl From for u128 { -- /// Convert an `Ipv6Addr` into a host byte order `u128`. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::net::Ipv6Addr; -- /// -- /// let addr = Ipv6Addr::new( -- /// 0x1020, 0x3040, 0x5060, 0x7080, -- /// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D, -- /// ); -- /// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr)); -- /// ``` -- fn from(ip: Ipv6Addr) -> u128 { -- let ip = ip.octets(); -- u128::from_be_bytes(ip) -- } --} --#[stable(feature = "i128", since = "1.26.0")] --impl From for Ipv6Addr { -- /// Convert a host byte order `u128` into an `Ipv6Addr`. -- /// -- /// # Examples -- /// -- /// ``` -- /// use std::net::Ipv6Addr; -- /// -- /// let addr = Ipv6Addr::from(0x102030405060708090A0B0C0D0E0F00D_u128); -- /// assert_eq!( -- /// Ipv6Addr::new( -- /// 0x1020, 0x3040, 0x5060, 0x7080, -- /// 0x90A0, 0xB0C0, 0xD0E0, 0xF00D, -- /// ), -- /// addr); -- /// ``` -- fn from(ip: u128) -> Ipv6Addr { -- Ipv6Addr::from(ip.to_be_bytes()) -- } --} -- - #[stable(feature = "ipv6_from_octets", since = "1.9.0")] - impl From<[u8; 16]> for Ipv6Addr { - fn from(octets: [u8; 16]) -> Ipv6Addr { diff --git a/src/libstd/num.rs b/src/libstd/num.rs index 828d572..bc04fb1 100644 --- a/src/libstd/num.rs diff --git a/src/base.rs b/src/base.rs index 5e508afc9271f..e41d8934c4f42 100644 --- a/src/base.rs +++ b/src/base.rs @@ -64,7 +64,64 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 1. Get mir let mir = tcx.instance_mir(instance.def); - // Step 2. Declare function + // Step 2. Check fn sig for u128 and i128 and replace those functions with a trap. + { + // Step 2a. Check sig for u128 and i128 + let fn_ty = instance.ty(tcx); + let fn_sig = crate::abi::ty_fn_sig(tcx, fn_ty); + + struct UI128Visitor<'a, 'tcx: 'a>(TyCtxt<'a, 'tcx, 'tcx>, bool); + + impl<'a, 'tcx: 'a> rustc::ty::fold::TypeVisitor<'tcx> for UI128Visitor<'a, 'tcx> { + fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { + if t.sty == self.0.types.u128.sty || t.sty == self.0.types.i128.sty { + self.1 = true; + return false; // stop visiting + } + + t.super_visit_with(self) + } + } + + let mut visitor = UI128Visitor(tcx, false); + fn_sig.visit_with(&mut visitor); + + // Step 2b. If found replace function with a trap. + if visitor.1 { + tcx.sess.warn("u128 and i128 are not yet supported. \ + Functions using these as args will be replaced with a trap."); + + // Step 2b1. Declare function with fake signature + let sig = Signature { + params: vec![AbiParam::new(types::INVALID)], + returns: vec![], + call_conv: CallConv::Fast, + }; + let name = tcx.symbol_name(instance).as_str(); + let func_id = cx.module.declare_function(&*name, linkage, &sig).unwrap(); + + // Step 2b2. Create trapping function + let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); + let start_ebb = bcx.create_ebb(); + bcx.append_ebb_params_for_function_params(start_ebb); + bcx.switch_to_block(start_ebb); + crate::trap::trap_unreachable(&mut bcx); + bcx.seal_all_blocks(); + bcx.finalize(); + + // Step 2b3. Define function + cx.caches.context.func = func; + cx.module + .define_function(func_id, &mut cx.caches.context) + .unwrap(); + cx.caches.context.clear(); + return; + } + } + + // Step 3. Declare function let (name, sig) = get_function_name_and_sig(tcx, instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); let mut debug_context = cx @@ -72,19 +129,19 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( .as_mut() .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig)); - // Step 3. Make FunctionBuilder + // Step 4. Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); - // Step 4. Predefine ebb's + // Step 5. Predefine ebb's let start_ebb = bcx.create_ebb(); let mut ebb_map: HashMap = HashMap::new(); for (bb, _bb_data) in mir.basic_blocks().iter_enumerated() { ebb_map.insert(bb, bcx.create_ebb()); } - // Step 5. Make FunctionCx + // Step 6. Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance); @@ -106,34 +163,34 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( source_info_set: indexmap::IndexSet::new(), }; - // Step 6. Codegen function + // Step 7. Codegen function with_unimpl_span(fx.mir.span, || { crate::abi::codegen_fn_prelude(&mut fx, start_ebb); codegen_fn_content(&mut fx); }); let source_info_set = fx.source_info_set.clone(); - // Step 7. Write function to file for debugging + // Step 8. Write function to file for debugging #[cfg(debug_assertions)] fx.write_clif_file(); - // Step 8. Verify function + // Step 9. Verify function verify_func(tcx, fx.clif_comments, &func); - // Step 9. Define function + // Step 10. Define function cx.caches.context.func = func; cx.module .define_function(func_id, &mut cx.caches.context) .unwrap(); - // Step 10. Define debuginfo for function + // Step 11. Define debuginfo for function let context = &cx.caches.context; let isa = cx.module.isa(); debug_context .as_mut() .map(|x| x.define(tcx, context, isa, &source_info_set)); - // Step 11. Clear context to make it usable for the next function + // Step 12. Clear context to make it usable for the next function cx.caches.context.clear(); } From 2ce5387b7c58a241d6b4929b9b8bd9078a7c73be Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 2 Mar 2019 21:09:28 +0100 Subject: [PATCH 0563/1566] Rename load_value_pair to load_scalar_pair and fix dynamic dispatch with arbitrary self types --- ...itrary_self_types_pointers_and_wrappers.rs | 83 +++++++++++++++++++ example/mini_core.rs | 25 ++++++ src/base.rs | 6 +- src/common.rs | 32 +++---- src/intrinsics.rs | 4 +- src/unsize.rs | 2 +- src/vtable.rs | 9 +- test.sh | 4 + 8 files changed, 135 insertions(+), 30 deletions(-) create mode 100644 example/arbitrary_self_types_pointers_and_wrappers.rs diff --git a/example/arbitrary_self_types_pointers_and_wrappers.rs b/example/arbitrary_self_types_pointers_and_wrappers.rs new file mode 100644 index 0000000000000..5e7d476217964 --- /dev/null +++ b/example/arbitrary_self_types_pointers_and_wrappers.rs @@ -0,0 +1,83 @@ +// Adapted from rustc run-pass test suite + +#![feature(no_core, arbitrary_self_types, box_syntax)] +#![feature(rustc_attrs)] + +#![feature(start, lang_items)] +#![no_core] + +extern crate mini_core; + +use mini_core::*; +use mini_core::libc::*; + +macro_rules! assert_eq { + ($l:expr, $r: expr) => { + if $l != $r { + panic(&(stringify!($l != $r), file!(), line!(), 0)); + } + } +} + +struct Ptr(Box); + +impl Deref for Ptr { + type Target = T; + + fn deref(&self) -> &T { + &*self.0 + } +} + +impl + ?Sized, U: ?Sized> CoerceUnsized> for Ptr {} +impl + ?Sized, U: ?Sized> DispatchFromDyn> for Ptr {} + +struct Wrapper(T); + +impl Deref for Wrapper { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } +} + +impl, U> CoerceUnsized> for Wrapper {} +impl, U> DispatchFromDyn> for Wrapper {} + + +trait Trait { + // This method isn't object-safe yet. Unsized by-value `self` is object-safe (but not callable + // without unsized_locals), but wrappers arond `Self` currently are not. + // FIXME (mikeyhew) uncomment this when unsized rvalues object-safety is implemented + // fn wrapper(self: Wrapper) -> i32; + fn ptr_wrapper(self: Ptr>) -> i32; + fn wrapper_ptr(self: Wrapper>) -> i32; + fn wrapper_ptr_wrapper(self: Wrapper>>) -> i32; +} + +impl Trait for i32 { + fn ptr_wrapper(self: Ptr>) -> i32 { + **self + } + fn wrapper_ptr(self: Wrapper>) -> i32 { + **self + } + fn wrapper_ptr_wrapper(self: Wrapper>>) -> i32 { + ***self + } +} + +#[start] +fn main(_: isize, _: *const *const u8) -> isize { + let pw = Ptr(box Wrapper(5)) as Ptr>; + assert_eq!(pw.ptr_wrapper(), 5); + + let wp = Wrapper(Ptr(box 6)) as Wrapper>; + assert_eq!(wp.wrapper_ptr(), 6); + + let wpw = Wrapper(Ptr(box Wrapper(7))) as Wrapper>>; + assert_eq!(wpw.wrapper_ptr_wrapper(), 7); + + 0 +} diff --git a/example/mini_core.rs b/example/mini_core.rs index 1045e7f0cec59..ffc2cd8fb65a0 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -27,6 +27,7 @@ impl<'a, T: ?Sized+Unsize, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut impl, U: ?Sized> DispatchFromDyn<*const U> for *const T {} // *mut T -> *mut U impl, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {} +impl, U: ?Sized> DispatchFromDyn> for Box {} #[lang = "receiver"] pub trait Receiver {} @@ -216,6 +217,15 @@ impl PartialEq for usize { } } +impl PartialEq for i32 { + fn eq(&self, other: &i32) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &i32) -> bool { + (*self) != (*other) + } +} + impl PartialEq for isize { fn eq(&self, other: &isize) -> bool { (*self) == (*other) @@ -306,6 +316,13 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { drop_in_place(to_drop); } +#[lang = "deref"] +pub trait Deref { + type Target: ?Sized; + + fn deref(&self) -> &Self::Target; +} + #[lang = "owned_box"] pub struct Box(*mut T); @@ -317,6 +334,14 @@ impl Drop for Box { } } +impl Deref for Box { + type Target = T; + + fn deref(&self) -> &Self::Target { + &**self + } +} + #[lang = "exchange_malloc"] // Make it available to jited mini_core_hello_world // FIXME remove next line when jit supports linking rlibs diff --git a/src/base.rs b/src/base.rs index e41d8934c4f42..b816eab469417 100644 --- a/src/base.rs +++ b/src/base.rs @@ -537,7 +537,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); } else { // fat-ptr -> thin-ptr - let (ptr, _extra) = operand.load_value_pair(fx); + let (ptr, _extra) = operand.load_scalar_pair(fx); lval.write_cvalue(fx, CValue::ByVal(ptr, dest_layout)) } } else if let ty::Adt(adt_def, _substs) = from_ty.sty { @@ -1101,8 +1101,8 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( Offset (_) bug; // Handled above } } else { - let (lhs_ptr, lhs_extra) = lhs.load_value_pair(fx); - let (rhs_ptr, rhs_extra) = rhs.load_value_pair(fx); + let (lhs_ptr, lhs_extra) = lhs.load_scalar_pair(fx); + let (rhs_ptr, rhs_extra) = rhs.load_scalar_pair(fx); let res = match bin_op { BinOp::Eq => { let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); diff --git a/src/common.rs b/src/common.rs index 1faa6a8514c94..6da473bcbefe3 100644 --- a/src/common.rs +++ b/src/common.rs @@ -166,33 +166,33 @@ impl<'tcx> CValue<'tcx> { fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) } CValue::ByVal(value, _layout) => value, - CValue::ByValPair(_, _, _layout) => bug!("Please use load_value_pair for ByValPair"), + CValue::ByValPair(_, _, _layout) => bug!("Please use load_scalar_pair for ByValPair"), } } - pub fn load_value_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> (Value, Value) + /// Load a value pair with layout.abi of scalar pair + pub fn load_scalar_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> (Value, Value) where 'tcx: 'a, { match self { CValue::ByRef(addr, layout) => { - assert_eq!( - layout.size.bytes(), - fx.tcx.data_layout.pointer_size.bytes() * 2 + let (a, b) = match &layout.abi { + layout::Abi::ScalarPair(a, b) => (a.clone(), b.clone()), + _ => unreachable!(), + }; + let clif_ty1 = crate::abi::scalar_to_clif_type(fx.tcx, a.clone()); + let clif_ty2 = crate::abi::scalar_to_clif_type(fx.tcx, b); + let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); + let val2 = fx.bcx.ins().load( + clif_ty2, + MemFlags::new(), + addr, + a.value.size(&fx.tcx).bytes() as i32, ); - let val1_offset = layout.fields.offset(0).bytes() as i32; - let val2_offset = layout.fields.offset(1).bytes() as i32; - let val1 = fx - .bcx - .ins() - .load(fx.pointer_type, MemFlags::new(), addr, val1_offset); - let val2 = fx - .bcx - .ins() - .load(fx.pointer_type, MemFlags::new(), addr, val2_offset); (val1, val2) } - CValue::ByVal(_, _layout) => bug!("Please use load_value for ByVal"), + CValue::ByVal(_, _layout) => bug!("Please use load_scalar for ByVal"), CValue::ByValPair(val1, val2, _layout) => (val1, val2), } } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index c57c9d8cb9dba..ba3e69857bba4 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -156,7 +156,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( size_of_val, (c ptr) { let layout = fx.layout_of(T); let size = if layout.is_unsized() { - let (_ptr, info) = ptr.load_value_pair(fx); + let (_ptr, info) = ptr.load_scalar_pair(fx); let (size, _align) = crate::unsize::size_and_align_of_dst(fx, layout.ty, info); size } else { @@ -175,7 +175,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( min_align_of_val, (c ptr) { let layout = fx.layout_of(T); let align = if layout.is_unsized() { - let (_ptr, info) = ptr.load_value_pair(fx); + let (_ptr, info) = ptr.load_scalar_pair(fx); let (_size, align) = crate::unsize::size_and_align_of_dst(fx, layout.ty, info); align } else { diff --git a/src/unsize.rs b/src/unsize.rs index 09dead7e85e84..627199ddab6c3 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -96,7 +96,7 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a>( { // fat-ptr to fat-ptr unsize preserves the vtable // i.e., &'a fmt::Debug+Send => &'a fmt::Debug - src.load_value_pair(fx) + src.load_scalar_pair(fx) } else { let base = src.load_scalar(fx); unsize_thin_ptr(fx, base, src_ty, dst_ty) diff --git a/src/vtable.rs b/src/vtable.rs index d525f939120ac..6cfd59dcd0894 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -50,14 +50,7 @@ pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( arg: CValue<'tcx>, idx: usize, ) -> (Value, Value) { - let arg = if arg.layout().ty.is_box() { - // Cast `Box` to `*mut T` so `load_value_pair` works - arg.unchecked_cast_to(fx.layout_of(fx.tcx.mk_mut_ptr(arg.layout().ty.boxed_ty()))) - } else { - arg - }; - - let (ptr, vtable) = arg.load_value_pair(fx); + let (ptr, vtable) = arg.load_scalar_pair(fx); let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( pointer_ty(fx.tcx), diff --git a/test.sh b/test.sh index 0ea592778181a..5653caee16241 100755 --- a/test.sh +++ b/test.sh @@ -17,6 +17,10 @@ echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin ./target/out/mini_core_hello_world abc bcd +echo "[AOT] arbitrary_self_types_pointers_and_wrappers" +$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin +./target/out/arbitrary_self_types_pointers_and_wrappers + echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh From c2095c4afee993d0c8b06d52717dd7275858fbdf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 4 Mar 2019 18:57:09 +0100 Subject: [PATCH 0564/1566] Rustup to rustc 1.35.0-nightly (87a436377 2019-03-03) --- ...ng-saturating_-add-sub-intrinsic-imp.patch | 166 ------------------ src/base.rs | 3 +- src/intrinsics.rs | 31 ++++ 3 files changed, 33 insertions(+), 167 deletions(-) delete mode 100644 patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch diff --git a/patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch b/patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch deleted file mode 100644 index 9d6221b426ba2..0000000000000 --- a/patches/0009-Workaround-missing-saturating_-add-sub-intrinsic-imp.patch +++ /dev/null @@ -1,166 +0,0 @@ -From a84d00b816c1b771f3990ad5f7ba78981ab9c151 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Wed, 13 Feb 2019 14:54:20 +0100 -Subject: [PATCH] Workaround missing saturating_{add,sub} intrinsic impl - ---- - src/libcore/num/mod.rs | 94 -------------------------------------------------- - 1 file changed, 94 deletions(-) - -diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 4871b2e..5d5cd61 100644 ---- a/src/libcore/num/mod.rs -+++ b/src/libcore/num/mod.rs -@@ -880,7 +880,6 @@ $EndFeature, " - ```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] -- #[cfg(stage0)] - pub fn saturating_add(self, rhs: Self) -> Self { - match self.checked_add(rhs) { - Some(x) => x, -@@ -892,30 +891,6 @@ $EndFeature, " - } - - doc_comment! { -- concat!("Saturating integer addition. Computes `self + rhs`, saturating at the numeric --bounds instead of overflowing. -- --# Examples -- --Basic usage: -- --``` --", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); --assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT), --"::max_value());", --$EndFeature, " --```"), -- -- #[stable(feature = "rust1", since = "1.0.0")] -- #[rustc_const_unstable(feature = "const_saturating_int_methods")] -- #[inline] -- #[cfg(not(stage0))] -- pub const fn saturating_add(self, rhs: Self) -> Self { -- intrinsics::saturating_add(self, rhs) -- } -- } -- -- doc_comment! { - concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the - numeric bounds instead of overflowing. - -@@ -931,7 +906,6 @@ $EndFeature, " - ```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] -- #[cfg(stage0)] - pub fn saturating_sub(self, rhs: Self) -> Self { - match self.checked_sub(rhs) { - Some(x) => x, -@@ -942,29 +916,6 @@ $EndFeature, " - } - - doc_comment! { -- concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the --numeric bounds instead of overflowing. -- --# Examples -- --Basic usage: -- --``` --", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27); --assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT), --"::min_value());", --$EndFeature, " --```"), -- #[stable(feature = "rust1", since = "1.0.0")] -- #[rustc_const_unstable(feature = "const_saturating_int_methods")] -- #[inline] -- #[cfg(not(stage0))] -- pub const fn saturating_sub(self, rhs: Self) -> Self { -- intrinsics::saturating_sub(self, rhs) -- } -- } -- -- doc_comment! { - concat!("Saturating integer multiplication. Computes `self * rhs`, saturating at the - numeric bounds instead of overflowing. - -@@ -2779,7 +2730,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " - ```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] -- #[cfg(stage0)] - pub fn saturating_add(self, rhs: Self) -> Self { - match self.checked_add(rhs) { - Some(x) => x, -@@ -2789,28 +2739,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " - } - - doc_comment! { -- concat!("Saturating integer addition. Computes `self + rhs`, saturating at --the numeric bounds instead of overflowing. -- --# Examples -- --Basic usage: -- --``` --", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); --assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " --```"), -- -- #[stable(feature = "rust1", since = "1.0.0")] -- #[rustc_const_unstable(feature = "const_saturating_int_methods")] -- #[inline] -- #[cfg(not(stage0))] -- pub const fn saturating_add(self, rhs: Self) -> Self { -- intrinsics::saturating_add(self, rhs) -- } -- } -- -- doc_comment! { - concat!("Saturating integer subtraction. Computes `self - rhs`, saturating - at the numeric bounds instead of overflowing. - -@@ -2824,7 +2752,6 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " - ```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] -- #[cfg(stage0)] - pub fn saturating_sub(self, rhs: Self) -> Self { - match self.checked_sub(rhs) { - Some(x) => x, -@@ -2834,27 +2761,6 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " - } - - doc_comment! { -- concat!("Saturating integer subtraction. Computes `self - rhs`, saturating --at the numeric bounds instead of overflowing. -- --# Examples -- --Basic usage: -- --``` --", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(27), 73); --assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " --```"), -- #[stable(feature = "rust1", since = "1.0.0")] -- #[rustc_const_unstable(feature = "const_saturating_int_methods")] -- #[inline] -- #[cfg(not(stage0))] -- pub const fn saturating_sub(self, rhs: Self) -> Self { -- intrinsics::saturating_sub(self, rhs) -- } -- } -- -- doc_comment! { - concat!("Saturating integer multiplication. Computes `self * rhs`, - saturating at the numeric bounds instead of overflowing. - --- -2.11.0 - diff --git a/src/base.rs b/src/base.rs index b816eab469417..32299aeb68cd5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -515,7 +515,8 @@ fn trans_stmt<'a, 'tcx: 'a>( _ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", ty), } } - Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) => { + Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) + | Rvalue::Cast(CastKind::MutToConstPointer, operand, ty) => { let operand = trans_operand(fx, operand); let layout = fx.layout_of(ty); lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index ba3e69857bba4..2abe25381eaec 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -192,6 +192,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, type_id); }; _ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) { + // FIXME trap on overflow let bin_op = match intrinsic { "unchecked_div" | "exact_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, @@ -278,6 +279,36 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, res); }; + _ if intrinsic.starts_with("saturating_"), (c x, c y) { + // FIXME implement saturating behavior + assert_eq!(x.layout().ty, y.layout().ty); + let bin_op = match intrinsic { + "saturating_add" => BinOp::Add, + "saturating_sub" => BinOp::Sub, + "saturating_mul" => BinOp::Mul, + _ => unimplemented!("intrinsic {}", intrinsic), + }; + let res = match T.sty { + ty::Uint(_) => crate::base::trans_int_binop( + fx, + bin_op, + x, + y, + ret.layout().ty, + false, + ), + ty::Int(_) => crate::base::trans_int_binop( + fx, + bin_op, + x, + y, + ret.layout().ty, + true, + ), + _ => panic!(), + }; + ret.write_cvalue(fx, res); + }; rotate_left, (v x, v y) { let layout = fx.layout_of(T); let res = fx.bcx.ins().rotl(x, y); From 4bc7f839a75e3a6581de7307ac2d4d1d1b804fcd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 4 Mar 2019 18:17:57 +0000 Subject: [PATCH 0565/1566] Bump cc from 1.0.29 to 1.0.30 Bumps [cc](https://github.com/alexcrichton/cc-rs) from 1.0.29 to 1.0.30. - [Release notes](https://github.com/alexcrichton/cc-rs/releases) - [Commits](https://github.com/alexcrichton/cc-rs/compare/1.0.29...1.0.30) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d326ac34823a4..770e73185d23f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.29" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -521,7 +521,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -863,7 +863,7 @@ dependencies = [ "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "4390a3b5f4f6bce9c1d0c00128379df433e53777fdd30e92f16a529332baec4e" +"checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" From 19e7a1ab8d92fdc517d97d3804aede9835ea3fe1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 4 Mar 2019 18:18:46 +0000 Subject: [PATCH 0566/1566] Bump syn from 0.15.26 to 0.15.27 Bumps [syn](https://github.com/dtolnay/syn) from 0.15.26 to 0.15.27. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/0.15.26...0.15.27) Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d326ac34823a4..43bc9191678b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,7 +290,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -639,7 +639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -705,12 +705,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.26" +version = "0.15.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -725,7 +725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -935,7 +935,7 @@ dependencies = [ "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" "checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" -"checksum syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)" = "f92e629aa1d9c827b2bb8297046c1ccffc57c99b947a680d3ccff1f136a3bee9" +"checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" From 9a3ba598a0dcf2ab500c1ade4ad1bf7c4a78d3ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 5 Mar 2019 05:36:58 +0000 Subject: [PATCH 0567/1566] Bump gimli from `7b828cb` to `a5f5b72` Bumps [gimli](https://github.com/gimli-rs/gimli) from `7b828cb` to `a5f5b72`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/7b828cb40e07e2ea8c403f864aa9ffa9f15b2df4...a5f5b7266646ed41e984b9e48c46b099bc118f17) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index ffa5b63ae7ee3..93769d03eea18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#7b828cb40e07e2ea8c403f864aa9ffa9f15b2df4" +source = "git+https://github.com/gimli-rs/gimli.git#a5f5b7266646ed41e984b9e48c46b099bc118f17" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 735cafb7b59b8e8a050ce9eed2dafbe89a07c6c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 5 Mar 2019 05:37:16 +0000 Subject: [PATCH 0568/1566] Bump cfg-if from 0.1.6 to 0.1.7 Bumps [cfg-if](https://github.com/alexcrichton/cfg-if) from 0.1.6 to 0.1.7. - [Release notes](https://github.com/alexcrichton/cfg-if/releases) - [Commits](https://github.com/alexcrichton/cfg-if/compare/0.1.6...0.1.7) Signed-off-by: dependabot[bot] --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ffa5b63ae7ee3..7be079590feb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,7 +54,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -86,7 +86,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -372,7 +372,7 @@ name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -744,7 +744,7 @@ name = "tempfile" version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", @@ -864,7 +864,7 @@ dependencies = [ "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" -"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" +"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cranelift 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" From 8a9cadcd4c8e98e94b2084acab2c83f311475ce3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 6 Mar 2019 14:32:11 +0100 Subject: [PATCH 0569/1566] Bump libc from 0.2.49 to 0.2.50 (#400) Bumps [libc](https://github.com/rust-lang/libc) from 0.2.49 to 0.2.50. - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.49...0.2.50) Signed-off-by: dependabot[bot] --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 61543d4737f5e..7e5a366fc4517 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,7 +55,7 @@ dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -66,7 +66,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -208,7 +208,7 @@ dependencies = [ "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -244,7 +244,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -254,7 +254,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -364,7 +364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.49" +version = "0.2.50" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -380,7 +380,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -425,7 +425,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -480,7 +480,7 @@ name = "rand_jitter" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -492,7 +492,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -572,7 +572,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -605,7 +605,7 @@ dependencies = [ "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -745,7 +745,7 @@ version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -765,7 +765,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -894,7 +894,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.49 (registry+https://github.com/rust-lang/crates.io-index)" = "413f3dfc802c5dc91dc570b05125b6cda9855edfaa9825c9849807876376e70e" +"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" diff --git a/Cargo.toml b/Cargo.toml index 3384436fe998a..40860ef58c7df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ target-lexicon = "0.2.0" ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.7" -libc = "0.2.49" +libc = "0.2.50" tempfile = "3.0.7" env_logger = "0.6" gimli = { git = "https://github.com/gimli-rs/gimli.git" } From a5fdefe45ad1aeade840beaecfbf9063f1bf3d65 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Feb 2019 17:38:31 +0100 Subject: [PATCH 0570/1566] Fix trans_get_discriminant for uninhabited types --- src/base.rs | 2 +- src/trap.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index 32299aeb68cd5..7aeae55093341 100644 --- a/src/base.rs +++ b/src/base.rs @@ -739,7 +739,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let layout = place.layout(); if layout.abi == layout::Abi::Uninhabited { - trap_unreachable(&mut fx.bcx); + return trap_unreachable_ret_value(fx, dest_layout); } match layout.variants { layout::Variants::Single { index } => { diff --git a/src/trap.rs b/src/trap.rs index d94a852153e45..d76e2728aeac7 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -1,6 +1,4 @@ -use cranelift::prelude::*; - -use cranelift::codegen::ir::TrapCode; +use crate::prelude::*; /// Trap code: user0 pub fn trap_panic(bcx: &mut FunctionBuilder) { @@ -11,3 +9,10 @@ pub fn trap_panic(bcx: &mut FunctionBuilder) { pub fn trap_unreachable(bcx: &mut FunctionBuilder) { bcx.ins().trap(TrapCode::User(!0)); } + +pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>) -> CValue<'tcx> { + let true_ = fx.bcx.ins().iconst(types::I32, 1); + fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); + let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); + CValue::ByRef(zero, dest_layout) +} From 11af20b156dbe9ac158f1456083e296274de5a54 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Feb 2019 18:07:20 +0100 Subject: [PATCH 0571/1566] Fix panic with reported const_eval promoted error --- src/base.rs | 2 +- src/constant.rs | 14 ++++++++++---- src/trap.rs | 7 +++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/base.rs b/src/base.rs index 7aeae55093341..c1ce5409ab2c8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1134,7 +1134,7 @@ pub fn trans_place<'a, 'tcx: 'a>( match place { Place::Base(base) => match base { PlaceBase::Local(local) => fx.get_local_place(*local), - PlaceBase::Promoted(promoted) => crate::constant::trans_promoted(fx, promoted.0), + PlaceBase::Promoted(data) => crate::constant::trans_promoted(fx, data.0, data.1), PlaceBase::Static(static_) => crate::constant::codegen_static_ref(fx, static_), } Place::Projection(projection) => { diff --git a/src/constant.rs b/src/constant.rs index 74a16b3bf2ad2..19fce47358c54 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -53,16 +53,22 @@ pub fn codegen_static_ref<'a, 'tcx: 'a>( pub fn trans_promoted<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, promoted: Promoted, + dest_ty: Ty<'tcx>, ) -> CPlace<'tcx> { - let const_ = fx + match fx .tcx .const_eval(ParamEnv::reveal_all().and(GlobalId { instance: fx.instance, promoted: Some(promoted), })) - .unwrap(); - - trans_const_place(fx, const_) + { + Ok(const_) => { + let cplace = trans_const_place(fx, const_); + debug_assert_eq!(cplace.layout(), fx.layout_of(dest_ty)); + cplace + } + Err(_) => crate::trap::trap_unreachable_ret_place(fx, fx.layout_of(dest_ty)), + } } pub fn trans_constant<'a, 'tcx: 'a>( diff --git a/src/trap.rs b/src/trap.rs index d76e2728aeac7..9a517ae774927 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -16,3 +16,10 @@ pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl crane let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); CValue::ByRef(zero, dest_layout) } + +pub fn trap_unreachable_ret_place<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>) -> CPlace<'tcx> { + let true_ = fx.bcx.ins().iconst(types::I32, 1); + fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); + let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); + CPlace::Addr(zero, None, dest_layout) +} From e09ae252992acb2d646e8f749d92752fac5f85c6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Mar 2019 12:01:33 +0100 Subject: [PATCH 0572/1566] Remove 0006-alloc-Disable-some-unsupported-stuff.patch --- ...alloc-Disable-some-unsupported-stuff.patch | 54 ------------------- src/base.rs | 2 + 2 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 patches/0006-alloc-Disable-some-unsupported-stuff.patch diff --git a/patches/0006-alloc-Disable-some-unsupported-stuff.patch b/patches/0006-alloc-Disable-some-unsupported-stuff.patch deleted file mode 100644 index 18911113f19df..0000000000000 --- a/patches/0006-alloc-Disable-some-unsupported-stuff.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 610096e32cc7cfba58358219a1cf25ff72123208 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sun, 24 Feb 2019 11:27:11 +0100 -Subject: [PATCH] [alloc] Disable some unsupported stuff - ---- - src/liballoc/boxed.rs | 6 ------ - src/liballoc/vec.rs | 2 -- - 2 files changed, 8 deletions(-) - -diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs -index 0cd2373..696535a 100644 ---- a/src/liballoc/boxed.rs -+++ b/src/liballoc/boxed.rs -@@ -423,9 +423,6 @@ impl Hasher for Box { - fn write_u64(&mut self, i: u64) { - (**self).write_u64(i) - } -- fn write_u128(&mut self, i: u128) { -- (**self).write_u128(i) -- } - fn write_usize(&mut self, i: usize) { - (**self).write_usize(i) - } -@@ -441,9 +438,6 @@ impl Hasher for Box { - fn write_i64(&mut self, i: i64) { - (**self).write_i64(i) - } -- fn write_i128(&mut self, i: i128) { -- (**self).write_i128(i) -- } - fn write_isize(&mut self, i: isize) { - (**self).write_isize(i) - } -diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs -index 229dafc..944856e 100644 ---- a/src/liballoc/vec.rs -+++ b/src/liballoc/vec.rs -@@ -1601,13 +1601,11 @@ impl_is_zero!(i8, |x| x == 0); - impl_is_zero!(i16, |x| x == 0); - impl_is_zero!(i32, |x| x == 0); - impl_is_zero!(i64, |x| x == 0); --impl_is_zero!(i128, |x| x == 0); - impl_is_zero!(isize, |x| x == 0); - - impl_is_zero!(u16, |x| x == 0); - impl_is_zero!(u32, |x| x == 0); - impl_is_zero!(u64, |x| x == 0); --impl_is_zero!(u128, |x| x == 0); - impl_is_zero!(usize, |x| x == 0); - - impl_is_zero!(bool, |x| x == false); --- -2.17.2 (Apple Git-113) diff --git a/src/base.rs b/src/base.rs index c1ce5409ab2c8..b36e673854efd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -66,6 +66,8 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Step 2. Check fn sig for u128 and i128 and replace those functions with a trap. { + // FIXME implement u128 and i128 support + // Step 2a. Check sig for u128 and i128 let fn_ty = instance.ty(tcx); let fn_sig = crate::abi::ty_fn_sig(tcx, fn_ty); From 354eb0da9f15950ac2c53a0f69d102cc4ba6597f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 3 Mar 2019 16:33:46 +0100 Subject: [PATCH 0573/1566] Fix write_cvalue type assert for late bound regions in trait objects --- src/common.rs | 99 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/src/common.rs b/src/common.rs index 6da473bcbefe3..3e51d1e6904c5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -320,51 +320,70 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { + use rustc::hir::Mutability::*; + let from_ty = from.layout().ty; let to_ty = self.layout().ty; - match (&from_ty.sty, &to_ty.sty) { - (ty::Ref(_, t, src_mut), ty::Ref(_, u, dest_mut)) - if (if *dest_mut != crate::rustc::hir::Mutability::MutImmutable - && src_mut != dest_mut - { - false - } else if t != u { - false - } else { - true - }) => - { - // &mut T -> &T is allowed - // &'a T -> &'b T is allowed - } - (ty::FnPtr(_), ty::FnPtr(_)) => { - let from_sig = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - &from_ty.fn_sig(fx.tcx), - ); - let to_sig = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - &to_ty.fn_sig(fx.tcx), - ); - assert_eq!( - from_sig, to_sig, - "Can't write fn ptr with incompatible sig {:?} to place with sig {:?}\n\n{:#?}", - from_sig, to_sig, fx, - ); - // fn(&T) -> for<'l> fn(&'l T) is allowed - } - _ => { - assert_eq!( - from_ty, - to_ty, - "Can't write value with incompatible type {:?} to place with type {:?}\n\n{:#?}", - from_ty.sty, - to_ty.sty, - fx, - ); + + fn assert_assignable<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { + match (&from_ty.sty, &to_ty.sty) { + (ty::Ref(_, t, MutImmutable), ty::Ref(_, u, MutImmutable)) + | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutImmutable)) + | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutMutable)) => { + assert_assignable(fx, t, u); + // &mut T -> &T is allowed + // &'a T -> &'b T is allowed + } + (ty::Ref(_, _, MutImmutable), ty::Ref(_, _, MutMutable)) => { + panic!("Cant assign value of type {} to place of type {}", from_ty.sty, to_ty.sty) + } + (ty::FnPtr(_), ty::FnPtr(_)) => { + let from_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &from_ty.fn_sig(fx.tcx), + ); + let to_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &to_ty.fn_sig(fx.tcx), + ); + assert_eq!( + from_sig, to_sig, + "Can't write fn ptr with incompatible sig {:?} to place with sig {:?}\n\n{:#?}", + from_sig, to_sig, fx, + ); + // fn(&T) -> for<'l> fn(&'l T) is allowed + } + (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { + let from_traits = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + from_traits, + ); + let to_traits = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + to_traits, + ); + assert_eq!( + from_traits, to_traits, + "Can't write trait object of incompatible traits {:?} to place with traits {:?}\n\n{:#?}", + from_traits, to_traits, fx, + ); + // dyn for<'r> Trait<'r> -> dyn Trait<'_> is allowed + } + _ => { + assert_eq!( + from_ty, + to_ty, + "Can't write value with incompatible type {:?} to place with type {:?}\n\n{:#?}", + from_ty.sty, + to_ty.sty, + fx, + ); + } } } + assert_assignable(fx, from_ty, to_ty); + let (addr, dst_layout) = match self { CPlace::Var(var, _) => { let data = from.load_scalar(fx); From 4d4e06cbe5073ef7955944b9f84c3b1d43411d43 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 6 Mar 2019 20:34:57 +0100 Subject: [PATCH 0574/1566] Fix atomic intrinsics --- src/intrinsics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 2abe25381eaec..821f7858c9025 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -63,7 +63,7 @@ macro_rules! atomic_binop_return_old { ($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) => { let clif_ty = $fx.clif_type($T).unwrap(); let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); - let new = $fx.bcx.ins().band(old, $src); + let new = $fx.bcx.ins().$op(old, $src); $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); $ret.write_cvalue($fx, CValue::ByVal(old, $fx.layout_of($T))); }; @@ -440,7 +440,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( atomic_binop_return_old! (fx, band(ptr, src) -> ret); }; _ if intrinsic.starts_with("atomic_nand"), (v ptr, v src) { - atomic_binop_return_old! (fx, bnand(ptr, src) -> ret); + atomic_binop_return_old! (fx, band_not(ptr, src) -> ret); }; _ if intrinsic.starts_with("atomic_or"), (v ptr, v src) { atomic_binop_return_old! (fx, bor(ptr, src) -> ret); From 97fdde77dd49965c85349d8a21f246da3d021e54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 7 Mar 2019 18:30:36 +0100 Subject: [PATCH 0575/1566] Bump env_logger from 0.6.0 to 0.6.1 (#407) Bumps [env_logger](https://github.com/sebasmagri/env_logger) from 0.6.0 to 0.6.1. - [Release notes](https://github.com/sebasmagri/env_logger/releases) - [Commits](https://github.com/sebasmagri/env_logger/compare/v0.6.0...v0.6.1) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7e5a366fc4517..e34b9b2ac2780 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,7 +228,7 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -601,7 +601,7 @@ dependencies = [ "cranelift-faerie 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -878,7 +878,7 @@ dependencies = [ "checksum cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-simplejit 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" -"checksum env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afb070faf94c85d17d50ca44f6ad076bce18ae92f0037d350947240a36e9d42e" +"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "142ee8f6d2864117a92855815e710b03087763df41ab3c6a97ca25e00e178b98" From f40afddaad96a47095f89274eb34452df3306d1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 7 Mar 2019 18:30:53 +0100 Subject: [PATCH 0576/1566] Bump gimli from `a5f5b72` to `f30aeaa` (#408) Bumps [gimli](https://github.com/gimli-rs/gimli) from `a5f5b72` to `f30aeaa`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/a5f5b7266646ed41e984b9e48c46b099bc118f17...f30aeaa779b2e3fd0326705a05fb30793827bb93) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e34b9b2ac2780..288d33060e74c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#a5f5b7266646ed41e984b9e48c46b099bc118f17" +source = "git+https://github.com/gimli-rs/gimli.git#f30aeaa779b2e3fd0326705a05fb30793827bb93" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 77258579169d6dcce0d9f55fca18f086bd63e87c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 7 Mar 2019 18:31:39 +0100 Subject: [PATCH 0577/1566] Bump rand_os from 0.1.2 to 0.1.3 (#404) Bumps [rand_os](https://github.com/rust-random/rand) from 0.1.2 to 0.1.3. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/rand_os-0.1.2...rand_os-0.1.3) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 288d33060e74c..1c06920034dbc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,7 +431,7 @@ dependencies = [ "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -487,7 +487,7 @@ dependencies = [ [[package]] name = "rand_os" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -910,7 +910,7 @@ dependencies = [ "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" "checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" -"checksum rand_os 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b7c690732391ae0abafced5015ffb53656abfaec61b342290e5eb56b286a679d" +"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" From 87d7b5cfc77724455ea97429e7b2693b674dee73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 8 Mar 2019 08:24:53 +0100 Subject: [PATCH 0578/1566] Bump gimli from `f30aeaa` to `5763791` (#409) Bumps [gimli](https://github.com/gimli-rs/gimli) from `f30aeaa` to `5763791`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/f30aeaa779b2e3fd0326705a05fb30793827bb93...57637915bbb59bb9743dab9cd2b4ff62454f2f93) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1c06920034dbc..33f42600413f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#f30aeaa779b2e3fd0326705a05fb30793827bb93" +source = "git+https://github.com/gimli-rs/gimli.git#57637915bbb59bb9743dab9cd2b4ff62454f2f93" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 14d66b279c7e7c8df739461eafaf0a9f0c43028d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 8 Mar 2019 17:55:51 +0100 Subject: [PATCH 0579/1566] Update cranelift, faerie and target-lexicon --- Cargo.lock | 149 +++++++++++++++++++++-------------------------- Cargo.toml | 11 ++-- src/debuginfo.rs | 2 +- 3 files changed, 73 insertions(+), 89 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33f42600413f2..1439c42fccfc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,119 +113,107 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" [[package]] name = "cranelift-faerie" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.28.0" -source = "git+https://github.com/CraneStation/cranelift.git#fcd566c09dd6bd13c3bed1eceac4b0378fe7cc05" +version = "0.29.0" +source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" dependencies = [ - "cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "env_logger" -version = "0.5.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "env_logger" version = "0.6.1" @@ -259,19 +247,19 @@ dependencies = [ [[package]] name = "faerie" -version = "0.7.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -323,7 +311,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.0.19" +version = "0.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -597,16 +585,16 @@ dependencies = [ "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.28.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -731,7 +719,7 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -867,28 +855,27 @@ dependencies = [ "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cranelift 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.28.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" +"checksum cranelift 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "142ee8f6d2864117a92855815e710b03087763df41ab3c6a97ca25e00e178b98" +"checksum faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f48412f92b56015a240e249847295b38b0a731435806c21a199403b2c317272c" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eb7217124812dc5672b7476d0c2d20cfe9f7c0f1ba0904b674a9762a0212f72e" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)" = "" -"checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" +"checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" @@ -937,7 +924,7 @@ dependencies = [ "checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum target-lexicon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4af5e2227f0b887d591d3724b796a96eff04226104d872f5b3883fcd427d64b9" +"checksum target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6923974ce4eb5bd28814756256d8ab71c28dd6e7483313fe7ab6614306bf633" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" diff --git a/Cargo.toml b/Cargo.toml index 40860ef58c7df..b447ef5d5d13d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,16 +10,14 @@ edition = "2018" crate-type = ["dylib"] [dependencies] -#cranelift = "0.14.0" -#cranelift-module = "0.14.0" -#cranelift-simplejit = "0.14.0" -#cranelift-faerie = "0.14.0" - +# These have to be in sync with each other cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } -target-lexicon = "0.2.0" +target-lexicon = "0.3.0" +faerie = "0.9.1" + #goblin = "0.0.17" ar = "0.6.1" bitflags = "1.0.3" @@ -28,7 +26,6 @@ libc = "0.2.50" tempfile = "3.0.7" env_logger = "0.6" gimli = { git = "https://github.com/gimli-rs/gimli.git" } -faerie = "0.7.1" indexmap = "1.0.2" # Uncomment to use local checkout of cranelift diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 35b8369d8a5c9..8537e8b7205d1 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -191,7 +191,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { artifact - .declare_with(id.name(), Decl::DebugSection, section.writer.take()) + .declare_with(id.name(), Decl::debug_section(), section.writer.take()) .unwrap(); } Ok(()) From 27e9cfc79fb689b3ce3e88d4fabde720ecd7d1d9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Mar 2019 20:02:47 +0100 Subject: [PATCH 0580/1566] Rustup to rustc 1.35.0-nightly (9d71ec135 2019-03-10) --- src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bad8c6043eaa2..9a74954719f21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,11 +22,9 @@ use std::sync::mpsc; use rustc::dep_graph::DepGraph; use rustc::middle::cstore::MetadataLoader; use rustc::mir::mono::{Linkage as RLinkage, Visibility}; -use rustc::session::{ - config::{DebugInfo, OutputFilenames, OutputType}, - CompileIncomplete, -}; +use rustc::session::config::{DebugInfo, OutputFilenames, OutputType}; use rustc::ty::query::Providers; +use rustc::util::common::ErrorReported; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; use rustc_codegen_utils::codegen_backend::CodegenBackend; @@ -157,7 +155,7 @@ impl CodegenBackend for CraneliftCodegenBackend { match *cty { CrateType::Rlib | CrateType::Dylib | CrateType::Executable => {} _ => { - sess.err(&format!( + sess.warn(&format!( "Rustc codegen cranelift doesn't support output type {}", cty )); @@ -365,7 +363,7 @@ impl CodegenBackend for CraneliftCodegenBackend { sess: &Session, _dep_graph: &DepGraph, outputs: &OutputFilenames, - ) -> Result<(), CompileIncomplete> { + ) -> Result<(), ErrorReported> { let res = *res .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); From 119664f3b59d5e92d477f34916c88e1c9da0b23b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Mar 2019 20:06:05 +0100 Subject: [PATCH 0581/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1439c42fccfc2..390dec74047e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-bforest 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" [[package]] name = "cranelift-faerie" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ccc309fc6686b2ddbc98bd03749b101be5e9ecf2" +source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", From bfe8c89d41681264e0d8f06a458ac0091dbc43f0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Mar 2019 20:06:23 +0100 Subject: [PATCH 0582/1566] Remove "Saved incremental data" warning --- src/lib.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9a74954719f21..bbcf0928553bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -207,10 +207,6 @@ impl CodegenBackend for CraneliftCodegenBackend { let metadata = tcx.encode_metadata(); - // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore - save_incremental(tcx); - tcx.sess.warn("Saved incremental data"); - let mut log = if cfg!(debug_assertions) { Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) } else { @@ -323,6 +319,10 @@ impl CodegenBackend for CraneliftCodegenBackend { let mut allocator_module = new_module("allocator_shim.o".to_string()); let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); + rustc_incremental::assert_dep_graph(tcx); + rustc_incremental::save_dep_graph(tcx); + rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); + return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module( @@ -469,12 +469,6 @@ fn time(name: &str, f: impl FnOnce() -> R) -> R { res } -fn save_incremental<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - rustc_incremental::assert_dep_graph(tcx); - rustc_incremental::save_dep_graph(tcx); - rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); -} - /// This is the entrypoint for a hot plugged rustc_codegen_cranelift #[no_mangle] pub fn __rustc_codegen_backend() -> Box { From d9403bf3fdd0d924e38d781fae79402edd069c76 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Mar 2019 20:36:29 +0100 Subject: [PATCH 0583/1566] Implement weak linkage for statics --- example/mini_core_hello_world.rs | 16 ++++++++++++- src/constant.rs | 39 ++++++++++++++++++++++++++++---- src/lib.rs | 18 +++++---------- src/linkage.rs | 29 ++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 17 deletions(-) create mode 100644 src/linkage.rs diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index e07dcf6ba9e7d..4dea94e36872c 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -1,6 +1,6 @@ // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs -#![feature(no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns)] +#![feature(no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns, never_type, linkage)] #![no_core] #![allow(dead_code)] @@ -192,4 +192,18 @@ fn main() { } assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); + + extern { + #[linkage = "weak"] + static ABC: *const u8; + } + + { + extern { + #[linkage = "weak"] + static ABC: *const u8; + } + } + + unsafe { assert_eq!(ABC as usize, 0); } } diff --git a/src/constant.rs b/src/constant.rs index 19fce47358c54..14e7585b812e5 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -46,7 +46,8 @@ pub fn codegen_static_ref<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, static_: &Static<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fx.tcx, fx.module, static_.def_id, Linkage::Import); + let linkage = crate::linkage::get_static_ref_linkage(fx.tcx, static_.def_id); + let data_id = data_id_for_static(fx.tcx, fx.module, static_.def_id, linkage); cplace_for_dataid(fx, static_.ty, data_id) } @@ -188,9 +189,32 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( !tcx.type_of(def_id) .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) }; - module + + let data_id = module .declare_data(&*symbol_name, linkage, is_mutable) - .unwrap() + .unwrap(); + + if linkage == Linkage::Preemptible { + if let ty::RawPtr(_) = tcx.type_of(def_id).sty { + } else { + tcx.sess.span_fatal(tcx.def_span(def_id), "must have type `*const T` or `*mut T`") + } + + let mut data_ctx = DataContext::new(); + let zero_bytes = std::iter::repeat(0) + .take(pointer_ty(tcx).bytes() as usize) + .collect::>() + .into_boxed_slice(); + data_ctx.define(zero_bytes); + match module.define_data(data_id, &data_ctx) { + // Everytime a weak static is referenced, there will be a zero pointer definition, + // so duplicate definitions are expected and allowed. + Err(ModuleError::DuplicateDefinition(_)) => {} + res => res.unwrap(), + } + } + + data_id } fn cplace_for_dataid<'a, 'tcx: 'a>( @@ -222,6 +246,11 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( } TodoItem::Static(def_id) => { //println!("static {:?}", def_id); + + if tcx.is_foreign_item(def_id) { + continue; + } + let instance = ty::Instance::mono(tcx, def_id); let cid = GlobalId { instance, @@ -234,6 +263,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( _ => bug!("static const eval returned {:#?}", const_), }; + // FIXME set correct linkage let data_id = data_id_for_static(tcx, module, def_id, Linkage::Export); (data_id, alloc) } @@ -271,7 +301,8 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( } AllocKind::Static(def_id) => { cx.todo.insert(TodoItem::Static(def_id)); - data_id_for_static(tcx, module, def_id, Linkage::Import) + let linkage = crate::linkage::get_static_ref_linkage(tcx, def_id); + data_id_for_static(tcx, module, def_id, linkage) } }; diff --git a/src/lib.rs b/src/lib.rs index bbcf0928553bb..f9f899a857546 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,6 +29,7 @@ use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; use rustc_codegen_utils::codegen_backend::CodegenBackend; use rustc_codegen_utils::link::out_filename; +use rustc_mir::monomorphize::partitioning::CodegenUnitExt; use cranelift::codegen::settings; use cranelift_faerie::*; @@ -47,6 +48,7 @@ mod debuginfo; mod intrinsics; mod link; mod link_copied; +mod linkage; mod main_shim; mod metadata; mod pretty_clif; @@ -368,7 +370,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); - for &crate_type in sess.opts.crate_types.iter() { + for &crate_type in sess.crate_types.borrow().iter() { let output_name = out_filename(sess, crate_type, &outputs, &res.crate_name.as_str()); match crate_type { CrateType::Rlib => link::link_rlib(sess, &res, output_name), @@ -423,9 +425,8 @@ fn codegen_cgus<'a, 'tcx: 'a>( let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); let mono_items = cgus .iter() - .map(|cgu| cgu.items().iter()) + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) .flatten() - .map(|(&mono_item, &(linkage, vis))| (mono_item, (linkage, vis))) .collect::>(); codegen_mono_items(tcx, module, debug.as_mut(), log, mono_items); @@ -442,16 +443,9 @@ fn codegen_mono_items<'a, 'tcx: 'a>( ) { let mut cx = CodegenCx::new(tcx, module, debug_context); time("codegen mono items", move || { - for (mono_item, (linkage, vis)) in mono_items { + for (mono_item, (linkage, visibility)) in mono_items { unimpl::try_unimpl(tcx, log, || { - let linkage = match (linkage, vis) { - (RLinkage::External, Visibility::Default) => Linkage::Export, - (RLinkage::Internal, Visibility::Default) => Linkage::Local, - // FIXME this should get external linkage, but hidden visibility, - // not internal linkage and default visibility - (RLinkage::External, Visibility::Hidden) => Linkage::Export, - _ => panic!("{:?} = {:?} {:?}", mono_item, linkage, vis), - }; + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); base::trans_mono_item(&mut cx, mono_item, linkage); }); } diff --git a/src/linkage.rs b/src/linkage.rs new file mode 100644 index 0000000000000..3edfba61e3373 --- /dev/null +++ b/src/linkage.rs @@ -0,0 +1,29 @@ +use rustc::mir::mono::{MonoItem, Linkage as RLinkage, Visibility}; + +use crate::prelude::*; + +pub fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibility: Visibility) -> Linkage { + match (linkage, visibility) { + (RLinkage::External, Visibility::Default) => Linkage::Export, + (RLinkage::Internal, Visibility::Default) => Linkage::Local, + // FIXME this should get external linkage, but hidden visibility, + // not internal linkage and default visibility + (RLinkage::External, Visibility::Hidden) => Linkage::Export, + _ => panic!("{:?} = {:?} {:?}", mono_item, linkage, visibility), + } +} + +pub fn get_static_ref_linkage(tcx: TyCtxt, def_id: DefId) -> Linkage { + let fn_attrs = tcx.codegen_fn_attrs(def_id); + + if let Some(linkage) = fn_attrs.linkage { + match linkage { + RLinkage::External => Linkage::Export, + RLinkage::Internal => Linkage::Local, + RLinkage::ExternalWeak | RLinkage::WeakAny => Linkage::Preemptible, + _ => panic!("{:?}", linkage), + } + } else { + Linkage::Import + } +} From b0ecbf14a23a301183ff194ca97a62e23e2cc6f7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Mar 2019 20:44:05 +0100 Subject: [PATCH 0584/1566] Sign extend ints in trans_const_value --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 14e7585b812e5..01c8f84125a2a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -116,7 +116,7 @@ fn trans_const_value<'a, 'tcx: 'a>( } ty::Int(_) => { let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val(fx, ty, bits as i128 as i64) + CValue::const_val(fx, ty, rustc::mir::interpret::sign_extend(bits, layout.size) as i128 as i64) } ty::FnDef(_def_id, _substs) => CValue::ByRef( fx.bcx From 87424cb2883ebff319ff00ee11a33b0f519913b0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Mar 2019 20:45:59 +0100 Subject: [PATCH 0585/1566] Misc changes --- config.sh | 1 + patches/0013-Patch-away-bswap-usage.patch | 2 +- src/common.rs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config.sh b/config.sh index c73a75a008212..87acb63f888ac 100644 --- a/config.sh +++ b/config.sh @@ -20,3 +20,4 @@ fi export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" +export RUST_LOG=warn # display metadata load errors diff --git a/patches/0013-Patch-away-bswap-usage.patch b/patches/0013-Patch-away-bswap-usage.patch index 14d05a325835d..e29042c729705 100644 --- a/patches/0013-Patch-away-bswap-usage.patch +++ b/patches/0013-Patch-away-bswap-usage.patch @@ -16,7 +16,7 @@ index f928d40..6a146f5 100644 #[inline] pub const fn swap_bytes(self) -> Self { - intrinsics::bswap(self as $ActualT) as Self -+ 0 // bswap is unsupported by cg_clif ++ 42 // bswap is unsupported by cg_clif } } diff --git a/src/common.rs b/src/common.rs index 3e51d1e6904c5..869cacca87b80 100644 --- a/src/common.rs +++ b/src/common.rs @@ -396,8 +396,8 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { dst_layout, ), CPlace::NoPlace(layout) => { - assert!(layout.size.bytes() == 0); - assert!(from.layout().size.bytes() == 0); + assert_eq!(layout.size.bytes(), 0); + assert_eq!(from.layout().size.bytes(), 0); return; } CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), From 06c109a0e24c72b653a51c5b8b1e8bf61b53928c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 12 Mar 2019 11:25:57 +0100 Subject: [PATCH 0586/1566] Bump gimli from `5763791` to `f1f641c` (#418) Bumps [gimli](https://github.com/gimli-rs/gimli) from `5763791` to `f1f641c`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/57637915bbb59bb9743dab9cd2b4ff62454f2f93...f1f641c73eaa3caa38ef673e89bffd08469512dd) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 390dec74047e8..f8d118733b868 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,7 +300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#57637915bbb59bb9743dab9cd2b4ff62454f2f93" +source = "git+https://github.com/gimli-rs/gimli.git#f1f641c73eaa3caa38ef673e89bffd08469512dd" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 788d8cec93461833186d9d838df85687adfd4f2d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Mar 2019 10:54:02 +0100 Subject: [PATCH 0587/1566] Rustup to rustc 1.35.0-nightly (52e885628 2019-03-15) --- src/common.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common.rs b/src/common.rs index 869cacca87b80..2ba66e3aef836 100644 --- a/src/common.rs +++ b/src/common.rs @@ -64,7 +64,7 @@ pub fn clif_type_from_ty<'a, 'tcx: 'a>( return None; } } - ty::Param(_) => bug!("{:?}: {:?}", ty, ty.sty), + ty::Param(_) => bug!("ty param {:?}", ty), _ => return None, }) } @@ -335,7 +335,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { // &'a T -> &'b T is allowed } (ty::Ref(_, _, MutImmutable), ty::Ref(_, _, MutMutable)) => { - panic!("Cant assign value of type {} to place of type {}", from_ty.sty, to_ty.sty) + panic!("Cant assign value of type {} to place of type {}", from_ty, to_ty) } (ty::FnPtr(_), ty::FnPtr(_)) => { let from_sig = fx.tcx.normalize_erasing_late_bound_regions( @@ -374,8 +374,8 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { from_ty, to_ty, "Can't write value with incompatible type {:?} to place with type {:?}\n\n{:#?}", - from_ty.sty, - to_ty.sty, + from_ty, + to_ty, fx, ); } From a715c79263513a2d141d39c94d649706ab90820c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 21 Mar 2019 20:24:46 +0100 Subject: [PATCH 0588/1566] Rustup to rustc 1.35.0-nightly (82e2f3ec2 2019-03-20) --- example/alloc_example.rs | 4 +- ...002-Disable-u128-and-i128-in-libcore.patch | 142 ++++++++++++++++-- src/constant.rs | 18 +-- 3 files changed, 141 insertions(+), 23 deletions(-) diff --git a/example/alloc_example.rs b/example/alloc_example.rs index 06746ab1f76e9..3dc134521173c 100644 --- a/example/alloc_example.rs +++ b/example/alloc_example.rs @@ -1,10 +1,10 @@ -#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_error_handler)] +#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_prelude, alloc_error_handler)] #![no_std] extern crate alloc; extern crate alloc_system; -use alloc::prelude::*; +use alloc::prelude::v1::*; use alloc_system::System; diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index b4cd2f54be5f2..016667bf88109 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -54,14 +54,16 @@ index d0ee5fa..d02c454 100644 macro_rules! ptr_width { () => { 2 } diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index 91161ca..759497f 100644 +index ae6d807..4414e07 100644 --- a/src/libcore/time.rs +++ b/src/libcore/time.rs -@@ -518,80 +469,6 @@ impl Duration { - (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) +@@ -534,198 +534,6 @@ impl Duration { + pub const fn as_secs_f32(&self) -> f32 { + (self.secs as f32) + (self.nanos as f32) / (NANOS_PER_SEC as f32) } - -- /// Creates a new `Duration` from the specified number of seconds. +- +- /// Creates a new `Duration` from the specified number of seconds represented +- /// as `f64`. - /// - /// # Panics - /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`. @@ -71,12 +73,14 @@ index 91161ca..759497f 100644 - /// #![feature(duration_float)] - /// use std::time::Duration; - /// -- /// let dur = Duration::from_float_secs(2.7); +- /// let dur = Duration::from_secs_f64(2.7); - /// assert_eq!(dur, Duration::new(2, 700_000_000)); - /// ``` - #[unstable(feature = "duration_float", issue = "54361")] - #[inline] -- pub fn from_float_secs(secs: f64) -> Duration { +- pub fn from_secs_f64(secs: f64) -> Duration { +- const MAX_NANOS_F64: f64 = +- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; - let nanos = secs * (NANOS_PER_SEC as f64); - if !nanos.is_finite() { - panic!("got non-finite value when converting float to duration"); @@ -94,6 +98,42 @@ index 91161ca..759497f 100644 - } - } - +- /// Creates a new `Duration` from the specified number of seconds represented +- /// as `f32`. +- /// +- /// # Panics +- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur = Duration::from_secs_f32(2.7); +- /// assert_eq!(dur, Duration::new(2, 700_000_000)); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn from_secs_f32(secs: f32) -> Duration { +- const MAX_NANOS_F32: f32 = +- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f32; +- let nanos = secs * (NANOS_PER_SEC as f32); +- if !nanos.is_finite() { +- panic!("got non-finite value when converting float to duration"); +- } +- if nanos >= MAX_NANOS_F32 { +- panic!("overflow when converting float to duration"); +- } +- if nanos < 0.0 { +- panic!("underflow when converting float to duration"); +- } +- let nanos = nanos as u128; +- Duration { +- secs: (nanos / (NANOS_PER_SEC as u128)) as u64, +- nanos: (nanos % (NANOS_PER_SEC as u128)) as u32, +- } +- } +- - /// Multiplies `Duration` by `f64`. - /// - /// # Panics @@ -111,7 +151,29 @@ index 91161ca..759497f 100644 - #[unstable(feature = "duration_float", issue = "54361")] - #[inline] - pub fn mul_f64(self, rhs: f64) -> Duration { -- Duration::from_float_secs(rhs * self.as_float_secs()) +- Duration::from_secs_f64(rhs * self.as_secs_f64()) +- } +- +- /// Multiplies `Duration` by `f32`. +- /// +- /// # Panics +- /// This method will panic if result is not finite, negative or overflows `Duration`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur = Duration::new(2, 700_000_000); +- /// // note that due to rounding errors result is slightly different +- /// // from 8.478 and 847800.0 +- /// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_640)); +- /// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847799, 969_120_256)); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn mul_f32(self, rhs: f32) -> Duration { +- Duration::from_secs_f32(rhs * self.as_secs_f32()) - } - - /// Divide `Duration` by `f64`. @@ -132,12 +194,68 @@ index 91161ca..759497f 100644 - #[unstable(feature = "duration_float", issue = "54361")] - #[inline] - pub fn div_f64(self, rhs: f64) -> Duration { -- Duration::from_float_secs(self.as_float_secs() / rhs) +- Duration::from_secs_f64(self.as_secs_f64() / rhs) +- } +- +- /// Divide `Duration` by `f32`. +- /// +- /// # Panics +- /// This method will panic if result is not finite, negative or overflows `Duration`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur = Duration::new(2, 700_000_000); +- /// // note that due to rounding errors result is slightly +- /// // different from 0.859_872_611 +- /// assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_576)); +- /// // note that truncation is used, not rounding +- /// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_598)); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn div_f32(self, rhs: f32) -> Duration { +- Duration::from_secs_f32(self.as_secs_f32() / rhs) +- } +- +- /// Divide `Duration` by `Duration` and return `f64`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur1 = Duration::new(2, 700_000_000); +- /// let dur2 = Duration::new(5, 400_000_000); +- /// assert_eq!(dur1.div_duration_f64(dur2), 0.5); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn div_duration_f64(self, rhs: Duration) -> f64 { +- self.as_secs_f64() / rhs.as_secs_f64() - } - - /// Divide `Duration` by `Duration` and return `f64`. - /// - /// # Examples +- /// Divide `Duration` by `Duration` and return `f32`. +- /// +- /// # Examples +- /// ``` +- /// #![feature(duration_float)] +- /// use std::time::Duration; +- /// +- /// let dur1 = Duration::new(2, 700_000_000); +- /// let dur2 = Duration::new(5, 400_000_000); +- /// assert_eq!(dur1.div_duration_f32(dur2), 0.5); +- /// ``` +- #[unstable(feature = "duration_float", issue = "54361")] +- #[inline] +- pub fn div_duration_f32(self, rhs: Duration) -> f32 { +- self.as_secs_f32() / rhs.as_secs_f32() +- } + } + + #[stable(feature = "duration", since = "1.3.0")] diff --git a/src/libstd/num.rs b/src/libstd/num.rs index 828d572..bc04fb1 100644 --- a/src/libstd/num.rs diff --git a/src/constant.rs b/src/constant.rs index 01c8f84125a2a..2768e9fea5b65 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; -use rustc::ty::{Const, LazyConst}; +use rustc::ty::Const; use rustc_mir::interpret::{ EvalContext, ImmTy, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, @@ -76,18 +76,18 @@ pub fn trans_constant<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { - let const_ = fx.monomorphize(&constant.literal); - let const_ = force_eval_const(fx, const_); + let const_ = force_eval_const(fx, &constant.literal); trans_const_value(fx, const_) } pub fn force_eval_const<'a, 'tcx: 'a>( - fx: &FunctionCx<'a, 'tcx, impl Backend>, - const_: &'tcx LazyConst<'tcx>, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + const_: &'tcx Const, ) -> Const<'tcx> { - match *const_ { - LazyConst::Unevaluated(def_id, ref substs) => { + match const_.val { + ConstValue::Unevaluated(def_id, ref substs) => { let param_env = ParamEnv::reveal_all(); + let substs = fx.monomorphize(substs); let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap(); let cid = GlobalId { instance, @@ -95,7 +95,7 @@ pub fn force_eval_const<'a, 'tcx: 'a>( }; fx.tcx.const_eval(param_env.and(cid)).unwrap() } - LazyConst::Evaluated(const_) => const_, + _ => *fx.monomorphize(&const_), } } @@ -152,7 +152,7 @@ fn trans_const_place<'a, 'tcx: 'a>( span: DUMMY_SP, ty: const_.ty, user_ty: None, - literal: fx.tcx.mk_lazy_const(LazyConst::Evaluated(const_)), + literal: fx.tcx.mk_const(const_), })), None, )?; From f1432c0e2d9d6c96c380c8e9cef89fcfd1b22d5b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 25 Mar 2019 19:54:44 +0100 Subject: [PATCH 0589/1566] Rustup to rustc 1.35.0-nightly (0576ac109 2019-03-24) --- ...003-Disable-inline-assembly-in-hint-spin_loop.patch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch b/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch index 700c48e493566..a96ac09f971e0 100644 --- a/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch +++ b/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch @@ -16,12 +16,12 @@ index ad5a207..04712b8 100644 #[unstable(feature = "renamed_spin_loop", issue = "55002")] pub fn spin_loop() { + /* - #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] - unsafe { - asm!("pause" ::: "memory" : "volatile"); + #[cfg( + all( + any(target_arch = "x86", target_arch = "x86_64"), @@ -71,4 +72,5 @@ pub fn spin_loop() { - unsafe { - asm!("yield" ::: "memory" : "volatile"); + unsafe { crate::arch::arm::__yield() }; + } } + */ } From 47b1ef24e48bd3c250d14c756eb5e9de6c1ece20 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 25 Mar 2019 20:03:05 +0100 Subject: [PATCH 0590/1566] Update dependencies --- Cargo.lock | 82 ++++++++++++++++++++++++------------------------ src/debuginfo.rs | 4 +-- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8d118733b868..042df9b7108f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-bforest 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" [[package]] name = "cranelift-faerie" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#ba16b60293f07af10c4daced95ac3faf4224f5f4" +source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" dependencies = [ "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -222,7 +222,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -257,8 +257,8 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -278,13 +278,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fallible-iterator" -version = "0.1.6" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -300,11 +300,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#f1f641c73eaa3caa38ef673e89bffd08469512dd" +source = "git+https://github.com/gimli-rs/gimli.git#97ab9ea183cfd3d1fa31395ebed6a4fc9c8f987b" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -509,7 +509,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -536,7 +536,7 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -627,7 +627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -645,17 +645,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -668,7 +668,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -678,27 +678,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.27" +version = "0.15.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -713,7 +713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -724,7 +724,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -851,7 +851,7 @@ dependencies = [ "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" +"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -871,7 +871,7 @@ dependencies = [ "checksum faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f48412f92b56015a240e249847295b38b0a731435806c21a199403b2c317272c" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" -"checksum fallible-iterator 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eb7217124812dc5672b7476d0c2d20cfe9f7c0f1ba0904b674a9762a0212f72e" +"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)" = "" @@ -904,7 +904,7 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" +"checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f" "checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" "checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" @@ -915,14 +915,14 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)" = "9f301d728f2b94c9a7691c90f07b0b4e8a4517181d9461be94c04bddeb4bd850" -"checksum serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "27dce848e7467aa0e2fcaf0a413641499c0b745452aaca1194d24dedde9e13c9" +"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" +"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" -"checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" -"checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" +"checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" +"checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" +"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6923974ce4eb5bd28814756256d8ab71c28dd6e7483313fe7ab6614306bf633" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 8537e8b7205d1..9db4319113457 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -6,9 +6,9 @@ use syntax::source_map::FileName; use gimli::write::{ Address, AttributeValue, DwarfUnit, EndianVec, FileId, LineProgram, LineString, - LineStringTable, Range, RangeList, Result, SectionId, Sections, UnitEntryId, Writer, + LineStringTable, Range, RangeList, Result, Sections, UnitEntryId, Writer, }; -use gimli::{Encoding, Format, LineEncoding, RunTimeEndian}; +use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, SectionId}; use faerie::*; From 0df3b41630119f3b2dc3db27bf5ace942f210871 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Mar 2019 19:53:04 +0100 Subject: [PATCH 0591/1566] Skip ZST arguments Fixes #413 and increases compatibility with cg_llvm --- example/mini_core_hello_world.rs | 2 + src/abi.rs | 138 ++++++++++--------------------- src/base.rs | 3 +- src/pretty_clif.rs | 2 +- 4 files changed, 49 insertions(+), 96 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 4dea94e36872c..e69c509b76375 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -206,4 +206,6 @@ fn main() { } unsafe { assert_eq!(ABC as usize, 0); } + + &mut (|| Some(0 as *const ())) as &mut FnMut() -> Option<*const ()>; } diff --git a/src/abi.rs b/src/abi.rs index 45c2c6d3719c0..79bdfcc12406f 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -1,7 +1,5 @@ use std::borrow::Cow; -use std::iter; -use rustc::hir; use rustc::ty::layout::{FloatTy, Integer, Primitive, Scalar}; use rustc_target::spec::abi::Abi; @@ -44,26 +42,16 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { fn get_pass_mode<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>, - is_return: bool, ) -> PassMode { let layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); assert!(!layout.is_unsized()); - if layout.size.bytes() == 0 { - if is_return { - PassMode::NoPass - } else { - PassMode::ByRef - } + if layout.is_zst() { + // WARNING zst arguments must never be passed, as that will break CastKind::ClosureFnPointer + PassMode::NoPass } else { match &layout.abi { - layout::Abi::Uninhabited => { - if is_return { - PassMode::NoPass - } else { - PassMode::ByRef - } - } + layout::Abi::Uninhabited => PassMode::NoPass, layout::Abi::Scalar(scalar) => { PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) } @@ -80,11 +68,11 @@ fn get_pass_mode<'a, 'tcx: 'a>( fn adjust_arg_for_abi<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, arg: CValue<'tcx>, -) -> Value { - match get_pass_mode(fx.tcx, arg.layout().ty, false) { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => arg.load_scalar(fx), - PassMode::ByRef => arg.force_stack(fx), +) -> Option { + match get_pass_mode(fx.tcx, arg.layout().ty) { + PassMode::NoPass => None, + PassMode::ByVal(_) => Some(arg.load_scalar(fx)), + PassMode::ByRef => Some(arg.force_stack(fx)), } } @@ -109,13 +97,13 @@ fn clif_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: FnSig<'t let inputs = inputs .into_iter() - .filter_map(|ty| match get_pass_mode(tcx, ty, false) { + .filter_map(|ty| match get_pass_mode(tcx, ty) { + PassMode::NoPass => None, PassMode::ByVal(clif_ty) => Some(clif_ty), - PassMode::NoPass => unimplemented!("pass mode nopass"), PassMode::ByRef => Some(pointer_ty(tcx)), }); - let (params, returns) = match get_pass_mode(tcx, output, true) { + let (params, returns) = match get_pass_mode(tcx, output) { PassMode::NoPass => (inputs.map(AbiParam::new).collect(), vec![]), PassMode::ByVal(ret_ty) => ( inputs.map(AbiParam::new).collect(), @@ -140,59 +128,13 @@ fn clif_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: FnSig<'t } } -pub fn ty_fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> ty::FnSig<'tcx> { - let sig = match ty.sty { - ty::FnDef(..) | - // Shims currently have type TyFnPtr. Not sure this should remain. - ty::FnPtr(_) => ty.fn_sig(tcx), - ty::Closure(def_id, substs) => { - let sig = substs.closure_sig(def_id, tcx); - - let env_ty = tcx.closure_env_ty(def_id, substs).unwrap(); - sig.map_bound(|sig| tcx.mk_fn_sig( - iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), - sig.output(), - sig.c_variadic, - sig.unsafety, - sig.abi - )) - } - ty::Generator(def_id, substs, _) => { - let sig = substs.poly_sig(def_id, tcx); - - let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); - let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty); - - sig.map_bound(|sig| { - let state_did = tcx.lang_items().gen_state().unwrap(); - let state_adt_ref = tcx.adt_def(state_did); - let state_substs = tcx.intern_substs(&[ - sig.yield_ty.into(), - sig.return_ty.into(), - ]); - let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); - - tcx.mk_fn_sig(iter::once(env_ty), - ret_ty, - false, - hir::Unsafety::Normal, - Abi::Rust - ) - }) - } - _ => bug!("unexpected type {:?} to ty_fn_sig", ty) - }; - tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &sig) -} - pub fn get_function_name_and_sig<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, inst: Instance<'tcx>, support_vararg: bool, ) -> (String, Signature) { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); - let fn_ty = inst.ty(tcx); - let fn_sig = ty_fn_sig(tcx, fn_ty); + let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &inst.fn_sig(tcx)); if fn_sig.c_variadic && !support_vararg { unimpl!("Variadic function definitions are not yet supported"); } @@ -293,7 +235,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } fn self_sig(&self) -> FnSig<'tcx> { - ty_fn_sig(self.tcx, self.instance.ty(self.tcx)) + self.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &self.instance.fn_sig(self.tcx)) } fn return_type(&self) -> Ty<'tcx> { @@ -405,9 +347,14 @@ fn cvalue_for_param<'a, 'tcx: 'a>( local_field: Option, arg_ty: Ty<'tcx>, ssa_flags: crate::analyze::Flags, -) -> CValue<'tcx> { +) -> Option> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.tcx, arg_ty, false); + let pass_mode = get_pass_mode(fx.tcx, arg_ty); + + if let PassMode::NoPass = pass_mode { + return None; + } + let clif_type = pass_mode.get_param_ty(fx); let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); @@ -424,9 +371,9 @@ fn cvalue_for_param<'a, 'tcx: 'a>( ); match pass_mode { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(_) => CValue::ByVal(ebb_param, layout), - PassMode::ByRef => CValue::ByRef(ebb_param, layout), + PassMode::NoPass => unreachable!(), + PassMode::ByVal(_) => Some(CValue::ByVal(ebb_param, layout)), + PassMode::ByRef => Some(CValue::ByRef(ebb_param, layout)), } } @@ -440,7 +387,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); let ret_layout = fx.layout_of(fx.return_type()); - let output_pass_mode = get_pass_mode(fx.tcx, fx.return_type(), true); + let output_pass_mode = get_pass_mode(fx.tcx, fx.return_type()); let ret_param = match output_pass_mode { PassMode::NoPass => None, PassMode::ByVal(_) => None, @@ -462,9 +409,10 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( ); } + // None means pass_mode == NoPass enum ArgKind<'tcx> { - Normal(CValue<'tcx>), - Spread(Vec>), + Normal(Option>), + Spread(Vec>>), } let func_params = fx @@ -542,13 +490,17 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( match arg_kind { ArgKind::Normal(param) => { - place.write_cvalue(fx, param); + if let Some(param) = param { + place.write_cvalue(fx, param); + } } ArgKind::Spread(params) => { for (i, param) in params.into_iter().enumerate() { - place - .place_field(fx, mir::Field::new(i)) - .write_cvalue(fx, param); + if let Some(param) = param { + place + .place_field(fx, mir::Field::new(i)) + .write_cvalue(fx, param); + } } } } @@ -578,7 +530,7 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( destination: &Option<(Place<'tcx>, BasicBlock)>, ) { let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); - let sig = ty_fn_sig(fx.tcx, fn_ty); + let sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); // Unpack arguments tuple for closures let args = if sig.abi == Abi::RustCall { @@ -649,11 +601,11 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( args: Vec>, ret_place: Option>, ) { - let fn_sig = ty_fn_sig(fx.tcx, fn_ty); + let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fx.tcx, fn_sig.output(), true); + let output_pass_mode = get_pass_mode(fx.tcx, fn_sig.output()); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { @@ -683,7 +635,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( } // Normal call - Some(_) => (None, args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg))), + Some(_) => (None, args.get(0).and_then(|arg| adjust_arg_for_abi(fx, *arg))), // Indirect call None => { @@ -691,7 +643,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( .load_scalar(fx); ( Some(func), - args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)), + args.get(0).and_then(|arg| adjust_arg_for_abi(fx, *arg)), ) } }; @@ -702,7 +654,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( .chain( args.into_iter() .skip(1) - .map(|arg| adjust_arg_for_abi(fx, arg)), + .filter_map(|arg| adjust_arg_for_abi(fx, arg)), ) .collect::>(); @@ -756,9 +708,9 @@ pub fn codegen_drop<'a, 'tcx: 'a>( let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); - let fn_sig = ty_fn_sig(fx.tcx, drop_fn_ty); + let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &drop_fn_ty.fn_sig(fx.tcx)); - match get_pass_mode(fx.tcx, fn_sig.output(), true) { + match get_pass_mode(fx.tcx, fn_sig.output()) { PassMode::NoPass => {} _ => unreachable!(), }; @@ -770,7 +722,7 @@ pub fn codegen_drop<'a, 'tcx: 'a>( } pub fn codegen_return(fx: &mut FunctionCx) { - match get_pass_mode(fx.tcx, fx.return_type(), true) { + match get_pass_mode(fx.tcx, fx.return_type()) { PassMode::NoPass | PassMode::ByRef => { fx.bcx.ins().return_(&[]); } diff --git a/src/base.rs b/src/base.rs index b36e673854efd..ec057dd81d476 100644 --- a/src/base.rs +++ b/src/base.rs @@ -69,8 +69,7 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // FIXME implement u128 and i128 support // Step 2a. Check sig for u128 and i128 - let fn_ty = instance.ty(tcx); - let fn_sig = crate::abi::ty_fn_sig(tcx, fn_ty); + let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx)); struct UI128Visitor<'a, 'tcx: 'a>(TyCtxt<'a, 'tcx, 'tcx>, bool); diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 31ca4168d242c..ee16c68214b70 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -75,7 +75,7 @@ impl CommentWriter { global_comments: vec![ format!("symbol {}", tcx.symbol_name(instance).as_str()), format!("instance {:?}", instance), - format!("sig {:?}", crate::abi::ty_fn_sig(tcx, instance.ty(tcx))), + format!("sig {:?}", tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx))), String::new(), ], entity_comments: HashMap::new(), From b9295f1efd1f6c9d4317ab337fae142d1f3dfb49 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Mar 2019 17:45:20 +0100 Subject: [PATCH 0592/1566] Rustup to rustc 1.35.0-nightly (fbd34efb3 2019-03-26) --- src/base.rs | 10 ++++++++-- src/constant.rs | 9 +++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/base.rs b/src/base.rs index ec057dd81d476..441f882be1b7c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1135,8 +1135,14 @@ pub fn trans_place<'a, 'tcx: 'a>( match place { Place::Base(base) => match base { PlaceBase::Local(local) => fx.get_local_place(*local), - PlaceBase::Promoted(data) => crate::constant::trans_promoted(fx, data.0, data.1), - PlaceBase::Static(static_) => crate::constant::codegen_static_ref(fx, static_), + PlaceBase::Static(static_) => match static_.kind { + StaticKind::Static(def_id) => { + crate::constant::codegen_static_ref(fx, def_id, static_.ty) + } + StaticKind::Promoted(promoted) => { + crate::constant::trans_promoted(fx, promoted, static_.ty) + } + } } Place::Projection(projection) => { let base = trans_place(fx, &projection.base); diff --git a/src/constant.rs b/src/constant.rs index 2768e9fea5b65..8236af1470ecb 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -44,11 +44,12 @@ pub fn codegen_static<'a, 'tcx: 'a>(ccx: &mut ConstantCx, def_id: DefId) { pub fn codegen_static_ref<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - static_: &Static<'tcx>, + def_id: DefId, + ty: Ty<'tcx>, ) -> CPlace<'tcx> { - let linkage = crate::linkage::get_static_ref_linkage(fx.tcx, static_.def_id); - let data_id = data_id_for_static(fx.tcx, fx.module, static_.def_id, linkage); - cplace_for_dataid(fx, static_.ty, data_id) + 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); + cplace_for_dataid(fx, ty, data_id) } pub fn trans_promoted<'a, 'tcx: 'a>( From 1fc1fbef93456ac2444479073b36e7d4a9f44b58 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Mar 2019 17:52:51 +0100 Subject: [PATCH 0593/1566] Update Cargo.lock --- Cargo.lock | 100 ++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 042df9b7108f5..4602e75ecc779 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,29 +113,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-bforest 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -144,24 +144,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" [[package]] name = "cranelift-faerie" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", @@ -170,43 +170,43 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.29.0" -source = "git+https://github.com/CraneStation/cranelift.git#283bfb664572a03487fa49fa7f84a70c9798ace8" +version = "0.30.0" +source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" dependencies = [ - "cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -585,10 +585,10 @@ dependencies = [ "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.29.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", @@ -855,16 +855,16 @@ dependencies = [ "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cranelift 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.29.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 9e9e77bfb50185f4851cbdea24faf938f24b5cc9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 29 Mar 2019 18:05:17 +0100 Subject: [PATCH 0594/1566] Update Cargo.lock --- Cargo.lock | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4602e75ecc779..c081647b4f6b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,7 +55,7 @@ dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -65,8 +65,8 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.31" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,13 +202,13 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#08223094ade7af4399672068120cbc1fa4152300" +source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +232,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -242,7 +242,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -352,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.50" +version = "0.2.51" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -368,7 +368,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -413,7 +413,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -468,7 +468,7 @@ name = "rand_jitter" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -480,7 +480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -509,7 +509,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -560,7 +560,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -593,7 +593,7 @@ dependencies = [ "faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -733,7 +733,7 @@ version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -753,7 +753,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -851,7 +851,7 @@ dependencies = [ "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "c9ce8bb087aacff865633f0bd5aeaed910fe2fe55b55f4739527f2e023a2e53d" +"checksum cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ad0daef304fa0b4238f5f7ed7178774b43b06f6a9b6509f6642bef4ff1f7b9b2" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -881,7 +881,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" +"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" From a3f7b5da86fc142804eb49819cf23fbf7ed0c091 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 29 Mar 2019 19:33:12 +0100 Subject: [PATCH 0595/1566] Rustup to rustc 1.35.0-nightly (237bf3244 2019-03-28) --- src/constant.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 8236af1470ecb..03ab11d9e5985 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::Const; use rustc_mir::interpret::{ - EvalContext, ImmTy, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, + InterpretCx, ImmTy, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, }; @@ -135,7 +135,7 @@ fn trans_const_place<'a, 'tcx: 'a>( ) -> CPlace<'tcx> { // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 let result = || -> EvalResult<'tcx, &'tcx Allocation> { - let mut ecx = EvalContext::new( + let mut ecx = InterpretCx::new( fx.tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all(), TransPlaceInterpreter, @@ -338,16 +338,16 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { type MemoryMap = FxHashMap, Allocation<()>)>; const STATIC_KIND: Option = None; - fn enforce_validity(_: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool { + fn enforce_validity(_: &InterpretCx<'a, 'mir, 'tcx, Self>) -> bool { false } - fn before_terminator(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { + fn before_terminator(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { panic!(); } fn find_fn( - _: &mut EvalContext<'a, 'mir, 'tcx, Self>, + _: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: Option>, @@ -357,7 +357,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { } fn call_intrinsic( - _: &mut EvalContext<'a, 'mir, 'tcx, Self>, + _: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: PlaceTy<'tcx>, @@ -374,7 +374,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { } fn ptr_op( - _: &EvalContext<'a, 'mir, 'tcx, Self>, + _: &InterpretCx<'a, 'mir, 'tcx, Self>, _: mir::BinOp, _: ImmTy<'tcx>, _: ImmTy<'tcx>, @@ -382,12 +382,12 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn box_alloc(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> EvalResult<'tcx> { + fn box_alloc(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> EvalResult<'tcx> { panic!(); } fn tag_dereference( - _: &EvalContext<'a, 'mir, 'tcx, Self>, + _: &InterpretCx<'a, 'mir, 'tcx, Self>, _: MPlaceTy<'tcx>, _: Option<::rustc::hir::Mutability>, ) -> EvalResult<'tcx, Scalar> { @@ -402,18 +402,18 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { } fn tag_new_allocation( - _: &mut EvalContext<'a, 'mir, 'tcx, Self>, + _: &mut InterpretCx<'a, 'mir, 'tcx, Self>, ptr: Pointer, _: MemoryKind, ) -> Pointer { ptr } - fn stack_push(_: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { + fn stack_push(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { Ok(()) } - fn stack_pop(_: &mut EvalContext<'a, 'mir, 'tcx, Self>, _: ()) -> EvalResult<'tcx> { + fn stack_pop(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: ()) -> EvalResult<'tcx> { Ok(()) } } From 50e70086ba5c51e23370331144ba75676773c0ce Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Mar 2019 10:37:09 +0100 Subject: [PATCH 0596/1566] Rustup to rustc 1.35.0-nightly (e782d790f 2019-03-29) --- .../0002-Disable-u128-and-i128-in-libcore.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 016667bf88109..69f82eb9ac2c8 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -10,6 +10,21 @@ Subject: [PATCH] Disable u128 and i128 in libcore src/libstd/panic.rs | 6 -- 20 files changed, 63 insertions(+), 363 deletions(-) +diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs +index 6b657b1..5add3f3 100644 +--- a/src/libcore/num/mod.rs ++++ b/src/libcore/num/mod.rs +@@ -127,8 +127,8 @@ macro_rules! from_str_radix_nzint_impl { + )*} + } + +-from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize +- NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroI128 NonZeroIsize } ++from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroUsize ++ NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroIsize } + + /// Provides intentionally-wrapped arithmetic on `T`. + /// diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index d0ee5fa..d02c454 100644 --- a/src/libcore/sync/atomic.rs From 0ad4e2cc963e94131f63ffe2244a5a221b781eeb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 1 Apr 2019 20:22:59 +0200 Subject: [PATCH 0597/1566] Rustup to rustc 1.35.0-nightly (e3428db7c 2019-03-31) --- src/base.rs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/base.rs b/src/base.rs index 441f882be1b7c..fbc7692ee4e68 100644 --- a/src/base.rs +++ b/src/base.rs @@ -388,7 +388,7 @@ fn trans_stmt<'a, 'tcx: 'a>( layout::Variants::Single { index } => { assert_eq!(index, *variant_index); } - layout::Variants::Tagged { .. } => { + layout::Variants::Multiple { discr_kind: layout::DiscriminantKind::Tag, .. } => { let ptr = place.place_field(fx, mir::Field::new(0)); let to = layout .ty @@ -399,10 +399,12 @@ fn trans_stmt<'a, 'tcx: 'a>( let discr = CValue::const_val(fx, ptr.layout().ty, to as u64 as i64); ptr.write_cvalue(fx, discr); } - layout::Variants::NicheFilling { - dataful_variant, - ref niche_variants, - niche_start, + layout::Variants::Multiple { + discr_kind: layout::DiscriminantKind::Niche { + dataful_variant, + ref niche_variants, + niche_start, + }, .. } => { if *variant_index != dataful_variant { @@ -613,7 +615,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } } - Rvalue::Cast(CastKind::ClosureFnPointer, operand, _ty) => { + Rvalue::Cast(CastKind::ClosureFnPointer(_), operand, _ty) => { let operand = trans_operand(fx, operand); match operand.layout().ty.sty { ty::Closure(def_id, substs) => { @@ -742,37 +744,36 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( if layout.abi == layout::Abi::Uninhabited { return trap_unreachable_ret_value(fx, dest_layout); } - match layout.variants { + + let (discr_scalar, discr_kind) = match &layout.variants { layout::Variants::Single { index } => { let discr_val = layout .ty .ty_adt_def() .map_or(index.as_u32() as u128, |def| { - def.discriminant_for_variant(fx.tcx, index).val + def.discriminant_for_variant(fx.tcx, *index).val }); return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); } - layout::Variants::Tagged { .. } | layout::Variants::NicheFilling { .. } => {} - } + layout::Variants::Multiple { discr, discr_kind, variants: _ } => (discr, discr_kind), + }; let discr = place.place_field(fx, mir::Field::new(0)).to_cvalue(fx); let discr_ty = discr.layout().ty; let lldiscr = discr.load_scalar(fx); - match layout.variants { - layout::Variants::Single { .. } => bug!(), - layout::Variants::Tagged { ref tag, .. } => { - let signed = match tag.value { + match discr_kind { + layout::DiscriminantKind::Tag => { + let signed = match discr_scalar.value { layout::Int(_, signed) => signed, _ => false, }; let val = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), signed); return CValue::ByVal(val, dest_layout); } - layout::Variants::NicheFilling { + layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start, - .. } => { let niche_llty = fx.clif_type(discr_ty).unwrap(); let dest_clif_ty = fx.clif_type(dest_layout.ty).unwrap(); @@ -780,7 +781,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let b = fx .bcx .ins() - .icmp_imm(IntCC::Equal, lldiscr, niche_start as u64 as i64); + .icmp_imm(IntCC::Equal, lldiscr, *niche_start as u64 as i64); let if_true = fx .bcx .ins() From ee2c9deb0b89e7f8075d806f0b20d49318ffa474 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 1 Apr 2019 20:29:06 +0200 Subject: [PATCH 0598/1566] Update Cargo.lock --- Cargo.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c081647b4f6b9..a431815d484f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ # It is not intended for manual editing. [[package]] name = "aho-corasick" -version = "0.6.10" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#d477dc43177ef41f2b76298d8d52bf9615d68d8b" +source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -222,7 +222,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -523,7 +523,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.51" +version = "0.1.52" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -531,24 +531,24 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" -version = "1.1.2" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -735,7 +735,7 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -754,7 +754,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -841,7 +841,7 @@ dependencies = [ ] [metadata] -"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" +"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" @@ -902,10 +902,10 @@ dependencies = [ "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" +"checksum redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)" = "d32b3053e5ced86e4bc0411fec997389532bf56b000e66cb4884eeeb41413d69" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f" -"checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" +"checksum regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "559008764a17de49a3146b234641644ed37d118d1ef641a0bb573d146edc6ce0" +"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" From 94de167a93d998d7da95bc0848725ad0fdc8c58d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 2 Apr 2019 15:49:17 +0000 Subject: [PATCH 0599/1566] Bump cranelift from `6df7e41` to `73aa684` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `6df7e41` to `73aa684`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/6df7e41f5072b73706c441a5a052908320b9b39c...73aa6849b17d44f00c929ad2e95610ddffa65b8b) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a431815d484f2..5ded02bc5870a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#6df7e41f5072b73706c441a5a052908320b9b39c" +source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From e6acbdc20ab788f5c1f5a3b803ad3580b7776d64 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 3 Apr 2019 22:40:19 -0400 Subject: [PATCH 0600/1566] Rustup to rustc 1.35.0-nightly (f8673e0ad 2019-04-03) --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index fbc7692ee4e68..312e8a85d7937 100644 --- a/src/base.rs +++ b/src/base.rs @@ -309,7 +309,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) target, unwind: _, } => { - let ty = location.ty(fx.mir, fx.tcx).to_ty(fx.tcx); + let ty = location.ty(fx.mir, fx.tcx).ty; let ty = fx.monomorphize(&ty); let drop_fn = crate::rustc_mir::monomorphize::resolve_drop_in_place(fx.tcx, ty); From ce4a10ad5ce87be887513e543a9cc2c01bb6c2c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 5 Apr 2019 17:38:10 +0200 Subject: [PATCH 0601/1566] Bump gimli from `97ab9ea` to `21a3d2b` (#462) Bumps [gimli](https://github.com/gimli-rs/gimli) from `97ab9ea` to `21a3d2b`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/97ab9ea183cfd3d1fa31395ebed6a4fc9c8f987b...21a3d2b82d2e5d7e5ab37b114fb34b179cdd340d) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 5ded02bc5870a..11c03fd919771 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,7 +300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#97ab9ea183cfd3d1fa31395ebed6a4fc9c8f987b" +source = "git+https://github.com/gimli-rs/gimli.git#21a3d2b82d2e5d7e5ab37b114fb34b179cdd340d" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 085944875e5bd9e9274aff3bb2813feb58287827 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Apr 2019 19:42:23 +0200 Subject: [PATCH 0602/1566] Update cranelift, faerie and target-lexicon --- Cargo.lock | 46 +++++++++++++++++++++++----------------------- Cargo.toml | 4 ++-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11c03fd919771..c14ff7649059b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -139,13 +139,13 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,35 +153,35 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,17 +192,17 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#73aa6849b17d44f00c929ad2e95610ddffa65b8b" +source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -210,7 +210,7 @@ dependencies = [ "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -247,7 +247,7 @@ dependencies = [ [[package]] name = "faerie" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -259,7 +259,7 @@ dependencies = [ "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -590,11 +590,11 @@ dependencies = [ "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -719,7 +719,7 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -868,7 +868,7 @@ dependencies = [ "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f48412f92b56015a240e249847295b38b0a731435806c21a199403b2c317272c" +"checksum faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c6d75e6376216d6228fbab8025087523666623d9302ff17dd023d024bf98302" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" @@ -924,7 +924,7 @@ dependencies = [ "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" "checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6923974ce4eb5bd28814756256d8ab71c28dd6e7483313fe7ab6614306bf633" +"checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" diff --git a/Cargo.toml b/Cargo.toml index b447ef5d5d13d..14e05f70621a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } -target-lexicon = "0.3.0" -faerie = "0.9.1" +target-lexicon = "0.4.0" +faerie = "0.10.0" #goblin = "0.0.17" ar = "0.6.1" From 8eee61fe6989af62a9ed3b804b617d4b12febbc6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Apr 2019 20:10:55 +0200 Subject: [PATCH 0603/1566] Update dependencies --- Cargo.lock | 64 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c14ff7649059b..e9a12b9e0cfcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,7 +13,7 @@ name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -39,7 +39,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -49,7 +49,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -57,7 +57,7 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -65,7 +65,7 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -211,7 +211,7 @@ dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -233,7 +233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -267,7 +267,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -278,7 +278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -422,7 +422,7 @@ dependencies = [ "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -470,7 +470,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -483,7 +483,7 @@ dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -509,7 +509,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -562,7 +562,7 @@ dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -570,7 +570,7 @@ name = "remove_dir_all" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -627,7 +627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -645,7 +645,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -655,7 +655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -668,7 +668,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -693,12 +693,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.29" +version = "0.15.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -713,7 +713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -737,7 +737,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -806,7 +806,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -823,7 +823,7 @@ name = "winapi-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -836,7 +836,7 @@ name = "wincolor" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -847,11 +847,11 @@ dependencies = [ "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5a90e2b463010cd0e0ce9a11d4a9d5d58d9f41d4a6ba3dcaf9e68b466e88b4" +"checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)" = "ad0daef304fa0b4238f5f7ed7178774b43b06f6a9b6509f6642bef4ff1f7b9b2" +"checksum cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -915,14 +915,14 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" +"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" -"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" +"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" @@ -936,7 +936,7 @@ dependencies = [ "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" From 66e33c25703b7595e7db8f6d8f41d3079c8ab3a8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 6 Apr 2019 12:18:42 +0200 Subject: [PATCH 0604/1566] Rustup to rustc 1.35.0-nightly (acd8dd6a5 2019-04-05) --- .../0015-Remove-usage-of-unsized-locals.patch | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 patches/0015-Remove-usage-of-unsized-locals.patch diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch new file mode 100644 index 0000000000000..277d44ebfa4f1 --- /dev/null +++ b/patches/0015-Remove-usage-of-unsized-locals.patch @@ -0,0 +1,99 @@ +From 7403e2998345ef0650fd50628d7098d4d1e88e5c Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 6 Apr 2019 12:16:21 +0200 +Subject: [PATCH] Remove usage of unsized locals + +--- + src/liballoc/boxed.rs | 23 ----------------------- + src/libstd/sys_common/at_exit_imp.rs | 2 ++ + src/libstd/sys_common/mod.rs | 1 - + src/libstd/sys_common/thread.rs | 7 +------ + 4 files changed, 3 insertions(+), 30 deletions(-) + +diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs +index f6dee7c..0c6a8c0 100644 +--- a/src/liballoc/boxed.rs ++++ b/src/liballoc/boxed.rs +@@ -694,29 +694,6 @@ impl ExactSizeIterator for Box { + #[stable(feature = "fused", since = "1.26.0")] + impl FusedIterator for Box {} + +-#[stable(feature = "boxed_closure_impls", since = "1.35.0")] +-impl + ?Sized> FnOnce for Box { +- type Output = >::Output; +- +- extern "rust-call" fn call_once(self, args: A) -> Self::Output { +- >::call_once(*self, args) +- } +-} +- +-#[stable(feature = "boxed_closure_impls", since = "1.35.0")] +-impl + ?Sized> FnMut for Box { +- extern "rust-call" fn call_mut(&mut self, args: A) -> Self::Output { +- >::call_mut(self, args) +- } +-} +- +-#[stable(feature = "boxed_closure_impls", since = "1.35.0")] +-impl + ?Sized> Fn for Box { +- extern "rust-call" fn call(&self, args: A) -> Self::Output { +- >::call(self, args) +- } +-} +- + /// `FnBox` is a version of the `FnOnce` intended for use with boxed + /// closure objects. The idea is that where one would normally store a + /// `Box` in a data structure, you should use +diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs +index 1181b86..20f9251 100644 +--- a/src/libstd/sys_common/at_exit_imp.rs ++++ b/src/libstd/sys_common/at_exit_imp.rs +@@ -38,6 +38,7 @@ unsafe fn init() -> bool { + true + } + ++/* + pub fn cleanup() { + for i in 1..=ITERS { + unsafe { +@@ -60,6 +61,7 @@ pub fn cleanup() { + } + } + } ++*/ + + pub fn push(f: Box) -> bool { + unsafe { +diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs +index 6260c3b..611ed7e 100644 +--- a/src/libstd/sys_common/mod.rs ++++ b/src/libstd/sys_common/mod.rs +@@ -127,7 +127,6 @@ pub fn cleanup() { + CLEANUP.call_once(|| unsafe { + sys::args::cleanup(); + sys::stack_overflow::cleanup(); +- at_exit_imp::cleanup(); + }); + } + +diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs +index b2142e7..718bb1c 100644 +--- a/src/libstd/sys_common/thread.rs ++++ b/src/libstd/sys_common/thread.rs +@@ -6,12 +6,7 @@ use crate::sys::thread as imp; + + #[allow(dead_code)] + pub unsafe fn start_thread(main: *mut u8) { +- // Next, set up our stack overflow handler which may get triggered if we run +- // out of stack. +- let _handler = stack_overflow::Handler::new(); +- +- // Finally, let's run some code. +- Box::from_raw(main as *mut Box)() ++ panic!("Threads are not yet supported, because cranelift doesn't support atomics."); + } + + pub fn min_stack() -> usize { +-- +2.20.1 (Apple Git-117) + From 979795e05e45080eac8dc8e0d830087ae3a8ae55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 8 Apr 2019 04:17:43 +0000 Subject: [PATCH 0605/1566] Bump cranelift from `0d2badc` to `c08d231` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `0d2badc` to `c08d231`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/0d2badceb81a1f911b223eed3b42d4d89ac04182...c08d231708e49aeec6cc31e45f2d8aff3cb9372b) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9a12b9e0cfcc..5a6ebf18f4fcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#0d2badceb81a1f911b223eed3b42d4d89ac04182" +source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 42349e963db2bd07f5e73cb5a840655bba495f05 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 8 Apr 2019 18:21:40 +0200 Subject: [PATCH 0606/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a6ebf18f4fcc..8eaf207403ae0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c08d231708e49aeec6cc31e45f2d8aff3cb9372b" +source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 41a4175c84e4252a367083e5c625ccab9cc3caf9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 8 Apr 2019 18:22:28 +0200 Subject: [PATCH 0607/1566] Fix for mutable_borrow_reservation_conflict future compatibility lint --- src/abi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 79bdfcc12406f..1e1549469e11a 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -692,8 +692,8 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( PassMode::NoPass => {} PassMode::ByVal(_) => { if let Some(ret_place) = ret_place { - let results = fx.bcx.inst_results(call_inst); - ret_place.write_cvalue(fx, CValue::ByVal(results[0], ret_layout)); + let ret_val = fx.bcx.inst_results(call_inst)[0]; + ret_place.write_cvalue(fx, CValue::ByVal(ret_val, ret_layout)); } } PassMode::ByRef => {} From 6e3939e43ceb3d288da3d63479e166f495b8d714 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 9 Apr 2019 04:17:32 +0000 Subject: [PATCH 0608/1566] Bump cranelift from `cadf244` to `4bc56b8` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `cadf244` to `4bc56b8`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/cadf244ed5a94625d527515dbde4561814445695...4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8eaf207403ae0..3ce9473c047ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#cadf244ed5a94625d527515dbde4561814445695" +source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From f13cd3e6ef21829a15f62cc6a11209b61ff36b16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 10 Apr 2019 04:17:48 +0000 Subject: [PATCH 0609/1566] Bump cranelift from `4bc56b8` to `8456797` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `4bc56b8` to `8456797`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e...84567979ba18ad613d0066c0d8129393c9098a9c) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ce9473c047ff..8fe01820dee4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4bc56b8505a50e9fadbd2ccbe68ffbd3aba8e44e" +source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 3fb3043358c27a648430fc024111eba0651d0d5c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Apr 2019 16:44:18 +0200 Subject: [PATCH 0610/1566] Update Cargo.lock --- Cargo.lock | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8fe01820dee4e..8e4d3457cdf2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,7 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -91,14 +91,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.32.0" +version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -277,7 +277,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -300,7 +300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#21a3d2b82d2e5d7e5ab37b114fb34b179cdd340d" +source = "git+https://github.com/gimli-rs/gimli.git#053f9e3c9b219ffa5033760a10726ec2681f1dfb" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -401,7 +401,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -509,7 +509,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -523,7 +523,7 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.52" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -531,7 +531,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -626,7 +626,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -673,7 +673,7 @@ dependencies = [ [[package]] name = "strsim" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -681,7 +681,7 @@ name = "structopt" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -692,7 +692,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -702,7 +702,7 @@ version = "0.15.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -712,7 +712,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -735,7 +735,7 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -754,13 +754,13 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "textwrap" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -851,9 +851,9 @@ dependencies = [ "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)" = "30f813bf45048a18eda9190fd3c6b78644146056740c43172a5a3699118588fd" +"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" -"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -889,7 +889,7 @@ dependencies = [ "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" +"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" @@ -902,7 +902,7 @@ dependencies = [ "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.52 (registry+https://github.com/rust-lang/crates.io-index)" = "d32b3053e5ced86e4bc0411fec997389532bf56b000e66cb4884eeeb41413d69" +"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "559008764a17de49a3146b234641644ed37d118d1ef641a0bb573d146edc6ce0" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" @@ -919,7 +919,7 @@ dependencies = [ "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" -"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" "checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2" @@ -928,7 +928,7 @@ dependencies = [ "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" "checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" From 16f41266567b16924cd0dff66122db041cc613a5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 10 Apr 2019 16:50:50 +0200 Subject: [PATCH 0611/1566] Pass --sysroot in config.sh to prevent passing it --- build_sysroot/build_sysroot.sh | 2 +- config.sh | 2 +- test.sh | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 33da1e3dd6792..5e1d0904753f8 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -20,7 +20,7 @@ fi # Build libs mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ -export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked --sysroot sysroot" +export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked" if [[ "$1" == "--release" ]]; then channel='release' RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release diff --git a/config.sh b/config.sh index 87acb63f888ac..5dca77855d7f0 100644 --- a/config.sh +++ b/config.sh @@ -18,6 +18,6 @@ else cargo build fi -export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext +export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUST_LOG=warn # display metadata load errors diff --git a/test.sh b/test.sh index 5653caee16241..6be002a9c03d9 100755 --- a/test.sh +++ b/test.sh @@ -25,21 +25,21 @@ echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh echo "[BUILD+RUN] alloc_example" -$RUSTC --sysroot ./build_sysroot/sysroot example/alloc_example.rs --crate-type bin +$RUSTC example/alloc_example.rs --crate-type bin ./target/out/alloc_example echo "[BUILD+RUN] std_example" -$RUSTC --sysroot ./build_sysroot/sysroot example/std_example.rs --crate-type bin +$RUSTC example/std_example.rs --crate-type bin ./target/out/std_example echo "[BUILD] mod_bench" -$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin +$RUSTC example/mod_bench.rs --crate-type bin # FIXME linker gives multiple definitions error on Linux #echo "[BUILD] sysroot in release mode" #./build_sysroot/build_sysroot.sh --release -COMPILE_MOD_BENCH_INLINE="$RUSTC --sysroot ./build_sysroot/sysroot example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" +COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" From 970d164089f0cc2dc90dafeb3eedb681d505dc81 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Feb 2019 16:46:11 +0100 Subject: [PATCH 0612/1566] Fix and optimize init intrinsic --- example/mini_core.rs | 1 + example/mini_core_hello_world.rs | 23 +++++++++++++++++ src/intrinsics.rs | 43 +++++++++++++++++++++++++------- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index ffc2cd8fb65a0..dd42257b1946f 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -371,6 +371,7 @@ pub mod intrinsics { pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; pub fn uninit() -> T; + pub fn init() -> T; pub fn ctlz_nonzero(x: T) -> T; pub fn needs_drop() -> bool; pub fn bitreverse(x: T) -> T; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index e69c509b76375..fdd26f8791d66 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -165,6 +165,29 @@ fn main() { struct MyDst(T); intrinsics::size_of_val(&MyDst([0u8; 4]) as &MyDst<[u8]>); + + struct Foo { + x: u8, + y: !, + } + + unsafe fn zeroed() -> T { + intrinsics::init::() + } + + unsafe fn uninitialized() -> T { + intrinsics::uninit::() + } + + #[allow(unreachable_code)] + { + if false { + zeroed::(); + zeroed::(); + zeroed::<(u8, u8)>(); + uninitialized::(); + } + } } let _ = box NoisyDrop { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 821f7858c9025..34b58c5b40735 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -337,16 +337,36 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) }; - init, () { - let layout = fx.layout_of(T); - let inited_place = CPlace::new_stack_slot(fx, T); - let addr = inited_place.to_addr(fx); - let zero_val = fx.bcx.ins().iconst(types::I8, 0); - let len_val = fx.bcx.ins().iconst(pointer_ty(fx.tcx), layout.size.bytes() as i64); - fx.bcx.call_memset(fx.module.target_config(), addr, zero_val, len_val); + init, () { + if ret.layout().abi == Abi::Uninhabited { + crate::trap::trap_panic(&mut fx.bcx); + return; + } - let inited_val = inited_place.to_cvalue(fx); - ret.write_cvalue(fx, inited_val); + match ret { + CPlace::NoPlace(_layout) => {} + CPlace::Var(var, layout) => { + let clif_ty = fx.clif_type(layout.ty).unwrap(); + let val = match clif_ty { + types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 0), + types::F32 => { + let zero = fx.bcx.ins().iconst(types::I32, 0); + fx.bcx.ins().bitcast(types::F32, zero) + } + types::F64 => { + let zero = fx.bcx.ins().iconst(types::I64, 0); + fx.bcx.ins().bitcast(types::F64, zero) + } + _ => panic!("clif_type returned {}", clif_ty), + }; + fx.bcx.def_var(mir_var(var), val); + } + _ => { + let addr = ret.to_addr(fx); + let layout = ret.layout(); + fx.bcx.emit_small_memset(fx.module.target_config(), addr, 0, layout.size.bytes(), 1); + } + } }; write_bytes, (c dst, v val, v count) { let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty; @@ -356,6 +376,11 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); }; uninit, () { + if ret.layout().abi == Abi::Uninhabited { + crate::trap::trap_panic(&mut fx.bcx); + return; + } + let uninit_place = CPlace::new_stack_slot(fx, T); let uninit_val = uninit_place.to_cvalue(fx); ret.write_cvalue(fx, uninit_val); From c0ffc422abaf6a55ebcd8da59c12f05834219caa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Mar 2019 13:06:35 +0100 Subject: [PATCH 0613/1566] Print message when reaching trap --- src/abi.rs | 2 +- src/base.rs | 38 ++++++++++++++++++++++++++++++-------- src/constant.rs | 8 +++++++- src/intrinsics.rs | 12 ++++++------ src/trap.rs | 40 ++++++++++++++++++++++++++++++++++------ 5 files changed, 78 insertions(+), 22 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 1e1549469e11a..531e4f063af31 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -590,7 +590,7 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { - trap_unreachable(&mut fx.bcx); + trap_unreachable(fx, "[corruption] Diverging function returned"); } } diff --git a/src/base.rs b/src/base.rs index 312e8a85d7937..3f9fef329c3a8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -108,9 +108,28 @@ fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( let start_ebb = bcx.create_ebb(); bcx.append_ebb_params_for_function_params(start_ebb); bcx.switch_to_block(start_ebb); - crate::trap::trap_unreachable(&mut bcx); - bcx.seal_all_blocks(); - bcx.finalize(); + + let mut fx = FunctionCx { + tcx, + module: cx.module, + pointer_type: pointer_ty(tcx), + + instance, + mir, + + bcx, + ebb_map: HashMap::new(), + local_map: HashMap::new(), + + clif_comments: crate::pretty_clif::CommentWriter::new(tcx, instance), + constants: &mut cx.ccx, + caches: &mut cx.caches, + source_info_set: indexmap::IndexSet::new(), + }; + + crate::trap::trap_unreachable(&mut fx, "[unimplemented] Called function with u128 or i128 as argument."); + fx.bcx.seal_all_blocks(); + fx.bcx.finalize(); // Step 2b3. Define function cx.caches.context.func = func; @@ -254,7 +273,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) TerminatorKind::Assert { cond, expected, - msg: _, + msg, target, cleanup: _, } => { @@ -267,7 +286,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } else { fx.bcx.ins().brz(cond, target, &[]); }; - trap_panic(&mut fx.bcx); + trap_panic(fx, format!("[panic] Assert {:?} failed.", msg)); } TerminatorKind::SwitchInt { @@ -294,8 +313,11 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } => { crate::abi::codegen_terminator_call(fx, func, args, destination); } - TerminatorKind::Resume | TerminatorKind::Abort | TerminatorKind::Unreachable => { - trap_unreachable(&mut fx.bcx); + TerminatorKind::Resume | TerminatorKind::Abort => { + trap_unreachable(fx, "[corruption] Unwinding bb reached."); + } + TerminatorKind::Unreachable => { + trap_unreachable(fx, "[corruption] Hit unreachable code."); } TerminatorKind::Yield { .. } | TerminatorKind::FalseEdges { .. } @@ -742,7 +764,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let layout = place.layout(); if layout.abi == layout::Abi::Uninhabited { - return trap_unreachable_ret_value(fx, dest_layout); + return trap_unreachable_ret_value(fx, dest_layout, "[panic] Tried to get discriminant for uninhabited type."); } let (discr_scalar, discr_kind) = match &layout.variants { diff --git a/src/constant.rs b/src/constant.rs index 03ab11d9e5985..738349275b8fe 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -69,7 +69,13 @@ pub fn trans_promoted<'a, 'tcx: 'a>( debug_assert_eq!(cplace.layout(), fx.layout_of(dest_ty)); cplace } - Err(_) => crate::trap::trap_unreachable_ret_place(fx, fx.layout_of(dest_ty)), + Err(_) => { + crate::trap::trap_unreachable_ret_place( + fx, + fx.layout_of(dest_ty), + "[panic] Tried to get value of promoted value with errored during const eval.", + ) + } } } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 34b58c5b40735..22a527f0ab354 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -103,10 +103,10 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // Insert non returning intrinsics here match intrinsic { "abort" => { - trap_panic(&mut fx.bcx); + trap_panic(fx, "Called intrinisc::abort."); } "unreachable" => { - trap_unreachable(&mut fx.bcx); + trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); } _ => unimplemented!("unsupported instrinsic {}", intrinsic), } @@ -339,7 +339,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; init, () { if ret.layout().abi == Abi::Uninhabited { - crate::trap::trap_panic(&mut fx.bcx); + crate::trap::trap_panic(fx, "[panic] Called intrinsic::init for uninhabited type."); return; } @@ -377,7 +377,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; uninit, () { if ret.layout().abi == Abi::Uninhabited { - crate::trap::trap_panic(&mut fx.bcx); + crate::trap::trap_panic(fx, "[panic] Called intrinsic::uninit for uninhabited type."); return; } @@ -412,7 +412,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; panic_if_uninhabited, () { if fx.layout_of(T).abi.is_uninhabited() { - crate::trap::trap_panic(&mut fx.bcx); + crate::trap::trap_panic(fx, "[panic] Called intrinsic::panic_if_uninhabited for uninhabited type."); return; } }; @@ -492,6 +492,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let ret_ebb = fx.get_ebb(dest); fx.bcx.ins().jump(ret_ebb, &[]); } else { - trap_unreachable(&mut fx.bcx); + trap_unreachable(fx, "[corruption] Diverging intrinsic returned."); } } diff --git a/src/trap.rs b/src/trap.rs index 9a517ae774927..f492bcf4b1ebd 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -1,23 +1,51 @@ use crate::prelude::*; +fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { + let puts = fx.module.declare_function("puts", Linkage::Import, &Signature { + call_conv: CallConv::SystemV, + params: vec![AbiParam::new(pointer_ty(fx.tcx))], + returns: vec![], + }).unwrap(); + let puts = fx.module.declare_func_in_func(puts, &mut fx.bcx.func); + + let symbol_name = fx.tcx.symbol_name(fx.instance); + let msg_bytes = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg).into_bytes().into_boxed_slice(); + let mut data_ctx = DataContext::new(); + data_ctx.define(msg_bytes); + let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false).unwrap(); + + // Ignore DuplicateDefinition error, as the data will be the same + let _ = fx.module.define_data(msg_id, &data_ctx); + + let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); + let msg_ptr = fx.bcx.ins().global_value(pointer_ty(fx.tcx), local_msg_id); + fx.bcx.ins().call(puts, &[msg_ptr]); +} + /// Trap code: user0 -pub fn trap_panic(bcx: &mut FunctionBuilder) { - bcx.ins().trap(TrapCode::User(0)); +pub fn trap_panic(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { + codegen_print(fx, msg.as_ref()); + fx.bcx.ins().trap(TrapCode::User(0)); } /// Trap code: user65535 -pub fn trap_unreachable(bcx: &mut FunctionBuilder) { - bcx.ins().trap(TrapCode::User(!0)); +pub fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { + codegen_print(fx, msg.as_ref()); + fx.bcx.ins().trap(TrapCode::User(!0)); } -pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>) -> CValue<'tcx> { +/// Trap code: user65535 +pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef) -> CValue<'tcx> { + codegen_print(fx, msg.as_ref()); let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); CValue::ByRef(zero, dest_layout) } -pub fn trap_unreachable_ret_place<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>) -> CPlace<'tcx> { +/// Trap code: user65535 +pub fn trap_unreachable_ret_place<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef) -> CPlace<'tcx> { + codegen_print(fx, msg.as_ref()); let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); From 2f36416fc91686c8fd82dae883d11fd8a3fdadbb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 14 Apr 2019 10:49:07 +0200 Subject: [PATCH 0614/1566] Some changes to README.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index e6b6f68bfac1b..5fc18c82eca4b 100644 --- a/Readme.md +++ b/Readme.md @@ -7,7 +7,7 @@ ```bash $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift -$ ./prepare.sh # downloads and patches sysroot src and installs hyperfine for benchmarking +$ ./prepare.sh # download and patch sysroot src and install hyperfine for benchmarking $ ./test.sh ``` @@ -18,7 +18,7 @@ $ ./test.sh ### Rustc ```bash -$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.so my_crate.rs +$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs ``` ### Cargo From de792ad690a1a72d3c29dbfdc159128b004a8b9c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 15 Apr 2019 16:34:16 +0200 Subject: [PATCH 0615/1566] Rustup to rustc 1.35.0-nightly (aa99abeb2 2019-04-14) --- ...002-Disable-u128-and-i128-in-libcore.patch | 3 +++ .../0015-Remove-usage-of-unsized-locals.patch | 4 ++-- src/base.rs | 23 +++++++++++++------ src/lib.rs | 2 +- src/link.rs | 2 +- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 69f82eb9ac2c8..97ed483f7d788 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -281,6 +281,9 @@ index 828d572..bc04fb1 100644 #[stable(feature = "nonzero", since = "1.28.0")] -pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; +pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; + #[stable(feature = "signed_nonzero", since = "1.34.0")] +-pub use core::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize}; ++pub use core::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroIsize}; #[cfg(test)] use crate::fmt; #[cfg(test)] use crate::ops::{Add, Sub, Mul, Div, Rem}; diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch index 277d44ebfa4f1..2f104ad5b25e8 100644 --- a/patches/0015-Remove-usage-of-unsized-locals.patch +++ b/patches/0015-Remove-usage-of-unsized-locals.patch @@ -62,7 +62,7 @@ index 1181b86..20f9251 100644 } +*/ - pub fn push(f: Box) -> bool { + pub fn push(f: Box) -> bool { unsafe { diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs index 6260c3b..611ed7e 100644 @@ -89,7 +89,7 @@ index b2142e7..718bb1c 100644 - let _handler = stack_overflow::Handler::new(); - - // Finally, let's run some code. -- Box::from_raw(main as *mut Box)() +- Box::from_raw(main as *mut Box)() + panic!("Threads are not yet supported, because cranelift doesn't support atomics."); } diff --git a/src/base.rs b/src/base.rs index 3f9fef329c3a8..0fb69e2a1e35f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -410,8 +410,13 @@ fn trans_stmt<'a, 'tcx: 'a>( layout::Variants::Single { index } => { assert_eq!(index, *variant_index); } - layout::Variants::Multiple { discr_kind: layout::DiscriminantKind::Tag, .. } => { - let ptr = place.place_field(fx, mir::Field::new(0)); + layout::Variants::Multiple { + discr: _, + discr_index, + discr_kind: layout::DiscriminantKind::Tag, + variants: _, + } => { + let ptr = place.place_field(fx, mir::Field::new(discr_index)); let to = layout .ty .ty_adt_def() @@ -422,15 +427,17 @@ fn trans_stmt<'a, 'tcx: 'a>( ptr.write_cvalue(fx, discr); } layout::Variants::Multiple { + discr: _, + discr_index, discr_kind: layout::DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start, }, - .. + variants: _, } => { if *variant_index != dataful_variant { - let niche = place.place_field(fx, mir::Field::new(0)); + let niche = place.place_field(fx, mir::Field::new(discr_index)); //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); let niche_value = ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) @@ -767,7 +774,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( return trap_unreachable_ret_value(fx, dest_layout, "[panic] Tried to get discriminant for uninhabited type."); } - let (discr_scalar, discr_kind) = match &layout.variants { + let (discr_scalar, discr_index, discr_kind) = match &layout.variants { layout::Variants::Single { index } => { let discr_val = layout .ty @@ -777,10 +784,12 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( }); return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); } - layout::Variants::Multiple { discr, discr_kind, variants: _ } => (discr, discr_kind), + layout::Variants::Multiple { discr, discr_index, discr_kind, variants: _ } => { + (discr, *discr_index, discr_kind) + } }; - let discr = place.place_field(fx, mir::Field::new(0)).to_cvalue(fx); + let discr = place.place_field(fx, mir::Field::new(discr_index)).to_cvalue(fx); let discr_ty = discr.layout().ty; let lldiscr = discr.load_scalar(fx); match discr_kind { diff --git a/src/lib.rs b/src/lib.rs index f9f899a857546..8fb35c6e34212 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -173,7 +173,7 @@ impl CodegenBackend for CraneliftCodegenBackend { if sess.opts.cg.rpath { sess.err("rpath is not yet supported"); } - if sess.opts.debugging_opts.pgo_gen.is_some() { + if sess.opts.debugging_opts.pgo_gen.enabled() { sess.err("pgo is not supported"); } } diff --git a/src/link.rs b/src/link.rs index ca349de4848d9..4f0a15cdf00e5 100644 --- a/src/link.rs +++ b/src/link.rs @@ -448,7 +448,7 @@ fn link_args(cmd: &mut dyn Linker, cmd.build_static_executable(); } - if sess.opts.debugging_opts.pgo_gen.is_some() { + if sess.opts.debugging_opts.pgo_gen.enabled() { cmd.pgo_gen(); } From 9b4910aed03aa7ec721b1da02d8b20922df68ab0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 15 Apr 2019 16:41:13 +0200 Subject: [PATCH 0616/1566] Update Cargo.lock --- Cargo.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e4d3457cdf2c..baa2ed9c2e6a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,7 +56,7 @@ dependencies = [ "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -278,7 +278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -575,7 +575,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -627,7 +627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -693,12 +693,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.30" +version = "0.15.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -713,7 +713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -908,7 +908,7 @@ dependencies = [ "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" @@ -922,7 +922,7 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" -"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2" +"checksum syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b4cfac95805274c6afdb12d8f770fa2d27c045953e7b630a81801953699a9a" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" From b2d16c43d71c63b26b9317cf46696c45e7ce75ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 17 Apr 2019 14:15:28 +0200 Subject: [PATCH 0617/1566] Bump gimli from `053f9e3` to `1bcc823` (#484) Bumps [gimli](https://github.com/gimli-rs/gimli) from `053f9e3` to `1bcc823`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/053f9e3c9b219ffa5033760a10726ec2681f1dfb...1bcc82394136549c2c60f19bcb92316fccea5ce4) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index baa2ed9c2e6a2..e21831fac576b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,7 +300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#053f9e3c9b219ffa5033760a10726ec2681f1dfb" +source = "git+https://github.com/gimli-rs/gimli.git#1bcc82394136549c2c60f19bcb92316fccea5ce4" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From 96a3f5db69b1fb60b64b2d03465e750a886a843a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 17 Apr 2019 14:15:44 +0200 Subject: [PATCH 0618/1566] Bump regex from 1.1.5 to 1.1.6 (#483) Bumps [regex](https://github.com/rust-lang/regex) from 1.1.5 to 1.1.6. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/regex/compare/1.1.5...1.1.6) Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e21831fac576b..31d07a10c9fdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -222,7 +222,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -536,7 +536,7 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -904,7 +904,7 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "559008764a17de49a3146b234641644ed37d118d1ef641a0bb573d146edc6ce0" +"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" From dd21922f31c3dcaeb6f5ba0fea26c988b676346a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 18 Apr 2019 19:06:59 +0200 Subject: [PATCH 0619/1566] Rustup to rustc 1.36.0-nightly (3c3d3c177 2019-04-17) --- src/constant.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 738349275b8fe..13036cc121d51 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -407,12 +407,12 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { Cow::Borrowed(alloc) } - fn tag_new_allocation( - _: &mut InterpretCx<'a, 'mir, 'tcx, Self>, - ptr: Pointer, + fn new_allocation( + _: Size, + _: &(), _: MemoryKind, - ) -> Pointer { - ptr + ) -> ((), ()) { + ((), ()) } fn stack_push(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { From b90ff1e56a9871728388f4f8b70b5cb4c39a9335 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 19 Apr 2019 18:43:06 +0200 Subject: [PATCH 0620/1566] Bump gimli from `1bcc823` to `70c3730` (#490) Bumps [gimli](https://github.com/gimli-rs/gimli) from `1bcc823` to `70c3730`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/1bcc82394136549c2c60f19bcb92316fccea5ce4...70c3730b5e3d8669dd2dbcf829fedd4f679185d9) Signed-off-by: dependabot[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 31d07a10c9fdc..971fdf2e1ccfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,7 +300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#1bcc82394136549c2c60f19bcb92316fccea5ce4" +source = "git+https://github.com/gimli-rs/gimli.git#70c3730b5e3d8669dd2dbcf829fedd4f679185d9" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", From a09d92f9b11fea18ab4e09366145b5d86c45bfb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Fri, 19 Apr 2019 16:45:50 +0000 Subject: [PATCH 0621/1566] Bump cranelift from `8456797` to `538a066` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `8456797` to `538a066`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/84567979ba18ad613d0066c0d8129393c9098a9c...538a0662bf90a1daa9921c10f34827ace134abf1) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 971fdf2e1ccfa..4f044dcb65b69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#84567979ba18ad613d0066c0d8129393c9098a9c" +source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 5d3fbdd68ed8f6d91cc744aa80c4710690b2e430 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Apr 2019 17:35:58 +0200 Subject: [PATCH 0622/1566] Use more rustc_codegen_ssa::back::link for linking --- src/link.rs | 3 +- src/link_copied.rs | 282 +-------------------------------------------- src/metadata.rs | 3 +- 3 files changed, 4 insertions(+), 284 deletions(-) diff --git a/src/link.rs b/src/link.rs index 4f0a15cdf00e5..7694892a8e80a 100644 --- a/src/link.rs +++ b/src/link.rs @@ -11,6 +11,7 @@ use tempfile::Builder as TempFileBuilder; use rustc::session::config::{self, CrateType, DebugInfo, RUST_CGU_EXT}; use rustc::session::search_paths::PathKind; use rustc::session::Session; +use rustc_codegen_ssa::METADATA_FILENAME; use rustc_codegen_ssa::back::command::Command; use rustc_codegen_ssa::back::link::*; use rustc_codegen_ssa::back::linker::*; @@ -48,7 +49,7 @@ pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathB builder .append( &ar::Header::new( - crate::metadata::METADATA_FILENAME.as_bytes().to_vec(), + METADATA_FILENAME.as_bytes().to_vec(), res.metadata.raw_data.len() as u64, ), ::std::io::Cursor::new(res.metadata.raw_data.clone()), diff --git a/src/link_copied.rs b/src/link_copied.rs index 517455e927522..d58ffda3336c2 100644 --- a/src/link_copied.rs +++ b/src/link_copied.rs @@ -1,13 +1,6 @@ //! All functions here are copied from https://github.com/rust-lang/rust/blob/942864a000efd74b73e36bda5606b2cdb55ecf39/src/librustc_codegen_llvm/back/link.rs -use std::fmt; -use std::fs; -use std::io; -use std::iter; use std::path::{Path, PathBuf}; -use std::process::{Output, Stdio}; - -use log::info; use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; use rustc::middle::dependency_format::Linkage; @@ -15,7 +8,7 @@ use rustc::session::config::{self, OutputType, RUST_CGU_EXT}; use rustc::session::search_paths::PathKind; use rustc::session::Session; use rustc::util::common::time; -use rustc_codegen_ssa::back::command::Command; +use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; use rustc_codegen_ssa::back::linker::*; use rustc_codegen_ssa::back::link::*; use rustc_data_structures::fx::FxHashSet; @@ -25,11 +18,6 @@ use syntax::attr; use crate::prelude::*; use crate::archive::{ArchiveBuilder, ArchiveConfig}; -use crate::metadata::METADATA_FILENAME; - - -// cg_clif doesn't have bytecode, so this is just a dummy -const RLIB_BYTECODE_EXTENSION: &str = ".cg_clif_bytecode_dummy"; fn archive_search_paths(sess: &Session) -> Vec { sess.target_filesearch(PathKind::Native).search_path_dirs() @@ -46,147 +34,6 @@ fn archive_config<'a>(sess: &'a Session, } } -pub fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &Path) - -> io::Result -{ - // When attempting to spawn the linker we run a risk of blowing out the - // size limits for spawning a new process with respect to the arguments - // we pass on the command line. - // - // Here we attempt to handle errors from the OS saying "your list of - // arguments is too big" by reinvoking the linker again with an `@`-file - // that contains all the arguments. The theory is that this is then - // accepted on all linkers and the linker will read all its options out of - // there instead of looking at the command line. - if !cmd.very_likely_to_exceed_some_spawn_limit() { - match cmd.command().stdout(Stdio::piped()).stderr(Stdio::piped()).spawn() { - Ok(child) => { - let output = child.wait_with_output(); - flush_linked_file(&output, out_filename)?; - return output; - } - Err(ref e) if command_line_too_big(e) => { - info!("command line to linker was too big: {}", e); - } - Err(e) => return Err(e) - } - } - - info!("falling back to passing arguments to linker via an @-file"); - let mut cmd2 = cmd.clone(); - let mut args = String::new(); - for arg in cmd2.take_args() { - args.push_str(&Escape { - arg: arg.to_str().unwrap(), - is_like_msvc: sess.target.target.options.is_like_msvc, - }.to_string()); - args.push_str("\n"); - } - let file = tmpdir.join("linker-arguments"); - let bytes = if sess.target.target.options.is_like_msvc { - let mut out = Vec::with_capacity((1 + args.len()) * 2); - // start the stream with a UTF-16 BOM - for c in iter::once(0xFEFF).chain(args.encode_utf16()) { - // encode in little endian - out.push(c as u8); - out.push((c >> 8) as u8); - } - out - } else { - args.into_bytes() - }; - fs::write(&file, &bytes)?; - cmd2.arg(format!("@{}", file.display())); - info!("invoking linker {:?}", cmd2); - let output = cmd2.output(); - flush_linked_file(&output, out_filename)?; - return output; - - #[cfg(unix)] - fn flush_linked_file(_: &io::Result, _: &Path) -> io::Result<()> { - Ok(()) - } - - #[cfg(windows)] - fn flush_linked_file(command_output: &io::Result, out_filename: &Path) - -> io::Result<()> - { - // On Windows, under high I/O load, output buffers are sometimes not flushed, - // even long after process exit, causing nasty, non-reproducible output bugs. - // - // File::sync_all() calls FlushFileBuffers() down the line, which solves the problem. - // - // А full writeup of the original Chrome bug can be found at - // randomascii.wordpress.com/2018/02/25/compiler-bug-linker-bug-windows-kernel-bug/amp - - if let &Ok(ref out) = command_output { - if out.status.success() { - if let Ok(of) = fs::OpenOptions::new().write(true).open(out_filename) { - of.sync_all()?; - } - } - } - - Ok(()) - } - - #[cfg(unix)] - fn command_line_too_big(err: &io::Error) -> bool { - err.raw_os_error() == Some(::libc::E2BIG) - } - - #[cfg(windows)] - fn command_line_too_big(err: &io::Error) -> bool { - const ERROR_FILENAME_EXCED_RANGE: i32 = 206; - err.raw_os_error() == Some(ERROR_FILENAME_EXCED_RANGE) - } - - struct Escape<'a> { - arg: &'a str, - is_like_msvc: bool, - } - - impl<'a> fmt::Display for Escape<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if self.is_like_msvc { - // This is "documented" at - // https://msdn.microsoft.com/en-us/library/4xdcbak7.aspx - // - // Unfortunately there's not a great specification of the - // syntax I could find online (at least) but some local - // testing showed that this seemed sufficient-ish to catch - // at least a few edge cases. - write!(f, "\"")?; - for c in self.arg.chars() { - match c { - '"' => write!(f, "\\{}", c)?, - c => write!(f, "{}", c)?, - } - } - write!(f, "\"")?; - } else { - // This is documented at https://linux.die.net/man/1/ld, namely: - // - // > Options in file are separated by whitespace. A whitespace - // > character may be included in an option by surrounding the - // > entire option in either single or double quotes. Any - // > character (including a backslash) may be included by - // > prefixing the character to be included with a backslash. - // - // We put an argument on each line, so all we need to do is - // ensure the line is interpreted as one whole argument. - for c in self.arg.chars() { - match c { - '\\' | ' ' => write!(f, "\\{}", c)?, - c => write!(f, "{}", c)?, - } - } - } - Ok(()) - } - } -} - // # Rust Crate linking // // Rust crates are not considered at all when creating an rlib output. All @@ -505,130 +352,3 @@ pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, parent.unwrap_or(Path::new(""))); } } - -// # Native library linking -// -// User-supplied library search paths (-L on the command line). These are -// the same paths used to find Rust crates, so some of them may have been -// added already by the previous crate linking code. This only allows them -// to be found at compile time so it is still entirely up to outside -// forces to make sure that library can be found at runtime. -// -// Also note that the native libraries linked here are only the ones located -// in the current crate. Upstream crates with native library dependencies -// may have their native library pulled in above. -pub fn add_local_native_libraries(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults) { - let filesearch = sess.target_filesearch(PathKind::All); - for search_path in filesearch.search_paths() { - match search_path.kind { - PathKind::Framework => { cmd.framework_path(&search_path.dir); } - _ => { cmd.include_path(&fix_windows_verbatim_for_gcc(&search_path.dir)); } - } - } - - let relevant_libs = codegen_results.crate_info.used_libraries.iter().filter(|l| { - relevant_lib(sess, l) - }); - - let search_path = archive_search_paths(sess); - for lib in relevant_libs { - let name = match lib.name { - Some(ref l) => l, - None => continue, - }; - match lib.kind { - NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), - NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), - NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()), - NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(), - &search_path) - } - } -} - -// Link in all of our upstream crates' native dependencies. Remember that -// all of these upstream native dependencies are all non-static -// dependencies. We've got two cases then: -// -// 1. The upstream crate is an rlib. In this case we *must* link in the -// native dependency because the rlib is just an archive. -// -// 2. The upstream crate is a dylib. In order to use the dylib, we have to -// have the dependency present on the system somewhere. Thus, we don't -// gain a whole lot from not linking in the dynamic dependency to this -// crate as well. -// -// The use case for this is a little subtle. In theory the native -// dependencies of a crate are purely an implementation detail of the crate -// itself, but the problem arises with generic and inlined functions. If a -// generic function calls a native function, then the generic function must -// be instantiated in the target crate, meaning that the native symbol must -// also be resolved in the target crate. -pub fn add_upstream_native_libraries(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - crate_type: config::CrateType) { - // Be sure to use a topological sorting of crates because there may be - // interdependencies between native libraries. When passing -nodefaultlibs, - // for example, almost all native libraries depend on libc, so we have to - // make sure that's all the way at the right (liblibc is near the base of - // the dependency chain). - // - // This passes RequireStatic, but the actual requirement doesn't matter, - // we're just getting an ordering of crate numbers, we're not worried about - // the paths. - let formats = sess.dependency_formats.borrow(); - let data = formats.get(&crate_type).unwrap(); - - let crates = &codegen_results.crate_info.used_crates_static; - for &(cnum, _) in crates { - for lib in codegen_results.crate_info.native_libraries[&cnum].iter() { - let name = match lib.name { - Some(ref l) => l, - None => continue, - }; - if !relevant_lib(sess, &lib) { - continue - } - match lib.kind { - NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()), - NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()), - NativeLibraryKind::NativeStaticNobundle => { - // Link "static-nobundle" native libs only if the crate they originate from - // is being linked statically to the current crate. If it's linked dynamically - // or is an rlib already included via some other dylib crate, the symbols from - // native libs will have already been included in that dylib. - if data[cnum.as_usize() - 1] == Linkage::Static { - cmd.link_staticlib(&name.as_str()) - } - }, - // ignore statically included native libraries here as we've - // already included them when we included the rust library - // previously - NativeLibraryKind::NativeStatic => {} - } - } - } -} - -fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool { - match lib.cfg { - Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None), - None => true, - } -} - -fn are_upstream_rust_objects_already_included(sess: &Session) -> bool { - match sess.lto() { - Lto::Fat => true, - Lto::Thin => { - // If we defer LTO to the linker, we haven't run LTO ourselves, so - // any upstream object files have not been copied yet. - !sess.opts.cg.linker_plugin_lto.enabled() - } - Lto::No | - Lto::ThinLocal => false, - } -} diff --git a/src/metadata.rs b/src/metadata.rs index c9cdb44d87d17..d7fd026dfaf0f 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,11 +1,10 @@ use rustc::middle::cstore::MetadataLoader; +use rustc_codegen_ssa::METADATA_FILENAME; use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::rustc_erase_owner; use std::fs::File; use std::path::Path; -pub const METADATA_FILENAME: &str = "rust.metadata.bin"; - pub struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { From cc0804e8157af4899d0de9d65202e83d4688eb84 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 21 Apr 2019 14:41:23 +0200 Subject: [PATCH 0623/1566] Rustup to rustc 1.36.0-nightly (33fe1131c 2019-04-20) --- src/base.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/base.rs b/src/base.rs index 0fb69e2a1e35f..eed66a2880692 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,3 +1,5 @@ +use rustc::ty::adjustment::PointerCast; + use crate::prelude::*; struct PrintOnPanic String>(F); @@ -530,7 +532,7 @@ fn trans_stmt<'a, 'tcx: 'a>( }; lval.write_cvalue(fx, CValue::ByVal(res, layout)); } - Rvalue::Cast(CastKind::ReifyFnPointer, operand, ty) => { + Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, ty) => { let layout = fx.layout_of(ty); match fx .monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)) @@ -547,8 +549,8 @@ fn trans_stmt<'a, 'tcx: 'a>( _ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", ty), } } - Rvalue::Cast(CastKind::UnsafeFnPointer, operand, ty) - | Rvalue::Cast(CastKind::MutToConstPointer, operand, ty) => { + Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), operand, ty) + | Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, ty) => { let operand = trans_operand(fx, operand); let layout = fx.layout_of(ty); lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); @@ -644,7 +646,7 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); } } - Rvalue::Cast(CastKind::ClosureFnPointer(_), operand, _ty) => { + Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), operand, _ty) => { let operand = trans_operand(fx, operand); match operand.layout().ty.sty { ty::Closure(def_id, substs) => { @@ -663,7 +665,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } } } - Rvalue::Cast(CastKind::Unsize, operand, _ty) => { + Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _ty) => { let operand = trans_operand(fx, operand); operand.unsize_value(fx, lval); } From 3fedac85e7d40bb5db956f940e6920d662427d06 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 1 Apr 2019 19:34:26 +0200 Subject: [PATCH 0624/1566] Let the ArArchiveBuilder implement cg_ssa::back::archive::ArchiveBuilder --- src/archive.rs | 98 ++++++++++++++++++++++++++++++++++++++++------ src/link_copied.rs | 30 +++----------- 2 files changed, 91 insertions(+), 37 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 44d1fd2c6f296..1445e291ce756 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,26 +1,37 @@ use std::collections::HashMap; use std::fs::File; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use crate::prelude::*; -pub struct ArchiveConfig<'a> { +use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; +use rustc_codegen_ssa::back::archive::{ArchiveBuilder, find_library}; + +struct ArchiveConfig<'a> { pub sess: &'a Session, pub dst: PathBuf, pub src: Option, pub lib_search_paths: Vec, } -pub struct ArchiveBuilder<'a> { - cfg: ArchiveConfig<'a>, +pub struct ArArchiveBuilder<'a> { + config: ArchiveConfig<'a>, src_archive: Option>, src_entries: HashMap, builder: ar::Builder, update_symbols: bool, } -impl<'a> ArchiveBuilder<'a> { - pub fn new(cfg: ArchiveConfig<'a>) -> Self { +impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { + fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self { + use rustc_codegen_ssa::back::link::archive_search_paths; + let cfg = ArchiveConfig { + sess, + dst: output.to_path_buf(), + src: input.map(|p| p.to_path_buf()), + lib_search_paths: archive_search_paths(sess), + }; + let (src_archive, src_entries) = if let Some(src) = &cfg.src { let mut archive = ar::Archive::new(File::open(src).unwrap()); let mut entries = HashMap::new(); @@ -42,8 +53,8 @@ impl<'a> ArchiveBuilder<'a> { let builder = ar::Builder::new(File::create(&cfg.dst).unwrap()); - ArchiveBuilder { - cfg, + ArArchiveBuilder { + config: cfg, src_archive, src_entries, builder, @@ -51,11 +62,11 @@ impl<'a> ArchiveBuilder<'a> { } } - pub fn src_files(&self) -> Vec { + fn src_files(&mut self) -> Vec { self.src_entries.keys().cloned().collect() } - pub fn remove_file(&mut self, name: &str) { + fn remove_file(&mut self, name: &str) { let file = self.src_entries.remove(name); assert!( file.is_some(), @@ -63,11 +74,47 @@ impl<'a> ArchiveBuilder<'a> { ); } - pub fn update_symbols(&mut self) { + fn add_file(&mut self, file: &Path) { + self.builder.append_path(file).unwrap(); + } + + fn add_native_library(&mut self, name: &str) { + let location = find_library(name, &self.config.lib_search_paths, self.config.sess); + self.add_archive(&location, |_| false).unwrap_or_else(|e| { + panic!("failed to add native library {}: {}", location.to_string_lossy(), e); + }); + } + + fn add_rlib(&mut self, rlib: &Path, name: &str, lto: bool, skip_objects: bool) -> std::io::Result<()> { + let obj_start = name.to_owned(); + + self.add_archive(rlib, move |fname: &str| { + // Ignore bytecode/metadata files, no matter the name. + if fname.ends_with(RLIB_BYTECODE_EXTENSION) || fname == METADATA_FILENAME { + return true; + } + + // Don't include Rust objects if LTO is enabled + if lto && fname.starts_with(&obj_start) && fname.ends_with(".o") { + return true; + } + + // Otherwise if this is *not* a rust object and we're skipping + // objects then skip this file + if skip_objects && (!fname.starts_with(&obj_start) || !fname.ends_with(".o")) { + return true; + } + + // ok, don't skip this + return false; + }) + } + + fn update_symbols(&mut self) { self.update_symbols = true; } - pub fn build(mut self) { + fn build(mut self) { // Add files from original archive if let Some(mut src_archive) = self.src_archive { for (_entry_name, entry_idx) in self.src_entries.into_iter() { @@ -88,7 +135,7 @@ impl<'a> ArchiveBuilder<'a> { // Run ranlib to be able to link the archive let status = std::process::Command::new("ranlib") - .arg(self.cfg.dst) + .arg(self.config.dst) .status() .expect("Couldn't run ranlib"); assert!( @@ -98,3 +145,28 @@ impl<'a> ArchiveBuilder<'a> { ); } } + +impl<'a> ArArchiveBuilder<'a> { + fn add_archive(&mut self, archive: &Path, mut skip: F) -> std::io::Result<()> + where F: FnMut(&str) -> bool + 'static + { + let mut archive = ar::Archive::new(std::fs::File::open(archive)?); + while let Some(entry) = archive.next_entry() { + let entry = entry?; + let orig_header = entry.header(); + + if skip(std::str::from_utf8(orig_header.identifier()).unwrap()) { + continue; + } + + let mut header = + ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); + header.set_mtime(orig_header.mtime()); + header.set_uid(orig_header.uid()); + header.set_gid(orig_header.gid()); + header.set_mode(orig_header.mode()); + self.builder.append(&header, entry).unwrap(); + } + Ok(()) + } +} diff --git a/src/link_copied.rs b/src/link_copied.rs index d58ffda3336c2..a1205b079437e 100644 --- a/src/link_copied.rs +++ b/src/link_copied.rs @@ -1,38 +1,22 @@ //! All functions here are copied from https://github.com/rust-lang/rust/blob/942864a000efd74b73e36bda5606b2cdb55ecf39/src/librustc_codegen_llvm/back/link.rs -use std::path::{Path, PathBuf}; +use std::path::Path; -use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind}; +use rustc::middle::cstore::NativeLibraryKind; use rustc::middle::dependency_format::Linkage; use rustc::session::config::{self, OutputType, RUST_CGU_EXT}; -use rustc::session::search_paths::PathKind; use rustc::session::Session; use rustc::util::common::time; use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; +use rustc_codegen_ssa::back::archive::ArchiveBuilder; use rustc_codegen_ssa::back::linker::*; use rustc_codegen_ssa::back::link::*; use rustc_data_structures::fx::FxHashSet; use rustc_fs_util::fix_windows_verbatim_for_gcc; -use syntax::attr; use crate::prelude::*; -use crate::archive::{ArchiveBuilder, ArchiveConfig}; - -fn archive_search_paths(sess: &Session) -> Vec { - sess.target_filesearch(PathKind::Native).search_path_dirs() -} - -fn archive_config<'a>(sess: &'a Session, - output: &Path, - input: Option<&Path>) -> ArchiveConfig<'a> { - ArchiveConfig { - sess, - dst: output.to_path_buf(), - src: input.map(|p| p.to_path_buf()), - lib_search_paths: archive_search_paths(sess), - } -} +use crate::archive::ArArchiveBuilder; // # Rust Crate linking // @@ -184,8 +168,7 @@ pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, } let dst = tmpdir.join(cratepath.file_name().unwrap()); - let cfg = archive_config(sess, &dst, Some(cratepath)); - let mut archive = ArchiveBuilder::new(cfg); + let mut archive = ArArchiveBuilder::new(sess, &dst, Some(cratepath)); archive.update_symbols(); for f in archive.src_files() { @@ -261,8 +244,7 @@ pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, let name = &name[3..name.len() - 5]; // chop off lib/.rlib time(sess, &format!("altering {}.rlib", name), || { - let cfg = archive_config(sess, &dst, Some(cratepath)); - let mut archive = ArchiveBuilder::new(cfg); + let mut archive = ArArchiveBuilder::new(sess, &dst, Some(cratepath)); archive.update_symbols(); let mut any_objects = false; From 004dc33031f40e5d50c155e16e053553ac02cf49 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Apr 2019 18:41:07 +0200 Subject: [PATCH 0625/1566] Refactor archive.rs for future usage of ar::GnuBuilder --- src/archive.rs | 97 ++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 1445e291ce756..fb17bc8844133 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -14,25 +14,29 @@ struct ArchiveConfig<'a> { pub lib_search_paths: Vec, } +enum ArchiveEntry { + FromArchive { archive_index: usize, entry_index: usize }, + File(File), +} + pub struct ArArchiveBuilder<'a> { config: ArchiveConfig<'a>, - src_archive: Option>, - src_entries: HashMap, - builder: ar::Builder, + src_archives: Vec>, + entries: HashMap, update_symbols: bool, } impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self { use rustc_codegen_ssa::back::link::archive_search_paths; - let cfg = ArchiveConfig { + let config = ArchiveConfig { sess, dst: output.to_path_buf(), src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), }; - let (src_archive, src_entries) = if let Some(src) = &cfg.src { + let (src_archives, entries) = if let Some(src) = &config.src { let mut archive = ar::Archive::new(File::open(src).unwrap()); let mut entries = HashMap::new(); @@ -41,33 +45,30 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let entry = entry.unwrap(); entries.insert( String::from_utf8(entry.header().identifier().to_vec()).unwrap(), - i, + ArchiveEntry::FromArchive { archive_index: 0, entry_index: i }, ); i += 1; } - (Some(archive), entries) + (vec![archive], entries) } else { - (None, HashMap::new()) + (vec![], HashMap::new()) }; - let builder = ar::Builder::new(File::create(&cfg.dst).unwrap()); - ArArchiveBuilder { - config: cfg, - src_archive, - src_entries, - builder, + config, + src_archives, + entries, update_symbols: false, } } fn src_files(&mut self) -> Vec { - self.src_entries.keys().cloned().collect() + self.entries.keys().cloned().collect() } fn remove_file(&mut self, name: &str) { - let file = self.src_entries.remove(name); + let file = self.entries.remove(name); assert!( file.is_some(), "Tried to remove file not existing in src archive", @@ -75,7 +76,10 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn add_file(&mut self, file: &Path) { - self.builder.append_path(file).unwrap(); + self.entries.insert( + file.file_name().unwrap().to_str().unwrap().to_string(), + ArchiveEntry::File(File::open(file).unwrap()), + ); } fn add_native_library(&mut self, name: &str) { @@ -115,23 +119,30 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn build(mut self) { - // Add files from original archive - if let Some(mut src_archive) = self.src_archive { - for (_entry_name, entry_idx) in self.src_entries.into_iter() { - let entry = src_archive.jump_to_entry(entry_idx).unwrap(); - let orig_header = entry.header(); - let mut header = - ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); - header.set_mtime(orig_header.mtime()); - header.set_uid(orig_header.uid()); - header.set_gid(orig_header.gid()); - header.set_mode(orig_header.mode()); - self.builder.append(&header, entry).unwrap(); + let mut builder = ar::Builder::new(File::create(&self.config.dst).unwrap()); + + // Add all files + for (entry_name, entry) in self.entries.into_iter() { + match entry { + ArchiveEntry::FromArchive { archive_index, entry_index } => { + let entry = self.src_archives[archive_index].jump_to_entry(entry_index).unwrap(); + let orig_header = entry.header(); + let mut header = + ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); + header.set_mtime(orig_header.mtime()); + header.set_uid(orig_header.uid()); + header.set_gid(orig_header.gid()); + header.set_mode(orig_header.mode()); + builder.append(&header, entry).unwrap(); + } + ArchiveEntry::File(mut file) => { + builder.append_file(entry_name.as_bytes(), &mut file).unwrap(); + } } } // Finalize archive - std::mem::drop(self.builder); + std::mem::drop(builder); // Run ranlib to be able to link the archive let status = std::process::Command::new("ranlib") @@ -151,22 +162,22 @@ impl<'a> ArArchiveBuilder<'a> { where F: FnMut(&str) -> bool + 'static { let mut archive = ar::Archive::new(std::fs::File::open(archive)?); - while let Some(entry) = archive.next_entry() { - let entry = entry?; - let orig_header = entry.header(); + let archive_index = self.src_archives.len(); - if skip(std::str::from_utf8(orig_header.identifier()).unwrap()) { - continue; + let mut i = 0; + while let Some(entry) = archive.next_entry() { + let entry = entry.unwrap(); + let file_name = String::from_utf8(entry.header().identifier().to_vec()).unwrap(); + if !skip(&file_name) { + self.entries.insert( + file_name, + ArchiveEntry::FromArchive { archive_index, entry_index: i }, + ); } - - let mut header = - ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); - header.set_mtime(orig_header.mtime()); - header.set_uid(orig_header.uid()); - header.set_gid(orig_header.gid()); - header.set_mode(orig_header.mode()); - self.builder.append(&header, entry).unwrap(); + i += 1; } + + self.src_archives.push(archive); Ok(()) } } From 8c2bd3ec649f6334872a832980d31603986389a1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Apr 2019 16:35:00 +0200 Subject: [PATCH 0626/1566] Rustup to rustc 1.36.0-nightly (e938c2b9a 2019-04-23) --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 13036cc121d51..87056f679a620 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -190,7 +190,7 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( linkage: Linkage, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); - let is_mutable = if let ::rustc::hir::Mutability::MutMutable = tcx.is_static(def_id).unwrap() { + let is_mutable = if tcx.is_mutable_static(def_id) { true } else { !tcx.type_of(def_id) From 964edb9a618528247637c0fed6cf174bd8fe5e50 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Apr 2019 16:35:58 +0200 Subject: [PATCH 0627/1566] Don't remove incremental cache for sysroot building This more than halves compilation time for the sysroot --- build_sysroot/build_sysroot.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 5e1d0904753f8..57752c402c547 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -3,7 +3,8 @@ set -e cd $(dirname "$0") # Cleanup for previous run -cargo clean +# v Clean target dir except for build scripts and incremental cache +rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true rm Cargo.lock 2>/dev/null || true rm -r sysroot 2>/dev/null || true From 472b591f90c237efb3683b9addc49b98ef0fb797 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 1 Apr 2019 19:34:26 +0200 Subject: [PATCH 0628/1566] Use rustc_codegen_ssa::back::link instead of copy pasted version --- src/lib.rs | 26 ++- src/link.rs | 463 --------------------------------------------- src/link_copied.rs | 336 -------------------------------- 3 files changed, 12 insertions(+), 813 deletions(-) delete mode 100644 src/link.rs delete mode 100644 src/link_copied.rs diff --git a/src/lib.rs b/src/lib.rs index 8fb35c6e34212..53dc644ddc4dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,6 @@ use rustc::util::common::ErrorReported; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; use rustc_codegen_utils::codegen_backend::CodegenBackend; -use rustc_codegen_utils::link::out_filename; use rustc_mir::monomorphize::partitioning::CodegenUnitExt; use cranelift::codegen::settings; @@ -46,8 +45,6 @@ mod common; mod constant; mod debuginfo; mod intrinsics; -mod link; -mod link_copied; mod linkage; mod main_shim; mod metadata; @@ -366,20 +363,21 @@ impl CodegenBackend for CraneliftCodegenBackend { _dep_graph: &DepGraph, outputs: &OutputFilenames, ) -> Result<(), ErrorReported> { - let res = *res + use rustc_codegen_ssa::back::link::link_binary; + + let codegen_results = *res .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); - for &crate_type in sess.crate_types.borrow().iter() { - let output_name = out_filename(sess, crate_type, &outputs, &res.crate_name.as_str()); - match crate_type { - CrateType::Rlib => link::link_rlib(sess, &res, output_name), - CrateType::Dylib | CrateType::Executable => { - link::link_natively(sess, crate_type, &res, &output_name); - } - _ => sess.fatal(&format!("Unsupported crate type: {:?}", crate_type)), - } - } + let target_cpu = ::target_lexicon::HOST.to_string(); + link_binary::>( + sess, + &codegen_results, + outputs, + &codegen_results.crate_name.as_str(), + &target_cpu, + ); + Ok(()) } } diff --git a/src/link.rs b/src/link.rs deleted file mode 100644 index 7694892a8e80a..0000000000000 --- a/src/link.rs +++ /dev/null @@ -1,463 +0,0 @@ -use std::ascii; -use std::char; -use std::env; -use std::fs::File; -use std::io; -use std::path::{Path, PathBuf}; -use std::str; - -use tempfile::Builder as TempFileBuilder; - -use rustc::session::config::{self, CrateType, DebugInfo, RUST_CGU_EXT}; -use rustc::session::search_paths::PathKind; -use rustc::session::Session; -use rustc_codegen_ssa::METADATA_FILENAME; -use rustc_codegen_ssa::back::command::Command; -use rustc_codegen_ssa::back::link::*; -use rustc_codegen_ssa::back::linker::*; -use rustc_fs_util::fix_windows_verbatim_for_gcc; -use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel}; - -use crate::prelude::*; - -use crate::link_copied::*; - -pub(crate) fn link_rlib(sess: &Session, res: &CodegenResults, output_name: PathBuf) { - let file = File::create(&output_name).unwrap(); - let mut builder = ar::Builder::new(file); - - // Add main object file - for module in &res.modules { - if let Some(ref object_path) = module.object { - let object = File::open(object_path).expect("Someone deleted our object file"); - let object_len = object.metadata().unwrap().len(); - builder - .append( - &ar::Header::new( - (module.name.to_string() + RUST_CGU_EXT).into_bytes(), - object_len, - ), - object, - ) - .unwrap(); - } - } - - // Non object files need to be added after object files, because ranlib will - // try to read the native architecture from the first file, even if it isn't - // an object file - builder - .append( - &ar::Header::new( - METADATA_FILENAME.as_bytes().to_vec(), - res.metadata.raw_data.len() as u64, - ), - ::std::io::Cursor::new(res.metadata.raw_data.clone()), - ) - .unwrap(); - - // Finalize archive - std::mem::drop(builder); - - // Run ranlib to be able to link the archive - let status = std::process::Command::new("ranlib") - .arg(output_name) - .status() - .expect("Couldn't run ranlib"); - if !status.success() { - sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); - } -} - -pub(crate) fn link_natively( - sess: &Session, - crate_type: CrateType, - codegen_results: &CodegenResults, - out_filename: &Path, -) { - let tmpdir = match TempFileBuilder::new().prefix("rustc").tempdir() { - Ok(tmpdir) => tmpdir, - Err(err) => sess.fatal(&format!("couldn't create a temp dir: {}", err)), - }; - - let (linker, flavor) = linker_and_flavor(sess); - - // The invocations of cc share some flags across platforms - let (pname, mut cmd) = get_linker(sess, &linker, flavor); - - let root = sess.target_filesearch(PathKind::Native).get_lib_path(); - if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) { - cmd.args(args); - } - if let Some(args) = sess.target.target.options.pre_link_args_crt.get(&flavor) { - if sess.crt_static() { - cmd.args(args); - } - } - if let Some(ref args) = sess.opts.debugging_opts.pre_link_args { - cmd.args(args); - } - cmd.args(&sess.opts.debugging_opts.pre_link_arg); - - let pre_link_objects = if crate_type == config::CrateType::Executable { - &sess.target.target.options.pre_link_objects_exe - } else { - &sess.target.target.options.pre_link_objects_dll - }; - for obj in pre_link_objects { - cmd.arg(root.join(obj)); - } - - if crate_type == config::CrateType::Executable && sess.crt_static() { - for obj in &sess.target.target.options.pre_link_objects_exe_crt { - cmd.arg(root.join(obj)); - } - } - - if sess.target.target.options.is_like_emscripten { - cmd.arg("-s"); - cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort { - "DISABLE_EXCEPTION_CATCHING=1" - } else { - "DISABLE_EXCEPTION_CATCHING=0" - }); - } - - { - let target_cpu = ::target_lexicon::HOST.to_string(); - let mut linker = codegen_results.linker_info.to_linker(cmd, &sess, flavor, &target_cpu); - link_args(&mut *linker, flavor, sess, crate_type, tmpdir.path(), - out_filename, codegen_results); - cmd = linker.finalize(); - } - if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) { - cmd.args(args); - } - for obj in &sess.target.target.options.post_link_objects { - cmd.arg(root.join(obj)); - } - if sess.crt_static() { - for obj in &sess.target.target.options.post_link_objects_crt { - cmd.arg(root.join(obj)); - } - } - if let Some(args) = sess.target.target.options.post_link_args.get(&flavor) { - cmd.args(args); - } - for &(ref k, ref v) in &sess.target.target.options.link_env { - cmd.env(k, v); - } - - if sess.opts.debugging_opts.print_link_args { - println!("{:?}", &cmd); - } - - // May have not found libraries in the right formats. - sess.abort_if_errors(); - - // Invoke the system linker - // - // Note that there's a terribly awful hack that really shouldn't be present - // in any compiler. Here an environment variable is supported to - // automatically retry the linker invocation if the linker looks like it - // segfaulted. - // - // Gee that seems odd, normally segfaults are things we want to know about! - // Unfortunately though in rust-lang/rust#38878 we're experiencing the - // linker segfaulting on Travis quite a bit which is causing quite a bit of - // pain to land PRs when they spuriously fail due to a segfault. - // - // The issue #38878 has some more debugging information on it as well, but - // this unfortunately looks like it's just a race condition in macOS's linker - // with some thread pool working in the background. It seems that no one - // currently knows a fix for this so in the meantime we're left with this... - let retry_on_segfault = env::var("RUSTC_RETRY_LINKER_ON_SEGFAULT").is_ok(); - let mut prog; - let mut i = 0; - loop { - i += 1; - prog = exec_linker(sess, &mut cmd, out_filename, tmpdir.path()); - let output = match prog { - Ok(ref output) => output, - Err(_) => break, - }; - if output.status.success() { - break - } - let mut out = output.stderr.clone(); - out.extend(&output.stdout); - let out = String::from_utf8_lossy(&out); - - // Check to see if the link failed with "unrecognized command line option: - // '-no-pie'" for gcc or "unknown argument: '-no-pie'" for clang. If so, - // reperform the link step without the -no-pie option. This is safe because - // if the linker doesn't support -no-pie then it should not default to - // linking executables as pie. Different versions of gcc seem to use - // different quotes in the error message so don't check for them. - if sess.target.target.options.linker_is_gnu && - flavor != LinkerFlavor::Ld && - (out.contains("unrecognized command line option") || - out.contains("unknown argument")) && - out.contains("-no-pie") && - cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") { - for arg in cmd.take_args() { - if arg.to_string_lossy() != "-no-pie" { - cmd.arg(arg); - } - } - continue; - } - if !retry_on_segfault || i > 3 { - break - } - let msg_segv = "clang: error: unable to execute command: Segmentation fault: 11"; - let msg_bus = "clang: error: unable to execute command: Bus error: 10"; - if !(out.contains(msg_segv) || out.contains(msg_bus)) { - break - } - } - - match prog { - Ok(prog) => { - fn escape_string(s: &[u8]) -> String { - str::from_utf8(s).map(|s| s.to_owned()) - .unwrap_or_else(|_| { - let mut x = "Non-UTF-8 output: ".to_string(); - x.extend(s.iter() - .flat_map(|&b| ascii::escape_default(b)) - .map(char::from)); - x - }) - } - if !prog.status.success() { - let mut output = prog.stderr.clone(); - output.extend_from_slice(&prog.stdout); - sess.struct_err(&format!("linking with `{}` failed: {}", - pname.display(), - prog.status)) - .note(&format!("{:?}", &cmd)) - .note(&escape_string(&output)) - .emit(); - sess.abort_if_errors(); - } - }, - Err(e) => { - let linker_not_found = e.kind() == io::ErrorKind::NotFound; - - let mut linker_error = { - if linker_not_found { - sess.struct_err(&format!("linker `{}` not found", pname.display())) - } else { - sess.struct_err(&format!("could not exec the linker `{}`", pname.display())) - } - }; - - linker_error.note(&e.to_string()); - - if !linker_not_found { - linker_error.note(&format!("{:?}", &cmd)); - } - - linker_error.emit(); - - if sess.target.target.options.is_like_msvc && linker_not_found { - sess.note_without_error("the msvc targets depend on the msvc linker \ - but `link.exe` was not found"); - sess.note_without_error("please ensure that VS 2013, VS 2015 or VS 2017 \ - was installed with the Visual C++ option"); - } - sess.abort_if_errors(); - } - } - - - // On macOS, debuggers need this utility to get run to do some munging of - // the symbols. Note, though, that if the object files are being preserved - // for their debug information there's no need for us to run dsymutil. - if sess.target.target.options.is_like_osx && - sess.opts.debuginfo != DebugInfo::None - { - if let Err(e) = Command::new("dsymutil").arg(out_filename).output() { - sess.fatal(&format!("failed to run dsymutil: {}", e)) - } - } -} - -fn link_args(cmd: &mut dyn Linker, - flavor: LinkerFlavor, - sess: &Session, - crate_type: config::CrateType, - tmpdir: &Path, - out_filename: &Path, - codegen_results: &CodegenResults) { - - // Linker plugins should be specified early in the list of arguments - cmd.linker_plugin_lto(); - - // The default library location, we need this to find the runtime. - // The location of crates will be determined as needed. - let lib_path = sess.target_filesearch(PathKind::All).get_lib_path(); - - // target descriptor - let t = &sess.target.target; - - cmd.include_path(&fix_windows_verbatim_for_gcc(&lib_path)); - for obj in codegen_results.modules.iter().filter_map(|m| m.object.as_ref()) { - cmd.add_object(obj); - } - cmd.output_filename(out_filename); - - if crate_type == config::CrateType::Executable && - sess.target.target.options.is_like_windows { - if let Some(ref s) = codegen_results.windows_subsystem { - cmd.subsystem(s); - } - } - - // If we're building a dynamic library then some platforms need to make sure - // that all symbols are exported correctly from the dynamic library. - if crate_type != config::CrateType::Executable || - sess.target.target.options.is_like_emscripten { - cmd.export_symbols(tmpdir, crate_type); - } - - // When linking a dynamic library, we put the metadata into a section of the - // executable. This metadata is in a separate object file from the main - // object file, so we link that in here. - if crate_type == config::CrateType::Dylib || - crate_type == config::CrateType::ProcMacro { - if let Some(obj) = codegen_results.metadata_module.object.as_ref() { - cmd.add_object(obj); - } - } - - let obj = codegen_results.allocator_module - .as_ref() - .and_then(|m| m.object.as_ref()); - if let Some(obj) = obj { - cmd.add_object(obj); - } - - // Try to strip as much out of the generated object by removing unused - // sections if possible. See more comments in linker.rs - if !sess.opts.cg.link_dead_code { - let keep_metadata = crate_type == config::CrateType::Dylib; - cmd.gc_sections(keep_metadata); - } - - let used_link_args = &codegen_results.crate_info.link_args; - - if crate_type == config::CrateType::Executable { - let mut position_independent_executable = false; - - if t.options.position_independent_executables { - let empty_vec = Vec::new(); - let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec); - let more_args = &sess.opts.cg.link_arg; - let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter()); - - if !sess.crt_static() && !args.any(|x| *x == "-static") { - position_independent_executable = true; - } - } - - if position_independent_executable { - cmd.position_independent_executable(); - } else { - // recent versions of gcc can be configured to generate position - // independent executables by default. We have to pass -no-pie to - // explicitly turn that off. Not applicable to ld. - if sess.target.target.options.linker_is_gnu - && flavor != LinkerFlavor::Ld { - cmd.no_position_independent_executable(); - } - } - } - - let relro_level = match sess.opts.debugging_opts.relro_level { - Some(level) => level, - None => t.options.relro_level, - }; - match relro_level { - RelroLevel::Full => { - cmd.full_relro(); - }, - RelroLevel::Partial => { - cmd.partial_relro(); - }, - RelroLevel::Off => { - cmd.no_relro(); - }, - RelroLevel::None => { - }, - } - - // Pass optimization flags down to the linker. - cmd.optimize(); - - // Pass debuginfo flags down to the linker. - cmd.debuginfo(); - - // We want to, by default, prevent the compiler from accidentally leaking in - // any system libraries, so we may explicitly ask linkers to not link to any - // libraries by default. Note that this does not happen for windows because - // windows pulls in some large number of libraries and I couldn't quite - // figure out which subset we wanted. - // - // This is all naturally configurable via the standard methods as well. - if !sess.opts.cg.default_linker_libraries.unwrap_or(false) && - t.options.no_default_libraries - { - cmd.no_default_libraries(); - } - - // Take careful note of the ordering of the arguments we pass to the linker - // here. Linkers will assume that things on the left depend on things to the - // right. Things on the right cannot depend on things on the left. This is - // all formally implemented in terms of resolving symbols (libs on the right - // resolve unknown symbols of libs on the left, but not vice versa). - // - // For this reason, we have organized the arguments we pass to the linker as - // such: - // - // 1. The local object that LLVM just generated - // 2. Local native libraries - // 3. Upstream rust libraries - // 4. Upstream native libraries - // - // The rationale behind this ordering is that those items lower down in the - // list can't depend on items higher up in the list. For example nothing can - // depend on what we just generated (e.g., that'd be a circular dependency). - // Upstream rust libraries are not allowed to depend on our local native - // libraries as that would violate the structure of the DAG, in that - // scenario they are required to link to them as well in a shared fashion. - // - // Note that upstream rust libraries may contain native dependencies as - // well, but they also can't depend on what we just started to add to the - // link line. And finally upstream native libraries can't depend on anything - // in this DAG so far because they're only dylibs and dylibs can only depend - // on other dylibs (e.g., other native deps). - add_local_native_libraries(cmd, sess, codegen_results); - add_upstream_rust_crates(cmd, sess, codegen_results, crate_type, tmpdir); - add_upstream_native_libraries(cmd, sess, codegen_results, crate_type); - - // Tell the linker what we're doing. - if crate_type != config::CrateType::Executable { - cmd.build_dylib(out_filename); - } - if crate_type == config::CrateType::Executable && sess.crt_static() { - cmd.build_static_executable(); - } - - if sess.opts.debugging_opts.pgo_gen.enabled() { - cmd.pgo_gen(); - } - - // Finally add all the linker arguments provided on the command line along - // with any #[link_args] attributes found inside the crate - if let Some(ref args) = sess.opts.cg.link_args { - cmd.args(args); - } - cmd.args(&sess.opts.cg.link_arg); - cmd.args(&used_link_args); -} diff --git a/src/link_copied.rs b/src/link_copied.rs deleted file mode 100644 index a1205b079437e..0000000000000 --- a/src/link_copied.rs +++ /dev/null @@ -1,336 +0,0 @@ -//! All functions here are copied from https://github.com/rust-lang/rust/blob/942864a000efd74b73e36bda5606b2cdb55ecf39/src/librustc_codegen_llvm/back/link.rs - -use std::path::Path; - -use rustc::middle::cstore::NativeLibraryKind; -use rustc::middle::dependency_format::Linkage; -use rustc::session::config::{self, OutputType, RUST_CGU_EXT}; -use rustc::session::Session; -use rustc::util::common::time; -use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; -use rustc_codegen_ssa::back::archive::ArchiveBuilder; -use rustc_codegen_ssa::back::linker::*; -use rustc_codegen_ssa::back::link::*; -use rustc_data_structures::fx::FxHashSet; -use rustc_fs_util::fix_windows_verbatim_for_gcc; - -use crate::prelude::*; - -use crate::archive::ArArchiveBuilder; - -// # Rust Crate linking -// -// Rust crates are not considered at all when creating an rlib output. All -// dependencies will be linked when producing the final output (instead of -// the intermediate rlib version) -pub fn add_upstream_rust_crates(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - crate_type: config::CrateType, - tmpdir: &Path) { - // All of the heavy lifting has previously been accomplished by the - // dependency_format module of the compiler. This is just crawling the - // output of that module, adding crates as necessary. - // - // Linking to a rlib involves just passing it to the linker (the linker - // will slurp up the object files inside), and linking to a dynamic library - // involves just passing the right -l flag. - - let formats = sess.dependency_formats.borrow(); - let data = formats.get(&crate_type).unwrap(); - - // Invoke get_used_crates to ensure that we get a topological sorting of - // crates. - let deps = &codegen_results.crate_info.used_crates_dynamic; - - // There's a few internal crates in the standard library (aka libcore and - // libstd) which actually have a circular dependence upon one another. This - // currently arises through "weak lang items" where libcore requires things - // like `rust_begin_unwind` but libstd ends up defining it. To get this - // circular dependence to work correctly in all situations we'll need to be - // sure to correctly apply the `--start-group` and `--end-group` options to - // GNU linkers, otherwise if we don't use any other symbol from the standard - // library it'll get discarded and the whole application won't link. - // - // In this loop we're calculating the `group_end`, after which crate to - // pass `--end-group` and `group_start`, before which crate to pass - // `--start-group`. We currently do this by passing `--end-group` after - // the first crate (when iterating backwards) that requires a lang item - // defined somewhere else. Once that's set then when we've defined all the - // necessary lang items we'll pass `--start-group`. - // - // Note that this isn't amazing logic for now but it should do the trick - // for the current implementation of the standard library. - let mut group_end = None; - let mut group_start = None; - let mut end_with = FxHashSet::default(); - let info = &codegen_results.crate_info; - for &(cnum, _) in deps.iter().rev() { - if let Some(missing) = info.missing_lang_items.get(&cnum) { - end_with.extend(missing.iter().cloned()); - if end_with.len() > 0 && group_end.is_none() { - group_end = Some(cnum); - } - } - end_with.retain(|item| info.lang_item_to_crate.get(item) != Some(&cnum)); - if end_with.len() == 0 && group_end.is_some() { - group_start = Some(cnum); - break - } - } - - // If we didn't end up filling in all lang items from upstream crates then - // we'll be filling it in with our crate. This probably means we're the - // standard library itself, so skip this for now. - if group_end.is_some() && group_start.is_none() { - group_end = None; - } - - let mut compiler_builtins = None; - - for &(cnum, _) in deps.iter() { - if group_start == Some(cnum) { - cmd.group_start(); - } - - // We may not pass all crates through to the linker. Some crates may - // appear statically in an existing dylib, meaning we'll pick up all the - // symbols from the dylib. - let src = &codegen_results.crate_info.used_crate_source[&cnum]; - match data[cnum.as_usize() - 1] { - _ if codegen_results.crate_info.profiler_runtime == Some(cnum) => { - add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); - } - _ if codegen_results.crate_info.sanitizer_runtime == Some(cnum) => { - link_sanitizer_runtime(cmd, sess, codegen_results, tmpdir, cnum); - } - // compiler-builtins are always placed last to ensure that they're - // linked correctly. - _ if codegen_results.crate_info.compiler_builtins == Some(cnum) => { - assert!(compiler_builtins.is_none()); - compiler_builtins = Some(cnum); - } - Linkage::NotLinked | - Linkage::IncludedFromDylib => {} - Linkage::Static => { - add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); - } - Linkage::Dynamic => { - add_dynamic_crate(cmd, sess, &src.dylib.as_ref().unwrap().0) - } - } - - if group_end == Some(cnum) { - cmd.group_end(); - } - } - - // compiler-builtins are always placed last to ensure that they're - // linked correctly. - // We must always link the `compiler_builtins` crate statically. Even if it - // was already "included" in a dylib (e.g., `libstd` when `-C prefer-dynamic` - // is used) - if let Some(cnum) = compiler_builtins { - add_static_crate(cmd, sess, codegen_results, tmpdir, crate_type, cnum); - } - - // Converts a library file-stem into a cc -l argument - fn unlib<'a>(config: &config::Config, stem: &'a str) -> &'a str { - if stem.starts_with("lib") && !config.target.options.is_like_windows { - &stem[3..] - } else { - stem - } - } - - // We must link the sanitizer runtime using -Wl,--whole-archive but since - // it's packed in a .rlib, it contains stuff that are not objects that will - // make the linker error. So we must remove those bits from the .rlib before - // linking it. - fn link_sanitizer_runtime(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - tmpdir: &Path, - cnum: CrateNum) { - let src = &codegen_results.crate_info.used_crate_source[&cnum]; - let cratepath = &src.rlib.as_ref().unwrap().0; - - if sess.target.target.options.is_like_osx { - // On Apple platforms, the sanitizer is always built as a dylib, and - // LLVM will link to `@rpath/*.dylib`, so we need to specify an - // rpath to the library as well (the rpath should be absolute, see - // PR #41352 for details). - // - // FIXME: Remove this logic into librustc_*san once Cargo supports it - let rpath = cratepath.parent().unwrap(); - let rpath = rpath.to_str().expect("non-utf8 component in path"); - cmd.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]); - } - - let dst = tmpdir.join(cratepath.file_name().unwrap()); - let mut archive = ArArchiveBuilder::new(sess, &dst, Some(cratepath)); - archive.update_symbols(); - - for f in archive.src_files() { - if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { - archive.remove_file(&f); - } - } - - archive.build(); - - cmd.link_whole_rlib(&dst); - } - - // Adds the static "rlib" versions of all crates to the command line. - // There's a bit of magic which happens here specifically related to LTO and - // dynamic libraries. Specifically: - // - // * For LTO, we remove upstream object files. - // * For dylibs we remove metadata and bytecode from upstream rlibs - // - // When performing LTO, almost(*) all of the bytecode from the upstream - // libraries has already been included in our object file output. As a - // result we need to remove the object files in the upstream libraries so - // the linker doesn't try to include them twice (or whine about duplicate - // symbols). We must continue to include the rest of the rlib, however, as - // it may contain static native libraries which must be linked in. - // - // (*) Crates marked with `#![no_builtins]` don't participate in LTO and - // their bytecode wasn't included. The object files in those libraries must - // still be passed to the linker. - // - // When making a dynamic library, linkers by default don't include any - // object files in an archive if they're not necessary to resolve the link. - // We basically want to convert the archive (rlib) to a dylib, though, so we - // *do* want everything included in the output, regardless of whether the - // linker thinks it's needed or not. As a result we must use the - // --whole-archive option (or the platform equivalent). When using this - // option the linker will fail if there are non-objects in the archive (such - // as our own metadata and/or bytecode). All in all, for rlibs to be - // entirely included in dylibs, we need to remove all non-object files. - // - // Note, however, that if we're not doing LTO or we're not producing a dylib - // (aka we're making an executable), we can just pass the rlib blindly to - // the linker (fast) because it's fine if it's not actually included as - // we're at the end of the dependency chain. - fn add_static_crate(cmd: &mut dyn Linker, - sess: &Session, - codegen_results: &CodegenResults, - tmpdir: &Path, - crate_type: config::CrateType, - cnum: CrateNum) { - let src = &codegen_results.crate_info.used_crate_source[&cnum]; - let cratepath = &src.rlib.as_ref().unwrap().0; - - // See the comment above in `link_staticlib` and `link_rlib` for why if - // there's a static library that's not relevant we skip all object - // files. - let native_libs = &codegen_results.crate_info.native_libraries[&cnum]; - let skip_native = native_libs.iter().any(|lib| { - lib.kind == NativeLibraryKind::NativeStatic && !relevant_lib(sess, lib) - }); - - if (!are_upstream_rust_objects_already_included(sess) || - ignored_for_lto(sess, &codegen_results.crate_info, cnum)) && - crate_type != config::CrateType::Dylib && - !skip_native { - cmd.link_rlib(&fix_windows_verbatim_for_gcc(cratepath)); - return - } - - let dst = tmpdir.join(cratepath.file_name().unwrap()); - let name = cratepath.file_name().unwrap().to_str().unwrap(); - let name = &name[3..name.len() - 5]; // chop off lib/.rlib - - time(sess, &format!("altering {}.rlib", name), || { - let mut archive = ArArchiveBuilder::new(sess, &dst, Some(cratepath)); - archive.update_symbols(); - - let mut any_objects = false; - for f in archive.src_files() { - if f.ends_with(RLIB_BYTECODE_EXTENSION) || f == METADATA_FILENAME { - archive.remove_file(&f); - continue - } - - let canonical = f.replace("-", "_"); - let canonical_name = name.replace("-", "_"); - - // Look for `.rcgu.o` at the end of the filename to conclude - // that this is a Rust-related object file. - fn looks_like_rust(s: &str) -> bool { - let path = Path::new(s); - let ext = path.extension().and_then(|s| s.to_str()); - if ext != Some(OutputType::Object.extension()) { - return false - } - let ext2 = path.file_stem() - .and_then(|s| Path::new(s).extension()) - .and_then(|s| s.to_str()); - ext2 == Some(RUST_CGU_EXT) - } - - let is_rust_object = - canonical.starts_with(&canonical_name) && - looks_like_rust(&f); - - // If we've been requested to skip all native object files - // (those not generated by the rust compiler) then we can skip - // this file. See above for why we may want to do this. - let skip_because_cfg_say_so = skip_native && !is_rust_object; - - // If we're performing LTO and this is a rust-generated object - // file, then we don't need the object file as it's part of the - // LTO module. Note that `#![no_builtins]` is excluded from LTO, - // though, so we let that object file slide. - let skip_because_lto = are_upstream_rust_objects_already_included(sess) && - is_rust_object && - (sess.target.target.options.no_builtins || - !codegen_results.crate_info.is_no_builtins.contains(&cnum)); - - if skip_because_cfg_say_so || skip_because_lto { - archive.remove_file(&f); - } else { - any_objects = true; - } - } - - if !any_objects { - return - } - archive.build(); - - // If we're creating a dylib, then we need to include the - // whole of each object in our archive into that artifact. This is - // because a `dylib` can be reused as an intermediate artifact. - // - // Note, though, that we don't want to include the whole of a - // compiler-builtins crate (e.g., compiler-rt) because it'll get - // repeatedly linked anyway. - if crate_type == config::CrateType::Dylib && - codegen_results.crate_info.compiler_builtins != Some(cnum) { - cmd.link_whole_rlib(&fix_windows_verbatim_for_gcc(&dst)); - } else { - cmd.link_rlib(&fix_windows_verbatim_for_gcc(&dst)); - } - }); - } - - // Same thing as above, but for dynamic crates instead of static crates. - fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) { - // If we're performing LTO, then it should have been previously required - // that all upstream rust dependencies were available in an rlib format. - assert!(!are_upstream_rust_objects_already_included(sess)); - - // Just need to tell the linker about where the library lives and - // what its name is - let parent = cratepath.parent(); - if let Some(dir) = parent { - cmd.include_path(&fix_windows_verbatim_for_gcc(dir)); - } - let filestem = cratepath.file_stem().unwrap().to_str().unwrap(); - cmd.link_rust_dylib(&unlib(&sess.target, filestem), - parent.unwrap_or(Path::new(""))); - } -} From 103f2faa1a698d3119d218088dff4ac660b41744 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Apr 2019 19:07:30 +0200 Subject: [PATCH 0629/1566] [WIP] Try using GnuBuilder --- Cargo.lock | 6 +++--- Cargo.toml | 3 +++ src/archive.rs | 39 ++++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f044dcb65b69..aeca3ecf47242 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ dependencies = [ [[package]] name = "ar" version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/mdsteele/rust-ar.git#1cfa68dcecaa063510758e8bdced7115a3393616" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -582,7 +582,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.6.2 (git+https://github.com/mdsteele/rust-ar.git)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -843,7 +843,7 @@ dependencies = [ [metadata] "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "579681b3fecd1e9d6b5ce6969e05f9feb913f296eddaf595be1166a5ca597bc4" +"checksum ar 0.6.2 (git+https://github.com/mdsteele/rust-ar.git)" = "" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" diff --git a/Cargo.toml b/Cargo.toml index 14e05f70621a8..b71ad7ffb2558 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,5 +38,8 @@ indexmap = "1.0.2" #[patch."https://github.com/gimli-rs/gimli.git"] #gimli = { path = "../" } +[patch.crates-io] +ar = { git = "https://github.com/mdsteele/rust-ar.git" } + [profile.dev.overrides."*"] opt-level = 3 diff --git a/src/archive.rs b/src/archive.rs index fb17bc8844133..02b8c4fd14e51 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -8,12 +8,14 @@ use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; use rustc_codegen_ssa::back::archive::{ArchiveBuilder, find_library}; struct ArchiveConfig<'a> { - pub sess: &'a Session, - pub dst: PathBuf, - pub src: Option, - pub lib_search_paths: Vec, + sess: &'a Session, + dst: PathBuf, + src: Option, + lib_search_paths: Vec, + is_like_osx: bool, } +#[derive(Debug)] enum ArchiveEntry { FromArchive { archive_index: usize, entry_index: usize }, File(File), @@ -34,6 +36,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { dst: output.to_path_buf(), src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), + is_like_osx: sess.target.target.options.is_like_osx, }; let (src_archives, entries) = if let Some(src) = &config.src { @@ -119,7 +122,23 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn build(mut self) { - let mut builder = ar::Builder::new(File::create(&self.config.dst).unwrap()); + println!("{:?}", self.src_archives.len()); + println!("{:?}", self.entries); + + enum BuilderKind { + Bsd(ar::Builder), + Gnu(ar::GnuBuilder), + } + + let archive_file = File::create(&self.config.dst).unwrap(); + let mut builder = if self.config.is_like_osx { + BuilderKind::Bsd(ar::Builder::new(archive_file)) + } else { + BuilderKind::Gnu(ar::GnuBuilder::new( + archive_file, + self.entries.keys().map(|key| key.as_bytes().to_vec()).collect(), + )) + }; // Add all files for (entry_name, entry) in self.entries.into_iter() { @@ -133,10 +152,16 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { header.set_uid(orig_header.uid()); header.set_gid(orig_header.gid()); header.set_mode(orig_header.mode()); - builder.append(&header, entry).unwrap(); + match builder { + BuilderKind::Bsd(ref mut builder) => builder.append(&header, entry).unwrap(), + BuilderKind::Gnu(ref mut builder) => builder.append(&header, entry).unwrap(), + } } ArchiveEntry::File(mut file) => { - builder.append_file(entry_name.as_bytes(), &mut file).unwrap(); + match builder { + BuilderKind::Bsd(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut file).unwrap(), + BuilderKind::Gnu(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut file).unwrap(), + } } } } From e8db15f662af7fe646a75fbbb3c507037dc55753 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 21 Apr 2019 15:25:39 +0200 Subject: [PATCH 0630/1566] Fix filename length for ar files --- src/archive.rs | 20 ++++++++++++++++++-- src/lib.rs | 6 +++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 02b8c4fd14e51..44ca68c2127d1 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -36,7 +36,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { dst: output.to_path_buf(), src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), - is_like_osx: sess.target.target.options.is_like_osx, + is_like_osx: true, //sess.target.target.options.is_like_osx, }; let (src_archives, entries) = if let Some(src) = &config.src { @@ -146,8 +146,24 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { ArchiveEntry::FromArchive { archive_index, entry_index } => { let entry = self.src_archives[archive_index].jump_to_entry(entry_index).unwrap(); let orig_header = entry.header(); + + let orig_filename = orig_header.identifier().to_vec(); + + use std::collections::hash_map::DefaultHasher; + use std::hash::{Hash, Hasher}; + let mut hasher = DefaultHasher::new(); + orig_filename.hash(&mut hasher); + let mut filename = hasher.finish().to_le_bytes()[0..6].to_vec(); + filename.extend(&orig_filename[orig_filename.len() - 9..]); + + assert!( + filename.len() <= 16, + "Filenames bigger than 16 bytes are not yet supported. Filename was: \"{}\"", + String::from_utf8(filename).unwrap_or_else(|e| e.to_string()), + ); + let mut header = - ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); + ar::Header::new(filename, orig_header.size()); header.set_mtime(orig_header.mtime()); header.set_uid(orig_header.uid()); header.set_gid(orig_header.gid()); diff --git a/src/lib.rs b/src/lib.rs index 53dc644ddc4dc..f1bceb648e6df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -325,14 +325,14 @@ impl CodegenBackend for CraneliftCodegenBackend { return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module( - "dummy_name", + "u", ModuleKind::Regular, faerie_module, debug, )], allocator_module: if created_alloc_shim { Some(emit_module( - "allocator_shim", + "a", ModuleKind::Allocator, allocator_module, None, @@ -341,7 +341,7 @@ impl CodegenBackend for CraneliftCodegenBackend { None }, metadata_module: CompiledModule { - name: "dummy_metadata".to_string(), + name: "m".to_string(), kind: ModuleKind::Metadata, object: None, bytecode: None, From 7ab8dda160f246fcf8ca7eac28587f0ecacb42b6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Apr 2019 20:50:23 +0200 Subject: [PATCH 0631/1566] Fix gnu archives --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- src/archive.rs | 19 ++----------------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aeca3ecf47242..80bc1c90a4720 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,7 +19,7 @@ dependencies = [ [[package]] name = "ar" version = "0.6.2" -source = "git+https://github.com/mdsteele/rust-ar.git#1cfa68dcecaa063510758e8bdced7115a3393616" +source = "git+https://github.com/bjorn3/rust-ar.git?branch=non_multiple_of_two_identifiers_gnu_format#efa2308b9ded41f4977d4fed98dac7af4d9075cf" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -582,7 +582,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar 0.6.2 (git+https://github.com/mdsteele/rust-ar.git)", + "ar 0.6.2 (git+https://github.com/bjorn3/rust-ar.git?branch=non_multiple_of_two_identifiers_gnu_format)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -843,7 +843,7 @@ dependencies = [ [metadata] "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.6.2 (git+https://github.com/mdsteele/rust-ar.git)" = "" +"checksum ar 0.6.2 (git+https://github.com/bjorn3/rust-ar.git?branch=non_multiple_of_two_identifiers_gnu_format)" = "" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" diff --git a/Cargo.toml b/Cargo.toml index b71ad7ffb2558..c5565699cdedb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ indexmap = "1.0.2" #gimli = { path = "../" } [patch.crates-io] -ar = { git = "https://github.com/mdsteele/rust-ar.git" } +ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "non_multiple_of_two_identifiers_gnu_format" } [profile.dev.overrides."*"] opt-level = 3 diff --git a/src/archive.rs b/src/archive.rs index 44ca68c2127d1..2adb80da8794c 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -36,7 +36,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { dst: output.to_path_buf(), src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), - is_like_osx: true, //sess.target.target.options.is_like_osx, + is_like_osx: sess.target.target.options.is_like_osx, }; let (src_archives, entries) = if let Some(src) = &config.src { @@ -147,23 +147,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let entry = self.src_archives[archive_index].jump_to_entry(entry_index).unwrap(); let orig_header = entry.header(); - let orig_filename = orig_header.identifier().to_vec(); - - use std::collections::hash_map::DefaultHasher; - use std::hash::{Hash, Hasher}; - let mut hasher = DefaultHasher::new(); - orig_filename.hash(&mut hasher); - let mut filename = hasher.finish().to_le_bytes()[0..6].to_vec(); - filename.extend(&orig_filename[orig_filename.len() - 9..]); - - assert!( - filename.len() <= 16, - "Filenames bigger than 16 bytes are not yet supported. Filename was: \"{}\"", - String::from_utf8(filename).unwrap_or_else(|e| e.to_string()), - ); - let mut header = - ar::Header::new(filename, orig_header.size()); + ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); header.set_mtime(orig_header.mtime()); header.set_uid(orig_header.uid()); header.set_gid(orig_header.gid()); From f096ad14a3e75eb01ed83ebbe10ab01f6b995767 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Apr 2019 20:54:01 +0200 Subject: [PATCH 0632/1566] Change module names back --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f1bceb648e6df..53dc644ddc4dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -325,14 +325,14 @@ impl CodegenBackend for CraneliftCodegenBackend { return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module( - "u", + "dummy_name", ModuleKind::Regular, faerie_module, debug, )], allocator_module: if created_alloc_shim { Some(emit_module( - "a", + "allocator_shim", ModuleKind::Allocator, allocator_module, None, @@ -341,7 +341,7 @@ impl CodegenBackend for CraneliftCodegenBackend { None }, metadata_module: CompiledModule { - name: "m".to_string(), + name: "dummy_metadata".to_string(), kind: ModuleKind::Metadata, object: None, bytecode: None, From 746e5c5142b6c1f6b7b2de549a99abaa75fff9cf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Apr 2019 20:55:31 +0200 Subject: [PATCH 0633/1566] Remove some debug println's --- src/archive.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 2adb80da8794c..fb2f67cb801e8 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -36,7 +36,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { dst: output.to_path_buf(), src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), - is_like_osx: sess.target.target.options.is_like_osx, + is_like_osx: sess.target.target.options.is_like_osx, // FIXME should probably check for linux }; let (src_archives, entries) = if let Some(src) = &config.src { @@ -122,9 +122,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn build(mut self) { - println!("{:?}", self.src_archives.len()); - println!("{:?}", self.entries); - enum BuilderKind { Bsd(ar::Builder), Gnu(ar::GnuBuilder), From 9f6a65b08bfa89292bad8d9274f5bb2fb527c4fd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Apr 2019 21:08:11 +0200 Subject: [PATCH 0634/1566] Update comment --- src/archive.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index fb2f67cb801e8..b2553bb59e93c 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -12,7 +12,7 @@ struct ArchiveConfig<'a> { dst: PathBuf, src: Option, lib_search_paths: Vec, - is_like_osx: bool, + use_gnu_style_archive: bool, } #[derive(Debug)] @@ -36,7 +36,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { dst: output.to_path_buf(), src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), - is_like_osx: sess.target.target.options.is_like_osx, // FIXME should probably check for linux + // FIXME test for linux and System V derivatives instead + use_gnu_style_archive: !sess.target.target.options.is_like_osx, }; let (src_archives, entries) = if let Some(src) = &config.src { @@ -128,13 +129,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } let archive_file = File::create(&self.config.dst).unwrap(); - let mut builder = if self.config.is_like_osx { - BuilderKind::Bsd(ar::Builder::new(archive_file)) - } else { + let mut builder = if self.config.use_gnu_style_archive { BuilderKind::Gnu(ar::GnuBuilder::new( archive_file, self.entries.keys().map(|key| key.as_bytes().to_vec()).collect(), )) + } else { + BuilderKind::Bsd(ar::Builder::new(archive_file)) }; // Add all files From 11d816cce5e5b7ed2095f52179021071aeee0beb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Apr 2019 17:44:12 +0200 Subject: [PATCH 0635/1566] Rustup to rustc 1.36.0-nightly (597f43248 2019-04-26) --- build_sysroot/Cargo.toml | 1 + .../rustc-std-workspace-alloc/Cargo.toml | 15 +++++++++++++++ build_sysroot/rustc-std-workspace-alloc/lib.rs | 5 +++++ src/lib.rs | 4 ++-- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 build_sysroot/rustc-std-workspace-alloc/Cargo.toml create mode 100644 build_sysroot/rustc-std-workspace-alloc/lib.rs diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 3ba06fcb0f613..648a407984ca5 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -13,6 +13,7 @@ alloc_system = { path = "./alloc_system" } [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } compiler_builtins = { path = "./compiler_builtins" } [profile.release] diff --git a/build_sysroot/rustc-std-workspace-alloc/Cargo.toml b/build_sysroot/rustc-std-workspace-alloc/Cargo.toml new file mode 100644 index 0000000000000..221365373ffab --- /dev/null +++ b/build_sysroot/rustc-std-workspace-alloc/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "rustc-std-workspace-alloc" +version = "1.0.0" +authors = ["Alex Crichton "] +license = 'MIT/Apache-2.0' +description = """ +Hack for the compiler's own build system +""" +edition = "2018" + +[lib] +path = "lib.rs" + +[dependencies] +alloc = { path = "../sysroot_src/src/liballoc" } diff --git a/build_sysroot/rustc-std-workspace-alloc/lib.rs b/build_sysroot/rustc-std-workspace-alloc/lib.rs new file mode 100644 index 0000000000000..cf216ec9d29a7 --- /dev/null +++ b/build_sysroot/rustc-std-workspace-alloc/lib.rs @@ -0,0 +1,5 @@ +#![feature(no_core)] +#![no_core] +#![deny(rust_2018_idioms)] + +pub use ::alloc::*; diff --git a/src/lib.rs b/src/lib.rs index 53dc644ddc4dc..db73d930665fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -340,13 +340,13 @@ impl CodegenBackend for CraneliftCodegenBackend { } else { None }, - metadata_module: CompiledModule { + metadata_module: Some(CompiledModule { name: "dummy_metadata".to_string(), kind: ModuleKind::Metadata, object: None, bytecode: None, bytecode_compressed: None, - }, + }), crate_hash: tcx.crate_hash(LOCAL_CRATE), metadata, windows_subsystem: None, // Windows is not yet supported From aeecb45bebc26499ba7382627733e2677fab1af6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Apr 2019 17:47:15 +0200 Subject: [PATCH 0636/1566] Preserve the order files are added to archives rust.metadata.bin could have been at the start of an .rlib file confusing ld --- example/alloc_example.rs | 2 +- src/archive.rs | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/example/alloc_example.rs b/example/alloc_example.rs index 3dc134521173c..20a8642cbd175 100644 --- a/example/alloc_example.rs +++ b/example/alloc_example.rs @@ -1,4 +1,4 @@ -#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc, alloc_prelude, alloc_error_handler)] +#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc_prelude, alloc_error_handler)] #![no_std] extern crate alloc; diff --git a/src/archive.rs b/src/archive.rs index b2553bb59e93c..ea6357b539a22 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::fs::File; use std::path::{Path, PathBuf}; @@ -24,7 +23,9 @@ enum ArchiveEntry { pub struct ArArchiveBuilder<'a> { config: ArchiveConfig<'a>, src_archives: Vec>, - entries: HashMap, + // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at + // the end of an archive for linkers to not get confused. + entries: Vec<(String, ArchiveEntry)>, update_symbols: bool, } @@ -42,21 +43,21 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let (src_archives, entries) = if let Some(src) = &config.src { let mut archive = ar::Archive::new(File::open(src).unwrap()); - let mut entries = HashMap::new(); + let mut entries = Vec::new(); let mut i = 0; while let Some(entry) = archive.next_entry() { let entry = entry.unwrap(); - entries.insert( + entries.push(( String::from_utf8(entry.header().identifier().to_vec()).unwrap(), ArchiveEntry::FromArchive { archive_index: 0, entry_index: i }, - ); + )); i += 1; } (vec![archive], entries) } else { - (vec![], HashMap::new()) + (vec![], Vec::new()) }; ArArchiveBuilder { @@ -68,22 +69,22 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn src_files(&mut self) -> Vec { - self.entries.keys().cloned().collect() + self.entries.iter().map(|(name, _)| name.clone()).collect() } fn remove_file(&mut self, name: &str) { - let file = self.entries.remove(name); - assert!( - file.is_some(), - "Tried to remove file not existing in src archive", - ); + let index = self.entries + .iter() + .position(|(entry_name, _)| entry_name == name) + .expect("Tried to remove file not existing in src archive"); + self.entries.remove(index); } fn add_file(&mut self, file: &Path) { - self.entries.insert( + self.entries.push(( file.file_name().unwrap().to_str().unwrap().to_string(), ArchiveEntry::File(File::open(file).unwrap()), - ); + )); } fn add_native_library(&mut self, name: &str) { @@ -132,7 +133,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let mut builder = if self.config.use_gnu_style_archive { BuilderKind::Gnu(ar::GnuBuilder::new( archive_file, - self.entries.keys().map(|key| key.as_bytes().to_vec()).collect(), + self.entries.iter().map(|(name, _)| name.as_bytes().to_vec()).collect(), )) } else { BuilderKind::Bsd(ar::Builder::new(archive_file)) @@ -193,10 +194,10 @@ impl<'a> ArArchiveBuilder<'a> { let entry = entry.unwrap(); let file_name = String::from_utf8(entry.header().identifier().to_vec()).unwrap(); if !skip(&file_name) { - self.entries.insert( + self.entries.push(( file_name, ArchiveEntry::FromArchive { archive_index, entry_index: i }, - ); + )); } i += 1; } From 421fe2e982bd6173a17aa850557f031d3e1dfd2c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Apr 2019 18:48:34 +0200 Subject: [PATCH 0637/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80bc1c90a4720..9e0795085f977 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#538a0662bf90a1daa9921c10f34827ace134abf1" +source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 27ea27e2e3e77f82cc470dd695f54ececa16cb4b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Apr 2019 18:49:13 +0200 Subject: [PATCH 0638/1566] Fix using using the same vtable twice --- src/vtable.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vtable.rs b/src/vtable.rs index 6cfd59dcd0894..5c3d62e22bb49 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -138,7 +138,12 @@ fn build_vtable<'a, 'tcx: 'a>( false, ) .unwrap(); - fx.module.define_data(data_id, &data_ctx).unwrap(); + + match fx.module.define_data(data_id, &data_ctx) { + Ok(()) | Err(cranelift_module::ModuleError::DuplicateDefinition(_)) => {} + err => err.unwrap(), + } + data_id } From f473ba8f87a8397e358a79f8ccae2d944f7bee95 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Apr 2019 20:37:44 +0200 Subject: [PATCH 0639/1566] Rustup to rustc 1.36.0-nightly (938d4ffe1 2019-04-27) --- src/abi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 531e4f063af31..74b373276cb70 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -87,7 +87,7 @@ fn clif_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: FnSig<'t _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; let mut inputs: Vec = vec![sig.inputs()[0]]; - inputs.extend(extra_args.into_iter()); + inputs.extend(extra_args.types()); (CallConv::SystemV, inputs, sig.output()) } Abi::System => bug!("system abi should be selected elsewhere"), @@ -434,7 +434,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( }; let mut params = Vec::new(); - for (i, arg_ty) in tupled_arg_tys.iter().enumerate() { + for (i, arg_ty) in tupled_arg_tys.types().enumerate() { let param = cvalue_for_param( fx, start_ebb, From c33d127a59cffa64b9b9096cedd409df01f4f755 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Mon, 29 Apr 2019 04:17:55 +0000 Subject: [PATCH 0640/1566] Bump cranelift from `4f69c32` to `c0ee30f` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `4f69c32` to `c0ee30f`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/4f69c32572a13f4ded3b05542abf476d1cd2ead8...c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e0795085f977..0d1edf39aef5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#4f69c32572a13f4ded3b05542abf476d1cd2ead8" +source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 8fa92b8bb4d457408a1cceae5bcc1ab5f10b8341 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 1 May 2019 13:13:31 +0200 Subject: [PATCH 0641/1566] Bump libc from 0.2.51 to 0.2.53 (#508) Bumps [libc](https://github.com/rust-lang/libc) from 0.2.51 to 0.2.53. - [Release notes](https://github.com/rust-lang/libc/releases) - [Commits](https://github.com/rust-lang/libc/compare/0.2.51...0.2.53) Signed-off-by: dependabot[bot] --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d1edf39aef5e..4d1e5a083dbae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,7 +55,7 @@ dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -66,7 +66,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -208,7 +208,7 @@ dependencies = [ "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +232,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -242,7 +242,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -352,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.51" +version = "0.2.53" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -368,7 +368,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -413,7 +413,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -468,7 +468,7 @@ name = "rand_jitter" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -480,7 +480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -560,7 +560,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -593,7 +593,7 @@ dependencies = [ "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -733,7 +733,7 @@ version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -753,7 +753,7 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -881,7 +881,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)" = "bedcc7a809076656486ffe045abeeac163da1b558e963a31e29fbfbeba916917" +"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" diff --git a/Cargo.toml b/Cargo.toml index c5565699cdedb..c4ee9056d9ed0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ faerie = "0.10.0" ar = "0.6.1" bitflags = "1.0.3" byteorder = "1.2.7" -libc = "0.2.50" +libc = "0.2.53" tempfile = "3.0.7" env_logger = "0.6" gimli = { git = "https://github.com/gimli-rs/gimli.git" } From bbd83ebf9d91789edba826171fd6a43b6d17aac7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 1 May 2019 13:13:46 +0200 Subject: [PATCH 0642/1566] Bump proc-macro2 from 0.4.27 to 0.4.29 (#507) Bumps [proc-macro2](https://github.com/alexcrichton/proc-macro2) from 0.4.27 to 0.4.29. - [Release notes](https://github.com/alexcrichton/proc-macro2/releases) - [Commits](https://github.com/alexcrichton/proc-macro2/compare/0.4.27...0.4.29) Signed-off-by: dependabot[bot] --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d1e5a083dbae..21ab665f3ae42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,7 +276,7 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -388,7 +388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.27" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -404,7 +404,7 @@ name = "quote" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -625,7 +625,7 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -691,7 +691,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -701,7 +701,7 @@ name = "syn" version = "0.15.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -711,7 +711,7 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -887,7 +887,7 @@ dependencies = [ "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" +"checksum proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)" = "64c827cea7a7ab30ce4593e5e04d7a11617ad6ece2fa230605a78b00ff965316" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" From 8598a34e4514e90bf22eba00ec07c6cee5842df7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 14:57:41 +0200 Subject: [PATCH 0643/1566] Rustup to rustc 1.36.0-nightly (a3404557c 2019-05-03) --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index db73d930665fb..562f9e5e56830 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ use std::os::raw::{c_char, c_int}; use std::sync::mpsc; use rustc::dep_graph::DepGraph; -use rustc::middle::cstore::MetadataLoader; +use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc::mir::mono::{Linkage as RLinkage, Visibility}; use rustc::session::config::{DebugInfo, OutputFilenames, OutputType}; use rustc::ty::query::Providers; @@ -192,6 +192,8 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_crate<'a, 'tcx>( &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, + metadata: EncodedMetadata, + _need_metadata_module: bool, _rx: mpsc::Receiver>, ) -> Box { env_logger::init(); @@ -204,8 +206,6 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx.sess.abort_if_errors(); - let metadata = tcx.encode_metadata(); - let mut log = if cfg!(debug_assertions) { Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) } else { From 98dae86d214226b2d9bf400bae39f040f279821b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 16:15:20 +0200 Subject: [PATCH 0644/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- src/constant.rs | 9 +++++---- src/lib.rs | 6 ++++-- src/trap.rs | 2 +- src/vtable.rs | 1 + 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21ab665f3ae42..19ef265e754a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/src/constant.rs b/src/constant.rs index 87056f679a620..282f429d74de2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -179,7 +179,7 @@ fn trans_const_place<'a, 'tcx: 'a>( fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) -> DataId { module - .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false) + .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, None) .unwrap() } @@ -190,15 +190,16 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( linkage: Linkage, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); + let ty = tcx.type_of(def_id); let is_mutable = if tcx.is_mutable_static(def_id) { true } else { - !tcx.type_of(def_id) - .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + !ty.is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) }; + let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes(); let data_id = module - .declare_data(&*symbol_name, linkage, is_mutable) + .declare_data(&*symbol_name, linkage, is_mutable, Some(align.try_into().unwrap())) .unwrap(); if linkage == Linkage::Preemptible { diff --git a/src/lib.rs b/src/lib.rs index 562f9e5e56830..95eb75c22c828 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,7 @@ mod vtable; mod prelude { pub use std::any::Any; pub use std::collections::{HashMap, HashSet}; + pub use std::convert::TryInto; pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::source_map::{Pos, Span, DUMMY_SP}; @@ -213,7 +214,8 @@ impl CodegenBackend for CraneliftCodegenBackend { }; if std::env::var("SHOULD_RUN").is_ok() { - let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); + let mut jit_module: Module = + Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names())); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); let sig = Signature { @@ -263,7 +265,7 @@ impl CodegenBackend for CraneliftCodegenBackend { build_isa(tcx.sess), name + ".o", FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names(), + cranelift_module::default_libcall_names(), ) .unwrap(), ); diff --git a/src/trap.rs b/src/trap.rs index f492bcf4b1ebd..925d59ac255e0 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -12,7 +12,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let msg_bytes = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg).into_bytes().into_boxed_slice(); let mut data_ctx = DataContext::new(); data_ctx.define(msg_bytes); - let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false).unwrap(); + let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false, None).unwrap(); // Ignore DuplicateDefinition error, as the data will be the same let _ = fx.module.define_data(msg_id, &data_ctx); diff --git a/src/vtable.rs b/src/vtable.rs index 5c3d62e22bb49..a19b6b458c408 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -136,6 +136,7 @@ fn build_vtable<'a, 'tcx: 'a>( &format!("vtable.{:?}.for.{:?}", trait_ref, ty), Linkage::Local, false, + Some(fx.tcx.data_layout.pointer_align.pref.bytes().try_into().unwrap()) ) .unwrap(); From 7bf9b8e6e13bdead4217217e8f66cbf0eff414a5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 16:20:43 +0200 Subject: [PATCH 0645/1566] Update gimli --- Cargo.lock | 8 ++++---- src/debuginfo.rs | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19ef265e754a3..cfa87b421b4e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -299,8 +299,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" -version = "0.17.0" -source = "git+https://github.com/gimli-rs/gimli.git#70c3730b5e3d8669dd2dbcf829fedd4f679185d9" +version = "0.18.0" +source = "git+https://github.com/gimli-rs/gimli.git#423431f6747167af8e64cc8c8378f9a34a18ff8f" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -591,7 +591,7 @@ dependencies = [ "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)", + "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -874,7 +874,7 @@ dependencies = [ "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.17.0 (git+https://github.com/gimli-rs/gimli.git)" = "" +"checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 9db4319113457..d287e2cfaa308 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -135,7 +135,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { root.set(gimli::DW_AT_comp_dir, AttributeValue::StringRef(comp_dir)); root.set( gimli::DW_AT_low_pc, - AttributeValue::Address(Address::Absolute(0)), + AttributeValue::Address(Address::Constant(0)), ); } @@ -251,7 +251,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { entry.set( gimli::DW_AT_low_pc, - AttributeValue::Address(Address::Relative { symbol, addend: 0 }), + AttributeValue::Address(Address::Symbol { symbol, addend: 0 }), ); debug_context.emit_location(tcx, entry_id, mir.span); @@ -273,7 +273,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { ) { let line_program = &mut self.debug_context.dwarf.unit.line_program; - line_program.begin_sequence(Some(Address::Relative { + line_program.begin_sequence(Some(Address::Symbol { symbol: self.symbol, addend: 0, })); @@ -326,7 +326,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { .unit_range_list .0 .push(Range::StartLength { - begin: Address::Relative { + begin: Address::Symbol { symbol: self.symbol, addend: 0, }, @@ -371,8 +371,8 @@ impl Writer for WriterRelocate { fn write_address(&mut self, address: Address, size: u8) -> Result<()> { match address { - Address::Absolute(val) => self.write_word(val, size), - Address::Relative { symbol, addend } => { + Address::Constant(val) => self.write_udata(val, size), + Address::Symbol { symbol, addend } => { let offset = self.len() as u64; self.relocs.push(DebugReloc { offset: offset as u32, @@ -380,11 +380,13 @@ impl Writer for WriterRelocate { name: DebugRelocName::Symbol(symbol), addend: addend as i64, }); - self.write_word(0, size) + self.write_udata(0, size) } } } + // TODO: implement write_eh_pointer + fn write_offset(&mut self, val: usize, section: SectionId, size: u8) -> Result<()> { let offset = self.len() as u32; self.relocs.push(DebugReloc { @@ -393,7 +395,7 @@ impl Writer for WriterRelocate { name: DebugRelocName::Section(section), addend: val as i64, }); - self.write_word(0, size) + self.write_udata(0, size) } fn write_offset_at( @@ -409,6 +411,6 @@ impl Writer for WriterRelocate { name: DebugRelocName::Section(section), addend: val as i64, }); - self.write_word_at(offset, 0, size) + self.write_udata_at(offset, 0, size) } } From 80fc7b569ce01da361c160ce98686655fab4aa64 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 16:23:53 +0200 Subject: [PATCH 0646/1566] Use crates.io version of ar again --- Cargo.lock | 8 ++++---- Cargo.toml | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfa87b421b4e5..9c125d1a3249f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,8 +18,8 @@ dependencies = [ [[package]] name = "ar" -version = "0.6.2" -source = "git+https://github.com/bjorn3/rust-ar.git?branch=non_multiple_of_two_identifiers_gnu_format#efa2308b9ded41f4977d4fed98dac7af4d9075cf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -582,7 +582,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar 0.6.2 (git+https://github.com/bjorn3/rust-ar.git?branch=non_multiple_of_two_identifiers_gnu_format)", + "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -843,7 +843,7 @@ dependencies = [ [metadata] "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum ar 0.6.2 (git+https://github.com/bjorn3/rust-ar.git?branch=non_multiple_of_two_identifiers_gnu_format)" = "" +"checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" diff --git a/Cargo.toml b/Cargo.toml index c4ee9056d9ed0..c823278cb39fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ target-lexicon = "0.4.0" faerie = "0.10.0" #goblin = "0.0.17" -ar = "0.6.1" +ar = "0.7.0" bitflags = "1.0.3" byteorder = "1.2.7" libc = "0.2.53" @@ -38,8 +38,5 @@ indexmap = "1.0.2" #[patch."https://github.com/gimli-rs/gimli.git"] #gimli = { path = "../" } -[patch.crates-io] -ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "non_multiple_of_two_identifiers_gnu_format" } - [profile.dev.overrides."*"] opt-level = 3 From 97747aa91a731b537251f327cd30924f4aa8d935 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 16:25:19 +0200 Subject: [PATCH 0647/1566] Update Cargo.lock --- Cargo.lock | 97 +++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c125d1a3249f..23bad972ded27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,8 +37,8 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,7 +55,7 @@ dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -65,13 +65,13 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -81,7 +81,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -96,7 +96,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -108,7 +108,7 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -208,7 +208,7 @@ dependencies = [ "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +232,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -242,7 +242,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -278,7 +278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -342,7 +342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itoa" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -352,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.53" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -368,7 +368,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -381,6 +381,11 @@ name = "nodrop" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "numtoa" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "plain" version = "0.2.3" @@ -413,12 +418,12 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -465,10 +470,10 @@ dependencies = [ [[package]] name = "rand_jitter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -480,7 +485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -508,8 +513,8 @@ name = "raw-cpuid" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -559,8 +564,8 @@ name = "region" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -583,7 +588,7 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -593,7 +598,7 @@ dependencies = [ "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -608,7 +613,7 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -627,7 +632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -653,8 +658,8 @@ name = "serde_json" version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -693,12 +698,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.31" +version = "0.15.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -713,7 +718,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -733,7 +738,7 @@ version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -750,10 +755,11 @@ dependencies = [ [[package]] name = "termion" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -849,9 +855,9 @@ dependencies = [ "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bd1fa8ad26490b0a5cfec99089952250301b6716cdeaa7c9ab229598fb82ab66" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5f3fee5eeb60324c2781f1e41286bdee933850fff9b3c672587fed5ec58c83" +"checksum cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a0c56216487bb80eec9c4516337b2588a4f2a2290d72a1416d930e4dcdb0c90d" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -879,13 +885,14 @@ dependencies = [ "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee" +"checksum libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "c6785aa7dd976f5fbf3b71cfd9cd49d7f783c1ff565a858d71031c6c313aa5c6" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" +"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)" = "64c827cea7a7ab30ce4593e5e04d7a11617ad6ece2fa230605a78b00ff965316" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -896,7 +903,7 @@ dependencies = [ "checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" +"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" "checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" @@ -910,7 +917,7 @@ dependencies = [ "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" +"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -922,12 +929,12 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" -"checksum syn 0.15.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b4cfac95805274c6afdb12d8f770fa2d27c045953e7b630a81801953699a9a" +"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" From bb7a990ee790b9063f1c4e0aa7911d618c3e4386 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 16:54:25 +0200 Subject: [PATCH 0648/1566] Extract driver.rs --- src/base.rs | 56 +---------- src/driver.rs | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 235 +++---------------------------------------- 3 files changed, 290 insertions(+), 274 deletions(-) create mode 100644 src/driver.rs diff --git a/src/base.rs b/src/base.rs index eed66a2880692..a3865b34524ab 100644 --- a/src/base.rs +++ b/src/base.rs @@ -2,61 +2,7 @@ use rustc::ty::adjustment::PointerCast; use crate::prelude::*; -struct PrintOnPanic String>(F); -impl String> Drop for PrintOnPanic { - fn drop(&mut self) { - if ::std::thread::panicking() { - println!("{}", (self.0)()); - } - } -} - -pub fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( - cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, - mono_item: MonoItem<'tcx>, - linkage: Linkage, -) { - let tcx = cx.tcx; - match mono_item { - MonoItem::Fn(inst) => { - let _inst_guard = - PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).as_str())); - debug_assert!(!inst.substs.needs_infer()); - let _mir_guard = PrintOnPanic(|| { - match inst.def { - InstanceDef::Item(_) - | InstanceDef::DropGlue(_, _) - | InstanceDef::Virtual(_, _) - if inst.def_id().krate == LOCAL_CRATE => - { - let mut mir = ::std::io::Cursor::new(Vec::new()); - crate::rustc_mir::util::write_mir_pretty( - tcx, - Some(inst.def_id()), - &mut mir, - ) - .unwrap(); - String::from_utf8(mir.into_inner()).unwrap() - } - _ => { - // FIXME fix write_mir_pretty for these instances - format!("{:#?}", tcx.instance_mir(inst.def)) - } - } - }); - - trans_fn(cx, inst, linkage); - } - MonoItem::Static(def_id) => { - crate::constant::codegen_static(&mut cx.ccx, def_id); - } - MonoItem::GlobalAsm(node_id) => tcx - .sess - .fatal(&format!("Unimplemented global asm mono item {:?}", node_id)), - } -} - -fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( +pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, instance: Instance<'tcx>, linkage: Linkage, diff --git a/src/driver.rs b/src/driver.rs new file mode 100644 index 0000000000000..6ec558705bc3a --- /dev/null +++ b/src/driver.rs @@ -0,0 +1,273 @@ +use std::any::Any; +use std::ffi::CString; +use std::fs::File; +use std::os::raw::{c_char, c_int}; + +use rustc::middle::cstore::EncodedMetadata; +use rustc::mir::mono::{Linkage as RLinkage, Visibility}; +use rustc::session::config::{DebugInfo, OutputType}; +use rustc_codegen_ssa::back::linker::LinkerInfo; +use rustc_codegen_ssa::CrateInfo; +use rustc_mir::monomorphize::partitioning::CodegenUnitExt; + +use cranelift_faerie::*; + +use crate::prelude::*; + +pub fn codegen_crate<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + metadata: EncodedMetadata, + _need_metadata_module: bool, +) -> Box { + env_logger::init(); + if !tcx.sess.crate_types.get().contains(&CrateType::Executable) + && std::env::var("SHOULD_RUN").is_ok() + { + tcx.sess + .err("Can't JIT run non executable (SHOULD_RUN env var is set)"); + } + + tcx.sess.abort_if_errors(); + + let mut log = if cfg!(debug_assertions) { + Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) + } else { + None + }; + + if std::env::var("SHOULD_RUN").is_ok() { + let mut jit_module: Module = + Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names())); + assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); + + let sig = Signature { + params: vec![ + AbiParam::new(jit_module.target_config().pointer_type()), + AbiParam::new(jit_module.target_config().pointer_type()), + ], + returns: vec![AbiParam::new( + jit_module.target_config().pointer_type(), /*isize*/ + )], + call_conv: CallConv::SystemV, + }; + let main_func_id = jit_module + .declare_function("main", Linkage::Import, &sig) + .unwrap(); + + codegen_cgus(tcx, &mut jit_module, &mut None, &mut log); + crate::allocator::codegen(tcx.sess, &mut jit_module); + jit_module.finalize_definitions(); + + tcx.sess.abort_if_errors(); + + let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); + + println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); + + let f: extern "C" fn(c_int, *const *const c_char) -> c_int = + unsafe { ::std::mem::transmute(finalized_main) }; + + let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_| String::new()); + let args = args + .split(" ") + .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) + .map(|arg| CString::new(arg).unwrap()) + .collect::>(); + let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); + // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end + + let ret = f(args.len() as c_int, argv.as_ptr()); + + jit_module.finish(); + std::process::exit(ret); + } else { + let new_module = |name: String| { + let module: Module = Module::new( + FaerieBuilder::new( + crate::build_isa(tcx.sess), + name + ".o", + FaerieTrapCollection::Disabled, + cranelift_module::default_libcall_names(), + ) + .unwrap(), + ); + assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); + module + }; + + let emit_module = |name: &str, + kind: ModuleKind, + mut module: Module, + debug: Option| { + module.finalize_definitions(); + let mut artifact = module.finish().artifact; + + if let Some(mut debug) = debug { + debug.emit(&mut artifact); + } + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(name)); + let obj = artifact.emit().unwrap(); + std::fs::write(&tmp_file, obj).unwrap(); + CompiledModule { + name: name.to_string(), + kind, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + } + }; + + let mut faerie_module = new_module("some_file".to_string()); + + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None + // macOS debuginfo doesn't work yet (see #303) + && !tcx.sess.target.target.options.is_like_osx + { + let debug = DebugContext::new( + tcx, + faerie_module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) + } else { + None + }; + + codegen_cgus(tcx, &mut faerie_module, &mut debug, &mut log); + + tcx.sess.abort_if_errors(); + + let mut allocator_module = new_module("allocator_shim.o".to_string()); + let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); + + rustc_incremental::assert_dep_graph(tcx); + rustc_incremental::save_dep_graph(tcx); + rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); + + Box::new(CodegenResults { + crate_name: tcx.crate_name(LOCAL_CRATE), + modules: vec![emit_module( + "dummy_name", + ModuleKind::Regular, + faerie_module, + debug, + )], + allocator_module: if created_alloc_shim { + Some(emit_module( + "allocator_shim", + ModuleKind::Allocator, + allocator_module, + None, + )) + } else { + None + }, + metadata_module: Some(CompiledModule { + name: "dummy_metadata".to_string(), + kind: ModuleKind::Metadata, + object: None, + bytecode: None, + bytecode_compressed: None, + }), + crate_hash: tcx.crate_hash(LOCAL_CRATE), + metadata, + windows_subsystem: None, // Windows is not yet supported + linker_info: LinkerInfo::new(tcx), + crate_info: CrateInfo::new(tcx), + }) + } +} + +fn codegen_cgus<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + debug: &mut Option>, + log: &mut Option, +) { + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) + .flatten() + .collect::>(); + + codegen_mono_items(tcx, module, debug.as_mut(), log, mono_items); + + crate::main_shim::maybe_create_entry_wrapper(tcx, module); +} + +fn codegen_mono_items<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + module: &mut Module, + debug_context: Option<&mut DebugContext<'tcx>>, + log: &mut Option, + mono_items: FxHashMap, (RLinkage, Visibility)>, +) { + let mut cx = CodegenCx::new(tcx, module, debug_context); + time("codegen mono items", move || { + for (mono_item, (linkage, visibility)) in mono_items { + crate::unimpl::try_unimpl(tcx, log, || { + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + trans_mono_item(&mut cx, mono_item, linkage); + }); + } + + cx.finalize(); + }); +} + +fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( + cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, + mono_item: MonoItem<'tcx>, + linkage: Linkage, +) { + let tcx = cx.tcx; + match mono_item { + MonoItem::Fn(inst) => { + let _inst_guard = + PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).as_str())); + debug_assert!(!inst.substs.needs_infer()); + let _mir_guard = PrintOnPanic(|| { + match inst.def { + InstanceDef::Item(_) + | InstanceDef::DropGlue(_, _) + | InstanceDef::Virtual(_, _) + if inst.def_id().krate == LOCAL_CRATE => + { + let mut mir = ::std::io::Cursor::new(Vec::new()); + crate::rustc_mir::util::write_mir_pretty( + tcx, + Some(inst.def_id()), + &mut mir, + ) + .unwrap(); + String::from_utf8(mir.into_inner()).unwrap() + } + _ => { + // FIXME fix write_mir_pretty for these instances + format!("{:#?}", tcx.instance_mir(inst.def)) + } + } + }); + + crate::base::trans_fn(cx, inst, linkage); + } + MonoItem::Static(def_id) => { + crate::constant::codegen_static(&mut cx.ccx, def_id); + } + MonoItem::GlobalAsm(node_id) => tcx + .sess + .fatal(&format!("Unimplemented global asm mono item {:?}", node_id)), + } +} + +fn time(name: &str, f: impl FnOnce() -> R) -> R { + println!("[{}] start", name); + let before = std::time::Instant::now(); + let res = f(); + let after = std::time::Instant::now(); + println!("[{}] end time: {:?}", name, after - before); + res +} diff --git a/src/lib.rs b/src/lib.rs index 95eb75c22c828..bfadb90ae73c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,24 +14,16 @@ extern crate rustc_target; extern crate syntax; use std::any::Any; -use std::ffi::CString; -use std::fs::File; -use std::os::raw::{c_char, c_int}; use std::sync::mpsc; use rustc::dep_graph::DepGraph; use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; -use rustc::mir::mono::{Linkage as RLinkage, Visibility}; -use rustc::session::config::{DebugInfo, OutputFilenames, OutputType}; +use rustc::session::config::OutputFilenames; use rustc::ty::query::Providers; use rustc::util::common::ErrorReported; -use rustc_codegen_ssa::back::linker::LinkerInfo; -use rustc_codegen_ssa::CrateInfo; use rustc_codegen_utils::codegen_backend::CodegenBackend; -use rustc_mir::monomorphize::partitioning::CodegenUnitExt; use cranelift::codegen::settings; -use cranelift_faerie::*; use crate::constant::ConstantCx; use crate::prelude::*; @@ -44,6 +36,7 @@ mod base; mod common; mod constant; mod debuginfo; +mod driver; mod intrinsics; mod linkage; mod main_shim; @@ -103,6 +96,15 @@ mod prelude { pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; pub use crate::{Caches, CodegenCx}; + + pub struct PrintOnPanic String>(pub F); + impl String> Drop for PrintOnPanic { + fn drop(&mut self) { + if ::std::thread::panicking() { + println!("{}", (self.0)()); + } + } + } } pub struct Caches<'tcx> { @@ -194,168 +196,10 @@ impl CodegenBackend for CraneliftCodegenBackend { &self, tcx: TyCtxt<'a, 'tcx, 'tcx>, metadata: EncodedMetadata, - _need_metadata_module: bool, + need_metadata_module: bool, _rx: mpsc::Receiver>, ) -> Box { - env_logger::init(); - if !tcx.sess.crate_types.get().contains(&CrateType::Executable) - && std::env::var("SHOULD_RUN").is_ok() - { - tcx.sess - .err("Can't JIT run non executable (SHOULD_RUN env var is set)"); - } - - tcx.sess.abort_if_errors(); - - let mut log = if cfg!(debug_assertions) { - Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) - } else { - None - }; - - if std::env::var("SHOULD_RUN").is_ok() { - let mut jit_module: Module = - Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names())); - assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); - - let sig = Signature { - params: vec![ - AbiParam::new(jit_module.target_config().pointer_type()), - AbiParam::new(jit_module.target_config().pointer_type()), - ], - returns: vec![AbiParam::new( - jit_module.target_config().pointer_type(), /*isize*/ - )], - call_conv: CallConv::SystemV, - }; - let main_func_id = jit_module - .declare_function("main", Linkage::Import, &sig) - .unwrap(); - - codegen_cgus(tcx, &mut jit_module, &mut None, &mut log); - crate::allocator::codegen(tcx.sess, &mut jit_module); - jit_module.finalize_definitions(); - - tcx.sess.abort_if_errors(); - - let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); - - println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); - - let f: extern "C" fn(c_int, *const *const c_char) -> c_int = - unsafe { ::std::mem::transmute(finalized_main) }; - - let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_| String::new()); - let args = args - .split(" ") - .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) - .map(|arg| CString::new(arg).unwrap()) - .collect::>(); - let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); - // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end - - let ret = f(args.len() as c_int, argv.as_ptr()); - - jit_module.finish(); - std::process::exit(ret); - } else { - let new_module = |name: String| { - let module: Module = Module::new( - FaerieBuilder::new( - build_isa(tcx.sess), - name + ".o", - FaerieTrapCollection::Disabled, - cranelift_module::default_libcall_names(), - ) - .unwrap(), - ); - assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); - module - }; - - let emit_module = |name: &str, - kind: ModuleKind, - mut module: Module, - debug: Option| { - module.finalize_definitions(); - let mut artifact = module.finish().artifact; - - if let Some(mut debug) = debug { - debug.emit(&mut artifact); - } - - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, Some(name)); - let obj = artifact.emit().unwrap(); - std::fs::write(&tmp_file, obj).unwrap(); - CompiledModule { - name: name.to_string(), - kind, - object: Some(tmp_file), - bytecode: None, - bytecode_compressed: None, - } - }; - - let mut faerie_module = new_module("some_file".to_string()); - - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None - // macOS debuginfo doesn't work yet (see #303) - && !tcx.sess.target.target.options.is_like_osx - { - let debug = DebugContext::new( - tcx, - faerie_module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) - } else { - None - }; - - codegen_cgus(tcx, &mut faerie_module, &mut debug, &mut log); - - tcx.sess.abort_if_errors(); - - let mut allocator_module = new_module("allocator_shim.o".to_string()); - let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); - - rustc_incremental::assert_dep_graph(tcx); - rustc_incremental::save_dep_graph(tcx); - rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); - - return Box::new(CodegenResults { - crate_name: tcx.crate_name(LOCAL_CRATE), - modules: vec![emit_module( - "dummy_name", - ModuleKind::Regular, - faerie_module, - debug, - )], - allocator_module: if created_alloc_shim { - Some(emit_module( - "allocator_shim", - ModuleKind::Allocator, - allocator_module, - None, - )) - } else { - None - }, - metadata_module: Some(CompiledModule { - name: "dummy_metadata".to_string(), - kind: ModuleKind::Metadata, - object: None, - bytecode: None, - bytecode_compressed: None, - }), - crate_hash: tcx.crate_hash(LOCAL_CRATE), - metadata, - windows_subsystem: None, // Windows is not yet supported - linker_info: LinkerInfo::new(tcx), - crate_info: CrateInfo::new(tcx), - }); - } + driver::codegen_crate(tcx, metadata, need_metadata_module) } fn join_codegen_and_link( @@ -385,8 +229,6 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn build_isa(sess: &Session) -> Box { - use rustc::session::config::OptLevel; - let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); flags_builder.set("probestack_enabled", "false").unwrap(); // ___cranelift_probestack is not provided @@ -397,7 +239,9 @@ fn build_isa(sess: &Session) -> Box { }).unwrap(); // FIXME enable again when https://github.com/CraneStation/cranelift/issues/664 is fixed - /*match sess.opts.optimize { + /* + use rustc::session::config::OptLevel; + match sess.opts.optimize { OptLevel::No => { flags_builder.set("opt_level", "fastest").unwrap(); } @@ -416,53 +260,6 @@ fn build_isa(sess: &Session) -> Box { .finish(flags) } -fn codegen_cgus<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &mut Module, - debug: &mut Option>, - log: &mut Option, -) { - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let mono_items = cgus - .iter() - .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) - .flatten() - .collect::>(); - - codegen_mono_items(tcx, module, debug.as_mut(), log, mono_items); - - crate::main_shim::maybe_create_entry_wrapper(tcx, module); -} - -fn codegen_mono_items<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - module: &mut Module, - debug_context: Option<&mut DebugContext<'tcx>>, - log: &mut Option, - mono_items: FxHashMap, (RLinkage, Visibility)>, -) { - let mut cx = CodegenCx::new(tcx, module, debug_context); - time("codegen mono items", move || { - for (mono_item, (linkage, visibility)) in mono_items { - unimpl::try_unimpl(tcx, log, || { - let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - base::trans_mono_item(&mut cx, mono_item, linkage); - }); - } - - cx.finalize(); - }); -} - -fn time(name: &str, f: impl FnOnce() -> R) -> R { - println!("[{}] start", name); - let before = ::std::time::Instant::now(); - let res = f(); - let after = ::std::time::Instant::now(); - println!("[{}] end time: {:?}", name, after - before); - res -} - /// This is the entrypoint for a hot plugged rustc_codegen_cranelift #[no_mangle] pub fn __rustc_codegen_backend() -> Box { From 2aeffa679a6c9a36459b5aa8d77277e80c17a30c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 May 2019 20:05:01 +0200 Subject: [PATCH 0649/1566] Rustup to rustc 1.36.0-nightly (cfdc84a00 2019-05-07) --- src/common.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common.rs b/src/common.rs index 2ba66e3aef836..35af43f231823 100644 --- a/src/common.rs +++ b/src/common.rs @@ -622,6 +622,12 @@ impl<'a, 'tcx, B: Backend + 'a> layout::HasDataLayout for FunctionCx<'a, 'tcx, B } } +impl<'a, 'tcx, B: Backend + 'a> layout::HasParamEnv<'tcx> for FunctionCx<'a, 'tcx, B> { + fn param_env(&self) -> ParamEnv<'tcx> { + ParamEnv::reveal_all() + } +} + impl<'a, 'tcx, B: Backend + 'a> HasTargetSpec for FunctionCx<'a, 'tcx, B> { fn target_spec(&self) -> &Target { &self.tcx.sess.target.target From 82d113cad41cee9ab0e797664b847f6f1791dc80 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 8 May 2019 18:07:11 +0000 Subject: [PATCH 0650/1566] Bump syn from 0.15.33 to 0.15.34 Bumps [syn](https://github.com/dtolnay/syn) from 0.15.33 to 0.15.34. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/0.15.33...0.15.34) Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23bad972ded27..7b1b8d3e06b73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,7 +278,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -632,7 +632,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -698,12 +698,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.33" +version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -718,7 +718,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -929,7 +929,7 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" -"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836" +"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" From 6663c9f185de6dfc52942145160f58aa1a2e37bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 8 May 2019 18:07:19 +0000 Subject: [PATCH 0651/1566] Bump serde from 1.0.90 to 1.0.91 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.90 to 1.0.91. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.90...v1.0.91) Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23bad972ded27..fa13b432e642f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -650,7 +650,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.90" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -660,7 +660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -673,7 +673,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -922,7 +922,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" +"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" From e998997f98e936bfa7445272df1aaa43448c736a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 9 May 2019 11:29:05 +0200 Subject: [PATCH 0652/1566] Bump proc-macro2 from 0.4.29 to 0.4.30 (#527) Bumps [proc-macro2](https://github.com/alexcrichton/proc-macro2) from 0.4.29 to 0.4.30. - [Release notes](https://github.com/alexcrichton/proc-macro2/releases) - [Commits](https://github.com/alexcrichton/proc-macro2/compare/0.4.29...0.4.30) Signed-off-by: dependabot[bot] --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1e6b7a4d050d2..55a1051eb1b17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,7 +276,7 @@ name = "failure_derive" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -393,7 +393,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -409,7 +409,7 @@ name = "quote" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -630,7 +630,7 @@ name = "scroll_derive" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -696,7 +696,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -706,7 +706,7 @@ name = "syn" version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -716,7 +716,7 @@ name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -894,7 +894,7 @@ dependencies = [ "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)" = "64c827cea7a7ab30ce4593e5e04d7a11617ad6ece2fa230605a78b00ff965316" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" From 0046ce4c85d7db52923578a0d907597aa26b61e4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 May 2019 12:23:40 +0200 Subject: [PATCH 0653/1566] Partial support for wasm32-unknown-wasi as host triple This needs a rustc compiled for wasi (see rust-lang/miri#722) It also needs CraneStation/target-lexicon#14 --- Cargo.lock | 17 ++- Cargo.toml | 7 +- src/driver.rs | 301 +++++++++++++++++++++++++++----------------------- src/lib.rs | 2 - 4 files changed, 171 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55a1051eb1b17..d718a6f41d975 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -139,7 +139,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0", ] [[package]] @@ -165,7 +165,7 @@ dependencies = [ "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0", ] [[package]] @@ -175,7 +175,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf3 dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0", ] [[package]] @@ -196,7 +196,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf3 dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0", ] [[package]] @@ -210,7 +210,7 @@ dependencies = [ "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -259,7 +259,7 @@ dependencies = [ "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0", ] [[package]] @@ -594,12 +594,11 @@ dependencies = [ "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -725,7 +724,6 @@ dependencies = [ [[package]] name = "target-lexicon" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -931,7 +929,6 @@ dependencies = [ "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" diff --git a/Cargo.toml b/Cargo.toml index c823278cb39fe..2900dd852b98e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,13 +7,12 @@ authors = ["bjorn3 "] edition = "2018" [lib] -crate-type = ["dylib"] +crate-type = ["rlib", "dylib"] [dependencies] # These have to be in sync with each other cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } -cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.4.0" faerie = "0.10.0" @@ -24,7 +23,6 @@ bitflags = "1.0.3" byteorder = "1.2.7" libc = "0.2.53" tempfile = "3.0.7" -env_logger = "0.6" gimli = { git = "https://github.com/gimli-rs/gimli.git" } indexmap = "1.0.2" @@ -38,5 +36,8 @@ indexmap = "1.0.2" #[patch."https://github.com/gimli-rs/gimli.git"] #gimli = { path = "../" } +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } + [profile.dev.overrides."*"] opt-level = 3 diff --git a/src/driver.rs b/src/driver.rs index 6ec558705bc3a..6c66ee0f82e2a 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -17,9 +17,8 @@ use crate::prelude::*; pub fn codegen_crate<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, metadata: EncodedMetadata, - _need_metadata_module: bool, + need_metadata_module: bool, ) -> Box { - env_logger::init(); if !tcx.sess.crate_types.get().contains(&CrateType::Executable) && std::env::var("SHOULD_RUN").is_ok() { @@ -36,148 +35,168 @@ pub fn codegen_crate<'a, 'tcx>( }; if std::env::var("SHOULD_RUN").is_ok() { - let mut jit_module: Module = - Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names())); - assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); - - let sig = Signature { - params: vec![ - AbiParam::new(jit_module.target_config().pointer_type()), - AbiParam::new(jit_module.target_config().pointer_type()), - ], - returns: vec![AbiParam::new( - jit_module.target_config().pointer_type(), /*isize*/ - )], - call_conv: CallConv::SystemV, - }; - let main_func_id = jit_module - .declare_function("main", Linkage::Import, &sig) - .unwrap(); - - codegen_cgus(tcx, &mut jit_module, &mut None, &mut log); - crate::allocator::codegen(tcx.sess, &mut jit_module); - jit_module.finalize_definitions(); - - tcx.sess.abort_if_errors(); - - let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); - - println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); - - let f: extern "C" fn(c_int, *const *const c_char) -> c_int = - unsafe { ::std::mem::transmute(finalized_main) }; - - let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_| String::new()); - let args = args - .split(" ") - .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) - .map(|arg| CString::new(arg).unwrap()) - .collect::>(); - let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); - // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end - - let ret = f(args.len() as c_int, argv.as_ptr()); - - jit_module.finish(); - std::process::exit(ret); + #[cfg(not(target_arch = "wasm32"))] + let _: ! = run_jit(tcx, &mut log); + + #[cfg(target_arch = "wasm32")] + panic!("jit not supported on wasm"); + } + + run_aot(tcx, metadata, need_metadata_module, &mut log) +} + +#[cfg(not(target_arch = "wasm32"))] +fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option) -> ! { + use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; + + let mut jit_module: Module = + Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names())); + assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); + + let sig = Signature { + params: vec![ + AbiParam::new(jit_module.target_config().pointer_type()), + AbiParam::new(jit_module.target_config().pointer_type()), + ], + returns: vec![AbiParam::new( + jit_module.target_config().pointer_type(), /*isize*/ + )], + call_conv: CallConv::SystemV, + }; + let main_func_id = jit_module + .declare_function("main", Linkage::Import, &sig) + .unwrap(); + + codegen_cgus(tcx, &mut jit_module, &mut None, log); + crate::allocator::codegen(tcx.sess, &mut jit_module); + jit_module.finalize_definitions(); + + tcx.sess.abort_if_errors(); + + let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); + + println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); + + let f: extern "C" fn(c_int, *const *const c_char) -> c_int = + unsafe { ::std::mem::transmute(finalized_main) }; + + let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_| String::new()); + let args = args + .split(" ") + .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) + .map(|arg| CString::new(arg).unwrap()) + .collect::>(); + let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); + // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end + + let ret = f(args.len() as c_int, argv.as_ptr()); + + jit_module.finish(); + std::process::exit(ret); +} + +fn run_aot<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + metadata: EncodedMetadata, + _need_metadata_module: bool, + log: &mut Option, +) -> Box { + let new_module = |name: String| { + let module: Module = Module::new( + FaerieBuilder::new( + crate::build_isa(tcx.sess), + name + ".o", + FaerieTrapCollection::Disabled, + cranelift_module::default_libcall_names(), + ) + .unwrap(), + ); + assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); + module + }; + + let emit_module = |name: &str, + kind: ModuleKind, + mut module: Module, + debug: Option| { + module.finalize_definitions(); + let mut artifact = module.finish().artifact; + + if let Some(mut debug) = debug { + debug.emit(&mut artifact); + } + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(name)); + let obj = artifact.emit().unwrap(); + std::fs::write(&tmp_file, obj).unwrap(); + CompiledModule { + name: name.to_string(), + kind, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + } + }; + + let mut faerie_module = new_module("some_file".to_string()); + + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None + // macOS debuginfo doesn't work yet (see #303) + && !tcx.sess.target.target.options.is_like_osx + { + let debug = DebugContext::new( + tcx, + faerie_module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) } else { - let new_module = |name: String| { - let module: Module = Module::new( - FaerieBuilder::new( - crate::build_isa(tcx.sess), - name + ".o", - FaerieTrapCollection::Disabled, - cranelift_module::default_libcall_names(), - ) - .unwrap(), - ); - assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); - module - }; - - let emit_module = |name: &str, - kind: ModuleKind, - mut module: Module, - debug: Option| { - module.finalize_definitions(); - let mut artifact = module.finish().artifact; - - if let Some(mut debug) = debug { - debug.emit(&mut artifact); - } - - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, Some(name)); - let obj = artifact.emit().unwrap(); - std::fs::write(&tmp_file, obj).unwrap(); - CompiledModule { - name: name.to_string(), - kind, - object: Some(tmp_file), - bytecode: None, - bytecode_compressed: None, - } - }; - - let mut faerie_module = new_module("some_file".to_string()); - - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None - // macOS debuginfo doesn't work yet (see #303) - && !tcx.sess.target.target.options.is_like_osx - { - let debug = DebugContext::new( - tcx, - faerie_module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) + None + }; + + codegen_cgus(tcx, &mut faerie_module, &mut debug, log); + + tcx.sess.abort_if_errors(); + + let mut allocator_module = new_module("allocator_shim.o".to_string()); + let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); + + rustc_incremental::assert_dep_graph(tcx); + rustc_incremental::save_dep_graph(tcx); + rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); + + Box::new(CodegenResults { + crate_name: tcx.crate_name(LOCAL_CRATE), + modules: vec![emit_module( + "dummy_name", + ModuleKind::Regular, + faerie_module, + debug, + )], + allocator_module: if created_alloc_shim { + Some(emit_module( + "allocator_shim", + ModuleKind::Allocator, + allocator_module, + None, + )) } else { None - }; - - codegen_cgus(tcx, &mut faerie_module, &mut debug, &mut log); - - tcx.sess.abort_if_errors(); - - let mut allocator_module = new_module("allocator_shim.o".to_string()); - let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); - - rustc_incremental::assert_dep_graph(tcx); - rustc_incremental::save_dep_graph(tcx); - rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); - - Box::new(CodegenResults { - crate_name: tcx.crate_name(LOCAL_CRATE), - modules: vec![emit_module( - "dummy_name", - ModuleKind::Regular, - faerie_module, - debug, - )], - allocator_module: if created_alloc_shim { - Some(emit_module( - "allocator_shim", - ModuleKind::Allocator, - allocator_module, - None, - )) - } else { - None - }, - metadata_module: Some(CompiledModule { - name: "dummy_metadata".to_string(), - kind: ModuleKind::Metadata, - object: None, - bytecode: None, - bytecode_compressed: None, - }), - crate_hash: tcx.crate_hash(LOCAL_CRATE), - metadata, - windows_subsystem: None, // Windows is not yet supported - linker_info: LinkerInfo::new(tcx), - crate_info: CrateInfo::new(tcx), - }) - } + }, + metadata_module: Some(CompiledModule { + name: "dummy_metadata".to_string(), + kind: ModuleKind::Metadata, + object: None, + bytecode: None, + bytecode_compressed: None, + }), + crate_hash: tcx.crate_hash(LOCAL_CRATE), + metadata, + windows_subsystem: None, // Windows is not yet supported + linker_info: LinkerInfo::new(tcx), + crate_info: CrateInfo::new(tcx), + }) } fn codegen_cgus<'a, 'tcx: 'a>( diff --git a/src/lib.rs b/src/lib.rs index bfadb90ae73c3..1389a127c244e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ #![feature(rustc_private, never_type, decl_macro)] #![allow(intra_doc_link_resolution_failure)] -extern crate log; extern crate rustc; extern crate rustc_allocator; extern crate rustc_codegen_ssa; @@ -87,7 +86,6 @@ mod prelude { pub use cranelift_module::{ self, Backend, DataContext, DataId, FuncId, FuncOrDataId, Linkage, Module, }; - pub use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; From 5593bc8cd3ea06500879551b0acad373266d22af Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 May 2019 16:12:58 +0200 Subject: [PATCH 0654/1566] Update cranelift --- src/base.rs | 59 +++++++++++++++------------- src/common.rs | 19 --------- src/pretty_clif.rs | 97 ++++++++++++++++++++++++++++++++-------------- 3 files changed, 100 insertions(+), 75 deletions(-) diff --git a/src/base.rs b/src/base.rs index a3865b34524ab..2bc1af2fc59a5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -9,14 +9,13 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( ) { let tcx = cx.tcx; - // Step 1. Get mir let mir = tcx.instance_mir(instance.def); - // Step 2. Check fn sig for u128 and i128 and replace those functions with a trap. + // Check fn sig for u128 and i128 and replace those functions with a trap. { // FIXME implement u128 and i128 support - // Step 2a. Check sig for u128 and i128 + // Check sig for u128 and i128 let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx)); struct UI128Visitor<'a, 'tcx: 'a>(TyCtxt<'a, 'tcx, 'tcx>, bool); @@ -35,12 +34,12 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( let mut visitor = UI128Visitor(tcx, false); fn_sig.visit_with(&mut visitor); - // Step 2b. If found replace function with a trap. + //If found replace function with a trap. if visitor.1 { tcx.sess.warn("u128 and i128 are not yet supported. \ Functions using these as args will be replaced with a trap."); - // Step 2b1. Declare function with fake signature + // Declare function with fake signature let sig = Signature { params: vec![AbiParam::new(types::INVALID)], returns: vec![], @@ -49,7 +48,7 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( let name = tcx.symbol_name(instance).as_str(); let func_id = cx.module.declare_function(&*name, linkage, &sig).unwrap(); - // Step 2b2. Create trapping function + // Create trapping function let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); @@ -79,7 +78,7 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( fx.bcx.seal_all_blocks(); fx.bcx.finalize(); - // Step 2b3. Define function + // Define function cx.caches.context.func = func; cx.module .define_function(func_id, &mut cx.caches.context) @@ -89,7 +88,7 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( } } - // Step 3. Declare function + // Declare function let (name, sig) = get_function_name_and_sig(tcx, instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); let mut debug_context = cx @@ -97,19 +96,19 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( .as_mut() .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig)); - // Step 4. Make FunctionBuilder + // Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); - // Step 5. Predefine ebb's + // Predefine ebb's let start_ebb = bcx.create_ebb(); let mut ebb_map: HashMap = HashMap::new(); for (bb, _bb_data) in mir.basic_blocks().iter_enumerated() { ebb_map.insert(bb, bcx.create_ebb()); } - // Step 6. Make FunctionCx + // Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance); @@ -131,38 +130,46 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( source_info_set: indexmap::IndexSet::new(), }; - // Step 7. Codegen function with_unimpl_span(fx.mir.span, || { crate::abi::codegen_fn_prelude(&mut fx, start_ebb); codegen_fn_content(&mut fx); }); - let source_info_set = fx.source_info_set.clone(); - // Step 8. Write function to file for debugging + // Recover all necessary data from fx, before accessing func will prevent future access to it. + let instance = fx.instance; + let clif_comments = fx.clif_comments; + let source_info_set = fx.source_info_set; + #[cfg(debug_assertions)] - fx.write_clif_file(); + crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &func, &clif_comments, None); - // Step 9. Verify function - verify_func(tcx, fx.clif_comments, &func); + // Verify function + verify_func(tcx, &clif_comments, &func); - // Step 10. Define function - cx.caches.context.func = func; + // Define function + let context = &mut cx.caches.context; + context.func = func; cx.module - .define_function(func_id, &mut cx.caches.context) + .define_function(func_id, context) .unwrap(); - // Step 11. Define debuginfo for function - let context = &cx.caches.context; + let value_ranges = context.build_value_labels_ranges(cx.module.isa()).expect("value location ranges"); + + // Write optimized function to file for debugging + #[cfg(debug_assertions)] + crate::pretty_clif::write_clif_file(cx.tcx, "opt", instance, &context.func, &clif_comments, Some(&value_ranges)); + + // Define debuginfo for function let isa = cx.module.isa(); debug_context .as_mut() .map(|x| x.define(tcx, context, isa, &source_info_set)); - // Step 12. Clear context to make it usable for the next function - cx.caches.context.clear(); + // Clear context to make it usable for the next function + context.clear(); } -fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Function) { +fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { let flags = settings::Flags::new(settings::builder()); match ::cranelift::codegen::verify_function(&func, &flags) { Ok(_) => {} @@ -171,7 +178,7 @@ fn verify_func(tcx: TyCtxt, writer: crate::pretty_clif::CommentWriter, func: &Fu let pretty_error = ::cranelift::codegen::print_errors::pretty_verifier_error( &func, None, - Some(Box::new(&writer)), + Some(Box::new(writer)), err, ); tcx.sess diff --git a/src/common.rs b/src/common.rs index 35af43f231823..c48482344c79a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,3 @@ -use std::fmt; - use rustc_target::spec::{HasTargetSpec, Target}; use cranelift_module::Module; @@ -583,23 +581,6 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { pub source_info_set: indexmap::IndexSet, } -impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - writeln!(f, "{:?}", self.instance.substs)?; - writeln!(f, "{:?}", self.local_map)?; - - let mut clif = String::new(); - ::cranelift::codegen::write::decorate_function( - &mut &self.clif_comments, - &mut clif, - &self.bcx.func, - None, - ) - .unwrap(); - writeln!(f, "\n{}", clif) - } -} - impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> { type Ty = Ty<'tcx>; type TyLayout = TyLayout<'tcx>; diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index ee16c68214b70..66b3c66334f80 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -2,9 +2,16 @@ use std::borrow::Cow; use std::collections::HashMap; use std::fmt; -use cranelift::codegen::entity::SecondaryMap; -use cranelift::codegen::ir::entities::AnyEntity; -use cranelift::codegen::write::{FuncWriter, PlainWriter}; +use cranelift::codegen::{ + entity::SecondaryMap, + ir::{ + self, + entities::AnyEntity, + function::DisplayFunctionAnnotations, + }, + write::{FuncWriter, PlainWriter}, + ValueLabelsRanges, +}; use crate::prelude::*; @@ -184,42 +191,72 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } } } +} + +pub fn write_clif_file<'a, 'tcx: 'a>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + postfix: &str, + instance: Instance<'tcx>, + func: &ir::Function, + mut clif_comments: &CommentWriter, + value_ranges: Option<&ValueLabelsRanges>, +) { + use std::io::Write; + + let symbol_name = tcx.symbol_name(instance).as_str(); + let clif_file_name = format!( + "{}/{}__{}.{}.clif", + concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), + tcx.crate_name(LOCAL_CRATE), + symbol_name, + postfix, + ); - pub fn write_clif_file(&mut self) { - use std::io::Write; + let mut clif = String::new(); + cranelift::codegen::write::decorate_function( + &mut clif_comments, + &mut clif, + &func, + &DisplayFunctionAnnotations { + isa: Some(&*crate::build_isa(tcx.sess)), + value_ranges, + }, + ) + .unwrap(); + + match ::std::fs::File::create(clif_file_name) { + Ok(mut file) => { + let target_triple: ::target_lexicon::Triple = + tcx.sess.target.target.llvm_target.parse().unwrap(); + writeln!(file, "test compile").unwrap(); + writeln!(file, "set is_pic").unwrap(); + writeln!(file, "target {}", target_triple).unwrap(); + writeln!(file, "").unwrap(); + file.write(clif.as_bytes()).unwrap(); + } + Err(e) => { + tcx.sess.warn(&format!("err opening clif file: {:?}", e)); + } + } +} - let symbol_name = self.tcx.symbol_name(self.instance).as_str(); - let clif_file_name = format!( - "{}/{}__{}.clif", - concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), - self.tcx.crate_name(LOCAL_CRATE), - symbol_name, - ); +impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + writeln!(f, "{:?}", self.instance.substs)?; + writeln!(f, "{:?}", self.local_map)?; let mut clif = String::new(); ::cranelift::codegen::write::decorate_function( &mut &self.clif_comments, &mut clif, &self.bcx.func, - None, + // FIXME use DisplayFunctionAnnotations::default() instead + &DisplayFunctionAnnotations { + isa: None, + value_ranges: None, + }, ) .unwrap(); - - match ::std::fs::File::create(clif_file_name) { - Ok(mut file) => { - let target_triple: ::target_lexicon::Triple = - self.tcx.sess.target.target.llvm_target.parse().unwrap(); - writeln!(file, "test compile").unwrap(); - writeln!(file, "set is_pic").unwrap(); - writeln!(file, "target {}", target_triple).unwrap(); - writeln!(file, "").unwrap(); - file.write(clif.as_bytes()).unwrap(); - } - Err(e) => { - self.tcx - .sess - .warn(&format!("err opening clif file: {:?}", e)); - } - } + writeln!(f, "\n{}", clif) } } From 8ff6febdbf89d44e445be4094e97cc8b58b21a04 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 May 2019 15:21:05 +0200 Subject: [PATCH 0655/1566] Update cranelift --- Cargo.lock | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d718a6f41d975..8a3e6d72d1f05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -139,13 +139,13 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,35 +153,35 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,17 +192,17 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" +source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -210,7 +210,7 @@ dependencies = [ "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -259,7 +259,7 @@ dependencies = [ "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -598,7 +598,7 @@ dependencies = [ "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -724,6 +724,7 @@ dependencies = [ [[package]] name = "target-lexicon" version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -929,6 +930,7 @@ dependencies = [ "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" From d078fde07a5e1b6892318e4d772b2ec490b3620f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 May 2019 12:30:21 +0200 Subject: [PATCH 0656/1566] Rustup to rustc 1.36.0-nightly (dec4c5201 2019-05-24) --- src/lib.rs | 16 ++++++++++++++-- src/pretty_clif.rs | 3 +-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1389a127c244e..b9f8370872f5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,7 +184,7 @@ impl CodegenBackend for CraneliftCodegenBackend { rustc_codegen_utils::symbol_names::provide(providers); rustc_codegen_ssa::back::symbol_export::provide(providers); - providers.target_features_whitelist = |_tcx, _cnum| Lrc::new(Default::default()); + providers.target_features_whitelist = |tcx, _cnum| tcx.arena.alloc(FxHashMap::default()); } fn provide_extern(&self, providers: &mut Providers) { rustc_codegen_ssa::back::symbol_export::provide_extern(providers); @@ -226,6 +226,17 @@ impl CodegenBackend for CraneliftCodegenBackend { } } +fn target_triple(sess: &Session) -> target_lexicon::Triple { + let mut target = &*sess.target.target.llvm_target; + + // FIXME add support for x86_64-apple-macosx10.7.0 to target-lexicon + if target.starts_with("x86_64-apple-macosx") { + target = "x86_64-apple-darwin"; + } + + target.parse().unwrap() +} + fn build_isa(sess: &Session) -> Box { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); @@ -252,8 +263,9 @@ fn build_isa(sess: &Session) -> Box { } }*/ + let target_triple = target_triple(sess); let flags = settings::Flags::new(flags_builder); - cranelift::codegen::isa::lookup(sess.target.target.llvm_target.parse().unwrap()) + cranelift::codegen::isa::lookup(target_triple) .unwrap() .finish(flags) } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 66b3c66334f80..47524c59b16e1 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -226,8 +226,7 @@ pub fn write_clif_file<'a, 'tcx: 'a>( match ::std::fs::File::create(clif_file_name) { Ok(mut file) => { - let target_triple: ::target_lexicon::Triple = - tcx.sess.target.target.llvm_target.parse().unwrap(); + let target_triple = crate::target_triple(tcx.sess); writeln!(file, "test compile").unwrap(); writeln!(file, "set is_pic").unwrap(); writeln!(file, "target {}", target_triple).unwrap(); From b408885f70bf97a84603f866690253a3505556c8 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Sat, 25 May 2019 10:32:31 +0000 Subject: [PATCH 0657/1566] Bump cranelift from `dcce879` to `be02e94` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `dcce879` to `be02e94`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/dcce8792b18888228759122356683215f802d6a7...be02e945613270d17a316a23a58e0791d5712cee) Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a3e6d72d1f05..ef056e2bd0e70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#dcce8792b18888228759122356683215f802d6a7" +source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 5db3fcd1698f7d9c7593cd9d25b42a52210f0cee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 May 2019 13:56:28 +0200 Subject: [PATCH 0658/1566] Update Cargo.lock --- Cargo.lock | 103 ++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef056e2bd0e70..a6820f64bf997 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,27 +37,26 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.15" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -65,13 +64,13 @@ name = "backtrace-sys" version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -81,12 +80,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -96,7 +95,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -108,7 +107,7 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -208,7 +207,7 @@ dependencies = [ "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,7 +231,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -242,7 +241,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -267,7 +266,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -279,7 +278,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -300,7 +299,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.18.0" -source = "git+https://github.com/gimli-rs/gimli.git#423431f6747167af8e64cc8c8378f9a34a18ff8f" +source = "git+https://github.com/gimli-rs/gimli.git#2d8c8e200a3cac9fb649e7ed77c621168cb91d8d" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -324,7 +323,7 @@ name = "heck" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -352,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -360,7 +359,7 @@ name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -368,7 +367,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -417,8 +416,8 @@ name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -435,7 +434,7 @@ name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -473,7 +472,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -485,7 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -496,7 +495,7 @@ name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -513,8 +512,8 @@ name = "raw-cpuid" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -564,8 +563,8 @@ name = "region" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -588,7 +587,7 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -597,9 +596,9 @@ dependencies = [ "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -712,7 +711,7 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -733,11 +732,11 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.0.7" +version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -757,7 +756,7 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -786,7 +785,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-segmentation" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -851,13 +850,13 @@ dependencies = [ "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum backtrace 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f106c02a3604afcdc0df5d36cc47b44b55917dbaf3d808f71c163a0ddba64637" +"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum bitflags 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bd1fa8ad26490b0a5cfec99089952250301b6716cdeaa7c9ab229598fb82ab66" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" -"checksum cc 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "a0c56216487bb80eec9c4516337b2588a4f2a2290d72a1416d930e4dcdb0c90d" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" +"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -886,7 +885,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "c6785aa7dd976f5fbf3b71cfd9cd49d7f783c1ff565a858d71031c6c313aa5c6" +"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -929,15 +928,15 @@ dependencies = [ "checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" "checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" -"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" +"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" -"checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" +"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" "checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa6024fc12ddfd1c6dbc14a80fa2324d4568849869b779f6bd37e5e4c03344d1" +"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" From 610f377b7de358e6c3a7d57fe1a236347a48c833 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 26 May 2019 10:20:35 +0200 Subject: [PATCH 0659/1566] Rustup to rustc 1.36.0-nightly (f49269398 2019-05-25) --- patches/0015-Remove-usage-of-unsized-locals.patch | 6 +++--- src/constant.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch index 2f104ad5b25e8..da75a44fa3b93 100644 --- a/patches/0015-Remove-usage-of-unsized-locals.patch +++ b/patches/0015-Remove-usage-of-unsized-locals.patch @@ -41,9 +41,9 @@ index f6dee7c..0c6a8c0 100644 - } -} - - /// `FnBox` is a version of the `FnOnce` intended for use with boxed - /// closure objects. The idea is that where one would normally store a - /// `Box` in a data structure, you should use + /// `FnBox` is deprecated and will be removed. + /// `Box` can be called directly, since Rust 1.35.0. + /// diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs index 1181b86..20f9251 100644 --- a/src/libstd/sys_common/at_exit_imp.rs diff --git a/src/constant.rs b/src/constant.rs index 282f429d74de2..c0827941d2c96 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -65,7 +65,7 @@ pub fn trans_promoted<'a, 'tcx: 'a>( })) { Ok(const_) => { - let cplace = trans_const_place(fx, const_); + let cplace = trans_const_place(fx, *const_); debug_assert_eq!(cplace.layout(), fx.layout_of(dest_ty)); cplace } @@ -100,7 +100,7 @@ pub fn force_eval_const<'a, 'tcx: 'a>( instance, promoted: None, }; - fx.tcx.const_eval(param_env.and(cid)).unwrap() + *fx.tcx.const_eval(param_env.and(cid)).unwrap() } _ => *fx.monomorphize(&const_), } From b625e56488798ccf843cb21b54c3ca8b1dbd969b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 31 May 2019 10:56:55 +0200 Subject: [PATCH 0660/1566] Rustup to rustc 1.37.0-nightly (3ade426ed 2019-05-30) --- src/common.rs | 2 +- src/constant.rs | 2 +- src/debuginfo.rs | 4 ++-- src/lib.rs | 2 +- src/pretty_clif.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common.rs b/src/common.rs index c48482344c79a..1d9caf92f2255 100644 --- a/src/common.rs +++ b/src/common.rs @@ -569,7 +569,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { pub pointer_type: Type, // Cached from module pub instance: Instance<'tcx>, - pub mir: &'tcx Mir<'tcx>, + pub mir: &'tcx Body<'tcx>, pub bcx: FunctionBuilder<'a>, pub ebb_map: HashMap, diff --git a/src/constant.rs b/src/constant.rs index c0827941d2c96..5ee14ad763c18 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -359,7 +359,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { _: &[OpTy<'tcx>], _: Option>, _: Option, - ) -> EvalResult<'tcx, Option<&'mir Mir<'tcx>>> { + ) -> EvalResult<'tcx, Option<&'mir Body<'tcx>>> { panic!(); } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index d287e2cfaa308..3afdaf8d926b9 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -229,7 +229,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { pub fn new( tcx: TyCtxt<'b, 'tcx, 'tcx>, debug_context: &'a mut DebugContext<'tcx>, - mir: &Mir, + mir: &Body, name: &str, _sig: &Signature, ) -> Self { @@ -268,7 +268,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { &mut self, tcx: TyCtxt, context: &Context, - isa: &cranelift::codegen::isa::TargetIsa, + isa: &dyn cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet, ) { let line_program = &mut self.debug_context.dwarf.unit.line_program; diff --git a/src/lib.rs b/src/lib.rs index b9f8370872f5b..2cdd97374260a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -237,7 +237,7 @@ fn target_triple(sess: &Session) -> target_lexicon::Triple { target.parse().unwrap() } -fn build_isa(sess: &Session) -> Box { +fn build_isa(sess: &Session) -> Box { let mut flags_builder = settings::builder(); flags_builder.enable("is_pic").unwrap(); flags_builder.set("probestack_enabled", "false").unwrap(); // ___cranelift_probestack is not provided diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 47524c59b16e1..53cd4f3344241 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -117,7 +117,7 @@ impl<'a> FuncWriter for &'a CommentWriter { w: &mut dyn fmt::Write, _func: &Function, entity: AnyEntity, - value: &fmt::Display, + value: &dyn fmt::Display, ) -> fmt::Result { write!(w, " {} = {}", entity, value)?; From 37708ada2c5dfac8673d7920b39b946be647faff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Jun 2019 12:05:48 +0200 Subject: [PATCH 0661/1566] Update dependencies --- Cargo.lock | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6820f64bf997..e2cfdad9c773f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,8 +55,8 @@ dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -65,7 +65,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -207,7 +207,7 @@ dependencies = [ "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -231,7 +231,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -241,7 +241,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -256,8 +256,8 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -351,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.55" +version = "0.2.57" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -367,7 +367,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -417,7 +417,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -472,7 +472,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -484,7 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -564,7 +564,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -579,7 +579,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -596,7 +596,7 @@ dependencies = [ "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -648,7 +648,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.91" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -658,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -671,7 +671,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -681,16 +681,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -736,7 +736,7 @@ version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -756,7 +756,7 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -885,7 +885,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "42914d39aad277d9e176efbdad68acb1d5443ab65afe0e0e4f0d49352a950880" +"checksum libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)" = "a844cabbd5a77e60403a58af576f0a1baa83c3dd2670be63e615bd24fc58b82d" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -913,20 +913,20 @@ dependencies = [ "checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" "checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" +"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "a72e9b96fa45ce22a4bc23da3858dfccfd60acd28a25bcd328a98fdd6bea43fd" +"checksum serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "3d0760c312538987d363c36c42339b55f5ee176ea8808bbe4543d484a291c8d1" -"checksum structopt-derive 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "528aeb7351d042e6ffbc2a6fb76a86f9b622fdf7c25932798e7a82cb03bc94c6" +"checksum structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c767a8971f53d7324583085deee2e230903be09e52fb27df9af94c5cb2b43c31" +"checksum structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c57a30c87454ced2186f62f940e981746e8cbbe026d52090c8c4352b636f8235" "checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" From d3dbf358ae37a3a285e4def6f5621f74fe4ca2b5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Jun 2019 12:06:02 +0200 Subject: [PATCH 0662/1566] Rustup to rustc 1.37.0-nightly (03ee55bb1 2019-06-01) --- src/constant.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 5ee14ad763c18..b4e6273cfcbd2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ - read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar, + read_target_uint, AllocId, GlobalAlloc, Allocation, ConstValue, EvalResult, GlobalId, Scalar, }; use rustc::ty::Const; use rustc_mir::interpret::{ @@ -171,7 +171,7 @@ fn trans_const_place<'a, 'tcx: 'a>( let alloc = result().expect("unable to convert ConstValue to Allocation"); //println!("const value: {:?} allocation: {:?}", value, alloc); - let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); + let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); fx.constants.todo.insert(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id); cplace_for_dataid(fx, const_.ty, data_id) @@ -296,18 +296,18 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( }; let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { - AllocKind::Function(instance) => { + GlobalAlloc::Function(instance) => { assert_eq!(addend, 0); let func_id = crate::abi::import_function(tcx, module, instance); let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx); data_ctx.write_function_addr(offset.bytes() as u32, local_func_id); continue; } - AllocKind::Memory(_) => { + GlobalAlloc::Memory(_) => { cx.todo.insert(TodoItem::Alloc(reloc)); data_id_for_alloc_id(module, reloc) } - AllocKind::Static(def_id) => { + GlobalAlloc::Static(def_id) => { cx.todo.insert(TodoItem::Static(def_id)); let linkage = crate::linkage::get_static_ref_linkage(tcx, def_id); data_id_for_static(tcx, module, def_id, linkage) From 161c8aa5cf129d98b2c0b52744b7ef5385f9701c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 6 Jun 2019 20:31:09 +0200 Subject: [PATCH 0663/1566] Rustup to rustc 1.37.0-nightly (7cdaffd79 2019-06-05) --- src/base.rs | 4 ++-- src/constant.rs | 29 +++++++++-------------------- src/driver.rs | 1 - src/lib.rs | 4 ++-- src/vtable.rs | 2 +- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/base.rs b/src/base.rs index 2bc1af2fc59a5..5bc98237cd311 100644 --- a/src/base.rs +++ b/src/base.rs @@ -288,7 +288,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } => { let ty = location.ty(fx.mir, fx.tcx).ty; let ty = fx.monomorphize(&ty); - let drop_fn = crate::rustc_mir::monomorphize::resolve_drop_in_place(fx.tcx, ty); + let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty); if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything @@ -603,7 +603,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let operand = trans_operand(fx, operand); match operand.layout().ty.sty { ty::Closure(def_id, substs) => { - let instance = rustc_mir::monomorphize::resolve_closure( + let instance = Instance::resolve_closure( fx.tcx, def_id, substs, diff --git a/src/constant.rs b/src/constant.rs index b4e6273cfcbd2..e9ea58ed1b13b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::Const; use rustc_mir::interpret::{ - InterpretCx, ImmTy, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, + InterpretCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, StackPopCleanup, }; @@ -375,7 +375,6 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { fn find_foreign_static( _: DefId, _: ::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, - _: &(), ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } @@ -393,27 +392,17 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn tag_dereference( - _: &InterpretCx<'a, 'mir, 'tcx, Self>, - _: MPlaceTy<'tcx>, - _: Option<::rustc::hir::Mutability>, - ) -> EvalResult<'tcx, Scalar> { - panic!(); - } - - fn adjust_static_allocation<'alloc>( - alloc: &'alloc Allocation, + fn tag_allocation<'b>( + _: AllocId, + alloc: Cow<'b, Allocation>, + _: Option>, _: &(), - ) -> Cow<'alloc, Allocation> { - Cow::Borrowed(alloc) + ) -> (Cow<'b, Allocation<(), ()>>, ()) { + (alloc, ()) } - fn new_allocation( - _: Size, - _: &(), - _: MemoryKind, - ) -> ((), ()) { - ((), ()) + fn tag_static_base_pointer(_: AllocId, _: &()) -> Self::PointerTag { + () } fn stack_push(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { diff --git a/src/driver.rs b/src/driver.rs index 6c66ee0f82e2a..beaa24d62f557 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -8,7 +8,6 @@ use rustc::mir::mono::{Linkage as RLinkage, Visibility}; use rustc::session::config::{DebugInfo, OutputType}; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; -use rustc_mir::monomorphize::partitioning::CodegenUnitExt; use cranelift_faerie::*; diff --git a/src/lib.rs b/src/lib.rs index 2cdd97374260a..0d545ebb9af07 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,7 @@ mod prelude { pub use rustc::bug; pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; - pub use rustc::mir::{self, interpret::AllocId, *}; + pub use rustc::mir::{self, interpret::AllocId, mono::MonoItem, *}; pub use rustc::session::{ config::{CrateType, Lto}, Session, @@ -71,7 +71,7 @@ mod prelude { indexed_vec::Idx, sync::Lrc, }; - pub use rustc_mir::monomorphize::{collector, MonoItem}; + pub use rustc_mir::monomorphize::collector; pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; pub use rustc_codegen_ssa::traits::*; diff --git a/src/vtable.rs b/src/vtable.rs index a19b6b458c408..d89f16ded0d7e 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -89,7 +89,7 @@ fn build_vtable<'a, 'tcx: 'a>( let drop_in_place_fn = import_function( tcx, fx.module, - crate::rustc_mir::monomorphize::resolve_drop_in_place(tcx, ty), + Instance::resolve_drop_in_place(tcx, ty), ); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; From a91625bdbbec66d980e7a72ea545006f6d774a82 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Sat, 8 Jun 2019 07:43:58 +0000 Subject: [PATCH 0664/1566] Bump bitflags from 1.0.4 to 1.1.0 Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.0.4 to 1.1.0. - [Release notes](https://github.com/bitflags/bitflags/releases) - [Changelog](https://github.com/bitflags/bitflags/blob/master/CHANGELOG.md) - [Commits](https://github.com/bitflags/bitflags/compare/1.0.4...1.1.0) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2cfdad9c773f..350138a2ebbc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -95,7 +95,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -107,7 +107,7 @@ name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -512,7 +512,7 @@ name = "raw-cpuid" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -563,7 +563,7 @@ name = "region" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -587,7 +587,7 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -853,7 +853,7 @@ dependencies = [ "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" diff --git a/Cargo.toml b/Cargo.toml index 2900dd852b98e..b60411311b14e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ faerie = "0.10.0" #goblin = "0.0.17" ar = "0.7.0" -bitflags = "1.0.3" +bitflags = "1.1.0" byteorder = "1.2.7" libc = "0.2.53" tempfile = "3.0.7" From 4b5bb3302b63872048a296f90861694754487a5a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Jun 2019 20:41:15 +0200 Subject: [PATCH 0665/1566] Pretty print non local mir bodies too on panic --- src/driver.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index beaa24d62f557..c975f77550f4b 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -48,8 +48,9 @@ pub fn codegen_crate<'a, 'tcx>( fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; - let mut jit_module: Module = - Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names())); + let mut jit_module: Module = Module::new(SimpleJITBuilder::new( + cranelift_module::default_libcall_names(), + )); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); let sig = Signature { @@ -115,9 +116,9 @@ fn run_aot<'a, 'tcx: 'a>( }; let emit_module = |name: &str, - kind: ModuleKind, - mut module: Module, - debug: Option| { + kind: ModuleKind, + mut module: Module, + debug: Option| { module.finalize_definitions(); let mut artifact = module.finish().artifact; @@ -251,9 +252,7 @@ fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( match inst.def { InstanceDef::Item(_) | InstanceDef::DropGlue(_, _) - | InstanceDef::Virtual(_, _) - if inst.def_id().krate == LOCAL_CRATE => - { + | InstanceDef::Virtual(_, _) => { let mut mir = ::std::io::Cursor::new(Vec::new()); crate::rustc_mir::util::write_mir_pretty( tcx, From d8d405e85b46ffa26ac2f243b04af9d55338756e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 9 Jun 2019 15:16:45 +0200 Subject: [PATCH 0666/1566] Rustup to rustc 1.37.0-nightly (991c719a1 2019-06-08) --- src/constant.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index e9ea58ed1b13b..191f483391905 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ - read_target_uint, AllocId, GlobalAlloc, Allocation, ConstValue, EvalResult, GlobalId, Scalar, + read_target_uint, AllocId, GlobalAlloc, Allocation, ConstValue, InterpResult, GlobalId, Scalar, }; use rustc::ty::Const; use rustc_mir::interpret::{ @@ -140,7 +140,7 @@ fn trans_const_place<'a, 'tcx: 'a>( const_: Const<'tcx>, ) -> CPlace<'tcx> { // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 - let result = || -> EvalResult<'tcx, &'tcx Allocation> { + let result = || -> InterpResult<'tcx, &'tcx Allocation> { let mut ecx = InterpretCx::new( fx.tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all(), @@ -349,7 +349,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { false } - fn before_terminator(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { + fn before_terminator(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> InterpResult<'tcx> { panic!(); } @@ -359,7 +359,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { _: &[OpTy<'tcx>], _: Option>, _: Option, - ) -> EvalResult<'tcx, Option<&'mir Body<'tcx>>> { + ) -> InterpResult<'tcx, Option<&'mir Body<'tcx>>> { panic!(); } @@ -368,14 +368,14 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { _: Instance<'tcx>, _: &[OpTy<'tcx>], _: PlaceTy<'tcx>, - ) -> EvalResult<'tcx> { + ) -> InterpResult<'tcx> { panic!(); } fn find_foreign_static( _: DefId, _: ::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, - ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { + ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } @@ -384,11 +384,11 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { _: mir::BinOp, _: ImmTy<'tcx>, _: ImmTy<'tcx>, - ) -> EvalResult<'tcx, (Scalar, bool)> { + ) -> InterpResult<'tcx, (Scalar, bool)> { panic!(); } - fn box_alloc(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> EvalResult<'tcx> { + fn box_alloc(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { panic!(); } @@ -405,11 +405,11 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { () } - fn stack_push(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { + fn stack_push(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> InterpResult<'tcx> { Ok(()) } - fn stack_pop(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: ()) -> EvalResult<'tcx> { + fn stack_pop(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> { Ok(()) } } From 165314bac9e29568160e9579a5050eb13b9371e5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 9 Jun 2019 15:27:37 +0200 Subject: [PATCH 0667/1566] Update cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 350138a2ebbc4..16e2b06c07ed3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -130,7 +130,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -152,12 +152,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -180,7 +180,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -191,7 +191,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -201,7 +201,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#be02e945613270d17a316a23a58e0791d5712cee" +source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From e8767b04acbd111e8aa49a7ec99cafd7c5dfad66 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 9 Jun 2019 15:34:44 +0200 Subject: [PATCH 0668/1566] Update Cargo.lock --- Cargo.lock | 68 +++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16e2b06c07ed3..68d9db2c1f4a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,7 +37,7 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -49,13 +49,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -65,7 +65,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -207,7 +207,7 @@ dependencies = [ "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -221,8 +221,8 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -231,7 +231,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -241,7 +241,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -266,7 +266,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -277,7 +277,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -351,7 +351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.57" +version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -367,7 +367,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -417,7 +417,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -472,7 +472,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -484,7 +484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -540,19 +540,19 @@ dependencies = [ [[package]] name = "regex" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -564,7 +564,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -596,7 +596,7 @@ dependencies = [ "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -630,7 +630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -696,12 +696,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.34" +version = "0.15.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -716,7 +716,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -736,7 +736,7 @@ version = "3.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -745,7 +745,7 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -756,7 +756,7 @@ name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -851,7 +851,7 @@ dependencies = [ "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum backtrace 0.3.26 (registry+https://github.com/rust-lang/crates.io-index)" = "1a13fc43f04daf08ab4f71e3d27e1fc27fc437d3e95ac0063a796d92fb40f39b" +"checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" @@ -885,7 +885,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)" = "a844cabbd5a77e60403a58af576f0a1baa83c3dd2670be63e615bd24fc58b82d" +"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" @@ -909,8 +909,8 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" -"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" +"checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" +"checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" @@ -927,11 +927,11 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c767a8971f53d7324583085deee2e230903be09e52fb27df9af94c5cb2b43c31" "checksum structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c57a30c87454ced2186f62f940e981746e8cbbe026d52090c8c4352b636f8235" -"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +"checksum syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)" = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" -"checksum termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4096add70612622289f2fdcdbd5086dc81c1e2675e6ae58d6c4f62a16c6d7f2f" +"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" From 18b78d116a3fbe518d7e02c48ea0eb503f3d2804 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 15:21:05 +0200 Subject: [PATCH 0669/1566] Update dependencies --- Cargo.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68d9db2c1f4a2..58d253edcc854 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,7 +21,7 @@ name = "ar" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -75,7 +75,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -208,7 +208,7 @@ dependencies = [ "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "region 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -256,8 +256,8 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -302,7 +302,7 @@ version = "0.18.0" source = "git+https://github.com/gimli-rs/gimli.git#2d8c8e200a3cac9fb649e7ed77c621168cb91d8d" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -547,7 +547,7 @@ dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -560,7 +560,7 @@ dependencies = [ [[package]] name = "region" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -588,7 +588,7 @@ version = "0.1.0" dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -681,16 +681,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -800,7 +800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "utf8-ranges" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -854,7 +854,7 @@ dependencies = [ "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" -"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" @@ -911,7 +911,7 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" -"checksum region 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ace21a7fc79cffefeb66f2cc3ef22c7687015023bf7f85bec8840f0d46cb51cc" +"checksum region 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0626be7920e71f5f600f358ee436e8c14ad0605d5434f78ac47863429ee6ce3" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" @@ -925,8 +925,8 @@ dependencies = [ "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum structopt 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c767a8971f53d7324583085deee2e230903be09e52fb27df9af94c5cb2b43c31" -"checksum structopt-derive 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c57a30c87454ced2186f62f940e981746e8cbbe026d52090c8c4352b636f8235" +"checksum structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fa19a5a708e22bb5be31c1b6108a2a902f909c4b9ba85cba44c06632386bc0ff" +"checksum structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d59d0ae8ef8de16e49e3ca7afa16024a3e0dfd974a75ef93fdc5464e34523f" "checksum syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)" = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" @@ -939,7 +939,7 @@ dependencies = [ "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" +"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" From d6e07cfcc8e6a735c60814e44143591e0c2911ae Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 15:32:30 +0200 Subject: [PATCH 0670/1566] Encapsulate CValue and CPlace creation --- src/abi.rs | 16 +++++++--------- src/base.rs | 30 +++++++++++++++--------------- src/common.rs | 26 ++++++++++++++++++++++++++ src/constant.rs | 2 +- src/intrinsics.rs | 6 +++--- src/trap.rs | 2 +- src/unsize.rs | 2 +- 7 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 74b373276cb70..cad6fe3285e8d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -223,9 +223,9 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { Some(self.clif_type(return_ty).unwrap()) }; if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { - CValue::ByVal(val, return_layout) + CValue::by_val(val, return_layout) } else { - CValue::ByRef( + CValue::by_ref( self.bcx .ins() .iconst(self.pointer_type, self.pointer_type.bytes() as i64), @@ -291,9 +291,7 @@ fn local_place<'a, 'tcx: 'a>( is_ssa: bool, ) -> CPlace<'tcx> { let place = if is_ssa { - fx.bcx - .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); - CPlace::Var(local, layout) + CPlace::new_var(fx, local, layout) } else { let place = CPlace::new_stack_slot(fx, layout.ty); @@ -372,8 +370,8 @@ fn cvalue_for_param<'a, 'tcx: 'a>( match pass_mode { PassMode::NoPass => unreachable!(), - PassMode::ByVal(_) => Some(CValue::ByVal(ebb_param, layout)), - PassMode::ByRef => Some(CValue::ByRef(ebb_param, layout)), + PassMode::ByVal(_) => Some(CValue::by_val(ebb_param, layout)), + PassMode::ByRef => Some(CValue::by_ref(ebb_param, layout)), } } @@ -460,7 +458,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( match output_pass_mode { PassMode::NoPass => { fx.local_map - .insert(RETURN_PLACE, CPlace::NoPlace(ret_layout)); + .insert(RETURN_PLACE, CPlace::no_place(ret_layout)); } PassMode::ByVal(_) => { let is_ssa = !ssa_analyzed @@ -693,7 +691,7 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( PassMode::ByVal(_) => { if let Some(ret_place) = ret_place { let ret_val = fx.bcx.inst_results(call_inst)[0]; - ret_place.write_cvalue(fx, CValue::ByVal(ret_val, ret_layout)); + ret_place.write_cvalue(fx, CValue::by_val(ret_val, ret_layout)); } } PassMode::ByRef => {} diff --git a/src/base.rs b/src/base.rs index 5bc98237cd311..628f89675b8b2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -483,7 +483,7 @@ fn trans_stmt<'a, 'tcx: 'a>( _ => unimplemented!("un op Neg for {:?}", layout.ty), }, }; - lval.write_cvalue(fx, CValue::ByVal(res, layout)); + lval.write_cvalue(fx, CValue::by_val(res, layout)); } Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, ty) => { let layout = fx.layout_of(ty); @@ -497,7 +497,7 @@ fn trans_stmt<'a, 'tcx: 'a>( .unwrap(), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); - lval.write_cvalue(fx, CValue::ByVal(func_addr, layout)); + lval.write_cvalue(fx, CValue::by_val(func_addr, layout)); } _ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", ty), } @@ -526,7 +526,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } else { // fat-ptr -> thin-ptr let (ptr, _extra) = operand.load_scalar_pair(fx); - lval.write_cvalue(fx, CValue::ByVal(ptr, dest_layout)) + lval.write_cvalue(fx, CValue::by_val(ptr, dest_layout)) } } else if let ty::Adt(adt_def, _substs) = from_ty.sty { // enum -> discriminant value @@ -596,7 +596,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } else { unimpl!("rval misc {:?} {:?}", from_ty, to_ty) }; - lval.write_cvalue(fx, CValue::ByVal(res, dest_layout)); + lval.write_cvalue(fx, CValue::by_val(res, dest_layout)); } } Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), operand, _ty) => { @@ -611,7 +611,7 @@ fn trans_stmt<'a, 'tcx: 'a>( ); let func_ref = fx.get_function_ref(instance); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); - lval.write_cvalue(fx, CValue::ByVal(func_addr, lval.layout())); + lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); } _ => { bug!("{} cannot be cast to a fn ptr", operand.layout().ty) @@ -639,7 +639,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let place = trans_place(fx, place); let usize_layout = fx.layout_of(fx.tcx.types.usize); let len = codegen_array_len(fx, place); - lval.write_cvalue(fx, CValue::ByVal(len, usize_layout)); + lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { use rustc::middle::lang_items::ExchangeMallocFnLangItem; @@ -666,7 +666,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let func_ref = fx.get_function_ref(instance); let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); let ptr = fx.bcx.inst_results(call)[0]; - lval.write_cvalue(fx, CValue::ByVal(ptr, box_layout)); + lval.write_cvalue(fx, CValue::by_val(ptr, box_layout)); } Rvalue::NullaryOp(NullOp::SizeOf, ty) => { assert!(lval @@ -754,7 +754,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( _ => false, }; let val = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), signed); - return CValue::ByVal(val, dest_layout); + return CValue::by_val(val, dest_layout); } layout::DiscriminantKind::Niche { dataful_variant, @@ -777,7 +777,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( .ins() .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); let val = fx.bcx.ins().select(b, if_true, if_false); - return CValue::ByVal(val, dest_layout); + return CValue::by_val(val, dest_layout); } else { // Rebase from niche values to discriminant values. let delta = niche_start.wrapping_sub(niche_variants.start().as_u32() as u128); @@ -795,7 +795,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( .ins() .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); let val = fx.bcx.ins().select(b, if_true, if_false); - return CValue::ByVal(val, dest_layout); + return CValue::by_val(val, dest_layout); } } } @@ -810,20 +810,20 @@ macro_rules! binop_match { let ret_layout = $fx.layout_of($ret_ty); let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); - CValue::ByVal($fx.bcx.ins().bint(types::I8, b), ret_layout) + CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) }}; (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ assert_eq!($fx.tcx.types.bool, $ret_ty); let ret_layout = $fx.layout_of($ret_ty); let b = $fx.bcx.ins().fcmp(FloatCC::$cc, $lhs, $rhs); - CValue::ByVal($fx.bcx.ins().bint(types::I8, b), ret_layout) + CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) }}; (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, custom(|| $body:expr)) => {{ $body }}; (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $name:ident) => {{ let ret_layout = $fx.layout_of($ret_ty); - CValue::ByVal($fx.bcx.ins().$name($lhs, $rhs), ret_layout) + CValue::by_val($fx.bcx.ins().$name($lhs, $rhs), ret_layout) }}; ( $fx:expr, $bin_op:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $bug_fmt:expr; @@ -1064,7 +1064,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); let base_val = base.load_scalar(fx); let res = fx.bcx.ins().iadd(base_val, ptr_diff); - return CValue::ByVal(res, base.layout()); + return CValue::by_val(res, base.layout()); } binop_match! { @@ -1111,7 +1111,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( assert_eq!(fx.tcx.types.bool, ret_ty); let ret_layout = fx.layout_of(ret_ty); - CValue::ByVal(fx.bcx.ins().bint(types::I8, res), ret_layout) + CValue::by_val(fx.bcx.ins().bint(types::I8, res), ret_layout) } } diff --git a/src/common.rs b/src/common.rs index 1d9caf92f2255..a29e07f422704 100644 --- a/src/common.rs +++ b/src/common.rs @@ -109,6 +109,18 @@ pub enum CValue<'tcx> { } impl<'tcx> CValue<'tcx> { + pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue::ByRef(value, layout) + } + + pub fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue::ByVal(value, layout) + } + + pub fn by_val_pair(value: Value, extra: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue::ByValPair(value, extra, layout) + } + pub fn layout(&self) -> TyLayout<'tcx> { match *self { CValue::ByRef(_, layout) @@ -257,6 +269,10 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } + pub fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { + CPlace::NoPlace(layout) + } + pub fn new_stack_slot( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, @@ -275,6 +291,16 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Stack(stack_slot, layout) } + pub fn new_var( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + local: Local, + layout: TyLayout<'tcx>, + ) -> CPlace<'tcx> { + fx.bcx + .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); + CPlace::Var(local, layout) + } + pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { match self { CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(mir_var(var)), layout), diff --git a/src/constant.rs b/src/constant.rs index 191f483391905..31f95cda1e3ff 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -125,7 +125,7 @@ fn trans_const_value<'a, 'tcx: 'a>( let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, rustc::mir::interpret::sign_extend(bits, layout.size) as i128 as i64) } - ty::FnDef(_def_id, _substs) => CValue::ByRef( + ty::FnDef(_def_id, _substs) => CValue::by_ref( fx.bcx .ins() .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 22a527f0ab354..8900e5f275604 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -335,7 +335,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( assert_eq!(from.layout().ty, src_ty); let addr = from.force_stack(fx); let dst_layout = fx.layout_of(dst_ty); - ret.write_cvalue(fx, CValue::ByRef(addr, dst_layout)) + ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) }; init, () { if ret.layout().abi == Abi::Uninhabited { @@ -422,7 +422,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("atomic_load"), (c ptr) { let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); - let val = CValue::ByRef(ptr.load_scalar(fx), inner_layout); + let val = CValue::by_ref(ptr.load_scalar(fx), inner_layout); ret.write_cvalue(fx, val); }; _ if intrinsic.starts_with("atomic_store"), (v ptr, c val) { @@ -451,7 +451,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // Write new fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); - let ret_val = CValue::ByValPair(old, fx.bcx.ins().bint(types::I8, is_eq), ret.layout()); + let ret_val = CValue::by_val_pair(old, fx.bcx.ins().bint(types::I8, is_eq), ret.layout()); ret.write_cvalue(fx, ret_val); }; diff --git a/src/trap.rs b/src/trap.rs index 925d59ac255e0..a597e18e19ecc 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -40,7 +40,7 @@ pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl crane let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); - CValue::ByRef(zero, dest_layout) + CValue::by_ref(zero, dest_layout) } /// Trap code: user65535 diff --git a/src/unsize.rs b/src/unsize.rs index 627199ddab6c3..57399e10b7ab9 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -101,7 +101,7 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a>( let base = src.load_scalar(fx); unsize_thin_ptr(fx, base, src_ty, dst_ty) }; - dst.write_cvalue(fx, CValue::ByValPair(base, info, dst.layout())); + dst.write_cvalue(fx, CValue::by_val_pair(base, info, dst.layout())); }; match (&src_ty.sty, &dst_ty.sty) { (&ty::Ref(..), &ty::Ref(..)) From 466ecad2f0ddc55c15ee60943c84bb66ffd5ec17 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 15:43:22 +0200 Subject: [PATCH 0671/1566] Move CValue and CPlace to separate file and remove duplicate scalar_to_clif_type --- src/common.rs | 495 ----------------------------------------- src/lib.rs | 2 + src/value_and_place.rs | 486 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 488 insertions(+), 495 deletions(-) create mode 100644 src/value_and_place.rs diff --git a/src/common.rs b/src/common.rs index a29e07f422704..00135d2c03305 100644 --- a/src/common.rs +++ b/src/common.rs @@ -17,16 +17,6 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } } -fn scalar_to_clif_type(tcx: TyCtxt, scalar: &Scalar) -> Type { - match scalar.value.size(&tcx).bits() { - 8 => types::I8, - 16 => types::I16, - 32 => types::I32, - 64 => types::I64, - size => bug!("Unsupported scalar size {}", size), - } -} - pub fn clif_type_from_ty<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>, @@ -82,491 +72,6 @@ pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: V } } -fn codegen_field<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - base: Value, - layout: TyLayout<'tcx>, - field: mir::Field, -) -> (Value, TyLayout<'tcx>) { - let field_offset = layout.fields.offset(field.index()); - let field_ty = layout.field(&*fx, field.index()); - if field_offset.bytes() > 0 { - ( - fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), - field_ty, - ) - } else { - (base, field_ty) - } -} - -/// A read-only value -#[derive(Debug, Copy, Clone)] -pub enum CValue<'tcx> { - ByRef(Value, TyLayout<'tcx>), - ByVal(Value, TyLayout<'tcx>), - ByValPair(Value, Value, TyLayout<'tcx>), -} - -impl<'tcx> CValue<'tcx> { - pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue::ByRef(value, layout) - } - - pub fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue::ByVal(value, layout) - } - - pub fn by_val_pair(value: Value, extra: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue::ByValPair(value, extra, layout) - } - - pub fn layout(&self) -> TyLayout<'tcx> { - match *self { - CValue::ByRef(_, layout) - | CValue::ByVal(_, layout) - | CValue::ByValPair(_, _, layout) => layout, - } - } - - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value - where - 'tcx: 'a, - { - match self { - CValue::ByRef(value, _layout) => value, - CValue::ByVal(value, layout) => { - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); - fx.bcx.ins().store(MemFlags::new(), value, addr, 0); - addr - } - CValue::ByValPair(value, extra, layout) => { - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let base = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); - let a_addr = codegen_field(fx, base, layout, mir::Field::new(0)).0; - let b_addr = codegen_field(fx, base, layout, mir::Field::new(1)).0; - fx.bcx.ins().store(MemFlags::new(), value, a_addr, 0); - fx.bcx.ins().store(MemFlags::new(), extra, b_addr, 0); - base - } - } - } - - /// Load a value with layout.abi of scalar - pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value - where - 'tcx: 'a, - { - match self { - CValue::ByRef(addr, layout) => { - let scalar = match layout.abi { - layout::Abi::Scalar(ref scalar) => scalar.clone(), - _ => unreachable!(), - }; - let clif_ty = crate::abi::scalar_to_clif_type(fx.tcx, scalar); - fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) - } - CValue::ByVal(value, _layout) => value, - CValue::ByValPair(_, _, _layout) => bug!("Please use load_scalar_pair for ByValPair"), - } - } - - /// Load a value pair with layout.abi of scalar pair - pub fn load_scalar_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> (Value, Value) - where - 'tcx: 'a, - { - match self { - CValue::ByRef(addr, layout) => { - let (a, b) = match &layout.abi { - layout::Abi::ScalarPair(a, b) => (a.clone(), b.clone()), - _ => unreachable!(), - }; - let clif_ty1 = crate::abi::scalar_to_clif_type(fx.tcx, a.clone()); - let clif_ty2 = crate::abi::scalar_to_clif_type(fx.tcx, b); - let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); - let val2 = fx.bcx.ins().load( - clif_ty2, - MemFlags::new(), - addr, - a.value.size(&fx.tcx).bytes() as i32, - ); - (val1, val2) - } - CValue::ByVal(_, _layout) => bug!("Please use load_scalar for ByVal"), - CValue::ByValPair(val1, val2, _layout) => (val1, val2), - } - } - - pub fn value_field<'a>( - self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - field: mir::Field, - ) -> CValue<'tcx> - where - 'tcx: 'a, - { - let (base, layout) = match self { - CValue::ByRef(addr, layout) => (addr, layout), - _ => bug!("place_field for {:?}", self), - }; - - let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); - CValue::ByRef(field_ptr, field_layout) - } - - pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - crate::unsize::coerce_unsized_into(fx, self, dest); - } - - pub fn const_val<'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - ty: Ty<'tcx>, - const_val: i64, - ) -> CValue<'tcx> - where - 'tcx: 'a, - { - let clif_ty = fx.clif_type(ty).unwrap(); - let layout = fx.layout_of(ty); - CValue::ByVal(fx.bcx.ins().iconst(clif_ty, const_val), layout) - } - - pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { - match self { - CValue::ByRef(addr, _) => CValue::ByRef(addr, layout), - CValue::ByVal(val, _) => CValue::ByVal(val, layout), - CValue::ByValPair(val, extra, _) => CValue::ByValPair(val, extra, layout), - } - } -} - -/// A place where you can write a value to or read a value from -#[derive(Debug, Copy, Clone)] -pub enum CPlace<'tcx> { - Var(Local, TyLayout<'tcx>), - Addr(Value, Option, TyLayout<'tcx>), - Stack(StackSlot, TyLayout<'tcx>), - NoPlace(TyLayout<'tcx>), -} - -impl<'a, 'tcx: 'a> CPlace<'tcx> { - pub fn layout(&self) -> TyLayout<'tcx> { - match *self { - CPlace::Var(_, layout) - | CPlace::Addr(_, _, layout) - | CPlace::Stack(_, layout) - | CPlace::NoPlace(layout) => layout, - } - } - - pub fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { - CPlace::NoPlace(layout) - } - - pub fn new_stack_slot( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - ty: Ty<'tcx>, - ) -> CPlace<'tcx> { - let layout = fx.layout_of(ty); - assert!(!layout.is_unsized()); - if layout.size.bytes() == 0 { - return CPlace::NoPlace(layout); - } - - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - CPlace::Stack(stack_slot, layout) - } - - pub fn new_var( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - local: Local, - layout: TyLayout<'tcx>, - ) -> CPlace<'tcx> { - fx.bcx - .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); - CPlace::Var(local, layout) - } - - pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { - match self { - CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(mir_var(var)), layout), - CPlace::Addr(addr, extra, layout) => { - assert!(extra.is_none(), "unsized values are not yet supported"); - CValue::ByRef(addr, layout) - } - CPlace::Stack(stack_slot, layout) => CValue::ByRef( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), - layout, - ), - CPlace::NoPlace(layout) => CValue::ByRef( - fx.bcx - .ins() - .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), - layout, - ), - } - } - - pub fn to_addr(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { - match self.to_addr_maybe_unsized(fx) { - (addr, None) => addr, - (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), - } - } - - pub fn to_addr_maybe_unsized( - self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - ) -> (Value, Option) { - match self { - CPlace::Addr(addr, extra, _layout) => (addr, extra), - CPlace::Stack(stack_slot, _layout) => ( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), - None, - ), - CPlace::NoPlace(_) => (fx.bcx.ins().iconst(fx.pointer_type, 45), None), - CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), - } - } - - pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { - use rustc::hir::Mutability::*; - - let from_ty = from.layout().ty; - let to_ty = self.layout().ty; - - fn assert_assignable<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { - match (&from_ty.sty, &to_ty.sty) { - (ty::Ref(_, t, MutImmutable), ty::Ref(_, u, MutImmutable)) - | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutImmutable)) - | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutMutable)) => { - assert_assignable(fx, t, u); - // &mut T -> &T is allowed - // &'a T -> &'b T is allowed - } - (ty::Ref(_, _, MutImmutable), ty::Ref(_, _, MutMutable)) => { - panic!("Cant assign value of type {} to place of type {}", from_ty, to_ty) - } - (ty::FnPtr(_), ty::FnPtr(_)) => { - let from_sig = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - &from_ty.fn_sig(fx.tcx), - ); - let to_sig = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - &to_ty.fn_sig(fx.tcx), - ); - assert_eq!( - from_sig, to_sig, - "Can't write fn ptr with incompatible sig {:?} to place with sig {:?}\n\n{:#?}", - from_sig, to_sig, fx, - ); - // fn(&T) -> for<'l> fn(&'l T) is allowed - } - (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { - let from_traits = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - from_traits, - ); - let to_traits = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - to_traits, - ); - assert_eq!( - from_traits, to_traits, - "Can't write trait object of incompatible traits {:?} to place with traits {:?}\n\n{:#?}", - from_traits, to_traits, fx, - ); - // dyn for<'r> Trait<'r> -> dyn Trait<'_> is allowed - } - _ => { - assert_eq!( - from_ty, - to_ty, - "Can't write value with incompatible type {:?} to place with type {:?}\n\n{:#?}", - from_ty, - to_ty, - fx, - ); - } - } - } - - assert_assignable(fx, from_ty, to_ty); - - let (addr, dst_layout) = match self { - CPlace::Var(var, _) => { - let data = from.load_scalar(fx); - fx.bcx.def_var(mir_var(var), data); - return; - } - CPlace::Addr(addr, None, dst_layout) => (addr, dst_layout), - CPlace::Stack(stack_slot, dst_layout) => ( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), - dst_layout, - ), - CPlace::NoPlace(layout) => { - assert_eq!(layout.size.bytes(), 0); - assert_eq!(from.layout().size.bytes(), 0); - return; - } - CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), - }; - - match from { - CValue::ByVal(val, _src_layout) => { - fx.bcx.ins().store(MemFlags::new(), val, addr, 0); - } - CValue::ByValPair(val1, val2, _src_layout) => { - let val1_offset = dst_layout.fields.offset(0).bytes() as i32; - let val2_offset = dst_layout.fields.offset(1).bytes() as i32; - fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); - fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); - } - CValue::ByRef(from, src_layout) => { - let size = dst_layout.size.bytes(); - let src_align = src_layout.align.abi.bytes() as u8; - let dst_align = dst_layout.align.abi.bytes() as u8; - fx.bcx.emit_small_memcpy( - fx.module.target_config(), - addr, - from, - size, - dst_align, - src_align, - ); - } - } - } - - pub fn place_field( - self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - field: mir::Field, - ) -> CPlace<'tcx> { - let layout = self.layout(); - let (base, extra) = self.to_addr_maybe_unsized(fx); - - let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); - let extra = if field_layout.is_unsized() { - assert!(extra.is_some()); - extra - } else { - None - }; - CPlace::Addr(field_ptr, extra, field_layout) - } - - pub fn place_index( - self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - index: Value, - ) -> CPlace<'tcx> { - let (elem_layout, addr) = match self.layout().ty.sty { - ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_addr(fx)), - ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_addr_maybe_unsized(fx).0), - _ => bug!("place_index({:?})", self.layout().ty), - }; - - let offset = fx - .bcx - .ins() - .imul_imm(index, elem_layout.size.bytes() as i64); - - CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) - } - - pub fn place_deref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CPlace<'tcx> { - let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); - if !inner_layout.is_unsized() { - CPlace::Addr(self.to_cvalue(fx).load_scalar(fx), None, inner_layout) - } else { - match self.layout().abi { - Abi::ScalarPair(ref a, ref b) => { - let addr = self.to_addr(fx); - let ptr = - fx.bcx - .ins() - .load(scalar_to_clif_type(fx.tcx, a), MemFlags::new(), addr, 0); - let extra = fx.bcx.ins().load( - scalar_to_clif_type(fx.tcx, b), - MemFlags::new(), - addr, - a.value.size(&fx.tcx).bytes() as u32 as i32, - ); - CPlace::Addr(ptr, Some(extra), inner_layout) - } - _ => bug!( - "Fat ptr doesn't have abi ScalarPair, but it has {:?}", - self.layout().abi - ), - } - } - } - - pub fn write_place_ref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - if !self.layout().is_unsized() { - let ptr = CValue::ByVal(self.to_addr(fx), dest.layout()); - dest.write_cvalue(fx, ptr); - } else { - let (value, extra) = self.to_addr_maybe_unsized(fx); - - match dest.layout().abi { - Abi::ScalarPair(ref a, _) => { - let dest_addr = dest.to_addr(fx); - fx.bcx.ins().store(MemFlags::new(), value, dest_addr, 0); - fx.bcx.ins().store( - MemFlags::new(), - extra.expect("unsized type without metadata"), - dest_addr, - a.value.size(&fx.tcx).bytes() as u32 as i32, - ); - } - _ => bug!( - "Non ScalarPair abi {:?} in write_place_ref dest", - dest.layout().abi - ), - } - } - } - - pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { - assert!(!self.layout().is_unsized()); - match self { - CPlace::Var(var, _) => CPlace::Var(var, layout), - CPlace::Addr(addr, extra, _) => CPlace::Addr(addr, extra, layout), - CPlace::Stack(stack_slot, _) => CPlace::Stack(stack_slot, layout), - CPlace::NoPlace(_) => { - assert!(layout.size.bytes() == 0); - CPlace::NoPlace(layout) - } - } - } - - pub fn downcast_variant( - self, - fx: &FunctionCx<'a, 'tcx, impl Backend>, - variant: VariantIdx, - ) -> Self { - let layout = self.layout().for_variant(fx, variant); - self.unchecked_cast_to(layout) - } -} - pub fn clif_intcast<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, val: Value, diff --git a/src/lib.rs b/src/lib.rs index 0d545ebb9af07..a2435312fe1c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,6 +44,7 @@ mod pretty_clif; mod trap; mod unimpl; mod unsize; +mod value_and_place; mod vtable; mod prelude { @@ -93,6 +94,7 @@ mod prelude { pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; + pub use crate::value_and_place::{CValue, CPlace}; pub use crate::{Caches, CodegenCx}; pub struct PrintOnPanic String>(pub F); diff --git a/src/value_and_place.rs b/src/value_and_place.rs new file mode 100644 index 0000000000000..29b370baf8cf7 --- /dev/null +++ b/src/value_and_place.rs @@ -0,0 +1,486 @@ +use crate::prelude::*; + +fn codegen_field<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + base: Value, + layout: TyLayout<'tcx>, + field: mir::Field, +) -> (Value, TyLayout<'tcx>) { + let field_offset = layout.fields.offset(field.index()); + let field_ty = layout.field(&*fx, field.index()); + if field_offset.bytes() > 0 { + ( + fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), + field_ty, + ) + } else { + (base, field_ty) + } +} + +/// A read-only value +#[derive(Debug, Copy, Clone)] +pub enum CValue<'tcx> { + ByRef(Value, TyLayout<'tcx>), + ByVal(Value, TyLayout<'tcx>), + ByValPair(Value, Value, TyLayout<'tcx>), +} + +impl<'tcx> CValue<'tcx> { + pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue::ByRef(value, layout) + } + + pub fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue::ByVal(value, layout) + } + + pub fn by_val_pair(value: Value, extra: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue::ByValPair(value, extra, layout) + } + + pub fn layout(&self) -> TyLayout<'tcx> { + match *self { + CValue::ByRef(_, layout) + | CValue::ByVal(_, layout) + | CValue::ByValPair(_, _, layout) => layout, + } + } + + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value + where + 'tcx: 'a, + { + match self { + CValue::ByRef(value, _layout) => value, + CValue::ByVal(value, layout) => { + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); + fx.bcx.ins().store(MemFlags::new(), value, addr, 0); + addr + } + CValue::ByValPair(value, extra, layout) => { + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + let base = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); + let a_addr = codegen_field(fx, base, layout, mir::Field::new(0)).0; + let b_addr = codegen_field(fx, base, layout, mir::Field::new(1)).0; + fx.bcx.ins().store(MemFlags::new(), value, a_addr, 0); + fx.bcx.ins().store(MemFlags::new(), extra, b_addr, 0); + base + } + } + } + + /// Load a value with layout.abi of scalar + pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value + where + 'tcx: 'a, + { + match self { + CValue::ByRef(addr, layout) => { + let scalar = match layout.abi { + layout::Abi::Scalar(ref scalar) => scalar.clone(), + _ => unreachable!(), + }; + let clif_ty = scalar_to_clif_type(fx.tcx, scalar); + fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) + } + CValue::ByVal(value, _layout) => value, + CValue::ByValPair(_, _, _layout) => bug!("Please use load_scalar_pair for ByValPair"), + } + } + + /// Load a value pair with layout.abi of scalar pair + pub fn load_scalar_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> (Value, Value) + where + 'tcx: 'a, + { + match self { + CValue::ByRef(addr, layout) => { + let (a, b) = match &layout.abi { + layout::Abi::ScalarPair(a, b) => (a.clone(), b.clone()), + _ => unreachable!(), + }; + let clif_ty1 = scalar_to_clif_type(fx.tcx, a.clone()); + let clif_ty2 = scalar_to_clif_type(fx.tcx, b); + let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); + let val2 = fx.bcx.ins().load( + clif_ty2, + MemFlags::new(), + addr, + a.value.size(&fx.tcx).bytes() as i32, + ); + (val1, val2) + } + CValue::ByVal(_, _layout) => bug!("Please use load_scalar for ByVal"), + CValue::ByValPair(val1, val2, _layout) => (val1, val2), + } + } + + pub fn value_field<'a>( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + field: mir::Field, + ) -> CValue<'tcx> + where + 'tcx: 'a, + { + let (base, layout) = match self { + CValue::ByRef(addr, layout) => (addr, layout), + _ => bug!("place_field for {:?}", self), + }; + + let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + CValue::ByRef(field_ptr, field_layout) + } + + pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + crate::unsize::coerce_unsized_into(fx, self, dest); + } + + pub fn const_val<'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ty: Ty<'tcx>, + const_val: i64, + ) -> CValue<'tcx> + where + 'tcx: 'a, + { + let clif_ty = fx.clif_type(ty).unwrap(); + let layout = fx.layout_of(ty); + CValue::ByVal(fx.bcx.ins().iconst(clif_ty, const_val), layout) + } + + pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + match self { + CValue::ByRef(addr, _) => CValue::ByRef(addr, layout), + CValue::ByVal(val, _) => CValue::ByVal(val, layout), + CValue::ByValPair(val, extra, _) => CValue::ByValPair(val, extra, layout), + } + } +} + +/// A place where you can write a value to or read a value from +#[derive(Debug, Copy, Clone)] +pub enum CPlace<'tcx> { + Var(Local, TyLayout<'tcx>), + Addr(Value, Option, TyLayout<'tcx>), + Stack(StackSlot, TyLayout<'tcx>), + NoPlace(TyLayout<'tcx>), +} + +impl<'a, 'tcx: 'a> CPlace<'tcx> { + pub fn layout(&self) -> TyLayout<'tcx> { + match *self { + CPlace::Var(_, layout) + | CPlace::Addr(_, _, layout) + | CPlace::Stack(_, layout) + | CPlace::NoPlace(layout) => layout, + } + } + + pub fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { + CPlace::NoPlace(layout) + } + + pub fn new_stack_slot( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ty: Ty<'tcx>, + ) -> CPlace<'tcx> { + let layout = fx.layout_of(ty); + assert!(!layout.is_unsized()); + if layout.size.bytes() == 0 { + return CPlace::NoPlace(layout); + } + + let stack_slot = fx.bcx.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + size: layout.size.bytes() as u32, + offset: None, + }); + CPlace::Stack(stack_slot, layout) + } + + pub fn new_var( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + local: Local, + layout: TyLayout<'tcx>, + ) -> CPlace<'tcx> { + fx.bcx + .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); + CPlace::Var(local, layout) + } + + pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { + match self { + CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(mir_var(var)), layout), + CPlace::Addr(addr, extra, layout) => { + assert!(extra.is_none(), "unsized values are not yet supported"); + CValue::ByRef(addr, layout) + } + CPlace::Stack(stack_slot, layout) => CValue::ByRef( + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + layout, + ), + CPlace::NoPlace(layout) => CValue::ByRef( + fx.bcx + .ins() + .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), + layout, + ), + } + } + + pub fn to_addr(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { + match self.to_addr_maybe_unsized(fx) { + (addr, None) => addr, + (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), + } + } + + pub fn to_addr_maybe_unsized( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ) -> (Value, Option) { + match self { + CPlace::Addr(addr, extra, _layout) => (addr, extra), + CPlace::Stack(stack_slot, _layout) => ( + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + None, + ), + CPlace::NoPlace(_) => (fx.bcx.ins().iconst(fx.pointer_type, 45), None), + CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), + } + } + + pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { + use rustc::hir::Mutability::*; + + let from_ty = from.layout().ty; + let to_ty = self.layout().ty; + + fn assert_assignable<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { + match (&from_ty.sty, &to_ty.sty) { + (ty::Ref(_, t, MutImmutable), ty::Ref(_, u, MutImmutable)) + | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutImmutable)) + | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutMutable)) => { + assert_assignable(fx, t, u); + // &mut T -> &T is allowed + // &'a T -> &'b T is allowed + } + (ty::Ref(_, _, MutImmutable), ty::Ref(_, _, MutMutable)) => { + panic!("Cant assign value of type {} to place of type {}", from_ty, to_ty) + } + (ty::FnPtr(_), ty::FnPtr(_)) => { + let from_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &from_ty.fn_sig(fx.tcx), + ); + let to_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &to_ty.fn_sig(fx.tcx), + ); + assert_eq!( + from_sig, to_sig, + "Can't write fn ptr with incompatible sig {:?} to place with sig {:?}\n\n{:#?}", + from_sig, to_sig, fx, + ); + // fn(&T) -> for<'l> fn(&'l T) is allowed + } + (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { + let from_traits = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + from_traits, + ); + let to_traits = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + to_traits, + ); + assert_eq!( + from_traits, to_traits, + "Can't write trait object of incompatible traits {:?} to place with traits {:?}\n\n{:#?}", + from_traits, to_traits, fx, + ); + // dyn for<'r> Trait<'r> -> dyn Trait<'_> is allowed + } + _ => { + assert_eq!( + from_ty, + to_ty, + "Can't write value with incompatible type {:?} to place with type {:?}\n\n{:#?}", + from_ty, + to_ty, + fx, + ); + } + } + } + + assert_assignable(fx, from_ty, to_ty); + + let (addr, dst_layout) = match self { + CPlace::Var(var, _) => { + let data = from.load_scalar(fx); + fx.bcx.def_var(mir_var(var), data); + return; + } + CPlace::Addr(addr, None, dst_layout) => (addr, dst_layout), + CPlace::Stack(stack_slot, dst_layout) => ( + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + dst_layout, + ), + CPlace::NoPlace(layout) => { + assert_eq!(layout.size.bytes(), 0); + assert_eq!(from.layout().size.bytes(), 0); + return; + } + CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), + }; + + match from { + CValue::ByVal(val, _src_layout) => { + fx.bcx.ins().store(MemFlags::new(), val, addr, 0); + } + CValue::ByValPair(val1, val2, _src_layout) => { + let val1_offset = dst_layout.fields.offset(0).bytes() as i32; + let val2_offset = dst_layout.fields.offset(1).bytes() as i32; + fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); + fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); + } + CValue::ByRef(from, src_layout) => { + let size = dst_layout.size.bytes(); + let src_align = src_layout.align.abi.bytes() as u8; + let dst_align = dst_layout.align.abi.bytes() as u8; + fx.bcx.emit_small_memcpy( + fx.module.target_config(), + addr, + from, + size, + dst_align, + src_align, + ); + } + } + } + + pub fn place_field( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + field: mir::Field, + ) -> CPlace<'tcx> { + let layout = self.layout(); + let (base, extra) = self.to_addr_maybe_unsized(fx); + + let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + let extra = if field_layout.is_unsized() { + assert!(extra.is_some()); + extra + } else { + None + }; + CPlace::Addr(field_ptr, extra, field_layout) + } + + pub fn place_index( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + index: Value, + ) -> CPlace<'tcx> { + let (elem_layout, addr) = match self.layout().ty.sty { + ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_addr(fx)), + ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_addr_maybe_unsized(fx).0), + _ => bug!("place_index({:?})", self.layout().ty), + }; + + let offset = fx + .bcx + .ins() + .imul_imm(index, elem_layout.size.bytes() as i64); + + CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) + } + + pub fn place_deref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CPlace<'tcx> { + let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); + if !inner_layout.is_unsized() { + CPlace::Addr(self.to_cvalue(fx).load_scalar(fx), None, inner_layout) + } else { + match self.layout().abi { + Abi::ScalarPair(ref a, ref b) => { + let addr = self.to_addr(fx); + let ptr = + fx.bcx + .ins() + .load(scalar_to_clif_type(fx.tcx, a.clone()), MemFlags::new(), addr, 0); + let extra = fx.bcx.ins().load( + scalar_to_clif_type(fx.tcx, b.clone()), + MemFlags::new(), + addr, + a.value.size(&fx.tcx).bytes() as u32 as i32, + ); + CPlace::Addr(ptr, Some(extra), inner_layout) + } + _ => bug!( + "Fat ptr doesn't have abi ScalarPair, but it has {:?}", + self.layout().abi + ), + } + } + } + + pub fn write_place_ref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + if !self.layout().is_unsized() { + let ptr = CValue::ByVal(self.to_addr(fx), dest.layout()); + dest.write_cvalue(fx, ptr); + } else { + let (value, extra) = self.to_addr_maybe_unsized(fx); + + match dest.layout().abi { + Abi::ScalarPair(ref a, _) => { + let dest_addr = dest.to_addr(fx); + fx.bcx.ins().store(MemFlags::new(), value, dest_addr, 0); + fx.bcx.ins().store( + MemFlags::new(), + extra.expect("unsized type without metadata"), + dest_addr, + a.value.size(&fx.tcx).bytes() as u32 as i32, + ); + } + _ => bug!( + "Non ScalarPair abi {:?} in write_place_ref dest", + dest.layout().abi + ), + } + } + } + + pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + assert!(!self.layout().is_unsized()); + match self { + CPlace::Var(var, _) => CPlace::Var(var, layout), + CPlace::Addr(addr, extra, _) => CPlace::Addr(addr, extra, layout), + CPlace::Stack(stack_slot, _) => CPlace::Stack(stack_slot, layout), + CPlace::NoPlace(_) => { + assert!(layout.size.bytes() == 0); + CPlace::NoPlace(layout) + } + } + } + + pub fn downcast_variant( + self, + fx: &FunctionCx<'a, 'tcx, impl Backend>, + variant: VariantIdx, + ) -> Self { + let layout = self.layout().for_variant(fx, variant); + self.unchecked_cast_to(layout) + } +} From 3f04e73b40ba14560edddf21e0a4021d975dc96d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 16:25:07 +0200 Subject: [PATCH 0672/1566] Use CValue::by_val{,_pair} at more places --- src/base.rs | 2 +- src/intrinsics.rs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/base.rs b/src/base.rs index 628f89675b8b2..40e6b3ca172ff 100644 --- a/src/base.rs +++ b/src/base.rs @@ -963,7 +963,7 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( let out_place = CPlace::new_stack_slot(fx, out_ty); let out_layout = out_place.layout(); - out_place.write_cvalue(fx, CValue::ByValPair(res, has_overflow, out_layout)); + out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); out_place.to_cvalue(fx) } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 8900e5f275604..01992814b0717 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -65,7 +65,7 @@ macro_rules! atomic_binop_return_old { let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); let new = $fx.bcx.ins().$op(old, $src); $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); - $ret.write_cvalue($fx, CValue::ByVal(old, $fx.layout_of($T))); + $ret.write_cvalue($fx, CValue::by_val(old, $fx.layout_of($T))); }; } @@ -82,7 +82,7 @@ macro_rules! atomic_minmax { // Write new $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); - let ret_val = CValue::ByVal(old, $ret.layout()); + let ret_val = CValue::by_val(old, $ret.layout()); $ret.write_cvalue($fx, ret_val); }; } @@ -165,7 +165,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( .ins() .iconst(fx.pointer_type, layout.size.bytes() as i64) }; - ret.write_cvalue(fx, CValue::ByVal(size, usize_layout)); + ret.write_cvalue(fx, CValue::by_val(size, usize_layout)); }; min_align_of, () { let min_align = fx.layout_of(T).align.abi.bytes(); @@ -184,7 +184,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( .ins() .iconst(fx.pointer_type, layout.align.abi.bytes() as i64) }; - ret.write_cvalue(fx, CValue::ByVal(align, usize_layout)); + ret.write_cvalue(fx, CValue::by_val(align, usize_layout)); }; type_id, () { let type_id = fx.tcx.type_id_hash(T); @@ -312,12 +312,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( rotate_left, (v x, v y) { let layout = fx.layout_of(T); let res = fx.bcx.ins().rotl(x, y); - ret.write_cvalue(fx, CValue::ByVal(res, layout)); + ret.write_cvalue(fx, CValue::by_val(res, layout)); }; rotate_right, (v x, v y) { let layout = fx.layout_of(T); let res = fx.bcx.ins().rotr(x, y); - ret.write_cvalue(fx, CValue::ByVal(res, layout)); + ret.write_cvalue(fx, CValue::by_val(res, layout)); }; // The only difference between offset and arith_offset is regarding UB. Because Cranelift @@ -328,7 +328,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); let base_val = base.load_scalar(fx); let res = fx.bcx.ins().iadd(base_val, ptr_diff); - ret.write_cvalue(fx, CValue::ByVal(res, args[0].layout())); + ret.write_cvalue(fx, CValue::by_val(res, args[0].layout())); }; transmute, (c from) { @@ -386,19 +386,19 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, uninit_val); }; ctlz | ctlz_nonzero, (v arg) { - let res = CValue::ByVal(fx.bcx.ins().clz(arg), fx.layout_of(T)); + let res = CValue::by_val(fx.bcx.ins().clz(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; cttz | cttz_nonzero, (v arg) { - let res = CValue::ByVal(fx.bcx.ins().ctz(arg), fx.layout_of(T)); + let res = CValue::by_val(fx.bcx.ins().ctz(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; ctpop, (v arg) { - let res = CValue::ByVal(fx.bcx.ins().popcnt(arg), fx.layout_of(T)); + let res = CValue::by_val(fx.bcx.ins().popcnt(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; bitreverse, (v arg) { - let res = CValue::ByVal(fx.bcx.ins().bitrev(arg), fx.layout_of(T)); + let res = CValue::by_val(fx.bcx.ins().bitrev(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; needs_drop, () { @@ -433,7 +433,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // Read old let clif_ty = fx.clif_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); - ret.write_cvalue(fx, CValue::ByVal(old, fx.layout_of(T))); + ret.write_cvalue(fx, CValue::by_val(old, fx.layout_of(T))); // Write new let dest = CPlace::Addr(ptr, None, src.layout()); From 089e75ec420912d0381c885a6fbe8137a910e617 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 16:30:47 +0200 Subject: [PATCH 0673/1566] Encapsulate CPlace constructors --- src/abi.rs | 4 ++-- src/base.rs | 9 ++++----- src/constant.rs | 2 +- src/intrinsics.rs | 6 +++--- src/trap.rs | 2 +- src/value_and_place.rs | 8 ++++++++ 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index cad6fe3285e8d..7bb3b1b56b910 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -330,7 +330,7 @@ fn local_place<'a, 'tcx: 'a>( } // Take stack_addr in advance to avoid many duplicate instructions - CPlace::Addr(place.to_addr(fx), None, layout) + CPlace::for_addr(place.to_addr(fx), layout) }; let prev_place = fx.local_map.insert(local, place); @@ -471,7 +471,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( PassMode::ByRef => { fx.local_map.insert( RETURN_PLACE, - CPlace::Addr(ret_param.unwrap(), None, ret_layout), + CPlace::for_addr(ret_param.unwrap(), ret_layout), ); } } diff --git a/src/base.rs b/src/base.rs index 40e6b3ca172ff..a96110e7bd5d5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -538,7 +538,7 @@ fn trans_stmt<'a, 'tcx: 'a>( // FIXME avoid forcing to stack let place = - CPlace::Addr(operand.force_stack(fx), None, operand.layout()); + CPlace::for_addr(operand.force_stack(fx), operand.layout()); let discr = trans_get_discriminant(fx, place, fx.layout_of(to_ty)); lval.write_cvalue(fx, discr); } else { @@ -1162,9 +1162,8 @@ pub fn trans_place<'a, 'tcx: 'a>( let elem_layout = fx.layout_of(elem_ty); let ptr = base.to_addr(fx); let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx); - CPlace::Addr( + CPlace::for_addr( fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), - None, fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), ) } @@ -1172,9 +1171,9 @@ pub fn trans_place<'a, 'tcx: 'a>( let elem_layout = fx.layout_of(elem_ty); let (ptr, len) = base.to_addr_maybe_unsized(fx); let len = len.unwrap(); - CPlace::Addr( + CPlace::for_addr_with_extra( fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), - Some(fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64))), + fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), base.layout(), ) } diff --git a/src/constant.rs b/src/constant.rs index 31f95cda1e3ff..0403f8d0d1bac 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -234,7 +234,7 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); assert!(!layout.is_unsized(), "unsized statics aren't supported"); - CPlace::Addr(global_ptr, None, layout) + CPlace::for_addr(global_ptr, layout) } fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 01992814b0717..00d7cad85bbc9 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -144,7 +144,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; discriminant_value, (c val) { let pointee_layout = fx.layout_of(val.layout().ty.builtin_deref(true).unwrap().ty); - let place = CPlace::Addr(val.load_scalar(fx), None, pointee_layout); + let place = CPlace::for_addr(val.load_scalar(fx), pointee_layout); let discr = crate::base::trans_get_discriminant(fx, place, ret.layout()); ret.write_cvalue(fx, discr); }; @@ -426,7 +426,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, val); }; _ if intrinsic.starts_with("atomic_store"), (v ptr, c val) { - let dest = CPlace::Addr(ptr, None, val.layout()); + let dest = CPlace::for_addr(ptr, val.layout()); dest.write_cvalue(fx, val); }; _ if intrinsic.starts_with("atomic_xchg"), (v ptr, c src) { @@ -436,7 +436,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, CValue::by_val(old, fx.layout_of(T))); // Write new - let dest = CPlace::Addr(ptr, None, src.layout()); + let dest = CPlace::for_addr(ptr, src.layout()); dest.write_cvalue(fx, src); }; _ if intrinsic.starts_with("atomic_cxchg"), (v ptr, v test_old, v new) { // both atomic_cxchg_* and atomic_cxchgweak_* diff --git a/src/trap.rs b/src/trap.rs index a597e18e19ecc..c0464e18e4e4e 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -49,5 +49,5 @@ pub fn trap_unreachable_ret_place<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl crane let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); - CPlace::Addr(zero, None, dest_layout) + CPlace::for_addr(zero, dest_layout) } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 29b370baf8cf7..01975660072c3 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -219,6 +219,14 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Var(local, layout) } + pub fn for_addr(addr: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + CPlace::Addr(addr, None, layout) + } + + pub fn for_addr_with_extra(addr: Value, extra: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + CPlace::Addr(addr, Some(extra), layout) + } + pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { match self { CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(mir_var(var)), layout), From 8fb70f259f133c832aac003e83f0f77f89bbb8f7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 16:41:40 +0200 Subject: [PATCH 0674/1566] Move layout out of the enum for CValue --- src/value_and_place.rs | 86 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 01975660072c3..3c83220b0250d 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -20,40 +20,40 @@ fn codegen_field<'a, 'tcx: 'a>( /// A read-only value #[derive(Debug, Copy, Clone)] -pub enum CValue<'tcx> { - ByRef(Value, TyLayout<'tcx>), - ByVal(Value, TyLayout<'tcx>), - ByValPair(Value, Value, TyLayout<'tcx>), +pub struct CValue<'tcx>(CValueInner, TyLayout<'tcx>); + +#[derive(Debug, Copy, Clone)] +enum CValueInner { + ByRef(Value), + ByVal(Value), + ByValPair(Value, Value), } impl<'tcx> CValue<'tcx> { pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue::ByRef(value, layout) + CValue(CValueInner::ByRef(value), layout) } pub fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue::ByVal(value, layout) + CValue(CValueInner::ByVal(value), layout) } pub fn by_val_pair(value: Value, extra: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue::ByValPair(value, extra, layout) + CValue(CValueInner::ByValPair(value, extra), layout) } pub fn layout(&self) -> TyLayout<'tcx> { - match *self { - CValue::ByRef(_, layout) - | CValue::ByVal(_, layout) - | CValue::ByValPair(_, _, layout) => layout, - } + self.1 } pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value where 'tcx: 'a, { - match self { - CValue::ByRef(value, _layout) => value, - CValue::ByVal(value, layout) => { + let layout = self.1; + match self.0 { + CValueInner::ByRef(value) => value, + CValueInner::ByVal(value) => { let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -63,7 +63,7 @@ impl<'tcx> CValue<'tcx> { fx.bcx.ins().store(MemFlags::new(), value, addr, 0); addr } - CValue::ByValPair(value, extra, layout) => { + CValueInner::ByValPair(value, extra) => { let stack_slot = fx.bcx.create_stack_slot(StackSlotData { kind: StackSlotKind::ExplicitSlot, size: layout.size.bytes() as u32, @@ -84,8 +84,9 @@ impl<'tcx> CValue<'tcx> { where 'tcx: 'a, { - match self { - CValue::ByRef(addr, layout) => { + let layout = self.1; + match self.0 { + CValueInner::ByRef(addr) => { let scalar = match layout.abi { layout::Abi::Scalar(ref scalar) => scalar.clone(), _ => unreachable!(), @@ -93,8 +94,8 @@ impl<'tcx> CValue<'tcx> { let clif_ty = scalar_to_clif_type(fx.tcx, scalar); fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) } - CValue::ByVal(value, _layout) => value, - CValue::ByValPair(_, _, _layout) => bug!("Please use load_scalar_pair for ByValPair"), + CValueInner::ByVal(value) => value, + CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), } } @@ -103,8 +104,9 @@ impl<'tcx> CValue<'tcx> { where 'tcx: 'a, { - match self { - CValue::ByRef(addr, layout) => { + let layout = self.1; + match self.0 { + CValueInner::ByRef(addr) => { let (a, b) = match &layout.abi { layout::Abi::ScalarPair(a, b) => (a.clone(), b.clone()), _ => unreachable!(), @@ -120,8 +122,8 @@ impl<'tcx> CValue<'tcx> { ); (val1, val2) } - CValue::ByVal(_, _layout) => bug!("Please use load_scalar for ByVal"), - CValue::ByValPair(val1, val2, _layout) => (val1, val2), + CValueInner::ByVal(_) => bug!("Please use load_scalar for ByVal"), + CValueInner::ByValPair(val1, val2) => (val1, val2), } } @@ -133,13 +135,14 @@ impl<'tcx> CValue<'tcx> { where 'tcx: 'a, { - let (base, layout) = match self { - CValue::ByRef(addr, layout) => (addr, layout), + let layout = self.1; + let base = match self.0 { + CValueInner::ByRef(addr) => addr, _ => bug!("place_field for {:?}", self), }; let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); - CValue::ByRef(field_ptr, field_layout) + CValue::by_ref(field_ptr, field_layout) } pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { @@ -156,15 +159,11 @@ impl<'tcx> CValue<'tcx> { { let clif_ty = fx.clif_type(ty).unwrap(); let layout = fx.layout_of(ty); - CValue::ByVal(fx.bcx.ins().iconst(clif_ty, const_val), layout) + CValue::by_val(fx.bcx.ins().iconst(clif_ty, const_val), layout) } pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { - match self { - CValue::ByRef(addr, _) => CValue::ByRef(addr, layout), - CValue::ByVal(val, _) => CValue::ByVal(val, layout), - CValue::ByValPair(val, extra, _) => CValue::ByValPair(val, extra, layout), - } + CValue(self.0, layout) } } @@ -229,16 +228,16 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { match self { - CPlace::Var(var, layout) => CValue::ByVal(fx.bcx.use_var(mir_var(var)), layout), + CPlace::Var(var, layout) => CValue::by_val(fx.bcx.use_var(mir_var(var)), layout), CPlace::Addr(addr, extra, layout) => { assert!(extra.is_none(), "unsized values are not yet supported"); - CValue::ByRef(addr, layout) + CValue::by_ref(addr, layout) } - CPlace::Stack(stack_slot, layout) => CValue::ByRef( + CPlace::Stack(stack_slot, layout) => CValue::by_ref( fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), layout, ), - CPlace::NoPlace(layout) => CValue::ByRef( + CPlace::NoPlace(layout) => CValue::by_ref( fx.bcx .ins() .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), @@ -353,24 +352,25 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), }; - match from { - CValue::ByVal(val, _src_layout) => { + match from.0 { + CValueInner::ByVal(val) => { fx.bcx.ins().store(MemFlags::new(), val, addr, 0); } - CValue::ByValPair(val1, val2, _src_layout) => { + CValueInner::ByValPair(val1, val2) => { let val1_offset = dst_layout.fields.offset(0).bytes() as i32; let val2_offset = dst_layout.fields.offset(1).bytes() as i32; fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); } - CValue::ByRef(from, src_layout) => { + CValueInner::ByRef(from_addr) => { + let src_layout = from.1; let size = dst_layout.size.bytes(); let src_align = src_layout.align.abi.bytes() as u8; let dst_align = dst_layout.align.abi.bytes() as u8; fx.bcx.emit_small_memcpy( fx.module.target_config(), addr, - from, + from_addr, size, dst_align, src_align, @@ -446,7 +446,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn write_place_ref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if !self.layout().is_unsized() { - let ptr = CValue::ByVal(self.to_addr(fx), dest.layout()); + let ptr = CValue::by_val(self.to_addr(fx), dest.layout()); dest.write_cvalue(fx, ptr); } else { let (value, extra) = self.to_addr_maybe_unsized(fx); From e8c50cf2c2d1716fad0397ded02ac58f42ec9172 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Mar 2019 19:24:42 +0100 Subject: [PATCH 0675/1566] Read and write dylib metadata --- Cargo.lock | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/driver.rs | 37 +++++++++++++--- src/lib.rs | 1 + src/metadata.rs | 71 +++++++++++++++++++++++++++--- test.sh | 2 +- 6 files changed, 210 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58d253edcc854..939741d72ea52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,10 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "aho-corasick" version = "0.7.3" @@ -73,6 +78,11 @@ name = "bitflags" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "build_const" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "byteorder" version = "1.3.2" @@ -213,6 +223,22 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "env_logger" version = "0.6.1" @@ -286,6 +312,17 @@ name = "fallible-iterator" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "flate2" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fuchsia-cprng" version = "0.1.1" @@ -308,6 +345,16 @@ dependencies = [ "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "goblin" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "goblin" version = "0.0.21" @@ -375,6 +422,34 @@ name = "memchr" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "miniz-sys" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miniz_oxide_c_api" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nodrop" version = "0.1.13" @@ -385,6 +460,26 @@ name = "numtoa" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "object" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.35.7 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parity-wasm" +version = "0.35.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "plain" version = "0.2.3" @@ -597,6 +692,7 @@ dependencies = [ "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -803,6 +899,11 @@ name = "utf8-ranges" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "vec_map" version = "0.8.1" @@ -845,6 +946,7 @@ dependencies = [ ] [metadata] +"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" @@ -854,6 +956,7 @@ dependencies = [ "checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" +"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" @@ -869,6 +972,8 @@ dependencies = [ "checksum cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" @@ -876,9 +981,11 @@ dependencies = [ "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +"checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" +"checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" @@ -889,8 +996,13 @@ dependencies = [ "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" +"checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649" +"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" +"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" +"checksum object 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e7934267669d9b8637926ed243df1b917b40e43dd070aea2a178296e6ed1b72" +"checksum parity-wasm 0.35.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3e1e076c4e01399b6cd0793a8df42f90bba3ae424671ef421d1608a943155d93" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" @@ -940,6 +1052,7 @@ dependencies = [ "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" +"checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" diff --git a/Cargo.toml b/Cargo.toml index b60411311b14e..31897eaeac601 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ libc = "0.2.53" tempfile = "3.0.7" gimli = { git = "https://github.com/gimli-rs/gimli.git" } indexmap = "1.0.2" +object = "0.11.0" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] diff --git a/src/driver.rs b/src/driver.rs index c975f77550f4b..a9cf054e039ae 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -166,6 +166,35 @@ fn run_aot<'a, 'tcx: 'a>( rustc_incremental::save_dep_graph(tcx); rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); + let metadata_module = { + use rustc::mir::mono::CodegenUnitNameBuilder; + + let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); + let metadata_cgu_name = cgu_name_builder + .build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")) + .as_str() + .to_string(); + + let mut metadata_artifact = + faerie::Artifact::new(crate::build_isa(tcx.sess).triple().clone(), metadata_cgu_name.clone()); + crate::metadata::write_metadata(tcx, &mut metadata_artifact); + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Metadata, Some(&metadata_cgu_name)); + + let obj = metadata_artifact.emit().unwrap(); + std::fs::write(&tmp_file, obj).unwrap(); + + CompiledModule { + name: metadata_cgu_name, + kind: ModuleKind::Metadata, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + } + }; + Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module( @@ -184,13 +213,7 @@ fn run_aot<'a, 'tcx: 'a>( } else { None }, - metadata_module: Some(CompiledModule { - name: "dummy_metadata".to_string(), - kind: ModuleKind::Metadata, - object: None, - bytecode: None, - bytecode_compressed: None, - }), + metadata_module: Some(metadata_module), crate_hash: tcx.crate_hash(LOCAL_CRATE), metadata, windows_subsystem: None, // Windows is not yet supported diff --git a/src/lib.rs b/src/lib.rs index a2435312fe1c8..be46d638b1097 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ #![feature(rustc_private, never_type, decl_macro)] #![allow(intra_doc_link_resolution_failure)] +extern crate flate2; extern crate rustc; extern crate rustc_allocator; extern crate rustc_codegen_ssa; diff --git a/src/metadata.rs b/src/metadata.rs index d7fd026dfaf0f..1cc33df9e9b6b 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,16 +1,20 @@ -use rustc::middle::cstore::MetadataLoader; +use std::fs::File; +use std::path::Path; + +use rustc::session::config; +use rustc::ty::TyCtxt; +use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc_codegen_ssa::METADATA_FILENAME; use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::rustc_erase_owner; -use std::fs::File; -use std::path::Path; +use rustc_target::spec::Target; pub struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { fn get_rlib_metadata( &self, - _target: &crate::rustc_target::spec::Target, + _target: &Target, path: &Path, ) -> Result, String> { let mut archive = ar::Archive::new(File::open(path).map_err(|e| format!("{:?}", e))?); @@ -31,9 +35,62 @@ impl MetadataLoader for CraneliftMetadataLoader { fn get_dylib_metadata( &self, - _target: &crate::rustc_target::spec::Target, - _path: &Path, + _target: &Target, + path: &Path, ) -> Result, String> { - Err("dylib metadata loading is not yet supported".to_string()) + use object::Object; + let file = std::fs::read(path).map_err(|e| format!("read:{:?}", e))?; + let file = object::File::parse(&file).map_err(|e| format!("parse: {:?}", e))?; + let buf = file.section_data_by_name(".rustc").ok_or("no .rustc section")?.into_owned(); + let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); + Ok(rustc_erase_owner!(buf.map_owner_box())) } } + +// Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 +pub fn write_metadata<'a, 'gcx>( + tcx: TyCtxt<'a, 'gcx, 'gcx>, + artifact: &mut faerie::Artifact +) -> EncodedMetadata { + use std::io::Write; + use flate2::Compression; + use flate2::write::DeflateEncoder; + + #[derive(PartialEq, Eq, PartialOrd, Ord)] + enum MetadataKind { + None, + Uncompressed, + Compressed + } + + let kind = tcx.sess.crate_types.borrow().iter().map(|ty| { + match *ty { + config::CrateType::Executable | + config::CrateType::Staticlib | + config::CrateType::Cdylib => MetadataKind::None, + + config::CrateType::Rlib => MetadataKind::Uncompressed, + + config::CrateType::Dylib | + config::CrateType::ProcMacro => MetadataKind::Compressed, + } + }).max().unwrap_or(MetadataKind::None); + + if kind == MetadataKind::None { + return EncodedMetadata::new(); + } + + let metadata = tcx.encode_metadata(); + if kind == MetadataKind::Uncompressed { + return metadata; + } + + assert!(kind == MetadataKind::Compressed); + let mut compressed = tcx.metadata_encoding_version(); + DeflateEncoder::new(&mut compressed, Compression::fast()) + .write_all(&metadata.raw_data).unwrap(); + + artifact.declare_with(".rustc", faerie::Decl::debug_section(), compressed).unwrap(); + + metadata +} diff --git a/test.sh b/test.sh index 6be002a9c03d9..1dfbf9247546c 100755 --- a/test.sh +++ b/test.sh @@ -5,7 +5,7 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib From 8dae241368caa365df4321d0af6c3f1d760a4a5a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Mar 2019 20:54:44 +0100 Subject: [PATCH 0676/1566] [WIP] Use correct segment for metadata section --- Cargo.lock | 8 ++++---- Cargo.toml | 3 +++ src/debuginfo.rs | 2 +- src/metadata.rs | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 939741d72ea52..613f5a73a2f4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,7 +171,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9 dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.10.0 (git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -273,7 +273,7 @@ dependencies = [ [[package]] name = "faerie" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636#dcb671a99faa32b72fac88d2406e952a41844636" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -688,7 +688,7 @@ dependencies = [ "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.10.0 (git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -977,7 +977,7 @@ dependencies = [ "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c6d75e6376216d6228fbab8025087523666623d9302ff17dd023d024bf98302" +"checksum faerie 0.10.0 (git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636)" = "" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" diff --git a/Cargo.toml b/Cargo.toml index 31897eaeac601..164e6503a3387 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,5 +40,8 @@ object = "0.11.0" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } +[patch.crates-io] +faerie = { git = "https://github.com/m4b/faerie.git", rev = "dcb671a99faa32b72fac88d2406e952a41844636" } + [profile.dev.overrides."*"] opt-level = 3 diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 3afdaf8d926b9..0e98468070211 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -191,7 +191,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { artifact - .declare_with(id.name(), Decl::debug_section(), section.writer.take()) + .declare_with(id.name(), Decl::section(SectionKind::Debug), section.writer.take()) .unwrap(); } Ok(()) diff --git a/src/metadata.rs b/src/metadata.rs index 1cc33df9e9b6b..23cf7a6927d91 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -90,7 +90,7 @@ pub fn write_metadata<'a, 'gcx>( DeflateEncoder::new(&mut compressed, Compression::fast()) .write_all(&metadata.raw_data).unwrap(); - artifact.declare_with(".rustc", faerie::Decl::debug_section(), compressed).unwrap(); + artifact.declare_with(".rustc", faerie::Decl::section(faerie::SectionKind::Data), compressed).unwrap(); metadata } From 1bea823069d5a56e560500e25f2f2d0a0cd23ece Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 29 Mar 2019 19:25:14 +0100 Subject: [PATCH 0677/1566] [DEBUG] Add objdump invocation --- test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test.sh b/test.sh index 1dfbf9247546c..602cdc50b2ebd 100755 --- a/test.sh +++ b/test.sh @@ -7,6 +7,8 @@ mkdir -p target/out/clif echo "[BUILD] mini_core" $RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib +objdump -section-headers target/out/libmini_core.dylib + echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib From 805e270910f892780b06f36f6c4a8bfd29474876 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 4 Apr 2019 20:42:50 +0200 Subject: [PATCH 0678/1566] [WIP] --- ar_test.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ar_test.rs diff --git a/ar_test.rs b/ar_test.rs new file mode 100644 index 0000000000000..567b2f04d2a07 --- /dev/null +++ b/ar_test.rs @@ -0,0 +1,45 @@ +//! ```cargo +//! [dependencies] +//! ar = "0.6.2" +//! ``` + +use std::io::Read; + +// 64 gives Invalid file size field in entry header +// 32 gives unexpected EOF in the middle of archive entry header +const METADATA_LEN: usize = 64; + +fn main() { + let mut builder = ar::Builder::new(std::fs::File::create("test.a").expect("create")); + + // Remove this append and there is no problem. + let header = ar::Header::new(b"core-fc675.rcgu.o".to_vec(), 0); + // Remove any of the characters in the filename and ! from will show up in the error message. + // Making it shorter than 17 chars will fix the problem though. + + builder.append(&header, &mut (&[] as &[u8])).expect("add rcgu"); + + let mut buf: Vec = vec!['!' as u8; 28]; + buf.extend(b"hello worl"); + buf.extend(&['*' as u8; 26] as &[u8]); + assert!(buf.len() >= METADATA_LEN); + + let header = ar::Header::new(b"rust.metadata.bin".to_vec(), METADATA_LEN as u64); + builder.append(&header, &mut (&buf[0..METADATA_LEN])).expect("add meta"); + + std::mem::drop(builder); + + // Remove this ranlib invocation and there is no problem. + /*assert!( + std::process::Command::new("ranlib") + .arg("test.a") + .status() + .expect("Couldn't run ranlib") + .success() + );*/ + + let mut archive = ar::Archive::new(std::fs::File::open("test.a").expect("open")); + while let Some(entry) = archive.next_entry() { + entry.unwrap(); + } +} From 847a37fedc5463bdae4e5bcc2eb2bbcf08c196a6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 15:26:26 +0200 Subject: [PATCH 0679/1566] Only write metadata module when necessary --- src/driver.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index a9cf054e039ae..391154f80c1cd 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -98,7 +98,7 @@ fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option) -> fn run_aot<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, metadata: EncodedMetadata, - _need_metadata_module: bool, + need_metadata_module: bool, log: &mut Option, ) -> Box { let new_module = |name: String| { @@ -166,7 +166,7 @@ fn run_aot<'a, 'tcx: 'a>( rustc_incremental::save_dep_graph(tcx); rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); - let metadata_module = { + let metadata_module = if need_metadata_module { use rustc::mir::mono::CodegenUnitNameBuilder; let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); @@ -186,13 +186,15 @@ fn run_aot<'a, 'tcx: 'a>( let obj = metadata_artifact.emit().unwrap(); std::fs::write(&tmp_file, obj).unwrap(); - CompiledModule { + Some(CompiledModule { name: metadata_cgu_name, kind: ModuleKind::Metadata, object: Some(tmp_file), bytecode: None, bytecode_compressed: None, - } + }) + } else { + None }; Box::new(CodegenResults { @@ -213,7 +215,7 @@ fn run_aot<'a, 'tcx: 'a>( } else { None }, - metadata_module: Some(metadata_module), + metadata_module, crate_hash: tcx.crate_hash(LOCAL_CRATE), metadata, windows_subsystem: None, // Windows is not yet supported From 4ade7463332ddd5b30872cb824d738112f197b61 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 26 May 2019 10:02:32 +0200 Subject: [PATCH 0680/1566] [WIP] Add section symbol for mach-O --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 613f5a73a2f4c..2e105bb2f5bdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,7 +171,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9 dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636)", + "faerie 0.10.0 (git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -273,7 +273,7 @@ dependencies = [ [[package]] name = "faerie" version = "0.10.0" -source = "git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636#dcb671a99faa32b72fac88d2406e952a41844636" +source = "git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols#c08282ee1296abda4f815d5ef8582fc7785b0b3b" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -688,7 +688,7 @@ dependencies = [ "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636)", + "faerie 0.10.0 (git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -977,7 +977,7 @@ dependencies = [ "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.10.0 (git+https://github.com/m4b/faerie.git?rev=dcb671a99faa32b72fac88d2406e952a41844636)" = "" +"checksum faerie 0.10.0 (git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols)" = "" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" diff --git a/Cargo.toml b/Cargo.toml index 164e6503a3387..9f8e302c73e7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ object = "0.11.0" cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } [patch.crates-io] -faerie = { git = "https://github.com/m4b/faerie.git", rev = "dcb671a99faa32b72fac88d2406e952a41844636" } +faerie = { git = "https://github.com/bjorn3/faerie.git", branch = "macho_section_symbols" } [profile.dev.overrides."*"] opt-level = 3 From 893945bd717659bdd3ad2de601b87c49851d80e2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 31 May 2019 12:35:04 +0200 Subject: [PATCH 0681/1566] Update for faerie section symbols --- config.sh | 2 +- src/metadata.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config.sh b/config.sh index 5dca77855d7f0..7fbd41128895d 100644 --- a/config.sh +++ b/config.sh @@ -20,4 +20,4 @@ fi export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" -export RUST_LOG=warn # display metadata load errors +export RUSTC_LOG=warn # display metadata load errors diff --git a/src/metadata.rs b/src/metadata.rs index 23cf7a6927d91..8abf0dcc108dd 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -90,7 +90,12 @@ pub fn write_metadata<'a, 'gcx>( DeflateEncoder::new(&mut compressed, Compression::fast()) .write_all(&metadata.raw_data).unwrap(); - artifact.declare_with(".rustc", faerie::Decl::section(faerie::SectionKind::Data), compressed).unwrap(); + artifact.declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)).unwrap(); + artifact.define_with_symbols(".rustc", compressed, { + let mut map = std::collections::BTreeMap::new(); + map.insert(rustc::middle::exported_symbols::metadata_symbol_name(tcx), 0); + map + }).unwrap(); metadata } From aa48c1482a75b12d25d156d732d8333312a6801f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Jun 2019 11:42:31 +0200 Subject: [PATCH 0682/1566] [WIP] --- Cargo.lock | 26 +++++++++++--------------- Cargo.toml | 5 +++-- test.sh | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e105bb2f5bdd..dd3ef80c1505b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,7 +171,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9 dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols)", + "faerie 0.10.0", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -273,7 +273,6 @@ dependencies = [ [[package]] name = "faerie" version = "0.10.0" -source = "git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols#c08282ee1296abda4f815d5ef8582fc7785b0b3b" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -347,7 +346,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.0.19" +version = "0.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -357,7 +356,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.0.21" +version = "0.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -462,19 +461,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.12.0" dependencies = [ "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-wasm 0.35.7 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-wasm" -version = "0.35.7" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -688,11 +686,11 @@ dependencies = [ "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols)", + "faerie 0.10.0", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.12.0", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -977,7 +975,6 @@ dependencies = [ "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.10.0 (git+https://github.com/bjorn3/faerie.git?branch=macho_section_symbols)" = "" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" @@ -985,8 +982,8 @@ dependencies = [ "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" -"checksum goblin 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "c65cd533b33e3d04c6e393225fa8919ddfcf5862ca8919c7f9a167c312ef41c2" "checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9" +"checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" @@ -1001,8 +998,7 @@ dependencies = [ "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" -"checksum object 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e7934267669d9b8637926ed243df1b917b40e43dd070aea2a178296e6ed1b72" -"checksum parity-wasm 0.35.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3e1e076c4e01399b6cd0793a8df42f90bba3ae424671ef421d1608a943155d93" +"checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" diff --git a/Cargo.toml b/Cargo.toml index 9f8e302c73e7f..1b505f7e6b88d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ libc = "0.2.53" tempfile = "3.0.7" gimli = { git = "https://github.com/gimli-rs/gimli.git" } indexmap = "1.0.2" -object = "0.11.0" +object = "0.12.0" # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] @@ -41,7 +41,8 @@ object = "0.11.0" cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } [patch.crates-io] -faerie = { git = "https://github.com/bjorn3/faerie.git", branch = "macho_section_symbols" } +faerie = { path = "../faerie" } +object = { path = "../object" } [profile.dev.overrides."*"] opt-level = 3 diff --git a/test.sh b/test.sh index 602cdc50b2ebd..6573bdda6f3a1 100755 --- a/test.sh +++ b/test.sh @@ -5,7 +5,7 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib -Csave-temps objdump -section-headers target/out/libmini_core.dylib From 07bb89a02d37e2158023ebf4e23799e54c7c4f31 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 16:57:59 +0200 Subject: [PATCH 0683/1566] Fix it --- Cargo.lock | 20 +++++++++++--------- Cargo.toml | 4 ++-- src/metadata.rs | 7 ++++++- test.sh | 2 -- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd3ef80c1505b..ecd803172bc77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,7 +171,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9 dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0", + "faerie 0.10.0 (git+https://github.com/m4b/faerie.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -273,6 +273,7 @@ dependencies = [ [[package]] name = "faerie" version = "0.10.0" +source = "git+https://github.com/m4b/faerie.git#f6ce890950950d9ee85b7cb5de5fff9c9291f194" dependencies = [ "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -357,7 +358,7 @@ dependencies = [ [[package]] name = "goblin" version = "0.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b#f34cf128fb4d1f3c93e5cf129cf673c9d787217b" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -462,11 +463,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" version = "0.12.0" +source = "git+https://github.com/gimli-rs/object.git#aced06a20eb59867c88e23c03e15613ffd582618" dependencies = [ "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b)", "parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -474,9 +477,6 @@ dependencies = [ name = "parity-wasm" version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "plain" @@ -686,11 +686,11 @@ dependencies = [ "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0", + "faerie 0.10.0 (git+https://github.com/m4b/faerie.git)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.12.0", + "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -975,6 +975,7 @@ dependencies = [ "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +"checksum faerie 0.10.0 (git+https://github.com/m4b/faerie.git)" = "" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" @@ -983,7 +984,7 @@ dependencies = [ "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9" -"checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" +"checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b)" = "" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" @@ -998,6 +999,7 @@ dependencies = [ "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" +"checksum object 0.12.0 (git+https://github.com/gimli-rs/object.git)" = "" "checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" diff --git a/Cargo.toml b/Cargo.toml index 1b505f7e6b88d..59d66d07fa953 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,8 +41,8 @@ object = "0.12.0" cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } [patch.crates-io] -faerie = { path = "../faerie" } -object = { path = "../object" } +faerie = { git = "https://github.com/m4b/faerie.git" } +object = { git = "https://github.com/gimli-rs/object.git" } [profile.dev.overrides."*"] opt-level = 3 diff --git a/src/metadata.rs b/src/metadata.rs index 8abf0dcc108dd..56ce208a71aa3 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -93,7 +93,12 @@ pub fn write_metadata<'a, 'gcx>( artifact.declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)).unwrap(); artifact.define_with_symbols(".rustc", compressed, { let mut map = std::collections::BTreeMap::new(); - map.insert(rustc::middle::exported_symbols::metadata_symbol_name(tcx), 0); + // FIXME implement faerie elf backend section custom symbols + // For MachO this is necessary to prevent the linker from throwing away the .rustc section, + // but for ELF it isn't. + if tcx.sess.target.target.options.is_like_osx { + map.insert(rustc::middle::exported_symbols::metadata_symbol_name(tcx), 0); + } map }).unwrap(); diff --git a/test.sh b/test.sh index 6573bdda6f3a1..20f4a6bd1f429 100755 --- a/test.sh +++ b/test.sh @@ -7,8 +7,6 @@ mkdir -p target/out/clif echo "[BUILD] mini_core" $RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib -Csave-temps -objdump -section-headers target/out/libmini_core.dylib - echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib From 44a35507995b94751a4eaa58607b4a04a1310098 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 16:59:42 +0200 Subject: [PATCH 0684/1566] Cleanup --- ar_test.rs | 45 --------------------------------------------- test.sh | 2 +- 2 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 ar_test.rs diff --git a/ar_test.rs b/ar_test.rs deleted file mode 100644 index 567b2f04d2a07..0000000000000 --- a/ar_test.rs +++ /dev/null @@ -1,45 +0,0 @@ -//! ```cargo -//! [dependencies] -//! ar = "0.6.2" -//! ``` - -use std::io::Read; - -// 64 gives Invalid file size field in entry header -// 32 gives unexpected EOF in the middle of archive entry header -const METADATA_LEN: usize = 64; - -fn main() { - let mut builder = ar::Builder::new(std::fs::File::create("test.a").expect("create")); - - // Remove this append and there is no problem. - let header = ar::Header::new(b"core-fc675.rcgu.o".to_vec(), 0); - // Remove any of the characters in the filename and ! from will show up in the error message. - // Making it shorter than 17 chars will fix the problem though. - - builder.append(&header, &mut (&[] as &[u8])).expect("add rcgu"); - - let mut buf: Vec = vec!['!' as u8; 28]; - buf.extend(b"hello worl"); - buf.extend(&['*' as u8; 26] as &[u8]); - assert!(buf.len() >= METADATA_LEN); - - let header = ar::Header::new(b"rust.metadata.bin".to_vec(), METADATA_LEN as u64); - builder.append(&header, &mut (&buf[0..METADATA_LEN])).expect("add meta"); - - std::mem::drop(builder); - - // Remove this ranlib invocation and there is no problem. - /*assert!( - std::process::Command::new("ranlib") - .arg("test.a") - .status() - .expect("Couldn't run ranlib") - .success() - );*/ - - let mut archive = ar::Archive::new(std::fs::File::open("test.a").expect("open")); - while let Some(entry) = archive.next_entry() { - entry.unwrap(); - } -} diff --git a/test.sh b/test.sh index 20f4a6bd1f429..1dfbf9247546c 100755 --- a/test.sh +++ b/test.sh @@ -5,7 +5,7 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib -Csave-temps +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib From 44a98df8c23c0382f037f8045fc4fc3ec0396919 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 17:24:11 +0200 Subject: [PATCH 0685/1566] Remove workaround for previously missing encoding --- src/base.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/base.rs b/src/base.rs index a96110e7bd5d5..73444173c6569 100644 --- a/src/base.rs +++ b/src/base.rs @@ -563,12 +563,6 @@ fn trans_stmt<'a, 'tcx: 'a>( ) } else if from_clif_ty.is_int() && to_clif_ty.is_float() { // int-like -> float - // FIXME missing encoding for fcvt_from_sint.f32.i8 - let from = if from_clif_ty == types::I8 || from_clif_ty == types::I16 { - fx.bcx.ins().uextend(types::I32, from) - } else { - from - }; if signed { fx.bcx.ins().fcvt_from_sint(to_clif_ty, from) } else { From 87113588c7dec403fc5302207bb915970e4bc5d8 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Wed, 12 Jun 2019 17:05:50 +0200 Subject: [PATCH 0686/1566] Bump miniz-sys from 0.1.11 to 0.1.12 (#607) Bumps [miniz-sys](https://github.com/alexcrichton/flate2-rs) from 0.1.11 to 0.1.12. - [Release notes](https://github.com/alexcrichton/flate2-rs/releases) - [Commits](https://github.com/alexcrichton/flate2-rs/compare/miniz-sys-0.1.11...miniz-sys-0.1.12) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecd803172bc77..d988e57c236e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -319,7 +319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -424,7 +424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "miniz-sys" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -994,7 +994,7 @@ dependencies = [ "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" -"checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649" +"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" "checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" From ec05bcee29351233bbe643363d9da49246287da9 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" Date: Wed, 12 Jun 2019 17:06:15 +0200 Subject: [PATCH 0687/1566] Bump region from 2.1.0 to 2.1.1 (#606) Bumps [region](https://github.com/darfink/region-rs) from 2.1.0 to 2.1.1. - [Release notes](https://github.com/darfink/region-rs/releases) - [Commits](https://github.com/darfink/region-rs/compare/2.1.0...2.1.1) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d988e57c236e3..ac4f1c6722f5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "region 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "region 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -653,7 +653,7 @@ dependencies = [ [[package]] name = "region" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1021,7 +1021,7 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" -"checksum region 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0626be7920e71f5f600f358ee436e8c14ad0605d5434f78ac47863429ee6ce3" +"checksum region 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2772cece4fbb242b13b5874e4d2f0db7ebb7ba3f34c9e1372b87dfd1f86a8f8" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" From 5e2ea4f1943067c04e6f76db81c81f8cbb381b52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 18:40:07 +0200 Subject: [PATCH 0688/1566] Fix debuginfo generation when given source path doesn't contain a dir (eg plain lib.rs) --- src/debuginfo.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 0e98468070211..e379a7829f465 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -28,12 +28,17 @@ fn line_program_add_file( ) -> FileId { match file { FileName::Real(path) => { - let dir_name = LineString::new( - path.parent().unwrap().to_str().unwrap().as_bytes(), - line_program.encoding(), - line_strings, - ); - let dir_id = line_program.add_directory(dir_name); + let dir_name = path.parent().unwrap().to_str().unwrap().as_bytes(); + let dir_id = if !dir_name.is_empty() { + let dir_name = LineString::new( + dir_name, + line_program.encoding(), + line_strings, + ); + line_program.add_directory(dir_name) + } else { + line_program.default_directory() + }; let file_name = LineString::new( path.file_name().unwrap().to_str().unwrap().as_bytes(), line_program.encoding(), From 6d1bc088a7e04bb6b39cc94ab6de2e95eeca303e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 13 Jun 2019 20:44:40 +0200 Subject: [PATCH 0689/1566] Rustup to rustc 1.37.0-nightly (2887008e0 2019-06-12) --- src/abi.rs | 14 +++++++------- src/base.rs | 6 +++--- src/common.rs | 6 +++--- src/constant.rs | 26 +++++++++++++------------- src/debuginfo.rs | 4 ++-- src/driver.rs | 12 ++++++------ src/lib.rs | 10 +++++----- src/main_shim.rs | 4 ++-- src/metadata.rs | 2 +- src/pretty_clif.rs | 4 ++-- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 7bb3b1b56b910..033d41c5f20ad 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -39,8 +39,8 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { } } -fn get_pass_mode<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, +fn get_pass_mode<'tcx>( + tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>, ) -> PassMode { let layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); @@ -76,7 +76,7 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( } } -fn clif_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: FnSig<'tcx>) -> Signature { +fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sig: FnSig<'tcx>) -> Signature { let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), @@ -128,8 +128,8 @@ fn clif_sig_from_fn_sig<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sig: FnSig<'t } } -pub fn get_function_name_and_sig<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, +pub fn get_function_name_and_sig<'tcx>( + tcx: TyCtxt<'tcx, 'tcx>, inst: Instance<'tcx>, support_vararg: bool, ) -> (String, Signature) { @@ -143,8 +143,8 @@ pub fn get_function_name_and_sig<'a, 'tcx>( } /// Instance must be monomorphized -pub fn import_function<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, +pub fn import_function<'tcx>( + tcx: TyCtxt<'tcx, 'tcx>, module: &mut Module, inst: Instance<'tcx>, ) -> FuncId { diff --git a/src/base.rs b/src/base.rs index 73444173c6569..aec7f3f77e8cf 100644 --- a/src/base.rs +++ b/src/base.rs @@ -3,7 +3,7 @@ use rustc::ty::adjustment::PointerCast; use crate::prelude::*; pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( - cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, + cx: &mut crate::CodegenCx<'clif, 'tcx, B>, instance: Instance<'tcx>, linkage: Linkage, ) { @@ -18,9 +18,9 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Check sig for u128 and i128 let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx)); - struct UI128Visitor<'a, 'tcx: 'a>(TyCtxt<'a, 'tcx, 'tcx>, bool); + struct UI128Visitor<'tcx>(TyCtxt<'tcx, 'tcx>, bool); - impl<'a, 'tcx: 'a> rustc::ty::fold::TypeVisitor<'tcx> for UI128Visitor<'a, 'tcx> { + impl<'tcx> rustc::ty::fold::TypeVisitor<'tcx> for UI128Visitor<'tcx> { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { if t.sty == self.0.types.u128.sty || t.sty == self.0.types.i128.sty { self.1 = true; diff --git a/src/common.rs b/src/common.rs index 00135d2c03305..700c6ec75ec1f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -18,7 +18,7 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } pub fn clif_type_from_ty<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, ty: Ty<'tcx>, ) -> Option { Some(match ty.sty { @@ -95,7 +95,7 @@ pub fn clif_intcast<'a, 'tcx: 'a>( pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` - pub tcx: TyCtxt<'a, 'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx, 'tcx>, pub module: &'a mut Module, pub pointer_type: Type, // Cached from module @@ -123,7 +123,7 @@ impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> { } impl<'a, 'tcx, B: Backend + 'a> layout::HasTyCtxt<'tcx> for FunctionCx<'a, 'tcx, B> { - fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'tcx> { self.tcx } } diff --git a/src/constant.rs b/src/constant.rs index 0403f8d0d1bac..068d08097ddca 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -28,7 +28,7 @@ enum TodoItem { impl ConstantCx { pub fn finalize<'a, 'tcx: 'a, B: Backend>( mut self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, module: &mut Module, ) { //println!("todo {:?}", self.todo); @@ -184,7 +184,7 @@ fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) - } fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, module: &mut Module, def_id: DefId, linkage: Linkage, @@ -238,7 +238,7 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( } fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, module: &mut Module, cx: &mut ConstantCx, ) { @@ -336,7 +336,7 @@ fn pop_set(set: &mut HashSet) -> Option struct TransPlaceInterpreter; -impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { +impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { type MemoryKinds = !; type PointerTag = (); type AllocExtra = (); @@ -345,16 +345,16 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { type MemoryMap = FxHashMap, Allocation<()>)>; const STATIC_KIND: Option = None; - fn enforce_validity(_: &InterpretCx<'a, 'mir, 'tcx, Self>) -> bool { + fn enforce_validity(_: &InterpretCx<'mir, 'tcx, Self>) -> bool { false } - fn before_terminator(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> InterpResult<'tcx> { + fn before_terminator(_: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { panic!(); } fn find_fn( - _: &mut InterpretCx<'a, 'mir, 'tcx, Self>, + _: &mut InterpretCx<'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: Option>, @@ -364,7 +364,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { } fn call_intrinsic( - _: &mut InterpretCx<'a, 'mir, 'tcx, Self>, + _: &mut InterpretCx<'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: PlaceTy<'tcx>, @@ -374,13 +374,13 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { fn find_foreign_static( _: DefId, - _: ::rustc::ty::query::TyCtxtAt<'a, 'tcx, 'tcx>, + _: ::rustc::ty::query::TyCtxtAt<'tcx, 'tcx>, ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } fn ptr_op( - _: &InterpretCx<'a, 'mir, 'tcx, Self>, + _: &InterpretCx<'mir, 'tcx, Self>, _: mir::BinOp, _: ImmTy<'tcx>, _: ImmTy<'tcx>, @@ -388,7 +388,7 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn box_alloc(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { + fn box_alloc(_: &mut InterpretCx<'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { panic!(); } @@ -405,11 +405,11 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for TransPlaceInterpreter { () } - fn stack_push(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> InterpResult<'tcx> { + fn stack_push(_: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { Ok(()) } - fn stack_pop(_: &mut InterpretCx<'a, 'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> { + fn stack_pop(_: &mut InterpretCx<'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> { Ok(()) } } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index e379a7829f465..6d1726dd7b487 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -155,7 +155,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { } } - fn emit_location(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, entry_id: UnitEntryId, span: Span) { + fn emit_location(&mut self, tcx: TyCtxt<'tcx, 'tcx>, entry_id: UnitEntryId, span: Span) { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file( @@ -232,7 +232,7 @@ pub struct FunctionDebugContext<'a, 'tcx> { impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'b, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, debug_context: &'a mut DebugContext<'tcx>, mir: &Body, name: &str, diff --git a/src/driver.rs b/src/driver.rs index 391154f80c1cd..81c8100d3da8f 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -14,7 +14,7 @@ use cranelift_faerie::*; use crate::prelude::*; pub fn codegen_crate<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box { @@ -45,7 +45,7 @@ pub fn codegen_crate<'a, 'tcx>( } #[cfg(not(target_arch = "wasm32"))] -fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option) -> ! { +fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx, 'tcx>, log: &mut Option) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; let mut jit_module: Module = Module::new(SimpleJITBuilder::new( @@ -96,7 +96,7 @@ fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option) -> } fn run_aot<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, log: &mut Option, @@ -225,7 +225,7 @@ fn run_aot<'a, 'tcx: 'a>( } fn codegen_cgus<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, module: &mut Module, debug: &mut Option>, log: &mut Option, @@ -243,7 +243,7 @@ fn codegen_cgus<'a, 'tcx: 'a>( } fn codegen_mono_items<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, module: &mut Module, debug_context: Option<&mut DebugContext<'tcx>>, log: &mut Option, @@ -263,7 +263,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( } fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( - cx: &mut crate::CodegenCx<'a, 'clif, 'tcx, B>, + cx: &mut crate::CodegenCx<'clif, 'tcx, B>, mono_item: MonoItem<'tcx>, linkage: Linkage, ) { diff --git a/src/lib.rs b/src/lib.rs index be46d638b1097..897e8a1e367f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,17 +122,17 @@ impl<'tcx> Default for Caches<'tcx> { } } -pub struct CodegenCx<'a, 'clif, 'tcx, B: Backend + 'static> { - tcx: TyCtxt<'a, 'tcx, 'tcx>, +pub struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { + tcx: TyCtxt<'tcx, 'tcx>, module: &'clif mut Module, ccx: ConstantCx, caches: Caches<'tcx>, debug_context: Option<&'clif mut DebugContext<'tcx>>, } -impl<'a, 'clif, 'tcx, B: Backend + 'static> CodegenCx<'a, 'clif, 'tcx, B> { +impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { fn new( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, module: &'clif mut Module, debug_context: Option<&'clif mut DebugContext<'tcx>>, ) -> Self { @@ -195,7 +195,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn codegen_crate<'a, 'tcx>( &self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, _rx: mpsc::Receiver>, diff --git a/src/main_shim.rs b/src/main_shim.rs index 20d792912961c..6653951fd68b3 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -3,7 +3,7 @@ use crate::prelude::*; /// Create the `main` function which will initialize the rust runtime and call /// users main function. pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, module: &mut Module, ) { use rustc::middle::lang_items::StartFnLangItem; @@ -23,7 +23,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( create_entry_fn(tcx, module, main_def_id, use_start_lang_item);; fn create_entry_fn<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, m: &mut Module, rust_main_def_id: DefId, use_start_lang_item: bool, diff --git a/src/metadata.rs b/src/metadata.rs index 56ce208a71aa3..9f6fccdc71e8c 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -49,7 +49,7 @@ impl MetadataLoader for CraneliftMetadataLoader { // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 pub fn write_metadata<'a, 'gcx>( - tcx: TyCtxt<'a, 'gcx, 'gcx>, + tcx: TyCtxt<'gcx, 'gcx>, artifact: &mut faerie::Artifact ) -> EncodedMetadata { use std::io::Write; diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 53cd4f3344241..677cb4705bcc5 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -77,7 +77,7 @@ pub struct CommentWriter { } impl CommentWriter { - pub fn new<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) -> Self { + pub fn new<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx, 'tcx>, instance: Instance<'tcx>) -> Self { CommentWriter { global_comments: vec![ format!("symbol {}", tcx.symbol_name(instance).as_str()), @@ -194,7 +194,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } pub fn write_clif_file<'a, 'tcx: 'a>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, + tcx: TyCtxt<'tcx, 'tcx>, postfix: &str, instance: Instance<'tcx>, func: &ir::Function, From 80ab0cac3cb3da8926d53ff29ee21f86e99c2db3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Jun 2019 19:33:08 +0200 Subject: [PATCH 0690/1566] Apply rust-lang pr61828 to fix sysroot building --- patches/0016-Apply-rust-lang-pr61828.patch | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 patches/0016-Apply-rust-lang-pr61828.patch diff --git a/patches/0016-Apply-rust-lang-pr61828.patch b/patches/0016-Apply-rust-lang-pr61828.patch new file mode 100644 index 0000000000000..14abc18eea626 --- /dev/null +++ b/patches/0016-Apply-rust-lang-pr61828.patch @@ -0,0 +1,23 @@ +From e5f840ecb5093e4f5e96f76119d5e3b733e660f3 Mon Sep 17 00:00:00 2001 +From: Ralf Jung +Date: Fri, 14 Jun 2019 11:00:37 +0200 +Subject: [PATCH] make sure we use cfg-if as a std dependency + +--- + src/libstd/Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml +index a170dae2b08c..38df1f26d95f 100644 +--- a/src/libstd/Cargo.toml ++++ b/src/libstd/Cargo.toml +@@ -15,7 +15,7 @@ crate-type = ["dylib", "rlib"] + + [dependencies] + alloc = { path = "../liballoc" } +-cfg-if = "0.1.8" ++cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] } + panic_unwind = { path = "../libpanic_unwind", optional = true } + panic_abort = { path = "../libpanic_abort" } + core = { path = "../libcore" } + From 4d406cdcad83c992416ad213c077e3203d75cce1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 11:13:49 +0200 Subject: [PATCH 0691/1566] Rustup to rustc 1.37.0-nightly (0dc9e9c10 2019-06-15) --- patches/0016-Apply-rust-lang-pr61828.patch | 23 --------------------- src/abi.rs | 8 ++++---- src/base.rs | 2 +- src/common.rs | 8 ++++---- src/constant.rs | 24 +++++++++++----------- src/debuginfo.rs | 8 ++++---- src/driver.rs | 20 +++++++++--------- src/lib.rs | 10 ++++----- src/main_shim.rs | 8 ++++---- src/metadata.rs | 4 ++-- src/pretty_clif.rs | 8 ++++---- 11 files changed, 50 insertions(+), 73 deletions(-) delete mode 100644 patches/0016-Apply-rust-lang-pr61828.patch diff --git a/patches/0016-Apply-rust-lang-pr61828.patch b/patches/0016-Apply-rust-lang-pr61828.patch deleted file mode 100644 index 14abc18eea626..0000000000000 --- a/patches/0016-Apply-rust-lang-pr61828.patch +++ /dev/null @@ -1,23 +0,0 @@ -From e5f840ecb5093e4f5e96f76119d5e3b733e660f3 Mon Sep 17 00:00:00 2001 -From: Ralf Jung -Date: Fri, 14 Jun 2019 11:00:37 +0200 -Subject: [PATCH] make sure we use cfg-if as a std dependency - ---- - src/libstd/Cargo.toml | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml -index a170dae2b08c..38df1f26d95f 100644 ---- a/src/libstd/Cargo.toml -+++ b/src/libstd/Cargo.toml -@@ -15,7 +15,7 @@ crate-type = ["dylib", "rlib"] - - [dependencies] - alloc = { path = "../liballoc" } --cfg-if = "0.1.8" -+cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] } - panic_unwind = { path = "../libpanic_unwind", optional = true } - panic_abort = { path = "../libpanic_abort" } - core = { path = "../libcore" } - diff --git a/src/abi.rs b/src/abi.rs index 033d41c5f20ad..bb76e48ad72a4 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -40,7 +40,7 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { } fn get_pass_mode<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ) -> PassMode { let layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); @@ -76,7 +76,7 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( } } -fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sig: FnSig<'tcx>) -> Signature { +fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>) -> Signature { let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), @@ -129,7 +129,7 @@ fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx, 'tcx>, sig: FnSig<'tcx>) -> Sign } pub fn get_function_name_and_sig<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, inst: Instance<'tcx>, support_vararg: bool, ) -> (String, Signature) { @@ -144,7 +144,7 @@ pub fn get_function_name_and_sig<'tcx>( /// Instance must be monomorphized pub fn import_function<'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, module: &mut Module, inst: Instance<'tcx>, ) -> FuncId { diff --git a/src/base.rs b/src/base.rs index aec7f3f77e8cf..26b6e39b341a7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -18,7 +18,7 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( // Check sig for u128 and i128 let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx)); - struct UI128Visitor<'tcx>(TyCtxt<'tcx, 'tcx>, bool); + struct UI128Visitor<'tcx>(TyCtxt<'tcx>, bool); impl<'tcx> rustc::ty::fold::TypeVisitor<'tcx> for UI128Visitor<'tcx> { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { diff --git a/src/common.rs b/src/common.rs index 700c6ec75ec1f..bffa526c8b408 100644 --- a/src/common.rs +++ b/src/common.rs @@ -17,8 +17,8 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } } -pub fn clif_type_from_ty<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, +pub fn clif_type_from_ty<'tcx>( + tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ) -> Option { Some(match ty.sty { @@ -95,7 +95,7 @@ pub fn clif_intcast<'a, 'tcx: 'a>( pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` - pub tcx: TyCtxt<'tcx, 'tcx>, + pub tcx: TyCtxt<'tcx>, pub module: &'a mut Module, pub pointer_type: Type, // Cached from module @@ -123,7 +123,7 @@ impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> { } impl<'a, 'tcx, B: Backend + 'a> layout::HasTyCtxt<'tcx> for FunctionCx<'a, 'tcx, B> { - fn tcx<'b>(&'b self) -> TyCtxt<'tcx, 'tcx> { + fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } } diff --git a/src/constant.rs b/src/constant.rs index 068d08097ddca..60c583fd67c2e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -26,10 +26,10 @@ enum TodoItem { } impl ConstantCx { - pub fn finalize<'a, 'tcx: 'a, B: Backend>( + pub fn finalize( mut self, - tcx: TyCtxt<'tcx, 'tcx>, - module: &mut Module, + tcx: TyCtxt<'_>, + module: &mut Module, ) { //println!("todo {:?}", self.todo); define_all_allocs(tcx, module, &mut self); @@ -38,7 +38,7 @@ impl ConstantCx { } } -pub fn codegen_static<'a, 'tcx: 'a>(ccx: &mut ConstantCx, def_id: DefId) { +pub fn codegen_static(ccx: &mut ConstantCx, def_id: DefId) { ccx.todo.insert(TodoItem::Static(def_id)); } @@ -177,15 +177,15 @@ fn trans_const_place<'a, 'tcx: 'a>( cplace_for_dataid(fx, const_.ty, data_id) } -fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) -> DataId { +fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) -> DataId { module .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, None) .unwrap() } -fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( - tcx: TyCtxt<'tcx, 'tcx>, - module: &mut Module, +fn data_id_for_static( + tcx: TyCtxt<'_>, + module: &mut Module, def_id: DefId, linkage: Linkage, ) -> DataId { @@ -237,9 +237,9 @@ fn cplace_for_dataid<'a, 'tcx: 'a>( CPlace::for_addr(global_ptr, layout) } -fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>( - tcx: TyCtxt<'tcx, 'tcx>, - module: &mut Module, +fn define_all_allocs( + tcx: TyCtxt<'_>, + module: &mut Module, cx: &mut ConstantCx, ) { let memory = Memory::::new(tcx.at(DUMMY_SP)); @@ -374,7 +374,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn find_foreign_static( _: DefId, - _: ::rustc::ty::query::TyCtxtAt<'tcx, 'tcx>, + _: ::rustc::ty::query::TyCtxtAt<'tcx>, ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 6d1726dd7b487..ab63d12594518 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -92,7 +92,7 @@ pub struct DebugContext<'tcx> { _dummy: PhantomData<&'tcx ()>, } -impl<'a, 'tcx: 'a> DebugContext<'tcx> { +impl<'tcx> DebugContext<'tcx> { pub fn new(tcx: TyCtxt, address_size: u8) -> Self { let encoding = Encoding { format: Format::Dwarf32, @@ -155,7 +155,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> { } } - fn emit_location(&mut self, tcx: TyCtxt<'tcx, 'tcx>, entry_id: UnitEntryId, span: Span) { + fn emit_location(&mut self, tcx: TyCtxt<'tcx>, entry_id: UnitEntryId, span: Span) { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file( @@ -230,9 +230,9 @@ pub struct FunctionDebugContext<'a, 'tcx> { mir_span: Span, } -impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> { +impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, debug_context: &'a mut DebugContext<'tcx>, mir: &Body, name: &str, diff --git a/src/driver.rs b/src/driver.rs index 81c8100d3da8f..413f9f4e04840 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -13,8 +13,8 @@ use cranelift_faerie::*; use crate::prelude::*; -pub fn codegen_crate<'a, 'tcx>( - tcx: TyCtxt<'tcx, 'tcx>, +pub fn codegen_crate( + tcx: TyCtxt<'_>, metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box { @@ -45,7 +45,7 @@ pub fn codegen_crate<'a, 'tcx>( } #[cfg(not(target_arch = "wasm32"))] -fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx, 'tcx>, log: &mut Option) -> ! { +fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; let mut jit_module: Module = Module::new(SimpleJITBuilder::new( @@ -95,8 +95,8 @@ fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx, 'tcx>, log: &mut Option) -> ! { std::process::exit(ret); } -fn run_aot<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, +fn run_aot( + tcx: TyCtxt<'_>, metadata: EncodedMetadata, need_metadata_module: bool, log: &mut Option, @@ -224,8 +224,8 @@ fn run_aot<'a, 'tcx: 'a>( }) } -fn codegen_cgus<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, +fn codegen_cgus<'tcx>( + tcx: TyCtxt<'tcx>, module: &mut Module, debug: &mut Option>, log: &mut Option, @@ -242,8 +242,8 @@ fn codegen_cgus<'a, 'tcx: 'a>( crate::main_shim::maybe_create_entry_wrapper(tcx, module); } -fn codegen_mono_items<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, +fn codegen_mono_items<'tcx>( + tcx: TyCtxt<'tcx>, module: &mut Module, debug_context: Option<&mut DebugContext<'tcx>>, log: &mut Option, @@ -262,7 +262,7 @@ fn codegen_mono_items<'a, 'tcx: 'a>( }); } -fn trans_mono_item<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( +fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( cx: &mut crate::CodegenCx<'clif, 'tcx, B>, mono_item: MonoItem<'tcx>, linkage: Linkage, diff --git a/src/lib.rs b/src/lib.rs index 897e8a1e367f3..0d7cab1f8e341 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,7 +113,7 @@ pub struct Caches<'tcx> { pub vtables: HashMap<(Ty<'tcx>, Option>), DataId>, } -impl<'tcx> Default for Caches<'tcx> { +impl Default for Caches<'_> { fn default() -> Self { Caches { context: Context::new(), @@ -123,7 +123,7 @@ impl<'tcx> Default for Caches<'tcx> { } pub struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, module: &'clif mut Module, ccx: ConstantCx, caches: Caches<'tcx>, @@ -132,7 +132,7 @@ pub struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { fn new( - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, module: &'clif mut Module, debug_context: Option<&'clif mut DebugContext<'tcx>>, ) -> Self { @@ -193,9 +193,9 @@ impl CodegenBackend for CraneliftCodegenBackend { rustc_codegen_ssa::back::symbol_export::provide_extern(providers); } - fn codegen_crate<'a, 'tcx>( + fn codegen_crate<'tcx>( &self, - tcx: TyCtxt<'tcx, 'tcx>, + tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, _rx: mpsc::Receiver>, diff --git a/src/main_shim.rs b/src/main_shim.rs index 6653951fd68b3..1dae9e32baad3 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -2,8 +2,8 @@ use crate::prelude::*; /// Create the `main` function which will initialize the rust runtime and call /// users main function. -pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, +pub fn maybe_create_entry_wrapper( + tcx: TyCtxt<'_>, module: &mut Module, ) { use rustc::middle::lang_items::StartFnLangItem; @@ -22,8 +22,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx: 'a>( create_entry_fn(tcx, module, main_def_id, use_start_lang_item);; - fn create_entry_fn<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, + fn create_entry_fn( + tcx: TyCtxt<'_>, m: &mut Module, rust_main_def_id: DefId, use_start_lang_item: bool, diff --git a/src/metadata.rs b/src/metadata.rs index 9f6fccdc71e8c..265a160e7a8e4 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -48,8 +48,8 @@ impl MetadataLoader for CraneliftMetadataLoader { } // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 -pub fn write_metadata<'a, 'gcx>( - tcx: TyCtxt<'gcx, 'gcx>, +pub fn write_metadata( + tcx: TyCtxt<'_>, artifact: &mut faerie::Artifact ) -> EncodedMetadata { use std::io::Write; diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 677cb4705bcc5..57fcebe79c26f 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -77,7 +77,7 @@ pub struct CommentWriter { } impl CommentWriter { - pub fn new<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx, 'tcx>, instance: Instance<'tcx>) -> Self { + pub fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self { CommentWriter { global_comments: vec![ format!("symbol {}", tcx.symbol_name(instance).as_str()), @@ -91,7 +91,7 @@ impl CommentWriter { } } -impl<'a> FuncWriter for &'a CommentWriter { +impl FuncWriter for &'_ CommentWriter { fn write_preamble( &mut self, w: &mut dyn fmt::Write, @@ -193,8 +193,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } } -pub fn write_clif_file<'a, 'tcx: 'a>( - tcx: TyCtxt<'tcx, 'tcx>, +pub fn write_clif_file<'tcx>( + tcx: TyCtxt<'tcx>, postfix: &str, instance: Instance<'tcx>, func: &ir::Function, From 65bc1e5b5b9191db6f0082447e22c4d971c8cc19 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 12:51:16 +0200 Subject: [PATCH 0692/1566] Fix `write_cvalue` for `ByValPair` when the cvalue is not trivially a pair `write_cvalue` didn't work for `Box<[u8]>`, because the inner fat ptr was wrapped inside a newtype, which meant `Box<[u8]>` itself only had one field. This also simplifies `CValue::force_stack` by reusing `write_cvalue` when it is not already on the stack. --- src/value_and_place.rs | 47 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 3c83220b0250d..51af4650942db 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -53,28 +53,10 @@ impl<'tcx> CValue<'tcx> { let layout = self.1; match self.0 { CValueInner::ByRef(value) => value, - CValueInner::ByVal(value) => { - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); - fx.bcx.ins().store(MemFlags::new(), value, addr, 0); - addr - } - CValueInner::ByValPair(value, extra) => { - let stack_slot = fx.bcx.create_stack_slot(StackSlotData { - kind: StackSlotKind::ExplicitSlot, - size: layout.size.bytes() as u32, - offset: None, - }); - let base = fx.bcx.ins().stack_addr(types::I64, stack_slot, 0); - let a_addr = codegen_field(fx, base, layout, mir::Field::new(0)).0; - let b_addr = codegen_field(fx, base, layout, mir::Field::new(1)).0; - fx.bcx.ins().store(MemFlags::new(), value, a_addr, 0); - fx.bcx.ins().store(MemFlags::new(), extra, b_addr, 0); - base + CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => { + let cplace = CPlace::new_stack_slot(fx, layout.ty); + cplace.write_cvalue(fx, self); + cplace.to_addr(fx) } } } @@ -356,11 +338,22 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CValueInner::ByVal(val) => { fx.bcx.ins().store(MemFlags::new(), val, addr, 0); } - CValueInner::ByValPair(val1, val2) => { - let val1_offset = dst_layout.fields.offset(0).bytes() as i32; - let val2_offset = dst_layout.fields.offset(1).bytes() as i32; - fx.bcx.ins().store(MemFlags::new(), val1, addr, val1_offset); - fx.bcx.ins().store(MemFlags::new(), val2, addr, val2_offset); + CValueInner::ByValPair(value, extra) => { + match dst_layout.abi { + Abi::ScalarPair(ref a, _) => { + fx.bcx.ins().store(MemFlags::new(), value, addr, 0); + fx.bcx.ins().store( + MemFlags::new(), + extra, + addr, + a.value.size(&fx.tcx).bytes() as u32 as i32, + ); + } + _ => bug!( + "Non ScalarPair abi {:?} for ByValPair CValue", + dst_layout.abi + ), + } } CValueInner::ByRef(from_addr) => { let src_layout = from.1; From 3f15b0a24bc95c3a94325fdb4a9670787da87e62 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 12:54:37 +0200 Subject: [PATCH 0693/1566] Implement scalar pair abi pass mode --- src/abi.rs | 218 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 162 insertions(+), 56 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index bb76e48ad72a4..e8523cd2de080 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -9,15 +9,73 @@ use crate::prelude::*; enum PassMode { NoPass, ByVal(Type), + ByValPair(Type, Type), ByRef, } +#[derive(Copy, Clone, Debug)] +enum EmptySinglePair { + Empty, + Single(T), + Pair(T, T), +} + +impl EmptySinglePair { + fn into_iter(self) -> EmptySinglePairIter { + EmptySinglePairIter(self) + } + + fn map(self, mut f: impl FnMut(T) -> U) -> EmptySinglePair { + match self { + Empty => Empty, + Single(v) => Single(f(v)), + Pair(a, b) => Pair(f(a), f(b)), + } + } +} + +struct EmptySinglePairIter(EmptySinglePair); + +impl Iterator for EmptySinglePairIter { + type Item = T; + + fn next(&mut self) -> Option { + match std::mem::replace(&mut self.0, Empty) { + Empty => None, + Single(v) => Some(v), + Pair(a, b) => { + self.0 = Single(b); + Some(a) + } + } + } +} + +impl EmptySinglePair { + fn assert_single(self) -> T { + match self { + Single(v) => v, + _ => panic!("Called assert_single on {:?}", self) + } + } + + fn assert_pair(self) -> (T, T) { + match self { + Pair(a, b) => (a, b), + _ => panic!("Called assert_pair on {:?}", self) + } + } +} + +use EmptySinglePair::*; + impl PassMode { - fn get_param_ty(self, fx: &FunctionCx) -> Type { + fn get_param_ty(self, fx: &FunctionCx) -> EmptySinglePair { match self { - PassMode::NoPass => unimplemented!("pass mode nopass"), - PassMode::ByVal(clif_type) => clif_type, - PassMode::ByRef => fx.pointer_type, + PassMode::NoPass => Empty, + PassMode::ByVal(clif_type) => Single(clif_type), + PassMode::ByValPair(a, b) => Pair(a, b), + PassMode::ByRef => Single(fx.pointer_type), } } } @@ -41,9 +99,8 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { fn get_pass_mode<'tcx>( tcx: TyCtxt<'tcx>, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, ) -> PassMode { - let layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); assert!(!layout.is_unsized()); if layout.is_zst() { @@ -55,9 +112,14 @@ fn get_pass_mode<'tcx>( layout::Abi::Scalar(scalar) => { PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) } + layout::Abi::ScalarPair(a, b) => { + PassMode::ByValPair( + scalar_to_clif_type(tcx, a.clone()), + scalar_to_clif_type(tcx, b.clone()), + ) + } - // FIXME implement ScalarPair and Vector Abi in a cg_llvm compatible way - layout::Abi::ScalarPair(_, _) => PassMode::ByRef, + // FIXME implement Vector Abi in a cg_llvm compatible way layout::Abi::Vector { .. } => PassMode::ByRef, layout::Abi::Aggregate { .. } => PassMode::ByRef, @@ -68,15 +130,19 @@ fn get_pass_mode<'tcx>( fn adjust_arg_for_abi<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, arg: CValue<'tcx>, -) -> Option { - match get_pass_mode(fx.tcx, arg.layout().ty) { - PassMode::NoPass => None, - PassMode::ByVal(_) => Some(arg.load_scalar(fx)), - PassMode::ByRef => Some(arg.force_stack(fx)), +) -> EmptySinglePair { + match get_pass_mode(fx.tcx, arg.layout()) { + PassMode::NoPass => Empty, + PassMode::ByVal(_) => Single(arg.load_scalar(fx)), + PassMode::ByValPair(_, _) => { + let (a, b) = arg.load_scalar_pair(fx); + Pair(a, b) + } + PassMode::ByRef => Single(arg.force_stack(fx)), } } -fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>) -> Signature { +fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: bool) -> Signature { let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), @@ -97,18 +163,32 @@ fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>) -> Signature let inputs = inputs .into_iter() - .filter_map(|ty| match get_pass_mode(tcx, ty) { - PassMode::NoPass => None, - PassMode::ByVal(clif_ty) => Some(clif_ty), - PassMode::ByRef => Some(pointer_ty(tcx)), - }); - - let (params, returns) = match get_pass_mode(tcx, output) { + .enumerate() + .map(|(i, ty)| { + let mut layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + if i == 0 && is_vtable_fn { + // Virtual calls turn their self param into a thin pointer. + // See https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc/ty/layout.rs.html#2519-2572 for more info + layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.mk_mut_ptr(tcx.mk_unit()))).unwrap(); + } + match get_pass_mode(tcx, layout) { + PassMode::NoPass => Empty, + PassMode::ByVal(clif_ty) => Single(clif_ty), + PassMode::ByValPair(clif_ty_a, clif_ty_b) => Pair(clif_ty_a, clif_ty_b), + PassMode::ByRef => Single(pointer_ty(tcx)), + }.into_iter() + }).flatten(); + + let (params, returns) = match get_pass_mode(tcx, tcx.layout_of(ParamEnv::reveal_all().and(output)).unwrap()) { PassMode::NoPass => (inputs.map(AbiParam::new).collect(), vec![]), PassMode::ByVal(ret_ty) => ( inputs.map(AbiParam::new).collect(), vec![AbiParam::new(ret_ty)], ), + PassMode::ByValPair(ret_ty_a, ret_ty_b) => ( + inputs.map(AbiParam::new).collect(), + vec![AbiParam::new(ret_ty_a), AbiParam::new(ret_ty_b)], + ), PassMode::ByRef => { ( Some(pointer_ty(tcx)) // First param is place to put return val @@ -138,7 +218,7 @@ pub fn get_function_name_and_sig<'tcx>( if fn_sig.c_variadic && !support_vararg { unimpl!("Variadic function definitions are not yet supported"); } - let sig = clif_sig_from_fn_sig(tcx, fn_sig); + let sig = clif_sig_from_fn_sig(tcx, fn_sig, false); (tcx.symbol_name(inst).as_str().to_string(), sig) } @@ -238,8 +318,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { self.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &self.instance.fn_sig(self.tcx)) } - fn return_type(&self) -> Ty<'tcx> { - self.self_sig().output() + fn return_layout(&self) -> TyLayout<'tcx> { + self.layout_of(self.self_sig().output()) } } @@ -249,7 +329,7 @@ fn add_arg_comment<'a, 'tcx: 'a>( msg: &str, local: mir::Local, local_field: Option, - param: Option, + params: EmptySinglePair, pass_mode: PassMode, ssa: crate::analyze::Flags, ty: Ty<'tcx>, @@ -259,18 +339,18 @@ fn add_arg_comment<'a, 'tcx: 'a>( } else { Cow::Borrowed("") }; - let param = if let Some(param) = param { - Cow::Owned(format!("= {:?}", param)) - } else { - Cow::Borrowed("-") + let params = match params { + Empty => Cow::Borrowed("-"), + Single(param) => Cow::Owned(format!("= {:?}", param)), + Pair(param_a, param_b) => Cow::Owned(format!("= {:?}, {:?}", param_a, param_b)), }; let pass_mode = format!("{:?}", pass_mode); fx.add_global_comment(format!( - "{msg:5} {local:>3}{local_field:<5} {param:10} {pass_mode:20} {ssa:10} {ty:?}", + "{msg:5} {local:>3}{local_field:<5} {params:10} {pass_mode:20} {ssa:10} {ty:?}", msg = msg, local = format!("{:?}", local), local_field = local_field, - param = param, + params = params, pass_mode = pass_mode, ssa = format!("{:?}", ssa), ty = ty, @@ -347,14 +427,14 @@ fn cvalue_for_param<'a, 'tcx: 'a>( ssa_flags: crate::analyze::Flags, ) -> Option> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.tcx, arg_ty); + let pass_mode = get_pass_mode(fx.tcx, fx.layout_of(arg_ty)); if let PassMode::NoPass = pass_mode { return None; } - let clif_type = pass_mode.get_param_ty(fx); - let ebb_param = fx.bcx.append_ebb_param(start_ebb, clif_type); + let clif_types = pass_mode.get_param_ty(fx); + let ebb_params = clif_types.map(|t| fx.bcx.append_ebb_param(start_ebb, t)); #[cfg(debug_assertions)] add_arg_comment( @@ -362,7 +442,7 @@ fn cvalue_for_param<'a, 'tcx: 'a>( "arg", local, local_field, - Some(ebb_param), + ebb_params, pass_mode, ssa_flags, arg_ty, @@ -370,8 +450,12 @@ fn cvalue_for_param<'a, 'tcx: 'a>( match pass_mode { PassMode::NoPass => unreachable!(), - PassMode::ByVal(_) => Some(CValue::by_val(ebb_param, layout)), - PassMode::ByRef => Some(CValue::by_ref(ebb_param, layout)), + PassMode::ByVal(_) => Some(CValue::by_val(ebb_params.assert_single(), layout)), + PassMode::ByValPair(_, _) => { + let (a, b) = ebb_params.assert_pair(); + Some(CValue::by_val_pair(a, b, layout)) + } + PassMode::ByRef => Some(CValue::by_ref(ebb_params.assert_single(), layout)), } } @@ -384,17 +468,20 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( #[cfg(debug_assertions)] fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); - let ret_layout = fx.layout_of(fx.return_type()); - let output_pass_mode = get_pass_mode(fx.tcx, fx.return_type()); + let ret_layout = fx.return_layout(); + let output_pass_mode = get_pass_mode(fx.tcx, fx.return_layout()); let ret_param = match output_pass_mode { - PassMode::NoPass => None, - PassMode::ByVal(_) => None, + PassMode::NoPass | PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, fx.pointer_type)), }; #[cfg(debug_assertions)] { add_local_header_comment(fx); + let ret_param = match ret_param { + Some(param) => Single(param), + None => Empty, + }; add_arg_comment( fx, "ret", @@ -460,7 +547,7 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( fx.local_map .insert(RETURN_PLACE, CPlace::no_place(ret_layout)); } - PassMode::ByVal(_) => { + PassMode::ByVal(_) | PassMode::ByValPair(_, _) => { let is_ssa = !ssa_analyzed .get(&RETURN_PLACE) .unwrap() @@ -603,14 +690,14 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fx.tcx, fn_sig.output()); + let output_pass_mode = get_pass_mode(fx.tcx, fx.layout_of(fn_sig.output())); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { Some(ret_place) => Some(ret_place.to_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), }, - PassMode::ByVal(_) => None, + PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, }; let instance = match fn_ty.sty { @@ -620,46 +707,53 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( _ => None, }; - // | Indirect call target - // v v the first argument to be passed - let (func_ref, first_arg) = match instance { + // | indirect call target + // | | the first argument to be passed + // v v v virtual calls are special cased below + let (func_ref, first_arg, is_virtual_call) = match instance { // Trait object call Some(Instance { def: InstanceDef::Virtual(_, idx), .. }) => { + let nop_inst = fx.bcx.ins().nop(); + fx.add_comment(nop_inst, format!("virtual call; self arg pass mode: {:?}", get_pass_mode(fx.tcx, args[0].layout()))); let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0], idx); - (Some(method), Some(ptr)) + (Some(method), Single(ptr), true) } // Normal call - Some(_) => (None, args.get(0).and_then(|arg| adjust_arg_for_abi(fx, *arg))), + Some(_) => (None, args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)).unwrap_or(Empty), false), // Indirect call None => { + let nop_inst = fx.bcx.ins().nop(); + fx.add_comment(nop_inst, "indirect call"); let func = trans_operand(fx, func.expect("indirect call without func Operand")) .load_scalar(fx); ( Some(func), - args.get(0).and_then(|arg| adjust_arg_for_abi(fx, *arg)), + args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)).unwrap_or(Empty), + false, ) } }; let call_args: Vec = return_ptr .into_iter() - .chain(first_arg) + .chain(first_arg.into_iter()) .chain( args.into_iter() .skip(1) - .filter_map(|arg| adjust_arg_for_abi(fx, arg)), + .map(|arg| adjust_arg_for_abi(fx, arg).into_iter()) + .flatten(), ) .collect::>(); let call_inst = if let Some(func_ref) = func_ref { let sig = fx .bcx - .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); + .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, is_virtual_call)); fx.bcx.ins().call_indirect(sig, func_ref, &call_args) } else { let func_ref = fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); @@ -694,6 +788,13 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( ret_place.write_cvalue(fx, CValue::by_val(ret_val, ret_layout)); } } + PassMode::ByValPair(_, _) => { + if let Some(ret_place) = ret_place { + let ret_val_a = fx.bcx.inst_results(call_inst)[0]; + let ret_val_b = fx.bcx.inst_results(call_inst)[1]; + ret_place.write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_layout)); + } + } PassMode::ByRef => {} } } @@ -708,19 +809,19 @@ pub fn codegen_drop<'a, 'tcx: 'a>( let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &drop_fn_ty.fn_sig(fx.tcx)); - match get_pass_mode(fx.tcx, fn_sig.output()) { + match get_pass_mode(fx.tcx, fx.layout_of(fn_sig.output())) { PassMode::NoPass => {} _ => unreachable!(), }; let sig = fx .bcx - .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig)); + .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, true)); fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); } pub fn codegen_return(fx: &mut FunctionCx) { - match get_pass_mode(fx.tcx, fx.return_type()) { + match get_pass_mode(fx.tcx, fx.return_layout()) { PassMode::NoPass | PassMode::ByRef => { fx.bcx.ins().return_(&[]); } @@ -729,5 +830,10 @@ pub fn codegen_return(fx: &mut FunctionCx) { let ret_val = place.to_cvalue(fx).load_scalar(fx); fx.bcx.ins().return_(&[ret_val]); } + PassMode::ByValPair(_, _) => { + let place = fx.get_local_place(RETURN_PLACE); + let (ret_val_a, ret_val_b) = place.to_cvalue(fx).load_scalar_pair(fx); + fx.bcx.ins().return_(&[ret_val_a, ret_val_b]); + } } } From 5b70fd6430535bd9199c973c64cd8be98072d394 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 14:39:23 +0200 Subject: [PATCH 0694/1566] Update dependencies --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac4f1c6722f5b..a6ca7a2df9298 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -303,7 +303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -664,7 +664,7 @@ dependencies = [ [[package]] name = "remove_dir_all" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -724,7 +724,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -790,12 +790,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.35" +version = "0.15.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -810,7 +810,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -833,7 +833,7 @@ dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -847,7 +847,7 @@ dependencies = [ [[package]] name = "termion" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1022,7 +1022,7 @@ dependencies = [ "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" "checksum region 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2772cece4fbb242b13b5874e4d2f0db7ebb7ba3f34c9e1372b87dfd1f86a8f8" -"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" +"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" @@ -1037,12 +1037,12 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fa19a5a708e22bb5be31c1b6108a2a902f909c4b9ba85cba44c06632386bc0ff" "checksum structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d59d0ae8ef8de16e49e3ca7afa16024a3e0dfd974a75ef93fdc5464e34523f" -"checksum syn 0.15.35 (registry+https://github.com/rust-lang/crates.io-index)" = "641e117d55514d6d918490e47102f7e08d096fdde360247e4a10f7a91a8478d3" +"checksum syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)" = "8b4f551a91e2e3848aeef8751d0d4eec9489b6474c720fd4c55958d8d31a430c" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" -"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" +"checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" From f8c5e10f266b45ecfbb603c165aca61144008c17 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 14:47:01 +0200 Subject: [PATCH 0695/1566] Fix compiling in release mode --- src/abi.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index e8523cd2de080..3c608a1d97c43 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -716,8 +716,14 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( def: InstanceDef::Virtual(_, idx), .. }) => { - let nop_inst = fx.bcx.ins().nop(); - fx.add_comment(nop_inst, format!("virtual call; self arg pass mode: {:?}", get_pass_mode(fx.tcx, args[0].layout()))); + #[cfg(debug_assertions)] + { + let nop_inst = fx.bcx.ins().nop(); + fx.add_comment( + nop_inst, + format!("virtual call; self arg pass mode: {:?}", get_pass_mode(fx.tcx, args[0].layout())), + ); + } let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0], idx); (Some(method), Single(ptr), true) } @@ -727,8 +733,11 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( // Indirect call None => { - let nop_inst = fx.bcx.ins().nop(); - fx.add_comment(nop_inst, "indirect call"); + #[cfg(debug_assertions)] + { + let nop_inst = fx.bcx.ins().nop(); + fx.add_comment(nop_inst, "indirect call"); + } let func = trans_operand(fx, func.expect("indirect call without func Operand")) .load_scalar(fx); ( From 76a178098d0ff5d1266f9c601958255cdfd86f4e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 15:57:53 +0200 Subject: [PATCH 0696/1566] Refactor drop codegen --- src/abi.rs | 55 ++++++++++++++++++++++++++++++++++++++++------------- src/base.rs | 38 ++---------------------------------- 2 files changed, 44 insertions(+), 49 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 3c608a1d97c43..7543d16e25faa 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -679,7 +679,7 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( } } -pub fn codegen_call_inner<'a, 'tcx: 'a>( +fn codegen_call_inner<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, func: Option<&Operand<'tcx>>, fn_ty: Ty<'tcx>, @@ -811,22 +811,51 @@ pub fn codegen_call_inner<'a, 'tcx: 'a>( pub fn codegen_drop<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, drop_place: CPlace<'tcx>, - drop_fn_ty: Ty<'tcx>, ) { - let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); - let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); + let ty = drop_place.layout().ty; + let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty); - let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &drop_fn_ty.fn_sig(fx.tcx)); + if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { + // we don't actually need to drop anything + } else { + let drop_fn_ty = drop_fn.ty(fx.tcx); + match ty.sty { + ty::Dynamic(..) => { + let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); + let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); - match get_pass_mode(fx.tcx, fx.layout_of(fn_sig.output())) { - PassMode::NoPass => {} - _ => unreachable!(), - }; + let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &drop_fn_ty.fn_sig(fx.tcx)); - let sig = fx - .bcx - .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, true)); - fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); + assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); + + let sig = fx + .bcx + .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, true)); + fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); + } + _ => { + let arg_place = CPlace::new_stack_slot( + fx, + fx.tcx.mk_ref( + &ty::RegionKind::ReErased, + TypeAndMut { + ty, + mutbl: crate::rustc::hir::Mutability::MutMutable, + }, + ), + ); + drop_place.write_place_ref(fx, arg_place); + let arg_value = arg_place.to_cvalue(fx); + crate::abi::codegen_call_inner( + fx, + None, + drop_fn_ty, + vec![arg_value], + None, + ); + } + } + } } pub fn codegen_return(fx: &mut FunctionCx) { diff --git a/src/base.rs b/src/base.rs index 26b6e39b341a7..2b4cd42c7579f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -286,42 +286,8 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) target, unwind: _, } => { - let ty = location.ty(fx.mir, fx.tcx).ty; - let ty = fx.monomorphize(&ty); - let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty); - - if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { - // we don't actually need to drop anything - } else { - let drop_place = trans_place(fx, location); - let drop_fn_ty = drop_fn.ty(fx.tcx); - match ty.sty { - ty::Dynamic(..) => { - crate::abi::codegen_drop(fx, drop_place, drop_fn_ty); - } - _ => { - let arg_place = CPlace::new_stack_slot( - fx, - fx.tcx.mk_ref( - &ty::RegionKind::ReErased, - TypeAndMut { - ty, - mutbl: crate::rustc::hir::Mutability::MutMutable, - }, - ), - ); - drop_place.write_place_ref(fx, arg_place); - let arg_value = arg_place.to_cvalue(fx); - crate::abi::codegen_call_inner( - fx, - None, - drop_fn_ty, - vec![arg_value], - None, - ); - } - } - } + let drop_place = trans_place(fx, location); + crate::abi::codegen_drop(fx, drop_place); let target_ebb = fx.get_ebb(*target); fx.bcx.ins().jump(target_ebb, &[]); From 2eae6bc8793e43db7ebb210515e9b1de6574bd6d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 17:27:51 +0200 Subject: [PATCH 0697/1566] Make a link less prone to breaking --- src/abi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index 7543d16e25faa..2397da9be2627 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -168,7 +168,7 @@ fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: let mut layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); if i == 0 && is_vtable_fn { // Virtual calls turn their self param into a thin pointer. - // See https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc/ty/layout.rs.html#2519-2572 for more info + // See https://github.com/rust-lang/rust/blob/37b6a5e5e82497caf5353d9d856e4eb5d14cbe06/src/librustc/ty/layout.rs#L2519-L2572 for more info layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.mk_mut_ptr(tcx.mk_unit()))).unwrap(); } match get_pass_mode(tcx, layout) { From c0779d5d1dd03ecb4d507e236b2a642636e62ca1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Jun 2019 17:40:16 +0200 Subject: [PATCH 0698/1566] Add comments for trap::codegen_print gv and fn defs --- src/trap.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/trap.rs b/src/trap.rs index c0464e18e4e4e..f37f6cccae6bd 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -7,17 +7,19 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms returns: vec![], }).unwrap(); let puts = fx.module.declare_func_in_func(puts, &mut fx.bcx.func); + fx.add_entity_comment(puts, "puts"); let symbol_name = fx.tcx.symbol_name(fx.instance); - let msg_bytes = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg).into_bytes().into_boxed_slice(); + let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); let mut data_ctx = DataContext::new(); - data_ctx.define(msg_bytes); + data_ctx.define(real_msg.as_bytes().to_vec().into_boxed_slice()); let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false, None).unwrap(); // Ignore DuplicateDefinition error, as the data will be the same let _ = fx.module.define_data(msg_id, &data_ctx); let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); + fx.add_entity_comment(local_msg_id, msg); let msg_ptr = fx.bcx.ins().global_value(pointer_ty(fx.tcx), local_msg_id); fx.bcx.ins().call(puts, &[msg_ptr]); } From bd73128d2e4dba0af92e315fee75638da782e4a8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 18:40:49 +0200 Subject: [PATCH 0699/1566] Implement lt, le, ge and gt for fat pointers --- src/base.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index 2b4cd42c7579f..3f5b003a24de8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1052,6 +1052,7 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( } else { let (lhs_ptr, lhs_extra) = lhs.load_scalar_pair(fx); let (rhs_ptr, rhs_extra) = rhs.load_scalar_pair(fx); + let res = match bin_op { BinOp::Eq => { let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); @@ -1063,10 +1064,28 @@ fn trans_ptr_binop<'a, 'tcx: 'a>( let extra_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_extra, rhs_extra); fx.bcx.ins().bor(ptr_ne, extra_ne) } - _ => unimplemented!( - "trans_ptr_binop({:?}, , ) not implemented", - bin_op - ), + BinOp::Lt | BinOp::Le | BinOp::Ge | BinOp::Gt => { + let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); + + let ptr_cmp = fx.bcx.ins().icmp(match bin_op { + BinOp::Lt => IntCC::UnsignedLessThan, + BinOp::Le => IntCC::UnsignedLessThanOrEqual, + BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, + BinOp::Gt => IntCC::UnsignedGreaterThan, + _ => unreachable!(), + }, lhs_ptr, rhs_ptr); + + let extra_cmp = fx.bcx.ins().icmp(match bin_op { + BinOp::Lt => IntCC::UnsignedLessThan, + BinOp::Le => IntCC::UnsignedLessThanOrEqual, + BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, + BinOp::Gt => IntCC::UnsignedGreaterThan, + _ => unreachable!(), + }, lhs_extra, rhs_extra); + + fx.bcx.ins().select(ptr_eq, extra_cmp, ptr_cmp) + } + _ => panic!("bin_op {:?} on ptr", bin_op), }; assert_eq!(fx.tcx.types.bool, ret_ty); From 01e930385776a5c8a3719cf762362c52e894a46b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Jun 2019 16:25:10 +0200 Subject: [PATCH 0700/1566] Fix SetDiscriminant for generators --- src/base.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 3f5b003a24de8..0dc4752abba9e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -340,9 +340,8 @@ fn trans_stmt<'a, 'tcx: 'a>( let ptr = place.place_field(fx, mir::Field::new(discr_index)); let to = layout .ty - .ty_adt_def() - .unwrap() .discriminant_for_variant(fx.tcx, *variant_index) + .unwrap() .val; let discr = CValue::const_val(fx, ptr.layout().ty, to as u64 as i64); ptr.write_cvalue(fx, discr); From 2b61f90c715b264abd5f2c22506a3906360916d7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 2 Jun 2019 16:25:44 +0200 Subject: [PATCH 0701/1566] Fix returning non ZST uninhabited types --- src/value_and_place.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 51af4650942db..bf027dd3e88a6 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -327,8 +327,9 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { dst_layout, ), CPlace::NoPlace(layout) => { - assert_eq!(layout.size.bytes(), 0); - assert_eq!(from.layout().size.bytes(), 0); + if layout.abi != Abi::Uninhabited { + assert_eq!(layout.size.bytes(), 0, "{:?}", layout); + } return; } CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), From dd15051f5af4ce0a37f577a5062ac9505f2dc6c5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 23 Jun 2019 10:47:16 +0200 Subject: [PATCH 0702/1566] Rustup to rustc 1.37.0-nightly (de02101e6 2019-06-22) --- patches/0014-Don-t-use-OS-TLS.patch | 27 ++++++++++++++------------- src/constant.rs | 6 +++--- src/intrinsics.rs | 1 + 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/patches/0014-Don-t-use-OS-TLS.patch b/patches/0014-Don-t-use-OS-TLS.patch index 1ee7069262749..ca28fe2fd7043 100644 --- a/patches/0014-Don-t-use-OS-TLS.patch +++ b/patches/0014-Don-t-use-OS-TLS.patch @@ -1,6 +1,6 @@ -From 0c7406a33e3a40427760e6955188be193fd568a8 Mon Sep 17 00:00:00 2001 +From 9e8b8114de61ecdbf39f7582d7a3280ef2bfd339 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Fri, 1 Mar 2019 18:36:22 +0100 +Date: Sun, 23 Jun 2019 10:37:53 +0200 Subject: [PATCH] Don't use OS TLS --- @@ -9,13 +9,13 @@ Subject: [PATCH] Don't use OS TLS 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs -index d1f5373..ce83b3b 100644 +index 9b355aa..a074aa5 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs -@@ -164,10 +164,10 @@ macro_rules! __thread_local_inner { - &'static $crate::cell::UnsafeCell< - $crate::option::Option<$t>>> - { +@@ -154,10 +154,10 @@ macro_rules! __thread_local_inner { + fn __init() -> $t { $init } + + unsafe fn __getit() -> $crate::option::Option<&'static $t> { - #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] static __KEY: $crate::thread::__StaticLocalKeyInner<$t> = $crate::thread::__StaticLocalKeyInner::new(); @@ -24,24 +24,24 @@ index d1f5373..ce83b3b 100644 #[thread_local] #[cfg(all( target_thread_local, -@@ -182,6 +182,7 @@ macro_rules! __thread_local_inner { +@@ -172,6 +172,7 @@ macro_rules! __thread_local_inner { ))] static __KEY: $crate::thread::__OsLocalKeyInner<$t> = $crate::thread::__OsLocalKeyInner::new(); + */ - __KEY.get() + __KEY.get(__init) } -@@ -308,7 +309,6 @@ impl LocalKey { +@@ -320,7 +321,6 @@ mod lazy { /// On some platforms like wasm32 there's no threads, so no need to generate /// thread locals and we can instead just use plain statics! #[doc(hidden)] -#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] pub mod statik { - use crate::cell::UnsafeCell; + use super::lazy::LazyKeyInner; use crate::fmt; diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs -index 08f0aa2..eff3126 100644 +index 35de4f4..f142646 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -195,7 +195,6 @@ pub use self::local::{LocalKey, AccessError}; @@ -53,4 +53,5 @@ index 08f0aa2..eff3126 100644 #[unstable(feature = "libstd_thread_internals", issue = "0")] #[cfg(target_thread_local)] -- -2.17.2 (Apple Git-113) +2.20.1 (Apple Git-117) + diff --git a/src/constant.rs b/src/constant.rs index 60c583fd67c2e..72dd65ab3da0c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -267,7 +267,7 @@ fn define_all_allocs( let const_ = tcx.const_eval(ParamEnv::reveal_all().and(cid)).unwrap(); let alloc = match const_.val { - ConstValue::ByRef(ptr, alloc) if ptr.offset.bytes() == 0 => alloc, + ConstValue::ByRef { align: _, offset, alloc } if offset.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", const_), }; @@ -396,12 +396,12 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { _: AllocId, alloc: Cow<'b, Allocation>, _: Option>, - _: &(), + _: &Memory<'mir, 'tcx, Self>, ) -> (Cow<'b, Allocation<(), ()>>, ()) { (alloc, ()) } - fn tag_static_base_pointer(_: AllocId, _: &()) -> Self::PointerTag { + fn tag_static_base_pointer(_: AllocId, _: &Memory<'mir, 'tcx, Self>) -> Self::PointerTag { () } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 00d7cad85bbc9..24494d0f8d385 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -194,6 +194,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) { // FIXME trap on overflow let bin_op = match intrinsic { + "unchecked_sub" => BinOp::Sub, "unchecked_div" | "exact_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, "unchecked_shl" => BinOp::Shl, From 05307af6729a9df0375f063c4b2417366057e058 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 23 Jun 2019 11:22:16 +0200 Subject: [PATCH 0703/1566] Remove some unnecessary patches cc #337 --- .../0011-Workaround-for-libstd-crash.patch | 25 -------- patches/0014-Don-t-use-OS-TLS.patch | 57 ------------------- 2 files changed, 82 deletions(-) delete mode 100644 patches/0011-Workaround-for-libstd-crash.patch delete mode 100644 patches/0014-Don-t-use-OS-TLS.patch diff --git a/patches/0011-Workaround-for-libstd-crash.patch b/patches/0011-Workaround-for-libstd-crash.patch deleted file mode 100644 index 46712718decfa..0000000000000 --- a/patches/0011-Workaround-for-libstd-crash.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 2bc2ef06e118c6fba0626c0e9bf24fed873405b2 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 29 Dec 2018 12:37:34 +0100 -Subject: [PATCH] Workaround for libstd crash - -I think this is related to the use of TLS inside those functions ---- - src/libstd/rt.rs | 2 +- - 1 file changed, 1 insertions(+), 1 deletions(-) - -diff --git a/src/libstd/rt.rs b/src/libstd/rt.rs -index 5ddb66b..6a0d0b5 100644 ---- a/src/libstd/rt.rs -+++ b/src/libstd/rt.rs -@@ -51,7 +51,7 @@ fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe), - #[cfg(not(feature = "backtrace"))] - let exit_code = panic::catch_unwind(move || main()); - -- sys_common::cleanup(); -+ //sys_common::cleanup(); - exit_code.unwrap_or(101) as isize - } - } --- -2.17.2 (Apple Git-113) diff --git a/patches/0014-Don-t-use-OS-TLS.patch b/patches/0014-Don-t-use-OS-TLS.patch deleted file mode 100644 index ca28fe2fd7043..0000000000000 --- a/patches/0014-Don-t-use-OS-TLS.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 9e8b8114de61ecdbf39f7582d7a3280ef2bfd339 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sun, 23 Jun 2019 10:37:53 +0200 -Subject: [PATCH] Don't use OS TLS - ---- - src/libstd/thread/local.rs | 4 ++-- - src/libstd/thread/mod.rs | 1 - - 2 files changed, 2 insertions(+), 3 deletions(-) - -diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs -index 9b355aa..a074aa5 100644 ---- a/src/libstd/thread/local.rs -+++ b/src/libstd/thread/local.rs -@@ -154,10 +154,10 @@ macro_rules! __thread_local_inner { - fn __init() -> $t { $init } - - unsafe fn __getit() -> $crate::option::Option<&'static $t> { -- #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] - static __KEY: $crate::thread::__StaticLocalKeyInner<$t> = - $crate::thread::__StaticLocalKeyInner::new(); - -+ /* - #[thread_local] - #[cfg(all( - target_thread_local, -@@ -172,6 +172,7 @@ macro_rules! __thread_local_inner { - ))] - static __KEY: $crate::thread::__OsLocalKeyInner<$t> = - $crate::thread::__OsLocalKeyInner::new(); -+ */ - - __KEY.get(__init) - } -@@ -320,7 +321,6 @@ mod lazy { - /// On some platforms like wasm32 there's no threads, so no need to generate - /// thread locals and we can instead just use plain statics! - #[doc(hidden)] --#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] - pub mod statik { - use super::lazy::LazyKeyInner; - use crate::fmt; -diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs -index 35de4f4..f142646 100644 ---- a/src/libstd/thread/mod.rs -+++ b/src/libstd/thread/mod.rs -@@ -195,7 +195,6 @@ pub use self::local::{LocalKey, AccessError}; - // where available, but both are needed. - - #[unstable(feature = "libstd_thread_internals", issue = "0")] --#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] - #[doc(hidden)] pub use self::local::statik::Key as __StaticLocalKeyInner; - #[unstable(feature = "libstd_thread_internals", issue = "0")] - #[cfg(target_thread_local)] --- -2.20.1 (Apple Git-117) - From d7274ac5fdf84452cdfd09727e106bac2bf50e36 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 23 Jun 2019 15:14:26 +0200 Subject: [PATCH 0704/1566] Fix load and store for ByValPair values with differently sized components --- example/std_example.rs | 15 ++++++++++ src/value_and_place.rs | 62 ++++++++++++------------------------------ 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index ce74efee8a884..805a51ec219d1 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -17,6 +17,9 @@ fn main() { ONCE.call_once(|| {}); LoopState::Continue(()) == LoopState::Break(()); + + // Make sure ByValPair values with differently sized components are correctly passed + map(None::<(u8, Box)>); } #[derive(PartialEq)] @@ -24,3 +27,15 @@ enum LoopState { Continue(()), Break(()) } + +pub enum Instruction { + Increment, + Loop, +} + +fn map(a: Option<(u8, Box)>) -> Option> { + match a { + None => None, + Some((_, instr)) => Some(instr), + } +} diff --git a/src/value_and_place.rs b/src/value_and_place.rs index bf027dd3e88a6..716a81c5d8af1 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -18,6 +18,11 @@ fn codegen_field<'a, 'tcx: 'a>( } } +fn scalar_pair_calculate_b_offset(tcx: TyCtxt<'_>, a_scalar: &Scalar, b_scalar: &Scalar) -> i32 { + let b_offset = a_scalar.value.size(&tcx).align_to(b_scalar.value.align(&tcx).abi); + b_offset.bytes().try_into().unwrap() +} + /// A read-only value #[derive(Debug, Copy, Clone)] pub struct CValue<'tcx>(CValueInner, TyLayout<'tcx>); @@ -89,18 +94,19 @@ impl<'tcx> CValue<'tcx> { let layout = self.1; match self.0 { CValueInner::ByRef(addr) => { - let (a, b) = match &layout.abi { - layout::Abi::ScalarPair(a, b) => (a.clone(), b.clone()), + let (a_scalar, b_scalar) = match &layout.abi { + layout::Abi::ScalarPair(a, b) => (a, b), _ => unreachable!(), }; - let clif_ty1 = scalar_to_clif_type(fx.tcx, a.clone()); - let clif_ty2 = scalar_to_clif_type(fx.tcx, b); + let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); + let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); + let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); let val2 = fx.bcx.ins().load( clif_ty2, MemFlags::new(), addr, - a.value.size(&fx.tcx).bytes() as i32, + b_offset, ); (val1, val2) } @@ -341,13 +347,14 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } CValueInner::ByValPair(value, extra) => { match dst_layout.abi { - Abi::ScalarPair(ref a, _) => { + Abi::ScalarPair(ref a_scalar, ref b_scalar) => { + let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); fx.bcx.ins().store(MemFlags::new(), value, addr, 0); fx.bcx.ins().store( MemFlags::new(), extra, addr, - a.value.size(&fx.tcx).bytes() as u32 as i32, + b_offset, ); } _ => bug!( @@ -415,26 +422,8 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { if !inner_layout.is_unsized() { CPlace::Addr(self.to_cvalue(fx).load_scalar(fx), None, inner_layout) } else { - match self.layout().abi { - Abi::ScalarPair(ref a, ref b) => { - let addr = self.to_addr(fx); - let ptr = - fx.bcx - .ins() - .load(scalar_to_clif_type(fx.tcx, a.clone()), MemFlags::new(), addr, 0); - let extra = fx.bcx.ins().load( - scalar_to_clif_type(fx.tcx, b.clone()), - MemFlags::new(), - addr, - a.value.size(&fx.tcx).bytes() as u32 as i32, - ); - CPlace::Addr(ptr, Some(extra), inner_layout) - } - _ => bug!( - "Fat ptr doesn't have abi ScalarPair, but it has {:?}", - self.layout().abi - ), - } + let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); + CPlace::Addr(addr, Some(extra), inner_layout) } } @@ -444,23 +433,8 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { dest.write_cvalue(fx, ptr); } else { let (value, extra) = self.to_addr_maybe_unsized(fx); - - match dest.layout().abi { - Abi::ScalarPair(ref a, _) => { - let dest_addr = dest.to_addr(fx); - fx.bcx.ins().store(MemFlags::new(), value, dest_addr, 0); - fx.bcx.ins().store( - MemFlags::new(), - extra.expect("unsized type without metadata"), - dest_addr, - a.value.size(&fx.tcx).bytes() as u32 as i32, - ); - } - _ => bug!( - "Non ScalarPair abi {:?} in write_place_ref dest", - dest.layout().abi - ), - } + let ptr = CValue::by_val_pair(value, extra.expect("unsized type without metadata"), dest.layout()); + dest.write_cvalue(fx, ptr); } } From d425116bdc764bdd46bf482c91aeef38fe4480e7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 23 Jun 2019 16:33:34 +0200 Subject: [PATCH 0705/1566] Implement some intrinsics --- src/constant.rs | 2 +- src/intrinsics.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 72dd65ab3da0c..c13cc72b88d00 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -106,7 +106,7 @@ pub fn force_eval_const<'a, 'tcx: 'a>( } } -fn trans_const_value<'a, 'tcx: 'a>( +pub fn trans_const_value<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, const_: Const<'tcx>, ) -> CValue<'tcx> { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 24494d0f8d385..18a300ed12e28 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -186,11 +186,24 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; ret.write_cvalue(fx, CValue::by_val(align, usize_layout)); }; + pref_align_of, () { + let pref_align = fx.layout_of(T).align.pref.bytes(); + let pref_align = CValue::const_val(fx, usize_layout.ty, pref_align as i64); + ret.write_cvalue(fx, pref_align); + }; + + type_id, () { let type_id = fx.tcx.type_id_hash(T); let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); ret.write_cvalue(fx, type_id); }; + type_name, () { + let type_name = fx.tcx.type_name(T); + let type_name = crate::constant::trans_const_value(fx, *type_name); + ret.write_cvalue(fx, type_name); + }; + _ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) { // FIXME trap on overflow let bin_op = match intrinsic { @@ -418,6 +431,19 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( } }; + volatile_load, (c ptr) { + // Cranelift treats loads as volatile by default + let inner_layout = + fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); + let val = CValue::by_ref(ptr.load_scalar(fx), inner_layout); + ret.write_cvalue(fx, val); + }; + volatile_store, (v ptr, c val) { + // Cranelift treats stores as volatile by default + let dest = CPlace::for_addr(ptr, val.layout()); + dest.write_cvalue(fx, val); + }; + _ if intrinsic.starts_with("atomic_fence"), () {}; _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; _ if intrinsic.starts_with("atomic_load"), (c ptr) { From db5ffdedf7ed64bde30a55e14e67efbb0f6ea538 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 17 Nov 2018 18:52:47 +0100 Subject: [PATCH 0706/1566] Implement bswap intrinsic --- example/mini_core.rs | 11 ++++ example/mini_core_hello_world.rs | 5 ++ patches/0013-Patch-away-bswap-usage.patch | 25 -------- src/intrinsics.rs | 73 +++++++++++++++++++++++ 4 files changed, 89 insertions(+), 25 deletions(-) delete mode 100644 patches/0013-Patch-away-bswap-usage.patch diff --git a/example/mini_core.rs b/example/mini_core.rs index dd42257b1946f..56ab9578e7872 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -208,6 +208,16 @@ impl PartialEq for u32 { } } + +impl PartialEq for u64 { + fn eq(&self, other: &u64) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &u64) -> bool { + (*self) != (*other) + } +} + impl PartialEq for usize { fn eq(&self, other: &usize) -> bool { (*self) == (*other) @@ -375,6 +385,7 @@ pub mod intrinsics { pub fn ctlz_nonzero(x: T) -> T; pub fn needs_drop() -> bool; pub fn bitreverse(x: T) -> T; + pub fn bswap(x: T) -> T; } } diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index fdd26f8791d66..f9e820da76c12 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -139,6 +139,11 @@ fn main() { assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8); + assert_eq!(intrinsics::bswap(0xabu8), 0xabu8); + assert_eq!(intrinsics::bswap(0xddccu16), 0xccddu16); + assert_eq!(intrinsics::bswap(0xffee_ddccu32), 0xccdd_eeffu32); + assert_eq!(intrinsics::bswap(0x1234_5678_ffee_ddccu64), 0xccdd_eeff_7856_3412u64); + assert_eq!(intrinsics::size_of_val(hello) as u8, 6); let chars = &['C', 'h', 'a', 'r', 's']; diff --git a/patches/0013-Patch-away-bswap-usage.patch b/patches/0013-Patch-away-bswap-usage.patch deleted file mode 100644 index e29042c729705..0000000000000 --- a/patches/0013-Patch-away-bswap-usage.patch +++ /dev/null @@ -1,25 +0,0 @@ -From da996dae0b95f986de46a916aca00e03257ba4f9 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Wed, 30 Jan 2019 14:51:57 +0100 -Subject: [PATCH] Patch away bswap usage - ---- - src/libcore/num/mod.rs | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index f928d40..6a146f5 100644 ---- a/src/libcore/num/mod.rs -+++ b/src/libcore/num/mod.rs -@@ -2303,7 +2303,7 @@ assert_eq!(m, ", $swapped, "); - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - pub const fn swap_bytes(self) -> Self { -- intrinsics::bswap(self as $ActualT) as Self -+ 42 // bswap is unsupported by cg_clif - } - } - --- -2.11.0 - diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 18a300ed12e28..4f455454a2fd1 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -415,6 +415,79 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let res = CValue::by_val(fx.bcx.ins().bitrev(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; + bswap, (v arg) { + // FIXME(CraneStation/cranelift#794) add bswap instruction to cranelift + fn swap(bcx: &mut FunctionBuilder, v: Value) -> Value { + match bcx.func.dfg.value_type(v) { + types::I8 => v, + + // https://code.woboq.org/gcc/include/bits/byteswap.h.html + types::I16 => { + let tmp1 = bcx.ins().ishl_imm(v, 8); + let n1 = bcx.ins().band_imm(tmp1, 0xFF00); + + let tmp2 = bcx.ins().ushr_imm(v, 8); + let n2 = bcx.ins().band_imm(tmp2, 0x00FF); + + bcx.ins().bor(n1, n2) + } + types::I32 => { + let tmp1 = bcx.ins().ishl_imm(v, 24); + let n1 = bcx.ins().band_imm(tmp1, 0xFF00_0000); + + let tmp2 = bcx.ins().ishl_imm(v, 8); + let n2 = bcx.ins().band_imm(tmp2, 0x00FF_0000); + + let tmp3 = bcx.ins().ushr_imm(v, 8); + let n3 = bcx.ins().band_imm(tmp3, 0x0000_FF00); + + let tmp4 = bcx.ins().ushr_imm(v, 24); + let n4 = bcx.ins().band_imm(tmp4, 0x0000_00FF); + + let or_tmp1 = bcx.ins().bor(n1, n2); + let or_tmp2 = bcx.ins().bor(n3, n4); + bcx.ins().bor(or_tmp1, or_tmp2) + } + types::I64 => { + let tmp1 = bcx.ins().ishl_imm(v, 56); + let n1 = bcx.ins().band_imm(tmp1, 0xFF00_0000_0000_0000u64 as i64); + + let tmp2 = bcx.ins().ishl_imm(v, 40); + let n2 = bcx.ins().band_imm(tmp2, 0x00FF_0000_0000_0000u64 as i64); + + let tmp3 = bcx.ins().ishl_imm(v, 24); + let n3 = bcx.ins().band_imm(tmp3, 0x0000_FF00_0000_0000u64 as i64); + + let tmp4 = bcx.ins().ishl_imm(v, 8); + let n4 = bcx.ins().band_imm(tmp4, 0x0000_00FF_0000_0000u64 as i64); + + let tmp5 = bcx.ins().ushr_imm(v, 8); + let n5 = bcx.ins().band_imm(tmp5, 0x0000_0000_FF00_0000u64 as i64); + + let tmp6 = bcx.ins().ushr_imm(v, 24); + let n6 = bcx.ins().band_imm(tmp6, 0x0000_0000_00FF_0000u64 as i64); + + let tmp7 = bcx.ins().ushr_imm(v, 40); + let n7 = bcx.ins().band_imm(tmp7, 0x0000_0000_0000_FF00u64 as i64); + + let tmp8 = bcx.ins().ushr_imm(v, 56); + let n8 = bcx.ins().band_imm(tmp8, 0x0000_0000_0000_00FFu64 as i64); + + let or_tmp1 = bcx.ins().bor(n1, n2); + let or_tmp2 = bcx.ins().bor(n3, n4); + let or_tmp3 = bcx.ins().bor(n5, n6); + let or_tmp4 = bcx.ins().bor(n7, n8); + + let or_tmp5 = bcx.ins().bor(or_tmp1, or_tmp2); + let or_tmp6 = bcx.ins().bor(or_tmp3, or_tmp4); + bcx.ins().bor(or_tmp5, or_tmp6) + } + ty => unimplemented!("bwap {}", ty), + } + }; + let res = CValue::by_val(swap(&mut fx.bcx, arg), fx.layout_of(T)); + ret.write_cvalue(fx, res); + }; needs_drop, () { let needs_drop = if T.needs_drop(fx.tcx, ParamEnv::reveal_all()) { 1 From 83b2b0fa8b7d639b3809ed1f4bb3a06022f58514 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2019 04:58:50 +0000 Subject: [PATCH 0707/1566] Bump cranelift from `f3f7cad` to `1eb92b1` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `f3f7cad` to `1eb92b1`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/f3f7cadd0157d06089c9b5864d513a61856d0f4d...1eb92b193dcd8f137005d0dcfde972ac25a20221) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6ca7a2df9298..3fdffeaaee7c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -132,7 +132,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -162,12 +162,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -180,7 +180,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -190,7 +190,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -201,7 +201,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -211,7 +211,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#f3f7cadd0157d06089c9b5864d513a61856d0f4d" +source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", From 159c6585fe5c22d893c3ef70f737f8817e53906f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 24 Jun 2019 21:01:38 +0200 Subject: [PATCH 0708/1566] Update Cargo.lock --- Cargo.lock | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fdffeaaee7c6..874ea1c0db2d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,7 +54,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -132,7 +132,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -162,12 +162,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -180,7 +180,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -190,7 +190,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -201,7 +201,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -211,14 +211,14 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#1eb92b193dcd8f137005d0dcfde972ac25a20221" +source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "region 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -292,7 +292,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -303,7 +303,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -314,7 +314,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "flate2" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -465,7 +465,7 @@ name = "object" version = "0.12.0" source = "git+https://github.com/gimli-rs/object.git#aced06a20eb59867c88e23c03e15613ffd582618" dependencies = [ - "flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b)", "parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -653,7 +653,7 @@ dependencies = [ [[package]] name = "region" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -724,7 +724,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -742,7 +742,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -752,7 +752,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -765,7 +765,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -790,12 +790,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.36" +version = "0.15.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -810,7 +810,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -951,7 +951,7 @@ dependencies = [ "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum backtrace 0.3.30 (registry+https://github.com/rust-lang/crates.io-index)" = "ada4c783bb7e7443c14e0480f429ae2cc99da95065aeab7ee1b81ada0419404f" +"checksum backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "e0f77aa27f55a4beb477ff6bc4d9bf72f90eb422b19c1d8e5a644b8aeb674d66" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" @@ -979,7 +979,7 @@ dependencies = [ "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -"checksum flate2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f87e68aa82b2de08a6e037f1385455759df6e445a8df5e005b4297191dbf18aa" +"checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" @@ -1021,7 +1021,7 @@ dependencies = [ "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" -"checksum region 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2772cece4fbb242b13b5874e4d2f0db7ebb7ba3f34c9e1372b87dfd1f86a8f8" +"checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" @@ -1030,14 +1030,14 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" +"checksum serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)" = "960e29cf7004b3b6e65fc5002981400eb3ccc017a08a2406940823e58e7179a9" "checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fa19a5a708e22bb5be31c1b6108a2a902f909c4b9ba85cba44c06632386bc0ff" "checksum structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d59d0ae8ef8de16e49e3ca7afa16024a3e0dfd974a75ef93fdc5464e34523f" -"checksum syn 0.15.36 (registry+https://github.com/rust-lang/crates.io-index)" = "8b4f551a91e2e3848aeef8751d0d4eec9489b6474c720fd4c55958d8d31a430c" +"checksum syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)" = "37ea458a750f59ab679b47fef9b6722c586c5742f4cfe18a120bbc807e5e01fd" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" From 4e1d219f06912bf97b1d8b3592ee0f6baeb392cf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 25 Jun 2019 20:18:10 +0200 Subject: [PATCH 0709/1566] Implement some float intrinsics --- example/std_example.rs | 9 ++++++ src/intrinsics.rs | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index 805a51ec219d1..98d9ed17b0308 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -20,6 +20,15 @@ fn main() { // Make sure ByValPair values with differently sized components are correctly passed map(None::<(u8, Box)>); + + println!("{}", 2.3f32.exp()); + println!("{}", 2.3f32.exp2()); + println!("{}", 2.3f32.abs()); + println!("{}", 2.3f32.sqrt()); + println!("{}", 2.3f32.floor()); + println!("{}", 2.3f32.ceil()); + println!("{}", 2.3f32.min(1.0)); + println!("{}", 2.3f32.max(1.0)); } #[derive(PartialEq)] diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 4f455454a2fd1..f8d5c0c0da42b 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -586,6 +586,73 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("atomic_umin"), (v ptr, v src) { atomic_minmax!(fx, IntCC::UnsignedLessThan, (ptr, src) -> ret); }; + + expf32, (c flt) { + let res = fx.easy_call("expf", &[flt], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + expf64, (c flt) { + let res = fx.easy_call("exp", &[flt], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + exp2f32, (c flt) { + let res = fx.easy_call("exp2f", &[flt], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + exp2f64, (c flt) { + let res = fx.easy_call("exp2", &[flt], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + fabsf32, (c flt) { + let res = fx.easy_call("fabsf", &[flt], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + fabsf64, (c flt) { + let res = fx.easy_call("fabs", &[flt], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + sqrtf32, (c flt) { + let res = fx.easy_call("sqrtf", &[flt], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + sqrtf64, (c flt) { + let res = fx.easy_call("sqrt", &[flt], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + floorf32, (c flt) { + let res = fx.easy_call("floorf", &[flt], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + floorf64, (c flt) { + let res = fx.easy_call("floor", &[flt], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + ceilf32, (c flt) { + let res = fx.easy_call("ceilf", &[flt], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + ceilf64, (c flt) { + let res = fx.easy_call("ceil", &[flt], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + + minnumf32, (c a, c b) { + let res = fx.easy_call("fminf", &[a, b], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + minnumf64, (c a, c b) { + let res = fx.easy_call("fmin", &[a, b], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + maxnumf32, (c a, c b) { + let res = fx.easy_call("fmaxf", &[a, b], fx.tcx.types.f32); + ret.write_cvalue(fx, res); + }; + maxnumf64, (c a, c b) { + let res = fx.easy_call("fmax", &[a, b], fx.tcx.types.f64); + ret.write_cvalue(fx, res); + }; + } if let Some((_, dest)) = destination { From c453b83f2b15e664037324d37377ab0e9b5c380d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Jun 2019 11:16:55 +0200 Subject: [PATCH 0710/1566] Rustup to rustc 1.37.0-nightly (433a46781 2019-06-28) --- patches/0015-Remove-usage-of-unsized-locals.patch | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch index da75a44fa3b93..5d7a780d32971 100644 --- a/patches/0015-Remove-usage-of-unsized-locals.patch +++ b/patches/0015-Remove-usage-of-unsized-locals.patch @@ -41,9 +41,9 @@ index f6dee7c..0c6a8c0 100644 - } -} - - /// `FnBox` is deprecated and will be removed. - /// `Box` can be called directly, since Rust 1.35.0. - /// + #[unstable(feature = "coerce_unsized", issue = "27732")] + impl, U: ?Sized> CoerceUnsized> for Box {} + diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs index 1181b86..20f9251 100644 --- a/src/libstd/sys_common/at_exit_imp.rs @@ -96,4 +96,3 @@ index b2142e7..718bb1c 100644 pub fn min_stack() -> usize { -- 2.20.1 (Apple Git-117) - From 91b058de9409569a07e92ae36380b41a9c1b4ec1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 3 Jul 2019 16:27:06 +0200 Subject: [PATCH 0711/1566] [CI] Only cache .cargo dir --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f32a95d2d46fb..17bcefde38b36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ sudo: false language: rust -cache: cargo +cache: + directories: + - $HOME/.cargo os: - linux From c2e68223428b061410ace1bde16b0feb5a707d5f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 3 Jul 2019 16:49:42 +0200 Subject: [PATCH 0712/1566] Rustup to rustc 1.37.0-nightly (0beb2ba16 2019-07-02) Also removes some unnecessary errors. --- src/lib.rs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0d7cab1f8e341..0a59395539859 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,31 +153,7 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { struct CraneliftCodegenBackend; impl CodegenBackend for CraneliftCodegenBackend { - fn init(&self, sess: &Session) { - for cty in sess.opts.crate_types.iter() { - match *cty { - CrateType::Rlib | CrateType::Dylib | CrateType::Executable => {} - _ => { - sess.warn(&format!( - "Rustc codegen cranelift doesn't support output type {}", - cty - )); - } - } - } - match sess.lto() { - Lto::Fat | Lto::Thin | Lto::ThinLocal => { - sess.warn("Rustc codegen cranelift doesn't support lto"); - } - Lto::No => {} - } - if sess.opts.cg.rpath { - sess.err("rpath is not yet supported"); - } - if sess.opts.debugging_opts.pgo_gen.enabled() { - sess.err("pgo is not supported"); - } - } + fn init(&self, _sess: &Session) {} fn metadata_loader(&self) -> Box { Box::new(crate::metadata::CraneliftMetadataLoader) From 058dc13829ac085e37949fc7f1341eee38e76add Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2019 15:38:07 +0000 Subject: [PATCH 0713/1566] Bump cranelift-faerie from `3317fc6` to `312516a` Bumps [cranelift-faerie](https://github.com/CraneStation/cranelift) from `3317fc6` to `312516a`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/3317fc623c315073710fc1ed67c2d17d2466ab5d...312516a69da03dc06eace32f61412389a8dcadf3) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 113 +++++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 874ea1c0db2d7..322c443fdb873 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,29 +122,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -153,69 +153,69 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" [[package]] name = "cranelift-faerie" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.0 (git+https://github.com/m4b/faerie.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#3317fc623c315073710fc1ed67c2d17d2466ab5d" +version = "0.32.0" +source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" dependencies = [ - "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -365,6 +365,16 @@ dependencies = [ "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "goblin" +version = "0.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "heck" version = "0.3.1" @@ -682,10 +692,10 @@ dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.0 (git+https://github.com/m4b/faerie.git)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -960,16 +970,16 @@ dependencies = [ "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cranelift 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.30.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" @@ -985,6 +995,7 @@ dependencies = [ "checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9" "checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b)" = "" +"checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" From 69591844bbcf9930695913ea35a0b009bae5c2be Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 4 Jul 2019 18:02:47 +0200 Subject: [PATCH 0714/1566] Update Cargo.lock --- Cargo.lock | 397 ++++++++++++++++++++++------------------------------- 1 file changed, 164 insertions(+), 233 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 322c443fdb873..af4a29197373e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "aho-corasick" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -54,11 +54,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -66,7 +65,7 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,14 +78,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "build_const" -version = "0.2.1" +name = "byteorder" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "byteorder" -version = "1.3.2" +name = "c2-chacha" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cc" @@ -112,39 +115,31 @@ dependencies = [ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cranelift" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-bforest 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -153,25 +148,25 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" [[package]] name = "cranelift-faerie" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (git+https://github.com/m4b/faerie.git)", + "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -179,43 +174,43 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.32.0" -source = "git+https://github.com/CraneStation/cranelift.git#312516a69da03dc06eace32f61412389a8dcadf3" +version = "0.33.0" +source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" dependencies = [ - "cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -223,14 +218,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "crc" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crc32fast" version = "1.2.0" @@ -241,7 +228,7 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -272,18 +259,18 @@ dependencies = [ [[package]] name = "faerie" -version = "0.10.0" -source = "git+https://github.com/m4b/faerie.git#f6ce890950950d9ee85b7cb5de5fff9c9291f194" +version = "0.10.1" +source = "git+https://github.com/m4b/faerie.git#926b3765b8f3751fb17f26321626b41b30b894e2" dependencies = [ - "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -292,7 +279,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -303,7 +290,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -320,18 +307,22 @@ dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "fuchsia-cprng" -version = "0.1.1" +name = "gcc" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "gcc" -version = "0.3.55" +name = "getrandom" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "gimli" @@ -347,8 +338,8 @@ dependencies = [ [[package]] name = "goblin" -version = "0.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.0.22" +source = "git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83#e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -358,7 +349,7 @@ dependencies = [ [[package]] name = "goblin" version = "0.0.22" -source = "git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b#f34cf128fb4d1f3c93e5cf129cf673c9d787217b" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -367,7 +358,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.0.22" +version = "0.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -405,6 +396,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "libc" @@ -443,7 +437,7 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -451,13 +445,13 @@ dependencies = [ [[package]] name = "miniz_oxide_c_api" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -473,10 +467,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" version = "0.12.0" -source = "git+https://github.com/gimli-rs/object.git#aced06a20eb59867c88e23c03e15613ffd582618" +source = "git+https://github.com/gimli-rs/object.git#79ce87e3fd25ef385326655c5ad151e03d456b0a" dependencies = [ "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b)", + "goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)", "parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -493,6 +487,11 @@ name = "plain" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -516,98 +515,40 @@ dependencies = [ [[package]] name = "rand" -version = "0.6.5" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_chacha" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.3.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -620,17 +561,9 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "redox_syscall" -version = "0.1.54" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -638,7 +571,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -646,7 +579,7 @@ name = "regex" version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -692,17 +625,17 @@ dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.32.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.10.0 (git+https://github.com/m4b/faerie.git)", + "cranelift 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -715,7 +648,7 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -734,7 +667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -752,19 +685,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "spin" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -775,7 +713,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -785,27 +723,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.38" +version = "0.15.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -820,7 +758,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -831,18 +769,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tempfile" -version = "3.0.8" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -862,7 +800,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -955,47 +893,45 @@ dependencies = [ [metadata] "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" -"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" +"checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum backtrace 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "e0f77aa27f55a4beb477ff6bc4d9bf72f90eb422b19c1d8e5a644b8aeb674d66" -"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" +"checksum backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "18b50f5258d1a9ad8396d2d345827875de4261b158124d4c819d9b351454fae5" +"checksum backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" -"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cranelift 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.32.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +"checksum cranelift 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" +"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.10.0 (git+https://github.com/m4b/faerie.git)" = "" +"checksum faerie 0.10.1 (git+https://github.com/m4b/faerie.git)" = "" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" -"checksum goblin 0.0.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6a4013e9182f2345c6b7829b9ef6e670bce0dfca12c6f974457ed2160c2c7fe9" -"checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=f34cf128fb4d1f3c93e5cf129cf673c9d787217b)" = "" +"checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)" = "" "checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" +"checksum goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ac56b4753b6b8c2e052ca30717e5a09acf1b02a2c1681bf3d883bd660e5d22bd" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" @@ -1006,29 +942,23 @@ dependencies = [ "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c468f2369f07d651a5d0bb2c9079f8488a66d5466efe42d0c5c6466edcb7f71e" -"checksum miniz_oxide_c_api 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fe927a42e3807ef71defb191dc87d4e24479b221e67015fe38ae2b7b447bab" +"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d" +"checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum object 0.12.0 (git+https://github.com/gimli-rs/object.git)" = "" "checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" -"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" +"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" +"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" "checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" @@ -1036,22 +966,23 @@ dependencies = [ "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.93 (registry+https://github.com/rust-lang/crates.io-index)" = "960e29cf7004b3b6e65fc5002981400eb3ccc017a08a2406940823e58e7179a9" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" +"checksum serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "076a696fdea89c19d3baed462576b8f6d663064414b5c793642da8dfeb99475b" +"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum structopt 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fa19a5a708e22bb5be31c1b6108a2a902f909c4b9ba85cba44c06632386bc0ff" -"checksum structopt-derive 0.2.16 (registry+https://github.com/rust-lang/crates.io-index)" = "c6d59d0ae8ef8de16e49e3ca7afa16024a3e0dfd974a75ef93fdc5464e34523f" -"checksum syn 0.15.38 (registry+https://github.com/rust-lang/crates.io-index)" = "37ea458a750f59ab679b47fef9b6722c586c5742f4cfe18a120bbc807e5e01fd" +"checksum structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" +"checksum structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" +"checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" -"checksum tempfile 3.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7dc4738f2e68ed2855de5ac9cdbe05c9216773ecde4739b2f095002ab03a13ef" +"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" From b82472184d12235e971ab1b62e527aa62d15d141 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 7 Jul 2019 11:59:11 +0200 Subject: [PATCH 0715/1566] Rustup to rustc 1.38.0-nightly (dfd52ba6a 2019-07-06) --- build_sysroot/alloc_system/lib.rs | 1 - example/example.rs | 4 --- example/mini_core.rs | 8 ++++-- example/mini_core_hello_world.rs | 4 +-- src/constant.rs | 41 ++++++++++++++++++++----------- src/intrinsics.rs | 10 -------- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index 74b52a6497e17..a942fa8d95e49 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -23,7 +23,6 @@ feature(integer_atomics, stdsimd) )] #![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] -#![rustc_alloc_kind = "lib"] // The minimum alignment guaranteed by the architecture. This value is used to // add fast paths for low alignment values. #[cfg(all(any(target_arch = "x86", diff --git a/example/example.rs b/example/example.rs index d7fbb932240e2..e8ddc4aaea145 100644 --- a/example/example.rs +++ b/example/example.rs @@ -137,10 +137,6 @@ unsafe fn transmute(c: char) -> u32 { intrinsics::transmute(c) } -unsafe fn call_uninit() -> u8 { - intrinsics::uninit() -} - unsafe fn deref_str_ptr(s: *const str) -> &'static str { &*s } diff --git a/example/mini_core.rs b/example/mini_core.rs index 56ab9578e7872..d900776c55cc8 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,4 +1,4 @@ -#![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types)] +#![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, untagged_unions)] #![no_core] #![allow(dead_code)] @@ -371,6 +371,11 @@ pub trait Drop { fn drop(&mut self); } +pub union MaybeUninit { + pub uninit: (), + pub value: T, +} + pub mod intrinsics { extern "rust-intrinsic" { pub fn abort() -> !; @@ -380,7 +385,6 @@ pub mod intrinsics { pub fn min_align_of_val(val: &T) -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; - pub fn uninit() -> T; pub fn init() -> T; pub fn ctlz_nonzero(x: T) -> T; pub fn needs_drop() -> bool; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index f9e820da76c12..e51f257f6b46a 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -181,15 +181,15 @@ fn main() { } unsafe fn uninitialized() -> T { - intrinsics::uninit::() + MaybeUninit { uninit: () }.value } + zeroed::<(u8, u8)>(); #[allow(unreachable_code)] { if false { zeroed::(); zeroed::(); - zeroed::<(u8, u8)>(); uninitialized::(); } } diff --git a/src/constant.rs b/src/constant.rs index c13cc72b88d00..94007c83587c6 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::Const; use rustc_mir::interpret::{ - InterpretCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, + InterpCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, StackPopCleanup, }; @@ -141,10 +141,11 @@ fn trans_const_place<'a, 'tcx: 'a>( ) -> CPlace<'tcx> { // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 let result = || -> InterpResult<'tcx, &'tcx Allocation> { - let mut ecx = InterpretCx::new( + let mut ecx = InterpCx::new( fx.tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all(), TransPlaceInterpreter, + (), ); ecx.push_stack_frame( fx.instance, @@ -242,7 +243,7 @@ fn define_all_allocs( module: &mut Module, cx: &mut ConstantCx, ) { - let memory = Memory::::new(tcx.at(DUMMY_SP)); + let memory = Memory::::new(tcx.at(DUMMY_SP), ()); while let Some(todo_item) = pop_set(&mut cx.todo) { let (data_id, alloc) = match todo_item { @@ -338,23 +339,25 @@ struct TransPlaceInterpreter; impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { type MemoryKinds = !; + type ExtraFnVal = !; type PointerTag = (); type AllocExtra = (); type MemoryExtra = (); type FrameExtra = (); type MemoryMap = FxHashMap, Allocation<()>)>; + const STATIC_KIND: Option = None; - fn enforce_validity(_: &InterpretCx<'mir, 'tcx, Self>) -> bool { + fn enforce_validity(_: &InterpCx<'mir, 'tcx, Self>) -> bool { false } - fn before_terminator(_: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { + fn before_terminator(_: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { panic!(); } fn find_fn( - _: &mut InterpretCx<'mir, 'tcx, Self>, + _: &mut InterpCx<'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: Option>, @@ -364,7 +367,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { } fn call_intrinsic( - _: &mut InterpretCx<'mir, 'tcx, Self>, + _: &mut InterpCx<'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: PlaceTy<'tcx>, @@ -373,14 +376,14 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { } fn find_foreign_static( + _: TyCtxt<'tcx>, _: DefId, - _: ::rustc::ty::query::TyCtxtAt<'tcx>, ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } fn ptr_op( - _: &InterpretCx<'mir, 'tcx, Self>, + _: &InterpCx<'mir, 'tcx, Self>, _: mir::BinOp, _: ImmTy<'tcx>, _: ImmTy<'tcx>, @@ -388,28 +391,38 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn box_alloc(_: &mut InterpretCx<'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { + fn box_alloc(_: &mut InterpCx<'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { panic!(); } fn tag_allocation<'b>( + _: &(), _: AllocId, alloc: Cow<'b, Allocation>, _: Option>, - _: &Memory<'mir, 'tcx, Self>, ) -> (Cow<'b, Allocation<(), ()>>, ()) { (alloc, ()) } - fn tag_static_base_pointer(_: AllocId, _: &Memory<'mir, 'tcx, Self>) -> Self::PointerTag { + fn tag_static_base_pointer(_: &(), _: AllocId) -> Self::PointerTag { () } - fn stack_push(_: &mut InterpretCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { + fn call_extra_fn( + _: &mut InterpCx<'mir, 'tcx, Self>, + _: !, + _: &[OpTy<'tcx, ()>], + _: Option>, + _: Option, + ) -> InterpResult<'tcx> { + unreachable!(); + } + + fn stack_push(_: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { Ok(()) } - fn stack_pop(_: &mut InterpretCx<'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> { + fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> { Ok(()) } } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index f8d5c0c0da42b..fbdbf927e2d8e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -389,16 +389,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let dst_ptr = dst.load_scalar(fx); fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); }; - uninit, () { - if ret.layout().abi == Abi::Uninhabited { - crate::trap::trap_panic(fx, "[panic] Called intrinsic::uninit for uninhabited type."); - return; - } - - let uninit_place = CPlace::new_stack_slot(fx, T); - let uninit_val = uninit_place.to_cvalue(fx); - ret.write_cvalue(fx, uninit_val); - }; ctlz | ctlz_nonzero, (v arg) { let res = CValue::by_val(fx.bcx.ins().clz(arg), fx.layout_of(T)); ret.write_cvalue(fx, res); From 624d6849baf130859d9f36256ab9f1e9b77e2560 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2019 04:52:42 +0000 Subject: [PATCH 0716/1566] Bump cranelift from `00ac8be` to `1ba2b65` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `00ac8be` to `1ba2b65`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/00ac8be2fecbef3bb59d845a83123126e8317113...1ba2b6536c1d2f9834825bda0c64e084b0f03d47) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af4a29197373e..30ce8335bcd0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,7 +118,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-bforest 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -149,7 +149,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -157,12 +157,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" [[package]] name = "cranelift-faerie" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -185,7 +185,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -196,7 +196,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,7 +206,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#00ac8be2fecbef3bb59d845a83123126e8317113" +source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", From d0db8f0cac6e424578ae472a9a5fd54205318ac3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 8 Jul 2019 09:54:18 +0200 Subject: [PATCH 0717/1566] Rustup --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 0a59395539859..9e31d026cc460 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ extern crate rustc_allocator; extern crate rustc_codegen_ssa; extern crate rustc_codegen_utils; extern crate rustc_data_structures; +extern crate rustc_driver; extern crate rustc_fs_util; extern crate rustc_incremental; extern crate rustc_mir; From 55b99230d6c0bcc2edb0a3dd0beb236673257e17 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2019 09:42:03 +0200 Subject: [PATCH 0718/1566] Bump cranelift-module from `1ba2b65` to `4125d47` (#636) Bumps [cranelift-module](https://github.com/CraneStation/cranelift) from `1ba2b65` to `4125d47`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/1ba2b6536c1d2f9834825bda0c64e084b0f03d47...4125d47d692813a1ddfc66dd2ef87243df86f697) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30ce8335bcd0e..c28b6fd70a60f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,7 +118,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-bforest 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -149,7 +149,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -157,12 +157,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" [[package]] name = "cranelift-faerie" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -175,7 +175,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -185,7 +185,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -196,7 +196,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,7 +206,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#1ba2b6536c1d2f9834825bda0c64e084b0f03d47" +source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" dependencies = [ "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", From 02eeaad10a68a8a452a6b96de8579e9d2ab7669d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 13 Jul 2019 11:07:07 +0200 Subject: [PATCH 0719/1566] Rustup to rustc 1.38.0-nightly (71f9384e3 2019-07-12) --- src/constant.rs | 16 ++++++++-------- src/intrinsics.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 94007c83587c6..9a2b0cf3688b1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -65,7 +65,7 @@ pub fn trans_promoted<'a, 'tcx: 'a>( })) { Ok(const_) => { - let cplace = trans_const_place(fx, *const_); + let cplace = trans_const_place(fx, const_); debug_assert_eq!(cplace.layout(), fx.layout_of(dest_ty)); cplace } @@ -90,7 +90,7 @@ pub fn trans_constant<'a, 'tcx: 'a>( pub fn force_eval_const<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const, -) -> Const<'tcx> { +) -> &'tcx Const<'tcx> { match const_.val { ConstValue::Unevaluated(def_id, ref substs) => { let param_env = ParamEnv::reveal_all(); @@ -100,15 +100,15 @@ pub fn force_eval_const<'a, 'tcx: 'a>( instance, promoted: None, }; - *fx.tcx.const_eval(param_env.and(cid)).unwrap() + fx.tcx.const_eval(param_env.and(cid)).unwrap() } - _ => *fx.monomorphize(&const_), + _ => fx.monomorphize(&const_), } } pub fn trans_const_value<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - const_: Const<'tcx>, + const_: &'tcx Const<'tcx>, ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); @@ -137,7 +137,7 @@ pub fn trans_const_value<'a, 'tcx: 'a>( fn trans_const_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - const_: Const<'tcx>, + const_: &'tcx Const<'tcx>, ) -> CPlace<'tcx> { // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 let result = || -> InterpResult<'tcx, &'tcx Allocation> { @@ -160,13 +160,13 @@ fn trans_const_place<'a, 'tcx: 'a>( span: DUMMY_SP, ty: const_.ty, user_ty: None, - literal: fx.tcx.mk_const(const_), + literal: const_, })), None, )?; let ptr = ecx.allocate(op.layout, MemoryKind::Stack); ecx.copy_op(op, ptr.into())?; - let alloc = ecx.memory().get(ptr.to_ptr()?.alloc_id)?; + let alloc = ecx.memory().get(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) }; let alloc = result().expect("unable to convert ConstValue to Allocation"); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index fbdbf927e2d8e..08a829ff1da19 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -200,7 +200,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; type_name, () { let type_name = fx.tcx.type_name(T); - let type_name = crate::constant::trans_const_value(fx, *type_name); + let type_name = crate::constant::trans_const_value(fx, type_name); ret.write_cvalue(fx, type_name); }; From 521b06a7123cf8ff4538ee8f67918e244fa3a21d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 13 Jul 2019 13:31:30 +0200 Subject: [PATCH 0720/1566] Update cranelift --- Cargo.lock | 100 ++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c28b6fd70a60f..3a3148553f68b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,29 +117,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-bforest 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -148,24 +148,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" [[package]] name = "cranelift-faerie" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -174,43 +174,43 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.33.0" -source = "git+https://github.com/CraneStation/cranelift.git#4125d47d692813a1ddfc66dd2ef87243df86f697" +version = "0.35.0" +source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ - "cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -625,10 +625,10 @@ dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.33.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -907,16 +907,16 @@ dependencies = [ "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum cranelift 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.33.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" From 2c9139d51e079a02ae8d6dd7a37b04b10c2fff25 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 13 Jul 2019 13:36:13 +0200 Subject: [PATCH 0721/1566] Update Cargo.lock --- Cargo.lock | 138 +++++++++++++++++++++-------------------------------- 1 file changed, 55 insertions(+), 83 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a3148553f68b..f5d0abec0dcae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ name = "aho-corasick" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -31,7 +31,7 @@ dependencies = [ [[package]] name = "arrayvec" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -39,11 +39,10 @@ dependencies = [ [[package]] name = "atty" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -59,7 +58,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -69,7 +68,7 @@ version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -107,7 +106,7 @@ version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -142,7 +141,7 @@ dependencies = [ "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -178,7 +177,7 @@ version = "0.35.0" source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" dependencies = [ "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -190,7 +189,7 @@ dependencies = [ "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -212,7 +211,7 @@ dependencies = [ "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -231,10 +230,10 @@ name = "env_logger" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -244,7 +243,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -254,7 +253,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -266,7 +265,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -289,7 +288,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -305,7 +304,7 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -321,15 +320,15 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "gimli" -version = "0.18.0" -source = "git+https://github.com/gimli-rs/gimli.git#2d8c8e200a3cac9fb649e7ed77c621168cb91d8d" +version = "0.19.0" +source = "git+https://github.com/gimli-rs/gimli.git#91e38653f2f4d615d7acc5da1df2fcbec0b50eb0" dependencies = [ - "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -341,7 +340,7 @@ name = "goblin" version = "0.0.22" source = "git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83#e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -351,7 +350,7 @@ name = "goblin" version = "0.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -361,7 +360,7 @@ name = "goblin" version = "0.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -402,12 +401,12 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.58" +version = "0.2.59" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -418,12 +417,12 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -432,7 +431,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -450,7 +449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -459,11 +458,6 @@ name = "nodrop" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "numtoa" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "object" version = "0.12.0" @@ -507,7 +501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.6.12" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -519,7 +513,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -566,29 +560,21 @@ name = "redox_syscall" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "regex" -version = "1.1.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -600,7 +586,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -630,9 +616,9 @@ dependencies = [ "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", - "gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)", + "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -666,7 +652,7 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -737,7 +723,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -747,7 +733,7 @@ version = "0.15.39" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -757,7 +743,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -778,7 +764,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -793,17 +779,6 @@ dependencies = [ "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "termion" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -896,8 +871,8 @@ dependencies = [ "checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" -"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" -"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" +"checksum atty 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ecaaea69f52b3b18633611ec0007d188517d0366f47ff703d400fa6879d6f8d5" "checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" "checksum backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "18b50f5258d1a9ad8396d2d345827875de4261b158124d4c819d9b351454fae5" "checksum backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" @@ -928,7 +903,7 @@ dependencies = [ "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" -"checksum gimli 0.18.0 (git+https://github.com/gimli-rs/gimli.git)" = "" +"checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)" = "" "checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" "checksum goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ac56b4753b6b8c2e052ca30717e5a09acf1b02a2c1681bf3d883bd660e5d22bd" @@ -937,31 +912,29 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +"checksum libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "3262021842bf00fe07dbd6cf34ff25c99d7a7ebef8deea84db72be3ea3bb0aff" +"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" +"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d" "checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" "checksum object 0.12.0 (git+https://github.com/gimli-rs/object.git)" = "" "checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" +"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0b2f0808e7d7e4fb1cb07feb6ff2f4bc827938f24f8c2e6a3beb7370af544bdd" -"checksum regex-syntax 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d76410686f9e3a17f06128962e0ecc5755870bb890c34820c7af7f1db2e1d48" +"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" +"checksum regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9b01330cce219c1c6b2e209e5ed64ccd587ae5c67bed91c0b49eecf02ae40e21" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" @@ -984,7 +957,6 @@ dependencies = [ "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" -"checksum termion 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a8fb22f7cde82c8220e5aeacb3258ed7ce996142c77cba193f203515e26c330" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" From 94effb972fa80c89a7d3cf2e209b84b2f301ce3a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jul 2019 13:04:02 +0200 Subject: [PATCH 0722/1566] Rustup to rustc 1.38.0-nightly (e3cebcb3b 2019-07-19) --- build_sysroot/Cargo.toml | 4 ++++ patches/0001-Disable-stdsimd.patch | 4 ++-- src/unsize.rs | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 648a407984ca5..45484027edc37 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -18,3 +18,7 @@ compiler_builtins = { path = "./compiler_builtins" } [profile.release] debug = true + +[profile.dev] +# FIXME correctly align constants, so that copy_nonoverlapping doesn't complain about alignment +debug-assertions = false diff --git a/patches/0001-Disable-stdsimd.patch b/patches/0001-Disable-stdsimd.patch index 343b618be73c3..7fb003d199e07 100644 --- a/patches/0001-Disable-stdsimd.patch +++ b/patches/0001-Disable-stdsimd.patch @@ -18,7 +18,7 @@ index f2165c6..cdb42c1 100644 +/* // Pull in the `core_arch` crate directly into libcore. The contents of - // `core_arch` are in a different repository: rust-lang-nursery/stdsimd. + // `core_arch` are in a different repository: rust-lang/stdarch. // @@ -235,3 +236,4 @@ mod core_arch; @@ -53,7 +53,7 @@ index 6dd3a6c..c7401e2 100644 +/* // Pull in the `std_detect` crate directly into libstd. The contents of - // `std_detect` are in a different repository: rust-lang-nursery/stdsimd. + // `std_detect` are in a different repository: rust-lang/stdarch. // @@ -505,6 +502,7 @@ mod std_detect; #[unstable(feature = "stdsimd", issue = "48556")] diff --git a/src/unsize.rs b/src/unsize.rs index 57399e10b7ab9..8f8f9116f597c 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -14,7 +14,8 @@ pub fn unsized_info<'a, 'tcx: 'a>( target: Ty<'tcx>, old_info: Option, ) -> Value { - let (source, target) = fx.tcx.struct_lockstep_tails(source, target); + let (source, target) = + fx.tcx.struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); match (&source.sty, &target.sty) { (&ty::Array(_, len), &ty::Slice(_)) => fx .bcx From 8c2577c74731688ccc2d59ed92e8d334735c673c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jul 2019 15:33:57 +0200 Subject: [PATCH 0723/1566] Don't disable stdsimd anymore This doesn't enable simd support. Actually using the functions will result in a compilation error. --- patches/0001-Disable-stdsimd.patch | 67 -------------- src/base.rs | 53 ++++++++++- src/lib.rs | 17 +++- src/target_features_whitelist.rs | 142 +++++++++++++++++++++++++++++ src/trap.rs | 24 ++++- 5 files changed, 230 insertions(+), 73 deletions(-) delete mode 100644 patches/0001-Disable-stdsimd.patch create mode 100644 src/target_features_whitelist.rs diff --git a/patches/0001-Disable-stdsimd.patch b/patches/0001-Disable-stdsimd.patch deleted file mode 100644 index 7fb003d199e07..0000000000000 --- a/patches/0001-Disable-stdsimd.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 95157a64120faffebc2cc67baf65f45f992e167e Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sun, 24 Feb 2019 11:27:11 +0100 -Subject: [PATCH] Disable stdsimd - ---- - src/libcore/lib.rs | 2 ++ - src/libstd/lib.rs | 6 ++---- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs -index f2165c6..cdb42c1 100644 ---- a/src/libcore/lib.rs -+++ b/src/libcore/lib.rs -@@ -222,6 +222,7 @@ pub mod alloc; - mod tuple; - mod unit; - -+/* - // Pull in the `core_arch` crate directly into libcore. The contents of - // `core_arch` are in a different repository: rust-lang/stdarch. - // -@@ -235,3 +236,4 @@ mod core_arch; - - #[stable(feature = "simd_arch", since = "1.27.0")] - pub use core_arch::arch; -+*/ -diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs -index 6dd3a6c..c7401e2 100644 ---- a/src/libstd/lib.rs -+++ b/src/libstd/lib.rs -@@ -291,7 +291,6 @@ - #![feature(slice_patterns)] - #![feature(staged_api)] - #![feature(std_internals)] --#![feature(stdsimd)] - #![feature(stmt_expr_attributes)] - #![feature(str_internals)] - #![feature(thread_local)] -@@ -357,9 +356,6 @@ pub mod prelude; - // Public module declarations and re-exports - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::any; --#[stable(feature = "simd_arch", since = "1.27.0")] --#[doc(no_inline)] --pub use core::arch; - #[stable(feature = "rust1", since = "1.0.0")] - pub use core::cell; - #[stable(feature = "rust1", since = "1.0.0")] -@@ -489,6 +485,7 @@ mod memchr; - // compiler - pub mod rt; - -+/* - // Pull in the `std_detect` crate directly into libstd. The contents of - // `std_detect` are in a different repository: rust-lang/stdarch. - // -@@ -505,6 +502,7 @@ mod std_detect; - #[unstable(feature = "stdsimd", issue = "48556")] - #[cfg(not(test))] - pub use std_detect::detect; -+*/ - - // Include a number of private modules that exist solely to provide - // the rustdoc documentation for primitive types. Using `include!` --- -2.17.2 (Apple Git-113) diff --git a/src/base.rs b/src/base.rs index 0dc4752abba9e..0566170bba1d8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -656,7 +656,58 @@ fn trans_stmt<'a, 'tcx: 'a>( | StatementKind::Retag { .. } | StatementKind::AscribeUserType(..) => {} - StatementKind::InlineAsm { .. } => unimpl!("Inline assembly is not supported"), + StatementKind::InlineAsm(asm) => { + use syntax::ast::Name; + let InlineAsm { asm, outputs: _, inputs: _ } = &**asm; + let rustc::hir::InlineAsm { + asm: asm_code, // Name + outputs, // Vec + inputs, // Vec + clobbers, // Vec + volatile, // bool + alignstack, // bool + dialect, // syntax::ast::AsmDialect + asm_str_style: _, + ctxt: _, + } = asm; + match &*asm_code.as_str() { + "cpuid" | "cpuid\n" => { + assert_eq!(inputs, &[Name::intern("{eax}"), Name::intern("{ecx}")]); + + assert_eq!(outputs.len(), 4); + for (i, c) in (&["={eax}", "={ebx}", "={ecx}", "={edx}"]).iter().enumerate() { + assert_eq!(&outputs[i].constraint.as_str(), c); + assert!(!outputs[i].is_rw); + assert!(!outputs[i].is_indirect); + } + + assert_eq!(clobbers, &[Name::intern("rbx")]); + + assert!(!volatile); + assert!(!alignstack); + + crate::trap::trap_unimplemented(fx, "__cpuid_count arch intrinsic is not supported"); + } + "xgetbv" => { + assert_eq!(inputs, &[Name::intern("{ecx}")]); + + assert_eq!(outputs.len(), 2); + for (i, c) in (&["={eax}", "={edx}"]).iter().enumerate() { + assert_eq!(&outputs[i].constraint.as_str(), c); + assert!(!outputs[i].is_rw); + assert!(!outputs[i].is_indirect); + } + + assert_eq!(clobbers, &[]); + + assert!(!volatile); + assert!(!alignstack); + + crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); + } + _ => unimpl!("Inline assembly is not supported"), + } + } } } diff --git a/src/lib.rs b/src/lib.rs index 9e31d026cc460..c6f77954a869f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,6 +43,7 @@ mod linkage; mod main_shim; mod metadata; mod pretty_clif; +mod target_features_whitelist; mod trap; mod unimpl; mod unsize; @@ -164,7 +165,21 @@ impl CodegenBackend for CraneliftCodegenBackend { rustc_codegen_utils::symbol_names::provide(providers); rustc_codegen_ssa::back::symbol_export::provide(providers); - providers.target_features_whitelist = |tcx, _cnum| tcx.arena.alloc(FxHashMap::default()); + providers.target_features_whitelist = |tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + if tcx.sess.opts.actually_rustdoc { + // rustdoc needs to be able to document functions that use all the features, so + // whitelist them all + tcx.arena.alloc(target_features_whitelist::all_known_features() + .map(|(a, b)| (a.to_string(), b)) + .collect()) + } else { + tcx.arena.alloc(target_features_whitelist::target_feature_whitelist(tcx.sess) + .iter() + .map(|&(a, b)| (a.to_string(), b)) + .collect()) + } + }; } fn provide_extern(&self, providers: &mut Providers) { rustc_codegen_ssa::back::symbol_export::provide_extern(providers); diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs new file mode 100644 index 0000000000000..8049b615be227 --- /dev/null +++ b/src/target_features_whitelist.rs @@ -0,0 +1,142 @@ +use syntax::symbol::{sym, Symbol}; + +use rustc::session::Session; + +// Copied from https://github.com/rust-lang/rust/blob/f69b07144a151f46aaee1b6230ba4160e9394562/src/librustc_codegen_llvm/llvm_util.rs#L93-L264 + +// WARNING: the features after applying `to_llvm_feature` must be known +// to LLVM or the feature detection code will walk past the end of the feature +// array, leading to crashes. + +const ARM_WHITELIST: &[(&str, Option)] = &[ + ("aclass", Some(sym::arm_target_feature)), + ("mclass", Some(sym::arm_target_feature)), + ("rclass", Some(sym::arm_target_feature)), + ("dsp", Some(sym::arm_target_feature)), + ("neon", Some(sym::arm_target_feature)), + ("v5te", Some(sym::arm_target_feature)), + ("v6", Some(sym::arm_target_feature)), + ("v6k", Some(sym::arm_target_feature)), + ("v6t2", Some(sym::arm_target_feature)), + ("v7", Some(sym::arm_target_feature)), + ("v8", Some(sym::arm_target_feature)), + ("vfp2", Some(sym::arm_target_feature)), + ("vfp3", Some(sym::arm_target_feature)), + ("vfp4", Some(sym::arm_target_feature)), +]; + +const AARCH64_WHITELIST: &[(&str, Option)] = &[ + ("fp", Some(sym::aarch64_target_feature)), + ("neon", Some(sym::aarch64_target_feature)), + ("sve", Some(sym::aarch64_target_feature)), + ("crc", Some(sym::aarch64_target_feature)), + ("crypto", Some(sym::aarch64_target_feature)), + ("ras", Some(sym::aarch64_target_feature)), + ("lse", Some(sym::aarch64_target_feature)), + ("rdm", Some(sym::aarch64_target_feature)), + ("fp16", Some(sym::aarch64_target_feature)), + ("rcpc", Some(sym::aarch64_target_feature)), + ("dotprod", Some(sym::aarch64_target_feature)), + ("v8.1a", Some(sym::aarch64_target_feature)), + ("v8.2a", Some(sym::aarch64_target_feature)), + ("v8.3a", Some(sym::aarch64_target_feature)), +]; + +const X86_WHITELIST: &[(&str, Option)] = &[ + ("adx", Some(sym::adx_target_feature)), + ("aes", None), + ("avx", None), + ("avx2", None), + ("avx512bw", Some(sym::avx512_target_feature)), + ("avx512cd", Some(sym::avx512_target_feature)), + ("avx512dq", Some(sym::avx512_target_feature)), + ("avx512er", Some(sym::avx512_target_feature)), + ("avx512f", Some(sym::avx512_target_feature)), + ("avx512ifma", Some(sym::avx512_target_feature)), + ("avx512pf", Some(sym::avx512_target_feature)), + ("avx512vbmi", Some(sym::avx512_target_feature)), + ("avx512vl", Some(sym::avx512_target_feature)), + ("avx512vpopcntdq", Some(sym::avx512_target_feature)), + ("bmi1", None), + ("bmi2", None), + ("cmpxchg16b", Some(sym::cmpxchg16b_target_feature)), + ("f16c", Some(sym::f16c_target_feature)), + ("fma", None), + ("fxsr", None), + ("lzcnt", None), + ("mmx", Some(sym::mmx_target_feature)), + ("movbe", Some(sym::movbe_target_feature)), + ("pclmulqdq", None), + ("popcnt", None), + ("rdrand", None), + ("rdseed", None), + ("rtm", Some(sym::rtm_target_feature)), + ("sha", None), + ("sse", None), + ("sse2", None), + ("sse3", None), + ("sse4.1", None), + ("sse4.2", None), + ("sse4a", Some(sym::sse4a_target_feature)), + ("ssse3", None), + ("tbm", Some(sym::tbm_target_feature)), + ("xsave", None), + ("xsavec", None), + ("xsaveopt", None), + ("xsaves", None), +]; + +const HEXAGON_WHITELIST: &[(&str, Option)] = &[ + ("hvx", Some(sym::hexagon_target_feature)), + ("hvx-double", Some(sym::hexagon_target_feature)), +]; + +const POWERPC_WHITELIST: &[(&str, Option)] = &[ + ("altivec", Some(sym::powerpc_target_feature)), + ("power8-altivec", Some(sym::powerpc_target_feature)), + ("power9-altivec", Some(sym::powerpc_target_feature)), + ("power8-vector", Some(sym::powerpc_target_feature)), + ("power9-vector", Some(sym::powerpc_target_feature)), + ("vsx", Some(sym::powerpc_target_feature)), +]; + +const MIPS_WHITELIST: &[(&str, Option)] = &[ + ("fp64", Some(sym::mips_target_feature)), + ("msa", Some(sym::mips_target_feature)), +]; + +const WASM_WHITELIST: &[(&str, Option)] = &[ + ("simd128", Some(sym::wasm_target_feature)), + ("atomics", Some(sym::wasm_target_feature)), +]; + +/// When rustdoc is running, provide a list of all known features so that all their respective +/// primitives may be documented. +/// +/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this +/// iterator! +pub fn all_known_features() -> impl Iterator)> { + ARM_WHITELIST.iter().cloned() + .chain(AARCH64_WHITELIST.iter().cloned()) + .chain(X86_WHITELIST.iter().cloned()) + .chain(HEXAGON_WHITELIST.iter().cloned()) + .chain(POWERPC_WHITELIST.iter().cloned()) + .chain(MIPS_WHITELIST.iter().cloned()) + .chain(WASM_WHITELIST.iter().cloned()) +} + +pub fn target_feature_whitelist(sess: &Session) + -> &'static [(&'static str, Option)] +{ + match &*sess.target.target.arch { + "arm" => ARM_WHITELIST, + "aarch64" => AARCH64_WHITELIST, + "x86" | "x86_64" => X86_WHITELIST, + "hexagon" => HEXAGON_WHITELIST, + "mips" | "mips64" => MIPS_WHITELIST, + "powerpc" | "powerpc64" => POWERPC_WHITELIST, + // wasm32 on emscripten does not support these target features + "wasm32" if !sess.target.target.options.is_like_emscripten => WASM_WHITELIST, + _ => &[], + } +} diff --git a/src/trap.rs b/src/trap.rs index f37f6cccae6bd..cbbe5d203bb5d 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -24,32 +24,48 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms fx.bcx.ins().call(puts, &[msg_ptr]); } +/// Use this when `rustc_codegen_llvm` would insert a call to the panic handler. +/// /// Trap code: user0 pub fn trap_panic(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::User(0)); } +/// Use this for example when a function call should never return. This will fill the current block, +/// so you can **not** add instructions to it afterwards. +/// /// Trap code: user65535 pub fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::User(!0)); } +/// Use this when something is unimplemented, but `libcore` or `libstd` requires it to codegen. +/// Unlike `trap_unreachable` this will not fill the current block, so you **must** add instructions +/// to it afterwards. +/// /// Trap code: user65535 -pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef) -> CValue<'tcx> { +pub fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); +} + +/// Like `trap_unreachable` but returns a fake value of the specified type. +/// +/// Trap code: user65535 +pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef) -> CValue<'tcx> { + trap_unimplemented(fx, msg); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); CValue::by_ref(zero, dest_layout) } +/// Like `trap_unreachable` but returns a fake place for the specified type. +/// /// Trap code: user65535 pub fn trap_unreachable_ret_place<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef) -> CPlace<'tcx> { - codegen_print(fx, msg.as_ref()); - let true_ = fx.bcx.ins().iconst(types::I32, 1); - fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); + trap_unimplemented(fx, msg); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); CPlace::for_addr(zero, dest_layout) } From 4f54314440e9dc56a57e435e1442772d38fa1a30 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jul 2019 15:42:26 +0200 Subject: [PATCH 0724/1566] Update cranelift --- Cargo.lock | 100 ++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5d0abec0dcae..16369b4f8ce4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,29 +116,29 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-bforest 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -147,24 +147,24 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" [[package]] name = "cranelift-faerie" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -173,43 +173,43 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.35.0" -source = "git+https://github.com/CraneStation/cranelift.git#a4426e5f10c2ae0f143f8a502520566752497fc0" +version = "0.36.0" +source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -611,10 +611,10 @@ dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.35.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -882,16 +882,16 @@ dependencies = [ "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum cranelift 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.35.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" From 853234006ef12376d0f4574b6b726895f5d79210 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jul 2019 15:48:18 +0200 Subject: [PATCH 0725/1566] Update Cargo.lock --- Cargo.lock | 68 +++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 16369b4f8ce4c..6e9f0955a928a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,36 +39,36 @@ dependencies = [ [[package]] name = "atty" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -106,7 +106,7 @@ version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -211,7 +211,7 @@ dependencies = [ "cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -230,7 +230,7 @@ name = "env_logger" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "atty 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -243,7 +243,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -253,7 +253,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -278,7 +278,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -304,7 +304,7 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -320,7 +320,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -401,7 +401,7 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.59" +version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -417,7 +417,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -431,7 +431,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -449,7 +449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -513,7 +513,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -524,7 +524,7 @@ name = "rand_chacha" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -586,7 +586,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -618,7 +618,7 @@ dependencies = [ "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -671,7 +671,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.94" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -681,7 +681,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -699,7 +699,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -764,7 +764,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -872,10 +872,10 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum atty 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ecaaea69f52b3b18633611ec0007d188517d0366f47ff703d400fa6879d6f8d5" -"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "18b50f5258d1a9ad8396d2d345827875de4261b158124d4c819d9b351454fae5" -"checksum backtrace-sys 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "5b3a000b9c543553af61bc01cbfc403b04b5caa9e421033866f2e98061eb3e61" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" +"checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" +"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" @@ -912,7 +912,7 @@ dependencies = [ "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "3262021842bf00fe07dbd6cf34ff25c99d7a7ebef8deea84db72be3ea3bb0aff" +"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" "checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" @@ -944,7 +944,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "076a696fdea89c19d3baed462576b8f6d663064414b5c793642da8dfeb99475b" +"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" From 92f2b6243d717b6ff711fdf9fe9d579d41669ee1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jul 2019 11:56:24 +0200 Subject: [PATCH 0726/1566] Rustup to rustc 1.38.0-nightly (a7f28678b 2019-07-23) --- src/analyze.rs | 4 +- src/base.rs | 128 +++++++++++++++++++++++++++---------------------- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index 1c3f52d50afff..243c660368d3a 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -47,8 +47,8 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap } fn analyze_non_ssa_place(flag_map: &mut HashMap, place: &Place) { - match place { - Place::Base(PlaceBase::Local(local)) => not_ssa(flag_map, local), + match place.base { + PlaceBase::Local(local) => not_ssa(flag_map, local), _ => {} } } diff --git a/src/base.rs b/src/base.rs index 0566170bba1d8..1adcec046e033 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1148,70 +1148,82 @@ pub fn trans_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, place: &Place<'tcx>, ) -> CPlace<'tcx> { - match place { - Place::Base(base) => match base { - PlaceBase::Local(local) => fx.get_local_place(*local), - PlaceBase::Static(static_) => match static_.kind { - StaticKind::Static(def_id) => { - crate::constant::codegen_static_ref(fx, def_id, static_.ty) - } - StaticKind::Promoted(promoted) => { - crate::constant::trans_promoted(fx, promoted, static_.ty) - } + let base = match &place.base { + PlaceBase::Local(local) => fx.get_local_place(*local), + PlaceBase::Static(static_) => match static_.kind { + StaticKind::Static(def_id) => { + crate::constant::codegen_static_ref(fx, def_id, static_.ty) + } + StaticKind::Promoted(promoted) => { + crate::constant::trans_promoted(fx, promoted, static_.ty) } } - Place::Projection(projection) => { - let base = trans_place(fx, &projection.base); - match projection.elem { - ProjectionElem::Deref => base.place_deref(fx), - ProjectionElem::Field(field, _ty) => base.place_field(fx, field), - ProjectionElem::Index(local) => { - let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx); - base.place_index(fx, index) - } - ProjectionElem::ConstantIndex { - offset, - min_length: _, - from_end, - } => { - let index = if !from_end { - fx.bcx.ins().iconst(fx.pointer_type, offset as i64) - } else { - let len = codegen_array_len(fx, base); - fx.bcx.ins().iadd_imm(len, -(offset as i64)) - }; - base.place_index(fx, index) + }; + + trans_place_projection(fx, base, &place.projection) +} + +pub fn trans_place_projection<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + base: CPlace<'tcx>, + projection: &Option>>, +) -> CPlace<'tcx> { + let projection = if let Some(projection) = projection { + projection + } else { + return base; + }; + + let base = trans_place_projection(fx, base, &projection.base); + + match projection.elem { + ProjectionElem::Deref => base.place_deref(fx), + ProjectionElem::Field(field, _ty) => base.place_field(fx, field), + ProjectionElem::Index(local) => { + let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx); + base.place_index(fx, index) + } + ProjectionElem::ConstantIndex { + offset, + min_length: _, + from_end, + } => { + let index = if !from_end { + fx.bcx.ins().iconst(fx.pointer_type, offset as i64) + } else { + let len = codegen_array_len(fx, base); + fx.bcx.ins().iadd_imm(len, -(offset as i64)) + }; + base.place_index(fx, index) + } + ProjectionElem::Subslice { from, to } => { + // These indices are generated by slice patterns. + // slice[from:-to] in Python terms. + + match base.layout().ty.sty { + ty::Array(elem_ty, len) => { + let elem_layout = fx.layout_of(elem_ty); + let ptr = base.to_addr(fx); + let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx); + CPlace::for_addr( + fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), + ) } - ProjectionElem::Subslice { from, to } => { - // These indices are generated by slice patterns. - // slice[from:-to] in Python terms. - - match base.layout().ty.sty { - ty::Array(elem_ty, len) => { - let elem_layout = fx.layout_of(elem_ty); - let ptr = base.to_addr(fx); - let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx); - CPlace::for_addr( - fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), - fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), - ) - } - ty::Slice(elem_ty) => { - let elem_layout = fx.layout_of(elem_ty); - let (ptr, len) = base.to_addr_maybe_unsized(fx); - let len = len.unwrap(); - CPlace::for_addr_with_extra( - fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), - fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), - base.layout(), - ) - } - _ => unreachable!(), - } + ty::Slice(elem_ty) => { + let elem_layout = fx.layout_of(elem_ty); + let (ptr, len) = base.to_addr_maybe_unsized(fx); + let len = len.unwrap(); + CPlace::for_addr_with_extra( + fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), + base.layout(), + ) } - ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant), + _ => unreachable!(), } } + ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant), } } From bf3ec3be3e595780d842ac3069bb07f3c50f54b8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 13 Jul 2019 16:55:08 +0200 Subject: [PATCH 0727/1566] Implement checked binops --- example/mini_core.rs | 48 +++++++++++++++++++++++ example/mini_core_hello_world.rs | 17 +++++++++ src/base.rs | 65 ++++++++++++++++++++++++++------ 3 files changed, 119 insertions(+), 11 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index d900776c55cc8..8c372450abd80 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -128,6 +128,14 @@ impl Add for u8 { } } +impl Add for i8 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + impl Add for usize { type Output = Self; @@ -151,6 +159,30 @@ impl Sub for usize { } } +impl Sub for u8 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for i8 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for i16 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + #[lang = "bitor"] pub trait BitOr { type Output; @@ -270,6 +302,22 @@ pub trait Neg { fn neg(self) -> Self::Output; } +impl Neg for i8 { + type Output = i8; + + fn neg(self) -> i8 { + -self + } +} + +impl Neg for i16 { + type Output = i16; + + fn neg(self) -> i16 { + -self + } +} + impl Neg for isize { type Output = isize; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index e51f257f6b46a..15f0442b624ec 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -236,4 +236,21 @@ fn main() { unsafe { assert_eq!(ABC as usize, 0); } &mut (|| Some(0 as *const ())) as &mut FnMut() -> Option<*const ()>; + + // checked binops + let zeroi8 = 0i8; + let oneu8 = 1u8; + let onei8 = 1i8; + zeroi8 - 1; + oneu8 - 1; + zeroi8 - -2i8; + #[allow(unreachable_code)] + { + if false { + let minustwoi8 = -2i8; + oneu8 + 255; + onei8 + 127; + minustwoi8 - 127; + } + } } diff --git a/src/base.rs b/src/base.rs index 1adcec046e033..7b29d15e56b1a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -241,7 +241,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } else { fx.bcx.ins().brz(cond, target, &[]); }; - trap_panic(fx, format!("[panic] Assert {:?} failed.", msg)); + trap_panic(fx, format!("[panic] Assert {:?} failed at {:?}.", msg, bb_data.terminator().source_info.span)); } TerminatorKind::SwitchInt { @@ -948,17 +948,62 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - let res = match bin_op { - BinOp::Add => fx.bcx.ins().iadd(lhs, rhs), - BinOp::Sub => fx.bcx.ins().isub(lhs, rhs), - BinOp::Mul => fx.bcx.ins().imul(lhs, rhs), - BinOp::Shl => fx.bcx.ins().ishl(lhs, rhs), + let (res, has_overflow) = match bin_op { + BinOp::Add => { + /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); + (val, c_out)*/ + // FIXME(CraneStation/cranelift#849) legalize iadd_cout for i8 and i16 + let val = fx.bcx.ins().iadd(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, slt) + }; + (val, has_overflow) + } + BinOp::Sub => { + /*let (val, b_out) = fx.bcx.ins().isub_bout(lhs, rhs); + (val, b_out)*/ + // FIXME(CraneStation/cranelift#849) legalize isub_bout for i8 and i16 + let val = fx.bcx.ins().isub(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, sgt) + }; + (val, has_overflow) + } + BinOp::Mul => { + let val = fx.bcx.ins().imul(lhs, rhs); + /*let val_hi = if !signed { + fx.bcx.ins().umulhi(lhs, rhs) + } else { + fx.bcx.ins().smulhi(lhs, rhs) + }; + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + BinOp::Shl => { + let val = fx.bcx.ins().ishl(lhs, rhs); + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } BinOp::Shr => { - if !signed { + let val = if !signed { fx.bcx.ins().ushr(lhs, rhs) } else { fx.bcx.ins().sshr(lhs, rhs) - } + }; + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) } _ => bug!( "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", @@ -968,9 +1013,7 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( ), }; - // TODO: check for overflow - let has_overflow = fx.bcx.ins().iconst(types::I8, 0); - + let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); let out_place = CPlace::new_stack_slot(fx, out_ty); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); From de32ddad23abbc831ae60d5efefab0df84e8910b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 12 Jun 2019 20:54:38 +0200 Subject: [PATCH 0728/1566] [WIP] Basic i128 support --- Cargo.lock | 60 +++++-------- Cargo.toml | 10 +-- example/mini_core.rs | 8 ++ example/mini_core_hello_world.rs | 136 +---------------------------- src/abi.rs | 2 +- src/base.rs | 145 ++++++++++++++++++------------- src/common.rs | 4 +- src/value_and_place.rs | 28 ++++-- 8 files changed, 144 insertions(+), 249 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e9f0955a928a..6752108006fdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,28 +117,25 @@ dependencies = [ [[package]] name = "cranelift" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0", + "cranelift-frontend 0.36.0", ] [[package]] name = "cranelift-bforest" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.36.0", ] [[package]] name = "cranelift-codegen" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-bforest 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.36.0", + "cranelift-codegen-meta 0.36.0", + "cranelift-entity 0.36.0", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -148,23 +145,20 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.36.0", ] [[package]] name = "cranelift-entity" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" [[package]] name = "cranelift-faerie" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0", + "cranelift-module 0.36.0", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -174,9 +168,8 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -184,10 +177,9 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0", + "cranelift-entity 0.36.0", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -195,9 +187,8 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -205,11 +196,10 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.36.0" -source = "git+https://github.com/CraneStation/cranelift.git#e7f2b719eebfb9280c3e38eae42a9ee25221a4e3" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.36.0", + "cranelift-module 0.36.0", + "cranelift-native 0.36.0", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -611,10 +601,10 @@ dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.36.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.36.0", + "cranelift-faerie 0.36.0", + "cranelift-module 0.36.0", + "cranelift-simplejit 0.36.0", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -882,16 +872,6 @@ dependencies = [ "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum cranelift 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.36.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" diff --git a/Cargo.toml b/Cargo.toml index 59d66d07fa953..64126d917f385 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,11 +28,11 @@ indexmap = "1.0.2" object = "0.12.0" # Uncomment to use local checkout of cranelift -#[patch."https://github.com/CraneStation/cranelift.git"] -#cranelift = { path = "../cranelift/cranelift-umbrella" } -#cranelift-module = { path = "../cranelift/cranelift-module" } -#cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } -#cranelift-faerie = { path = "../cranelift/cranelift-faerie" } +[patch."https://github.com/CraneStation/cranelift.git"] +cranelift = { path = "../cranelift/cranelift-umbrella" } +cranelift-module = { path = "../cranelift/cranelift-module" } +cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } +cranelift-faerie = { path = "../cranelift/cranelift-faerie" } #[patch."https://github.com/gimli-rs/gimli.git"] #gimli = { path = "../" } diff --git a/example/mini_core.rs b/example/mini_core.rs index 8c372450abd80..745e86de4850b 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -144,6 +144,14 @@ impl Add for usize { } } +impl Add for u128 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + #[lang = "sub"] pub trait Sub { type Output; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 15f0442b624ec..23a92c737808b 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -118,139 +118,5 @@ fn take_f32(_f: f32) {} fn take_unique(_u: Unique<()>) {} fn main() { - take_unique(Unique { - pointer: 0 as *const (), - _marker: PhantomData, - }); - take_f32(0.1); - - //return; - - unsafe { - printf("Hello %s\n\0" as *const str as *const i8, "printf\0" as *const str as *const i8); - - let hello: &[u8] = b"Hello\0" as &[u8; 6]; - let ptr: *const u8 = hello as *const [u8] as *const u8; - puts(ptr); - - let world: Box<&str> = box "World!\0"; - puts(*world as *const str as *const u8); - world as Box; - - assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8); - - assert_eq!(intrinsics::bswap(0xabu8), 0xabu8); - assert_eq!(intrinsics::bswap(0xddccu16), 0xccddu16); - assert_eq!(intrinsics::bswap(0xffee_ddccu32), 0xccdd_eeffu32); - assert_eq!(intrinsics::bswap(0x1234_5678_ffee_ddccu64), 0xccdd_eeff_7856_3412u64); - - assert_eq!(intrinsics::size_of_val(hello) as u8, 6); - - let chars = &['C', 'h', 'a', 'r', 's']; - let chars = chars as &[char]; - assert_eq!(intrinsics::size_of_val(chars) as u8, 4 * 5); - - let a: &dyn SomeTrait = &"abc\0"; - a.object_safe(); - - assert_eq!(intrinsics::size_of_val(a) as u8, 16); - assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); - - assert_eq!(intrinsics::min_align_of::() as u8, 2); - assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8); - - assert!(!intrinsics::needs_drop::()); - assert!(intrinsics::needs_drop::()); - - Unique { - pointer: 0 as *const &str, - _marker: PhantomData, - } as Unique; - - struct MyDst(T); - - intrinsics::size_of_val(&MyDst([0u8; 4]) as &MyDst<[u8]>); - - struct Foo { - x: u8, - y: !, - } - - unsafe fn zeroed() -> T { - intrinsics::init::() - } - - unsafe fn uninitialized() -> T { - MaybeUninit { uninit: () }.value - } - - zeroed::<(u8, u8)>(); - #[allow(unreachable_code)] - { - if false { - zeroed::(); - zeroed::(); - uninitialized::(); - } - } - } - - let _ = box NoisyDrop { - text: "Boxed outer got dropped!\0", - inner: NoisyDropInner, - } as Box; - - const FUNC_REF: Option = Some(main); - match FUNC_REF { - Some(_) => {}, - None => assert!(false), - } - - match Ordering::Less { - Ordering::Less => {}, - _ => assert!(false), - } - - [NoisyDropInner, NoisyDropInner]; - - let x = &[0u32, 42u32] as &[u32]; - match x { - [] => assert_eq!(0u32, 1), - [_, ref y..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize), - } - - assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); - - extern { - #[linkage = "weak"] - static ABC: *const u8; - } - - { - extern { - #[linkage = "weak"] - static ABC: *const u8; - } - } - - unsafe { assert_eq!(ABC as usize, 0); } - - &mut (|| Some(0 as *const ())) as &mut FnMut() -> Option<*const ()>; - - // checked binops - let zeroi8 = 0i8; - let oneu8 = 1u8; - let onei8 = 1i8; - zeroi8 - 1; - oneu8 - 1; - zeroi8 - -2i8; - #[allow(unreachable_code)] - { - if false { - let minustwoi8 = -2i8; - oneu8 + 255; - onei8 + 127; - minustwoi8 - 127; - } - } + assert_eq!((1u128 + 2) as u16, 3); } diff --git a/src/abi.rs b/src/abi.rs index 2397da9be2627..b7e7d0a830a60 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -87,7 +87,7 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { Integer::I16 => types::I16, Integer::I32 => types::I32, Integer::I64 => types::I64, - Integer::I128 => unimpl!("u/i128"), + Integer::I128 => types::I128, }, Primitive::Float(flt) => match flt { FloatTy::F32 => types::F32, diff --git a/src/base.rs b/src/base.rs index 7b29d15e56b1a..f8bd567234611 100644 --- a/src/base.rs +++ b/src/base.rs @@ -899,6 +899,19 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( "int binop requires lhs and rhs of same type" ); } + + if out_ty == fx.tcx.types.u128 || out_ty == fx.tcx.types.i128 { + return match (bin_op, signed) { + _ => { + let layout = fx.layout_of(out_ty); + let a = fx.bcx.ins().iconst(types::I64, 42); + let b = fx.bcx.ins().iconst(types::I64, 0); + let val = fx.bcx.ins().iconcat(a, b); + CValue::by_val(val, layout) + } + } + } + binop_match! { fx, bin_op, signed, lhs, rhs, out_ty, "int/uint"; Add (_) iadd; @@ -948,69 +961,79 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - let (res, has_overflow) = match bin_op { - BinOp::Add => { - /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); - (val, c_out)*/ - // FIXME(CraneStation/cranelift#849) legalize iadd_cout for i8 and i16 - let val = fx.bcx.ins().iadd(lhs, rhs); - let has_overflow = if !signed { - fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) - } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); - let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); - fx.bcx.ins().bxor(rhs_is_negative, slt) - }; - (val, has_overflow) - } - BinOp::Sub => { - /*let (val, b_out) = fx.bcx.ins().isub_bout(lhs, rhs); - (val, b_out)*/ - // FIXME(CraneStation/cranelift#849) legalize isub_bout for i8 and i16 - let val = fx.bcx.ins().isub(lhs, rhs); - let has_overflow = if !signed { - fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) - } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); - let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); - fx.bcx.ins().bxor(rhs_is_negative, sgt) - }; - (val, has_overflow) - } - BinOp::Mul => { - let val = fx.bcx.ins().imul(lhs, rhs); - /*let val_hi = if !signed { - fx.bcx.ins().umulhi(lhs, rhs) - } else { - fx.bcx.ins().smulhi(lhs, rhs) - }; - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) - } - BinOp::Shl => { - let val = fx.bcx.ins().ishl(lhs, rhs); - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) + let (res, has_overflow) = if in_lhs.layout().ty == fx.tcx.types.u128 || in_lhs.layout().ty == fx.tcx.types.i128 { + match (bin_op, signed) { + _ => { + let a = fx.bcx.ins().iconst(types::I64, 42); + let b = fx.bcx.ins().iconst(types::I64, 0); + (fx.bcx.ins().iconcat(a, b), fx.bcx.ins().bconst(types::B1, false)) + } } - BinOp::Shr => { - let val = if !signed { - fx.bcx.ins().ushr(lhs, rhs) - } else { - fx.bcx.ins().sshr(lhs, rhs) - }; - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) + } else { + match bin_op { + BinOp::Add => { + /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); + (val, c_out)*/ + // FIXME(CraneStation/cranelift#849) legalize iadd_cout for i8 and i16 + let val = fx.bcx.ins().iadd(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, slt) + }; + (val, has_overflow) + } + BinOp::Sub => { + /*let (val, b_out) = fx.bcx.ins().isub_bout(lhs, rhs); + (val, b_out)*/ + // FIXME(CraneStation/cranelift#849) legalize isub_bout for i8 and i16 + let val = fx.bcx.ins().isub(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, sgt) + }; + (val, has_overflow) + } + BinOp::Mul => { + let val = fx.bcx.ins().imul(lhs, rhs); + /*let val_hi = if !signed { + fx.bcx.ins().umulhi(lhs, rhs) + } else { + fx.bcx.ins().smulhi(lhs, rhs) + }; + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + BinOp::Shl => { + let val = fx.bcx.ins().ishl(lhs, rhs); + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + BinOp::Shr => { + let val = if !signed { + fx.bcx.ins().ushr(lhs, rhs) + } else { + fx.bcx.ins().sshr(lhs, rhs) + }; + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + _ => bug!( + "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", + bin_op, + in_lhs, + in_rhs + ), } - _ => bug!( - "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", - bin_op, - in_lhs, - in_rhs - ), }; let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); diff --git a/src/common.rs b/src/common.rs index bffa526c8b408..30f343d02b25a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -28,7 +28,7 @@ pub fn clif_type_from_ty<'tcx>( UintTy::U16 => types::I16, UintTy::U32 => types::I32, UintTy::U64 => types::I64, - UintTy::U128 => unimpl!("u128"), + UintTy::U128 => types::I128, UintTy::Usize => pointer_ty(tcx), }, ty::Int(size) => match size { @@ -36,7 +36,7 @@ pub fn clif_type_from_ty<'tcx>( IntTy::I16 => types::I16, IntTy::I32 => types::I32, IntTy::I64 => types::I64, - IntTy::I128 => unimpl!("i128"), + IntTy::I128 => types::I128, IntTy::Isize => pointer_ty(tcx), }, ty::Char => types::I32, diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 716a81c5d8af1..6bd82265bc1b3 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -34,6 +34,16 @@ enum CValueInner { ByValPair(Value, Value), } +fn store_scalar<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value: Value, addr: Value, offset: i32) { + if fx.bcx.func.dfg.value_type(value) == types::I128 { + let (a, b) = fx.bcx.ins().isplit(value); + fx.bcx.ins().store(MemFlags::new(), a, addr, offset); + fx.bcx.ins().store(MemFlags::new(), b, addr, offset + 8); + } else { + fx.bcx.ins().store(MemFlags::new(), value, addr, offset); + } +} + impl<'tcx> CValue<'tcx> { pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByRef(value), layout) @@ -147,7 +157,15 @@ impl<'tcx> CValue<'tcx> { { let clif_ty = fx.clif_type(ty).unwrap(); let layout = fx.layout_of(ty); - CValue::by_val(fx.bcx.ins().iconst(clif_ty, const_val), layout) + let val = if clif_ty == types::I128 { + // FIXME don't assume little-endian arch + let lsb = fx.bcx.ins().iconst(types::I64, const_val); + let msb = fx.bcx.ins().iconst(types::I64, 0); + fx.bcx.ins().iconcat(lsb, msb) + } else { + fx.bcx.ins().iconst(clif_ty, const_val) + }; + CValue::by_val(val, layout) } pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { @@ -343,15 +361,15 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match from.0 { CValueInner::ByVal(val) => { - fx.bcx.ins().store(MemFlags::new(), val, addr, 0); + store_scalar(fx, val, addr, 0); } CValueInner::ByValPair(value, extra) => { match dst_layout.abi { Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); - fx.bcx.ins().store(MemFlags::new(), value, addr, 0); - fx.bcx.ins().store( - MemFlags::new(), + store_scalar(fx, value, addr, 0); + store_scalar( + fx, extra, addr, b_offset, From d629d97f25d02d59144b3d2de144022bff9e3151 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 17 Jun 2019 21:13:02 +0200 Subject: [PATCH 0729/1566] Fix some things --- src/common.rs | 3 +++ src/value_and_place.rs | 23 +++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/common.rs b/src/common.rs index 30f343d02b25a..810744527f94a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -88,6 +88,9 @@ pub fn clif_intcast<'a, 'tcx: 'a>( } else { fx.bcx.ins().uextend(to, val) } + } else if from == types::I128 { + let (lsb, msb) = fx.bcx.ins().isplit(val); + fx.bcx.ins().ireduce(to, lsb) } else { fx.bcx.ins().ireduce(to, val) } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 6bd82265bc1b3..3589d77057240 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -44,6 +44,21 @@ fn store_scalar<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value } } +fn load_scalar<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + clif_ty: Type, + addr: Value, + offset: i32, +) -> Value { + if clif_ty == types::I128 { + let a = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset); + let b = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset + 8); + fx.bcx.ins().iconcat(a, b) + } else { + fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset) + } +} + impl<'tcx> CValue<'tcx> { pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByRef(value), layout) @@ -89,7 +104,7 @@ impl<'tcx> CValue<'tcx> { _ => unreachable!(), }; let clif_ty = scalar_to_clif_type(fx.tcx, scalar); - fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) + load_scalar(fx, clif_ty, addr, 0) } CValueInner::ByVal(value) => value, CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), @@ -111,10 +126,10 @@ impl<'tcx> CValue<'tcx> { let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); - let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); - let val2 = fx.bcx.ins().load( + let val1 = load_scalar(fx, clif_ty1, addr, 0); + let val2 = load_scalar( + fx, clif_ty2, - MemFlags::new(), addr, b_offset, ); From 596fdd5a6463d55d8dedd202c41a6392eca2c4c8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 17 Jun 2019 21:19:08 +0200 Subject: [PATCH 0730/1566] Fix type in load_scalar --- src/intrinsics.rs | 2 +- src/value_and_place.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 08a829ff1da19..792d7c993731d 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -103,7 +103,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // Insert non returning intrinsics here match intrinsic { "abort" => { - trap_panic(fx, "Called intrinisc::abort."); + trap_panic(fx, "Called intrinsic::abort."); } "unreachable" => { trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 3589d77057240..8b5c764f69c89 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -51,8 +51,8 @@ fn load_scalar<'a, 'tcx: 'a>( offset: i32, ) -> Value { if clif_ty == types::I128 { - let a = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset); - let b = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset + 8); + let a = fx.bcx.ins().load(types::I64, MemFlags::new(), addr, offset); + let b = fx.bcx.ins().load(types::I64, MemFlags::new(), addr, offset + 8); fx.bcx.ins().iconcat(a, b) } else { fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset) From c814ee0d2a7b9f67cf2be6a6488d07105606c64c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 27 Jun 2019 20:49:39 +0200 Subject: [PATCH 0731/1566] [WIP] --- build_sysroot/Cargo.toml | 2 +- example/mini_core_hello_world.rs | 2 +- example/std_example.rs | 27 +--------- src/base.rs | 89 +++----------------------------- src/common.rs | 11 +++- 5 files changed, 20 insertions(+), 111 deletions(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 45484027edc37..532216ba8514f 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -14,7 +14,7 @@ alloc_system = { path = "./alloc_system" } [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } -compiler_builtins = { path = "./compiler_builtins" } +#compiler_builtins = { path = "./compiler_builtins" } [profile.release] debug = true diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 23a92c737808b..d435e3470051d 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -118,5 +118,5 @@ fn take_f32(_f: f32) {} fn take_unique(_u: Unique<()>) {} fn main() { - assert_eq!((1u128 + 2) as u16, 3); + } diff --git a/example/std_example.rs b/example/std_example.rs index 98d9ed17b0308..ae77616a83db5 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -3,32 +3,7 @@ use std::io::Write; fn main() { - let _ = ::std::iter::repeat('a' as u8).take(10).collect::>(); - let stderr = ::std::io::stderr(); - let mut stderr = stderr.lock(); - - writeln!(stderr, "some {} text", "").unwrap(); - - let _ = std::process::Command::new("true").env("c", "d").spawn(); - - println!("cargo:rustc-link-lib=z"); - - static ONCE: std::sync::Once = std::sync::ONCE_INIT; - ONCE.call_once(|| {}); - - LoopState::Continue(()) == LoopState::Break(()); - - // Make sure ByValPair values with differently sized components are correctly passed - map(None::<(u8, Box)>); - - println!("{}", 2.3f32.exp()); - println!("{}", 2.3f32.exp2()); - println!("{}", 2.3f32.abs()); - println!("{}", 2.3f32.sqrt()); - println!("{}", 2.3f32.floor()); - println!("{}", 2.3f32.ceil()); - println!("{}", 2.3f32.min(1.0)); - println!("{}", 2.3f32.max(1.0)); + assert_eq!((1u128 + 2) as u16, 3); } #[derive(PartialEq)] diff --git a/src/base.rs b/src/base.rs index f8bd567234611..7163c0949f773 100644 --- a/src/base.rs +++ b/src/base.rs @@ -11,83 +11,6 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( let mir = tcx.instance_mir(instance.def); - // Check fn sig for u128 and i128 and replace those functions with a trap. - { - // FIXME implement u128 and i128 support - - // Check sig for u128 and i128 - let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx)); - - struct UI128Visitor<'tcx>(TyCtxt<'tcx>, bool); - - impl<'tcx> rustc::ty::fold::TypeVisitor<'tcx> for UI128Visitor<'tcx> { - fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { - if t.sty == self.0.types.u128.sty || t.sty == self.0.types.i128.sty { - self.1 = true; - return false; // stop visiting - } - - t.super_visit_with(self) - } - } - - let mut visitor = UI128Visitor(tcx, false); - fn_sig.visit_with(&mut visitor); - - //If found replace function with a trap. - if visitor.1 { - tcx.sess.warn("u128 and i128 are not yet supported. \ - Functions using these as args will be replaced with a trap."); - - // Declare function with fake signature - let sig = Signature { - params: vec![AbiParam::new(types::INVALID)], - returns: vec![], - call_conv: CallConv::Fast, - }; - let name = tcx.symbol_name(instance).as_str(); - let func_id = cx.module.declare_function(&*name, linkage, &sig).unwrap(); - - // Create trapping function - let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); - let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); - let start_ebb = bcx.create_ebb(); - bcx.append_ebb_params_for_function_params(start_ebb); - bcx.switch_to_block(start_ebb); - - let mut fx = FunctionCx { - tcx, - module: cx.module, - pointer_type: pointer_ty(tcx), - - instance, - mir, - - bcx, - ebb_map: HashMap::new(), - local_map: HashMap::new(), - - clif_comments: crate::pretty_clif::CommentWriter::new(tcx, instance), - constants: &mut cx.ccx, - caches: &mut cx.caches, - source_info_set: indexmap::IndexSet::new(), - }; - - crate::trap::trap_unreachable(&mut fx, "[unimplemented] Called function with u128 or i128 as argument."); - fx.bcx.seal_all_blocks(); - fx.bcx.finalize(); - - // Define function - cx.caches.context.func = func; - cx.module - .define_function(func_id, &mut cx.caches.context) - .unwrap(); - cx.caches.context.clear(); - return; - } - } - // Declare function let (name, sig) = get_function_name_and_sig(tcx, instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); @@ -391,7 +314,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let rhs = trans_operand(fx, rhs); let res = match ty.sty { - ty::Bool => trans_bool_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), + ty::Bool => trans_bool_binop(fx, *bin_op, lhs, rhs), ty::Uint(_) => { trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } @@ -666,7 +589,7 @@ fn trans_stmt<'a, 'tcx: 'a>( clobbers, // Vec volatile, // bool alignstack, // bool - dialect, // syntax::ast::AsmDialect + dialect: _, // syntax::ast::AsmDialect asm_str_style: _, ctxt: _, } = asm; @@ -705,6 +628,9 @@ fn trans_stmt<'a, 'tcx: 'a>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } + _ if fx.tcx.symbol_name(fx.instance).as_str() == "__rust_probestack" => { + crate::trap::trap_unimplemented(fx, "__rust_probestack is not supported"); + } _ => unimpl!("Inline assembly is not supported"), } } @@ -856,10 +782,9 @@ fn trans_bool_binop<'a, 'tcx: 'a>( bin_op: BinOp, lhs: CValue<'tcx>, rhs: CValue<'tcx>, - ty: Ty<'tcx>, ) -> CValue<'tcx> { let res = binop_match! { - fx, bin_op, false, lhs, rhs, ty, "bool"; + fx, bin_op, false, lhs, rhs, fx.tcx.types.bool, "bool"; Add (_) bug; Sub (_) bug; Mul (_) bug; @@ -900,7 +825,7 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( ); } - if out_ty == fx.tcx.types.u128 || out_ty == fx.tcx.types.i128 { + if lhs.layout().ty == fx.tcx.types.u128 || lhs.layout().ty == fx.tcx.types.i128 { return match (bin_op, signed) { _ => { let layout = fx.layout_of(out_ty); diff --git a/src/common.rs b/src/common.rs index 810744527f94a..57794a66b9c24 100644 --- a/src/common.rs +++ b/src/common.rs @@ -82,6 +82,15 @@ pub fn clif_intcast<'a, 'tcx: 'a>( if from == to { return val; } + if to == types::I128 { + let wider = if signed { + fx.bcx.ins().sextend(types::I64, val) + } else { + fx.bcx.ins().uextend(types::I64, val) + }; + let zero = fx.bcx.ins().iconst(types::I64, 0); + return fx.bcx.ins().iconcat(wider, zero); + } if to.wider_or_equal(from) { if signed { fx.bcx.ins().sextend(to, val) @@ -89,7 +98,7 @@ pub fn clif_intcast<'a, 'tcx: 'a>( fx.bcx.ins().uextend(to, val) } } else if from == types::I128 { - let (lsb, msb) = fx.bcx.ins().isplit(val); + let (lsb, _msb) = fx.bcx.ins().isplit(val); fx.bcx.ins().ireduce(to, lsb) } else { fx.bcx.ins().ireduce(to, val) From 79f4c3d002c1265220d2b39b74a7b4b37b6e2f54 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 27 Jun 2019 20:53:21 +0200 Subject: [PATCH 0732/1566] [WIP] --- src/base.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/base.rs b/src/base.rs index 7163c0949f773..7720296cfbff8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -826,14 +826,16 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( } if lhs.layout().ty == fx.tcx.types.u128 || lhs.layout().ty == fx.tcx.types.i128 { - return match (bin_op, signed) { - _ => { - let layout = fx.layout_of(out_ty); - let a = fx.bcx.ins().iconst(types::I64, 42); - let b = fx.bcx.ins().iconst(types::I64, 0); - let val = fx.bcx.ins().iconcat(a, b); - CValue::by_val(val, layout) - } + if out_ty == fx.tcx.types.bool { + let layout = fx.layout_of(fx.tcx.types.bool); + let val = fx.bcx.ins().iconst(types::I8, 0); + return CValue::by_val(val, layout); + } else { + let layout = fx.layout_of(out_ty); + let a = fx.bcx.ins().iconst(types::I64, 42); + let b = fx.bcx.ins().iconst(types::I64, 0); + let val = fx.bcx.ins().iconcat(a, b); + return CValue::by_val(val, layout); } } From 45de0336a5ca03834f74189af6682462d874f980 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Jun 2019 16:43:20 +0200 Subject: [PATCH 0733/1566] Fix some more stuff --- example/mini_core.rs | 28 +++++++++++++++++ example/mini_core_hello_world.rs | 18 ++++++++++- src/base.rs | 19 +++++++++-- src/common.rs | 54 +++++++++++++++++++++----------- src/intrinsics.rs | 26 +++++++++++++-- 5 files changed, 120 insertions(+), 25 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 745e86de4850b..fa47831b6486d 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -44,10 +44,12 @@ unsafe impl Copy for u8 {} unsafe impl Copy for u16 {} unsafe impl Copy for u32 {} unsafe impl Copy for u64 {} +unsafe impl Copy for u128 {} unsafe impl Copy for usize {} unsafe impl Copy for i8 {} unsafe impl Copy for i16 {} unsafe impl Copy for i32 {} +unsafe impl Copy for i128 {} unsafe impl Copy for isize {} unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} @@ -152,6 +154,14 @@ impl Add for u128 { } } +impl Add for i128 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + #[lang = "sub"] pub trait Sub { type Output; @@ -276,6 +286,15 @@ impl PartialEq for i32 { } } +impl PartialEq for i128 { + fn eq(&self, other: &i128) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &i128) -> bool { + (*self) != (*other) + } +} + impl PartialEq for isize { fn eq(&self, other: &isize) -> bool { (*self) == (*other) @@ -322,6 +341,14 @@ impl Neg for i16 { type Output = i16; fn neg(self) -> i16 { + self + } +} + +impl Neg for i128 { + type Output = i128; + + fn neg(self) -> i128 { -self } } @@ -446,6 +473,7 @@ pub mod intrinsics { pub fn needs_drop() -> bool; pub fn bitreverse(x: T) -> T; pub fn bswap(x: T) -> T; + pub fn unchecked_div(lhs: T, rhs: T) -> T; } } diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index d435e3470051d..4a26577af524a 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -117,6 +117,22 @@ impl CoerceUnsized> for Unique where T: Unsiz fn take_f32(_f: f32) {} fn take_unique(_u: Unique<()>) {} -fn main() { +fn checked_div_i128(lhs: i128, rhs: i128) -> Option { + if rhs == 0 || (lhs == -170141183460469231731687303715884105728 && rhs == -1) { + None + } else { + Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) + } +} +fn checked_div_u128(lhs: u128, rhs: u128) -> Option { + match rhs { + 0 => None, + rhs => Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) + } +} + +fn main() { + checked_div_i128(0i128, 2i128); + checked_div_u128(0u128, 2u128); } diff --git a/src/base.rs b/src/base.rs index 7720296cfbff8..94ba93de14193 100644 --- a/src/base.rs +++ b/src/base.rs @@ -357,15 +357,28 @@ fn trans_stmt<'a, 'tcx: 'a>( let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); fx.bcx.ins().bint(types::I8, res) } - ty::Uint(_) | ty::Int(_) => fx.bcx.ins().bnot(val), + ty::Uint(_) | ty::Int(_) => { + if fx.bcx.func.dfg.value_type(val) == types::I128 { + let (a, b) = fx.bcx.ins().isplit(val); + let a = fx.bcx.ins().bnot(a); + let b = fx.bcx.ins().bnot(b); + fx.bcx.ins().iconcat(a, b) + } else { + fx.bcx.ins().bnot(val) + } + } _ => unimplemented!("un op Not for {:?}", layout.ty), } } UnOp::Neg => match layout.ty.sty { ty::Int(_) => { let clif_ty = fx.clif_type(layout.ty).unwrap(); - let zero = fx.bcx.ins().iconst(clif_ty, 0); - fx.bcx.ins().isub(zero, val) + if clif_ty == types::I128 { + crate::trap::trap_unreachable_ret_value(fx, layout, "i128 neg is not yet supported").load_scalar(fx) + } else { + let zero = fx.bcx.ins().iconst(clif_ty, 0); + fx.bcx.ins().isub(zero, val) + } } ty::Float(_) => fx.bcx.ins().fneg(val), _ => unimplemented!("un op Neg for {:?}", layout.ty), diff --git a/src/common.rs b/src/common.rs index 57794a66b9c24..6c907720477cc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -82,26 +82,42 @@ pub fn clif_intcast<'a, 'tcx: 'a>( if from == to { return val; } - if to == types::I128 { - let wider = if signed { - fx.bcx.ins().sextend(types::I64, val) - } else { - fx.bcx.ins().uextend(types::I64, val) - }; - let zero = fx.bcx.ins().iconst(types::I64, 0); - return fx.bcx.ins().iconcat(wider, zero); - } - if to.wider_or_equal(from) { - if signed { - fx.bcx.ins().sextend(to, val) - } else { - fx.bcx.ins().uextend(to, val) + match (from, to) { + // equal + (_, _) if from == to => val, + + // extend + (_, types::I128) => { + let wider = if from == types::I64 { + val + } else if signed { + fx.bcx.ins().sextend(types::I64, val) + } else { + fx.bcx.ins().uextend(types::I64, val) + }; + let zero = fx.bcx.ins().iconst(types::I64, 0); + fx.bcx.ins().iconcat(wider, zero) + } + (_, _) if to.wider_or_equal(from) => { + if signed { + fx.bcx.ins().sextend(to, val) + } else { + fx.bcx.ins().uextend(to, val) + } + } + + // reduce + (types::I128, _) => { + let (lsb, _msb) = fx.bcx.ins().isplit(val); + if to == types::I64 { + lsb + } else { + fx.bcx.ins().ireduce(to, lsb) + } + } + (_, _) => { + fx.bcx.ins().ireduce(to, val) } - } else if from == types::I128 { - let (lsb, _msb) = fx.bcx.ins().isplit(val); - fx.bcx.ins().ireduce(to, lsb) - } else { - fx.bcx.ins().ireduce(to, val) } } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 792d7c993731d..aaf4622178526 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -390,11 +390,33 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); }; ctlz | ctlz_nonzero, (v arg) { - let res = CValue::by_val(fx.bcx.ins().clz(arg), fx.layout_of(T)); + let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { + // FIXME verify this algorithm is correct + let (lsb, msb) = fx.bcx.ins().isplit(arg); + let lsb_lz = fx.bcx.ins().clz(lsb); + let msb_lz = fx.bcx.ins().clz(msb); + let msb_lz_is_64 = fx.bcx.ins().icmp_imm(IntCC::Equal, msb_lz, 64); + let lsb_lz_plus_64 = fx.bcx.ins().iadd_imm(lsb_lz, 64); + fx.bcx.ins().select(msb_lz_is_64, lsb_lz_plus_64, msb_lz) + } else { + fx.bcx.ins().clz(arg) + }; + let res = CValue::by_val(res, fx.layout_of(T)); ret.write_cvalue(fx, res); }; cttz | cttz_nonzero, (v arg) { - let res = CValue::by_val(fx.bcx.ins().ctz(arg), fx.layout_of(T)); + let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { + // FIXME verify this algorithm is correct + let (lsb, msb) = fx.bcx.ins().isplit(arg); + let lsb_tz = fx.bcx.ins().ctz(lsb); + let msb_tz = fx.bcx.ins().ctz(msb); + let lsb_tz_is_64 = fx.bcx.ins().icmp_imm(IntCC::Equal, lsb_tz, 64); + let msb_lz_plus_64 = fx.bcx.ins().iadd_imm(msb_tz, 64); + fx.bcx.ins().select(lsb_tz_is_64, msb_lz_plus_64, lsb_tz) + } else { + fx.bcx.ins().ctz(arg) + }; + let res = CValue::by_val(res, fx.layout_of(T)); ret.write_cvalue(fx, res); }; ctpop, (v arg) { From d8cae099d0ec6c2db802f1cb6ee392ed117910dc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Jun 2019 16:53:20 +0200 Subject: [PATCH 0734/1566] Fix it --- src/intrinsics.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index aaf4622178526..f521a07d91f04 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -494,7 +494,13 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let or_tmp6 = bcx.ins().bor(or_tmp3, or_tmp4); bcx.ins().bor(or_tmp5, or_tmp6) } - ty => unimplemented!("bwap {}", ty), + types::I128 => { + let (lo, hi) = bcx.ins().isplit(v); + let lo = swap(bcx, lo); + let hi = swap(bcx, hi); + bcx.ins().iconcat(hi, lo) + } + ty => unimplemented!("bswap {}", ty), } }; let res = CValue::by_val(swap(&mut fx.bcx, arg), fx.layout_of(T)); From 8b3628028e270f18ec945b24360341363b8383bf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Jun 2019 17:02:34 +0200 Subject: [PATCH 0735/1566] Don't special case u/i128 for UnOp::not --- src/base.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/base.rs b/src/base.rs index 94ba93de14193..88964a34ed1fe 100644 --- a/src/base.rs +++ b/src/base.rs @@ -358,14 +358,7 @@ fn trans_stmt<'a, 'tcx: 'a>( fx.bcx.ins().bint(types::I8, res) } ty::Uint(_) | ty::Int(_) => { - if fx.bcx.func.dfg.value_type(val) == types::I128 { - let (a, b) = fx.bcx.ins().isplit(val); - let a = fx.bcx.ins().bnot(a); - let b = fx.bcx.ins().bnot(b); - fx.bcx.ins().iconcat(a, b) - } else { - fx.bcx.ins().bnot(val) - } + fx.bcx.ins().bnot(val) } _ => unimplemented!("un op Not for {:?}", layout.ty), } From 3080c73f50a286a7a6199bf88d7bad7570c2e646 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Jun 2019 17:43:25 +0200 Subject: [PATCH 0736/1566] Remove unnecessary if statement --- src/common.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/common.rs b/src/common.rs index 6c907720477cc..838ea6c8f5251 100644 --- a/src/common.rs +++ b/src/common.rs @@ -79,9 +79,6 @@ pub fn clif_intcast<'a, 'tcx: 'a>( signed: bool, ) -> Value { let from = fx.bcx.func.dfg.value_type(val); - if from == to { - return val; - } match (from, to) { // equal (_, _) if from == to => val, From 641a210ff688d8101688b32650d09c270d381b02 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 7 Jul 2019 18:08:38 +0200 Subject: [PATCH 0737/1566] Implement most 128bit binops --- example/std_example.rs | 20 +----- src/abi.rs | 2 +- src/base.rs | 151 +++++++++++++++++++---------------------- src/codegen_i128.rs | 107 +++++++++++++++++++++++++++++ src/lib.rs | 1 + 5 files changed, 178 insertions(+), 103 deletions(-) create mode 100644 src/codegen_i128.rs diff --git a/example/std_example.rs b/example/std_example.rs index ae77616a83db5..c0ec0bb5b73ff 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -3,23 +3,5 @@ use std::io::Write; fn main() { - assert_eq!((1u128 + 2) as u16, 3); -} - -#[derive(PartialEq)] -enum LoopState { - Continue(()), - Break(()) -} - -pub enum Instruction { - Increment, - Loop, -} - -fn map(a: Option<(u8, Box)>) -> Option> { - match a { - None => None, - Some((_, instr)) => Some(instr), - } + assert_eq!(1u128 + 2, 3); } diff --git a/src/abi.rs b/src/abi.rs index b7e7d0a830a60..c5dbe6dffa981 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -846,7 +846,7 @@ pub fn codegen_drop<'a, 'tcx: 'a>( ); drop_place.write_place_ref(fx, arg_place); let arg_value = arg_place.to_cvalue(fx); - crate::abi::codegen_call_inner( + codegen_call_inner( fx, None, drop_fn_ty, diff --git a/src/base.rs b/src/base.rs index 88964a34ed1fe..8821a629519e9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -831,18 +831,8 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( ); } - if lhs.layout().ty == fx.tcx.types.u128 || lhs.layout().ty == fx.tcx.types.i128 { - if out_ty == fx.tcx.types.bool { - let layout = fx.layout_of(fx.tcx.types.bool); - let val = fx.bcx.ins().iconst(types::I8, 0); - return CValue::by_val(val, layout); - } else { - let layout = fx.layout_of(out_ty); - let a = fx.bcx.ins().iconst(types::I64, 42); - let b = fx.bcx.ins().iconst(types::I64, 0); - let val = fx.bcx.ins().iconcat(a, b); - return CValue::by_val(val, layout); - } + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, signed, lhs, rhs, out_ty) { + return res; } binop_match! { @@ -894,79 +884,74 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - let (res, has_overflow) = if in_lhs.layout().ty == fx.tcx.types.u128 || in_lhs.layout().ty == fx.tcx.types.i128 { - match (bin_op, signed) { - _ => { - let a = fx.bcx.ins().iconst(types::I64, 42); - let b = fx.bcx.ins().iconst(types::I64, 0); - (fx.bcx.ins().iconcat(a, b), fx.bcx.ins().bconst(types::B1, false)) - } + + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, true, signed, in_lhs, in_rhs, out_ty) { + return res; + } + + let (res, has_overflow) = match bin_op { + BinOp::Add => { + /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); + (val, c_out)*/ + // FIXME(CraneStation/cranelift#849) legalize iadd_cout for i8 and i16 + let val = fx.bcx.ins().iadd(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, slt) + }; + (val, has_overflow) } - } else { - match bin_op { - BinOp::Add => { - /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); - (val, c_out)*/ - // FIXME(CraneStation/cranelift#849) legalize iadd_cout for i8 and i16 - let val = fx.bcx.ins().iadd(lhs, rhs); - let has_overflow = if !signed { - fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) - } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); - let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); - fx.bcx.ins().bxor(rhs_is_negative, slt) - }; - (val, has_overflow) - } - BinOp::Sub => { - /*let (val, b_out) = fx.bcx.ins().isub_bout(lhs, rhs); - (val, b_out)*/ - // FIXME(CraneStation/cranelift#849) legalize isub_bout for i8 and i16 - let val = fx.bcx.ins().isub(lhs, rhs); - let has_overflow = if !signed { - fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) - } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); - let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); - fx.bcx.ins().bxor(rhs_is_negative, sgt) - }; - (val, has_overflow) - } - BinOp::Mul => { - let val = fx.bcx.ins().imul(lhs, rhs); - /*let val_hi = if !signed { - fx.bcx.ins().umulhi(lhs, rhs) - } else { - fx.bcx.ins().smulhi(lhs, rhs) - }; - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) - } - BinOp::Shl => { - let val = fx.bcx.ins().ishl(lhs, rhs); - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) - } - BinOp::Shr => { - let val = if !signed { - fx.bcx.ins().ushr(lhs, rhs) - } else { - fx.bcx.ins().sshr(lhs, rhs) - }; - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) - } - _ => bug!( - "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", - bin_op, - in_lhs, - in_rhs - ), + BinOp::Sub => { + /*let (val, b_out) = fx.bcx.ins().isub_bout(lhs, rhs); + (val, b_out)*/ + // FIXME(CraneStation/cranelift#849) legalize isub_bout for i8 and i16 + let val = fx.bcx.ins().isub(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, sgt) + }; + (val, has_overflow) + } + BinOp::Mul => { + let val = fx.bcx.ins().imul(lhs, rhs); + /*let val_hi = if !signed { + fx.bcx.ins().umulhi(lhs, rhs) + } else { + fx.bcx.ins().smulhi(lhs, rhs) + }; + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + BinOp::Shl => { + let val = fx.bcx.ins().ishl(lhs, rhs); + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + BinOp::Shr => { + let val = if !signed { + fx.bcx.ins().ushr(lhs, rhs) + } else { + fx.bcx.ins().sshr(lhs, rhs) + }; + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) } + _ => bug!( + "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", + bin_op, + in_lhs, + in_rhs + ), }; let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs new file mode 100644 index 0000000000000..ded6b597f26a4 --- /dev/null +++ b/src/codegen_i128.rs @@ -0,0 +1,107 @@ +//! Replaces 128-bit operators with lang item calls + +use crate::prelude::*; + +pub fn maybe_codegen<'a, 'tcx>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + bin_op: BinOp, + checked: bool, + is_signed: bool, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + out_ty: Ty<'tcx>, +) -> Option> { + if lhs.layout().ty != fx.tcx.types.u128 && lhs.layout().ty != fx.tcx.types.i128 { + return None; + } + + let lhs_val = lhs.load_scalar(fx); + let rhs_val = rhs.load_scalar(fx); + + match bin_op { + BinOp::Add | BinOp::Sub | BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => return None, + BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), + BinOp::Mul => { + let res = if checked { + if is_signed { + let oflow_place = CPlace::new_stack_slot(fx, fx.tcx.types.i32); + let oflow_addr = oflow_place.to_addr(fx); + let oflow_addr = CValue::by_val(oflow_addr, fx.layout_of(fx.tcx.mk_mut_ptr(fx.tcx.types.i32))); + let val = fx.easy_call("__muloti4", &[lhs, rhs, oflow_addr], fx.tcx.types.i128); + let val = val.load_scalar(fx); + let oflow = oflow_place.to_cvalue(fx).load_scalar(fx); + let oflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, oflow, 0); + let oflow = fx.bcx.ins().bint(types::I8, oflow); + CValue::by_val_pair(val, oflow, fx.layout_of(out_ty)) + } else { + // FIXME implement it + let out_layout = fx.layout_of(out_ty); + return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit checked binop unsigned mul"))); + } + } else { + let val_ty = if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }; + fx.easy_call("__multi3", &[lhs, rhs], val_ty) + }; + return Some(res); + } + BinOp::Div => { + let res = if checked { + // FIXME implement it + let out_layout = fx.layout_of(out_ty); + return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit checked binop div"))); + } else { + if is_signed { + fx.easy_call("__divti3", &[lhs, rhs], fx.tcx.types.i128) + } else { + fx.easy_call("__udivti3", &[lhs, rhs], fx.tcx.types.u128) + } + }; + return Some(res); + } + BinOp::Rem => { + let res = if checked { + // FIXME implement it + let out_layout = fx.layout_of(out_ty); + return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit checked binop rem"))); + } else { + if is_signed { + fx.easy_call("__modti3", &[lhs, rhs], fx.tcx.types.i128) + } else { + fx.easy_call("__umodti3", &[lhs, rhs], fx.tcx.types.u128) + } + }; + return Some(res); + } + BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { + assert!(!checked); + let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); + let (rhs_lsb, rhs_msb) = fx.bcx.ins().isplit(rhs_val); + let res = match (bin_op, is_signed) { + (BinOp::Eq, _) => { + let lsb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_lsb, rhs_lsb); + let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); + fx.bcx.ins().band(lsb_eq, msb_eq) + } + (BinOp::Ne, _) => { + let lsb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_lsb, rhs_lsb); + let msb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_msb, rhs_msb); + fx.bcx.ins().bor(lsb_ne, msb_ne) + } + _ => { + // FIXME implement it + let out_layout = fx.layout_of(out_ty); + return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit binop {:?}", bin_op))); + }, + }; + + let res = fx.bcx.ins().bint(types::I8, res); + let res = CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)); + return Some(res); + } + BinOp::Shl | BinOp::Shr => { + // FIXME implement it + let out_layout = fx.layout_of(out_ty); + return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit binop {:?}", bin_op))); + } + } +} diff --git a/src/lib.rs b/src/lib.rs index c6f77954a869f..9bd985e3dc9f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,7 @@ mod allocator; mod analyze; mod archive; mod base; +mod codegen_i128; mod common; mod constant; mod debuginfo; From 834a3bf49c9e6cc422a0028926654d46dc5749ba Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 17 Jul 2019 20:45:54 +0200 Subject: [PATCH 0738/1566] [WIP] --- example/mini_core_hello_world.rs | 129 +++++++++++++++++++++++++++---- example/std_example.rs | 18 +++++ 2 files changed, 133 insertions(+), 14 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 4a26577af524a..e51f257f6b46a 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -117,22 +117,123 @@ impl CoerceUnsized> for Unique where T: Unsiz fn take_f32(_f: f32) {} fn take_unique(_u: Unique<()>) {} -fn checked_div_i128(lhs: i128, rhs: i128) -> Option { - if rhs == 0 || (lhs == -170141183460469231731687303715884105728 && rhs == -1) { - None - } else { - Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) +fn main() { + take_unique(Unique { + pointer: 0 as *const (), + _marker: PhantomData, + }); + take_f32(0.1); + + //return; + + unsafe { + printf("Hello %s\n\0" as *const str as *const i8, "printf\0" as *const str as *const i8); + + let hello: &[u8] = b"Hello\0" as &[u8; 6]; + let ptr: *const u8 = hello as *const [u8] as *const u8; + puts(ptr); + + let world: Box<&str> = box "World!\0"; + puts(*world as *const str as *const u8); + world as Box; + + assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8); + + assert_eq!(intrinsics::bswap(0xabu8), 0xabu8); + assert_eq!(intrinsics::bswap(0xddccu16), 0xccddu16); + assert_eq!(intrinsics::bswap(0xffee_ddccu32), 0xccdd_eeffu32); + assert_eq!(intrinsics::bswap(0x1234_5678_ffee_ddccu64), 0xccdd_eeff_7856_3412u64); + + assert_eq!(intrinsics::size_of_val(hello) as u8, 6); + + let chars = &['C', 'h', 'a', 'r', 's']; + let chars = chars as &[char]; + assert_eq!(intrinsics::size_of_val(chars) as u8, 4 * 5); + + let a: &dyn SomeTrait = &"abc\0"; + a.object_safe(); + + assert_eq!(intrinsics::size_of_val(a) as u8, 16); + assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); + + assert_eq!(intrinsics::min_align_of::() as u8, 2); + assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8); + + assert!(!intrinsics::needs_drop::()); + assert!(intrinsics::needs_drop::()); + + Unique { + pointer: 0 as *const &str, + _marker: PhantomData, + } as Unique; + + struct MyDst(T); + + intrinsics::size_of_val(&MyDst([0u8; 4]) as &MyDst<[u8]>); + + struct Foo { + x: u8, + y: !, + } + + unsafe fn zeroed() -> T { + intrinsics::init::() + } + + unsafe fn uninitialized() -> T { + MaybeUninit { uninit: () }.value + } + + zeroed::<(u8, u8)>(); + #[allow(unreachable_code)] + { + if false { + zeroed::(); + zeroed::(); + uninitialized::(); + } + } } -} -fn checked_div_u128(lhs: u128, rhs: u128) -> Option { - match rhs { - 0 => None, - rhs => Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) + let _ = box NoisyDrop { + text: "Boxed outer got dropped!\0", + inner: NoisyDropInner, + } as Box; + + const FUNC_REF: Option = Some(main); + match FUNC_REF { + Some(_) => {}, + None => assert!(false), } -} -fn main() { - checked_div_i128(0i128, 2i128); - checked_div_u128(0u128, 2u128); + match Ordering::Less { + Ordering::Less => {}, + _ => assert!(false), + } + + [NoisyDropInner, NoisyDropInner]; + + let x = &[0u32, 42u32] as &[u32]; + match x { + [] => assert_eq!(0u32, 1), + [_, ref y..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize), + } + + assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); + + extern { + #[linkage = "weak"] + static ABC: *const u8; + } + + { + extern { + #[linkage = "weak"] + static ABC: *const u8; + } + } + + unsafe { assert_eq!(ABC as usize, 0); } + + &mut (|| Some(0 as *const ())) as &mut FnMut() -> Option<*const ()>; } diff --git a/example/std_example.rs b/example/std_example.rs index c0ec0bb5b73ff..a67ca2f79c7a3 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,7 +1,25 @@ #![feature(core_intrinsics)] use std::io::Write; +use std::intrinsics; + +fn checked_div_i128(lhs: i128, rhs: i128) -> Option { + if rhs == 0 || (lhs == -170141183460469231731687303715884105728 && rhs == -1) { + None + } else { + Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) + } +} + +fn checked_div_u128(lhs: u128, rhs: u128) -> Option { + match rhs { + 0 => None, + rhs => Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) + } +} fn main() { + checked_div_i128(0i128, 2i128); + checked_div_u128(0u128, 2u128); assert_eq!(1u128 + 2, 3); } From 869372832788b8949ef03cd1a421542f5b96eb79 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jul 2019 17:05:43 +0200 Subject: [PATCH 0739/1566] Respect sess.overflow_checks() --- src/base.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/base.rs b/src/base.rs index 8821a629519e9..7f99f4ad4f71d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -874,6 +874,10 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( out_ty: Ty<'tcx>, signed: bool, ) -> CValue<'tcx> { + if !fx.tcx.sess.overflow_checks() { + return trans_int_binop(fx, bin_op, in_lhs, in_rhs, out_ty, signed); + } + if bin_op != BinOp::Shl && bin_op != BinOp::Shr { assert_eq!( in_lhs.layout().ty, From 88ad25f45e9adbf08871ce77449e1b1193d23df4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jul 2019 17:44:41 +0200 Subject: [PATCH 0740/1566] Implement 128bit shl and shr binops --- src/abi.rs | 1 + src/codegen_i128.rs | 84 ++++++++++++++++++++++++++++++++++++++++++--- src/common.rs | 46 ++++++++++++++++++++++++- 3 files changed, 126 insertions(+), 5 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index c5dbe6dffa981..1c9f84b37e4fd 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -270,6 +270,7 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { .module .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); + self.add_comment(call_inst, format!("easy_call {}", name)); if output_ty.is_none() { return None; } diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index ded6b597f26a4..81388573c9ee0 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -19,7 +19,13 @@ pub fn maybe_codegen<'a, 'tcx>( let rhs_val = rhs.load_scalar(fx); match bin_op { - BinOp::Add | BinOp::Sub | BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => return None, + BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => { + assert!(!checked); + return None; + } + BinOp::Add | BinOp::Sub => { + return None; // FIXME implement checked versions + } BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { let res = if checked { @@ -99,9 +105,79 @@ pub fn maybe_codegen<'a, 'tcx>( return Some(res); } BinOp::Shl | BinOp::Shr => { - // FIXME implement it - let out_layout = fx.layout_of(out_ty); - return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit binop {:?}", bin_op))); + let is_overflow = if checked { + // rhs >= 128 + + // FIXME support non 128bit rhs + /*let (rhs_lsb, rhs_msb) = fx.bcx.ins().isplit(rhs_val); + let rhs_msb_gt_0 = fx.bcx.ins().icmp_imm(IntCC::NotEqual, rhs_msb, 0); + let rhs_lsb_ge_128 = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThan, rhs_lsb, 127); + let is_overflow = fx.bcx.ins().bor(rhs_msb_gt_0, rhs_lsb_ge_128);*/ + let is_overflow = fx.bcx.ins().bconst(types::B1, false); + + Some(fx.bcx.ins().bint(types::I8, is_overflow)) + } else { + None + }; + + // Optimize `val >> 64`, because compiler_builtins uses it to deconstruct an 128bit + // integer into its lsb and msb. + // https://github.com/rust-lang-nursery/compiler-builtins/blob/79a6a1603d5672cbb9187ff41ff4d9b5048ac1cb/src/int/mod.rs#L217 + if let Some(64) = resolve_value_imm(fx.bcx.func, rhs_val) { + let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); + let all_zeros = fx.bcx.ins().iconst(types::I64, 0); + let val = match (bin_op, is_signed) { + (BinOp::Shr, false) => { + let val = fx.bcx.ins().iconcat(lhs_msb, all_zeros); + Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.u128))) + } + (BinOp::Shr, true) => { + let sign = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, lhs_msb, 0); + let all_ones = fx.bcx.ins().iconst(types::I64, u64::max_value() as i64); + let all_sign_bits = fx.bcx.ins().select(sign, all_zeros, all_ones); + + let val = fx.bcx.ins().iconcat(lhs_msb, all_sign_bits); + Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.i128))) + } + (BinOp::Shl, _) => { + let val = fx.bcx.ins().iconcat(all_zeros, lhs_lsb); + Some(CValue::by_val(val, fx.layout_of(out_ty))) + } + _ => None + }; + if let Some(val) = val { + if let Some(is_overflow) = is_overflow { + let val = val.load_scalar(fx); + return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) + } else { + return Some(val); + } + } + } + + let truncated_rhs = clif_intcast(fx, rhs_val, types::I32, false); + let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fx.tcx.types.u32)); + let val = match (bin_op, is_signed) { + (BinOp::Shl, false) => { + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.tcx.types.u128) + } + (BinOp::Shl, true) => { + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.tcx.types.i128) + } + (BinOp::Shr, false) => { + fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fx.tcx.types.u128) + } + (BinOp::Shr, true) => { + fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fx.tcx.types.i128) + } + (_, _) => unreachable!(), + }; + if let Some(is_overflow) = is_overflow { + let val = val.load_scalar(fx); + Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) + } else { + Some(val) + } } } } diff --git a/src/common.rs b/src/common.rs index 838ea6c8f5251..6a00d1341980b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,6 @@ use rustc_target::spec::{HasTargetSpec, Target}; +use cranelift::codegen::ir::{Opcode, InstructionData, ValueDef}; use cranelift_module::Module; use crate::prelude::*; @@ -62,7 +63,7 @@ pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: V let rhs_ty = bcx.func.dfg.value_type(rhs); assert_eq!(lhs_ty, rhs_ty); if lhs_ty == types::I8 || lhs_ty == types::I16 { - // FIXME workaround for missing enocding for select.i8 + // FIXME workaround for missing encoding for select.i8 let lhs = bcx.ins().uextend(types::I32, lhs); let rhs = bcx.ins().uextend(types::I32, rhs); let res = bcx.ins().select(cond, lhs, rhs); @@ -118,6 +119,49 @@ pub fn clif_intcast<'a, 'tcx: 'a>( } } +fn resolve_normal_value_imm(func: &Function, val: Value) -> Option { + if let ValueDef::Result(inst, 0 /*param*/) = func.dfg.value_def(val) { + if let InstructionData::UnaryImm { + opcode: Opcode::Iconst, + imm, + } = func.dfg[inst] { + Some(imm.into()) + } else { + None + } + } else { + None + } +} + +fn resolve_128bit_value_imm(func: &Function, val: Value) -> Option { + let (lsb, msb) = if let ValueDef::Result(inst, 0 /*param*/) = func.dfg.value_def(val) { + if let InstructionData::Binary { + opcode: Opcode::Iconcat, + args: [lsb, msb], + } = func.dfg[inst] { + (lsb, msb) + } else { + return None; + } + } else { + return None; + }; + + let lsb = resolve_normal_value_imm(func, lsb)? as u64 as u128; + let msb = resolve_normal_value_imm(func, msb)? as u64 as u128; + + Some(msb << 64 | lsb) +} + +pub fn resolve_value_imm(func: &Function, val: Value) -> Option { + if func.dfg.value_type(val) == types::I128 { + resolve_128bit_value_imm(func, val) + } else { + resolve_normal_value_imm(func, val).map(|imm| imm as u64 as u128) + } +} + pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` pub tcx: TyCtxt<'tcx>, From 65e337cdf3e9a54dbabcdb92aebdfb79b5660e24 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jul 2019 17:57:00 +0200 Subject: [PATCH 0741/1566] Implement 128bit multiply with overflow --- example/std_example.rs | 5 +++++ src/abi.rs | 36 +++++++++++++------------------ src/codegen_i128.rs | 49 ++++++++++++------------------------------ 3 files changed, 34 insertions(+), 56 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index a67ca2f79c7a3..9e9a7a67e05e6 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -22,4 +22,9 @@ fn main() { checked_div_i128(0i128, 2i128); checked_div_u128(0u128, 2u128); assert_eq!(1u128 + 2, 3); + + println!("{}", 0b100010000000000000000000000000000u128 >> 10); + println!("{}", 0xFEDCBA987654321123456789ABCDEFu128 >> 64); + println!("{} >> 64 == {}", 0xFEDCBA987654321123456789ABCDEFu128 as i128, 0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64); + println!("{}", 353985398u128 * 932490u128); } diff --git a/src/abi.rs b/src/abi.rs index 1c9f84b37e4fd..b884d80b3944e 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -252,14 +252,12 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { &mut self, name: &str, input_tys: Vec, - output_ty: Option, + output_tys: Vec, args: &[Value], - ) -> Option { + ) -> &[Value] { let sig = Signature { params: input_tys.iter().cloned().map(AbiParam::new).collect(), - returns: output_ty - .map(|output_ty| vec![AbiParam::new(output_ty)]) - .unwrap_or(Vec::new()), + returns: output_tys.iter().cloned().map(AbiParam::new).collect(), call_conv: CallConv::SystemV, }; let func_id = self @@ -271,12 +269,9 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); self.add_comment(call_inst, format!("easy_call {}", name)); - if output_ty.is_none() { - return None; - } let results = self.bcx.inst_results(call_inst); - assert_eq!(results.len(), 1); - Some(results[0]) + assert!(results.len() <= 2, "{}", results.len()); + results } pub fn easy_call( @@ -295,23 +290,22 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { }) .unzip(); let return_layout = self.layout_of(return_ty); - let return_ty = if let ty::Tuple(tup) = return_ty.sty { - if !tup.is_empty() { - bug!("easy_call( (...) -> ) is not allowed"); - } - None + let return_tys = if let ty::Tuple(tup) = return_ty.sty { + tup.types().map(|ty| self.clif_type(ty).unwrap()).collect() } else { - Some(self.clif_type(return_ty).unwrap()) + vec![self.clif_type(return_ty).unwrap()] }; - if let Some(val) = self.lib_call(name, input_tys, return_ty, &args) { - CValue::by_val(val, return_layout) - } else { - CValue::by_ref( + let ret_vals = self.lib_call(name, input_tys, return_tys, &args); + match *ret_vals { + [] => CValue::by_ref( self.bcx .ins() .iconst(self.pointer_type, self.pointer_type.bytes() as i64), return_layout, - ) + ), + [val] => CValue::by_val(val, return_layout), + [val, extra] => CValue::by_val_pair(val, extra, return_layout), + _ => unreachable!(), } } diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 81388573c9ee0..b5e2bb6b3c962 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -30,19 +30,9 @@ pub fn maybe_codegen<'a, 'tcx>( BinOp::Mul => { let res = if checked { if is_signed { - let oflow_place = CPlace::new_stack_slot(fx, fx.tcx.types.i32); - let oflow_addr = oflow_place.to_addr(fx); - let oflow_addr = CValue::by_val(oflow_addr, fx.layout_of(fx.tcx.mk_mut_ptr(fx.tcx.types.i32))); - let val = fx.easy_call("__muloti4", &[lhs, rhs, oflow_addr], fx.tcx.types.i128); - let val = val.load_scalar(fx); - let oflow = oflow_place.to_cvalue(fx).load_scalar(fx); - let oflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, oflow, 0); - let oflow = fx.bcx.ins().bint(types::I8, oflow); - CValue::by_val_pair(val, oflow, fx.layout_of(out_ty)) + fx.easy_call("__rust_i128_mulo", &[lhs, rhs], out_ty) } else { - // FIXME implement it - let out_layout = fx.layout_of(out_ty); - return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit checked binop unsigned mul"))); + fx.easy_call("__rust_u128_mulo", &[lhs, rhs], out_ty) } } else { let val_ty = if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }; @@ -51,32 +41,20 @@ pub fn maybe_codegen<'a, 'tcx>( return Some(res); } BinOp::Div => { - let res = if checked { - // FIXME implement it - let out_layout = fx.layout_of(out_ty); - return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit checked binop div"))); + assert!(!checked); + if is_signed { + Some(fx.easy_call("__divti3", &[lhs, rhs], fx.tcx.types.i128)) } else { - if is_signed { - fx.easy_call("__divti3", &[lhs, rhs], fx.tcx.types.i128) - } else { - fx.easy_call("__udivti3", &[lhs, rhs], fx.tcx.types.u128) - } - }; - return Some(res); + Some(fx.easy_call("__udivti3", &[lhs, rhs], fx.tcx.types.u128)) + } } BinOp::Rem => { - let res = if checked { - // FIXME implement it - let out_layout = fx.layout_of(out_ty); - return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit checked binop rem"))); + assert!(!checked); + if is_signed { + Some(fx.easy_call("__modti3", &[lhs, rhs], fx.tcx.types.i128)) } else { - if is_signed { - fx.easy_call("__modti3", &[lhs, rhs], fx.tcx.types.i128) - } else { - fx.easy_call("__umodti3", &[lhs, rhs], fx.tcx.types.u128) - } - }; - return Some(res); + Some(fx.easy_call("__umodti3", &[lhs, rhs], fx.tcx.types.u128)) + } } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { assert!(!checked); @@ -140,8 +118,9 @@ pub fn maybe_codegen<'a, 'tcx>( Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.i128))) } (BinOp::Shl, _) => { + let val_ty = if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }; let val = fx.bcx.ins().iconcat(all_zeros, lhs_lsb); - Some(CValue::by_val(val, fx.layout_of(out_ty))) + Some(CValue::by_val(val, fx.layout_of(val_ty))) } _ => None }; From 4d35be684da8c82ac699093132bda4a5292f9578 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jul 2019 13:08:31 +0200 Subject: [PATCH 0742/1566] Implement 128bit comparison binops --- src/codegen_i128.rs | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index b5e2bb6b3c962..76d0fcb301ee6 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -60,22 +60,43 @@ pub fn maybe_codegen<'a, 'tcx>( assert!(!checked); let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); let (rhs_lsb, rhs_msb) = fx.bcx.ins().isplit(rhs_val); - let res = match (bin_op, is_signed) { - (BinOp::Eq, _) => { + + let res = match bin_op { + BinOp::Eq => { let lsb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_lsb, rhs_lsb); let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); fx.bcx.ins().band(lsb_eq, msb_eq) } - (BinOp::Ne, _) => { + BinOp::Ne => { let lsb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_lsb, rhs_lsb); let msb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_msb, rhs_msb); fx.bcx.ins().bor(lsb_ne, msb_ne) } _ => { - // FIXME implement it - let out_layout = fx.layout_of(out_ty); - return Some(crate::trap::trap_unreachable_ret_value(fx, out_layout, format!("unimplemented 128bit binop {:?}", bin_op))); - }, + // if msb_eq { + // lhs_cc + // } else { + // msb_cc + // } + let cc = match (bin_op, is_signed) { + (BinOp::Ge, false) => IntCC::UnsignedGreaterThanOrEqual, + (BinOp::Gt, false) => IntCC::UnsignedGreaterThan, + (BinOp::Lt, false) => IntCC::UnsignedLessThan, + (BinOp::Le, false) => IntCC::UnsignedLessThanOrEqual, + + (BinOp::Ge, true) => IntCC::SignedGreaterThanOrEqual, + (BinOp::Gt, true) => IntCC::SignedGreaterThan, + (BinOp::Lt, true) => IntCC::SignedLessThan, + (BinOp::Le, true) => IntCC::SignedLessThanOrEqual, + _ => unreachable!(), + }; + + let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); + let lsb_cc = fx.bcx.ins().icmp(cc, lhs_lsb, rhs_lsb); + let msb_cc = fx.bcx.ins().icmp(cc, lhs_msb, rhs_msb); + + fx.bcx.ins().select(msb_eq, lsb_cc, msb_cc) + } }; let res = fx.bcx.ins().bint(types::I8, res); From 63b82238bbe54643c63a8693299d6a9f4c0b0358 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jul 2019 13:16:36 +0200 Subject: [PATCH 0743/1566] Implement 128bit checked add and sub --- example/mini_core.rs | 27 --------------------------- example/std_example.rs | 3 +++ src/codegen_i128.rs | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index fa47831b6486d..221cdb3e863de 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -44,12 +44,10 @@ unsafe impl Copy for u8 {} unsafe impl Copy for u16 {} unsafe impl Copy for u32 {} unsafe impl Copy for u64 {} -unsafe impl Copy for u128 {} unsafe impl Copy for usize {} unsafe impl Copy for i8 {} unsafe impl Copy for i16 {} unsafe impl Copy for i32 {} -unsafe impl Copy for i128 {} unsafe impl Copy for isize {} unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} @@ -146,22 +144,6 @@ impl Add for usize { } } -impl Add for u128 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i128 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - #[lang = "sub"] pub trait Sub { type Output; @@ -286,15 +268,6 @@ impl PartialEq for i32 { } } -impl PartialEq for i128 { - fn eq(&self, other: &i128) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &i128) -> bool { - (*self) != (*other) - } -} - impl PartialEq for isize { fn eq(&self, other: &isize) -> bool { (*self) == (*other) diff --git a/example/std_example.rs b/example/std_example.rs index 9e9a7a67e05e6..f9fc1f2cde326 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -23,6 +23,9 @@ fn main() { checked_div_u128(0u128, 2u128); assert_eq!(1u128 + 2, 3); + // overflow panic + // 0xFEDCBA987654321123456789ABCDEFu128 + 0xFEDCBA987654321123456789ABCDEFu128; + println!("{}", 0b100010000000000000000000000000000u128 >> 10); println!("{}", 0xFEDCBA987654321123456789ABCDEFu128 >> 64); println!("{} >> 64 == {}", 0xFEDCBA987654321123456789ABCDEFu128 as i128, 0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64); diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 76d0fcb301ee6..9cd6bc8c78687 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -23,8 +23,20 @@ pub fn maybe_codegen<'a, 'tcx>( assert!(!checked); return None; } - BinOp::Add | BinOp::Sub => { - return None; // FIXME implement checked versions + BinOp::Add | BinOp::Sub if !checked => return None, + BinOp::Add => { + return Some(if is_signed { + fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty) + } else { + fx.easy_call("__rust_u128_addo", &[lhs, rhs], out_ty) + }) + } + BinOp::Sub => { + return Some(if is_signed { + fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty) + } else { + fx.easy_call("__rust_u128_subo", &[lhs, rhs], out_ty) + }) } BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { From 5180becc7c11573d267166437abf3d9951c6b0c7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jul 2019 17:16:31 +0200 Subject: [PATCH 0744/1566] Fix 128bit CValue::const_val --- example/std_example.rs | 3 +++ src/base.rs | 8 ++++---- src/constant.rs | 10 +++------- src/intrinsics.rs | 18 +++++++++--------- src/lib.rs | 2 +- src/value_and_place.rs | 29 +++++++++++++++++++++-------- 6 files changed, 41 insertions(+), 29 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index f9fc1f2cde326..465b6143525ce 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -19,6 +19,9 @@ fn checked_div_u128(lhs: u128, rhs: u128) -> Option { } fn main() { + assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); + assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); + checked_div_i128(0i128, 2i128); checked_div_u128(0u128, 2u128); assert_eq!(1u128 + 2, 3); diff --git a/src/base.rs b/src/base.rs index 7f99f4ad4f71d..6476de7652d19 100644 --- a/src/base.rs +++ b/src/base.rs @@ -266,7 +266,7 @@ fn trans_stmt<'a, 'tcx: 'a>( .discriminant_for_variant(fx.tcx, *variant_index) .unwrap() .val; - let discr = CValue::const_val(fx, ptr.layout().ty, to as u64 as i64); + let discr = CValue::const_val(fx, ptr.layout().ty, to); ptr.write_cvalue(fx, discr); } layout::Variants::Multiple { @@ -289,7 +289,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let niche_llval = if niche_value == 0 { CValue::const_val(fx, niche.layout().ty, 0) } else { - CValue::const_val(fx, niche.layout().ty, niche_value as u64 as i64) + CValue::const_val(fx, niche.layout().ty, niche_value) }; niche.write_cvalue(fx, niche_llval); } @@ -562,7 +562,7 @@ fn trans_stmt<'a, 'tcx: 'a>( .ty .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all())); let ty_size = fx.layout_of(ty).size.bytes(); - let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size as i64); + let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size.into()); lval.write_cvalue(fx, val); } Rvalue::Aggregate(kind, operands) => match **kind { @@ -679,7 +679,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( .map_or(index.as_u32() as u128, |def| { def.discriminant_for_variant(fx.tcx, *index).val }); - return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); + return CValue::const_val(fx, dest_layout.ty, discr_val); } layout::Variants::Multiple { discr, discr_index, discr_kind, variants: _ } => { (discr, *discr_index, discr_kind) diff --git a/src/constant.rs b/src/constant.rs index 9a2b0cf3688b1..10f757ffce876 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -113,17 +113,13 @@ pub fn trans_const_value<'a, 'tcx: 'a>( let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); match ty.sty { - ty::Bool => { + ty::Bool | ty::Uint(_) => { let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val(fx, ty, bits as u64 as i64) - } - ty::Uint(_) => { - let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val(fx, ty, bits as u64 as i64) + CValue::const_val(fx, ty, bits) } ty::Int(_) => { let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val(fx, ty, rustc::mir::interpret::sign_extend(bits, layout.size) as i128 as i64) + CValue::const_val(fx, ty, rustc::mir::interpret::sign_extend(bits, layout.size)) } ty::FnDef(_def_id, _substs) => CValue::by_ref( fx.bcx diff --git a/src/intrinsics.rs b/src/intrinsics.rs index f521a07d91f04..ee00924ad821d 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -150,7 +150,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; size_of, () { let size_of = fx.layout_of(T).size.bytes(); - let size_of = CValue::const_val(fx, usize_layout.ty, size_of as i64); + let size_of = CValue::const_val(fx, usize_layout.ty, size_of.into()); ret.write_cvalue(fx, size_of); }; size_of_val, (c ptr) { @@ -169,7 +169,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; min_align_of, () { let min_align = fx.layout_of(T).align.abi.bytes(); - let min_align = CValue::const_val(fx, usize_layout.ty, min_align as i64); + let min_align = CValue::const_val(fx, usize_layout.ty, min_align.into()); ret.write_cvalue(fx, min_align); }; min_align_of_val, (c ptr) { @@ -188,14 +188,14 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; pref_align_of, () { let pref_align = fx.layout_of(T).align.pref.bytes(); - let pref_align = CValue::const_val(fx, usize_layout.ty, pref_align as i64); + let pref_align = CValue::const_val(fx, usize_layout.ty, pref_align.into()); ret.write_cvalue(fx, pref_align); }; type_id, () { let type_id = fx.tcx.type_id_hash(T); - let type_id = CValue::const_val(fx, u64_layout.ty, type_id as i64); + let type_id = CValue::const_val(fx, u64_layout.ty, type_id.into()); ret.write_cvalue(fx, type_id); }; type_name, () { @@ -395,9 +395,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_lz = fx.bcx.ins().clz(lsb); let msb_lz = fx.bcx.ins().clz(msb); - let msb_lz_is_64 = fx.bcx.ins().icmp_imm(IntCC::Equal, msb_lz, 64); + let msb_is_zero = fx.bcx.ins().icmp_imm(IntCC::Equal, msb, 0); let lsb_lz_plus_64 = fx.bcx.ins().iadd_imm(lsb_lz, 64); - fx.bcx.ins().select(msb_lz_is_64, lsb_lz_plus_64, msb_lz) + fx.bcx.ins().select(msb_is_zero, lsb_lz_plus_64, msb_lz) } else { fx.bcx.ins().clz(arg) }; @@ -410,9 +410,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_tz = fx.bcx.ins().ctz(lsb); let msb_tz = fx.bcx.ins().ctz(msb); - let lsb_tz_is_64 = fx.bcx.ins().icmp_imm(IntCC::Equal, lsb_tz, 64); - let msb_lz_plus_64 = fx.bcx.ins().iadd_imm(msb_tz, 64); - fx.bcx.ins().select(lsb_tz_is_64, msb_lz_plus_64, lsb_tz) + let lsb_is_zero = fx.bcx.ins().icmp_imm(IntCC::Equal, lsb, 0); + let msb_tz_plus_64 = fx.bcx.ins().iadd_imm(msb_tz, 64); + fx.bcx.ins().select(lsb_is_zero, msb_tz_plus_64, lsb_tz) } else { fx.bcx.ins().ctz(arg) }; diff --git a/src/lib.rs b/src/lib.rs index 9bd985e3dc9f4..df53d741a7528 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,7 +54,7 @@ mod vtable; mod prelude { pub use std::any::Any; pub use std::collections::{HashMap, HashSet}; - pub use std::convert::TryInto; + pub use std::convert::{TryFrom, TryInto}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::source_map::{Pos, Span, DUMMY_SP}; diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 8b5c764f69c89..21c90d0d91a93 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -162,24 +162,37 @@ impl<'tcx> CValue<'tcx> { crate::unsize::coerce_unsized_into(fx, self, dest); } + /// If `ty` is signed, `const_val` must already be sign extended. pub fn const_val<'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>, - const_val: i64, + const_val: u128, ) -> CValue<'tcx> where 'tcx: 'a, { let clif_ty = fx.clif_type(ty).unwrap(); let layout = fx.layout_of(ty); - let val = if clif_ty == types::I128 { - // FIXME don't assume little-endian arch - let lsb = fx.bcx.ins().iconst(types::I64, const_val); - let msb = fx.bcx.ins().iconst(types::I64, 0); - fx.bcx.ins().iconcat(lsb, msb) - } else { - fx.bcx.ins().iconst(clif_ty, const_val) + + let val = match ty.sty { + ty::TyKind::Uint(UintTy::U128) | ty::TyKind::Int(IntTy::I128) => { + let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64); + let msb = fx.bcx.ins().iconst(types::I64, (const_val >> 64) as u64 as i64); + fx.bcx.ins().iconcat(lsb, msb) + } + ty::TyKind::Bool => { + assert!(const_val == 0 || const_val == 1, "Invalid bool 0x{:032X}", const_val); + fx.bcx.ins().iconst(types::I8, const_val as i64) + } + ty::TyKind::Uint(_) | ty::TyKind::Ref(..) | ty::TyKind::RawPtr(.. )=> { + fx.bcx.ins().iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64) + } + ty::TyKind::Int(_) => { + fx.bcx.ins().iconst(clif_ty, const_val as i128 as i64) + } + _ => panic!("CValue::const_val for non bool/integer/pointer type {:?} is not allowed", ty), }; + CValue::by_val(val, layout) } From 7f5c2dab9dfcf128336422bcefded78a99ff1c42 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jul 2019 17:23:23 +0200 Subject: [PATCH 0745/1566] Remove some unnecessary changes --- example/mini_core.rs | 1 - example/std_example.rs | 76 ++++++++++++++++++++++++++++++++---------- src/value_and_place.rs | 41 +++++------------------ 3 files changed, 67 insertions(+), 51 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 221cdb3e863de..191f465fb8891 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -446,7 +446,6 @@ pub mod intrinsics { pub fn needs_drop() -> bool; pub fn bitreverse(x: T) -> T; pub fn bswap(x: T) -> T; - pub fn unchecked_div(lhs: T, rhs: T) -> T; } } diff --git a/example/std_example.rs b/example/std_example.rs index 465b6143525ce..bd51a37f29fab 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -3,6 +3,65 @@ use std::io::Write; use std::intrinsics; +fn main() { + let _ = ::std::iter::repeat('a' as u8).take(10).collect::>(); + let stderr = ::std::io::stderr(); + let mut stderr = stderr.lock(); + + writeln!(stderr, "some {} text", "").unwrap(); + + let _ = std::process::Command::new("true").env("c", "d").spawn(); + + println!("cargo:rustc-link-lib=z"); + + static ONCE: std::sync::Once = std::sync::ONCE_INIT; + ONCE.call_once(|| {}); + + LoopState::Continue(()) == LoopState::Break(()); + + // Make sure ByValPair values with differently sized components are correctly passed + map(None::<(u8, Box)>); + + println!("{}", 2.3f32.exp()); + println!("{}", 2.3f32.exp2()); + println!("{}", 2.3f32.abs()); + println!("{}", 2.3f32.sqrt()); + println!("{}", 2.3f32.floor()); + println!("{}", 2.3f32.ceil()); + println!("{}", 2.3f32.min(1.0)); + println!("{}", 2.3f32.max(1.0)); + + assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); + assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); + + checked_div_i128(0i128, 2i128); + checked_div_u128(0u128, 2u128); + assert_eq!(1u128 + 2, 3); + + assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128); + assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 >> 64, 0xFEDCBA98765432u128); + assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128); + assert_eq!(353985398u128 * 932490u128, 330087843781020u128); +} + +#[derive(PartialEq)] +enum LoopState { + Continue(()), + Break(()) +} + +pub enum Instruction { + Increment, + Loop, +} + +fn map(a: Option<(u8, Box)>) -> Option> { + match a { + None => None, + Some((_, instr)) => Some(instr), + } +} + fn checked_div_i128(lhs: i128, rhs: i128) -> Option { if rhs == 0 || (lhs == -170141183460469231731687303715884105728 && rhs == -1) { None @@ -17,20 +76,3 @@ fn checked_div_u128(lhs: u128, rhs: u128) -> Option { rhs => Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) } } - -fn main() { - assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); - assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); - - checked_div_i128(0i128, 2i128); - checked_div_u128(0u128, 2u128); - assert_eq!(1u128 + 2, 3); - - // overflow panic - // 0xFEDCBA987654321123456789ABCDEFu128 + 0xFEDCBA987654321123456789ABCDEFu128; - - println!("{}", 0b100010000000000000000000000000000u128 >> 10); - println!("{}", 0xFEDCBA987654321123456789ABCDEFu128 >> 64); - println!("{} >> 64 == {}", 0xFEDCBA987654321123456789ABCDEFu128 as i128, 0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64); - println!("{}", 353985398u128 * 932490u128); -} diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 21c90d0d91a93..a8b3a2954381f 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -34,31 +34,6 @@ enum CValueInner { ByValPair(Value, Value), } -fn store_scalar<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value: Value, addr: Value, offset: i32) { - if fx.bcx.func.dfg.value_type(value) == types::I128 { - let (a, b) = fx.bcx.ins().isplit(value); - fx.bcx.ins().store(MemFlags::new(), a, addr, offset); - fx.bcx.ins().store(MemFlags::new(), b, addr, offset + 8); - } else { - fx.bcx.ins().store(MemFlags::new(), value, addr, offset); - } -} - -fn load_scalar<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - clif_ty: Type, - addr: Value, - offset: i32, -) -> Value { - if clif_ty == types::I128 { - let a = fx.bcx.ins().load(types::I64, MemFlags::new(), addr, offset); - let b = fx.bcx.ins().load(types::I64, MemFlags::new(), addr, offset + 8); - fx.bcx.ins().iconcat(a, b) - } else { - fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset) - } -} - impl<'tcx> CValue<'tcx> { pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByRef(value), layout) @@ -104,7 +79,7 @@ impl<'tcx> CValue<'tcx> { _ => unreachable!(), }; let clif_ty = scalar_to_clif_type(fx.tcx, scalar); - load_scalar(fx, clif_ty, addr, 0) + fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) } CValueInner::ByVal(value) => value, CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), @@ -126,10 +101,10 @@ impl<'tcx> CValue<'tcx> { let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); - let val1 = load_scalar(fx, clif_ty1, addr, 0); - let val2 = load_scalar( - fx, + let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); + let val2 = fx.bcx.ins().load( clif_ty2, + MemFlags::new(), addr, b_offset, ); @@ -389,15 +364,15 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { match from.0 { CValueInner::ByVal(val) => { - store_scalar(fx, val, addr, 0); + fx.bcx.ins().store(MemFlags::new(), val, addr, 0); } CValueInner::ByValPair(value, extra) => { match dst_layout.abi { Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); - store_scalar(fx, value, addr, 0); - store_scalar( - fx, + fx.bcx.ins().store(MemFlags::new(), value, addr, 0); + fx.bcx.ins().store( + MemFlags::new(), extra, addr, b_offset, From 81fa33da3d3a7fa747e332de5f6adafcf4ac7bdf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jul 2019 17:56:16 +0200 Subject: [PATCH 0746/1566] Fix arg header comments --- src/abi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index b884d80b3944e..5e041e6c6d37d 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -341,7 +341,7 @@ fn add_arg_comment<'a, 'tcx: 'a>( }; let pass_mode = format!("{:?}", pass_mode); fx.add_global_comment(format!( - "{msg:5} {local:>3}{local_field:<5} {params:10} {pass_mode:20} {ssa:10} {ty:?}", + "{msg:5} {local:>3}{local_field:<5} {params:10} {pass_mode:36} {ssa:10} {ty:?}", msg = msg, local = format!("{:?}", local), local_field = local_field, @@ -355,7 +355,7 @@ fn add_arg_comment<'a, 'tcx: 'a>( #[cfg(debug_assertions)] fn add_local_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(format!( - "msg loc.idx param pass mode ssa flags ty" + "msg loc.idx param pass mode ssa flags ty" )); } From 718a5a2e3f8190d30c527692cf700fdd761d3712 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 25 Jul 2019 14:52:37 +0200 Subject: [PATCH 0747/1566] Display span in Assert panic message --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 6476de7652d19..3d09b7cefc560 100644 --- a/src/base.rs +++ b/src/base.rs @@ -164,7 +164,7 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) } else { fx.bcx.ins().brz(cond, target, &[]); }; - trap_panic(fx, format!("[panic] Assert {:?} failed at {:?}.", msg, bb_data.terminator().source_info.span)); + trap_panic(fx, format!("[panic] Assert {:?} at {:?} failed.", msg, bb_data.terminator().source_info.span)); } TerminatorKind::SwitchInt { From b46c8bfb7e2803f50cde344bd21e8f9deb59d62d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 25 Jul 2019 14:55:55 +0200 Subject: [PATCH 0748/1566] Use std checked_div --- example/std_example.rs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index bd51a37f29fab..a09e050ce3b90 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -34,8 +34,8 @@ fn main() { assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); - checked_div_i128(0i128, 2i128); - checked_div_u128(0u128, 2u128); + 0i128.checked_div(2i128); + 0u128.checked_div(2u128); assert_eq!(1u128 + 2, 3); assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128); @@ -61,18 +61,3 @@ fn map(a: Option<(u8, Box)>) -> Option> { Some((_, instr)) => Some(instr), } } - -fn checked_div_i128(lhs: i128, rhs: i128) -> Option { - if rhs == 0 || (lhs == -170141183460469231731687303715884105728 && rhs == -1) { - None - } else { - Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) - } -} - -fn checked_div_u128(lhs: u128, rhs: u128) -> Option { - match rhs { - 0 => None, - rhs => Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) - } -} From 0a833ba8a1b04281ec06892262ca326d259d1e41 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 25 Jul 2019 15:49:38 +0200 Subject: [PATCH 0749/1566] [WIP] --- build_sysroot/Cargo.toml | 8 +--- build_sysroot/build_sysroot.sh | 2 - build_sysroot/compiler-builtins | 1 + build_sysroot/compiler_builtins/Cargo.toml | 20 ---------- build_sysroot/compiler_builtins/lib.rs | 9 ----- example/alloc_example.rs | 25 ++----------- src/lib.rs | 2 + test.sh | 43 ---------------------- 8 files changed, 9 insertions(+), 101 deletions(-) create mode 160000 build_sysroot/compiler-builtins delete mode 100644 build_sysroot/compiler_builtins/Cargo.toml delete mode 100644 build_sysroot/compiler_builtins/lib.rs diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 532216ba8514f..af199c757e005 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -5,16 +5,12 @@ version = "0.0.0" [dependencies] core = { path = "./sysroot_src/src/libcore" } -compiler_builtins = "0.1" -alloc = { path = "./sysroot_src/src/liballoc" } -std = { path = "./sysroot_src/src/libstd" } - -alloc_system = { path = "./alloc_system" } +compiler_builtins = { version = "0.1", features = ["rustc-dep-of-std"] } [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } -#compiler_builtins = { path = "./compiler_builtins" } +compiler_builtins = { path = "./compiler-builtins" } [profile.release] debug = true diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 57752c402c547..ea5e4a169e566 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -4,8 +4,6 @@ cd $(dirname "$0") # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache -rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true -rm Cargo.lock 2>/dev/null || true rm -r sysroot 2>/dev/null || true # FIXME find a better way to get the target triple diff --git a/build_sysroot/compiler-builtins b/build_sysroot/compiler-builtins new file mode 160000 index 0000000000000..36da64f20e962 --- /dev/null +++ b/build_sysroot/compiler-builtins @@ -0,0 +1 @@ +Subproject commit 36da64f20e96206ac279f700586817c8abe3bdf8 diff --git a/build_sysroot/compiler_builtins/Cargo.toml b/build_sysroot/compiler_builtins/Cargo.toml deleted file mode 100644 index 724a637a20135..0000000000000 --- a/build_sysroot/compiler_builtins/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "compiler_builtins" -# Make sure the `compiler_builtins` from crates.io doesn't take precedence over this -# replacement by specifying a higher version than the one on crates.io. -version = "0.1.100" -authors = ["bjorn3 "] -edition = "2018" - -[lib] -name = "compiler_builtins" -path = "lib.rs" -test = false -doc = false - -[dependencies] -core = { path = "../sysroot_src/src/libcore" } - -[features] -rustc-dep-of-std = [] -c = [] diff --git a/build_sysroot/compiler_builtins/lib.rs b/build_sysroot/compiler_builtins/lib.rs deleted file mode 100644 index 79a54a3a4b897..0000000000000 --- a/build_sysroot/compiler_builtins/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(compiler_builtins, staged_api)] -#![compiler_builtins] -#![no_std] - -#![unstable( - feature = "compiler_builtins_lib", - reason = "Compiler builtins. Will never become stable.", - issue = "0" -)] diff --git a/example/alloc_example.rs b/example/alloc_example.rs index 20a8642cbd175..497f5fbdb2d03 100644 --- a/example/alloc_example.rs +++ b/example/alloc_example.rs @@ -1,16 +1,6 @@ -#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc_prelude, alloc_error_handler)] +#![feature(start, box_syntax, core_intrinsics, alloc_error_handler)] #![no_std] -extern crate alloc; -extern crate alloc_system; - -use alloc::prelude::v1::*; - -use alloc_system::System; - -#[global_allocator] -static ALLOC: System = System; - #[link(name = "c")] extern "C" { fn puts(s: *const u8); @@ -23,19 +13,12 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! { } } -#[alloc_error_handler] -fn alloc_error_handler(_: alloc::alloc::Layout) -> ! { - unsafe { - core::intrinsics::abort(); - } -} - #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { - let world: Box<&str> = box "Hello World!\0"; - unsafe { - puts(*world as *const str as *const u8); + extern "C" { + fn __rust_u128_mulo(a: u128, b: u128) -> (u128, bool); } + assert_eq!(unsafe { __rust_u128_mulo(353985398u128, 932490u128).0 }, 330087843781020u128); 0 } diff --git a/src/lib.rs b/src/lib.rs index df53d741a7528..8a4e79d544ba4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -243,6 +243,8 @@ fn build_isa(sess: &Session) -> Box { "false" }).unwrap(); + flags_builder.set("opt_level", "best").unwrap(); + // FIXME enable again when https://github.com/CraneStation/cranelift/issues/664 is fixed /* use rustc::session::config::OptLevel; diff --git a/test.sh b/test.sh index 1dfbf9247546c..2b8f9ad733b62 100755 --- a/test.sh +++ b/test.sh @@ -4,52 +4,9 @@ source config.sh rm -r target/out || true mkdir -p target/out/clif -echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib - -echo "[BUILD] example" -$RUSTC example/example.rs --crate-type lib - -echo "[JIT] mini_core_hello_world" -SHOULD_RUN=1 JIT_ARGS="abc bcd" $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit - -echo "[AOT] mini_core_hello_world" -$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -./target/out/mini_core_hello_world abc bcd - -echo "[AOT] arbitrary_self_types_pointers_and_wrappers" -$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin -./target/out/arbitrary_self_types_pointers_and_wrappers - echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh echo "[BUILD+RUN] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin ./target/out/alloc_example - -echo "[BUILD+RUN] std_example" -$RUSTC example/std_example.rs --crate-type bin -./target/out/std_example - -echo "[BUILD] mod_bench" -$RUSTC example/mod_bench.rs --crate-type bin - -# FIXME linker gives multiple definitions error on Linux -#echo "[BUILD] sysroot in release mode" -#./build_sysroot/build_sysroot.sh --release - -COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" -COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" -COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" -COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" -COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort" - -# Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow -hyperfine --runs 100 "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3" - -echo -echo "[Bench] mod_bench" -hyperfine ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* - -cat target/out/log.txt | sort | uniq -c From ffa34ae328c2132cf589b4f2937b507d3331add4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 26 Jul 2019 11:45:01 +0200 Subject: [PATCH 0750/1566] Remove unnecessary changes --- build_sysroot/Cargo.toml | 7 ++++-- build_sysroot/build_sysroot.sh | 2 ++ build_sysroot/compiler-builtins | 1 - example/alloc_example.rs | 25 ++++++++++++++++--- example/mini_core.rs | 8 ------ test.sh | 43 +++++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 15 deletions(-) delete mode 160000 build_sysroot/compiler-builtins diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index af199c757e005..90d245522f60f 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -5,12 +5,15 @@ version = "0.0.0" [dependencies] core = { path = "./sysroot_src/src/libcore" } -compiler_builtins = { version = "0.1", features = ["rustc-dep-of-std"] } +compiler_builtins = "0.1" +alloc = { path = "./sysroot_src/src/liballoc" } +std = { path = "./sysroot_src/src/libstd" } + +alloc_system = { path = "./alloc_system" } [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } -compiler_builtins = { path = "./compiler-builtins" } [profile.release] debug = true diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index ea5e4a169e566..57752c402c547 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -4,6 +4,8 @@ cd $(dirname "$0") # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache +rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true +rm Cargo.lock 2>/dev/null || true rm -r sysroot 2>/dev/null || true # FIXME find a better way to get the target triple diff --git a/build_sysroot/compiler-builtins b/build_sysroot/compiler-builtins deleted file mode 160000 index 36da64f20e962..0000000000000 --- a/build_sysroot/compiler-builtins +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 36da64f20e96206ac279f700586817c8abe3bdf8 diff --git a/example/alloc_example.rs b/example/alloc_example.rs index 497f5fbdb2d03..20a8642cbd175 100644 --- a/example/alloc_example.rs +++ b/example/alloc_example.rs @@ -1,6 +1,16 @@ -#![feature(start, box_syntax, core_intrinsics, alloc_error_handler)] +#![feature(start, box_syntax, alloc_system, core_intrinsics, alloc_prelude, alloc_error_handler)] #![no_std] +extern crate alloc; +extern crate alloc_system; + +use alloc::prelude::v1::*; + +use alloc_system::System; + +#[global_allocator] +static ALLOC: System = System; + #[link(name = "c")] extern "C" { fn puts(s: *const u8); @@ -13,12 +23,19 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! { } } +#[alloc_error_handler] +fn alloc_error_handler(_: alloc::alloc::Layout) -> ! { + unsafe { + core::intrinsics::abort(); + } +} + #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { - extern "C" { - fn __rust_u128_mulo(a: u128, b: u128) -> (u128, bool); + let world: Box<&str> = box "Hello World!\0"; + unsafe { + puts(*world as *const str as *const u8); } - assert_eq!(unsafe { __rust_u128_mulo(353985398u128, 932490u128).0 }, 330087843781020u128); 0 } diff --git a/example/mini_core.rs b/example/mini_core.rs index 191f465fb8891..069a930e0a2c6 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -318,14 +318,6 @@ impl Neg for i16 { } } -impl Neg for i128 { - type Output = i128; - - fn neg(self) -> i128 { - -self - } -} - impl Neg for isize { type Output = isize; diff --git a/test.sh b/test.sh index 2b8f9ad733b62..1dfbf9247546c 100755 --- a/test.sh +++ b/test.sh @@ -4,9 +4,52 @@ source config.sh rm -r target/out || true mkdir -p target/out/clif +echo "[BUILD] mini_core" +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib + +echo "[BUILD] example" +$RUSTC example/example.rs --crate-type lib + +echo "[JIT] mini_core_hello_world" +SHOULD_RUN=1 JIT_ARGS="abc bcd" $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit + +echo "[AOT] mini_core_hello_world" +$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin +./target/out/mini_core_hello_world abc bcd + +echo "[AOT] arbitrary_self_types_pointers_and_wrappers" +$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin +./target/out/arbitrary_self_types_pointers_and_wrappers + echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh echo "[BUILD+RUN] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin ./target/out/alloc_example + +echo "[BUILD+RUN] std_example" +$RUSTC example/std_example.rs --crate-type bin +./target/out/std_example + +echo "[BUILD] mod_bench" +$RUSTC example/mod_bench.rs --crate-type bin + +# FIXME linker gives multiple definitions error on Linux +#echo "[BUILD] sysroot in release mode" +#./build_sysroot/build_sysroot.sh --release + +COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" +COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" +COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" +COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" +COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort" + +# Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow +hyperfine --runs 100 "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3" + +echo +echo "[Bench] mod_bench" +hyperfine ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* + +cat target/out/log.txt | sort | uniq -c From ca714e4f01d921b4627e913c26081df1fbacb627 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 26 Jul 2019 11:47:27 +0200 Subject: [PATCH 0751/1566] Update Readme.md --- Readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 5fc18c82eca4b..56b65cf3efeab 100644 --- a/Readme.md +++ b/Readme.md @@ -29,10 +29,9 @@ $ RUSTFLAGS="-Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_ ## Not yet supported -* Good non-rust abi support ([scalar pair and vector are passed by-ref](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) +* Good non-rust abi support ([vectors are passed by-ref](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) * Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) * Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444)) -* u128 and i128 ([no cranelift support](https://github.com/CraneStation/cranelift/issues/354)) * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171)) ## Troubleshooting From 770c12ac9723cd4ecfa549a0903adf68a6c2be48 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 26 Jul 2019 12:02:51 +0200 Subject: [PATCH 0752/1566] Use own branch of clif instead of local checkout --- Cargo.lock | 60 ++++++++++++++++++++++++++++++++++++------------------ Cargo.toml | 16 ++++++++++----- 2 files changed, 51 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6752108006fdc..139fb70fd05b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,25 +117,28 @@ dependencies = [ [[package]] name = "cranelift" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-codegen 0.36.0", - "cranelift-frontend 0.36.0", + "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-frontend 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", ] [[package]] name = "cranelift-bforest" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-entity 0.36.0", + "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", ] [[package]] name = "cranelift-codegen" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-bforest 0.36.0", - "cranelift-codegen-meta 0.36.0", - "cranelift-entity 0.36.0", + "cranelift-bforest 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-codegen-meta 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -145,20 +148,23 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-entity 0.36.0", + "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", ] [[package]] name = "cranelift-entity" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" [[package]] name = "cranelift-faerie" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-codegen 0.36.0", - "cranelift-module 0.36.0", + "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -168,8 +174,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-codegen 0.36.0", + "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -177,9 +184,10 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-codegen 0.36.0", - "cranelift-entity 0.36.0", + "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -187,8 +195,9 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-codegen 0.36.0", + "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -196,10 +205,11 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.36.0" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ - "cranelift-codegen 0.36.0", - "cranelift-module 0.36.0", - "cranelift-native 0.36.0", + "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-native 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -601,10 +611,10 @@ dependencies = [ "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.36.0", - "cranelift-faerie 0.36.0", - "cranelift-module 0.36.0", - "cranelift-simplejit 0.36.0", + "cranelift 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-faerie 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-simplejit 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -872,6 +882,16 @@ dependencies = [ "checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum cranelift 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-bforest 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-codegen-meta 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-faerie 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-frontend 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-native 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift-simplejit 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" diff --git a/Cargo.toml b/Cargo.toml index 64126d917f385..414423d72b975 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,12 +27,18 @@ gimli = { git = "https://github.com/gimli-rs/gimli.git" } indexmap = "1.0.2" object = "0.12.0" -# Uncomment to use local checkout of cranelift [patch."https://github.com/CraneStation/cranelift.git"] -cranelift = { path = "../cranelift/cranelift-umbrella" } -cranelift-module = { path = "../cranelift/cranelift-module" } -cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } -cranelift-faerie = { path = "../cranelift/cranelift-faerie" } +cranelift = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } +cranelift-module = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } +cranelift-simplejit = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } +cranelift-faerie = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } + +# Uncomment to use local checkout of cranelift +#[patch."https://github.com/CraneStation/cranelift.git"] +#cranelift = { path = "../cranelift/cranelift-umbrella" } +#cranelift-module = { path = "../cranelift/cranelift-module" } +#cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } +#cranelift-faerie = { path = "../cranelift/cranelift-faerie" } #[patch."https://github.com/gimli-rs/gimli.git"] #gimli = { path = "../" } From 8506784d74603ddbe3e37aeb4f9191afc28b5205 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 26 Jul 2019 12:22:58 +0200 Subject: [PATCH 0753/1566] Reduce patching of libcore a bit These parts are no longer necessary as of #627 --- ...002-Disable-u128-and-i128-in-libcore.patch | 203 ------------------ 1 file changed, 203 deletions(-) diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch index 97ed483f7d788..0e663c0482b65 100644 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ b/patches/0002-Disable-u128-and-i128-in-libcore.patch @@ -68,209 +68,6 @@ index d0ee5fa..d02c454 100644 #[cfg(target_pointer_width = "16")] macro_rules! ptr_width { () => { 2 } -diff --git a/src/libcore/time.rs b/src/libcore/time.rs -index ae6d807..4414e07 100644 ---- a/src/libcore/time.rs -+++ b/src/libcore/time.rs -@@ -534,198 +534,6 @@ impl Duration { - pub const fn as_secs_f32(&self) -> f32 { - (self.secs as f32) + (self.nanos as f32) / (NANOS_PER_SEC as f32) - } -- -- /// Creates a new `Duration` from the specified number of seconds represented -- /// as `f64`. -- /// -- /// # Panics -- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur = Duration::from_secs_f64(2.7); -- /// assert_eq!(dur, Duration::new(2, 700_000_000)); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn from_secs_f64(secs: f64) -> Duration { -- const MAX_NANOS_F64: f64 = -- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; -- let nanos = secs * (NANOS_PER_SEC as f64); -- if !nanos.is_finite() { -- panic!("got non-finite value when converting float to duration"); -- } -- if nanos >= MAX_NANOS_F64 { -- panic!("overflow when converting float to duration"); -- } -- if nanos < 0.0 { -- panic!("underflow when converting float to duration"); -- } -- let nanos = nanos as u128; -- Duration { -- secs: (nanos / (NANOS_PER_SEC as u128)) as u64, -- nanos: (nanos % (NANOS_PER_SEC as u128)) as u32, -- } -- } -- -- /// Creates a new `Duration` from the specified number of seconds represented -- /// as `f32`. -- /// -- /// # Panics -- /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur = Duration::from_secs_f32(2.7); -- /// assert_eq!(dur, Duration::new(2, 700_000_000)); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn from_secs_f32(secs: f32) -> Duration { -- const MAX_NANOS_F32: f32 = -- ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f32; -- let nanos = secs * (NANOS_PER_SEC as f32); -- if !nanos.is_finite() { -- panic!("got non-finite value when converting float to duration"); -- } -- if nanos >= MAX_NANOS_F32 { -- panic!("overflow when converting float to duration"); -- } -- if nanos < 0.0 { -- panic!("underflow when converting float to duration"); -- } -- let nanos = nanos as u128; -- Duration { -- secs: (nanos / (NANOS_PER_SEC as u128)) as u64, -- nanos: (nanos % (NANOS_PER_SEC as u128)) as u32, -- } -- } -- -- /// Multiplies `Duration` by `f64`. -- /// -- /// # Panics -- /// This method will panic if result is not finite, negative or overflows `Duration`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur = Duration::new(2, 700_000_000); -- /// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000)); -- /// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0)); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn mul_f64(self, rhs: f64) -> Duration { -- Duration::from_secs_f64(rhs * self.as_secs_f64()) -- } -- -- /// Multiplies `Duration` by `f32`. -- /// -- /// # Panics -- /// This method will panic if result is not finite, negative or overflows `Duration`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur = Duration::new(2, 700_000_000); -- /// // note that due to rounding errors result is slightly different -- /// // from 8.478 and 847800.0 -- /// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_640)); -- /// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847799, 969_120_256)); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn mul_f32(self, rhs: f32) -> Duration { -- Duration::from_secs_f32(rhs * self.as_secs_f32()) -- } -- -- /// Divide `Duration` by `f64`. -- /// -- /// # Panics -- /// This method will panic if result is not finite, negative or overflows `Duration`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur = Duration::new(2, 700_000_000); -- /// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611)); -- /// // note that truncation is used, not rounding -- /// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_598)); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn div_f64(self, rhs: f64) -> Duration { -- Duration::from_secs_f64(self.as_secs_f64() / rhs) -- } -- -- /// Divide `Duration` by `f32`. -- /// -- /// # Panics -- /// This method will panic if result is not finite, negative or overflows `Duration`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur = Duration::new(2, 700_000_000); -- /// // note that due to rounding errors result is slightly -- /// // different from 0.859_872_611 -- /// assert_eq!(dur.div_f32(3.14), Duration::new(0, 859_872_576)); -- /// // note that truncation is used, not rounding -- /// assert_eq!(dur.div_f32(3.14e5), Duration::new(0, 8_598)); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn div_f32(self, rhs: f32) -> Duration { -- Duration::from_secs_f32(self.as_secs_f32() / rhs) -- } -- -- /// Divide `Duration` by `Duration` and return `f64`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur1 = Duration::new(2, 700_000_000); -- /// let dur2 = Duration::new(5, 400_000_000); -- /// assert_eq!(dur1.div_duration_f64(dur2), 0.5); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn div_duration_f64(self, rhs: Duration) -> f64 { -- self.as_secs_f64() / rhs.as_secs_f64() -- } -- -- /// Divide `Duration` by `Duration` and return `f32`. -- /// -- /// # Examples -- /// ``` -- /// #![feature(duration_float)] -- /// use std::time::Duration; -- /// -- /// let dur1 = Duration::new(2, 700_000_000); -- /// let dur2 = Duration::new(5, 400_000_000); -- /// assert_eq!(dur1.div_duration_f32(dur2), 0.5); -- /// ``` -- #[unstable(feature = "duration_float", issue = "54361")] -- #[inline] -- pub fn div_duration_f32(self, rhs: Duration) -> f32 { -- self.as_secs_f32() / rhs.as_secs_f32() -- } - } - - #[stable(feature = "duration", since = "1.3.0")] diff --git a/src/libstd/num.rs b/src/libstd/num.rs index 828d572..bc04fb1 100644 --- a/src/libstd/num.rs From fe20f8cba6a3599b79c335fc3284c34cf42e5b2a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jul 2019 11:35:46 +0200 Subject: [PATCH 0754/1566] Rustup to rustc 1.38.0-nightly (c43753f91 2019-07-26) --- src/abi.rs | 1 + src/allocator.rs | 3 +-- src/lib.rs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 5e041e6c6d37d..92872a14359ae 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -379,6 +379,7 @@ fn local_place<'a, 'tcx: 'a>( abi: _, variants: _, fields: _, + largest_niche: _, } = details; match place { CPlace::Stack(stack_slot, _) => fx.add_entity_comment( diff --git a/src/allocator.rs b/src/allocator.rs index cfc071612e71f..b3b2b53444d17 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -10,8 +10,7 @@ use crate::prelude::*; -use rustc::middle::allocator::AllocatorKind; -use rustc_allocator::{AllocatorTy, ALLOCATOR_METHODS}; +use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created pub fn codegen(sess: &Session, module: &mut Module) -> bool { diff --git a/src/lib.rs b/src/lib.rs index 8a4e79d544ba4..299b47403bc76 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,6 @@ extern crate flate2; extern crate rustc; -extern crate rustc_allocator; extern crate rustc_codegen_ssa; extern crate rustc_codegen_utils; extern crate rustc_data_structures; From c7fa94bf003ac2ff3a0871e619d0d84e587d2fa5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jul 2019 16:11:04 +0200 Subject: [PATCH 0755/1566] Fix checked binops when overflow checks are disabled --- src/base.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 3d09b7cefc560..dd0594611cff3 100644 --- a/src/base.rs +++ b/src/base.rs @@ -831,6 +831,11 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( ); } + match out_ty.sty { + ty::Bool | ty::Uint(_) | ty::Int(_) => {} + _ => unreachable!("Out ty {:?} is not an integer or bool", out_ty), + } + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, signed, lhs, rhs, out_ty) { return res; } @@ -875,7 +880,9 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( signed: bool, ) -> CValue<'tcx> { if !fx.tcx.sess.overflow_checks() { - return trans_int_binop(fx, bin_op, in_lhs, in_rhs, out_ty, signed); + let val = trans_int_binop(fx, bin_op, in_lhs, in_rhs, in_lhs.layout().ty, signed).load_scalar(fx); + let is_overflow = fx.bcx.ins().iconst(types::I8, 0); + return CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty)); } if bin_op != BinOp::Shl && bin_op != BinOp::Shr { From bdf23c02018ec87f30a24dd98c8ad4a8bfbf15dd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jul 2019 16:12:15 +0200 Subject: [PATCH 0756/1566] Don't set opt_level to best LICM is still broken --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 299b47403bc76..fb23522738df6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -242,7 +242,8 @@ fn build_isa(sess: &Session) -> Box { "false" }).unwrap(); - flags_builder.set("opt_level", "best").unwrap(); + // FIXME(CraneStation/cranelift#732) fix LICM in presence of jump tables + //flags_builder.set("opt_level", "best").unwrap(); // FIXME enable again when https://github.com/CraneStation/cranelift/issues/664 is fixed /* From 436a24a85dd235743852359b990c66761ff3a4b1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jul 2019 16:51:48 +0200 Subject: [PATCH 0757/1566] Implement many more float intrinsics --- example/std_example.rs | 1 + src/intrinsics.rs | 138 +++++++++++++++++++++-------------------- 2 files changed, 72 insertions(+), 67 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index a09e050ce3b90..2a9df999559bf 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -30,6 +30,7 @@ fn main() { println!("{}", 2.3f32.ceil()); println!("{}", 2.3f32.min(1.0)); println!("{}", 2.3f32.max(1.0)); + println!("{}", 2.3f32.powi(2)); assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index ee00924ad821d..1f86b096e6309 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -59,6 +59,35 @@ macro_rules! intrinsic_match { }; } +macro_rules! call_intrinsic_match { + ($fx:expr, $intrinsic:expr, $substs:expr, $ret:expr, $destination:expr, $args:expr, $( + $name:ident($($arg:ident),*) -> $ty:ident => $func:ident, + )*) => { + match $intrinsic { + $( + stringify!($name) => { + assert!($substs.is_noop()); + if let [$($arg),*] = *$args { + let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty); + $ret.write_cvalue($fx, res); + + if let Some((_, dest)) = $destination { + let ret_ebb = $fx.get_ebb(dest); + $fx.bcx.ins().jump(ret_ebb, &[]); + return; + } else { + unreachable!(); + } + } else { + bug!("wrong number of args for intrinsic {:?}", $intrinsic); + } + } + )* + _ => {} + } + } +} + macro_rules! atomic_binop_return_old { ($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) => { let clif_ty = $fx.clif_type($T).unwrap(); @@ -117,6 +146,48 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let u64_layout = fx.layout_of(fx.tcx.types.u64); let usize_layout = fx.layout_of(fx.tcx.types.usize); + call_intrinsic_match! { + fx, intrinsic, substs, ret, destination, args, + expf32(flt) -> f32 => expf, + expf64(flt) -> f64 => exp, + exp2f32(flt) -> f32 => exp2f, + exp2f64(flt) -> f64 => exp2, + sqrtf32(flt) -> f32 => sqrtf, + sqrtf64(flt) -> f64 => sqrt, + powif32(a, x) -> f32 => __powisf2, // compiler-builtins + powif64(a, x) -> f64 => __powidf2, // compiler-builtins + logf32(flt) -> f32 => logf, + logf64(flt) -> f64 => log, + fabsf32(flt) -> f32 => fabsf, + fabsf64(flt) -> f64 => fabs, + fmaf32(x, y, z) -> f32 => fmaf, + fmaf64(x, y, z) -> f64 => fma, + + // rounding variants + floorf32(flt) -> f32 => floorf, + floorf64(flt) -> f64 => floor, + ceilf32(flt) -> f32 => ceilf, + ceilf64(flt) -> f64 => ceil, + truncf32(flt) -> f32 => truncf, + truncf64(flt) -> f64 => trunc, + roundf32(flt) -> f32 => roundf, + roundf64(flt) -> f64 => round, + + // trigonometry + sinf32(flt) -> f32 => sinf, + sinf64(flt) -> f64 => sin, + cosf32(flt) -> f32 => cosf, + cosf64(flt) -> f64 => cos, + tanf32(flt) -> f32 => tanf, + tanf64(flt) -> f64 => tan, + + // minmax + minnumf32(a, b) -> f32 => fminf, + minnumf64(a, b) -> f64 => fmin, + maxnumf32(a, b) -> f32 => fmaxf, + maxnumf64(a, b) -> f64 => fmax, + } + intrinsic_match! { fx, intrinsic, substs, args, @@ -604,73 +675,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("atomic_umin"), (v ptr, v src) { atomic_minmax!(fx, IntCC::UnsignedLessThan, (ptr, src) -> ret); }; - - expf32, (c flt) { - let res = fx.easy_call("expf", &[flt], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - expf64, (c flt) { - let res = fx.easy_call("exp", &[flt], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - exp2f32, (c flt) { - let res = fx.easy_call("exp2f", &[flt], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - exp2f64, (c flt) { - let res = fx.easy_call("exp2", &[flt], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - fabsf32, (c flt) { - let res = fx.easy_call("fabsf", &[flt], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - fabsf64, (c flt) { - let res = fx.easy_call("fabs", &[flt], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - sqrtf32, (c flt) { - let res = fx.easy_call("sqrtf", &[flt], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - sqrtf64, (c flt) { - let res = fx.easy_call("sqrt", &[flt], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - floorf32, (c flt) { - let res = fx.easy_call("floorf", &[flt], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - floorf64, (c flt) { - let res = fx.easy_call("floor", &[flt], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - ceilf32, (c flt) { - let res = fx.easy_call("ceilf", &[flt], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - ceilf64, (c flt) { - let res = fx.easy_call("ceil", &[flt], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - - minnumf32, (c a, c b) { - let res = fx.easy_call("fminf", &[a, b], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - minnumf64, (c a, c b) { - let res = fx.easy_call("fmin", &[a, b], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - maxnumf32, (c a, c b) { - let res = fx.easy_call("fmaxf", &[a, b], fx.tcx.types.f32); - ret.write_cvalue(fx, res); - }; - maxnumf64, (c a, c b) { - let res = fx.easy_call("fmax", &[a, b], fx.tcx.types.f64); - ret.write_cvalue(fx, res); - }; - } if let Some((_, dest)) = destination { From dbf94c5697482c5a7947c5a17300f754a6b7e582 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Jul 2019 09:24:16 +0200 Subject: [PATCH 0758/1566] Rustup to rustc 1.38.0-nightly (c798dffac 2019-07-27) --- example/mini_core.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 069a930e0a2c6..68e056b905fa5 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,4 +1,7 @@ -#![feature(no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, untagged_unions)] +#![feature( + no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, + untagged_unions, decl_macro, rustc_attrs +)] #![no_core] #![allow(dead_code)] @@ -483,3 +486,15 @@ extern { #[lang = "va_list"] #[repr(transparent)] pub struct VaList<'a>(&'a mut VaListImpl); + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro stringify($($t:tt)*) { /* compiler built-in */ } + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro file() { /* compiler built-in */ } + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro line() { /* compiler built-in */ } From a24a956aa6377e35633c39d2f134d642bde4bb25 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Jul 2019 09:24:27 +0200 Subject: [PATCH 0759/1566] Update dependencies --- Cargo.lock | 67 ++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 139fb70fd05b7..64359a8b7683e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,11 +46,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "autocfg" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "backtrace" version = "0.3.33" @@ -67,7 +62,7 @@ name = "backtrace-sys" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -92,7 +87,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -233,7 +228,7 @@ dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -289,7 +284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -306,7 +301,7 @@ dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -430,13 +425,13 @@ name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "miniz_oxide" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -444,13 +439,13 @@ dependencies = [ [[package]] name = "miniz_oxide_c_api" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -514,17 +509,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_chacha" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -551,7 +545,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -562,22 +556,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.1.9" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.8" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -653,7 +647,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -724,12 +718,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.39" +version = "0.15.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -744,7 +738,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -797,7 +791,7 @@ dependencies = [ [[package]] name = "ucd-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -873,13 +867,12 @@ dependencies = [ "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" "checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)" = "39f75544d7bbaf57560d2168f28fd649ff9c76153874db88bdbdfd839b1a7e7d" +"checksum cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ce400c638d48ee0e9ab75aef7997609ec57367ccfe1463f21bf53c3eca67bf46" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cranelift 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" @@ -917,8 +910,8 @@ dependencies = [ "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d" -"checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494" +"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516" +"checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum object 0.12.0 (git+https://github.com/gimli-rs/object.git)" = "" "checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" @@ -928,13 +921,13 @@ dependencies = [ "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" -"checksum rand_chacha 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e193067942ef6f485a349a113329140d0ab9e2168ce92274499bb0e9a4190d9d" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "d9d8297cc20bbb6184f8b45ff61c8ee6a9ac56c156cec8e38c3e5084773c44ad" -"checksum regex-syntax 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9b01330cce219c1c6b2e209e5ed64ccd587ae5c67bed91c0b49eecf02ae40e21" +"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" +"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" @@ -952,14 +945,14 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" "checksum structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" -"checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" +"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" +"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" From 3f7660788042796773fd12e80dccd9af997f7242 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 10:32:24 +0200 Subject: [PATCH 0760/1566] Rustup to rustc 1.38.0-nightly (4560cb830 2019-07-28) --- example/mini_core_hello_world.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index e51f257f6b46a..641f0c9891295 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -216,7 +216,7 @@ fn main() { let x = &[0u32, 42u32] as &[u32]; match x { [] => assert_eq!(0u32, 1), - [_, ref y..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize), + [_, ref y @ ..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize), } assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); From 7fdd058c609e9cc727b44a63fd4d9d1ad3cef206 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jul 2019 17:48:24 +0200 Subject: [PATCH 0761/1566] Emulate some simd intrinsics --- example/std_example.rs | 16 ++++++ src/intrinsics.rs | 127 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 2a9df999559bf..7deaddd7df7c7 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -3,6 +3,7 @@ use std::io::Write; use std::intrinsics; + fn main() { let _ = ::std::iter::repeat('a' as u8).take(10).collect::>(); let stderr = ::std::io::stderr(); @@ -43,6 +44,21 @@ fn main() { assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 >> 64, 0xFEDCBA98765432u128); assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128); assert_eq!(353985398u128 * 932490u128, 330087843781020u128); + + unsafe { + test_simd(); + } +} + +#[target_feature(enable = "sse2")] +unsafe fn test_simd() { + use std::arch::x86_64::*; + + let x = _mm_setzero_si128(); + let y = _mm_set1_epi16(7); + let or = _mm_or_si128(x, y); + + assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 7]); } #[derive(PartialEq)] diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 1f86b096e6309..8efeb0b4acc39 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -116,6 +116,64 @@ macro_rules! atomic_minmax { }; } +fn lane_type_and_count<'tcx>( + fx: &FunctionCx<'_, 'tcx, impl Backend>, + layout: TyLayout<'tcx>, + intrinsic: &str, +) -> (TyLayout<'tcx>, usize) { + let lane_count = match layout.fields { + layout::FieldPlacement::Array { stride: _, count } => usize::try_from(count).unwrap(), + _ => panic!("Non vector type {:?} passed to or returned from simd_* intrinsic {}", layout.ty, intrinsic), + }; + let lane_layout = layout.field(fx, 0); + (lane_layout, lane_count) +} + +fn simd_for_each_lane<'tcx, B: Backend>( + fx: &mut FunctionCx<'_, 'tcx, B>, + intrinsic: &str, + x: CValue<'tcx>, + y: CValue<'tcx>, + ret: CPlace<'tcx>, + f: impl Fn(&mut FunctionCx<'_, 'tcx, B>, TyLayout<'tcx>, TyLayout<'tcx>, Value, Value) -> CValue<'tcx>, +) { + assert_eq!(x.layout(), y.layout()); + let layout = x.layout(); + + let (lane_layout, lane_count) = lane_type_and_count(fx, layout, intrinsic); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + assert_eq!(lane_count, ret_lane_count); + + for lane in 0..lane_count { + let lane = mir::Field::new(lane); + let x_lane = x.value_field(fx, lane).load_scalar(fx); + let y_lane = y.value_field(fx, lane).load_scalar(fx); + + let res_lane = f(fx, lane_layout, ret_lane_layout, x_lane, y_lane); + + ret.place_field(fx, lane).write_cvalue(fx, res_lane); + } +} + +macro_rules! simd_binop { + ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = fx.bcx.ins().$op(x_lane, y_lane); + CValue::by_val(res_lane, ret_lane_layout) + }); + }; + ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }); + }; +} + pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, def_id: DefId, @@ -180,12 +238,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( cosf64(flt) -> f64 => cos, tanf32(flt) -> f32 => tanf, tanf64(flt) -> f64 => tan, - - // minmax - minnumf32(a, b) -> f32 => fminf, - minnumf64(a, b) -> f64 => fmin, - maxnumf32(a, b) -> f32 => fmaxf, - maxnumf64(a, b) -> f64 => fmax, } intrinsic_match! { @@ -675,6 +727,69 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ if intrinsic.starts_with("atomic_umin"), (v ptr, v src) { atomic_minmax!(fx, IntCC::UnsignedLessThan, (ptr, src) -> ret); }; + + minnumf32, (v a, v b) { + let val = fx.bcx.ins().fmin(a, b); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32)); + ret.write_cvalue(fx, val); + }; + minnumf64, (v a, v b) { + let val = fx.bcx.ins().fmin(a, b); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64)); + ret.write_cvalue(fx, val); + }; + maxnumf32, (v a, v b) { + let val = fx.bcx.ins().fmax(a, b); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32)); + ret.write_cvalue(fx, val); + }; + maxnumf64, (v a, v b) { + let val = fx.bcx.ins().fmax(a, b); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64)); + ret.write_cvalue(fx, val); + }; + + simd_cast, (c x) { + ret.write_cvalue(fx, x.unchecked_cast_to(ret.layout())); + }; + + simd_add, (c x, c y) { + simd_binop!(fx, intrinsic, iadd(x, y) -> ret); + }; + simd_sub, (c x, c y) { + simd_binop!(fx, intrinsic, isub(x, y) -> ret); + }; + simd_mul, (c x, c y) { + simd_binop!(fx, intrinsic, imul(x, y) -> ret); + }; + simd_div, (c x, c y) { + simd_binop!(fx, intrinsic, udiv|sdiv(x, y) -> ret); + }; + simd_rem, (c x, c y) { + simd_binop!(fx, intrinsic, urem|srem(x, y) -> ret); + }; + simd_shl, (c x, c y) { + simd_binop!(fx, intrinsic, ishl(x, y) -> ret); + }; + simd_shr, (c x, c y) { + simd_binop!(fx, intrinsic, ushr|sshr(x, y) -> ret); + }; + simd_and, (c x, c y) { + simd_binop!(fx, intrinsic, band(x, y) -> ret); + }; + simd_or, (c x, c y) { + simd_binop!(fx, intrinsic, bor(x, y) -> ret); + }; + simd_bxor, (c x, c y) { + simd_binop!(fx, intrinsic, bxor(x, y) -> ret); + }; + + simd_fmin, (c x, c y) { + simd_binop!(fx, intrinsic, fmin(x, y) -> ret); + }; + simd_fmax, (c x, c y) { + simd_binop!(fx, intrinsic, fmax(x, y) -> ret); + }; } if let Some((_, dest)) = destination { From 9e3f2391b8f9da831c8aa25ce8cdc4eb4dc300ef Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jul 2019 17:52:57 +0200 Subject: [PATCH 0762/1566] Emulate compare simd intrinsics --- src/intrinsics.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 8efeb0b4acc39..3fd1d5fd6d45e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -156,6 +156,25 @@ fn simd_for_each_lane<'tcx, B: Backend>( } macro_rules! simd_binop { + ($fx:expr, $intrinsic:expr, icmp($cc:ident, $x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane); + let res_lane = fx.bcx.ins().bint(types::I8, res_lane); + CValue::by_val(res_lane, ret_lane_layout) + }); + }; + ($fx:expr, $intrinsic:expr, icmp($cc_u:ident|$cc_s:ident, $x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) => fx.bcx.ins().icmp(IntCC::$cc_u, x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc_s, x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + let res_lane = fx.bcx.ins().bint(types::I8, res_lane); + CValue::by_val(res_lane, ret_lane_layout) + }); + }; + ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, ret_lane_layout, x_lane, y_lane| { let res_lane = fx.bcx.ins().$op(x_lane, y_lane); @@ -753,6 +772,25 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, x.unchecked_cast_to(ret.layout())); }; + simd_eq, (c x, c y) { + simd_binop!(fx, intrinsic, icmp(Equal, x, y) -> ret); + }; + simd_ne, (c x, c y) { + simd_binop!(fx, intrinsic, icmp(NotEqual, x, y) -> ret); + }; + simd_lt, (c x, c y) { + simd_binop!(fx, intrinsic, icmp(UnsignedLessThan|SignedLessThan, x, y) -> ret); + }; + simd_le, (c x, c y) { + simd_binop!(fx, intrinsic, icmp(UnsignedLessThanOrEqual|SignedLessThanOrEqual, x, y) -> ret); + }; + simd_gt, (c x, c y) { + simd_binop!(fx, intrinsic, icmp(UnsignedGreaterThan|SignedGreaterThan, x, y) -> ret); + }; + simd_ge, (c x, c y) { + simd_binop!(fx, intrinsic, icmp(UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual, x, y) -> ret); + }; + simd_add, (c x, c y) { simd_binop!(fx, intrinsic, iadd(x, y) -> ret); }; From 90f2b12d473e51ba16267178aeb576edda11123a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Jul 2019 09:45:01 +0200 Subject: [PATCH 0763/1566] Fix simd comparison --- example/std_example.rs | 4 ++++ src/intrinsics.rs | 44 ++++++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 7deaddd7df7c7..7fe1d082e34bf 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -57,8 +57,12 @@ unsafe fn test_simd() { let x = _mm_setzero_si128(); let y = _mm_set1_epi16(7); let or = _mm_or_si128(x, y); + let cmp_eq = _mm_cmpeq_epi8(y, y); + let cmp_lt = _mm_cmplt_epi8(y, y); assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 7]); + assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_eq), [0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff]); + assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_lt), [0, 0, 0, 0, 0, 0, 0, 0]); } #[derive(PartialEq)] diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 3fd1d5fd6d45e..a2451ff464b6e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -155,26 +155,40 @@ fn simd_for_each_lane<'tcx, B: Backend>( } } -macro_rules! simd_binop { - ($fx:expr, $intrinsic:expr, icmp($cc:ident, $x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, ret_lane_layout, x_lane, y_lane| { +fn bool_to_zero_or_max_uint<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + layout: TyLayout<'tcx>, + val: Value, +) -> CValue<'tcx> { + let ty = fx.clif_type(layout.ty).unwrap(); + + let zero = fx.bcx.ins().iconst(ty, 0); + let max = fx.bcx.ins().iconst(ty, (u64::max_value() >> (64 - ty.bits())) as i64); + let res = crate::common::codegen_select(&mut fx.bcx, val, max, zero); + CValue::by_val(res, layout) +} + +macro_rules! simd_cmp { + ($fx:expr, $intrinsic:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane); - let res_lane = fx.bcx.ins().bint(types::I8, res_lane); - CValue::by_val(res_lane, ret_lane_layout) + bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) }); }; - ($fx:expr, $intrinsic:expr, icmp($cc_u:ident|$cc_s:ident, $x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + ($fx:expr, $intrinsic:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = match lane_layout.ty.sty { ty::Uint(_) => fx.bcx.ins().icmp(IntCC::$cc_u, x_lane, y_lane), ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc_s, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; - let res_lane = fx.bcx.ins().bint(types::I8, res_lane); - CValue::by_val(res_lane, ret_lane_layout) + bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) }); }; +} + +macro_rules! simd_binop { ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, ret_lane_layout, x_lane, y_lane| { let res_lane = fx.bcx.ins().$op(x_lane, y_lane); @@ -773,22 +787,22 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; simd_eq, (c x, c y) { - simd_binop!(fx, intrinsic, icmp(Equal, x, y) -> ret); + simd_cmp!(fx, intrinsic, Equal(x, y) -> ret); }; simd_ne, (c x, c y) { - simd_binop!(fx, intrinsic, icmp(NotEqual, x, y) -> ret); + simd_cmp!(fx, intrinsic, NotEqual(x, y) -> ret); }; simd_lt, (c x, c y) { - simd_binop!(fx, intrinsic, icmp(UnsignedLessThan|SignedLessThan, x, y) -> ret); + simd_cmp!(fx, intrinsic, UnsignedLessThan|SignedLessThan(x, y) -> ret); }; simd_le, (c x, c y) { - simd_binop!(fx, intrinsic, icmp(UnsignedLessThanOrEqual|SignedLessThanOrEqual, x, y) -> ret); + simd_cmp!(fx, intrinsic, UnsignedLessThanOrEqual|SignedLessThanOrEqual(x, y) -> ret); }; simd_gt, (c x, c y) { - simd_binop!(fx, intrinsic, icmp(UnsignedGreaterThan|SignedGreaterThan, x, y) -> ret); + simd_cmp!(fx, intrinsic, UnsignedGreaterThan|SignedGreaterThan(x, y) -> ret); }; simd_ge, (c x, c y) { - simd_binop!(fx, intrinsic, icmp(UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual, x, y) -> ret); + simd_cmp!(fx, intrinsic, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret); }; simd_add, (c x, c y) { From 1a2689117013d7137f207dc85da7df57df5e0af9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Jul 2019 09:54:57 +0200 Subject: [PATCH 0764/1566] Replace llvm intrinsics with runtime trap --- src/abi.rs | 5 +++++ src/lib.rs | 1 + src/llvm_intrinsics.rs | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/llvm_intrinsics.rs diff --git a/src/abi.rs b/src/abi.rs index 92872a14359ae..0fa546f50e538 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -643,6 +643,11 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( let instance = ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap(); + if fx.tcx.symbol_name(instance).as_str().starts_with("llvm.") { + crate::llvm_intrinsics::codegen_llvm_intrinsic_call(fx, &fx.tcx.symbol_name(instance).as_str(), substs, args, destination); + return; + } + match instance.def { InstanceDef::Intrinsic(_) => { crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination); diff --git a/src/lib.rs b/src/lib.rs index fb23522738df6..cdaabcf9a3903 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,6 +40,7 @@ mod debuginfo; mod driver; mod intrinsics; mod linkage; +mod llvm_intrinsics; mod main_shim; mod metadata; mod pretty_clif; diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs new file mode 100644 index 0000000000000..63627c41a2c97 --- /dev/null +++ b/src/llvm_intrinsics.rs @@ -0,0 +1,21 @@ +use crate::prelude::*; + +use rustc::ty::subst::SubstsRef; + +pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + intrinsic: &str, + substs: SubstsRef<'tcx>, + args: Vec>, + destination: Option<(CPlace<'tcx>, BasicBlock)>, +) { + fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); + crate::trap::trap_unimplemented(fx, intrinsic); + + if let Some((_, dest)) = destination { + let ret_ebb = fx.get_ebb(dest); + fx.bcx.ins().jump(ret_ebb, &[]); + } else { + trap_unreachable(fx, "[corruption] Diverging intrinsic returned."); + } +} From 78e0525366d0e2873797624a558fd026d8809cde Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Jul 2019 10:24:57 +0200 Subject: [PATCH 0765/1566] [WIP] simd_shuffle support --- src/intrinsics.rs | 23 ++++++++++++++++++++++- src/llvm_intrinsics.rs | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index a2451ff464b6e..5c7f8b46f5ce6 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -121,6 +121,7 @@ fn lane_type_and_count<'tcx>( layout: TyLayout<'tcx>, intrinsic: &str, ) -> (TyLayout<'tcx>, usize) { + assert!(layout.ty.is_simd()); let lane_count = match layout.fields { layout::FieldPlacement::Array { stride: _, count } => usize::try_from(count).unwrap(), _ => panic!("Non vector type {:?} passed to or returned from simd_* intrinsic {}", layout.ty, intrinsic), @@ -805,6 +806,26 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( simd_cmp!(fx, intrinsic, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret); }; + // simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U + _ if intrinsic.starts_with("simd_shuffle"), (c x, c y, c idx) { + let n: usize = intrinsic["simd_shuffle".len()..].parse().unwrap(); + + assert_eq!(x.layout(), y.layout()); + let layout = x.layout(); + + let (lane_type, lane_count) = lane_type_and_count(fx, layout, intrinsic); + let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + + assert_eq!(lane_type, ret_lane_type); + assert_eq!(n, ret_lane_count); + + let total_len = lane_count * 2; + + // TODO get shuffle indices + fx.tcx.sess.warn("simd_shuffle* not yet implemented"); + crate::trap::trap_unimplemented(fx, "simd_shuffle* not yet implemented"); + }; + simd_add, (c x, c y) { simd_binop!(fx, intrinsic, iadd(x, y) -> ret); }; @@ -832,7 +853,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( simd_or, (c x, c y) { simd_binop!(fx, intrinsic, bor(x, y) -> ret); }; - simd_bxor, (c x, c y) { + simd_xor, (c x, c y) { simd_binop!(fx, intrinsic, bxor(x, y) -> ret); }; diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index 63627c41a2c97..765adafa10b9e 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -19,3 +19,11 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( trap_unreachable(fx, "[corruption] Diverging intrinsic returned."); } } + +// llvm.x86.sse2.pmovmskb.128 +// llvm.x86.avx2.vperm2i128 +// llvm.x86.ssse3.pshuf.b.128 +// llvm.x86.avx2.pshuf.b +// llvm.x86.avx2.pmovmskb +// llvm.x86.avx2.psrli.w +// llvm.x86.sse2.psrli.w From 76b89476c3aa8ae96d544684218f772223b18031 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 28 Jul 2019 11:24:33 +0200 Subject: [PATCH 0766/1566] [WIP] simd_shuffle* --- example/std_example.rs | 2 + src/abi.rs | 44 ++++++++++----------- src/intrinsics.rs | 89 ++++++++++++++++++++++++++++++++++-------- src/llvm_intrinsics.rs | 2 +- 4 files changed, 98 insertions(+), 39 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 7fe1d082e34bf..8a4a6337ca7e1 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -59,10 +59,12 @@ unsafe fn test_simd() { let or = _mm_or_si128(x, y); let cmp_eq = _mm_cmpeq_epi8(y, y); let cmp_lt = _mm_cmplt_epi8(y, y); + let shl = _mm_slli_si128(y, 1); assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 7]); assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_eq), [0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff]); assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_lt), [0, 0, 0, 0, 0, 0, 0, 0]); + assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 0]); } #[derive(PartialEq)] diff --git a/src/abi.rs b/src/abi.rs index 0fa546f50e538..3de9ea60e7179 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -613,28 +613,6 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); let sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - // Unpack arguments tuple for closures - let args = if sig.abi == Abi::RustCall { - assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); - let self_arg = trans_operand(fx, &args[0]); - let pack_arg = trans_operand(fx, &args[1]); - let mut args = Vec::new(); - args.push(self_arg); - match pack_arg.layout().ty.sty { - ty::Tuple(ref tupled_arguments) => { - for (i, _) in tupled_arguments.iter().enumerate() { - args.push(pack_arg.value_field(fx, mir::Field::new(i))); - } - } - _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), - } - args - } else { - args.into_iter() - .map(|arg| trans_operand(fx, arg)) - .collect::>() - }; - let destination = destination .as_ref() .map(|&(ref place, bb)| (trans_place(fx, place), bb)); @@ -664,6 +642,28 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( } } + // Unpack arguments tuple for closures + let args = if sig.abi == Abi::RustCall { + assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); + let self_arg = trans_operand(fx, &args[0]); + let pack_arg = trans_operand(fx, &args[1]); + let mut args = Vec::new(); + args.push(self_arg); + match pack_arg.layout().ty.sty { + ty::Tuple(ref tupled_arguments) => { + for (i, _) in tupled_arguments.iter().enumerate() { + args.push(pack_arg.value_field(fx, mir::Field::new(i))); + } + } + _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), + } + args + } else { + args.into_iter() + .map(|arg| trans_operand(fx, arg)) + .collect::>() + }; + codegen_call_inner( fx, Some(func), diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 5c7f8b46f5ce6..c8d8bd7a79307 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -12,11 +12,14 @@ macro_rules! intrinsic_pat { } macro_rules! intrinsic_arg { - (c $fx:expr, $arg:ident) => { + (o $fx:expr, $arg:ident) => { $arg }; + (c $fx:expr, $arg:ident) => { + trans_operand($fx, $arg) + }; (v $fx:expr, $arg:ident) => { - $arg.load_scalar($fx) + trans_operand($fx, $arg).load_scalar($fx) }; } @@ -40,9 +43,9 @@ macro_rules! intrinsic_match { $( intrinsic_substs!($substs, 0, $($subst),*); )? - if let [$($arg),*] = *$args { - let ($($arg),*) = ( - $(intrinsic_arg!($a $fx, $arg)),* + if let [$($arg),*] = $args { + let ($($arg,)*) = ( + $(intrinsic_arg!($a $fx, $arg),)* ); #[warn(unused_parens, non_snake_case)] { @@ -67,7 +70,10 @@ macro_rules! call_intrinsic_match { $( stringify!($name) => { assert!($substs.is_noop()); - if let [$($arg),*] = *$args { + if let [$(ref $arg),*] = *$args { + let ($($arg,)*) = ( + $(trans_operand($fx, $arg),)* + ); let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty); $ret.write_cvalue($fx, res); @@ -120,10 +126,10 @@ fn lane_type_and_count<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, intrinsic: &str, -) -> (TyLayout<'tcx>, usize) { +) -> (TyLayout<'tcx>, u32) { assert!(layout.ty.is_simd()); let lane_count = match layout.fields { - layout::FieldPlacement::Array { stride: _, count } => usize::try_from(count).unwrap(), + layout::FieldPlacement::Array { stride: _, count } => u32::try_from(count).unwrap(), _ => panic!("Non vector type {:?} passed to or returned from simd_* intrinsic {}", layout.ty, intrinsic), }; let lane_layout = layout.field(fx, 0); @@ -146,7 +152,7 @@ fn simd_for_each_lane<'tcx, B: Backend>( assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { - let lane = mir::Field::new(lane); + let lane = mir::Field::new(lane.try_into().unwrap()); let x_lane = x.value_field(fx, lane).load_scalar(fx); let y_lane = y.value_field(fx, lane).load_scalar(fx); @@ -212,7 +218,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, def_id: DefId, substs: SubstsRef<'tcx>, - args: Vec>, + args: &[mir::Operand<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, ) { let intrinsic = fx.tcx.item_name(def_id).as_str(); @@ -499,7 +505,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); let base_val = base.load_scalar(fx); let res = fx.bcx.ins().iadd(base_val, ptr_diff); - ret.write_cvalue(fx, CValue::by_val(res, args[0].layout())); + ret.write_cvalue(fx, CValue::by_val(res, base.layout())); }; transmute, (c from) { @@ -807,8 +813,8 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; // simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U - _ if intrinsic.starts_with("simd_shuffle"), (c x, c y, c idx) { - let n: usize = intrinsic["simd_shuffle".len()..].parse().unwrap(); + _ if intrinsic.starts_with("simd_shuffle"), (c x, c y, o idx) { + let n: u32 = intrinsic["simd_shuffle".len()..].parse().unwrap(); assert_eq!(x.layout(), y.layout()); let layout = x.layout(); @@ -821,9 +827,60 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let total_len = lane_count * 2; - // TODO get shuffle indices - fx.tcx.sess.warn("simd_shuffle* not yet implemented"); - crate::trap::trap_unimplemented(fx, "simd_shuffle* not yet implemented"); + let indexes = { + use rustc::mir::interpret::*; + let idx_place = match idx { + Operand::Copy(idx_place) => { + idx_place + } + _ => panic!("simd_shuffle* idx is not Operand::Copy, but {:?}", idx), + }; + + assert!(idx_place.projection.is_none()); + let static_ = match &idx_place.base { + PlaceBase::Static(static_) => { + static_ + } + PlaceBase::Local(_) => panic!("simd_shuffle* idx is not constant, but a local"), + }; + + let idx_const = match &static_.kind { + StaticKind::Static(_) => unimplemented!(), + StaticKind::Promoted(promoted) => { + fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { + instance: fx.instance, + promoted: Some(*promoted), + })).unwrap() + } + }; + + let idx_bytes = match idx_const.val { + ConstValue::ByRef { align: _, offset, alloc } => { + let ptr = Pointer::new(AllocId(0 /* dummy */), offset); + let size = Size::from_bytes(4 * u64::from(ret_lane_count) /* size_of([u32; ret_lane_count]) */); + alloc.get_bytes(fx, ptr, size).unwrap() + } + _ => unreachable!("{:?}", idx_const), + }; + + (0..ret_lane_count).map(|i| { + let i = usize::try_from(i).unwrap(); + let idx = rustc::mir::interpret::read_target_uint( + fx.tcx.data_layout.endian, + &idx_bytes[4*i.. 4*i + 4], + ).expect("read_target_uint"); + u32::try_from(idx).expect("try_from u32") + }).collect::>() + }; + + for &idx in &indexes { + assert!(idx < total_len, "idx {} out of range 0..{}", idx, total_len); + } + + + + println!("{:?}", indexes); + unimplemented!(); }; simd_add, (c x, c y) { diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index 765adafa10b9e..1ffd43bb7808f 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -6,7 +6,7 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, intrinsic: &str, substs: SubstsRef<'tcx>, - args: Vec>, + args: &[mir::Operand<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, ) { fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); From 9cb787fe7057311741d63ee26f3e14b4d58893d5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 11:23:53 +0200 Subject: [PATCH 0767/1566] Implement and test simd_shuffle* --- example/std_example.rs | 52 ++++++++++++++++++++++++++++++++++++++++-- src/intrinsics.rs | 13 +++++++---- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 8a4a6337ca7e1..9da701d44696e 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -59,12 +59,60 @@ unsafe fn test_simd() { let or = _mm_or_si128(x, y); let cmp_eq = _mm_cmpeq_epi8(y, y); let cmp_lt = _mm_cmplt_epi8(y, y); - let shl = _mm_slli_si128(y, 1); assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 7]); assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_eq), [0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff]); assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_lt), [0, 0, 0, 0, 0, 0, 0, 0]); - assert_eq!(std::mem::transmute::<_, [u16; 8]>(or), [7, 7, 7, 7, 7, 7, 7, 0]); + + test_mm_slli_si128(); +} + +#[target_feature(enable = "sse2")] +unsafe fn test_mm_slli_si128() { + use std::arch::x86_64::*; + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, 1); + let e = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + assert_eq_m128i(r, e); + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, 15); + let e = _mm_setr_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + assert_eq_m128i(r, e); + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, 16); + assert_eq_m128i(r, _mm_set1_epi8(0)); + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, -1); + assert_eq_m128i(_mm_set1_epi8(0), r); + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + ); + let r = _mm_slli_si128(a, -0x80000000); + assert_eq_m128i(r, _mm_set1_epi8(0)); +} + +fn assert_eq_m128i(x: std::arch::x86_64::__m128i, y: std::arch::x86_64::__m128i) { + unsafe { + assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(x)); + } } #[derive(PartialEq)] diff --git a/src/intrinsics.rs b/src/intrinsics.rs index c8d8bd7a79307..251299dcdbe55 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -877,10 +877,15 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( assert!(idx < total_len, "idx {} out of range 0..{}", idx, total_len); } - - - println!("{:?}", indexes); - unimplemented!(); + for (out_idx, in_idx) in indexes.into_iter().enumerate() { + let in_lane = if in_idx < lane_count { + x.value_field(fx, mir::Field::new(in_idx.try_into().unwrap())) + } else { + y.value_field(fx, mir::Field::new((in_idx - lane_count).try_into().unwrap())) + }; + let out_lane = ret.place_field(fx, mir::Field::new(out_idx)); + out_lane.write_cvalue(fx, in_lane); + } }; simd_add, (c x, c y) { From 48a6b581b557f1120e3cb59f2ce51b1b0384275a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 12:43:24 +0200 Subject: [PATCH 0768/1566] Emulate llvm.x86.sse2.pmovmskb.128 llvm intrinsic --- src/intrinsics.rs | 43 ++++++++++++++++++++++++-------------- src/llvm_intrinsics.rs | 47 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 19 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 251299dcdbe55..042a09347092c 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -2,42 +2,50 @@ use crate::prelude::*; use rustc::ty::subst::SubstsRef; -macro_rules! intrinsic_pat { +macro intrinsic_pat { (_) => { _ - }; + }, ($name:ident) => { stringify!($name) + }, + ($name:literal) => { + stringify!($name) + }, + ($x:ident . $($xs:tt).*) => { + concat!(stringify!($x), ".", intrinsic_pat!($($xs).*)) } } -macro_rules! intrinsic_arg { +macro intrinsic_arg { (o $fx:expr, $arg:ident) => { $arg - }; + }, (c $fx:expr, $arg:ident) => { trans_operand($fx, $arg) - }; + }, (v $fx:expr, $arg:ident) => { trans_operand($fx, $arg).load_scalar($fx) - }; + } } -macro_rules! intrinsic_substs { - ($substs:expr, $index:expr,) => {}; +macro intrinsic_substs { + ($substs:expr, $index:expr,) => {}, ($substs:expr, $index:expr, $first:ident $(,$rest:ident)*) => { let $first = $substs.type_at($index); intrinsic_substs!($substs, $index+1, $($rest),*); - }; + } } -macro_rules! intrinsic_match { - ($fx:expr, $intrinsic:expr, $substs:expr, $args:expr, $( - $($name:tt)|+ $(if $cond:expr)?, $(<$($subst:ident),*>)? ($($a:ident $arg:ident),*) $content:block; +pub macro intrinsic_match { + ($fx:expr, $intrinsic:expr, $substs:expr, $args:expr, + _ => $unknown:block; + $( + $($($name:tt).*)|+ $(if $cond:expr)?, $(<$($subst:ident),*>)? ($($a:ident $arg:ident),*) $content:block; )*) => { match $intrinsic { $( - $(intrinsic_pat!($name))|* $(if $cond)? => { + $(intrinsic_pat!($($name).*))|* $(if $cond)? => { #[allow(unused_parens, non_snake_case)] { $( @@ -57,9 +65,9 @@ macro_rules! intrinsic_match { } } )* - _ => unimpl!("unsupported intrinsic {}", $intrinsic), + _ => $unknown, } - }; + } } macro_rules! call_intrinsic_match { @@ -122,7 +130,7 @@ macro_rules! atomic_minmax { }; } -fn lane_type_and_count<'tcx>( +pub fn lane_type_and_count<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, intrinsic: &str, @@ -282,6 +290,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( intrinsic_match! { fx, intrinsic, substs, args, + _ => { + unimpl!("unsupported intrinsic {}", intrinsic) + }; assume, (c _a) {}; likely | unlikely, (c a) { diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index 1ffd43bb7808f..bb99329841150 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -9,8 +9,50 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( args: &[mir::Operand<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, ) { - fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); - crate::trap::trap_unimplemented(fx, intrinsic); + let ret = match destination { + Some((place, _)) => place, + None => { + // Insert non returning intrinsics here + match intrinsic { + "abort" => { + trap_panic(fx, "Called intrinsic::abort."); + } + "unreachable" => { + trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); + } + _ => unimplemented!("unsupported instrinsic {}", intrinsic), + } + return; + } + }; + + crate::intrinsics::intrinsic_match! { + fx, intrinsic, substs, args, + _ => { + fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); + crate::trap::trap_unimplemented(fx, intrinsic); + }; + + // Used by _mm_movemask_epi8 + llvm.x86.sse2.pmovmskb.128, (c a) { + let (lane_layout, lane_count) = crate::intrinsics::lane_type_and_count(fx, a.layout(), intrinsic); + assert_eq!(lane_layout.ty.sty, fx.tcx.types.i8.sty); + assert_eq!(lane_count, 16); + + let mut res = fx.bcx.ins().iconst(types::I32, 0); + + for lane in 0..16 { + let a_lane = a.value_field(fx, mir::Field::new(lane.try_into().unwrap())).load_scalar(fx); + let a_lane_sign = fx.bcx.ins().ushr_imm(a_lane, 7); // extract sign bit of 8bit int + let a_lane_sign = fx.bcx.ins().uextend(types::I32, a_lane_sign); + res = fx.bcx.ins().ishl_imm(res, 1); + res = fx.bcx.ins().bor(res, a_lane_sign); + } + + let res = CValue::by_val(res, fx.layout_of(fx.tcx.types.i32)); + ret.write_cvalue(fx, res); + }; + } if let Some((_, dest)) = destination { let ret_ebb = fx.get_ebb(dest); @@ -20,7 +62,6 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( } } -// llvm.x86.sse2.pmovmskb.128 // llvm.x86.avx2.vperm2i128 // llvm.x86.ssse3.pshuf.b.128 // llvm.x86.avx2.pshuf.b From 63646b1956375836fac8610d04da5d2e8ce04559 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 12:50:20 +0200 Subject: [PATCH 0769/1566] Implement llvm.x86.avx2.pmovmskb llvm intrinsic --- example/std_example.rs | 27 +++++++++++++++++++++++++++ src/llvm_intrinsics.rs | 9 ++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 9da701d44696e..e3b3edd86af37 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -65,6 +65,8 @@ unsafe fn test_simd() { assert_eq!(std::mem::transmute::<_, [u16; 8]>(cmp_lt), [0, 0, 0, 0, 0, 0, 0, 0]); test_mm_slli_si128(); + test_mm_movemask_epi8(); + test_mm256_movemask_epi8(); } #[target_feature(enable = "sse2")] @@ -109,6 +111,31 @@ unsafe fn test_mm_slli_si128() { assert_eq_m128i(r, _mm_set1_epi8(0)); } +#[target_feature(enable = "sse2")] +unsafe fn test_mm_movemask_epi8() { + use std::arch::x86_64::*; + + #[rustfmt::skip] + let a = _mm_setr_epi8( + 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8, 0b01, + 0b0101, 0b1111_0000u8 as i8, 0, 0, + 0, 0, 0b1111_0000u8 as i8, 0b0101, + 0b01, 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8, + ); + let r = _mm_movemask_epi8(a); + assert_eq!(r, 0b10100100_00100101); +} + +#[target_feature(enable = "avx2")] +unsafe fn test_mm256_movemask_epi8() { + use std::arch::x86_64::*; + + let a = _mm256_set1_epi8(-1); + let r = _mm256_movemask_epi8(a); + let e = -1; + assert_eq!(r, e); +} + fn assert_eq_m128i(x: std::arch::x86_64::__m128i, y: std::arch::x86_64::__m128i) { unsafe { assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(x)); diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index bb99329841150..32aa8b5d3df67 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -33,15 +33,15 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( crate::trap::trap_unimplemented(fx, intrinsic); }; - // Used by _mm_movemask_epi8 - llvm.x86.sse2.pmovmskb.128, (c a) { + // Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8` + llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb, (c a) { let (lane_layout, lane_count) = crate::intrinsics::lane_type_and_count(fx, a.layout(), intrinsic); assert_eq!(lane_layout.ty.sty, fx.tcx.types.i8.sty); - assert_eq!(lane_count, 16); + assert!(lane_count == 16 || lane_count == 32); let mut res = fx.bcx.ins().iconst(types::I32, 0); - for lane in 0..16 { + for lane in 0..lane_count { let a_lane = a.value_field(fx, mir::Field::new(lane.try_into().unwrap())).load_scalar(fx); let a_lane_sign = fx.bcx.ins().ushr_imm(a_lane, 7); // extract sign bit of 8bit int let a_lane_sign = fx.bcx.ins().uextend(types::I32, a_lane_sign); @@ -65,6 +65,5 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( // llvm.x86.avx2.vperm2i128 // llvm.x86.ssse3.pshuf.b.128 // llvm.x86.avx2.pshuf.b -// llvm.x86.avx2.pmovmskb // llvm.x86.avx2.psrli.w // llvm.x86.sse2.psrli.w From 49b21f27309b423c702bf184e653eb9f669ef30a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 13:18:21 +0200 Subject: [PATCH 0770/1566] Fix returning (u128, u128) --- example/mini_core_hello_world.rs | 10 ++++++++++ src/abi.rs | 14 ++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 641f0c9891295..380bc487bcc96 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -117,6 +117,14 @@ impl CoerceUnsized> for Unique where T: Unsiz fn take_f32(_f: f32) {} fn take_unique(_u: Unique<()>) {} +fn return_u128_pair() -> (u128, u128) { + (0, 0) +} + +fn call_return_u128_pair() { + return_u128_pair(); +} + fn main() { take_unique(Unique { pointer: 0 as *const (), @@ -124,6 +132,8 @@ fn main() { }); take_f32(0.1); + call_return_u128_pair(); + //return; unsafe { diff --git a/src/abi.rs b/src/abi.rs index 3de9ea60e7179..f9a747da3140f 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -113,10 +113,16 @@ fn get_pass_mode<'tcx>( PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) } layout::Abi::ScalarPair(a, b) => { - PassMode::ByValPair( - scalar_to_clif_type(tcx, a.clone()), - scalar_to_clif_type(tcx, b.clone()), - ) + let a = scalar_to_clif_type(tcx, a.clone()); + let b = scalar_to_clif_type(tcx, b.clone()); + if a == types::I128 && b == types::I128 { + // Returning (i128, i128) by-val-pair would take 4 regs, while only 3 are + // available on x86_64. Cranelift gets confused when too many return params + // are used. + PassMode::ByRef + } else { + PassMode::ByValPair(a, b) + } } // FIXME implement Vector Abi in a cg_llvm compatible way From 9f0fad00243c6b1c5b491e40cb1d5b04daa51b93 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 14:35:15 +0200 Subject: [PATCH 0771/1566] Fix thread disable patch --- patches/0015-Remove-usage-of-unsized-locals.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch index 5d7a780d32971..14504cce09ff7 100644 --- a/patches/0015-Remove-usage-of-unsized-locals.patch +++ b/patches/0015-Remove-usage-of-unsized-locals.patch @@ -94,5 +94,18 @@ index b2142e7..718bb1c 100644 } pub fn min_stack() -> usize { +diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs +index f4a1783..362b537 100644 +--- a/src/libstd/sys/unix/thread.rs ++++ b/src/libstd/sys/unix/thread.rs +@@ -40,6 +40,8 @@ impl Thread { + // unsafe: see thread::Builder::spawn_unchecked for safety requirements + pub unsafe fn new(stack: usize, p: Box) + -> io::Result { ++ panic!("Threads are not yet supported, because cranelift doesn't support atomics."); ++ + let p = box p; + let mut native: libc::pthread_t = mem::zeroed(); + let mut attr: libc::pthread_attr_t = mem::zeroed(); -- 2.20.1 (Apple Git-117) From aae9a8b91dafe09adee1d80079e79526f57d29eb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 14:35:42 +0200 Subject: [PATCH 0772/1566] Patch core_arch to tell programs that cpuid is not supported --- patches/0016-Disable-cpuid-intrinsic.patch | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 patches/0016-Disable-cpuid-intrinsic.patch diff --git a/patches/0016-Disable-cpuid-intrinsic.patch b/patches/0016-Disable-cpuid-intrinsic.patch new file mode 100644 index 0000000000000..ac24bc6e88c24 --- /dev/null +++ b/patches/0016-Disable-cpuid-intrinsic.patch @@ -0,0 +1,25 @@ +From 7403e2998345ef0650fd50628d7098d4d1e88e5c Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 6 Apr 2019 12:16:21 +0200 +Subject: [PATCH] Remove usage of unsized locals + +--- + src/stdarch/crates/core_arch/src/x86/cpuid.rs | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/src/stdarch/crates/core_arch/src/x86/cpuid.rs b/src/stdarch/crates/core_arch/src/x86/cpuid.rs +index f313c42..ff952bc 100644 +--- a/src/stdarch/crates/core_arch/src/x86/cpuid.rs ++++ b/src/stdarch/crates/core_arch/src/x86/cpuid.rs +@@ -84,6 +84,9 @@ pub unsafe fn __cpuid(leaf: u32) -> CpuidResult { + /// Does the host support the `cpuid` instruction? + #[inline] + pub fn has_cpuid() -> bool { ++ // __cpuid intrinsic is not yet implemented ++ return false; ++ + #[cfg(target_env = "sgx")] + { + false +-- +2.20.1 (Apple Git-117) From ee4927e069ae317c4b2360eafe07a3fbaa8f0988 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jul 2019 18:59:17 +0200 Subject: [PATCH 0773/1566] Fix _mm_movemask_epi8 The order of iteration was wrong --- example/std_example.rs | 3 +++ src/llvm_intrinsics.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/example/std_example.rs b/example/std_example.rs index e3b3edd86af37..8a43af5bd80d3 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -67,6 +67,9 @@ unsafe fn test_simd() { test_mm_slli_si128(); test_mm_movemask_epi8(); test_mm256_movemask_epi8(); + + let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); + assert_eq!(mask1, 1); } #[target_feature(enable = "sse2")] diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index 32aa8b5d3df67..b93fa1bdbdf02 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -41,7 +41,7 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( let mut res = fx.bcx.ins().iconst(types::I32, 0); - for lane in 0..lane_count { + for lane in (0..lane_count).rev() { let a_lane = a.value_field(fx, mir::Field::new(lane.try_into().unwrap())).load_scalar(fx); let a_lane_sign = fx.bcx.ins().ushr_imm(a_lane, 7); // extract sign bit of 8bit int let a_lane_sign = fx.bcx.ins().uextend(types::I32, a_lane_sign); From 8691b8b8b6d88a51ee4783a8c704f052db479738 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Jul 2019 13:37:47 +0200 Subject: [PATCH 0774/1566] Test rust-lang/regex example shootout-regex-dna --- .gitignore | 1 + build_sysroot/build_sysroot.sh | 26 +++++++++++--------------- cargo.sh | 14 ++++++++++++++ clean_all.sh | 1 + config.sh | 10 ++-------- crate_patches/regex.patch | 34 ++++++++++++++++++++++++++++++++++ prepare.sh | 7 +++++++ test.sh | 22 ++++++++++++++++++++++ 8 files changed, 92 insertions(+), 23 deletions(-) create mode 100755 cargo.sh create mode 100644 crate_patches/regex.patch diff --git a/.gitignore b/.gitignore index 9a9df1021e5f3..c455aa46a0c43 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ perf.data.old /build_sysroot/sysroot_src /build_sysroot/Cargo.lock /rust +/regex diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 57752c402c547..165d67a8146cc 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -1,34 +1,30 @@ #!/bin/bash + +# Requires the CHANNEL env var to be set to `debug` or `release.` + set -e cd $(dirname "$0") +pushd ../ >/dev/null +source ./config.sh +popd >/dev/null + # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true rm Cargo.lock 2>/dev/null || true rm -r sysroot 2>/dev/null || true -# FIXME find a better way to get the target triple -unamestr=`uname` -if [[ "$unamestr" == 'Linux' ]]; then - TARGET_TRIPLE='x86_64-unknown-linux-gnu' -elif [[ "$unamestr" == 'Darwin' ]]; then - TARGET_TRIPLE='x86_64-apple-darwin' -else - echo "Unsupported os" - exit 1 -fi - # Build libs -mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked" if [[ "$1" == "--release" ]]; then - channel='release' + sysroot_channel='release' RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release else - channel='debug' + sysroot_channel='debug' cargo build --target $TARGET_TRIPLE fi # Copy files to sysroot -cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/cargo.sh b/cargo.sh new file mode 100755 index 0000000000000..42c137030a5d8 --- /dev/null +++ b/cargo.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ -z $CHANNEL ]; then +export CHANNEL='debug' +fi + +pushd $(dirname "$0") >/dev/null +source config.sh +popd >/dev/null + +cmd=$1 +shift + +cargo $cmd --target $TARGET_TRIPLE $@ diff --git a/clean_all.sh b/clean_all.sh index f768bb50c73f6..ced73acc57972 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -2,3 +2,4 @@ set -e rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/,Cargo.lock} perf.data{,.old} +rm -rf regex/ diff --git a/config.sh b/config.sh index 7fbd41128895d..a6868f792decf 100644 --- a/config.sh +++ b/config.sh @@ -10,14 +10,8 @@ else exit 1 fi -if [[ "$1" == "--release" ]]; then - channel='release' - cargo build --release -else - channel='debug' - cargo build -fi +TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") -export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$channel'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors diff --git a/crate_patches/regex.patch b/crate_patches/regex.patch new file mode 100644 index 0000000000000..4209ccfbdd2a9 --- /dev/null +++ b/crate_patches/regex.patch @@ -0,0 +1,34 @@ +From febff2a8c639efb5de1e1b4758cdb473847d80ce Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Tue, 30 Jul 2019 12:12:37 +0200 +Subject: [PATCH] Disable threads in shootout-regex-dna example + +--- + examples/shootout-regex-dna.rs | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/examples/shootout-regex-dna.rs b/examples/shootout-regex-dna.rs +index 2171bb3..37382f8 100644 +--- a/examples/shootout-regex-dna.rs ++++ b/examples/shootout-regex-dna.rs +@@ -37,7 +37,7 @@ fn main() { + for variant in variants { + let seq = seq_arc.clone(); + let restr = variant.to_string(); +- let future = thread::spawn(move || variant.find_iter(&seq).count()); ++ let future = variant.find_iter(&seq).count(); + counts.push((restr, future)); + } + +@@ -60,7 +60,7 @@ fn main() { + } + + for (variant, count) in counts { +- println!("{} {}", variant, count.join().unwrap()); ++ println!("{} {}", variant, count); + } + println!("\n{}\n{}\n{}", ilen, clen, seq.len()); + } +-- +2.11.0 + diff --git a/prepare.sh b/prepare.sh index be3388aac555f..32cfa4b8c8830 100755 --- a/prepare.sh +++ b/prepare.sh @@ -4,3 +4,10 @@ set -e rustup component add rust-src ./build_sysroot/prepare_sysroot_src.sh cargo install hyperfine || echo "Skipping hyperfine install" + +git clone https://github.com/rust-lang/regex.git || echo "rust-lang/regex has already been cloned" +pushd regex +git checkout -- . +git checkout 341f207c1071f7290e3f228c710817c280c8dca1 +git apply ../crate_patches/regex.patch +popd diff --git a/test.sh b/test.sh index 1dfbf9247546c..1de4a65bbed82 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,13 @@ #!/bin/bash + +if [[ "$1" == "--release" ]]; then + export CHANNEL='release' + cargo build --release +else + export CHANNEL='debug' + cargo build +fi + source config.sh rm -r target/out || true @@ -39,6 +48,19 @@ $RUSTC example/mod_bench.rs --crate-type bin #echo "[BUILD] sysroot in release mode" #./build_sysroot/build_sysroot.sh --release +pushd regex +echo "[TEST] rust-lang/regex example shootout-regex-dna" +../cargo.sh clean +# Make sure `[codegen mono items] start` doesn't poison the diff +../cargo.sh build --example shootout-regex-dna +cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt +diff -u res.txt examples/regexdna-output.txt + +# FIXME compile libtest +# echo "[TEST] rust-lang/regex standalone tests" +# ../cargo.sh test +popd + COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" From 69526d464fc0ef021beb1718d68035555f30c33d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Jul 2019 14:37:20 +0200 Subject: [PATCH 0775/1566] Implement some float simd intrinsics --- example/std_example.rs | 41 +++++++++++--- src/constant.rs | 31 ++++++++++- src/intrinsics.rs | 123 +++++++++++++++++++++++++---------------- src/llvm_intrinsics.rs | 56 ++++++++++++++++--- 4 files changed, 187 insertions(+), 64 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 8a43af5bd80d3..33523a12871aa 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,5 +1,6 @@ #![feature(core_intrinsics)] +use std::arch::x86_64::*; use std::io::Write; use std::intrinsics; @@ -52,8 +53,6 @@ fn main() { #[target_feature(enable = "sse2")] unsafe fn test_simd() { - use std::arch::x86_64::*; - let x = _mm_setzero_si128(); let y = _mm_set1_epi16(7); let or = _mm_or_si128(x, y); @@ -67,6 +66,8 @@ unsafe fn test_simd() { test_mm_slli_si128(); test_mm_movemask_epi8(); test_mm256_movemask_epi8(); + test_mm_add_epi8(); + test_mm_add_pd(); let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); assert_eq!(mask1, 1); @@ -74,8 +75,6 @@ unsafe fn test_simd() { #[target_feature(enable = "sse2")] unsafe fn test_mm_slli_si128() { - use std::arch::x86_64::*; - #[rustfmt::skip] let a = _mm_setr_epi8( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -116,8 +115,6 @@ unsafe fn test_mm_slli_si128() { #[target_feature(enable = "sse2")] unsafe fn test_mm_movemask_epi8() { - use std::arch::x86_64::*; - #[rustfmt::skip] let a = _mm_setr_epi8( 0b1000_0000u8 as i8, 0b0, 0b1000_0000u8 as i8, 0b01, @@ -131,20 +128,48 @@ unsafe fn test_mm_movemask_epi8() { #[target_feature(enable = "avx2")] unsafe fn test_mm256_movemask_epi8() { - use std::arch::x86_64::*; - let a = _mm256_set1_epi8(-1); let r = _mm256_movemask_epi8(a); let e = -1; assert_eq!(r, e); } +#[target_feature(enable = "sse2")] +unsafe fn test_mm_add_epi8() { + let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + #[rustfmt::skip] + let b = _mm_setr_epi8( + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + ); + let r = _mm_add_epi8(a, b); + #[rustfmt::skip] + let e = _mm_setr_epi8( + 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, + ); + assert_eq_m128i(r, e); +} + +#[target_feature(enable = "sse2")] +unsafe fn test_mm_add_pd() { + let a = _mm_setr_pd(1.0, 2.0); + let b = _mm_setr_pd(5.0, 10.0); + let r = _mm_add_pd(a, b); + assert_eq_m128d(r, _mm_setr_pd(6.0, 12.0)); +} + fn assert_eq_m128i(x: std::arch::x86_64::__m128i, y: std::arch::x86_64::__m128i) { unsafe { assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(x)); } } +#[target_feature(enable = "sse2")] +pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { + if _mm_movemask_pd(_mm_cmpeq_pd(a, b)) != 0b11 { + panic!("{:?} != {:?}", a, b); + } +} + #[derive(PartialEq)] enum LoopState { Continue(()), diff --git a/src/constant.rs b/src/constant.rs index 10f757ffce876..c8fb2767f9a32 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -88,7 +88,7 @@ pub fn trans_constant<'a, 'tcx: 'a>( } pub fn force_eval_const<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &FunctionCx<'a, 'tcx, impl Backend>, const_: &'tcx Const, ) -> &'tcx Const<'tcx> { match const_.val { @@ -422,3 +422,32 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { Ok(()) } } + +pub fn mir_operand_get_const_val<'tcx>( + fx: &FunctionCx<'_, 'tcx, impl Backend>, + operand: &Operand<'tcx>, +) -> Result<&'tcx Const<'tcx>, String> { + let place = match operand { + Operand::Copy(place) => place, + Operand::Constant(const_) => return Ok(force_eval_const(fx, const_.literal)), + _ => return Err(format!("{:?}", operand)), + }; + + assert!(place.projection.is_none()); + let static_ = match &place.base { + PlaceBase::Static(static_) => { + static_ + } + PlaceBase::Local(_) => return Err("local".to_string()), + }; + + Ok(match &static_.kind { + StaticKind::Static(_) => unimplemented!(), + StaticKind::Promoted(promoted) => { + fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { + instance: fx.instance, + promoted: Some(*promoted), + })).unwrap() + } + }) +} diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 042a09347092c..a456cac1d747b 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -144,7 +144,7 @@ pub fn lane_type_and_count<'tcx>( (lane_layout, lane_count) } -fn simd_for_each_lane<'tcx, B: Backend>( +pub fn simd_for_each_lane<'tcx, B: Backend>( fx: &mut FunctionCx<'_, 'tcx, B>, intrinsic: &str, x: CValue<'tcx>, @@ -170,23 +170,37 @@ fn simd_for_each_lane<'tcx, B: Backend>( } } -fn bool_to_zero_or_max_uint<'tcx>( +pub fn bool_to_zero_or_max_uint<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, val: Value, ) -> CValue<'tcx> { let ty = fx.clif_type(layout.ty).unwrap(); - let zero = fx.bcx.ins().iconst(ty, 0); - let max = fx.bcx.ins().iconst(ty, (u64::max_value() >> (64 - ty.bits())) as i64); - let res = crate::common::codegen_select(&mut fx.bcx, val, max, zero); + let int_ty = match ty { + types::F32 => types::I32, + types::F64 => types::I64, + ty => ty, + }; + + let zero = fx.bcx.ins().iconst(int_ty, 0); + let max = fx.bcx.ins().iconst(int_ty, (u64::max_value() >> (64 - int_ty.bits())) as i64); + let mut res = crate::common::codegen_select(&mut fx.bcx, val, max, zero); + + if ty.is_float() { + res = fx.bcx.ins().bitcast(ty, res); + } + CValue::by_val(res, layout) } macro_rules! simd_cmp { ($fx:expr, $intrinsic:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane); + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) }); }; @@ -203,10 +217,13 @@ macro_rules! simd_cmp { } -macro_rules! simd_binop { +macro_rules! simd_int_binop { ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, _lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = fx.bcx.ins().$op(x_lane, y_lane); + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; CValue::by_val(res_lane, ret_lane_layout) }); }; @@ -222,6 +239,42 @@ macro_rules! simd_binop { }; } +macro_rules! simd_int_flt_binop { + ($fx:expr, $intrinsic:expr, $op:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), + ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }); + }; + ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), + ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }); + }; +} + +macro_rules! simd_flt_binop { + ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }); + } +} + pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, def_id: DefId, @@ -840,30 +893,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let indexes = { use rustc::mir::interpret::*; - let idx_place = match idx { - Operand::Copy(idx_place) => { - idx_place - } - _ => panic!("simd_shuffle* idx is not Operand::Copy, but {:?}", idx), - }; - - assert!(idx_place.projection.is_none()); - let static_ = match &idx_place.base { - PlaceBase::Static(static_) => { - static_ - } - PlaceBase::Local(_) => panic!("simd_shuffle* idx is not constant, but a local"), - }; - - let idx_const = match &static_.kind { - StaticKind::Static(_) => unimplemented!(), - StaticKind::Promoted(promoted) => { - fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { - instance: fx.instance, - promoted: Some(*promoted), - })).unwrap() - } - }; + let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_shuffle* idx not const"); let idx_bytes = match idx_const.val { ConstValue::ByRef { align: _, offset, alloc } => { @@ -900,41 +930,38 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; simd_add, (c x, c y) { - simd_binop!(fx, intrinsic, iadd(x, y) -> ret); + simd_int_flt_binop!(fx, intrinsic, iadd|fadd(x, y) -> ret); }; simd_sub, (c x, c y) { - simd_binop!(fx, intrinsic, isub(x, y) -> ret); + simd_int_flt_binop!(fx, intrinsic, isub|fsub(x, y) -> ret); }; simd_mul, (c x, c y) { - simd_binop!(fx, intrinsic, imul(x, y) -> ret); + simd_int_flt_binop!(fx, intrinsic, imul|fmul(x, y) -> ret); }; simd_div, (c x, c y) { - simd_binop!(fx, intrinsic, udiv|sdiv(x, y) -> ret); - }; - simd_rem, (c x, c y) { - simd_binop!(fx, intrinsic, urem|srem(x, y) -> ret); + simd_int_flt_binop!(fx, intrinsic, udiv|sdiv|fdiv(x, y) -> ret); }; simd_shl, (c x, c y) { - simd_binop!(fx, intrinsic, ishl(x, y) -> ret); + simd_int_binop!(fx, intrinsic, ishl(x, y) -> ret); }; simd_shr, (c x, c y) { - simd_binop!(fx, intrinsic, ushr|sshr(x, y) -> ret); + simd_int_binop!(fx, intrinsic, ushr|sshr(x, y) -> ret); }; simd_and, (c x, c y) { - simd_binop!(fx, intrinsic, band(x, y) -> ret); + simd_int_binop!(fx, intrinsic, band(x, y) -> ret); }; simd_or, (c x, c y) { - simd_binop!(fx, intrinsic, bor(x, y) -> ret); + simd_int_binop!(fx, intrinsic, bor(x, y) -> ret); }; simd_xor, (c x, c y) { - simd_binop!(fx, intrinsic, bxor(x, y) -> ret); + simd_int_binop!(fx, intrinsic, bxor(x, y) -> ret); }; simd_fmin, (c x, c y) { - simd_binop!(fx, intrinsic, fmin(x, y) -> ret); + simd_flt_binop!(fx, intrinsic, fmin(x, y) -> ret); }; simd_fmax, (c x, c y) { - simd_binop!(fx, intrinsic, fmax(x, y) -> ret); + simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret); }; } diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index b93fa1bdbdf02..284bdee52b8ce 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use crate::intrinsics::*; use rustc::ty::subst::SubstsRef; @@ -26,7 +27,7 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( } }; - crate::intrinsics::intrinsic_match! { + intrinsic_match! { fx, intrinsic, substs, args, _ => { fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); @@ -34,17 +35,28 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( }; // Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8` - llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb, (c a) { - let (lane_layout, lane_count) = crate::intrinsics::lane_type_and_count(fx, a.layout(), intrinsic); - assert_eq!(lane_layout.ty.sty, fx.tcx.types.i8.sty); - assert!(lane_count == 16 || lane_count == 32); + llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb | llvm.x86.sse2.movmsk.pd, (c a) { + let (lane_layout, lane_count) = lane_type_and_count(fx, a.layout(), intrinsic); + let lane_ty = fx.clif_type(lane_layout.ty).unwrap(); + assert!(lane_count <= 32); let mut res = fx.bcx.ins().iconst(types::I32, 0); for lane in (0..lane_count).rev() { let a_lane = a.value_field(fx, mir::Field::new(lane.try_into().unwrap())).load_scalar(fx); - let a_lane_sign = fx.bcx.ins().ushr_imm(a_lane, 7); // extract sign bit of 8bit int - let a_lane_sign = fx.bcx.ins().uextend(types::I32, a_lane_sign); + + // cast float to int + let a_lane = match lane_ty { + types::F32 => fx.bcx.ins().bitcast(types::I32, a_lane), + types::F64 => fx.bcx.ins().bitcast(types::I64, a_lane), + _ => a_lane, + }; + + // extract sign bit of an int + let a_lane_sign = fx.bcx.ins().ushr_imm(a_lane, i64::from(lane_ty.bits() - 1)); + + // shift sign bit into result + let a_lane_sign = clif_intcast(fx, a_lane_sign, types::I32, false); res = fx.bcx.ins().ishl_imm(res, 1); res = fx.bcx.ins().bor(res, a_lane_sign); } @@ -52,6 +64,36 @@ pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( let res = CValue::by_val(res, fx.layout_of(fx.tcx.types.i32)); ret.write_cvalue(fx, res); }; + llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) { + let kind_const = crate::constant::mir_operand_get_const_val(fx, kind).expect("llvm.x86.sse2.cmp.* kind not const"); + let flt_cc = match kind_const.val.try_to_bits(Size::from_bytes(1)).expect(&format!("kind not scalar: {:?}", kind_const)) { + 0 => FloatCC::Equal, + 1 => FloatCC::LessThan, + 2 => FloatCC::LessThanOrEqual, + 7 => { + unimplemented!("Compares corresponding elements in `a` and `b` to see if neither is `NaN`."); + } + 3 => { + unimplemented!("Compares corresponding elements in `a` and `b` to see if either is `NaN`."); + } + 4 => FloatCC::NotEqual, + 5 => { + unimplemented!("not less than"); + } + 6 => { + unimplemented!("not less than or equal"); + } + kind => unreachable!("kind {:?}", kind), + }; + + simd_for_each_lane(fx, intrinsic, x, y, ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Float(_) => fx.bcx.ins().fcmp(flt_cc, x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) + }); + }; } if let Some((_, dest)) = destination { From b62e892fb5f9215addd3e8e7f33dc84d6ff69946 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Jul 2019 14:51:05 +0200 Subject: [PATCH 0776/1566] Misc changes --- Readme.md | 2 +- test.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 56b65cf3efeab..d26e453b2a25e 100644 --- a/Readme.md +++ b/Readme.md @@ -32,7 +32,7 @@ $ RUSTFLAGS="-Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_ * Good non-rust abi support ([vectors are passed by-ref](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) * Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) * Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444)) -* SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171)) +* SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171), some basic things work) ## Troubleshooting diff --git a/test.sh b/test.sh index 1de4a65bbed82..8df6b20796457 100755 --- a/test.sh +++ b/test.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + if [[ "$1" == "--release" ]]; then export CHANNEL='release' cargo build --release From 1028fbb68c5f2caaeda4679a59258275b8c3d26e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Jul 2019 15:00:15 +0200 Subject: [PATCH 0777/1566] Fix release builds --- src/abi.rs | 4 +++- src/trap.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index f9a747da3140f..c66dbe3958d91 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -274,7 +274,9 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { .module .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); - self.add_comment(call_inst, format!("easy_call {}", name)); + #[cfg(debug_assertions)] { + self.add_comment(call_inst, format!("easy_call {}", name)); + } let results = self.bcx.inst_results(call_inst); assert!(results.len() <= 2, "{}", results.len()); results diff --git a/src/trap.rs b/src/trap.rs index cbbe5d203bb5d..c4e2cf35766bc 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -7,7 +7,9 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms returns: vec![], }).unwrap(); let puts = fx.module.declare_func_in_func(puts, &mut fx.bcx.func); - fx.add_entity_comment(puts, "puts"); + #[cfg(debug_assertions)] { + fx.add_entity_comment(puts, "puts"); + } let symbol_name = fx.tcx.symbol_name(fx.instance); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); @@ -19,7 +21,9 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let _ = fx.module.define_data(msg_id, &data_ctx); let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); - fx.add_entity_comment(local_msg_id, msg); + #[cfg(debug_assertions)] { + fx.add_entity_comment(local_msg_id, msg); + } let msg_ptr = fx.bcx.ins().global_value(pointer_ty(fx.tcx), local_msg_id); fx.bcx.ins().call(puts, &[msg_ptr]); } From b806070a88cd0d6aaf99d3d31103c296473ca4a4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 31 Jul 2019 09:45:11 +0200 Subject: [PATCH 0778/1566] Fix simd_cast --- example/std_example.rs | 13 ++++++ src/base.rs | 39 +----------------- src/cast.rs | 93 ++++++++++++++++++++++++++++++++++++++++++ src/common.rs | 46 --------------------- src/intrinsics.rs | 23 ++++++++++- src/lib.rs | 2 + 6 files changed, 130 insertions(+), 86 deletions(-) create mode 100644 src/cast.rs diff --git a/example/std_example.rs b/example/std_example.rs index 33523a12871aa..e28da13e4c851 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -68,6 +68,7 @@ unsafe fn test_simd() { test_mm256_movemask_epi8(); test_mm_add_epi8(); test_mm_add_pd(); + test_mm_cvtepi8_epi16(); let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); assert_eq!(mask1, 1); @@ -170,6 +171,18 @@ pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { } } +#[target_feature(enable = "sse4.1")] +unsafe fn test_mm_cvtepi8_epi16() { + let a = _mm_set1_epi8(10); + let r = _mm_cvtepi8_epi16(a); + let e = _mm_set1_epi16(10); + assert_eq_m128i(r, e); + let a = _mm_set1_epi8(-10); + let r = _mm_cvtepi8_epi16(a); + let e = _mm_set1_epi16(-10); + assert_eq_m128i(r, e); +} + #[derive(PartialEq)] enum LoopState { Continue(()), diff --git a/src/base.rs b/src/base.rs index dd0594611cff3..8612177166e5e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -436,7 +436,6 @@ fn trans_stmt<'a, 'tcx: 'a>( let discr = trans_get_discriminant(fx, place, fx.layout_of(to_ty)); lval.write_cvalue(fx, discr); } else { - let from_clif_ty = fx.clif_type(from_ty).unwrap(); let to_clif_ty = fx.clif_type(to_ty).unwrap(); let from = operand.load_scalar(fx); @@ -447,43 +446,7 @@ fn trans_stmt<'a, 'tcx: 'a>( _ => panic!("{}", from_ty), }; - let res = if from_clif_ty.is_int() && to_clif_ty.is_int() { - // int-like -> int-like - crate::common::clif_intcast( - fx, - from, - to_clif_ty, - signed, - ) - } else if from_clif_ty.is_int() && to_clif_ty.is_float() { - // int-like -> float - if signed { - fx.bcx.ins().fcvt_from_sint(to_clif_ty, from) - } else { - fx.bcx.ins().fcvt_from_uint(to_clif_ty, from) - } - } else if from_clif_ty.is_float() && to_clif_ty.is_int() { - // float -> int-like - let from = operand.load_scalar(fx); - if signed { - fx.bcx.ins().fcvt_to_sint_sat(to_clif_ty, from) - } else { - fx.bcx.ins().fcvt_to_uint_sat(to_clif_ty, from) - } - } else if from_clif_ty.is_float() && to_clif_ty.is_float() { - // float -> float - match (from_clif_ty, to_clif_ty) { - (types::F32, types::F64) => { - fx.bcx.ins().fpromote(types::F64, from) - } - (types::F64, types::F32) => { - fx.bcx.ins().fdemote(types::F32, from) - } - _ => from, - } - } else { - unimpl!("rval misc {:?} {:?}", from_ty, to_ty) - }; + let res = clif_int_or_float_cast(fx, from, to_clif_ty, signed); lval.write_cvalue(fx, CValue::by_val(res, dest_layout)); } } diff --git a/src/cast.rs b/src/cast.rs new file mode 100644 index 0000000000000..d14faf4bc3306 --- /dev/null +++ b/src/cast.rs @@ -0,0 +1,93 @@ +use crate::prelude::*; + +pub fn clif_intcast<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + val: Value, + to: Type, + signed: bool, +) -> Value { + let from = fx.bcx.func.dfg.value_type(val); + match (from, to) { + // equal + (_, _) if from == to => val, + + // extend + (_, types::I128) => { + let wider = if from == types::I64 { + val + } else if signed { + fx.bcx.ins().sextend(types::I64, val) + } else { + fx.bcx.ins().uextend(types::I64, val) + }; + let zero = fx.bcx.ins().iconst(types::I64, 0); + fx.bcx.ins().iconcat(wider, zero) + } + (_, _) if to.wider_or_equal(from) => { + if signed { + fx.bcx.ins().sextend(to, val) + } else { + fx.bcx.ins().uextend(to, val) + } + } + + // reduce + (types::I128, _) => { + let (lsb, _msb) = fx.bcx.ins().isplit(val); + if to == types::I64 { + lsb + } else { + fx.bcx.ins().ireduce(to, lsb) + } + } + (_, _) => { + fx.bcx.ins().ireduce(to, val) + } + } +} + +pub fn clif_int_or_float_cast( + fx: &mut FunctionCx<'_, '_, impl Backend>, + from: Value, + to_ty: Type, + signed: bool, +) -> Value { + let from_ty = fx.bcx.func.dfg.value_type(from); + + if from_ty.is_int() && to_ty.is_int() { + // int-like -> int-like + clif_intcast( + fx, + from, + to_ty, + signed, + ) + } else if from_ty.is_int() && to_ty.is_float() { + // int-like -> float + if signed { + fx.bcx.ins().fcvt_from_sint(to_ty, from) + } else { + fx.bcx.ins().fcvt_from_uint(to_ty, from) + } + } else if from_ty.is_float() && to_ty.is_int() { + // float -> int-like + if signed { + fx.bcx.ins().fcvt_to_sint_sat(to_ty, from) + } else { + fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) + } + } else if from_ty.is_float() && to_ty.is_float() { + // float -> float + match (from_ty, to_ty) { + (types::F32, types::F64) => { + fx.bcx.ins().fpromote(types::F64, from) + } + (types::F64, types::F32) => { + fx.bcx.ins().fdemote(types::F32, from) + } + _ => from, + } + } else { + unreachable!("cast value from {:?} to {:?}", from_ty, to_ty); + } +} diff --git a/src/common.rs b/src/common.rs index 6a00d1341980b..28287390c610b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -73,52 +73,6 @@ pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: V } } -pub fn clif_intcast<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - val: Value, - to: Type, - signed: bool, -) -> Value { - let from = fx.bcx.func.dfg.value_type(val); - match (from, to) { - // equal - (_, _) if from == to => val, - - // extend - (_, types::I128) => { - let wider = if from == types::I64 { - val - } else if signed { - fx.bcx.ins().sextend(types::I64, val) - } else { - fx.bcx.ins().uextend(types::I64, val) - }; - let zero = fx.bcx.ins().iconst(types::I64, 0); - fx.bcx.ins().iconcat(wider, zero) - } - (_, _) if to.wider_or_equal(from) => { - if signed { - fx.bcx.ins().sextend(to, val) - } else { - fx.bcx.ins().uextend(to, val) - } - } - - // reduce - (types::I128, _) => { - let (lsb, _msb) = fx.bcx.ins().isplit(val); - if to == types::I64 { - lsb - } else { - fx.bcx.ins().ireduce(to, lsb) - } - } - (_, _) => { - fx.bcx.ins().ireduce(to, val) - } - } -} - fn resolve_normal_value_imm(func: &Function, val: Value) -> Option { if let ValueDef::Result(inst, 0 /*param*/) = func.dfg.value_def(val) { if let InstructionData::UnaryImm { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index a456cac1d747b..7da7e738f522f 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -853,8 +853,27 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, val); }; - simd_cast, (c x) { - ret.write_cvalue(fx, x.unchecked_cast_to(ret.layout())); + simd_cast, (c a) { + let (lane_layout, lane_count) = lane_type_and_count(fx, a.layout(), intrinsic); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + assert_eq!(lane_count, ret_lane_count); + + let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); + + let signed = match lane_layout.ty.sty { + ty::Uint(..) => false, + ty::Int(..) => true, + ty::Float(..) => false, // `signed` is unused for floats + _ => panic!("{}", lane_layout.ty), + }; + + for lane in 0..lane_count { + let lane = mir::Field::new(lane.try_into().unwrap()); + + let a_lane = a.value_field(fx, lane).load_scalar(fx); + let res = clif_int_or_float_cast(fx, a_lane, ret_lane_ty, signed); + ret.place_field(fx, lane).write_cvalue(fx, CValue::by_val(res, ret_lane_layout)); + } }; simd_eq, (c x, c y) { diff --git a/src/lib.rs b/src/lib.rs index cdaabcf9a3903..eab10e5ca5e5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,6 +33,7 @@ mod allocator; mod analyze; mod archive; mod base; +mod cast; mod codegen_i128; mod common; mod constant; @@ -94,6 +95,7 @@ mod prelude { pub use crate::abi::*; pub use crate::base::{trans_operand, trans_place}; + pub use crate::cast::*; pub use crate::common::*; pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; pub use crate::trap::*; From bc914cd43b88794ae8d65534a2ba6c86336dcf8a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 1 Aug 2019 10:54:37 +0200 Subject: [PATCH 0779/1566] Update Cargo.lock --- Cargo.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64359a8b7683e..a4ed97f9e3d77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,7 +136,7 @@ dependencies = [ "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -172,7 +172,7 @@ version = "0.36.0" source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -184,7 +184,7 @@ dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -227,7 +227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -260,7 +260,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -335,7 +335,7 @@ name = "goblin" version = "0.0.22" source = "git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83#e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83" dependencies = [ - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -345,7 +345,7 @@ name = "goblin" version = "0.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -355,7 +355,7 @@ name = "goblin" version = "0.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -401,7 +401,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -665,7 +665,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -675,7 +675,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -693,7 +693,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -906,7 +906,7 @@ dependencies = [ "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" -"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" @@ -937,7 +937,7 @@ dependencies = [ "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" +"checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" From 62166ed9c8cd1b495bddc3fcfb02f48d3fa0e043 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 1 Aug 2019 10:58:18 +0200 Subject: [PATCH 0780/1566] Correctly implement atomic_nand_* intrinsics Fixes #639 --- src/intrinsics.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 7da7e738f522f..8fee0fa457d93 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -810,7 +810,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( atomic_binop_return_old! (fx, band(ptr, src) -> ret); }; _ if intrinsic.starts_with("atomic_nand"), (v ptr, v src) { - atomic_binop_return_old! (fx, band_not(ptr, src) -> ret); + let clif_ty = fx.clif_type(T).unwrap(); + let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); + let and = fx.bcx.ins().band(old, src); + let new = fx.bcx.ins().bnot(and); + fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); + ret.write_cvalue(fx, CValue::by_val(old, fx.layout_of(T))); }; _ if intrinsic.starts_with("atomic_or"), (v ptr, v src) { atomic_binop_return_old! (fx, bor(ptr, src) -> ret); From 2f0093b8c2f44f560dd51b26ac1c6bb902513ec7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Mar 2019 18:22:43 +0100 Subject: [PATCH 0781/1566] Test mutex locking --- example/std_example.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index e28da13e4c851..63227acc4bdef 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -6,6 +6,9 @@ use std::intrinsics; fn main() { + let mutex = std::sync::Mutex::new(()); + mutex.lock().unwrap(); + let _ = ::std::iter::repeat('a' as u8).take(10).collect::>(); let stderr = ::std::io::stderr(); let mut stderr = stderr.lock(); From c4af588f72c317a015f6e26bb7d25ae288096b91 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Mar 2019 18:22:43 +0100 Subject: [PATCH 0782/1566] Correctly align all allocs Fixes #348 --- build_sysroot/Cargo.toml | 4 ---- example/mini_core.rs | 15 +++++++++++++++ example/mini_core_hello_world.rs | 4 ++++ src/constant.rs | 12 ++++++------ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 90d245522f60f..e7d90b730ebf3 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -17,7 +17,3 @@ rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } [profile.release] debug = true - -[profile.dev] -# FIXME correctly align constants, so that copy_nonoverlapping doesn't complain about alignment -debug-assertions = false diff --git a/example/mini_core.rs b/example/mini_core.rs index 68e056b905fa5..f57f1ff635d70 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -186,6 +186,21 @@ impl Sub for i16 { } } +#[lang = "rem"] +pub trait Rem { + type Output; + + fn rem(self, rhs: RHS) -> Self::Output; +} + +impl Rem for usize { + type Output = Self; + + fn rem(self, rhs: Self) -> Self { + self % rhs + } +} + #[lang = "bitor"] pub trait BitOr { type Output; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 380bc487bcc96..48ae80baaad49 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -134,6 +134,10 @@ fn main() { call_return_u128_pair(); + let slice = &[0, 1] as &[i32]; + let slice_ptr = slice as *const [i32] as *const i32; + assert_eq!(slice_ptr as usize % 4, 0); + //return; unsafe { diff --git a/src/constant.rs b/src/constant.rs index c8fb2767f9a32..b8f7d039855df 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ read_target_uint, AllocId, GlobalAlloc, Allocation, ConstValue, InterpResult, GlobalId, Scalar, }; -use rustc::ty::Const; +use rustc::ty::{Const, layout::Align}; use rustc_mir::interpret::{ InterpCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, StackPopCleanup, @@ -170,13 +170,13 @@ fn trans_const_place<'a, 'tcx: 'a>( //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); fx.constants.todo.insert(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(fx.module, alloc_id); + let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); cplace_for_dataid(fx, const_.ty, data_id) } -fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) -> DataId { +fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId, align: Align) -> DataId { module - .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, None) + .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, Some(align.bytes() as u8)) .unwrap() } @@ -245,8 +245,8 @@ fn define_all_allocs( let (data_id, alloc) = match todo_item { TodoItem::Alloc(alloc_id) => { //println!("alloc_id {}", alloc_id); - let data_id = data_id_for_alloc_id(module, alloc_id); let alloc = memory.get(alloc_id).unwrap(); + let data_id = data_id_for_alloc_id(module, alloc_id, alloc.align); (data_id, alloc) } TodoItem::Static(def_id) => { @@ -302,7 +302,7 @@ fn define_all_allocs( } GlobalAlloc::Memory(_) => { cx.todo.insert(TodoItem::Alloc(reloc)); - data_id_for_alloc_id(module, reloc) + data_id_for_alloc_id(module, reloc, alloc.align) } GlobalAlloc::Static(def_id) => { cx.todo.insert(TodoItem::Static(def_id)); From fb3fa677fa88d960b2decab9728199bbde708f41 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 4 Aug 2019 13:36:43 +0200 Subject: [PATCH 0783/1566] Call assert_module_sources --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index eab10e5ca5e5a..22beefd162350 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -195,7 +195,11 @@ impl CodegenBackend for CraneliftCodegenBackend { need_metadata_module: bool, _rx: mpsc::Receiver>, ) -> Box { - driver::codegen_crate(tcx, metadata, need_metadata_module) + let res = driver::codegen_crate(tcx, metadata, need_metadata_module); + + rustc_incremental::assert_module_sources::assert_module_sources(tcx); + + res } fn join_codegen_and_link( From a1dd460714f05610a5bb9ccbfd5d69cc1478e3f5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 4 Aug 2019 13:42:40 +0200 Subject: [PATCH 0784/1566] Rustup to rustc 1.38.0-nightly (6e0d27d93 2019-08-03) --- src/constant.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index b8f7d039855df..c8428d8d6343a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,7 +5,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::{Const, layout::Align}; use rustc_mir::interpret::{ - InterpCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, + InterpCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, }; @@ -378,7 +378,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn ptr_op( + fn binary_ptr_op( _: &InterpCx<'mir, 'tcx, Self>, _: mir::BinOp, _: ImmTy<'tcx>, @@ -387,6 +387,13 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } + fn ptr_to_int( + _: &Memory<'mir, 'tcx, Self>, + _: Pointer<()>, + ) -> InterpResult<'tcx, u64> { + panic!(); + } + fn box_alloc(_: &mut InterpCx<'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { panic!(); } From 7602a46bb9421afc4e158326f438b1853503b804 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Aug 2019 16:28:27 +0200 Subject: [PATCH 0785/1566] Implement simd_extract --- example/std_example.rs | 7 +++++++ src/intrinsics.rs | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index 63227acc4bdef..1337c3147660a 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -72,6 +72,7 @@ unsafe fn test_simd() { test_mm_add_epi8(); test_mm_add_pd(); test_mm_cvtepi8_epi16(); + test_mm_cvtsi128_si64(); let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); assert_eq!(mask1, 1); @@ -174,6 +175,12 @@ pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { } } +#[target_feature(enable = "sse2")] +unsafe fn test_mm_cvtsi128_si64() { + let r = _mm_cvtsi128_si64(std::mem::transmute::<[i64; 2], _>([5, 0])); + assert_eq!(r, 5); +} + #[target_feature(enable = "sse4.1")] unsafe fn test_mm_cvtepi8_epi16() { let a = _mm_set1_epi8(10); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 8fee0fa457d93..4f1cbbe0f109c 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -953,6 +953,18 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( } }; + simd_extract, (c v, o idx) { + let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_extract* idx not const"); + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); + let (_lane_type, lane_count) = lane_type_and_count(fx, v.layout(), intrinsic); + if idx >= lane_count.into() { + fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); + } + + let ret_lane = v.value_field(fx, mir::Field::new(idx.try_into().unwrap())); + ret.write_cvalue(fx, ret_lane); + }; + simd_add, (c x, c y) { simd_int_flt_binop!(fx, intrinsic, iadd|fadd(x, y) -> ret); }; From bd7c119e4b949238f35115e4a79f6a4dadf5deb7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Aug 2019 12:35:49 +0200 Subject: [PATCH 0786/1566] Rustup to rustc 1.38.0-nightly (6a91782b7 2019-08-06) --- src/base.rs | 6 ++++-- src/constant.rs | 3 ++- src/intrinsics.rs | 2 +- src/unsize.rs | 5 ++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/base.rs b/src/base.rs index 8612177166e5e..6d2b6ad24e803 100644 --- a/src/base.rs +++ b/src/base.rs @@ -612,7 +612,8 @@ fn codegen_array_len<'a, 'tcx: 'a>( ) -> Value { match place.layout().ty.sty { ty::Array(_elem_ty, len) => { - let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx) as i64; + let len = crate::constant::force_eval_const(fx, len) + .eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place @@ -1162,7 +1163,8 @@ pub fn trans_place_projection<'a, 'tcx: 'a>( ty::Array(elem_ty, len) => { let elem_layout = fx.layout_of(elem_ty); let ptr = base.to_addr(fx); - let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx); + let len = crate::constant::force_eval_const(fx, len) + .eval_usize(fx.tcx, ParamEnv::reveal_all()); CPlace::for_addr( fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), diff --git a/src/constant.rs b/src/constant.rs index c8428d8d6343a..6e087f8ca5e50 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -264,7 +264,7 @@ fn define_all_allocs( let const_ = tcx.const_eval(ParamEnv::reveal_all().and(cid)).unwrap(); let alloc = match const_.val { - ConstValue::ByRef { align: _, offset, alloc } if offset.bytes() == 0 => alloc, + ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", const_), }; @@ -342,6 +342,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { type FrameExtra = (); type MemoryMap = FxHashMap, Allocation<()>)>; + const CHECK_ALIGN: bool = true; const STATIC_KIND: Option = None; fn enforce_validity(_: &InterpCx<'mir, 'tcx, Self>) -> bool { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 4f1cbbe0f109c..a5788bd21ac1c 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -920,7 +920,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_shuffle* idx not const"); let idx_bytes = match idx_const.val { - ConstValue::ByRef { align: _, offset, alloc } => { + ConstValue::ByRef { alloc, offset } => { let ptr = Pointer::new(AllocId(0 /* dummy */), offset); let size = Size::from_bytes(4 * u64::from(ret_lane_count) /* size_of([u32; ret_lane_count]) */); alloc.get_bytes(fx, ptr, size).unwrap() diff --git a/src/unsize.rs b/src/unsize.rs index 8f8f9116f597c..644ca6bc3697a 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -20,7 +20,10 @@ pub fn unsized_info<'a, 'tcx: 'a>( (&ty::Array(_, len), &ty::Slice(_)) => fx .bcx .ins() - .iconst(fx.pointer_type, len.unwrap_usize(fx.tcx) as i64), + .iconst( + fx.pointer_type, + len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64, + ), (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker // traits, and hence never actually require an actual From 19a3bfec3bc159eb9b25c44c889474a61d419d8f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 7 Aug 2019 15:26:29 +0200 Subject: [PATCH 0787/1566] Fix constant alignment on macOS --- src/constant.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 6e087f8ca5e50..3ccd0f97dc549 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -281,7 +281,12 @@ fn define_all_allocs( let mut data_ctx = DataContext::new(); - data_ctx.define(alloc.bytes.to_vec().into_boxed_slice()); + let mut bytes = alloc.bytes.to_vec(); + // The machO backend of faerie doesn't align data objects correctly unless we do this. + while bytes.len() as u64 % 16 != 0 { + bytes.push(0xde); + } + data_ctx.define(bytes.into_boxed_slice()); for &(offset, (_tag, reloc)) in alloc.relocations.iter() { let addend = { From 6414f03644931085f1859a0707273b11e26a5d18 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 8 Aug 2019 14:27:50 +0200 Subject: [PATCH 0788/1566] Don't omit overflow checks for *_with_overflow intrinsics when compiling without debug assertions --- src/base.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/base.rs b/src/base.rs index 6d2b6ad24e803..1f372192f31d2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -334,15 +334,20 @@ fn trans_stmt<'a, 'tcx: 'a>( let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let res = match ty.sty { - ty::Uint(_) => { - trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) - } - ty::Int(_) => { - trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) - } + let signed = match ty.sty { + ty::Uint(_) => false, + ty::Int(_) => true, _ => unimplemented!("checked binop {:?} for {:?}", bin_op, ty), }; + + let res = if !fx.tcx.sess.overflow_checks() { + let val = trans_int_binop(fx, *bin_op, lhs, rhs, lhs.layout().ty, signed).load_scalar(fx); + let is_overflow = fx.bcx.ins().iconst(types::I8, 0); + CValue::by_val_pair(val, is_overflow, lval.layout()) + } else { + trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, signed) + }; + lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, operand) => { @@ -843,12 +848,6 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( out_ty: Ty<'tcx>, signed: bool, ) -> CValue<'tcx> { - if !fx.tcx.sess.overflow_checks() { - let val = trans_int_binop(fx, bin_op, in_lhs, in_rhs, in_lhs.layout().ty, signed).load_scalar(fx); - let is_overflow = fx.bcx.ins().iconst(types::I8, 0); - return CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty)); - } - if bin_op != BinOp::Shl && bin_op != BinOp::Shr { assert_eq!( in_lhs.layout().ty, From e7a507863c281d571995e10f1e97beca42cb89ac Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 8 Aug 2019 15:54:13 +0200 Subject: [PATCH 0789/1566] Implement real saturating behaviour for the saturating_* intrinsics with unsigned ints --- src/common.rs | 68 +++++++++++++++++++++++++++++++++++++ src/intrinsics.rs | 86 +++++++++++++++++++++++++++-------------------- 2 files changed, 117 insertions(+), 37 deletions(-) diff --git a/src/common.rs b/src/common.rs index 28287390c610b..c9c733c3f6f6e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -116,6 +116,74 @@ pub fn resolve_value_imm(func: &Function, val: Value) -> Option { } } +pub fn type_min_max_value<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> (i64, i64) { + use syntax::ast::UintTy::*; + use syntax::ast::IntTy::*; + + let uint_usize_cvt = |uint| { + match uint { + UintTy::Usize => match pointer_ty(tcx) { + types::I16 => UintTy::U16, + types::I32 => UintTy::U32, + types::I64 => UintTy::U64, + ty => unreachable!("{:?}", ty), + } + _ => uint, + } + }; + + let int_isize_cvt = |int| { + match int { + IntTy::Isize => match pointer_ty(tcx) { + types::I16 => IntTy::I16, + types::I32 => IntTy::I32, + types::I64 => IntTy::I64, + ty => unreachable!("{:?}", ty), + } + _ => int, + } + }; + + let min = match ty.sty { + ty::Uint(uint) => match uint_usize_cvt(uint) { + U8 | U16 | U32 | U64 => 0i64, + U128 => unimplemented!(), + Usize => unreachable!(), + } + ty::Int(int) => match int_isize_cvt(int) { + I8 => i8::min_value() as i64, + I16 => i16::min_value() as i64, + I32 => i32::min_value() as i64, + I64 => i64::min_value(), + I128 => unimplemented!(), + Isize => unreachable!(), + } + _ => unreachable!(), + }; + + let max = match ty.sty { + ty::Uint(uint) => match uint_usize_cvt(uint) { + U8 => u8::max_value() as i64, + U16 => u16::max_value() as i64, + U32 => u32::max_value() as i64, + U64 => u64::max_value() as i64, + U128 => unimplemented!(), + Usize => unreachable!(), + } + ty::Int(int) => match int_isize_cvt(int) { + I8 => i8::max_value() as i64, + I16 => i16::max_value() as i64, + I32 => i32::max_value() as i64, + I64 => i64::max_value(), + I128 => unimplemented!(), + Isize => unreachable!(), + } + _ => unreachable!(), + }; + + (min, max) +} + pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` pub tcx: TyCtxt<'tcx>, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index a5788bd21ac1c..9c5565fa2b530 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -470,25 +470,21 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "mul_with_overflow" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = match T.sty { - ty::Uint(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - false, - ), - ty::Int(_) => crate::base::trans_checked_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - true, - ), - _ => panic!(), + + let signed = match T.sty { + ty::Uint(_) => false, + ty::Int(_) => true, + _ => unimplemented!("{} for {:?}", intrinsic, T), }; + + let res = crate::base::trans_checked_int_binop( + fx, + bin_op, + x, + y, + ret.layout().ty, + signed, + ); ret.write_cvalue(fx, res); }; _ if intrinsic.starts_with("overflowing_"), (c x, c y) { @@ -526,28 +522,44 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let bin_op = match intrinsic { "saturating_add" => BinOp::Add, "saturating_sub" => BinOp::Sub, - "saturating_mul" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = match T.sty { - ty::Uint(_) => crate::base::trans_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - false, - ), - ty::Int(_) => crate::base::trans_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - true, - ), - _ => panic!(), + + let signed = match T.sty { + ty::Uint(_) => false, + ty::Int(_) => true, + _ => unimplemented!("{} for {:?}", intrinsic, T), }; + + let checked_res = crate::base::trans_checked_int_binop( + fx, + bin_op, + x, + y, + fx.tcx.mk_tup([T, fx.tcx.types.bool].into_iter()), + signed, + ); + + let (val, has_overflow) = checked_res.load_scalar_pair(fx); + let clif_ty = fx.clif_type(T).unwrap(); + + // `select.i8` is not implemented by Cranelift. + let has_overflow = fx.bcx.ins().uextend(types::I32, has_overflow); + + let (min, max) = type_min_max_value(fx.tcx, T); + let min = fx.bcx.ins().iconst(clif_ty, min); + let max = fx.bcx.ins().iconst(clif_ty, max); + + let val = match (intrinsic, signed) { + ("saturating_add", false) => fx.bcx.ins().select(has_overflow, max, val), + ("saturating_sub", false) => fx.bcx.ins().select(has_overflow, min, val), + ("saturating_add", true) => unimplemented!(), + ("saturating_sub", true) => unimplemented!(), + _ => unreachable!(), + }; + + let res = CValue::by_val(val, fx.layout_of(T)); + ret.write_cvalue(fx, res); }; rotate_left, (v x, v y) { From dbac2192072a2a8b964be9858d06570da1cc86ba Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 31 Jul 2019 14:04:00 +0200 Subject: [PATCH 0790/1566] Libtest support --- .gitignore | 1 + build_sysroot/Cargo.toml | 2 +- build_sysroot/build_sysroot.sh | 14 ++++++- patches/0017-Fix-libtest-compilation.patch | 49 ++++++++++++++++++++++ src/intrinsics.rs | 14 +++++++ test.sh | 2 +- 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 patches/0017-Fix-libtest-compilation.patch diff --git a/.gitignore b/.gitignore index c455aa46a0c43..d00d779cb28ae 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ perf.data.old /build_sysroot/sysroot /build_sysroot/sysroot_src /build_sysroot/Cargo.lock +/build_sysroot/test_target/Cargo.lock /rust /regex diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index e7d90b730ebf3..7776f1bd38309 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -7,7 +7,7 @@ version = "0.0.0" core = { path = "./sysroot_src/src/libcore" } compiler_builtins = "0.1" alloc = { path = "./sysroot_src/src/liballoc" } -std = { path = "./sysroot_src/src/libstd" } +std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind"] } alloc_system = { path = "./alloc_system" } diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 165d67a8146cc..4e58858f133da 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -12,7 +12,8 @@ popd >/dev/null # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true -rm Cargo.lock 2>/dev/null || true +rm -r sysroot_src/src/{libcore,libtest}/target/$TARGET_TRIPLE/$sysroot_channel/ || true +rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true rm -r sysroot 2>/dev/null || true # Build libs @@ -28,3 +29,14 @@ fi # Copy files to sysroot mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ + +if [[ "$1" == "--release" ]]; then + channel='release' + RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release --manifest-path ./sysroot_src/src/libtest/Cargo.toml +else + channel='debug' + cargo build --target $TARGET_TRIPLE --manifest-path ./sysroot_src/src/libtest/Cargo.toml +fi + +# Copy files to sysroot +cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch new file mode 100644 index 0000000000000..de035f52f33f6 --- /dev/null +++ b/patches/0017-Fix-libtest-compilation.patch @@ -0,0 +1,49 @@ +From a25405f1fc4a168c9c370524be48aff8c8ebc529 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Wed, 12 Jun 2019 18:07:23 +0200 +Subject: [PATCH] Fix libtest compilation + +--- + src/libtest/lib.rs | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs +index 810a98e..4fdde0e 100644 +--- a/src/libtest/lib.rs ++++ b/src/libtest/lib.rs +@@ -1441,11 +1441,11 @@ pub fn run_test( + return; + } + +- fn run_test_inner( ++ fn run_test_inner( + desc: TestDesc, + monitor_ch: Sender, + nocapture: bool, +- testfn: Box, ++ testfn: F, + concurrency: Concurrent, + ) { + // Buffer for capturing standard I/O +@@ -1500,15 +1500,14 @@ pub fn run_test( + (benchfn.clone())(harness) + }); + } +- DynTestFn(f) => { +- let cb = move || __rust_begin_short_backtrace(f); +- run_test_inner(desc, monitor_ch, opts.nocapture, Box::new(cb), concurrency) ++ DynTestFn(_f) => { ++ unimplemented!(); + } + StaticTestFn(f) => run_test_inner( + desc, + monitor_ch, + opts.nocapture, +- Box::new(move || __rust_begin_short_backtrace(f)), ++ move || __rust_begin_short_backtrace(f), + concurrency, + ), + } +-- +2.11.0 + diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 9c5565fa2b530..5beabfb5ee2f4 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1011,6 +1011,20 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( simd_fmax, (c x, c y) { simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret); }; + + try, (v f, v data, v _local_ptr) { + // FIXME once unwinding is supported, change this to actually catch panics + let f_sig = fx.bcx.func.import_signature(Signature { + call_conv: cranelift::codegen::isa::CallConv::SystemV, + params: vec![AbiParam::new(fx.bcx.func.dfg.value_type(data))], + returns: vec![], + }); + + fx.bcx.ins().call_indirect(f_sig, f, &[data]); + + let ret_val = CValue::const_val(fx, ret.layout().ty, 0); + ret.write_cvalue(fx, ret_val); + }; } if let Some((_, dest)) = destination { diff --git a/test.sh b/test.sh index 8df6b20796457..dc4029bfb3387 100755 --- a/test.sh +++ b/test.sh @@ -58,7 +58,7 @@ echo "[TEST] rust-lang/regex example shootout-regex-dna" cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt diff -u res.txt examples/regexdna-output.txt -# FIXME compile libtest +# FIXME fix "memory allocation of k bytes failed" # echo "[TEST] rust-lang/regex standalone tests" # ../cargo.sh test popd From 89c36194db0e9ed60986f8490e8a2820ddcf064c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 9 Aug 2019 13:18:09 +0200 Subject: [PATCH 0791/1566] Force single thread mode for libtest --- .../0018-test-Force-single-thread-mode.patch | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 patches/0018-test-Force-single-thread-mode.patch diff --git a/patches/0018-test-Force-single-thread-mode.patch b/patches/0018-test-Force-single-thread-mode.patch new file mode 100644 index 0000000000000..19cead46ff718 --- /dev/null +++ b/patches/0018-test-Force-single-thread-mode.patch @@ -0,0 +1,34 @@ +From e275a6ac96bedda2d57296914f2bb736e1e4154c Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Fri, 9 Aug 2019 13:16:55 +0200 +Subject: [PATCH] [test] Force single thread mode + +--- + src/libtest/lib.rs | 11 +---------- + 1 file changed, 1 insertion(+), 10 deletions(-) + +diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs +index 8d74d9a..c7a3c23 100644 +--- a/src/libtest/lib.rs ++++ b/src/libtest/lib.rs +@@ -1419,16 +1419,7 @@ pub fn run_test( + .unwrap(); + }; + +- // If the platform is single-threaded we're just going to run +- // the test synchronously, regardless of the concurrency +- // level. +- let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32"); +- if concurrency == Concurrent::Yes && supports_threads { +- let cfg = thread::Builder::new().name(name.as_slice().to_owned()); +- cfg.spawn(runtest).unwrap(); +- } else { +- runtest(); +- } ++ runtest(); + } + + match testfn { +-- +2.20.1 + From 82e31e25c01a7a90e572506f2050d7fe0d9bbd3f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 9 Aug 2019 14:33:59 +0200 Subject: [PATCH 0792/1566] Enable regex tests --- test.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index dc4029bfb3387..8d1f41537197a 100755 --- a/test.sh +++ b/test.sh @@ -58,9 +58,8 @@ echo "[TEST] rust-lang/regex example shootout-regex-dna" cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt diff -u res.txt examples/regexdna-output.txt -# FIXME fix "memory allocation of k bytes failed" -# echo "[TEST] rust-lang/regex standalone tests" -# ../cargo.sh test +echo "[TEST] rust-lang/regex standalone tests" +../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options popd COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" From 3a56dffb9d62eceae5f8f4471fe384d21f671e8c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Aug 2019 14:06:08 +0200 Subject: [PATCH 0793/1566] Improve ci times --- .travis.yml | 9 +++++++-- test.sh | 11 +++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17bcefde38b36..e73e9933976f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,12 @@ rust: - nightly script: - - ./prepare.sh && ./test.sh + - ./prepare.sh + - ./test.sh --release env: - - RUST_BACKTRACE=1 + global: + # Enable backtraces for easier debugging. + - RUST_BACKTRACE=1 + # Reduce amount of benchmark runs as they are slow. + - COMPILE_RUNS=2 RUN_RUNS=2 diff --git a/test.sh b/test.sh index 8d1f41537197a..aa5b183652782 100755 --- a/test.sh +++ b/test.sh @@ -58,10 +58,13 @@ echo "[TEST] rust-lang/regex example shootout-regex-dna" cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt diff -u res.txt examples/regexdna-output.txt -echo "[TEST] rust-lang/regex standalone tests" +echo "[TEST] rust-lang/regex tests" ../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options popd +echo +echo "[BENCH COMPILE] mod_bench" + COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" @@ -69,10 +72,10 @@ COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-leve COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort" # Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow -hyperfine --runs 100 "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3" +hyperfine --runs ${COMPILE_RUNS:-100} "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3" echo -echo "[Bench] mod_bench" -hyperfine ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* +echo "[BENCH RUN] mod_bench" +hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* cat target/out/log.txt | sort | uniq -c From bbcffc23cafb8b4965c54860156fa9a0b0a16de1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Aug 2019 14:33:59 +0200 Subject: [PATCH 0794/1566] Update Cargo.lock --- Cargo.lock | 59 ++++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4ed97f9e3d77..1311e02f78f61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,7 +7,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "aho-corasick" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -48,7 +48,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -228,7 +228,7 @@ dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -273,7 +273,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -311,10 +311,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -390,9 +390,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "libc" @@ -507,7 +504,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -528,7 +525,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -556,23 +553,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "region" @@ -678,11 +671,6 @@ dependencies = [ "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "spin" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -789,11 +777,6 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ucd-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicode-segmentation" version = "1.3.0" @@ -809,11 +792,6 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "utf8-ranges" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "uuid" version = "0.7.4" @@ -862,12 +840,12 @@ dependencies = [ [metadata] "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" -"checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" -"checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" +"checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -895,7 +873,7 @@ dependencies = [ "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" +"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" "checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)" = "" "checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" @@ -926,8 +904,8 @@ dependencies = [ "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" -"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" +"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" +"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" @@ -939,7 +917,6 @@ dependencies = [ "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" -"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" @@ -952,11 +929,9 @@ dependencies = [ "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" From 3000a3f63d9bb96614a1d8ee9dc4d3005af0489e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Aug 2019 16:50:23 +0200 Subject: [PATCH 0795/1566] [WIP] Implement dylib loading for the JIT --- Cargo.lock | 11 +++++++++ Cargo.toml | 1 + config.sh | 3 +++ example/mini_core.rs | 7 ------ src/driver.rs | 59 ++++++++++++++++++++++++++++++++++++++++++-- test.sh | 9 ++++--- 6 files changed, 78 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1311e02f78f61..c642747e6f01d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -396,6 +396,15 @@ name = "libc" version = "0.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libloading" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "log" version = "0.4.8" @@ -606,6 +615,7 @@ dependencies = [ "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -884,6 +894,7 @@ dependencies = [ "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5692f82b51823e27c4118b3e5c0d98aee9be90633ebc71ad12afef380b50219" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" diff --git a/Cargo.toml b/Cargo.toml index 414423d72b975..ec0350687aacb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ tempfile = "3.0.7" gimli = { git = "https://github.com/gimli-rs/gimli.git" } indexmap = "1.0.2" object = "0.12.0" +libloading = "0.5.1" [patch."https://github.com/CraneStation/cranelift.git"] cranelift = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } diff --git a/config.sh b/config.sh index a6868f792decf..1d5c78c8e729d 100644 --- a/config.sh +++ b/config.sh @@ -15,3 +15,6 @@ TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors + +export LD_LIBRARY_PATH=$(pwd)/target/out +export DYLD_LIBRARY_PATH=$(pwd)/target/out diff --git a/example/mini_core.rs b/example/mini_core.rs index f57f1ff635d70..84664eb413927 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -369,9 +369,6 @@ pub trait FnMut: FnOnce { } #[lang = "panic"] -// Make it available to jited mini_core_hello_world -// FIXME remove next line when jit supports linking rlibs -#[inline(always)] pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); @@ -419,15 +416,11 @@ impl Deref for Box { } #[lang = "exchange_malloc"] -// Make it available to jited mini_core_hello_world -// FIXME remove next line when jit supports linking rlibs -#[inline(always)] unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { libc::malloc(size) } #[lang = "box_free"] -#[inline(always)] unsafe fn box_free(ptr: *mut T) { libc::free(ptr as *mut u8); } diff --git a/src/driver.rs b/src/driver.rs index 413f9f4e04840..e3bf4a0d56936 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -48,9 +48,64 @@ pub fn codegen_crate( fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; - let mut jit_module: Module = Module::new(SimpleJITBuilder::new( + let mut dylib_paths = Vec::new(); + + { + use rustc::middle::dependency_format::Linkage; + + let crate_info = CrateInfo::new(tcx); + let formats = tcx.sess.dependency_formats.borrow(); + let data = formats.get(&CrateType::Executable).unwrap(); + for &(cnum, _) in &crate_info.used_crates_dynamic { + let src = &crate_info.used_crate_source[&cnum]; + match data[cnum.as_usize() - 1] { + _ if crate_info.profiler_runtime == Some(cnum) => unimplemented!(), + _ if crate_info.sanitizer_runtime == Some(cnum) => unimplemented!(), + + // compiler-builtins are always placed last to ensure that they're + // linked correctly. + _ if crate_info.compiler_builtins == Some(cnum) => { + unimplemented!(); + } + Linkage::NotLinked | + Linkage::IncludedFromDylib => {} + Linkage::Static => { + let name = tcx.crate_name(cnum); + let mut err = tcx.sess.struct_fatal(&format!("Can't load static lib {}", name.as_str())); + err.note("rustc_codegen_cranelift can only load dylibs in JIT mode."); + err.emit(); + } + Linkage::Dynamic => { + dylib_paths.push(src.dylib.as_ref().unwrap().0.clone()); + } + } + } + } + + let mut imported_symbols = Vec::new(); + for path in dylib_paths { + use object::Object; + let lib = libloading::Library::new(&path).unwrap(); + let obj = std::fs::read(path).unwrap(); + let obj = object::File::parse(&obj).unwrap(); + imported_symbols.extend(obj.dynamic_symbols().filter_map(|(_idx, symbol)| { + let name = symbol.name().unwrap().to_string(); + if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { + return None; + } + println!("name: {:?}", name); + let symbol: libloading::Symbol<*const u8> = + unsafe { lib.get(name.as_bytes()) }.unwrap(); + Some((name, *symbol)) + })); + std::mem::forget(lib) + } + + let mut jit_builder = SimpleJITBuilder::new( cranelift_module::default_libcall_names(), - )); + ); + jit_builder.symbols(imported_symbols); + let mut jit_module: Module = Module::new(jit_builder); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); let sig = Signature { diff --git a/test.sh b/test.sh index aa5b183652782..71c3ba50f7e1c 100755 --- a/test.sh +++ b/test.sh @@ -33,13 +33,16 @@ $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitr ./target/out/arbitrary_self_types_pointers_and_wrappers echo "[BUILD] sysroot" -time ./build_sysroot/build_sysroot.sh +#time ./build_sysroot/build_sysroot.sh -echo "[BUILD+RUN] alloc_example" +echo "[AOT] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin ./target/out/alloc_example -echo "[BUILD+RUN] std_example" +echo "[JIT] std_example" +SHOULD_RUN=1 $RUSTC example/std_example.rs --crate-type bin -Cprefer-dynamic + +echo "[AOT] std_example" $RUSTC example/std_example.rs --crate-type bin ./target/out/std_example From 1538f7488e370f380aa5832f2d23f7010c1809f2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Aug 2019 16:56:19 +0200 Subject: [PATCH 0796/1566] Add libstd.so to sysroot --- build_sysroot/build_sysroot.sh | 4 ++-- test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 4e58858f133da..c37dd5104a858 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -28,7 +28,7 @@ fi # Copy files to sysroot mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ -cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ if [[ "$1" == "--release" ]]; then channel='release' @@ -39,4 +39,4 @@ else fi # Copy files to sysroot -cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/test.sh b/test.sh index 71c3ba50f7e1c..cd2b9fe448398 100755 --- a/test.sh +++ b/test.sh @@ -33,7 +33,7 @@ $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitr ./target/out/arbitrary_self_types_pointers_and_wrappers echo "[BUILD] sysroot" -#time ./build_sysroot/build_sysroot.sh +time ./build_sysroot/build_sysroot.sh echo "[AOT] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin From 9041db962decfe6fa719d3f801b3f985f8027110 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Aug 2019 17:06:18 +0200 Subject: [PATCH 0797/1566] Fix it --- src/driver.rs | 18 +++++------------- src/lib.rs | 10 +++++++--- src/pretty_clif.rs | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index e3bf4a0d56936..fc1049684b940 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -59,16 +59,7 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { for &(cnum, _) in &crate_info.used_crates_dynamic { let src = &crate_info.used_crate_source[&cnum]; match data[cnum.as_usize() - 1] { - _ if crate_info.profiler_runtime == Some(cnum) => unimplemented!(), - _ if crate_info.sanitizer_runtime == Some(cnum) => unimplemented!(), - - // compiler-builtins are always placed last to ensure that they're - // linked correctly. - _ if crate_info.compiler_builtins == Some(cnum) => { - unimplemented!(); - } - Linkage::NotLinked | - Linkage::IncludedFromDylib => {} + Linkage::NotLinked | Linkage::IncludedFromDylib => {} Linkage::Static => { let name = tcx.crate_name(cnum); let mut err = tcx.sess.struct_fatal(&format!("Can't load static lib {}", name.as_str())); @@ -101,7 +92,8 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { std::mem::forget(lib) } - let mut jit_builder = SimpleJITBuilder::new( + let mut jit_builder = SimpleJITBuilder::with_isa( + crate::build_isa(tcx.sess, false), cranelift_module::default_libcall_names(), ); jit_builder.symbols(imported_symbols); @@ -159,7 +151,7 @@ fn run_aot( let new_module = |name: String| { let module: Module = Module::new( FaerieBuilder::new( - crate::build_isa(tcx.sess), + crate::build_isa(tcx.sess, true), name + ".o", FaerieTrapCollection::Disabled, cranelift_module::default_libcall_names(), @@ -231,7 +223,7 @@ fn run_aot( .to_string(); let mut metadata_artifact = - faerie::Artifact::new(crate::build_isa(tcx.sess).triple().clone(), metadata_cgu_name.clone()); + faerie::Artifact::new(crate::build_isa(tcx.sess, true).triple().clone(), metadata_cgu_name.clone()); crate::metadata::write_metadata(tcx, &mut metadata_artifact); let tmp_file = tcx diff --git a/src/lib.rs b/src/lib.rs index 22beefd162350..e0cd46eea3c8a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -239,10 +239,14 @@ fn target_triple(sess: &Session) -> target_lexicon::Triple { target.parse().unwrap() } -fn build_isa(sess: &Session) -> Box { +fn build_isa(sess: &Session, enable_pic: bool) -> Box { let mut flags_builder = settings::builder(); - flags_builder.enable("is_pic").unwrap(); - flags_builder.set("probestack_enabled", "false").unwrap(); // ___cranelift_probestack is not provided + if enable_pic { + flags_builder.enable("is_pic").unwrap(); + } else { + flags_builder.set("is_pic", "false").unwrap(); + } + flags_builder.set("probestack_enabled", "false").unwrap(); // __cranelift_probestack is not provided flags_builder.set("enable_verifier", if cfg!(debug_assertions) { "true" } else { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 57fcebe79c26f..4d05659a060e9 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -218,7 +218,7 @@ pub fn write_clif_file<'tcx>( &mut clif, &func, &DisplayFunctionAnnotations { - isa: Some(&*crate::build_isa(tcx.sess)), + isa: Some(&*crate::build_isa(tcx.sess, true /* PIC doesn't matter here */)), value_ranges, }, ) From 05b7312db23eb9551f966e2b725bb62fae9dcd75 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Aug 2019 17:33:52 +0200 Subject: [PATCH 0798/1566] Misc changes --- config.sh | 4 ++-- src/driver.rs | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/config.sh b/config.sh index 1d5c78c8e729d..9bfff744a66f8 100644 --- a/config.sh +++ b/config.sh @@ -16,5 +16,5 @@ export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-back RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors -export LD_LIBRARY_PATH=$(pwd)/target/out -export DYLD_LIBRARY_PATH=$(pwd)/target/out +export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib" +export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH diff --git a/src/driver.rs b/src/driver.rs index fc1049684b940..a8be65b038136 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -18,13 +18,6 @@ pub fn codegen_crate( metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box { - if !tcx.sess.crate_types.get().contains(&CrateType::Executable) - && std::env::var("SHOULD_RUN").is_ok() - { - tcx.sess - .err("Can't JIT run non executable (SHOULD_RUN env var is set)"); - } - tcx.sess.abort_if_errors(); let mut log = if cfg!(debug_assertions) { @@ -33,7 +26,9 @@ pub fn codegen_crate( None }; - if std::env::var("SHOULD_RUN").is_ok() { + if std::env::var("SHOULD_RUN").is_ok() + && tcx.sess.crate_types.get().contains(&CrateType::Executable) + { #[cfg(not(target_arch = "wasm32"))] let _: ! = run_jit(tcx, &mut log); From bd19af37f48844838ad1d07c0c9eb214e43bd83c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Aug 2019 18:12:49 +0200 Subject: [PATCH 0799/1566] Remove debugging println --- src/driver.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/driver.rs b/src/driver.rs index a8be65b038136..65f81680bbc63 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -79,7 +79,6 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { return None; } - println!("name: {:?}", name); let symbol: libloading::Symbol<*const u8> = unsafe { lib.get(name.as_bytes()) }.unwrap(); Some((name, *symbol)) From 57bc9d8daf268fa7dc28d89665f4e8ee394ae726 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Aug 2019 18:17:51 +0200 Subject: [PATCH 0800/1566] Extract jit imported symbols loading functionAlso make the staticlib load error non fatal --- src/driver.rs | 90 +++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 42 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 65f81680bbc63..3c4ce99d98289 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -43,48 +43,7 @@ pub fn codegen_crate( fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; - let mut dylib_paths = Vec::new(); - - { - use rustc::middle::dependency_format::Linkage; - - let crate_info = CrateInfo::new(tcx); - let formats = tcx.sess.dependency_formats.borrow(); - let data = formats.get(&CrateType::Executable).unwrap(); - for &(cnum, _) in &crate_info.used_crates_dynamic { - let src = &crate_info.used_crate_source[&cnum]; - match data[cnum.as_usize() - 1] { - Linkage::NotLinked | Linkage::IncludedFromDylib => {} - Linkage::Static => { - let name = tcx.crate_name(cnum); - let mut err = tcx.sess.struct_fatal(&format!("Can't load static lib {}", name.as_str())); - err.note("rustc_codegen_cranelift can only load dylibs in JIT mode."); - err.emit(); - } - Linkage::Dynamic => { - dylib_paths.push(src.dylib.as_ref().unwrap().0.clone()); - } - } - } - } - - let mut imported_symbols = Vec::new(); - for path in dylib_paths { - use object::Object; - let lib = libloading::Library::new(&path).unwrap(); - let obj = std::fs::read(path).unwrap(); - let obj = object::File::parse(&obj).unwrap(); - imported_symbols.extend(obj.dynamic_symbols().filter_map(|(_idx, symbol)| { - let name = symbol.name().unwrap().to_string(); - if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { - return None; - } - let symbol: libloading::Symbol<*const u8> = - unsafe { lib.get(name.as_bytes()) }.unwrap(); - Some((name, *symbol)) - })); - std::mem::forget(lib) - } + let imported_symbols = load_imported_symbols_for_jit(tcx); let mut jit_builder = SimpleJITBuilder::with_isa( crate::build_isa(tcx.sess, false), @@ -136,6 +95,53 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { std::process::exit(ret); } +fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { + use rustc::middle::dependency_format::Linkage; + + let mut dylib_paths = Vec::new(); + + let crate_info = CrateInfo::new(tcx); + let formats = tcx.sess.dependency_formats.borrow(); + let data = formats.get(&CrateType::Executable).unwrap(); + for &(cnum, _) in &crate_info.used_crates_dynamic { + let src = &crate_info.used_crate_source[&cnum]; + match data[cnum.as_usize() - 1] { + Linkage::NotLinked | Linkage::IncludedFromDylib => {} + Linkage::Static => { + let name = tcx.crate_name(cnum); + let mut err = tcx.sess.struct_err(&format!("Can't load static lib {}", name.as_str())); + err.note("rustc_codegen_cranelift can only load dylibs in JIT mode."); + err.emit(); + } + Linkage::Dynamic => { + dylib_paths.push(src.dylib.as_ref().unwrap().0.clone()); + } + } + } + + let mut imported_symbols = Vec::new(); + for path in dylib_paths { + use object::Object; + let lib = libloading::Library::new(&path).unwrap(); + let obj = std::fs::read(path).unwrap(); + let obj = object::File::parse(&obj).unwrap(); + imported_symbols.extend(obj.dynamic_symbols().filter_map(|(_idx, symbol)| { + let name = symbol.name().unwrap().to_string(); + if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { + return None; + } + let symbol: libloading::Symbol<*const u8> = + unsafe { lib.get(name.as_bytes()) }.unwrap(); + Some((name, *symbol)) + })); + std::mem::forget(lib) + } + + tcx.sess.abort_if_errors(); + + imported_symbols +} + fn run_aot( tcx: TyCtxt<'_>, metadata: EncodedMetadata, From 314141392a6f97471ec6fc46a7a10053dacf59e9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 12 Aug 2019 15:54:24 +0200 Subject: [PATCH 0801/1566] Implement log2{f32,f64} intrinsics --- example/std_example.rs | 1 + src/intrinsics.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index 1337c3147660a..c0f236055ab03 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -36,6 +36,7 @@ fn main() { println!("{}", 2.3f32.min(1.0)); println!("{}", 2.3f32.max(1.0)); println!("{}", 2.3f32.powi(2)); + println!("{}", 2.3f32.log2()); assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 5beabfb5ee2f4..7754e34eb1fbf 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -317,6 +317,8 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( powif64(a, x) -> f64 => __powidf2, // compiler-builtins logf32(flt) -> f32 => logf, logf64(flt) -> f64 => log, + log2f32(flt) -> f32 => log2f, + log2f64(flt) -> f64 => log2, fabsf32(flt) -> f32 => fabsf, fabsf64(flt) -> f64 => fabs, fmaf32(x, y, z) -> f32 => fmaf, From f5b0a68fbfbaa542becc269b64e99efb5c9abaec Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 12 Aug 2019 16:00:10 +0200 Subject: [PATCH 0802/1566] Fix some warnings --- .../arbitrary_self_types_pointers_and_wrappers.rs | 1 - example/mini_core.rs | 1 + example/mini_core_hello_world.rs | 6 +++--- example/std_example.rs | 14 ++++++-------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/example/arbitrary_self_types_pointers_and_wrappers.rs b/example/arbitrary_self_types_pointers_and_wrappers.rs index 5e7d476217964..10934cebcf1ab 100644 --- a/example/arbitrary_self_types_pointers_and_wrappers.rs +++ b/example/arbitrary_self_types_pointers_and_wrappers.rs @@ -9,7 +9,6 @@ extern crate mini_core; use mini_core::*; -use mini_core::libc::*; macro_rules! assert_eq { ($l:expr, $r: expr) => { diff --git a/example/mini_core.rs b/example/mini_core.rs index 84664eb413927..fc31daf596f02 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -430,6 +430,7 @@ pub trait Drop { fn drop(&mut self); } +#[allow(unions_with_drop_fields)] pub union MaybeUninit { pub uninit: (), pub value: T, diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 48ae80baaad49..47d046d0e1b56 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -149,7 +149,7 @@ fn main() { let world: Box<&str> = box "World!\0"; puts(*world as *const str as *const u8); - world as Box; + world as Box; assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8); @@ -212,7 +212,7 @@ fn main() { let _ = box NoisyDrop { text: "Boxed outer got dropped!\0", inner: NoisyDropInner, - } as Box; + } as Box; const FUNC_REF: Option = Some(main); match FUNC_REF { @@ -249,5 +249,5 @@ fn main() { unsafe { assert_eq!(ABC as usize, 0); } - &mut (|| Some(0 as *const ())) as &mut FnMut() -> Option<*const ()>; + &mut (|| Some(0 as *const ())) as &mut dyn FnMut() -> Option<*const ()>; } diff --git a/example/std_example.rs b/example/std_example.rs index c0f236055ab03..7d1d8facdbe9e 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -2,12 +2,10 @@ use std::arch::x86_64::*; use std::io::Write; -use std::intrinsics; - fn main() { let mutex = std::sync::Mutex::new(()); - mutex.lock().unwrap(); + let _guard = mutex.lock().unwrap(); let _ = ::std::iter::repeat('a' as u8).take(10).collect::>(); let stderr = ::std::io::stderr(); @@ -19,10 +17,10 @@ fn main() { println!("cargo:rustc-link-lib=z"); - static ONCE: std::sync::Once = std::sync::ONCE_INIT; + static ONCE: std::sync::Once = std::sync::Once::new(); ONCE.call_once(|| {}); - LoopState::Continue(()) == LoopState::Break(()); + let _eq = LoopState::Continue(()) == LoopState::Break(()); // Make sure ByValPair values with differently sized components are correctly passed map(None::<(u8, Box)>); @@ -41,8 +39,8 @@ fn main() { assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); - 0i128.checked_div(2i128); - 0u128.checked_div(2u128); + let _d = 0i128.checked_div(2i128); + let _d = 0u128.checked_div(2u128); assert_eq!(1u128 + 2, 3); assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128); @@ -165,7 +163,7 @@ unsafe fn test_mm_add_pd() { fn assert_eq_m128i(x: std::arch::x86_64::__m128i, y: std::arch::x86_64::__m128i) { unsafe { - assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(x)); + assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(y)); } } From f93cd924ec50ba9e6ccf346bd0341e908fd87de0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 12 Aug 2019 17:25:16 +0200 Subject: [PATCH 0803/1566] Implement float -> small int cast Also workaround small signed int eq/ne binop clif bug --- example/mini_core.rs | 18 +++++++ example/mini_core_hello_world.rs | 6 +++ src/base.rs | 30 ++++++----- src/cast.rs | 48 ++++++++++++++--- src/common.rs | 90 +++++++++++--------------------- src/intrinsics.rs | 53 +++++-------------- 6 files changed, 128 insertions(+), 117 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index fc31daf596f02..a23c94aa7babd 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -52,6 +52,7 @@ unsafe impl Copy for i8 {} unsafe impl Copy for i16 {} unsafe impl Copy for i32 {} unsafe impl Copy for isize {} +unsafe impl Copy for f32 {} unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl Copy for *const T {} @@ -277,6 +278,15 @@ impl PartialEq for usize { } } +impl PartialEq for i8 { + fn eq(&self, other: &i8) -> bool { + (*self) == (*other) + } + fn ne(&self, other: &i8) -> bool { + (*self) != (*other) + } +} + impl PartialEq for i32 { fn eq(&self, other: &i32) -> bool { (*self) == (*other) @@ -344,6 +354,14 @@ impl Neg for isize { } } +impl Neg for f32 { + type Output = f32; + + fn neg(self) -> f32 { + -self + } +} + pub enum Option { Some(T), None, diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 47d046d0e1b56..282a9baf7524e 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -250,4 +250,10 @@ fn main() { unsafe { assert_eq!(ABC as usize, 0); } &mut (|| Some(0 as *const ())) as &mut dyn FnMut() -> Option<*const ()>; + + let f = 1000.0; + assert_eq!(f as u8, 255); + let f2 = -1000.0; + assert_eq!(f2 as i8, -128); + assert_eq!(f2 as u8, 0); } diff --git a/src/base.rs b/src/base.rs index 1f372192f31d2..d636ba3d76355 100644 --- a/src/base.rs +++ b/src/base.rs @@ -334,11 +334,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let signed = match ty.sty { - ty::Uint(_) => false, - ty::Int(_) => true, - _ => unimplemented!("checked binop {:?} for {:?}", bin_op, ty), - }; + let signed = type_sign(ty); let res = if !fx.tcx.sess.overflow_checks() { let val = trans_int_binop(fx, *bin_op, lhs, rhs, lhs.layout().ty, signed).load_scalar(fx); @@ -444,14 +440,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let to_clif_ty = fx.clif_type(to_ty).unwrap(); let from = operand.load_scalar(fx); - let signed = match from_ty.sty { - ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) | ty::Char | ty::Uint(..) | ty::Bool => false, - ty::Int(..) => true, - ty::Float(..) => false, // `signed` is unused for floats - _ => panic!("{}", from_ty), - }; - - let res = clif_int_or_float_cast(fx, from, to_clif_ty, signed); + let res = clif_int_or_float_cast(fx, from, type_sign(from_ty), to_clif_ty, type_sign(to_ty)); lval.write_cvalue(fx, CValue::by_val(res, dest_layout)); } } @@ -809,6 +798,21 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( return res; } + let (lhs, rhs) = if + (bin_op == BinOp::Eq || bin_op == BinOp::Ne) + && (lhs.layout().ty.sty == fx.tcx.types.i8.sty || lhs.layout().ty.sty == fx.tcx.types.i16.sty) + { + // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. + let lhs = lhs.load_scalar(fx); + let rhs = rhs.load_scalar(fx); + ( + CValue::by_val(fx.bcx.ins().sextend(types::I32, lhs), fx.layout_of(fx.tcx.types.i32)), + CValue::by_val(fx.bcx.ins().sextend(types::I32, rhs), fx.layout_of(fx.tcx.types.i32)), + ) + } else { + (lhs, rhs) + }; + binop_match! { fx, bin_op, signed, lhs, rhs, out_ty, "int/uint"; Add (_) iadd; diff --git a/src/cast.rs b/src/cast.rs index d14faf4bc3306..39aa2c96d4d36 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -49,8 +49,9 @@ pub fn clif_intcast<'a, 'tcx: 'a>( pub fn clif_int_or_float_cast( fx: &mut FunctionCx<'_, '_, impl Backend>, from: Value, + from_signed: bool, to_ty: Type, - signed: bool, + to_signed: bool, ) -> Value { let from_ty = fx.bcx.func.dfg.value_type(from); @@ -60,21 +61,56 @@ pub fn clif_int_or_float_cast( fx, from, to_ty, - signed, + from_signed, // FIXME is this correct? ) } else if from_ty.is_int() && to_ty.is_float() { // int-like -> float - if signed { + if from_signed { fx.bcx.ins().fcvt_from_sint(to_ty, from) } else { fx.bcx.ins().fcvt_from_uint(to_ty, from) } } else if from_ty.is_float() && to_ty.is_int() { // float -> int-like - if signed { - fx.bcx.ins().fcvt_to_sint_sat(to_ty, from) + if to_ty == types::I8 || to_ty == types::I16 { + // FIXME implement fcbt_to_*int_sat.i8/i16 + let val = if to_signed { + fx.bcx.ins().fcvt_to_sint_sat(types::I32, from) + } else { + fx.bcx.ins().fcvt_to_uint_sat(types::I32, from) + }; + let (min, max) = type_min_max_value(to_ty, to_signed); + let min_val = fx.bcx.ins().iconst(types::I32, min); + let max_val = fx.bcx.ins().iconst(types::I32, max); + + let val = if to_signed { + let has_underflow = fx.bcx.ins().icmp_imm( + IntCC::SignedLessThan, + val, + min, + ); + let has_overflow = fx.bcx.ins().icmp_imm( + IntCC::SignedGreaterThan, + val, + max, + ); + let bottom_capped = fx.bcx.ins().select(has_underflow, min_val, val); + fx.bcx.ins().select(has_overflow, max_val, bottom_capped) + } else { + let has_overflow = fx.bcx.ins().icmp_imm( + IntCC::UnsignedGreaterThan, + val, + max, + ); + fx.bcx.ins().select(has_overflow, max_val, val) + }; + fx.bcx.ins().ireduce(to_ty, val) } else { - fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) + if to_signed { + fx.bcx.ins().fcvt_to_sint_sat(to_ty, from) + } else { + fx.bcx.ins().fcvt_to_uint_sat(to_ty, from) + } } } else if from_ty.is_float() && to_ty.is_float() { // float -> float diff --git a/src/common.rs b/src/common.rs index c9c733c3f6f6e..46dcb5aad0354 100644 --- a/src/common.rs +++ b/src/common.rs @@ -116,74 +116,46 @@ pub fn resolve_value_imm(func: &Function, val: Value) -> Option { } } -pub fn type_min_max_value<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> (i64, i64) { - use syntax::ast::UintTy::*; - use syntax::ast::IntTy::*; - - let uint_usize_cvt = |uint| { - match uint { - UintTy::Usize => match pointer_ty(tcx) { - types::I16 => UintTy::U16, - types::I32 => UintTy::U32, - types::I64 => UintTy::U64, - ty => unreachable!("{:?}", ty), - } - _ => uint, - } - }; - - let int_isize_cvt = |int| { - match int { - IntTy::Isize => match pointer_ty(tcx) { - types::I16 => IntTy::I16, - types::I32 => IntTy::I32, - types::I64 => IntTy::I64, - ty => unreachable!("{:?}", ty), - } - _ => int, - } - }; - - let min = match ty.sty { - ty::Uint(uint) => match uint_usize_cvt(uint) { - U8 | U16 | U32 | U64 => 0i64, - U128 => unimplemented!(), - Usize => unreachable!(), - } - ty::Int(int) => match int_isize_cvt(int) { - I8 => i8::min_value() as i64, - I16 => i16::min_value() as i64, - I32 => i32::min_value() as i64, - I64 => i64::min_value(), - I128 => unimplemented!(), - Isize => unreachable!(), - } +pub fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { + assert!(ty.is_int()); + let min = match (ty, signed) { + (types::I8 , false) + | (types::I16, false) + | (types::I32, false) + | (types::I64, false) => 0i64, + (types::I8, true) => i8::min_value() as i64, + (types::I16, true) => i16::min_value() as i64, + (types::I32, true) => i32::min_value() as i64, + (types::I64, true) => i64::min_value(), + (types::I128, _) => unimplemented!(), _ => unreachable!(), }; - let max = match ty.sty { - ty::Uint(uint) => match uint_usize_cvt(uint) { - U8 => u8::max_value() as i64, - U16 => u16::max_value() as i64, - U32 => u32::max_value() as i64, - U64 => u64::max_value() as i64, - U128 => unimplemented!(), - Usize => unreachable!(), - } - ty::Int(int) => match int_isize_cvt(int) { - I8 => i8::max_value() as i64, - I16 => i16::max_value() as i64, - I32 => i32::max_value() as i64, - I64 => i64::max_value(), - I128 => unimplemented!(), - Isize => unreachable!(), - } + let max = match (ty, signed) { + (types::I8, false) => u8::max_value() as i64, + (types::I16, false) => u16::max_value() as i64, + (types::I32, false) => u32::max_value() as i64, + (types::I64, false) => u64::max_value() as i64, + (types::I8, true) => i8::max_value() as i64, + (types::I16, true) => i16::max_value() as i64, + (types::I32, true) => i32::max_value() as i64, + (types::I64, true) => i64::max_value(), + (types::I128, _) => unimplemented!(), _ => unreachable!(), }; (min, max) } +pub fn type_sign(ty: Ty<'_>) -> bool { + match ty.sty { + ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) | ty::Char | ty::Uint(..) | ty::Bool => false, + ty::Int(..) => true, + ty::Float(..) => false, // `signed` is unused for floats + _ => panic!("{}", ty), + } +} + pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` pub tcx: TyCtxt<'tcx>, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 7754e34eb1fbf..b9ec2a0e18283 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -473,19 +473,13 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; - let signed = match T.sty { - ty::Uint(_) => false, - ty::Int(_) => true, - _ => unimplemented!("{} for {:?}", intrinsic, T), - }; - let res = crate::base::trans_checked_int_binop( fx, bin_op, x, y, ret.layout().ty, - signed, + type_sign(T), ); ret.write_cvalue(fx, res); }; @@ -497,25 +491,14 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "overflowing_mul" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = match T.sty { - ty::Uint(_) => crate::base::trans_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - false, - ), - ty::Int(_) => crate::base::trans_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - true, - ), - _ => panic!(), - }; + let res = crate::base::trans_int_binop( + fx, + bin_op, + x, + y, + ret.layout().ty, + type_sign(T), + ); ret.write_cvalue(fx, res); }; _ if intrinsic.starts_with("saturating_"), (c x, c y) { @@ -527,11 +510,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; - let signed = match T.sty { - ty::Uint(_) => false, - ty::Int(_) => true, - _ => unimplemented!("{} for {:?}", intrinsic, T), - }; + let signed = type_sign(T); let checked_res = crate::base::trans_checked_int_binop( fx, @@ -548,7 +527,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( // `select.i8` is not implemented by Cranelift. let has_overflow = fx.bcx.ins().uextend(types::I32, has_overflow); - let (min, max) = type_min_max_value(fx.tcx, T); + let (min, max) = type_min_max_value(clif_ty, signed); let min = fx.bcx.ins().iconst(clif_ty, min); let max = fx.bcx.ins().iconst(clif_ty, max); @@ -879,18 +858,14 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); - let signed = match lane_layout.ty.sty { - ty::Uint(..) => false, - ty::Int(..) => true, - ty::Float(..) => false, // `signed` is unused for floats - _ => panic!("{}", lane_layout.ty), - }; + let from_signed = type_sign(lane_layout.ty); + let to_signed = type_sign(ret_lane_layout.ty); for lane in 0..lane_count { let lane = mir::Field::new(lane.try_into().unwrap()); let a_lane = a.value_field(fx, lane).load_scalar(fx); - let res = clif_int_or_float_cast(fx, a_lane, ret_lane_ty, signed); + let res = clif_int_or_float_cast(fx, a_lane, from_signed, ret_lane_ty, to_signed); ret.place_field(fx, lane).write_cvalue(fx, CValue::by_val(res, ret_lane_layout)); } }; From 36184d286c9fed8d7bb9b64848cd9b155dc54e0c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Aug 2019 11:46:59 +0200 Subject: [PATCH 0804/1566] Remove outdated FIXME and add some new FIXME --- src/intrinsics.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index b9ec2a0e18283..3e2a1e5e816e0 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -502,7 +502,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, res); }; _ if intrinsic.starts_with("saturating_"), (c x, c y) { - // FIXME implement saturating behavior assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { "saturating_add" => BinOp::Add, @@ -610,6 +609,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); }; ctlz | ctlz_nonzero, (v arg) { + // FIXME trap on `ctlz_nonzero` with zero arg. let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); @@ -625,6 +625,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.write_cvalue(fx, res); }; cttz | cttz_nonzero, (v arg) { + // FIXME trap on `cttz_nonzero` with zero arg. let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); From 5459b157ca6be1c9649709b9109c0ff1c698c537 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Aug 2019 11:52:09 +0200 Subject: [PATCH 0805/1566] Update Cargo.lock --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c642747e6f01d..11e4b2e338832 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,7 +284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -398,7 +398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libloading" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -437,7 +437,7 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -451,7 +451,7 @@ dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -615,7 +615,7 @@ dependencies = [ "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -650,7 +650,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -716,12 +716,12 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.42" +version = "0.15.44" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -736,7 +736,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -894,12 +894,12 @@ dependencies = [ "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" -"checksum libloading 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5692f82b51823e27c4118b3e5c0d98aee9be90633ebc71ad12afef380b50219" +"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" -"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516" +"checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" "checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum object 0.12.0 (git+https://github.com/gimli-rs/object.git)" = "" @@ -933,7 +933,7 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" "checksum structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" -"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" +"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" From f9c20ce2445d31b777f3d85ee5da08c201a03feb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Aug 2019 12:18:35 +0200 Subject: [PATCH 0806/1566] Rustup to rustc 1.38.0-nightly (534b42394 2019-08-09) --- src/intrinsics.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 3e2a1e5e816e0..57898212f342a 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -601,6 +601,34 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( } } }; + uninit, () { + if ret.layout().abi == Abi::Uninhabited { + crate::trap::trap_panic(fx, "[panic] Called intrinsic::uninit for uninhabited type."); + return; + } + match ret { + CPlace::NoPlace(_layout) => unreachable!("{:?}", ret), + CPlace::Var(var, layout) => { + let clif_ty = fx.clif_type(layout.ty).unwrap(); + let val = match clif_ty { + types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 42), + types::F32 => { + let zero = fx.bcx.ins().iconst(types::I32, 0xdeadbeef); + fx.bcx.ins().bitcast(types::F32, zero) + } + types::F64 => { + let zero = fx.bcx.ins().iconst(types::I64, 0xcafebabedeadbeefu64 as i64); + fx.bcx.ins().bitcast(types::F64, zero) + } + _ => panic!("clif_type returned {}", clif_ty), + }; + fx.bcx.def_var(mir_var(var), val); + } + CPlace::Addr(_, _, _) | CPlace::Stack(_, _) => { + // Don't write to `ret`, as the destination memory is already uninitialized. + } + } + }; write_bytes, (c dst, v val, v count) { let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty; let pointee_size = fx.layout_of(pointee_ty).size.bytes(); From 9fdef69fe4d6aaa8c50821e59c592b532ae2d9b6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Aug 2019 19:08:39 +0200 Subject: [PATCH 0807/1566] Fix uninit intrinsic for zst values --- src/intrinsics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 57898212f342a..136635f45e824 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -607,7 +607,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( return; } match ret { - CPlace::NoPlace(_layout) => unreachable!("{:?}", ret), + CPlace::NoPlace(_layout) => {}, CPlace::Var(var, layout) => { let clif_ty = fx.clif_type(layout.ty).unwrap(); let val = match clif_ty { From f02d135057e90ab1c8d6fd3d3d275ffd23febeb7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 4 Aug 2019 13:16:13 +0200 Subject: [PATCH 0808/1566] Print error for #[rustc_def_path] like expected --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index e0cd46eea3c8a..30a8ca02975ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -198,6 +198,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let res = driver::codegen_crate(tcx, metadata, need_metadata_module); rustc_incremental::assert_module_sources::assert_module_sources(tcx); + rustc_codegen_utils::symbol_names_test::report_symbol_names(tcx); res } From 70fbca287c38cad8d2f512dca1eae77ce61a8e0f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 4 Aug 2019 12:27:43 +0200 Subject: [PATCH 0809/1566] Fix intrinsic::transmute::<_, >(...) --- src/intrinsics.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 136635f45e824..551d069d4ae8f 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -296,6 +296,9 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "unreachable" => { trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); } + "transmute" => { + trap_unreachable(fx, "[corruption] Called intrinsic::transmute with uninhabited argument."); + } _ => unimplemented!("unsupported instrinsic {}", intrinsic), } return; From 6f23a053e479ca5f4f6c6b8759de4dd01c3f9329 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 1 Aug 2019 14:58:27 +0200 Subject: [PATCH 0810/1566] Fix a panic on type size overflow --- src/common.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index 46dcb5aad0354..5cdbd9bd79ea1 100644 --- a/src/common.rs +++ b/src/common.rs @@ -181,7 +181,12 @@ impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> { fn layout_of(&self, ty: Ty<'tcx>) -> TyLayout<'tcx> { let ty = self.monomorphize(&ty); - self.tcx.layout_of(ParamEnv::reveal_all().and(&ty)).unwrap() + self.tcx.layout_of(ParamEnv::reveal_all().and(&ty)) + .unwrap_or_else(|e| if let layout::LayoutError::SizeOverflow(_) = e { + self.tcx.sess.fatal(&e.to_string()) + } else { + bug!("failed to get layout for `{}`: {}", ty, e) + }) } } From 11b2b86b087d17018c71edef3e411b04483ae6b2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 1 Aug 2019 14:07:08 +0200 Subject: [PATCH 0811/1566] Fix some rustc tests * Check for `#[rustc_error]` attribute. * Use the same weak static type error message as cg_llvm --- src/constant.rs | 2 +- src/lib.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index 3ccd0f97dc549..a71a8d0bf2cdb 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -202,7 +202,7 @@ fn data_id_for_static( if linkage == Linkage::Preemptible { if let ty::RawPtr(_) = tcx.type_of(def_id).sty { } else { - tcx.sess.span_fatal(tcx.def_span(def_id), "must have type `*const T` or `*mut T`") + tcx.sess.span_fatal(tcx.def_span(def_id), "must have type `*const T` or `*mut T` due to `#[linkage]` attribute") } let mut data_ctx = DataContext::new(); diff --git a/src/lib.rs b/src/lib.rs index 30a8ca02975ec..b6ef7e39d148e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -195,6 +195,8 @@ impl CodegenBackend for CraneliftCodegenBackend { need_metadata_module: bool, _rx: mpsc::Receiver>, ) -> Box { + rustc_codegen_utils::check_for_rustc_errors_attr(tcx); + let res = driver::codegen_crate(tcx, metadata, need_metadata_module); rustc_incremental::assert_module_sources::assert_module_sources(tcx); From 2facd8e7ff09c89147d6bfc52b28d9c2f0079560 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 13 Aug 2019 19:36:07 +0200 Subject: [PATCH 0812/1566] Only build dylib This saves ~200mb of space --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ec0350687aacb..ab95a278c0e6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ authors = ["bjorn3 "] edition = "2018" [lib] -crate-type = ["rlib", "dylib"] +crate-type = ["dylib"] [dependencies] # These have to be in sync with each other From 581b6ea5bee7be1852713630d2eca8a7bd683e3e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Aug 2019 11:36:24 +0200 Subject: [PATCH 0813/1566] Misc changes --- src/base.rs | 2 +- src/codegen_i128.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index d636ba3d76355..2d490ae8679bf 100644 --- a/src/base.rs +++ b/src/base.rs @@ -634,7 +634,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let discr_val = layout .ty .ty_adt_def() - .map_or(index.as_u32() as u128, |def| { + .map_or(u128::from(index.as_u32()), |def| { def.discriminant_for_variant(fx.tcx, *index).val }); return CValue::const_val(fx, dest_layout.ty, discr_val); diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 9cd6bc8c78687..f173b4dbd5d9e 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -86,7 +86,7 @@ pub fn maybe_codegen<'a, 'tcx>( } _ => { // if msb_eq { - // lhs_cc + // lsb_cc // } else { // msb_cc // } From 883894a07a8f05b4d9d07514af8d8ac19fb27788 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Aug 2019 11:52:39 +0200 Subject: [PATCH 0814/1566] Move trans_*_binop to num.rs --- src/base.rs | 424 ++-------------------------------------------- src/intrinsics.rs | 10 +- src/lib.rs | 1 + src/num.rs | 406 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 422 insertions(+), 419 deletions(-) create mode 100644 src/num.rs diff --git a/src/base.rs b/src/base.rs index 2d490ae8679bf..17abee4a003d7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -314,17 +314,18 @@ fn trans_stmt<'a, 'tcx: 'a>( let rhs = trans_operand(fx, rhs); let res = match ty.sty { - ty::Bool => trans_bool_binop(fx, *bin_op, lhs, rhs), + ty::Bool => crate::num::trans_bool_binop(fx, *bin_op, lhs, rhs), ty::Uint(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) + crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) } ty::Int(_) => { - trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) + crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) + } + ty::Float(_) => crate::num::trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), + ty::Char => crate::num::trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), + ty::RawPtr(..) | ty::FnPtr(..) => { + crate::num::trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } - ty::Float(_) => trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), - ty::Char => trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), - ty::RawPtr(..) => trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), - ty::FnPtr(..) => trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), _ => unimplemented!("binop {:?} for {:?}", bin_op, ty), }; lval.write_cvalue(fx, res); @@ -337,11 +338,11 @@ fn trans_stmt<'a, 'tcx: 'a>( let signed = type_sign(ty); let res = if !fx.tcx.sess.overflow_checks() { - let val = trans_int_binop(fx, *bin_op, lhs, rhs, lhs.layout().ty, signed).load_scalar(fx); + let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lhs.layout().ty, signed).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); CValue::by_val_pair(val, is_overflow, lval.layout()) } else { - trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, signed) + crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, signed) }; lval.write_cvalue(fx, res); @@ -701,411 +702,6 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( } } -macro_rules! binop_match { - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, bug) => { - bug!("binop {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) - }; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, icmp($cc:ident)) => {{ - assert_eq!($fx.tcx.types.bool, $ret_ty); - let ret_layout = $fx.layout_of($ret_ty); - - let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); - CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) - }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ - assert_eq!($fx.tcx.types.bool, $ret_ty); - let ret_layout = $fx.layout_of($ret_ty); - let b = $fx.bcx.ins().fcmp(FloatCC::$cc, $lhs, $rhs); - CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) - }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, custom(|| $body:expr)) => {{ - $body - }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $name:ident) => {{ - let ret_layout = $fx.layout_of($ret_ty); - CValue::by_val($fx.bcx.ins().$name($lhs, $rhs), ret_layout) - }}; - ( - $fx:expr, $bin_op:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $bug_fmt:expr; - $( - $var:ident ($sign:pat) $name:tt $( ( $($next:tt)* ) )? ; - )* - ) => {{ - let lhs = $lhs.load_scalar($fx); - let rhs = $rhs.load_scalar($fx); - match ($bin_op, $signed) { - $( - (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, $signed, lhs, rhs, $ret_ty, $name $( ( $($next)* ) )?), - )* - } - }} -} - -fn trans_bool_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, -) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, false, lhs, rhs, fx.tcx.types.bool, "bool"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bxor; - BitAnd (_) band; - BitOr (_) bor; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) bug; - }; - - res -} - -pub fn trans_int_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - out_ty: Ty<'tcx>, - signed: bool, -) -> CValue<'tcx> { - if bin_op != BinOp::Shl && bin_op != BinOp::Shr { - assert_eq!( - lhs.layout().ty, - rhs.layout().ty, - "int binop requires lhs and rhs of same type" - ); - } - - match out_ty.sty { - ty::Bool | ty::Uint(_) | ty::Int(_) => {} - _ => unreachable!("Out ty {:?} is not an integer or bool", out_ty), - } - - if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, signed, lhs, rhs, out_ty) { - return res; - } - - let (lhs, rhs) = if - (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (lhs.layout().ty.sty == fx.tcx.types.i8.sty || lhs.layout().ty.sty == fx.tcx.types.i16.sty) - { - // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. - let lhs = lhs.load_scalar(fx); - let rhs = rhs.load_scalar(fx); - ( - CValue::by_val(fx.bcx.ins().sextend(types::I32, lhs), fx.layout_of(fx.tcx.types.i32)), - CValue::by_val(fx.bcx.ins().sextend(types::I32, rhs), fx.layout_of(fx.tcx.types.i32)), - ) - } else { - (lhs, rhs) - }; - - binop_match! { - fx, bin_op, signed, lhs, rhs, out_ty, "int/uint"; - Add (_) iadd; - Sub (_) isub; - Mul (_) imul; - Div (false) udiv; - Div (true) sdiv; - Rem (false) urem; - Rem (true) srem; - BitXor (_) bxor; - BitAnd (_) band; - BitOr (_) bor; - Shl (_) ishl; - Shr (false) ushr; - Shr (true) sshr; - - Eq (_) icmp(Equal); - Lt (false) icmp(UnsignedLessThan); - Lt (true) icmp(SignedLessThan); - Le (false) icmp(UnsignedLessThanOrEqual); - Le (true) icmp(SignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (false) icmp(UnsignedGreaterThanOrEqual); - Ge (true) icmp(SignedGreaterThanOrEqual); - Gt (false) icmp(UnsignedGreaterThan); - Gt (true) icmp(SignedGreaterThan); - - Offset (_) bug; - } -} - -pub fn trans_checked_int_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - bin_op: BinOp, - in_lhs: CValue<'tcx>, - in_rhs: CValue<'tcx>, - out_ty: Ty<'tcx>, - signed: bool, -) -> CValue<'tcx> { - if bin_op != BinOp::Shl && bin_op != BinOp::Shr { - assert_eq!( - in_lhs.layout().ty, - in_rhs.layout().ty, - "checked int binop requires lhs and rhs of same type" - ); - } - - let lhs = in_lhs.load_scalar(fx); - let rhs = in_rhs.load_scalar(fx); - - if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, true, signed, in_lhs, in_rhs, out_ty) { - return res; - } - - let (res, has_overflow) = match bin_op { - BinOp::Add => { - /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); - (val, c_out)*/ - // FIXME(CraneStation/cranelift#849) legalize iadd_cout for i8 and i16 - let val = fx.bcx.ins().iadd(lhs, rhs); - let has_overflow = if !signed { - fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) - } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); - let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); - fx.bcx.ins().bxor(rhs_is_negative, slt) - }; - (val, has_overflow) - } - BinOp::Sub => { - /*let (val, b_out) = fx.bcx.ins().isub_bout(lhs, rhs); - (val, b_out)*/ - // FIXME(CraneStation/cranelift#849) legalize isub_bout for i8 and i16 - let val = fx.bcx.ins().isub(lhs, rhs); - let has_overflow = if !signed { - fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) - } else { - let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); - let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); - fx.bcx.ins().bxor(rhs_is_negative, sgt) - }; - (val, has_overflow) - } - BinOp::Mul => { - let val = fx.bcx.ins().imul(lhs, rhs); - /*let val_hi = if !signed { - fx.bcx.ins().umulhi(lhs, rhs) - } else { - fx.bcx.ins().smulhi(lhs, rhs) - }; - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) - } - BinOp::Shl => { - let val = fx.bcx.ins().ishl(lhs, rhs); - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) - } - BinOp::Shr => { - let val = if !signed { - fx.bcx.ins().ushr(lhs, rhs) - } else { - fx.bcx.ins().sshr(lhs, rhs) - }; - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) - } - _ => bug!( - "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", - bin_op, - in_lhs, - in_rhs - ), - }; - - let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); - let out_place = CPlace::new_stack_slot(fx, out_ty); - let out_layout = out_place.layout(); - out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); - - out_place.to_cvalue(fx) -} - -fn trans_float_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - ty: Ty<'tcx>, -) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, false, lhs, rhs, ty, "float"; - Add (_) fadd; - Sub (_) fsub; - Mul (_) fmul; - Div (_) fdiv; - Rem (_) custom(|| { - assert_eq!(lhs.layout().ty, ty); - assert_eq!(rhs.layout().ty, ty); - match ty.sty { - ty::Float(FloatTy::F32) => fx.easy_call("fmodf", &[lhs, rhs], ty), - ty::Float(FloatTy::F64) => fx.easy_call("fmod", &[lhs, rhs], ty), - _ => bug!(), - } - }); - BitXor (_) bxor; - BitAnd (_) band; - BitOr (_) bor; - Shl (_) bug; - Shr (_) bug; - - Eq (_) fcmp(Equal); - Lt (_) fcmp(LessThan); - Le (_) fcmp(LessThanOrEqual); - Ne (_) fcmp(NotEqual); - Ge (_) fcmp(GreaterThanOrEqual); - Gt (_) fcmp(GreaterThan); - - Offset (_) bug; - }; - - res -} - -fn trans_char_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - ty: Ty<'tcx>, -) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, false, lhs, rhs, ty, "char"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) bug; - }; - - res -} - -fn trans_ptr_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - ret_ty: Ty<'tcx>, -) -> CValue<'tcx> { - let not_fat = match lhs.layout().ty.sty { - ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { - ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) - } - ty::FnPtr(..) => true, - _ => bug!("trans_ptr_binop on non ptr"), - }; - if not_fat { - if let BinOp::Offset = bin_op { - let (base, offset) = (lhs, rhs.load_scalar(fx)); - let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; - let pointee_size = fx.layout_of(pointee_ty).size.bytes(); - let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); - let base_val = base.load_scalar(fx); - let res = fx.bcx.ins().iadd(base_val, ptr_diff); - return CValue::by_val(res, base.layout()); - } - - binop_match! { - fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) bug; // Handled above - } - } else { - let (lhs_ptr, lhs_extra) = lhs.load_scalar_pair(fx); - let (rhs_ptr, rhs_extra) = rhs.load_scalar_pair(fx); - - let res = match bin_op { - BinOp::Eq => { - let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); - let extra_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_extra, rhs_extra); - fx.bcx.ins().band(ptr_eq, extra_eq) - } - BinOp::Ne => { - let ptr_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_ptr, rhs_ptr); - let extra_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_extra, rhs_extra); - fx.bcx.ins().bor(ptr_ne, extra_ne) - } - BinOp::Lt | BinOp::Le | BinOp::Ge | BinOp::Gt => { - let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); - - let ptr_cmp = fx.bcx.ins().icmp(match bin_op { - BinOp::Lt => IntCC::UnsignedLessThan, - BinOp::Le => IntCC::UnsignedLessThanOrEqual, - BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, - BinOp::Gt => IntCC::UnsignedGreaterThan, - _ => unreachable!(), - }, lhs_ptr, rhs_ptr); - - let extra_cmp = fx.bcx.ins().icmp(match bin_op { - BinOp::Lt => IntCC::UnsignedLessThan, - BinOp::Le => IntCC::UnsignedLessThanOrEqual, - BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, - BinOp::Gt => IntCC::UnsignedGreaterThan, - _ => unreachable!(), - }, lhs_extra, rhs_extra); - - fx.bcx.ins().select(ptr_eq, extra_cmp, ptr_cmp) - } - _ => panic!("bin_op {:?} on ptr", bin_op), - }; - - assert_eq!(fx.tcx.types.bool, ret_ty); - let ret_layout = fx.layout_of(ret_ty); - CValue::by_val(fx.bcx.ins().bint(types::I8, res), ret_layout) - } -} - pub fn trans_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, place: &Place<'tcx>, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 551d069d4ae8f..84288715f4d51 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -447,7 +447,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; let res = match ret.layout().ty.sty { - ty::Uint(_) => crate::base::trans_int_binop( + ty::Uint(_) => crate::num::trans_int_binop( fx, bin_op, x, @@ -455,7 +455,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ret.layout().ty, false, ), - ty::Int(_) => crate::base::trans_int_binop( + ty::Int(_) => crate::num::trans_int_binop( fx, bin_op, x, @@ -476,7 +476,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = crate::base::trans_checked_int_binop( + let res = crate::num::trans_checked_int_binop( fx, bin_op, x, @@ -494,7 +494,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "overflowing_mul" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = crate::base::trans_int_binop( + let res = crate::num::trans_int_binop( fx, bin_op, x, @@ -514,7 +514,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let signed = type_sign(T); - let checked_res = crate::base::trans_checked_int_binop( + let checked_res = crate::num::trans_checked_int_binop( fx, bin_op, x, diff --git a/src/lib.rs b/src/lib.rs index b6ef7e39d148e..b61114bec983b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,6 +44,7 @@ mod linkage; mod llvm_intrinsics; mod main_shim; mod metadata; +mod num; mod pretty_clif; mod target_features_whitelist; mod trap; diff --git a/src/num.rs b/src/num.rs new file mode 100644 index 0000000000000..41448b388db88 --- /dev/null +++ b/src/num.rs @@ -0,0 +1,406 @@ +use crate::prelude::*; + +macro_rules! binop_match { + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, bug) => { + bug!("binop {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) + }; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, icmp($cc:ident)) => {{ + assert_eq!($fx.tcx.types.bool, $ret_ty); + let ret_layout = $fx.layout_of($ret_ty); + + let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); + CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) + }}; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ + assert_eq!($fx.tcx.types.bool, $ret_ty); + let ret_layout = $fx.layout_of($ret_ty); + let b = $fx.bcx.ins().fcmp(FloatCC::$cc, $lhs, $rhs); + CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) + }}; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, custom(|| $body:expr)) => {{ + $body + }}; + (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $name:ident) => {{ + let ret_layout = $fx.layout_of($ret_ty); + CValue::by_val($fx.bcx.ins().$name($lhs, $rhs), ret_layout) + }}; + ( + $fx:expr, $bin_op:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $bug_fmt:expr; + $( + $var:ident ($sign:pat) $name:tt $( ( $($next:tt)* ) )? ; + )* + ) => {{ + let lhs = $lhs.load_scalar($fx); + let rhs = $rhs.load_scalar($fx); + match ($bin_op, $signed) { + $( + (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, $signed, lhs, rhs, $ret_ty, $name $( ( $($next)* ) )?), + )* + } + }} +} + +pub fn trans_bool_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, +) -> CValue<'tcx> { + let res = binop_match! { + fx, bin_op, false, lhs, rhs, fx.tcx.types.bool, "bool"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bxor; + BitAnd (_) band; + BitOr (_) bor; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) bug; + }; + + res +} + +pub fn trans_int_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + out_ty: Ty<'tcx>, + signed: bool, +) -> CValue<'tcx> { + if bin_op != BinOp::Shl && bin_op != BinOp::Shr { + assert_eq!( + lhs.layout().ty, + rhs.layout().ty, + "int binop requires lhs and rhs of same type" + ); + } + + match out_ty.sty { + ty::Bool | ty::Uint(_) | ty::Int(_) => {} + _ => unreachable!("Out ty {:?} is not an integer or bool", out_ty), + } + + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, signed, lhs, rhs, out_ty) { + return res; + } + + let (lhs, rhs) = if + (bin_op == BinOp::Eq || bin_op == BinOp::Ne) + && (lhs.layout().ty.sty == fx.tcx.types.i8.sty || lhs.layout().ty.sty == fx.tcx.types.i16.sty) + { + // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. + let lhs = lhs.load_scalar(fx); + let rhs = rhs.load_scalar(fx); + ( + CValue::by_val(fx.bcx.ins().sextend(types::I32, lhs), fx.layout_of(fx.tcx.types.i32)), + CValue::by_val(fx.bcx.ins().sextend(types::I32, rhs), fx.layout_of(fx.tcx.types.i32)), + ) + } else { + (lhs, rhs) + }; + + binop_match! { + fx, bin_op, signed, lhs, rhs, out_ty, "int/uint"; + Add (_) iadd; + Sub (_) isub; + Mul (_) imul; + Div (false) udiv; + Div (true) sdiv; + Rem (false) urem; + Rem (true) srem; + BitXor (_) bxor; + BitAnd (_) band; + BitOr (_) bor; + Shl (_) ishl; + Shr (false) ushr; + Shr (true) sshr; + + Eq (_) icmp(Equal); + Lt (false) icmp(UnsignedLessThan); + Lt (true) icmp(SignedLessThan); + Le (false) icmp(UnsignedLessThanOrEqual); + Le (true) icmp(SignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (false) icmp(UnsignedGreaterThanOrEqual); + Ge (true) icmp(SignedGreaterThanOrEqual); + Gt (false) icmp(UnsignedGreaterThan); + Gt (true) icmp(SignedGreaterThan); + + Offset (_) bug; + } +} + +pub fn trans_checked_int_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + bin_op: BinOp, + in_lhs: CValue<'tcx>, + in_rhs: CValue<'tcx>, + out_ty: Ty<'tcx>, + signed: bool, +) -> CValue<'tcx> { + if bin_op != BinOp::Shl && bin_op != BinOp::Shr { + assert_eq!( + in_lhs.layout().ty, + in_rhs.layout().ty, + "checked int binop requires lhs and rhs of same type" + ); + } + + let lhs = in_lhs.load_scalar(fx); + let rhs = in_rhs.load_scalar(fx); + + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, true, signed, in_lhs, in_rhs, out_ty) { + return res; + } + + let (res, has_overflow) = match bin_op { + BinOp::Add => { + /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); + (val, c_out)*/ + // FIXME(CraneStation/cranelift#849) legalize iadd_cout for i8 and i16 + let val = fx.bcx.ins().iadd(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedLessThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let slt = fx.bcx.ins().icmp(IntCC::SignedLessThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, slt) + }; + (val, has_overflow) + } + BinOp::Sub => { + /*let (val, b_out) = fx.bcx.ins().isub_bout(lhs, rhs); + (val, b_out)*/ + // FIXME(CraneStation/cranelift#849) legalize isub_bout for i8 and i16 + let val = fx.bcx.ins().isub(lhs, rhs); + let has_overflow = if !signed { + fx.bcx.ins().icmp(IntCC::UnsignedGreaterThan, val, lhs) + } else { + let rhs_is_negative = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, rhs, 0); + let sgt = fx.bcx.ins().icmp(IntCC::SignedGreaterThan, val, lhs); + fx.bcx.ins().bxor(rhs_is_negative, sgt) + }; + (val, has_overflow) + } + BinOp::Mul => { + let val = fx.bcx.ins().imul(lhs, rhs); + /*let val_hi = if !signed { + fx.bcx.ins().umulhi(lhs, rhs) + } else { + fx.bcx.ins().smulhi(lhs, rhs) + }; + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + BinOp::Shl => { + let val = fx.bcx.ins().ishl(lhs, rhs); + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + BinOp::Shr => { + let val = if !signed { + fx.bcx.ins().ushr(lhs, rhs) + } else { + fx.bcx.ins().sshr(lhs, rhs) + }; + // TODO: check for overflow + let has_overflow = fx.bcx.ins().bconst(types::B1, false); + (val, has_overflow) + } + _ => bug!( + "binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", + bin_op, + in_lhs, + in_rhs + ), + }; + + let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); + let out_place = CPlace::new_stack_slot(fx, out_ty); + let out_layout = out_place.layout(); + out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); + + out_place.to_cvalue(fx) +} + +pub fn trans_float_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ty: Ty<'tcx>, +) -> CValue<'tcx> { + let res = binop_match! { + fx, bin_op, false, lhs, rhs, ty, "float"; + Add (_) fadd; + Sub (_) fsub; + Mul (_) fmul; + Div (_) fdiv; + Rem (_) custom(|| { + assert_eq!(lhs.layout().ty, ty); + assert_eq!(rhs.layout().ty, ty); + match ty.sty { + ty::Float(FloatTy::F32) => fx.easy_call("fmodf", &[lhs, rhs], ty), + ty::Float(FloatTy::F64) => fx.easy_call("fmod", &[lhs, rhs], ty), + _ => bug!(), + } + }); + BitXor (_) bxor; + BitAnd (_) band; + BitOr (_) bor; + Shl (_) bug; + Shr (_) bug; + + Eq (_) fcmp(Equal); + Lt (_) fcmp(LessThan); + Le (_) fcmp(LessThanOrEqual); + Ne (_) fcmp(NotEqual); + Ge (_) fcmp(GreaterThanOrEqual); + Gt (_) fcmp(GreaterThan); + + Offset (_) bug; + }; + + res +} + +pub fn trans_char_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ty: Ty<'tcx>, +) -> CValue<'tcx> { + let res = binop_match! { + fx, bin_op, false, lhs, rhs, ty, "char"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) bug; + }; + + res +} + +pub fn trans_ptr_binop<'a, 'tcx: 'a>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + bin_op: BinOp, + lhs: CValue<'tcx>, + rhs: CValue<'tcx>, + ret_ty: Ty<'tcx>, +) -> CValue<'tcx> { + let not_fat = match lhs.layout().ty.sty { + ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { + ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) + } + ty::FnPtr(..) => true, + _ => bug!("trans_ptr_binop on non ptr"), + }; + if not_fat { + if let BinOp::Offset = bin_op { + let (base, offset) = (lhs, rhs.load_scalar(fx)); + let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; + let pointee_size = fx.layout_of(pointee_ty).size.bytes(); + let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); + let base_val = base.load_scalar(fx); + let res = fx.bcx.ins().iadd(base_val, ptr_diff); + return CValue::by_val(res, base.layout()); + } + + binop_match! { + fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; + Add (_) bug; + Sub (_) bug; + Mul (_) bug; + Div (_) bug; + Rem (_) bug; + BitXor (_) bug; + BitAnd (_) bug; + BitOr (_) bug; + Shl (_) bug; + Shr (_) bug; + + Eq (_) icmp(Equal); + Lt (_) icmp(UnsignedLessThan); + Le (_) icmp(UnsignedLessThanOrEqual); + Ne (_) icmp(NotEqual); + Ge (_) icmp(UnsignedGreaterThanOrEqual); + Gt (_) icmp(UnsignedGreaterThan); + + Offset (_) bug; // Handled above + } + } else { + let (lhs_ptr, lhs_extra) = lhs.load_scalar_pair(fx); + let (rhs_ptr, rhs_extra) = rhs.load_scalar_pair(fx); + + let res = match bin_op { + BinOp::Eq => { + let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); + let extra_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_extra, rhs_extra); + fx.bcx.ins().band(ptr_eq, extra_eq) + } + BinOp::Ne => { + let ptr_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_ptr, rhs_ptr); + let extra_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_extra, rhs_extra); + fx.bcx.ins().bor(ptr_ne, extra_ne) + } + BinOp::Lt | BinOp::Le | BinOp::Ge | BinOp::Gt => { + let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); + + let ptr_cmp = fx.bcx.ins().icmp(match bin_op { + BinOp::Lt => IntCC::UnsignedLessThan, + BinOp::Le => IntCC::UnsignedLessThanOrEqual, + BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, + BinOp::Gt => IntCC::UnsignedGreaterThan, + _ => unreachable!(), + }, lhs_ptr, rhs_ptr); + + let extra_cmp = fx.bcx.ins().icmp(match bin_op { + BinOp::Lt => IntCC::UnsignedLessThan, + BinOp::Le => IntCC::UnsignedLessThanOrEqual, + BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, + BinOp::Gt => IntCC::UnsignedGreaterThan, + _ => unreachable!(), + }, lhs_extra, rhs_extra); + + fx.bcx.ins().select(ptr_eq, extra_cmp, ptr_cmp) + } + _ => panic!("bin_op {:?} on ptr", bin_op), + }; + + assert_eq!(fx.tcx.types.bool, ret_ty); + let ret_layout = fx.layout_of(ret_ty); + CValue::by_val(fx.bcx.ins().bint(types::I8, res), ret_layout) + } +} From 32cb5b8c8ef6ea3dd782bd72f57d3a0981581a3d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Aug 2019 12:01:41 +0200 Subject: [PATCH 0815/1566] Move discriminant get and set to discriminant.rs --- src/base.rs | 137 +------------------------------------------ src/discriminant.rs | 140 ++++++++++++++++++++++++++++++++++++++++++++ src/intrinsics.rs | 2 +- src/lib.rs | 1 + 4 files changed, 145 insertions(+), 135 deletions(-) create mode 100644 src/discriminant.rs diff --git a/src/base.rs b/src/base.rs index 17abee4a003d7..444e39c359d6c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -246,55 +246,7 @@ fn trans_stmt<'a, 'tcx: 'a>( variant_index, } => { let place = trans_place(fx, place); - let layout = place.layout(); - if layout.for_variant(&*fx, *variant_index).abi == layout::Abi::Uninhabited { - return; - } - match layout.variants { - layout::Variants::Single { index } => { - assert_eq!(index, *variant_index); - } - layout::Variants::Multiple { - discr: _, - discr_index, - discr_kind: layout::DiscriminantKind::Tag, - variants: _, - } => { - let ptr = place.place_field(fx, mir::Field::new(discr_index)); - let to = layout - .ty - .discriminant_for_variant(fx.tcx, *variant_index) - .unwrap() - .val; - let discr = CValue::const_val(fx, ptr.layout().ty, to); - ptr.write_cvalue(fx, discr); - } - layout::Variants::Multiple { - discr: _, - discr_index, - discr_kind: layout::DiscriminantKind::Niche { - dataful_variant, - ref niche_variants, - niche_start, - }, - variants: _, - } => { - if *variant_index != dataful_variant { - let niche = place.place_field(fx, mir::Field::new(discr_index)); - //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); - let niche_value = - ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) - .wrapping_add(niche_start); - // FIXME(eddyb) Check the actual primitive type here. - let niche_llval = if niche_value == 0 { - CValue::const_val(fx, niche.layout().ty, 0) - } else { - CValue::const_val(fx, niche.layout().ty, niche_value) - }; - niche.write_cvalue(fx, niche_llval); - } - } - } + crate::discriminant::codegen_set_discriminant(fx, place, *variant_index); } StatementKind::Assign(to_place, rval) => { let lval = trans_place(fx, to_place); @@ -435,7 +387,7 @@ fn trans_stmt<'a, 'tcx: 'a>( // FIXME avoid forcing to stack let place = CPlace::for_addr(operand.force_stack(fx), operand.layout()); - let discr = trans_get_discriminant(fx, place, fx.layout_of(to_ty)); + let discr = crate::discriminant::codegen_get_discriminant(fx, place, fx.layout_of(to_ty)); lval.write_cvalue(fx, discr); } else { let to_clif_ty = fx.clif_type(to_ty).unwrap(); @@ -470,7 +422,7 @@ fn trans_stmt<'a, 'tcx: 'a>( } Rvalue::Discriminant(place) => { let place = trans_place(fx, place); - let discr = trans_get_discriminant(fx, place, dest_layout); + let discr = crate::discriminant::codegen_get_discriminant(fx, place, dest_layout); lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => { @@ -619,89 +571,6 @@ fn codegen_array_len<'a, 'tcx: 'a>( } } -pub fn trans_get_discriminant<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - place: CPlace<'tcx>, - dest_layout: TyLayout<'tcx>, -) -> CValue<'tcx> { - let layout = place.layout(); - - if layout.abi == layout::Abi::Uninhabited { - return trap_unreachable_ret_value(fx, dest_layout, "[panic] Tried to get discriminant for uninhabited type."); - } - - let (discr_scalar, discr_index, discr_kind) = match &layout.variants { - layout::Variants::Single { index } => { - let discr_val = layout - .ty - .ty_adt_def() - .map_or(u128::from(index.as_u32()), |def| { - def.discriminant_for_variant(fx.tcx, *index).val - }); - return CValue::const_val(fx, dest_layout.ty, discr_val); - } - layout::Variants::Multiple { discr, discr_index, discr_kind, variants: _ } => { - (discr, *discr_index, discr_kind) - } - }; - - let discr = place.place_field(fx, mir::Field::new(discr_index)).to_cvalue(fx); - let discr_ty = discr.layout().ty; - let lldiscr = discr.load_scalar(fx); - match discr_kind { - layout::DiscriminantKind::Tag => { - let signed = match discr_scalar.value { - layout::Int(_, signed) => signed, - _ => false, - }; - let val = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), signed); - return CValue::by_val(val, dest_layout); - } - layout::DiscriminantKind::Niche { - dataful_variant, - ref niche_variants, - niche_start, - } => { - let niche_llty = fx.clif_type(discr_ty).unwrap(); - let dest_clif_ty = fx.clif_type(dest_layout.ty).unwrap(); - if niche_variants.start() == niche_variants.end() { - let b = fx - .bcx - .ins() - .icmp_imm(IntCC::Equal, lldiscr, *niche_start as u64 as i64); - let if_true = fx - .bcx - .ins() - .iconst(dest_clif_ty, niche_variants.start().as_u32() as i64); - let if_false = fx - .bcx - .ins() - .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); - let val = fx.bcx.ins().select(b, if_true, if_false); - return CValue::by_val(val, dest_layout); - } else { - // Rebase from niche values to discriminant values. - let delta = niche_start.wrapping_sub(niche_variants.start().as_u32() as u128); - let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); - let lldiscr = fx.bcx.ins().isub(lldiscr, delta); - let b = fx.bcx.ins().icmp_imm( - IntCC::UnsignedLessThanOrEqual, - lldiscr, - niche_variants.end().as_u32() as i64, - ); - let if_true = - clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false); - let if_false = fx - .bcx - .ins() - .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); - let val = fx.bcx.ins().select(b, if_true, if_false); - return CValue::by_val(val, dest_layout); - } - } - } -} - pub fn trans_place<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, place: &Place<'tcx>, diff --git a/src/discriminant.rs b/src/discriminant.rs new file mode 100644 index 0000000000000..9b049cd4e1e1a --- /dev/null +++ b/src/discriminant.rs @@ -0,0 +1,140 @@ +use crate::prelude::*; + +pub fn codegen_set_discriminant<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + place: CPlace<'tcx>, + variant_index: VariantIdx, +) { + let layout = place.layout(); + if layout.for_variant(&*fx, variant_index).abi == layout::Abi::Uninhabited { + return; + } + match layout.variants { + layout::Variants::Single { index } => { + assert_eq!(index, variant_index); + } + layout::Variants::Multiple { + discr: _, + discr_index, + discr_kind: layout::DiscriminantKind::Tag, + variants: _, + } => { + let ptr = place.place_field(fx, mir::Field::new(discr_index)); + let to = layout + .ty + .discriminant_for_variant(fx.tcx, variant_index) + .unwrap() + .val; + let discr = CValue::const_val(fx, ptr.layout().ty, to); + ptr.write_cvalue(fx, discr); + } + layout::Variants::Multiple { + discr: _, + discr_index, + discr_kind: layout::DiscriminantKind::Niche { + dataful_variant, + ref niche_variants, + niche_start, + }, + variants: _, + } => { + if variant_index != dataful_variant { + let niche = place.place_field(fx, mir::Field::new(discr_index)); + //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); + let niche_value = + ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) + .wrapping_add(niche_start); + // FIXME(eddyb) Check the actual primitive type here. + let niche_llval = if niche_value == 0 { + CValue::const_val(fx, niche.layout().ty, 0) + } else { + CValue::const_val(fx, niche.layout().ty, niche_value) + }; + niche.write_cvalue(fx, niche_llval); + } + } + } +} + +pub fn codegen_get_discriminant<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + place: CPlace<'tcx>, + dest_layout: TyLayout<'tcx>, +) -> CValue<'tcx> { + let layout = place.layout(); + + if layout.abi == layout::Abi::Uninhabited { + return trap_unreachable_ret_value(fx, dest_layout, "[panic] Tried to get discriminant for uninhabited type."); + } + + let (discr_scalar, discr_index, discr_kind) = match &layout.variants { + layout::Variants::Single { index } => { + let discr_val = layout + .ty + .ty_adt_def() + .map_or(u128::from(index.as_u32()), |def| { + def.discriminant_for_variant(fx.tcx, *index).val + }); + return CValue::const_val(fx, dest_layout.ty, discr_val); + } + layout::Variants::Multiple { discr, discr_index, discr_kind, variants: _ } => { + (discr, *discr_index, discr_kind) + } + }; + + let discr = place.place_field(fx, mir::Field::new(discr_index)).to_cvalue(fx); + let discr_ty = discr.layout().ty; + let lldiscr = discr.load_scalar(fx); + match discr_kind { + layout::DiscriminantKind::Tag => { + let signed = match discr_scalar.value { + layout::Int(_, signed) => signed, + _ => false, + }; + let val = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), signed); + return CValue::by_val(val, dest_layout); + } + layout::DiscriminantKind::Niche { + dataful_variant, + ref niche_variants, + niche_start, + } => { + let niche_llty = fx.clif_type(discr_ty).unwrap(); + let dest_clif_ty = fx.clif_type(dest_layout.ty).unwrap(); + if niche_variants.start() == niche_variants.end() { + let b = fx + .bcx + .ins() + .icmp_imm(IntCC::Equal, lldiscr, *niche_start as u64 as i64); + let if_true = fx + .bcx + .ins() + .iconst(dest_clif_ty, niche_variants.start().as_u32() as i64); + let if_false = fx + .bcx + .ins() + .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); + let val = fx.bcx.ins().select(b, if_true, if_false); + return CValue::by_val(val, dest_layout); + } else { + // Rebase from niche values to discriminant values. + let delta = niche_start.wrapping_sub(niche_variants.start().as_u32() as u128); + let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); + let lldiscr = fx.bcx.ins().isub(lldiscr, delta); + let b = fx.bcx.ins().icmp_imm( + IntCC::UnsignedLessThanOrEqual, + lldiscr, + niche_variants.end().as_u32() as i64, + ); + let if_true = + clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false); + let if_false = fx + .bcx + .ins() + .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); + let val = fx.bcx.ins().select(b, if_true, if_false); + return CValue::by_val(val, dest_layout); + } + } + } +} diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 84288715f4d51..73d8bb8b0d2a2 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -377,7 +377,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( discriminant_value, (c val) { let pointee_layout = fx.layout_of(val.layout().ty.builtin_deref(true).unwrap().ty); let place = CPlace::for_addr(val.load_scalar(fx), pointee_layout); - let discr = crate::base::trans_get_discriminant(fx, place, ret.layout()); + let discr = crate::discriminant::codegen_get_discriminant(fx, place, ret.layout()); ret.write_cvalue(fx, discr); }; size_of, () { diff --git a/src/lib.rs b/src/lib.rs index b61114bec983b..d4f7219655536 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,6 +38,7 @@ mod codegen_i128; mod common; mod constant; mod debuginfo; +mod discriminant; mod driver; mod intrinsics; mod linkage; From db071db95aa1ab24d961c961e18daee66fdc4af4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Aug 2019 13:01:55 +0200 Subject: [PATCH 0816/1566] Calculate sign in trans{,_checked}_int_binop instead of caller --- src/base.rs | 19 ++++++------------- src/codegen_i128.rs | 3 ++- src/intrinsics.rs | 27 +++------------------------ src/num.rs | 10 ++++++---- 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/src/base.rs b/src/base.rs index 444e39c359d6c..26dfb1548daa1 100644 --- a/src/base.rs +++ b/src/base.rs @@ -261,40 +261,33 @@ fn trans_stmt<'a, 'tcx: 'a>( place.write_place_ref(fx, lval); } Rvalue::BinaryOp(bin_op, lhs, rhs) => { - let ty = fx.monomorphize(&lhs.ty(fx.mir, fx.tcx)); let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let res = match ty.sty { + let res = match lhs.layout().ty.sty { ty::Bool => crate::num::trans_bool_binop(fx, *bin_op, lhs, rhs), - ty::Uint(_) => { - crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, false) - } - ty::Int(_) => { - crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, true) + ty::Uint(_) | ty::Int(_ )=> { + crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } ty::Float(_) => crate::num::trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), ty::Char => crate::num::trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), ty::RawPtr(..) | ty::FnPtr(..) => { crate::num::trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) } - _ => unimplemented!("binop {:?} for {:?}", bin_op, ty), + _ => unimplemented!("{:?}({:?}, {:?})", bin_op, lhs.layout().ty, rhs.layout().ty), }; lval.write_cvalue(fx, res); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { - let ty = fx.monomorphize(&lhs.ty(fx.mir, fx.tcx)); let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let signed = type_sign(ty); - let res = if !fx.tcx.sess.overflow_checks() { - let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lhs.layout().ty, signed).load_scalar(fx); + let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lhs.layout().ty).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); CValue::by_val_pair(val, is_overflow, lval.layout()) } else { - crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty, signed) + crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) }; lval.write_cvalue(fx, res); diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index f173b4dbd5d9e..6fdd3042c5268 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -6,7 +6,6 @@ pub fn maybe_codegen<'a, 'tcx>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, checked: bool, - is_signed: bool, lhs: CValue<'tcx>, rhs: CValue<'tcx>, out_ty: Ty<'tcx>, @@ -18,6 +17,8 @@ pub fn maybe_codegen<'a, 'tcx>( let lhs_val = lhs.load_scalar(fx); let rhs_val = rhs.load_scalar(fx); + let is_signed = type_sign(lhs.layout().ty); + match bin_op { BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => { assert!(!checked); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 73d8bb8b0d2a2..45f8d82448e6b 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -446,28 +446,10 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "unchecked_shr" => BinOp::Shr, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = match ret.layout().ty.sty { - ty::Uint(_) => crate::num::trans_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - false, - ), - ty::Int(_) => crate::num::trans_int_binop( - fx, - bin_op, - x, - y, - ret.layout().ty, - true, - ), - _ => panic!(), - }; + let res = crate::num::trans_int_binop(fx, bin_op, x, y, ret.layout().ty); ret.write_cvalue(fx, res); }; - _ if intrinsic.ends_with("_with_overflow"), (c x, c y) { + _ if intrinsic.ends_with("_with_overflow"), (c x, c y) { assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { "add_with_overflow" => BinOp::Add, @@ -482,11 +464,10 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( x, y, ret.layout().ty, - type_sign(T), ); ret.write_cvalue(fx, res); }; - _ if intrinsic.starts_with("overflowing_"), (c x, c y) { + _ if intrinsic.starts_with("overflowing_"), (c x, c y) { assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { "overflowing_add" => BinOp::Add, @@ -500,7 +481,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( x, y, ret.layout().ty, - type_sign(T), ); ret.write_cvalue(fx, res); }; @@ -520,7 +500,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( x, y, fx.tcx.mk_tup([T, fx.tcx.types.bool].into_iter()), - signed, ); let (val, has_overflow) = checked_res.load_scalar_pair(fx); diff --git a/src/num.rs b/src/num.rs index 41448b388db88..9210c040ff377 100644 --- a/src/num.rs +++ b/src/num.rs @@ -78,7 +78,6 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( lhs: CValue<'tcx>, rhs: CValue<'tcx>, out_ty: Ty<'tcx>, - signed: bool, ) -> CValue<'tcx> { if bin_op != BinOp::Shl && bin_op != BinOp::Shr { assert_eq!( @@ -93,10 +92,12 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( _ => unreachable!("Out ty {:?} is not an integer or bool", out_ty), } - if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, signed, lhs, rhs, out_ty) { + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, lhs, rhs, out_ty) { return res; } + let signed = type_sign(lhs.layout().ty); + let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) && (lhs.layout().ty.sty == fx.tcx.types.i8.sty || lhs.layout().ty.sty == fx.tcx.types.i16.sty) @@ -149,7 +150,6 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, out_ty: Ty<'tcx>, - signed: bool, ) -> CValue<'tcx> { if bin_op != BinOp::Shl && bin_op != BinOp::Shr { assert_eq!( @@ -162,10 +162,12 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, true, signed, in_lhs, in_rhs, out_ty) { + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, true, in_lhs, in_rhs, out_ty) { return res; } + let signed = type_sign(in_lhs.layout().ty); + let (res, has_overflow) = match bin_op { BinOp::Add => { /*let (val, c_out) = fx.bcx.ins().iadd_cout(lhs, rhs); From b4e55cdeddcf53953214aadb6eaa431a24aa2601 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Aug 2019 15:03:52 +0200 Subject: [PATCH 0817/1566] Refactor num.rs --- src/base.rs | 18 +- src/codegen_i128.rs | 19 +- src/intrinsics.rs | 5 +- src/num.rs | 410 +++++++++++++++++++------------------------- 4 files changed, 183 insertions(+), 269 deletions(-) diff --git a/src/base.rs b/src/base.rs index 26dfb1548daa1..4af36117de023 100644 --- a/src/base.rs +++ b/src/base.rs @@ -264,18 +264,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let res = match lhs.layout().ty.sty { - ty::Bool => crate::num::trans_bool_binop(fx, *bin_op, lhs, rhs), - ty::Uint(_) | ty::Int(_ )=> { - crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) - } - ty::Float(_) => crate::num::trans_float_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), - ty::Char => crate::num::trans_char_binop(fx, *bin_op, lhs, rhs, lval.layout().ty), - ty::RawPtr(..) | ty::FnPtr(..) => { - crate::num::trans_ptr_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) - } - _ => unimplemented!("{:?}({:?}, {:?})", bin_op, lhs.layout().ty, rhs.layout().ty), - }; + let res = crate::num::codegen_binop(fx, *bin_op, lhs, rhs); lval.write_cvalue(fx, res); } Rvalue::CheckedBinaryOp(bin_op, lhs, rhs) => { @@ -283,11 +272,11 @@ fn trans_stmt<'a, 'tcx: 'a>( let rhs = trans_operand(fx, rhs); let res = if !fx.tcx.sess.overflow_checks() { - let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs, lhs.layout().ty).load_scalar(fx); + let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); CValue::by_val_pair(val, is_overflow, lval.layout()) } else { - crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs, lval.layout().ty) + crate::num::trans_checked_int_binop(fx, *bin_op, lhs, rhs) }; lval.write_cvalue(fx, res); @@ -314,6 +303,7 @@ fn trans_stmt<'a, 'tcx: 'a>( ty::Int(_) => { let clif_ty = fx.clif_type(layout.ty).unwrap(); if clif_ty == types::I128 { + // FIXME implement it crate::trap::trap_unreachable_ret_value(fx, layout, "i128 neg is not yet supported").load_scalar(fx) } else { let zero = fx.bcx.ins().iconst(clif_ty, 0); diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 6fdd3042c5268..87d69c2d9a71c 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -8,7 +8,6 @@ pub fn maybe_codegen<'a, 'tcx>( checked: bool, lhs: CValue<'tcx>, rhs: CValue<'tcx>, - out_ty: Ty<'tcx>, ) -> Option> { if lhs.layout().ty != fx.tcx.types.u128 && lhs.layout().ty != fx.tcx.types.i128 { return None; @@ -26,6 +25,7 @@ pub fn maybe_codegen<'a, 'tcx>( } BinOp::Add | BinOp::Sub if !checked => return None, BinOp::Add => { + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty) } else { @@ -33,6 +33,7 @@ pub fn maybe_codegen<'a, 'tcx>( }) } BinOp::Sub => { + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty) } else { @@ -42,6 +43,7 @@ pub fn maybe_codegen<'a, 'tcx>( BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { let res = if checked { + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); if is_signed { fx.easy_call("__rust_i128_mulo", &[lhs, rhs], out_ty) } else { @@ -91,18 +93,7 @@ pub fn maybe_codegen<'a, 'tcx>( // } else { // msb_cc // } - let cc = match (bin_op, is_signed) { - (BinOp::Ge, false) => IntCC::UnsignedGreaterThanOrEqual, - (BinOp::Gt, false) => IntCC::UnsignedGreaterThan, - (BinOp::Lt, false) => IntCC::UnsignedLessThan, - (BinOp::Le, false) => IntCC::UnsignedLessThanOrEqual, - - (BinOp::Ge, true) => IntCC::SignedGreaterThanOrEqual, - (BinOp::Gt, true) => IntCC::SignedGreaterThan, - (BinOp::Lt, true) => IntCC::SignedLessThan, - (BinOp::Le, true) => IntCC::SignedLessThanOrEqual, - _ => unreachable!(), - }; + let cc = crate::num::bin_op_to_intcc(bin_op, is_signed).unwrap(); let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); let lsb_cc = fx.bcx.ins().icmp(cc, lhs_lsb, rhs_lsb); @@ -160,6 +151,7 @@ pub fn maybe_codegen<'a, 'tcx>( }; if let Some(val) = val { if let Some(is_overflow) = is_overflow { + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); let val = val.load_scalar(fx); return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) } else { @@ -186,6 +178,7 @@ pub fn maybe_codegen<'a, 'tcx>( (_, _) => unreachable!(), }; if let Some(is_overflow) = is_overflow { + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); let val = val.load_scalar(fx); Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) } else { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 45f8d82448e6b..317da6f4aaf0d 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -446,7 +446,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( "unchecked_shr" => BinOp::Shr, _ => unimplemented!("intrinsic {}", intrinsic), }; - let res = crate::num::trans_int_binop(fx, bin_op, x, y, ret.layout().ty); + let res = crate::num::trans_int_binop(fx, bin_op, x, y); ret.write_cvalue(fx, res); }; _ if intrinsic.ends_with("_with_overflow"), (c x, c y) { @@ -463,7 +463,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( bin_op, x, y, - ret.layout().ty, ); ret.write_cvalue(fx, res); }; @@ -480,7 +479,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( bin_op, x, y, - ret.layout().ty, ); ret.write_cvalue(fx, res); }; @@ -499,7 +497,6 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( bin_op, x, y, - fx.tcx.mk_tup([T, fx.tcx.types.bool].into_iter()), ); let (val, has_overflow) = checked_res.load_scalar_pair(fx); diff --git a/src/num.rs b/src/num.rs index 9210c040ff377..1a8aed8f902b7 100644 --- a/src/num.rs +++ b/src/num.rs @@ -1,147 +1,141 @@ use crate::prelude::*; -macro_rules! binop_match { - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, bug) => { - bug!("binop {} on {} lhs: {:?} rhs: {:?}", stringify!($var), $bug_fmt, $lhs, $rhs) - }; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, icmp($cc:ident)) => {{ - assert_eq!($fx.tcx.types.bool, $ret_ty); - let ret_layout = $fx.layout_of($ret_ty); - - let b = $fx.bcx.ins().icmp(IntCC::$cc, $lhs, $rhs); - CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) - }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, fcmp($cc:ident)) => {{ - assert_eq!($fx.tcx.types.bool, $ret_ty); - let ret_layout = $fx.layout_of($ret_ty); - let b = $fx.bcx.ins().fcmp(FloatCC::$cc, $lhs, $rhs); - CValue::by_val($fx.bcx.ins().bint(types::I8, b), ret_layout) - }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, custom(|| $body:expr)) => {{ - $body - }}; - (@single $fx:expr, $bug_fmt:expr, $var:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $name:ident) => {{ - let ret_layout = $fx.layout_of($ret_ty); - CValue::by_val($fx.bcx.ins().$name($lhs, $rhs), ret_layout) - }}; - ( - $fx:expr, $bin_op:expr, $signed:expr, $lhs:expr, $rhs:expr, $ret_ty:expr, $bug_fmt:expr; - $( - $var:ident ($sign:pat) $name:tt $( ( $($next:tt)* ) )? ; - )* - ) => {{ - let lhs = $lhs.load_scalar($fx); - let rhs = $rhs.load_scalar($fx); - match ($bin_op, $signed) { - $( - (BinOp::$var, $sign) => binop_match!(@single $fx, $bug_fmt, $var, $signed, lhs, rhs, $ret_ty, $name $( ( $($next)* ) )?), - )* +pub fn bin_op_to_intcc(bin_op: BinOp, signed: bool) -> Option { + use BinOp::*; + use IntCC::*; + Some(match bin_op { + Eq => Equal, + Lt => if signed { SignedLessThan } else { UnsignedLessThan}, + Le => if signed { SignedLessThanOrEqual } else { UnsignedLessThanOrEqual}, + Ne => NotEqual, + Ge => if signed { SignedGreaterThanOrEqual } else { UnsignedGreaterThanOrEqual }, + Gt => if signed { SignedGreaterThan } else { UnsignedGreaterThan }, + _ => return None, + }) +} + +fn codegen_compare_bin_op<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + bin_op: BinOp, + signed: bool, + lhs: Value, + rhs: Value, +) -> CValue<'tcx> { + let val = fx.bcx.ins().icmp(bin_op_to_intcc(bin_op, signed).unwrap(), lhs, rhs); + let val = fx.bcx.ins().bint(types::I8, val); + CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)) +} + +pub fn codegen_binop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + bin_op: BinOp, + in_lhs: CValue<'tcx>, + in_rhs: CValue<'tcx>, +) -> CValue<'tcx> { + match bin_op { + BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { + match in_lhs.layout().ty.sty { + ref sty if *sty == fx.tcx.types.u128.sty || *sty == fx.tcx.types.i128.sty => {} + ty::Bool | ty::Uint(_) | ty::Int(_) | ty::Char => { + let signed = type_sign(in_lhs.layout().ty); + let lhs = in_lhs.load_scalar(fx); + let rhs = in_rhs.load_scalar(fx); + + let (lhs, rhs) = if + (bin_op == BinOp::Eq || bin_op == BinOp::Ne) + && (in_lhs.layout().ty.sty == fx.tcx.types.i8.sty || in_lhs.layout().ty.sty == fx.tcx.types.i16.sty) + { + // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. + ( + fx.bcx.ins().sextend(types::I32, lhs), + fx.bcx.ins().sextend(types::I32, rhs), + ) + } else { + (lhs, rhs) + }; + + return codegen_compare_bin_op(fx, bin_op, signed, lhs, rhs); + } + _ => {} + } + } + _ => {} + } + + match in_lhs.layout().ty.sty { + ty::Bool => crate::num::trans_bool_binop(fx, bin_op, in_lhs, in_rhs), + ty::Uint(_) | ty::Int(_)=> { + crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs) } - }} + ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs), + ty::RawPtr(..) | ty::FnPtr(..) => { + crate::num::trans_ptr_binop(fx, bin_op, in_lhs, in_rhs) + } + _ => unimplemented!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty), + } } pub fn trans_bool_binop<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, + in_lhs: CValue<'tcx>, + in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, false, lhs, rhs, fx.tcx.types.bool, "bool"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bxor; - BitAnd (_) band; - BitOr (_) bor; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) bug; + let lhs = in_lhs.load_scalar(fx); + let rhs = in_rhs.load_scalar(fx); + + let b = fx.bcx.ins(); + let res = match bin_op { + BinOp::BitXor => b.bxor(lhs, rhs), + BinOp::BitAnd => b.band(lhs, rhs), + BinOp::BitOr => b.bor(lhs, rhs), + // Compare binops handles by `codegen_binop`. + _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; - res + CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) } pub fn trans_int_binop<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - out_ty: Ty<'tcx>, + in_lhs: CValue<'tcx>, + in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { if bin_op != BinOp::Shl && bin_op != BinOp::Shr { assert_eq!( - lhs.layout().ty, - rhs.layout().ty, + in_lhs.layout().ty, + in_rhs.layout().ty, "int binop requires lhs and rhs of same type" ); } - match out_ty.sty { - ty::Bool | ty::Uint(_) | ty::Int(_) => {} - _ => unreachable!("Out ty {:?} is not an integer or bool", out_ty), - } - - if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, lhs, rhs, out_ty) { + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, false, in_lhs, in_rhs) { return res; } - let signed = type_sign(lhs.layout().ty); - - let (lhs, rhs) = if - (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (lhs.layout().ty.sty == fx.tcx.types.i8.sty || lhs.layout().ty.sty == fx.tcx.types.i16.sty) - { - // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. - let lhs = lhs.load_scalar(fx); - let rhs = rhs.load_scalar(fx); - ( - CValue::by_val(fx.bcx.ins().sextend(types::I32, lhs), fx.layout_of(fx.tcx.types.i32)), - CValue::by_val(fx.bcx.ins().sextend(types::I32, rhs), fx.layout_of(fx.tcx.types.i32)), - ) - } else { - (lhs, rhs) + let signed = type_sign(in_lhs.layout().ty); + + let lhs = in_lhs.load_scalar(fx); + let rhs = in_rhs.load_scalar(fx); + + let b = fx.bcx.ins(); + let val = match bin_op { + BinOp::Add => b.iadd(lhs, rhs), + BinOp::Sub => b.isub(lhs, rhs), + BinOp::Mul => b.imul(lhs, rhs), + BinOp::Div => if signed { b.sdiv(lhs, rhs) } else { b.udiv(lhs, rhs) }, + BinOp::Rem => if signed { b.srem(lhs, rhs) } else { b.urem(lhs, rhs) }, + BinOp::BitXor => b.bxor(lhs, rhs), + BinOp::BitAnd => b.band(lhs, rhs), + BinOp::BitOr => b.bor(lhs, rhs), + BinOp::Shl => b.ishl(lhs, rhs), + BinOp::Shr => if signed { b.sshr(lhs, rhs) } else { b.ushr(lhs, rhs) }, + // Compare binops handles by `codegen_binop`. + _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty), }; - binop_match! { - fx, bin_op, signed, lhs, rhs, out_ty, "int/uint"; - Add (_) iadd; - Sub (_) isub; - Mul (_) imul; - Div (false) udiv; - Div (true) sdiv; - Rem (false) urem; - Rem (true) srem; - BitXor (_) bxor; - BitAnd (_) band; - BitOr (_) bor; - Shl (_) ishl; - Shr (false) ushr; - Shr (true) sshr; - - Eq (_) icmp(Equal); - Lt (false) icmp(UnsignedLessThan); - Lt (true) icmp(SignedLessThan); - Le (false) icmp(UnsignedLessThanOrEqual); - Le (true) icmp(SignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (false) icmp(UnsignedGreaterThanOrEqual); - Ge (true) icmp(SignedGreaterThanOrEqual); - Gt (false) icmp(UnsignedGreaterThan); - Gt (true) icmp(SignedGreaterThan); - - Offset (_) bug; - } + CValue::by_val(val, in_lhs.layout()) } pub fn trans_checked_int_binop<'a, 'tcx: 'a>( @@ -149,7 +143,6 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, - out_ty: Ty<'tcx>, ) -> CValue<'tcx> { if bin_op != BinOp::Shl && bin_op != BinOp::Shr { assert_eq!( @@ -162,7 +155,7 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, true, in_lhs, in_rhs, out_ty) { + if let Some(res) = crate::codegen_i128::maybe_codegen(fx, bin_op, true, in_lhs, in_rhs) { return res; } @@ -234,7 +227,7 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( }; let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); - let out_place = CPlace::new_stack_slot(fx, out_ty); + let out_place = CPlace::new_stack_slot(fx, fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter())); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); @@ -244,85 +237,55 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( pub fn trans_float_binop<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - ty: Ty<'tcx>, + in_lhs: CValue<'tcx>, + in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, false, lhs, rhs, ty, "float"; - Add (_) fadd; - Sub (_) fsub; - Mul (_) fmul; - Div (_) fdiv; - Rem (_) custom(|| { - assert_eq!(lhs.layout().ty, ty); - assert_eq!(rhs.layout().ty, ty); - match ty.sty { - ty::Float(FloatTy::F32) => fx.easy_call("fmodf", &[lhs, rhs], ty), - ty::Float(FloatTy::F64) => fx.easy_call("fmod", &[lhs, rhs], ty), - _ => bug!(), - } - }); - BitXor (_) bxor; - BitAnd (_) band; - BitOr (_) bor; - Shl (_) bug; - Shr (_) bug; - - Eq (_) fcmp(Equal); - Lt (_) fcmp(LessThan); - Le (_) fcmp(LessThanOrEqual); - Ne (_) fcmp(NotEqual); - Ge (_) fcmp(GreaterThanOrEqual); - Gt (_) fcmp(GreaterThan); - - Offset (_) bug; - }; + assert_eq!(in_lhs.layout().ty, in_rhs.layout().ty); - res -} + let lhs = in_lhs.load_scalar(fx); + let rhs = in_rhs.load_scalar(fx); -pub fn trans_char_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, - bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - ty: Ty<'tcx>, -) -> CValue<'tcx> { - let res = binop_match! { - fx, bin_op, false, lhs, rhs, ty, "char"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) bug; + let b = fx.bcx.ins(); + let res = match bin_op { + BinOp::Add => b.fadd(lhs, rhs), + BinOp::Sub => b.fsub(lhs, rhs), + BinOp::Mul => b.fmul(lhs, rhs), + BinOp::Div => b.fdiv(lhs, rhs), + BinOp::Rem => { + let name = match in_lhs.layout().ty.sty { + ty::Float(FloatTy::F32) => "fmodf", + ty::Float(FloatTy::F64) => "fmod", + _ => bug!(), + }; + return fx.easy_call(name, &[in_lhs, in_rhs], in_lhs.layout().ty); + } + BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { + let fltcc = match bin_op { + BinOp::Eq => FloatCC::Equal, + BinOp::Lt => FloatCC::LessThan, + BinOp::Le => FloatCC::LessThanOrEqual, + BinOp::Ne => FloatCC::NotEqual, + BinOp::Ge => FloatCC::GreaterThanOrEqual, + BinOp::Gt => FloatCC::GreaterThan, + _ => unreachable!(), + }; + let val = fx.bcx.ins().fcmp(fltcc, lhs, rhs); + let val = fx.bcx.ins().bint(types::I8, val); + return CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)); + } + _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; - res + CValue::by_val(res, in_lhs.layout()) } pub fn trans_ptr_binop<'a, 'tcx: 'a>( fx: &mut FunctionCx<'a, 'tcx, impl Backend>, bin_op: BinOp, - lhs: CValue<'tcx>, - rhs: CValue<'tcx>, - ret_ty: Ty<'tcx>, + in_lhs: CValue<'tcx>, + in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { - let not_fat = match lhs.layout().ty.sty { + let not_fat = match in_lhs.layout().ty.sty { ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) } @@ -330,41 +293,27 @@ pub fn trans_ptr_binop<'a, 'tcx: 'a>( _ => bug!("trans_ptr_binop on non ptr"), }; if not_fat { - if let BinOp::Offset = bin_op { - let (base, offset) = (lhs, rhs.load_scalar(fx)); - let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; - let pointee_size = fx.layout_of(pointee_ty).size.bytes(); - let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); - let base_val = base.load_scalar(fx); - let res = fx.bcx.ins().iadd(base_val, ptr_diff); - return CValue::by_val(res, base.layout()); - } + match bin_op { + BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { + let lhs = in_lhs.load_scalar(fx); + let rhs = in_rhs.load_scalar(fx); - binop_match! { - fx, bin_op, false, lhs, rhs, ret_ty, "ptr"; - Add (_) bug; - Sub (_) bug; - Mul (_) bug; - Div (_) bug; - Rem (_) bug; - BitXor (_) bug; - BitAnd (_) bug; - BitOr (_) bug; - Shl (_) bug; - Shr (_) bug; - - Eq (_) icmp(Equal); - Lt (_) icmp(UnsignedLessThan); - Le (_) icmp(UnsignedLessThanOrEqual); - Ne (_) icmp(NotEqual); - Ge (_) icmp(UnsignedGreaterThanOrEqual); - Gt (_) icmp(UnsignedGreaterThan); - - Offset (_) bug; // Handled above - } + return codegen_compare_bin_op(fx, bin_op, false, lhs, rhs); + } + BinOp::Offset => { + let (base, offset) = (in_lhs, in_rhs.load_scalar(fx)); + let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; + let pointee_size = fx.layout_of(pointee_ty).size.bytes(); + let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); + let base_val = base.load_scalar(fx); + let res = fx.bcx.ins().iadd(base_val, ptr_diff); + return CValue::by_val(res, base.layout()); + } + _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), + }; } else { - let (lhs_ptr, lhs_extra) = lhs.load_scalar_pair(fx); - let (rhs_ptr, rhs_extra) = rhs.load_scalar_pair(fx); + let (lhs_ptr, lhs_extra) = in_lhs.load_scalar_pair(fx); + let (rhs_ptr, rhs_extra) = in_rhs.load_scalar_pair(fx); let res = match bin_op { BinOp::Eq => { @@ -380,29 +329,14 @@ pub fn trans_ptr_binop<'a, 'tcx: 'a>( BinOp::Lt | BinOp::Le | BinOp::Ge | BinOp::Gt => { let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); - let ptr_cmp = fx.bcx.ins().icmp(match bin_op { - BinOp::Lt => IntCC::UnsignedLessThan, - BinOp::Le => IntCC::UnsignedLessThanOrEqual, - BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, - BinOp::Gt => IntCC::UnsignedGreaterThan, - _ => unreachable!(), - }, lhs_ptr, rhs_ptr); - - let extra_cmp = fx.bcx.ins().icmp(match bin_op { - BinOp::Lt => IntCC::UnsignedLessThan, - BinOp::Le => IntCC::UnsignedLessThanOrEqual, - BinOp::Ge => IntCC::UnsignedGreaterThanOrEqual, - BinOp::Gt => IntCC::UnsignedGreaterThan, - _ => unreachable!(), - }, lhs_extra, rhs_extra); + let ptr_cmp = fx.bcx.ins().icmp(bin_op_to_intcc(bin_op, false).unwrap(), lhs_ptr, rhs_ptr); + let extra_cmp = fx.bcx.ins().icmp(bin_op_to_intcc(bin_op, false).unwrap(), lhs_extra, rhs_extra); fx.bcx.ins().select(ptr_eq, extra_cmp, ptr_cmp) } _ => panic!("bin_op {:?} on ptr", bin_op), }; - assert_eq!(fx.tcx.types.bool, ret_ty); - let ret_layout = fx.layout_of(ret_ty); - CValue::by_val(fx.bcx.ins().bint(types::I8, res), ret_layout) + CValue::by_val(fx.bcx.ins().bint(types::I8, res), fx.layout_of(fx.tcx.types.bool)) } } From 9505d60a249b23044e7054684388fd4993ba1a32 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Aug 2019 15:18:05 +0200 Subject: [PATCH 0818/1566] Cast rhs to lhs type for shl and shr --- example/std_example.rs | 2 ++ src/num.rs | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 7d1d8facdbe9e..7819881b69b4e 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -48,6 +48,8 @@ fn main() { assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128); assert_eq!(353985398u128 * 932490u128, 330087843781020u128); + let _a = 1u32 << 2u8; + unsafe { test_simd(); } diff --git a/src/num.rs b/src/num.rs index 1a8aed8f902b7..0b8ac786940de 100644 --- a/src/num.rs +++ b/src/num.rs @@ -129,8 +129,20 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( BinOp::BitXor => b.bxor(lhs, rhs), BinOp::BitAnd => b.band(lhs, rhs), BinOp::BitOr => b.bor(lhs, rhs), - BinOp::Shl => b.ishl(lhs, rhs), - BinOp::Shr => if signed { b.sshr(lhs, rhs) } else { b.ushr(lhs, rhs) }, + BinOp::Shl => { + let lhs_ty = fx.bcx.func.dfg.value_type(lhs); + let rhs = clif_intcast(fx, rhs, lhs_ty, false); + fx.bcx.ins().ishl(lhs, rhs) + } + BinOp::Shr => { + let lhs_ty = fx.bcx.func.dfg.value_type(lhs); + let rhs = clif_intcast(fx, rhs, lhs_ty, false); + if signed { + fx.bcx.ins().sshr(lhs, rhs) + } else { + fx.bcx.ins().ushr(lhs, rhs) + } + } // Compare binops handles by `codegen_binop`. _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty), }; From 7c7a8e8367829a2cb4f2804df03465128811c66c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Aug 2019 11:36:06 +0200 Subject: [PATCH 0819/1566] Workaround for missing icmp{,_imm}.i128 legalizations Fixes #667 --- ...002-Disable-u128-and-i128-in-libcore.patch | 112 ------------------ src/codegen_i128.rs | 34 +----- src/common.rs | 89 ++++++++++++++ src/discriminant.rs | 10 +- src/intrinsics.rs | 12 +- src/num.rs | 6 +- 6 files changed, 103 insertions(+), 160 deletions(-) delete mode 100644 patches/0002-Disable-u128-and-i128-in-libcore.patch diff --git a/patches/0002-Disable-u128-and-i128-in-libcore.patch b/patches/0002-Disable-u128-and-i128-in-libcore.patch deleted file mode 100644 index 0e663c0482b65..0000000000000 --- a/patches/0002-Disable-u128-and-i128-in-libcore.patch +++ /dev/null @@ -1,112 +0,0 @@ -From e87977477e8507a5749e64ea49ee503e706d7178 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Fri, 1 Mar 2019 18:36:21 +0100 -Subject: [PATCH] Disable u128 and i128 in libcore - ---- - src/libcore/sync/atomic.rs | 32 -------- - src/libcore/time.rs | 123 ------------------------------- - src/libstd/num.rs | 2 +- - src/libstd/panic.rs | 6 -- - 20 files changed, 63 insertions(+), 363 deletions(-) - -diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs -index 6b657b1..5add3f3 100644 ---- a/src/libcore/num/mod.rs -+++ b/src/libcore/num/mod.rs -@@ -127,8 +127,8 @@ macro_rules! from_str_radix_nzint_impl { - )*} - } - --from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroU128 NonZeroUsize -- NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroI128 NonZeroIsize } -+from_str_radix_nzint_impl! { NonZeroU8 NonZeroU16 NonZeroU32 NonZeroU64 NonZeroUsize -+ NonZeroI8 NonZeroI16 NonZeroI32 NonZeroI64 NonZeroIsize } - - /// Provides intentionally-wrapped arithmetic on `T`. - /// -diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs -index d0ee5fa..d02c454 100644 ---- a/src/libcore/sync/atomic.rs -+++ b/src/libcore/sync/atomic.rs -@@ -2012,38 +2012,6 @@ atomic_int! { - "AtomicU64::new(0)", - u64 AtomicU64 ATOMIC_U64_INIT - } --#[cfg(target_has_atomic = "128")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "i128", "../../../std/primitive.i128.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_min, atomic_max, -- 16, -- "AtomicI128::new(0)", -- i128 AtomicI128 ATOMIC_I128_INIT --} --#[cfg(target_has_atomic = "128")] --atomic_int! { -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- unstable(feature = "integer_atomics", issue = "32976"), -- "u128", "../../../std/primitive.u128.html", -- "#![feature(integer_atomics)]\n\n", -- atomic_umin, atomic_umax, -- 16, -- "AtomicU128::new(0)", -- u128 AtomicU128 ATOMIC_U128_INIT --} - #[cfg(target_pointer_width = "16")] - macro_rules! ptr_width { - () => { 2 } -diff --git a/src/libstd/num.rs b/src/libstd/num.rs -index 828d572..bc04fb1 100644 ---- a/src/libstd/num.rs -+++ b/src/libstd/num.rs -@@ -12,7 +12,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} - pub use core::num::Wrapping; - - #[stable(feature = "nonzero", since = "1.28.0")] --pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize}; -+pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroUsize}; - #[stable(feature = "signed_nonzero", since = "1.34.0")] --pub use core::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize}; -+pub use core::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroIsize}; - - #[cfg(test)] use crate::fmt; - #[cfg(test)] use crate::ops::{Add, Sub, Mul, Div, Rem}; -diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs -index 6a16414..f027102 100644 ---- a/src/libstd/panic.rs -+++ b/src/libstd/panic.rs -@@ -254,9 +254,6 @@ impl RefUnwindSafe for atomic::AtomicI32 {} - #[cfg(target_has_atomic = "64")] - #[unstable(feature = "integer_atomics", issue = "32976")] - impl RefUnwindSafe for atomic::AtomicI64 {} --#[cfg(target_has_atomic = "128")] --#[unstable(feature = "integer_atomics", issue = "32976")] --impl RefUnwindSafe for atomic::AtomicI128 {} - - #[cfg(target_has_atomic = "ptr")] - #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] -@@ -273,9 +270,6 @@ impl RefUnwindSafe for atomic::AtomicU32 {} - #[cfg(target_has_atomic = "64")] - #[unstable(feature = "integer_atomics", issue = "32976")] - impl RefUnwindSafe for atomic::AtomicU64 {} --#[cfg(target_has_atomic = "128")] --#[unstable(feature = "integer_atomics", issue = "32976")] --impl RefUnwindSafe for atomic::AtomicU128 {} - - #[cfg(target_has_atomic = "8")] - #[stable(feature = "unwind_safe_atomic_refs", since = "1.14.0")] --- -2.17.2 (Apple Git-113) diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 87d69c2d9a71c..cfe5ce5918f74 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -73,39 +73,7 @@ pub fn maybe_codegen<'a, 'tcx>( } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { assert!(!checked); - let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); - let (rhs_lsb, rhs_msb) = fx.bcx.ins().isplit(rhs_val); - - let res = match bin_op { - BinOp::Eq => { - let lsb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_lsb, rhs_lsb); - let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); - fx.bcx.ins().band(lsb_eq, msb_eq) - } - BinOp::Ne => { - let lsb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_lsb, rhs_lsb); - let msb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_msb, rhs_msb); - fx.bcx.ins().bor(lsb_ne, msb_ne) - } - _ => { - // if msb_eq { - // lsb_cc - // } else { - // msb_cc - // } - let cc = crate::num::bin_op_to_intcc(bin_op, is_signed).unwrap(); - - let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); - let lsb_cc = fx.bcx.ins().icmp(cc, lhs_lsb, rhs_lsb); - let msb_cc = fx.bcx.ins().icmp(cc, lhs_msb, rhs_msb); - - fx.bcx.ins().select(msb_eq, lsb_cc, msb_cc) - } - }; - - let res = fx.bcx.ins().bint(types::I8, res); - let res = CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)); - return Some(res); + return None; } BinOp::Shl | BinOp::Shr => { let is_overflow = if checked { diff --git a/src/common.rs b/src/common.rs index 5cdbd9bd79ea1..bbfee005a6280 100644 --- a/src/common.rs +++ b/src/common.rs @@ -73,6 +73,95 @@ pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: V } } +pub fn codegen_icmp<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + intcc: IntCC, + lhs: Value, + rhs: Value, +) -> Value { + let lhs_ty = fx.bcx.func.dfg.value_type(lhs); + let rhs_ty = fx.bcx.func.dfg.value_type(rhs); + assert_eq!(lhs_ty, rhs_ty); + if lhs_ty == types::I128 { + // FIXME legalize `icmp.i128` in Cranelift + + let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs); + let (rhs_lsb, rhs_msb) = fx.bcx.ins().isplit(rhs); + + match intcc { + IntCC::Equal => { + let lsb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_lsb, rhs_lsb); + let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); + fx.bcx.ins().band(lsb_eq, msb_eq) + } + IntCC::NotEqual => { + let lsb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_lsb, rhs_lsb); + let msb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_msb, rhs_msb); + fx.bcx.ins().bor(lsb_ne, msb_ne) + } + _ => { + // if msb_eq { + // lsb_cc + // } else { + // msb_cc + // } + + let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); + let lsb_cc = fx.bcx.ins().icmp(intcc, lhs_lsb, rhs_lsb); + let msb_cc = fx.bcx.ins().icmp(intcc, lhs_msb, rhs_msb); + + fx.bcx.ins().select(msb_eq, lsb_cc, msb_cc) + } + } + } else { + fx.bcx.ins().icmp(intcc, lhs, rhs) + } +} + +pub fn codegen_icmp_imm<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + intcc: IntCC, + lhs: Value, + rhs: i128, +) -> Value { + let lhs_ty = fx.bcx.func.dfg.value_type(lhs); + if lhs_ty == types::I128 { + // FIXME legalize `icmp_imm.i128` in Cranelift + + let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs); + let (rhs_lsb, rhs_msb) = (rhs as u128 as u64 as i64, (rhs as u128 >> 64) as u64 as i64); + + match intcc { + IntCC::Equal => { + let lsb_eq = fx.bcx.ins().icmp_imm(IntCC::Equal, lhs_lsb, rhs_lsb); + let msb_eq = fx.bcx.ins().icmp_imm(IntCC::Equal, lhs_msb, rhs_msb); + fx.bcx.ins().band(lsb_eq, msb_eq) + } + IntCC::NotEqual => { + let lsb_ne = fx.bcx.ins().icmp_imm(IntCC::NotEqual, lhs_lsb, rhs_lsb); + let msb_ne = fx.bcx.ins().icmp_imm(IntCC::NotEqual, lhs_msb, rhs_msb); + fx.bcx.ins().bor(lsb_ne, msb_ne) + } + _ => { + // if msb_eq { + // lsb_cc + // } else { + // msb_cc + // } + + let msb_eq = fx.bcx.ins().icmp_imm(IntCC::Equal, lhs_msb, rhs_msb); + let lsb_cc = fx.bcx.ins().icmp_imm(intcc, lhs_lsb, rhs_lsb); + let msb_cc = fx.bcx.ins().icmp_imm(intcc, lhs_msb, rhs_msb); + + fx.bcx.ins().select(msb_eq, lsb_cc, msb_cc) + } + } + } else { + let rhs = i64::try_from(rhs).expect("codegen_icmp_imm rhs out of range for <128bit int"); + fx.bcx.ins().icmp_imm(intcc, lhs, rhs) + } +} + fn resolve_normal_value_imm(func: &Function, val: Value) -> Option { if let ValueDef::Result(inst, 0 /*param*/) = func.dfg.value_def(val) { if let InstructionData::UnaryImm { diff --git a/src/discriminant.rs b/src/discriminant.rs index 9b049cd4e1e1a..1a83b39fb09d9 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -102,10 +102,7 @@ pub fn codegen_get_discriminant<'tcx>( let niche_llty = fx.clif_type(discr_ty).unwrap(); let dest_clif_ty = fx.clif_type(dest_layout.ty).unwrap(); if niche_variants.start() == niche_variants.end() { - let b = fx - .bcx - .ins() - .icmp_imm(IntCC::Equal, lldiscr, *niche_start as u64 as i64); + let b = codegen_icmp_imm(fx, IntCC::Equal, lldiscr, *niche_start as i128); let if_true = fx .bcx .ins() @@ -121,10 +118,11 @@ pub fn codegen_get_discriminant<'tcx>( let delta = niche_start.wrapping_sub(niche_variants.start().as_u32() as u128); let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); let lldiscr = fx.bcx.ins().isub(lldiscr, delta); - let b = fx.bcx.ins().icmp_imm( + let b = codegen_icmp_imm( + fx, IntCC::UnsignedLessThanOrEqual, lldiscr, - niche_variants.end().as_u32() as i64, + i128::from(niche_variants.end().as_u32()), ); let if_true = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 317da6f4aaf0d..8b4d596285699 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -119,8 +119,8 @@ macro_rules! atomic_minmax { let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); // Compare - let is_eq = $fx.bcx.ins().icmp(IntCC::SignedGreaterThan, old, $src); - let new = crate::common::codegen_select(&mut $fx.bcx, is_eq, old, $src); + let is_eq = codegen_icmp($fx, IntCC::SignedGreaterThan, old, $src); + let new = codegen_select(&mut $fx.bcx, is_eq, old, $src); // Write new $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); @@ -198,7 +198,7 @@ macro_rules! simd_cmp { ($fx:expr, $intrinsic:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = match lane_layout.ty.sty { - ty::Uint(_) | ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane), + ty::Uint(_) | ty::Int(_) => codegen_icmp(fx, IntCC::$cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) @@ -207,8 +207,8 @@ macro_rules! simd_cmp { ($fx:expr, $intrinsic:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = match lane_layout.ty.sty { - ty::Uint(_) => fx.bcx.ins().icmp(IntCC::$cc_u, x_lane, y_lane), - ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc_s, x_lane, y_lane), + ty::Uint(_) => codegen_icmp(fx, IntCC::$cc_u, x_lane, y_lane), + ty::Int(_) => codegen_icmp(fx, IntCC::$cc_s, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) @@ -791,7 +791,7 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); // Compare - let is_eq = fx.bcx.ins().icmp(IntCC::Equal, old, test_old); + let is_eq = codegen_icmp(fx, IntCC::Equal, old, test_old); let new = crate::common::codegen_select(&mut fx.bcx, is_eq, new, old); // Keep old if not equal to test_old // Write new diff --git a/src/num.rs b/src/num.rs index 0b8ac786940de..1e8329007f9c8 100644 --- a/src/num.rs +++ b/src/num.rs @@ -21,7 +21,8 @@ fn codegen_compare_bin_op<'tcx>( lhs: Value, rhs: Value, ) -> CValue<'tcx> { - let val = fx.bcx.ins().icmp(bin_op_to_intcc(bin_op, signed).unwrap(), lhs, rhs); + let intcc = crate::num::bin_op_to_intcc(bin_op, signed).unwrap(); + let val = codegen_icmp(fx, intcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)) } @@ -35,7 +36,6 @@ pub fn codegen_binop<'tcx>( match bin_op { BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { match in_lhs.layout().ty.sty { - ref sty if *sty == fx.tcx.types.u128.sty || *sty == fx.tcx.types.i128.sty => {} ty::Bool | ty::Uint(_) | ty::Int(_) | ty::Char => { let signed = type_sign(in_lhs.layout().ty); let lhs = in_lhs.load_scalar(fx); @@ -310,7 +310,7 @@ pub fn trans_ptr_binop<'a, 'tcx: 'a>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - return codegen_compare_bin_op(fx, bin_op, false, lhs, rhs); + return codegen_compare_bin_op(fx, bin_op, false, lhs, rhs);; } BinOp::Offset => { let (base, offset) = (in_lhs, in_rhs.load_scalar(fx)); From 6bf47ad0d42ebf756518584fe45fd081f3eba7c3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Aug 2019 13:37:38 +0200 Subject: [PATCH 0820/1566] Include load/store.i128 fix from my cranelift branch --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 11e4b2e338832..5e88f150ccc88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-frontend 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -121,7 +121,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", ] @@ -129,7 +129,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-bforest 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-codegen-meta 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -143,7 +143,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", ] @@ -151,12 +151,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" [[package]] name = "cranelift-faerie" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -169,7 +169,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -179,7 +179,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -190,7 +190,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -200,7 +200,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ca836a8e0d0b62e2ddecb5902cd5091b468a4db3" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", From 2558bf2f6bd5e74861d7db760f689b3b01bcc618 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Aug 2019 16:04:50 +0200 Subject: [PATCH 0821/1566] Workaround for missing `#[rustc_args_required_const(..)]` support cc #666 --- example/std_example.rs | 16 ++++++++++++++++ src/constant.rs | 15 ++++++--------- src/intrinsics.rs | 12 +++++++++++- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 7819881b69b4e..61182a49b9cce 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -75,6 +75,9 @@ unsafe fn test_simd() { test_mm_cvtepi8_epi16(); test_mm_cvtsi128_si64(); + // FIXME(#666) implement `#[rustc_arg_required_const(..)]` support + //test_mm_extract_epi8(); + let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); assert_eq!(mask1, 1); } @@ -194,6 +197,19 @@ unsafe fn test_mm_cvtepi8_epi16() { assert_eq_m128i(r, e); } +#[target_feature(enable = "sse4.1")] +unsafe fn test_mm_extract_epi8() { + #[rustfmt::skip] + let a = _mm_setr_epi8( + -1, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 + ); + let r1 = _mm_extract_epi8(a, 0); + let r2 = _mm_extract_epi8(a, 19); + assert_eq!(r1, 0xFF); + assert_eq!(r2, 3); +} + #[derive(PartialEq)] enum LoopState { Continue(()), diff --git a/src/constant.rs b/src/constant.rs index a71a8d0bf2cdb..23f550050e45c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -439,22 +439,19 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { pub fn mir_operand_get_const_val<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, operand: &Operand<'tcx>, -) -> Result<&'tcx Const<'tcx>, String> { +) -> Option<&'tcx Const<'tcx>> { let place = match operand { - Operand::Copy(place) => place, - Operand::Constant(const_) => return Ok(force_eval_const(fx, const_.literal)), - _ => return Err(format!("{:?}", operand)), + Operand::Copy(place) | Operand::Move(place) => place, + Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)), }; assert!(place.projection.is_none()); let static_ = match &place.base { - PlaceBase::Static(static_) => { - static_ - } - PlaceBase::Local(_) => return Err("local".to_string()), + PlaceBase::Static(static_) => static_, + PlaceBase::Local(_) => return None, }; - Ok(match &static_.kind { + Some(match &static_.kind { StaticKind::Static(_) => unimplemented!(), StaticKind::Promoted(promoted) => { fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 8b4d596285699..bd78271057c9e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -951,7 +951,17 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( }; simd_extract, (c v, o idx) { - let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_extract* idx not const"); + let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { + idx_const + } else { + fx.tcx.sess.span_warn( + fx.mir.span, + "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", + ); + crate::trap::trap_panic(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); + return; + }; + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); let (_lane_type, lane_count) = lane_type_and_count(fx, v.layout(), intrinsic); if idx >= lane_count.into() { From 480db7dd9e95492f987ee36b53935a179699a287 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Aug 2019 18:16:24 +0200 Subject: [PATCH 0822/1566] Implement system abi --- src/abi.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index c66dbe3958d91..6e4edc4a15186 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -149,7 +149,17 @@ fn adjust_arg_for_abi<'a, 'tcx: 'a>( } fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: bool) -> Signature { - let (call_conv, inputs, output): (CallConv, Vec, Ty) = match sig.abi { + let abi = match sig.abi { + Abi::System => { + if tcx.sess.target.target.options.is_like_windows { + unimplemented!() + } else { + Abi::C + } + } + abi => abi, + }; + let (call_conv, inputs, output): (CallConv, Vec, Ty) = match abi { Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { @@ -162,7 +172,7 @@ fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: inputs.extend(extra_args.types()); (CallConv::SystemV, inputs, sig.output()) } - Abi::System => bug!("system abi should be selected elsewhere"), + Abi::System => unreachable!(), Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), _ => unimplemented!("unsupported abi {:?}", sig.abi), }; From 21141eb235340f78655bb557876ca8435a4785b1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 17 Aug 2019 12:31:10 +0200 Subject: [PATCH 0823/1566] Don't keep alloc_map locked while calling data_id_for_static Fixes #670 --- src/constant.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 23f550050e45c..63ac186690a7c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -186,8 +186,9 @@ fn data_id_for_static( def_id: DefId, linkage: Linkage, ) -> DataId { - let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); - let ty = tcx.type_of(def_id); + let instance = Instance::mono(tcx, def_id); + let symbol_name = tcx.symbol_name(instance).as_str(); + let ty = instance.ty(tcx); let is_mutable = if tcx.is_mutable_static(def_id) { true } else { @@ -200,7 +201,7 @@ fn data_id_for_static( .unwrap(); if linkage == Linkage::Preemptible { - if let ty::RawPtr(_) = tcx.type_of(def_id).sty { + if let ty::RawPtr(_) = ty.sty { } else { tcx.sess.span_fatal(tcx.def_span(def_id), "must have type `*const T` or `*mut T` due to `#[linkage]` attribute") } @@ -297,7 +298,8 @@ fn define_all_allocs( read_target_uint(endianness, bytes).unwrap() }; - let data_id = match tcx.alloc_map.lock().get(reloc).unwrap() { + let reloc_target_alloc = tcx.alloc_map.lock().get(reloc).unwrap(); + let data_id = match reloc_target_alloc { GlobalAlloc::Function(instance) => { assert_eq!(addend, 0); let func_id = crate::abi::import_function(tcx, module, instance); From 43e68319fabb4f55071618e2a40ec534f4fbe9bc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 11:30:13 +0200 Subject: [PATCH 0824/1566] Rustup to rustc 1.39.0-nightly (2111aed0a 2019-08-17) --- build_sysroot/build_sysroot.sh | 4 ++-- src/base.rs | 1 - src/constant.rs | 3 +-- src/intrinsics.rs | 8 ++++---- src/main_shim.rs | 2 +- src/num.rs | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index c37dd5104a858..5b3ea291e7738 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -28,7 +28,7 @@ fi # Copy files to sysroot mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ -cp target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ if [[ "$1" == "--release" ]]; then channel='release' @@ -39,4 +39,4 @@ else fi # Copy files to sysroot -cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ +cp -r sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/src/base.rs b/src/base.rs index 4af36117de023..51e6e44b59e98 100644 --- a/src/base.rs +++ b/src/base.rs @@ -490,7 +490,6 @@ fn trans_stmt<'a, 'tcx: 'a>( alignstack, // bool dialect: _, // syntax::ast::AsmDialect asm_str_style: _, - ctxt: _, } = asm; match &*asm_code.as_str() { "cpuid" | "cpuid\n" => { diff --git a/src/constant.rs b/src/constant.rs index 63ac186690a7c..19529a79928b2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -154,7 +154,6 @@ fn trans_const_place<'a, 'tcx: 'a>( let op = ecx.eval_operand( &Operand::Constant(Box::new(Constant { span: DUMMY_SP, - ty: const_.ty, user_ty: None, literal: const_, })), @@ -391,7 +390,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { _: mir::BinOp, _: ImmTy<'tcx>, _: ImmTy<'tcx>, - ) -> InterpResult<'tcx, (Scalar, bool)> { + ) -> InterpResult<'tcx, (Scalar, bool, Ty<'tcx>)> { panic!(); } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index bd78271057c9e..2dfa45c9dfb07 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -466,12 +466,12 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( ); ret.write_cvalue(fx, res); }; - _ if intrinsic.starts_with("overflowing_"), (c x, c y) { + _ if intrinsic.starts_with("wrapping_"), (c x, c y) { assert_eq!(x.layout().ty, y.layout().ty); let bin_op = match intrinsic { - "overflowing_add" => BinOp::Add, - "overflowing_sub" => BinOp::Sub, - "overflowing_mul" => BinOp::Mul, + "wrapping_add" => BinOp::Add, + "wrapping_sub" => BinOp::Sub, + "wrapping_mul" => BinOp::Mul, _ => unimplemented!("intrinsic {}", intrinsic), }; let res = crate::num::trans_int_binop( diff --git a/src/main_shim.rs b/src/main_shim.rs index 1dae9e32baad3..3dc3fad51f501 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -20,7 +20,7 @@ pub fn maybe_create_entry_wrapper( None => return, }; - create_entry_fn(tcx, module, main_def_id, use_start_lang_item);; + create_entry_fn(tcx, module, main_def_id, use_start_lang_item); fn create_entry_fn( tcx: TyCtxt<'_>, diff --git a/src/num.rs b/src/num.rs index 1e8329007f9c8..8d3bb01921805 100644 --- a/src/num.rs +++ b/src/num.rs @@ -310,7 +310,7 @@ pub fn trans_ptr_binop<'a, 'tcx: 'a>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - return codegen_compare_bin_op(fx, bin_op, false, lhs, rhs);; + return codegen_compare_bin_op(fx, bin_op, false, lhs, rhs); } BinOp::Offset => { let (base, offset) = (in_lhs, in_rhs.load_scalar(fx)); From 8e400008ff6342f8fa5273259c5f51b7ac056fff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 14:49:10 +0200 Subject: [PATCH 0825/1566] Disable debug assertions for libstd This is necessary on macOS, because of alignment problems --- build_sysroot/Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 7776f1bd38309..c5bf0705c1933 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -15,5 +15,11 @@ alloc_system = { path = "./alloc_system" } rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } +[profile.dev] +# FIXME On macOS statics and promoted constants have the wrong alignment. This causes a debug +# assertion in `copy_nonoverlapping` to panic. +debug-assertions = false + [profile.release] debug = true +debug-assertions = false From 7aa4cb874a7448adb1d941b76ff03d1645ddccf3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 14:57:46 +0200 Subject: [PATCH 0826/1566] Misc changes --- build_sysroot/build_sysroot.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 5b3ea291e7738..37aa7c1908d9c 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -12,9 +12,9 @@ popd >/dev/null # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true -rm -r sysroot_src/src/{libcore,libtest}/target/$TARGET_TRIPLE/$sysroot_channel/ || true +rm -r sysroot_src/src/{libcore,libtest}/target/ || true rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true -rm -r sysroot 2>/dev/null || true +rm -r sysroot/ 2>/dev/null || true # Build libs export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked" From f61b36a396833ff2e387b4c657f84965f987fd16 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 15:30:06 +0200 Subject: [PATCH 0827/1566] Don't run a alignment assertion on macOS --- example/mini_core.rs | 4 ++++ example/mini_core_hello_world.rs | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index a23c94aa7babd..78b493e0515c3 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -525,3 +525,7 @@ pub macro file() { /* compiler built-in */ } #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] pub macro line() { /* compiler built-in */ } + +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro cfg() { /* compiler built-in */ } diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 282a9baf7524e..56a799be2fb11 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -136,7 +136,12 @@ fn main() { let slice = &[0, 1] as &[i32]; let slice_ptr = slice as *const [i32] as *const i32; - assert_eq!(slice_ptr as usize % 4, 0); + + // FIXME On macOS statics and promoted constants have the wrong alignment. This causes this + // assertion to fail. + if cfg!(not(target_os = "macos")) { + assert_eq!(slice_ptr as usize % 4, 0); + } //return; From 2add773752379006f74867eec78fceec2c6403a4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 15:48:31 +0200 Subject: [PATCH 0828/1566] Don't run jit tests on macOS Workaround for #671 --- test.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test.sh b/test.sh index cd2b9fe448398..997c4da753834 100755 --- a/test.sh +++ b/test.sh @@ -12,6 +12,16 @@ fi source config.sh +jit() { + if [[ `uname` == 'Darwin' ]]; then + # FIXME(#671) `dlsym` returns "symbol not found" for existing symbols on macOS. + echo "[JIT] $1 (Ignored on macOS)" + else + echo "[JIT] $1" + SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic $2 + fi +} + rm -r target/out || true mkdir -p target/out/clif @@ -21,8 +31,7 @@ $RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib -echo "[JIT] mini_core_hello_world" -SHOULD_RUN=1 JIT_ARGS="abc bcd" $RUSTC --crate-type bin example/mini_core_hello_world.rs --cfg jit +JIT_ARGS="abc bcd" jit mini_core_hello_world example/mini_core_hello_world.rs echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin @@ -39,8 +48,7 @@ echo "[AOT] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin ./target/out/alloc_example -echo "[JIT] std_example" -SHOULD_RUN=1 $RUSTC example/std_example.rs --crate-type bin -Cprefer-dynamic +jit std_example example/std_example.rs echo "[AOT] std_example" $RUSTC example/std_example.rs --crate-type bin From 5b818e5e0f93e3870312aa3a780cb33ad95ad7a7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 16:06:59 +0200 Subject: [PATCH 0829/1566] Use native `ar` to create archive files Workaround for #672 --- src/archive.rs | 67 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index ea6357b539a22..6d76fb14c97c0 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -9,20 +9,20 @@ use rustc_codegen_ssa::back::archive::{ArchiveBuilder, find_library}; struct ArchiveConfig<'a> { sess: &'a Session, dst: PathBuf, - src: Option, lib_search_paths: Vec, + use_native_ar: bool, use_gnu_style_archive: bool, } #[derive(Debug)] enum ArchiveEntry { FromArchive { archive_index: usize, entry_index: usize }, - File(File), + File(PathBuf), } pub struct ArArchiveBuilder<'a> { config: ArchiveConfig<'a>, - src_archives: Vec>, + src_archives: Vec<(PathBuf, ar::Archive)>, // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at // the end of an archive for linkers to not get confused. entries: Vec<(String, ArchiveEntry)>, @@ -35,14 +35,14 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let config = ArchiveConfig { sess, dst: output.to_path_buf(), - src: input.map(|p| p.to_path_buf()), lib_search_paths: archive_search_paths(sess), + use_native_ar: true, // FIXME fix rust-ar to not emit corrupted archive files. // FIXME test for linux and System V derivatives instead use_gnu_style_archive: !sess.target.target.options.is_like_osx, }; - let (src_archives, entries) = if let Some(src) = &config.src { - let mut archive = ar::Archive::new(File::open(src).unwrap()); + let (src_archives, entries) = if let Some(input) = input { + let mut archive = ar::Archive::new(File::open(input).unwrap()); let mut entries = Vec::new(); let mut i = 0; @@ -55,7 +55,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { i += 1; } - (vec![archive], entries) + (vec![(input.to_owned(), archive)], entries) } else { (vec![], Vec::new()) }; @@ -83,13 +83,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { fn add_file(&mut self, file: &Path) { self.entries.push(( file.file_name().unwrap().to_str().unwrap().to_string(), - ArchiveEntry::File(File::open(file).unwrap()), + ArchiveEntry::File(file.to_owned()), )); } fn add_native_library(&mut self, name: &str) { let location = find_library(name, &self.config.lib_search_paths, self.config.sess); - self.add_archive(&location, |_| false).unwrap_or_else(|e| { + self.add_archive(location.clone(), |_| false).unwrap_or_else(|e| { panic!("failed to add native library {}: {}", location.to_string_lossy(), e); }); } @@ -97,7 +97,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { fn add_rlib(&mut self, rlib: &Path, name: &str, lto: bool, skip_objects: bool) -> std::io::Result<()> { let obj_start = name.to_owned(); - self.add_archive(rlib, move |fname: &str| { + self.add_archive(rlib.to_owned(), move |fname: &str| { // Ignore bytecode/metadata files, no matter the name. if fname.ends_with(RLIB_BYTECODE_EXTENSION) || fname == METADATA_FILENAME { return true; @@ -124,43 +124,66 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn build(mut self) { - enum BuilderKind { + use std::process::Command; + + fn add_file_using_ar(archive: &Path, file: &Path) { + Command::new("ar") + .arg("r") // add or replace file + .arg("-c") // silence created file message + .arg(archive) + .arg(&file) + .status() + .unwrap(); + } + + enum BuilderKind<'a> { Bsd(ar::Builder), Gnu(ar::GnuBuilder), + NativeAr(&'a Path), } - let archive_file = File::create(&self.config.dst).unwrap(); - let mut builder = if self.config.use_gnu_style_archive { + let mut builder = if self.config.use_native_ar { + BuilderKind::NativeAr(&self.config.dst) + } else if self.config.use_gnu_style_archive { BuilderKind::Gnu(ar::GnuBuilder::new( - archive_file, + File::create(&self.config.dst).unwrap(), self.entries.iter().map(|(name, _)| name.as_bytes().to_vec()).collect(), )) } else { - BuilderKind::Bsd(ar::Builder::new(archive_file)) + BuilderKind::Bsd(ar::Builder::new(File::create(&self.config.dst).unwrap())) }; // Add all files for (entry_name, entry) in self.entries.into_iter() { match entry { ArchiveEntry::FromArchive { archive_index, entry_index } => { - let entry = self.src_archives[archive_index].jump_to_entry(entry_index).unwrap(); + let (ref src_archive_path, ref mut src_archive) = self.src_archives[archive_index]; + let entry = src_archive.jump_to_entry(entry_index).unwrap(); let orig_header = entry.header(); + // FIXME implement clone for `ar::Archive`. let mut header = ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); header.set_mtime(orig_header.mtime()); header.set_uid(orig_header.uid()); header.set_gid(orig_header.gid()); header.set_mode(orig_header.mode()); + match builder { BuilderKind::Bsd(ref mut builder) => builder.append(&header, entry).unwrap(), BuilderKind::Gnu(ref mut builder) => builder.append(&header, entry).unwrap(), + BuilderKind::NativeAr(archive_file) => { + Command::new("ar").arg("x").arg(src_archive_path).arg(&entry_name).status().unwrap(); + add_file_using_ar(archive_file, Path::new(&entry_name)); + std::fs::remove_file(entry_name).unwrap(); + } } } - ArchiveEntry::File(mut file) => { + ArchiveEntry::File(file) => { match builder { - BuilderKind::Bsd(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut file).unwrap(), - BuilderKind::Gnu(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut file).unwrap(), + BuilderKind::Bsd(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()).unwrap(), + BuilderKind::Gnu(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()).unwrap(), + BuilderKind::NativeAr(archive_file) => add_file_using_ar(archive_file, &file), } } } @@ -183,10 +206,10 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } impl<'a> ArArchiveBuilder<'a> { - fn add_archive(&mut self, archive: &Path, mut skip: F) -> std::io::Result<()> + fn add_archive(&mut self, archive_path: PathBuf, mut skip: F) -> std::io::Result<()> where F: FnMut(&str) -> bool + 'static { - let mut archive = ar::Archive::new(std::fs::File::open(archive)?); + let mut archive = ar::Archive::new(std::fs::File::open(&archive_path)?); let archive_index = self.src_archives.len(); let mut i = 0; @@ -202,7 +225,7 @@ impl<'a> ArArchiveBuilder<'a> { i += 1; } - self.src_archives.push(archive); + self.src_archives.push((archive_path, archive)); Ok(()) } } From 1bee110d95e4611385b821a199bc8c4ce7ee00e0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 16:19:33 +0200 Subject: [PATCH 0830/1566] Let codegen_get_discriminant accept CValue instead of CPlace --- src/base.rs | 8 +++----- src/discriminant.rs | 6 +++--- src/intrinsics.rs | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/base.rs b/src/base.rs index 51e6e44b59e98..8064b83d72811 100644 --- a/src/base.rs +++ b/src/base.rs @@ -367,10 +367,7 @@ fn trans_stmt<'a, 'tcx: 'a>( _ => unreachable!("cast adt {} -> {}", from_ty, to_ty), } - // FIXME avoid forcing to stack - let place = - CPlace::for_addr(operand.force_stack(fx), operand.layout()); - let discr = crate::discriminant::codegen_get_discriminant(fx, place, fx.layout_of(to_ty)); + let discr = crate::discriminant::codegen_get_discriminant(fx, operand, fx.layout_of(to_ty)); lval.write_cvalue(fx, discr); } else { let to_clif_ty = fx.clif_type(to_ty).unwrap(); @@ -405,7 +402,8 @@ fn trans_stmt<'a, 'tcx: 'a>( } Rvalue::Discriminant(place) => { let place = trans_place(fx, place); - let discr = crate::discriminant::codegen_get_discriminant(fx, place, dest_layout); + let value = place.to_cvalue(fx); + let discr = crate::discriminant::codegen_get_discriminant(fx, value, dest_layout); lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => { diff --git a/src/discriminant.rs b/src/discriminant.rs index 1a83b39fb09d9..674486076de72 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -58,10 +58,10 @@ pub fn codegen_set_discriminant<'tcx>( pub fn codegen_get_discriminant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - place: CPlace<'tcx>, + value: CValue<'tcx>, dest_layout: TyLayout<'tcx>, ) -> CValue<'tcx> { - let layout = place.layout(); + let layout = value.layout(); if layout.abi == layout::Abi::Uninhabited { return trap_unreachable_ret_value(fx, dest_layout, "[panic] Tried to get discriminant for uninhabited type."); @@ -82,7 +82,7 @@ pub fn codegen_get_discriminant<'tcx>( } }; - let discr = place.place_field(fx, mir::Field::new(discr_index)).to_cvalue(fx); + let discr = value.value_field(fx, mir::Field::new(discr_index)); let discr_ty = discr.layout().ty; let lldiscr = discr.load_scalar(fx); match discr_kind { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 2dfa45c9dfb07..580d79fb223cd 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -374,10 +374,10 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( fx.bcx.call_memmove(fx.module.target_config(), dst, src, byte_amount); } }; - discriminant_value, (c val) { - let pointee_layout = fx.layout_of(val.layout().ty.builtin_deref(true).unwrap().ty); - let place = CPlace::for_addr(val.load_scalar(fx), pointee_layout); - let discr = crate::discriminant::codegen_get_discriminant(fx, place, ret.layout()); + discriminant_value, (c ptr) { + let pointee_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); + let val = CValue::by_ref(ptr.load_scalar(fx), pointee_layout); + let discr = crate::discriminant::codegen_get_discriminant(fx, val, ret.layout()); ret.write_cvalue(fx, discr); }; size_of, () { From 2a20cc0b94a60447c159095676d5813dd508d894 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 16:52:07 +0200 Subject: [PATCH 0831/1566] Use anonymous lifetimes where possible --- src/abi.rs | 34 +++++++++++------------ src/analyze.rs | 2 +- src/base.rs | 28 +++++++++---------- src/cast.rs | 6 ++--- src/codegen_i128.rs | 4 +-- src/common.rs | 33 +++++++++++------------ src/constant.rs | 34 +++++++++++------------ src/debuginfo.rs | 2 +- src/driver.rs | 2 +- src/intrinsics.rs | 4 +-- src/lib.rs | 6 ++--- src/llvm_intrinsics.rs | 4 +-- src/num.rs | 20 +++++++------- src/pretty_clif.rs | 4 +-- src/unsize.rs | 16 +++++------ src/value_and_place.rs | 61 ++++++++++++++++-------------------------- src/vtable.rs | 24 ++++++++--------- 17 files changed, 134 insertions(+), 150 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 6e4edc4a15186..b0fd9a1d73ac4 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -133,8 +133,8 @@ fn get_pass_mode<'tcx>( } } -fn adjust_arg_for_abi<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn adjust_arg_for_abi<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, ) -> EmptySinglePair { match get_pass_mode(fx.tcx, arg.layout()) { @@ -250,7 +250,7 @@ pub fn import_function<'tcx>( .unwrap() } -impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { let func_id = import_function(self.tcx, self.module, inst); @@ -337,8 +337,8 @@ impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { } #[cfg(debug_assertions)] -fn add_arg_comment<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn add_arg_comment<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, msg: &str, local: mir::Local, local_field: Option, @@ -377,8 +377,8 @@ fn add_local_header_comment(fx: &mut FunctionCx) { )); } -fn local_place<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn local_place<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, layout: TyLayout<'tcx>, is_ssa: bool, @@ -432,8 +432,8 @@ fn local_place<'a, 'tcx: 'a>( fx.local_map[&local] } -fn cvalue_for_param<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn cvalue_for_param<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_ebb: Ebb, local: mir::Local, local_field: Option, @@ -473,8 +473,8 @@ fn cvalue_for_param<'a, 'tcx: 'a>( } } -pub fn codegen_fn_prelude<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn codegen_fn_prelude( + fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: Ebb, ) { let ssa_analyzed = crate::analyze::analyze(fx); @@ -622,8 +622,8 @@ pub fn codegen_fn_prelude<'a, 'tcx: 'a>( .jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); } -pub fn codegen_terminator_call<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn codegen_terminator_call<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, func: &Operand<'tcx>, args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, @@ -698,8 +698,8 @@ pub fn codegen_terminator_call<'a, 'tcx: 'a>( } } -fn codegen_call_inner<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn codegen_call_inner<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, func: Option<&Operand<'tcx>>, fn_ty: Ty<'tcx>, args: Vec>, @@ -827,8 +827,8 @@ fn codegen_call_inner<'a, 'tcx: 'a>( } } -pub fn codegen_drop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn codegen_drop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_place: CPlace<'tcx>, ) { let ty = drop_place.layout().ty; diff --git a/src/analyze.rs b/src/analyze.rs index 243c660368d3a..f4624221ca88c 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -8,7 +8,7 @@ bitflags::bitflags! { } } -pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap { +pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap { let mut flag_map = HashMap::new(); for local in fx.mir.local_decls.indices() { diff --git a/src/base.rs b/src/base.rs index 8064b83d72811..54db738031feb 100644 --- a/src/base.rs +++ b/src/base.rs @@ -2,7 +2,7 @@ use rustc::ty::adjustment::PointerCast; use crate::prelude::*; -pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( +pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( cx: &mut crate::CodegenCx<'clif, 'tcx, B>, instance: Instance<'tcx>, linkage: Linkage, @@ -48,7 +48,7 @@ pub fn trans_fn<'a, 'clif, 'tcx: 'a, B: Backend + 'static>( local_map: HashMap::new(), clif_comments, - constants: &mut cx.ccx, + constants_cx: &mut cx.constants_cx, caches: &mut cx.caches, source_info_set: indexmap::IndexSet::new(), }; @@ -110,7 +110,7 @@ fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &F } } -fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) { +fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { if bb_data.is_cleanup { // Unwinding after panicking is not supported @@ -222,8 +222,8 @@ fn codegen_fn_content<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) fx.bcx.finalize(); } -fn trans_stmt<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn trans_stmt<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, cur_ebb: Ebb, stmt: &Statement<'tcx>, ) { @@ -343,7 +343,7 @@ fn trans_stmt<'a, 'tcx: 'a>( let operand = trans_operand(fx, operand); let from_ty = operand.layout().ty; - fn is_fat_ptr<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, ty: Ty<'tcx>) -> bool { + fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>) -> bool { ty .builtin_deref(true) .map(|ty::TypeAndMut {ty: pointee_ty, mutbl: _ }| fx.layout_of(pointee_ty).is_unsized()) @@ -533,8 +533,8 @@ fn trans_stmt<'a, 'tcx: 'a>( } } -fn codegen_array_len<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn codegen_array_len<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: CPlace<'tcx>, ) -> Value { match place.layout().ty.sty { @@ -551,8 +551,8 @@ fn codegen_array_len<'a, 'tcx: 'a>( } } -pub fn trans_place<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_place<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: &Place<'tcx>, ) -> CPlace<'tcx> { let base = match &place.base { @@ -570,8 +570,8 @@ pub fn trans_place<'a, 'tcx: 'a>( trans_place_projection(fx, base, &place.projection) } -pub fn trans_place_projection<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_place_projection<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, base: CPlace<'tcx>, projection: &Option>>, ) -> CPlace<'tcx> { @@ -635,8 +635,8 @@ pub fn trans_place_projection<'a, 'tcx: 'a>( } } -pub fn trans_operand<'a, 'tcx>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_operand<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, operand: &Operand<'tcx>, ) -> CValue<'tcx> { match operand { diff --git a/src/cast.rs b/src/cast.rs index 39aa2c96d4d36..7e411438875b9 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -1,7 +1,7 @@ use crate::prelude::*; -pub fn clif_intcast<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn clif_intcast( + fx: &mut FunctionCx<'_, '_, impl Backend>, val: Value, to: Type, signed: bool, @@ -73,7 +73,7 @@ pub fn clif_int_or_float_cast( } else if from_ty.is_float() && to_ty.is_int() { // float -> int-like if to_ty == types::I8 || to_ty == types::I16 { - // FIXME implement fcbt_to_*int_sat.i8/i16 + // FIXME implement fcvt_to_*int_sat.i8/i16 let val = if to_signed { fx.bcx.ins().fcvt_to_sint_sat(types::I32, from) } else { diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index cfe5ce5918f74..d8632e2f4aa94 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -2,8 +2,8 @@ use crate::prelude::*; -pub fn maybe_codegen<'a, 'tcx>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn maybe_codegen<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, checked: bool, lhs: CValue<'tcx>, diff --git a/src/common.rs b/src/common.rs index bbfee005a6280..eb6f204a8d284 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,7 +1,6 @@ use rustc_target::spec::{HasTargetSpec, Target}; use cranelift::codegen::ir::{Opcode, InstructionData, ValueDef}; -use cranelift_module::Module; use crate::prelude::*; @@ -73,8 +72,8 @@ pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: V } } -pub fn codegen_icmp<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, +pub fn codegen_icmp( + fx: &mut FunctionCx<'_, '_, impl Backend>, intcc: IntCC, lhs: Value, rhs: Value, @@ -118,8 +117,8 @@ pub fn codegen_icmp<'tcx>( } } -pub fn codegen_icmp_imm<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, +pub fn codegen_icmp_imm( + fx: &mut FunctionCx<'_, '_, impl Backend>, intcc: IntCC, lhs: Value, rhs: i128, @@ -245,26 +244,26 @@ pub fn type_sign(ty: Ty<'_>) -> bool { } } -pub struct FunctionCx<'a, 'tcx: 'a, B: Backend> { +pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` pub tcx: TyCtxt<'tcx>, - pub module: &'a mut Module, + pub module: &'clif mut Module, pub pointer_type: Type, // Cached from module pub instance: Instance<'tcx>, pub mir: &'tcx Body<'tcx>, - pub bcx: FunctionBuilder<'a>, + pub bcx: FunctionBuilder<'clif>, pub ebb_map: HashMap, pub local_map: HashMap>, pub clif_comments: crate::pretty_clif::CommentWriter, - pub constants: &'a mut crate::constant::ConstantCx, - pub caches: &'a mut Caches<'tcx>, + pub constants_cx: &'clif mut crate::constant::ConstantCx, + pub caches: &'clif mut Caches<'tcx>, pub source_info_set: indexmap::IndexSet, } -impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { type Ty = Ty<'tcx>; type TyLayout = TyLayout<'tcx>; @@ -279,31 +278,31 @@ impl<'a, 'tcx: 'a, B: Backend> LayoutOf for FunctionCx<'a, 'tcx, B> { } } -impl<'a, 'tcx, B: Backend + 'a> layout::HasTyCtxt<'tcx> for FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend + 'static> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx, B> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } } -impl<'a, 'tcx, B: Backend + 'a> layout::HasDataLayout for FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend + 'static> layout::HasDataLayout for FunctionCx<'_, 'tcx, B> { fn data_layout(&self) -> &layout::TargetDataLayout { &self.tcx.data_layout } } -impl<'a, 'tcx, B: Backend + 'a> layout::HasParamEnv<'tcx> for FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend + 'static> layout::HasParamEnv<'tcx> for FunctionCx<'_, 'tcx, B> { fn param_env(&self) -> ParamEnv<'tcx> { ParamEnv::reveal_all() } } -impl<'a, 'tcx, B: Backend + 'a> HasTargetSpec for FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { fn target_spec(&self) -> &Target { &self.tcx.sess.target.target } } -impl<'a, 'tcx, B: Backend> BackendTypes for FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend> BackendTypes for FunctionCx<'_, 'tcx, B> { type Value = Value; type BasicBlock = Ebb; type Type = Type; @@ -311,7 +310,7 @@ impl<'a, 'tcx, B: Backend> BackendTypes for FunctionCx<'a, 'tcx, B> { type DIScope = !; } -impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { +impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx>, diff --git a/src/constant.rs b/src/constant.rs index 19529a79928b2..465ca06a2b612 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -38,12 +38,12 @@ impl ConstantCx { } } -pub fn codegen_static(ccx: &mut ConstantCx, def_id: DefId) { - ccx.todo.insert(TodoItem::Static(def_id)); +pub fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { + constants_cx.todo.insert(TodoItem::Static(def_id)); } -pub fn codegen_static_ref<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn codegen_static_ref<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, def_id: DefId, ty: Ty<'tcx>, ) -> CPlace<'tcx> { @@ -52,8 +52,8 @@ pub fn codegen_static_ref<'a, 'tcx: 'a>( cplace_for_dataid(fx, ty, data_id) } -pub fn trans_promoted<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_promoted<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, promoted: Promoted, dest_ty: Ty<'tcx>, ) -> CPlace<'tcx> { @@ -79,16 +79,16 @@ pub fn trans_promoted<'a, 'tcx: 'a>( } } -pub fn trans_constant<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_constant<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { let const_ = force_eval_const(fx, &constant.literal); trans_const_value(fx, const_) } -pub fn force_eval_const<'a, 'tcx: 'a>( - fx: &FunctionCx<'a, 'tcx, impl Backend>, +pub fn force_eval_const<'tcx>( + fx: &FunctionCx<'_, 'tcx, impl Backend>, const_: &'tcx Const, ) -> &'tcx Const<'tcx> { match const_.val { @@ -106,8 +106,8 @@ pub fn force_eval_const<'a, 'tcx: 'a>( } } -pub fn trans_const_value<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_const_value<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); @@ -131,8 +131,8 @@ pub fn trans_const_value<'a, 'tcx: 'a>( } } -fn trans_const_place<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn trans_const_place<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> CPlace<'tcx> { // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 @@ -168,7 +168,7 @@ fn trans_const_place<'a, 'tcx: 'a>( //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); - fx.constants.todo.insert(TodoItem::Alloc(alloc_id)); + fx.constants_cx.todo.insert(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); cplace_for_dataid(fx, const_.ty, data_id) } @@ -222,8 +222,8 @@ fn data_id_for_static( data_id } -fn cplace_for_dataid<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn cplace_for_dataid<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>, data_id: DataId, ) -> CPlace<'tcx> { diff --git a/src/debuginfo.rs b/src/debuginfo.rs index ab63d12594518..74cc58a0c431b 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -93,7 +93,7 @@ pub struct DebugContext<'tcx> { } impl<'tcx> DebugContext<'tcx> { - pub fn new(tcx: TyCtxt, address_size: u8) -> Self { + pub fn new(tcx: TyCtxt<'tcx>, address_size: u8) -> Self { let encoding = Encoding { format: Format::Dwarf32, // TODO: this should be configurable diff --git a/src/driver.rs b/src/driver.rs index 3c4ce99d98289..0662762e220cd 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -344,7 +344,7 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( crate::base::trans_fn(cx, inst, linkage); } MonoItem::Static(def_id) => { - crate::constant::codegen_static(&mut cx.ccx, def_id); + crate::constant::codegen_static(&mut cx.constants_cx, def_id); } MonoItem::GlobalAsm(node_id) => tcx .sess diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 580d79fb223cd..74d5e95091f43 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -275,8 +275,8 @@ macro_rules! simd_flt_binop { } } -pub fn codegen_intrinsic_call<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn codegen_intrinsic_call<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, def_id: DefId, substs: SubstsRef<'tcx>, args: &[mir::Operand<'tcx>], diff --git a/src/lib.rs b/src/lib.rs index d4f7219655536..21c7f3af2267f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -132,7 +132,7 @@ impl Default for Caches<'_> { pub struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { tcx: TyCtxt<'tcx>, module: &'clif mut Module, - ccx: ConstantCx, + constants_cx: ConstantCx, caches: Caches<'tcx>, debug_context: Option<&'clif mut DebugContext<'tcx>>, } @@ -146,14 +146,14 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { CodegenCx { tcx, module, - ccx: ConstantCx::default(), + constants_cx: ConstantCx::default(), caches: Caches::default(), debug_context, } } fn finalize(self) { - self.ccx.finalize(self.tcx, self.module); + self.constants_cx.finalize(self.tcx, self.module); } } diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index 284bdee52b8ce..ef5c9092c7018 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -3,8 +3,8 @@ use crate::intrinsics::*; use rustc::ty::subst::SubstsRef; -pub fn codegen_llvm_intrinsic_call<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn codegen_llvm_intrinsic_call<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, intrinsic: &str, substs: SubstsRef<'tcx>, args: &[mir::Operand<'tcx>], diff --git a/src/num.rs b/src/num.rs index 8d3bb01921805..ef1ab328be505 100644 --- a/src/num.rs +++ b/src/num.rs @@ -75,8 +75,8 @@ pub fn codegen_binop<'tcx>( } } -pub fn trans_bool_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_bool_binop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -96,8 +96,8 @@ pub fn trans_bool_binop<'a, 'tcx: 'a>( CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) } -pub fn trans_int_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_int_binop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -150,8 +150,8 @@ pub fn trans_int_binop<'a, 'tcx: 'a>( CValue::by_val(val, in_lhs.layout()) } -pub fn trans_checked_int_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_checked_int_binop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -246,8 +246,8 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>( out_place.to_cvalue(fx) } -pub fn trans_float_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_float_binop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -291,8 +291,8 @@ pub fn trans_float_binop<'a, 'tcx: 'a>( CValue::by_val(res, in_lhs.layout()) } -pub fn trans_ptr_binop<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn trans_ptr_binop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 4d05659a060e9..597789b1f0ba2 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -157,7 +157,7 @@ impl FuncWriter for &'_ CommentWriter { } #[cfg(debug_assertions)] -impl<'a, 'tcx: 'a, B: Backend + 'a> FunctionCx<'a, 'tcx, B> { +impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub fn add_global_comment>(&mut self, comment: S) { self.clif_comments.global_comments.push(comment.into()); } @@ -239,7 +239,7 @@ pub fn write_clif_file<'tcx>( } } -impl<'a, 'tcx: 'a, B: Backend + 'a> fmt::Debug for FunctionCx<'a, 'tcx, B> { +impl<'a, 'tcx, B: Backend + 'static> fmt::Debug for FunctionCx<'_, 'tcx, B> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f, "{:?}", self.instance.substs)?; writeln!(f, "{:?}", self.local_map)?; diff --git a/src/unsize.rs b/src/unsize.rs index 644ca6bc3697a..c692f0c88aa5f 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -8,8 +8,8 @@ use crate::prelude::*; /// The `old_info` argument is a bit funny. It is intended for use /// in an upcast, where the new vtable for an object will be derived /// from the old one. -pub fn unsized_info<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn unsized_info<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, source: Ty<'tcx>, target: Ty<'tcx>, old_info: Option, @@ -40,8 +40,8 @@ pub fn unsized_info<'a, 'tcx: 'a>( } /// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer. -pub fn unsize_thin_ptr<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn unsize_thin_ptr<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, src: Value, src_ty: Ty<'tcx>, dst_ty: Ty<'tcx>, @@ -86,8 +86,8 @@ pub fn unsize_thin_ptr<'a, 'tcx: 'a>( /// Coerce `src`, which is a reference to a value of type `src_ty`, /// to a value of type `dst_ty` and store the result in `dst` -pub fn coerce_unsized_into<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn coerce_unsized_into<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, src: CValue<'tcx>, dst: CPlace<'tcx>, ) { @@ -139,8 +139,8 @@ pub fn coerce_unsized_into<'a, 'tcx: 'a>( // Adapted from https://github.com/rust-lang/rust/blob/2a663555ddf36f6b041445894a8c175cd1bc718c/src/librustc_codegen_ssa/glue.rs -pub fn size_and_align_of_dst<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn size_and_align_of_dst<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>, info: Value, ) -> (Value, Value) { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index a8b3a2954381f..f018ed0a2babe 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -1,7 +1,7 @@ use crate::prelude::*; -fn codegen_field<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn codegen_field<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, base: Value, layout: TyLayout<'tcx>, field: mir::Field, @@ -51,10 +51,7 @@ impl<'tcx> CValue<'tcx> { self.1 } - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value - where - 'tcx: 'a, - { + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; match self.0 { CValueInner::ByRef(value) => value, @@ -67,10 +64,7 @@ impl<'tcx> CValue<'tcx> { } /// Load a value with layout.abi of scalar - pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value - where - 'tcx: 'a, - { + pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; match self.0 { CValueInner::ByRef(addr) => { @@ -87,10 +81,7 @@ impl<'tcx> CValue<'tcx> { } /// Load a value pair with layout.abi of scalar pair - pub fn load_scalar_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> (Value, Value) - where - 'tcx: 'a, - { + pub fn load_scalar_pair<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Value, Value) { let layout = self.1; match self.0 { CValueInner::ByRef(addr) => { @@ -117,12 +108,9 @@ impl<'tcx> CValue<'tcx> { pub fn value_field<'a>( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, - ) -> CValue<'tcx> - where - 'tcx: 'a, - { + ) -> CValue<'tcx> { let layout = self.1; let base = match self.0 { CValueInner::ByRef(addr) => addr, @@ -133,19 +121,16 @@ impl<'tcx> CValue<'tcx> { CValue::by_ref(field_ptr, field_layout) } - pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { crate::unsize::coerce_unsized_into(fx, self, dest); } /// If `ty` is signed, `const_val` must already be sign extended. pub fn const_val<'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>, const_val: u128, - ) -> CValue<'tcx> - where - 'tcx: 'a, - { + ) -> CValue<'tcx> { let clif_ty = fx.clif_type(ty).unwrap(); let layout = fx.layout_of(ty); @@ -185,7 +170,7 @@ pub enum CPlace<'tcx> { NoPlace(TyLayout<'tcx>), } -impl<'a, 'tcx: 'a> CPlace<'tcx> { +impl<'tcx> CPlace<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { match *self { CPlace::Var(_, layout) @@ -200,7 +185,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } pub fn new_stack_slot( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>, ) -> CPlace<'tcx> { let layout = fx.layout_of(ty); @@ -218,7 +203,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } pub fn new_var( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, layout: TyLayout<'tcx>, ) -> CPlace<'tcx> { @@ -235,7 +220,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(addr, Some(extra), layout) } - pub fn to_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CValue<'tcx> { + pub fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> { match self { CPlace::Var(var, layout) => CValue::by_val(fx.bcx.use_var(mir_var(var)), layout), CPlace::Addr(addr, extra, layout) => { @@ -255,7 +240,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn to_addr(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { + pub fn to_addr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { match self.to_addr_maybe_unsized(fx) { (addr, None) => addr, (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), @@ -264,7 +249,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn to_addr_maybe_unsized( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ) -> (Value, Option) { match self { CPlace::Addr(addr, extra, _layout) => (addr, extra), @@ -277,13 +262,13 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn write_cvalue(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, from: CValue<'tcx>) { + pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { use rustc::hir::Mutability::*; let from_ty = from.layout().ty; let to_ty = self.layout().ty; - fn assert_assignable<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { + fn assert_assignable<'tcx>(fx: &FunctionCx<'_, 'tcx, impl Backend>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { match (&from_ty.sty, &to_ty.sty) { (ty::Ref(_, t, MutImmutable), ty::Ref(_, u, MutImmutable)) | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutImmutable)) @@ -403,7 +388,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn place_field( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, ) -> CPlace<'tcx> { let layout = self.layout(); @@ -421,7 +406,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn place_index( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, index: Value, ) -> CPlace<'tcx> { let (elem_layout, addr) = match self.layout().ty.sty { @@ -438,7 +423,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) } - pub fn place_deref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> CPlace<'tcx> { + pub fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); if !inner_layout.is_unsized() { CPlace::Addr(self.to_cvalue(fx).load_scalar(fx), None, inner_layout) @@ -448,7 +433,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { } } - pub fn write_place_ref(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + pub fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if !self.layout().is_unsized() { let ptr = CValue::by_val(self.to_addr(fx), dest.layout()); dest.write_cvalue(fx, ptr); @@ -474,7 +459,7 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> { pub fn downcast_variant( self, - fx: &FunctionCx<'a, 'tcx, impl Backend>, + fx: &FunctionCx<'_, 'tcx, impl Backend>, variant: VariantIdx, ) -> Self { let layout = self.layout().for_variant(fx, variant); diff --git a/src/vtable.rs b/src/vtable.rs index d89f16ded0d7e..fc601130710bf 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -6,8 +6,8 @@ const DROP_FN_INDEX: usize = 0; const SIZE_INDEX: usize = 1; const ALIGN_INDEX: usize = 2; -pub fn drop_fn_of_obj<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn drop_fn_of_obj( + fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value, ) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; @@ -19,8 +19,8 @@ pub fn drop_fn_of_obj<'a, 'tcx: 'a>( ) } -pub fn size_of_obj<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn size_of_obj( + fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value, ) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; @@ -32,8 +32,8 @@ pub fn size_of_obj<'a, 'tcx: 'a>( ) } -pub fn min_align_of_obj<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn min_align_of_obj( + fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value, ) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; @@ -45,8 +45,8 @@ pub fn min_align_of_obj<'a, 'tcx: 'a>( ) } -pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn get_ptr_and_method_ref<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, idx: usize, ) -> (Value, Value) { @@ -61,8 +61,8 @@ pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>( (ptr, func_ref) } -pub fn get_vtable<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +pub fn get_vtable<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>, trait_ref: Option>, ) -> Value { @@ -78,8 +78,8 @@ pub fn get_vtable<'a, 'tcx: 'a>( fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } -fn build_vtable<'a, 'tcx: 'a>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, +fn build_vtable<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>, trait_ref: Option>, ) -> DataId { From ce860e5fdebd626d025d94d53629264923e441d8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Aug 2019 15:36:03 +0200 Subject: [PATCH 0832/1566] Fix cross crate static duplicate codegen --- example/mini_core.rs | 2 ++ example/mini_core_hello_world.rs | 3 +++ src/constant.rs | 8 +++++++- test.sh | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 78b493e0515c3..a271cb6e62ef9 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -529,3 +529,5 @@ pub macro line() { /* compiler built-in */ } #[rustc_builtin_macro] #[rustc_macro_transparency = "semitransparent"] pub macro cfg() { /* compiler built-in */ } + +pub static A_STATIC: u8 = 42; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 56a799be2fb11..955530c7f919e 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -261,4 +261,7 @@ fn main() { let f2 = -1000.0; assert_eq!(f2 as i8, -128); assert_eq!(f2 as u8, 0); + + static ANOTHER_STATIC: &u8 = &A_STATIC; + assert_eq!(*ANOTHER_STATIC, 42); } diff --git a/src/constant.rs b/src/constant.rs index 465ca06a2b612..f035d8b9e060f 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -297,6 +297,10 @@ fn define_all_allocs( read_target_uint(endianness, bytes).unwrap() }; + // Don't inline `reloc_target_alloc` into the match. That would cause `tcx.alloc_map` + // to be locked for the duration of the match. `data_id_for_static` however may try + // to lock `tcx.alloc_map` itself while calculating the layout of the target static. + // This would cause a panic in single threaded rustc and a deadlock for parallel rustc. let reloc_target_alloc = tcx.alloc_map.lock().get(reloc).unwrap(); let data_id = match reloc_target_alloc { GlobalAlloc::Function(instance) => { @@ -311,7 +315,9 @@ fn define_all_allocs( data_id_for_alloc_id(module, reloc, alloc.align) } GlobalAlloc::Static(def_id) => { - cx.todo.insert(TodoItem::Static(def_id)); + // Don't push a `TodoItem::Static` here, as it will cause statics used by + // multiple crates to be duplicated between them. It isn't necessary anyway, + // as it will get pushed by `codegen_static` when necessary. let linkage = crate::linkage::get_static_ref_linkage(tcx, def_id); data_id_for_static(tcx, module, def_id, linkage) } diff --git a/test.sh b/test.sh index 997c4da753834..b961069e541a5 100755 --- a/test.sh +++ b/test.sh @@ -26,7 +26,7 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type dylib +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib From edbb5730ea966be9d810a3ec46db8245dce51b4e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Aug 2019 15:48:32 +0200 Subject: [PATCH 0833/1566] Implement copysign{f32,f64} intrinsics --- example/std_example.rs | 1 + src/intrinsics.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index 61182a49b9cce..2aa2235d7bd72 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -35,6 +35,7 @@ fn main() { println!("{}", 2.3f32.max(1.0)); println!("{}", 2.3f32.powi(2)); println!("{}", 2.3f32.log2()); + assert_eq!(2.3f32.copysign(-1.0), -2.3f32); assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 74d5e95091f43..1c14278866c08 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -326,8 +326,11 @@ pub fn codegen_intrinsic_call<'tcx>( fabsf64(flt) -> f64 => fabs, fmaf32(x, y, z) -> f32 => fmaf, fmaf64(x, y, z) -> f64 => fma, + copysignf32(x, y) -> f32 => copysignf, + copysignf64(x, y) -> f64 => copysign, // rounding variants + // FIXME use clif insts floorf32(flt) -> f32 => floorf, floorf64(flt) -> f64 => floor, ceilf32(flt) -> f32 => ceilf, From 0e35e4ea1907e4de9527f6c4cd7bf41ac4c8dae2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Aug 2019 16:24:08 +0200 Subject: [PATCH 0834/1566] Set correct linkage for statics --- src/constant.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index f035d8b9e060f..960097f2d1372 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -268,8 +268,11 @@ fn define_all_allocs( _ => bug!("static const eval returned {:#?}", const_), }; - // FIXME set correct linkage - let data_id = data_id_for_static(tcx, module, def_id, Linkage::Export); + let data_id = data_id_for_static(tcx, module, def_id, if tcx.is_reachable_non_generic(def_id) { + Linkage::Export + } else { + Linkage::Local + }); (data_id, alloc) } }; From 4a8bb164c678ad6bc98ad7360bf04cd7c336840b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Aug 2019 16:24:57 +0200 Subject: [PATCH 0835/1566] Don't pass -Zalways-encode-mir to rustc --- config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.sh b/config.sh index 9bfff744a66f8..43280c091419a 100644 --- a/config.sh +++ b/config.sh @@ -12,7 +12,7 @@ fi TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") -export RUSTFLAGS='-Zalways-encode-mir -Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors From ae428a2d702fe9a8ae7993b720c59d184a9d239c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Aug 2019 16:42:56 +0200 Subject: [PATCH 0836/1566] Fix saturating_{add,sub} for 8bit and 16bit ints --- src/intrinsics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 1c14278866c08..c12730da7585d 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -513,8 +513,8 @@ pub fn codegen_intrinsic_call<'tcx>( let max = fx.bcx.ins().iconst(clif_ty, max); let val = match (intrinsic, signed) { - ("saturating_add", false) => fx.bcx.ins().select(has_overflow, max, val), - ("saturating_sub", false) => fx.bcx.ins().select(has_overflow, min, val), + ("saturating_add", false) => codegen_select(&mut fx.bcx, has_overflow, max, val), + ("saturating_sub", false) => codegen_select(&mut fx.bcx, has_overflow, min, val), ("saturating_add", true) => unimplemented!(), ("saturating_sub", true) => unimplemented!(), _ => unreachable!(), From 95908f61a0c4e0cb874f5fbb882399a82003ae51 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Aug 2019 16:43:25 +0200 Subject: [PATCH 0837/1566] Add unimpl! for cast between 128bit int and float --- src/cast.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cast.rs b/src/cast.rs index 7e411438875b9..ddfe91966ddad 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -64,6 +64,10 @@ pub fn clif_int_or_float_cast( from_signed, // FIXME is this correct? ) } else if from_ty.is_int() && to_ty.is_float() { + if from_ty == types::I128 { + unimpl!("u/i128 -> float"); + } + // int-like -> float if from_signed { fx.bcx.ins().fcvt_from_sint(to_ty, from) @@ -71,6 +75,10 @@ pub fn clif_int_or_float_cast( fx.bcx.ins().fcvt_from_uint(to_ty, from) } } else if from_ty.is_float() && to_ty.is_int() { + if to_ty == types::I128 { + unimpl!("float -> u/i128"); + } + // float -> int-like if to_ty == types::I8 || to_ty == types::I16 { // FIXME implement fcvt_to_*int_sat.i8/i16 From f99d31dbfedd10ed3bb66bea1184065bd841f44c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 19 Aug 2019 17:16:21 +0200 Subject: [PATCH 0838/1566] Implement pow{f32,f64} intrinsics --- example/std_example.rs | 1 + src/intrinsics.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index 2aa2235d7bd72..f16ff592d4cfd 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -36,6 +36,7 @@ fn main() { println!("{}", 2.3f32.powi(2)); println!("{}", 2.3f32.log2()); assert_eq!(2.3f32.copysign(-1.0), -2.3f32); + println!("{}", 2.3f32.powf(2.0)); assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index c12730da7585d..e09dc25f4abff 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -318,6 +318,8 @@ pub fn codegen_intrinsic_call<'tcx>( sqrtf64(flt) -> f64 => sqrt, powif32(a, x) -> f32 => __powisf2, // compiler-builtins powif64(a, x) -> f64 => __powidf2, // compiler-builtins + powf32(a, x) -> f32 => powf, + powf64(a, x) -> f64 => pow, logf32(flt) -> f32 => logf, logf64(flt) -> f64 => log, log2f32(flt) -> f32 => log2f, From 3fcd54088c71cf64d723fe928f3da188f6d9952e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 20 Aug 2019 10:40:08 +0200 Subject: [PATCH 0839/1566] Implement saturating_{add,sub} intrinsics --- example/std_example.rs | 5 +++++ src/intrinsics.rs | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index f16ff592d4cfd..26289818896e3 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -38,6 +38,11 @@ fn main() { assert_eq!(2.3f32.copysign(-1.0), -2.3f32); println!("{}", 2.3f32.powf(2.0)); + assert_eq!(-128i8, (-128i8).saturating_sub(1)); + assert_eq!(127i8, 127i8.saturating_sub(-128)); + assert_eq!(-128i8, (-128i8).saturating_add(-128)); + assert_eq!(127i8, 127i8.saturating_add(1)); + assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index e09dc25f4abff..2cec9c57143f9 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -487,8 +487,8 @@ pub fn codegen_intrinsic_call<'tcx>( ); ret.write_cvalue(fx, res); }; - _ if intrinsic.starts_with("saturating_"), (c x, c y) { - assert_eq!(x.layout().ty, y.layout().ty); + _ if intrinsic.starts_with("saturating_"), (c lhs, c rhs) { + assert_eq!(lhs.layout().ty, rhs.layout().ty); let bin_op = match intrinsic { "saturating_add" => BinOp::Add, "saturating_sub" => BinOp::Sub, @@ -500,8 +500,8 @@ pub fn codegen_intrinsic_call<'tcx>( let checked_res = crate::num::trans_checked_int_binop( fx, bin_op, - x, - y, + lhs, + rhs, ); let (val, has_overflow) = checked_res.load_scalar_pair(fx); @@ -517,8 +517,18 @@ pub fn codegen_intrinsic_call<'tcx>( let val = match (intrinsic, signed) { ("saturating_add", false) => codegen_select(&mut fx.bcx, has_overflow, max, val), ("saturating_sub", false) => codegen_select(&mut fx.bcx, has_overflow, min, val), - ("saturating_add", true) => unimplemented!(), - ("saturating_sub", true) => unimplemented!(), + ("saturating_add", true) => { + let rhs = rhs.load_scalar(fx); + let rhs_ge_zero = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThanOrEqual, rhs, 0); + let sat_val = codegen_select(&mut fx.bcx, rhs_ge_zero, max, min); + codegen_select(&mut fx.bcx, has_overflow, sat_val, val) + } + ("saturating_sub", true) => { + let rhs = rhs.load_scalar(fx); + let rhs_ge_zero = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThanOrEqual, rhs, 0); + let sat_val = codegen_select(&mut fx.bcx, rhs_ge_zero, min, max); + codegen_select(&mut fx.bcx, has_overflow, sat_val, val) + } _ => unreachable!(), }; From b2d6705fe2e7eb51e3d3cf7421da8513ad1e948e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 21 Aug 2019 14:01:29 +0200 Subject: [PATCH 0840/1566] Implement u/i128 <-> float casts Fixes #668 --- example/std_example.rs | 11 +++++++++++ src/cast.rs | 43 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 26289818896e3..14a9a567d42b0 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -55,6 +55,17 @@ fn main() { assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128); assert_eq!(353985398u128 * 932490u128, 330087843781020u128); + // Check that all u/i128 <-> float casts work correctly. + assert_eq!(100u128 as f32, 100.0); + assert_eq!(100u128 as f64, 100.0); + assert_eq!(100.0f32 as u128, 100); + assert_eq!(100.0f64 as u128, 100); + assert_eq!(100i128 as f32, 100.0); + assert_eq!(100i128 as f64, 100.0); + assert_eq!(100.0f32 as i128, 100); + assert_eq!(100.0f64 as i128, 100); + + let _a = 1u32 << 2u8; unsafe { diff --git a/src/cast.rs b/src/cast.rs index ddfe91966ddad..5e038543771a1 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -55,6 +55,17 @@ pub fn clif_int_or_float_cast( ) -> Value { let from_ty = fx.bcx.func.dfg.value_type(from); + macro call_float_cvt_intrinsic($fmt:literal, $sign_name:literal, $from_ty:expr, $to_ty:expr) { + let intrinsic_sign_name = if from_signed { "" } else { $sign_name }; + let intrinsic_float_name = match to_ty { + types::F32 => "s", + types::F64 => "d", + _ => unreachable!("{:?}", to_ty), + }; + let intrinsic_name = format!($fmt, sign=intrinsic_sign_name, flt=intrinsic_float_name); + return fx.easy_call(&intrinsic_name, &[CValue::by_val(from, fx.layout_of($from_ty))], $to_ty).load_scalar(fx); + } + if from_ty.is_int() && to_ty.is_int() { // int-like -> int-like clif_intcast( @@ -65,7 +76,21 @@ pub fn clif_int_or_float_cast( ) } else if from_ty.is_int() && to_ty.is_float() { if from_ty == types::I128 { - unimpl!("u/i128 -> float"); + // _______ss__f_ + // __float tisf: i128 -> f32 + // __float tidf: i128 -> f64 + // __floatuntisf: u128 -> f32 + // __floatuntidf: u128 -> f64 + call_float_cvt_intrinsic!("__float{sign}ti{flt}f", "un", if from_signed { + fx.tcx.types.i128 + } else { + fx.tcx.types.u128 + }, + match to_ty { + types::F32 => fx.tcx.types.f32, + types::F64 => fx.tcx.types.f64, + _ => unreachable!(), + }); } // int-like -> float @@ -76,7 +101,21 @@ pub fn clif_int_or_float_cast( } } else if from_ty.is_float() && to_ty.is_int() { if to_ty == types::I128 { - unimpl!("float -> u/i128"); + // _____sssf___ + // __fix sfti: f32 -> i128 + // __fix dfti: f64 -> i128 + // __fixunssfti: f32 -> u128 + // __fixunsdfti: f64 -> u128 + call_float_cvt_intrinsic!("__fix{sign}{flt}fti", "uns", match from_ty { + types::F32 => fx.tcx.types.f32, + types::F64 => fx.tcx.types.f64, + _ => unreachable!(), + }, + if to_signed { + fx.tcx.types.i128 + } else { + fx.tcx.types.u128 + }); } // float -> int-like From 1f90b04cd6cd492260a5e4230da6128037b5461b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 21 Aug 2019 14:35:48 +0200 Subject: [PATCH 0841/1566] Fix float -> u/i128 cast The original test casts were optimized away by rustc, so cg_clif never saw them. cc #668 --- example/std_example.rs | 21 +++++++------ src/cast.rs | 69 ++++++++++++++++++++++++++++++------------ 2 files changed, 62 insertions(+), 28 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 14a9a567d42b0..71b2a34b61d56 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -56,15 +56,18 @@ fn main() { assert_eq!(353985398u128 * 932490u128, 330087843781020u128); // Check that all u/i128 <-> float casts work correctly. - assert_eq!(100u128 as f32, 100.0); - assert_eq!(100u128 as f64, 100.0); - assert_eq!(100.0f32 as u128, 100); - assert_eq!(100.0f64 as u128, 100); - assert_eq!(100i128 as f32, 100.0); - assert_eq!(100i128 as f64, 100.0); - assert_eq!(100.0f32 as i128, 100); - assert_eq!(100.0f64 as i128, 100); - + let houndred_u128 = 100u128; + let houndred_i128 = 100i128; + let houndred_f32 = 100.0f32; + let houndred_f64 = 100.0f64; + assert_eq!(houndred_u128 as f32, 100.0); + assert_eq!(houndred_u128 as f64, 100.0); + assert_eq!(houndred_f32 as u128, 100); + assert_eq!(houndred_f64 as u128, 100); + assert_eq!(houndred_i128 as f32, 100.0); + assert_eq!(houndred_i128 as f64, 100.0); + assert_eq!(houndred_f32 as i128, 100); + assert_eq!(houndred_f64 as i128, 100); let _a = 1u32 << 2u8; diff --git a/src/cast.rs b/src/cast.rs index 5e038543771a1..1285bf8c00cab 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -55,17 +55,6 @@ pub fn clif_int_or_float_cast( ) -> Value { let from_ty = fx.bcx.func.dfg.value_type(from); - macro call_float_cvt_intrinsic($fmt:literal, $sign_name:literal, $from_ty:expr, $to_ty:expr) { - let intrinsic_sign_name = if from_signed { "" } else { $sign_name }; - let intrinsic_float_name = match to_ty { - types::F32 => "s", - types::F64 => "d", - _ => unreachable!("{:?}", to_ty), - }; - let intrinsic_name = format!($fmt, sign=intrinsic_sign_name, flt=intrinsic_float_name); - return fx.easy_call(&intrinsic_name, &[CValue::by_val(from, fx.layout_of($from_ty))], $to_ty).load_scalar(fx); - } - if from_ty.is_int() && to_ty.is_int() { // int-like -> int-like clif_intcast( @@ -81,16 +70,37 @@ pub fn clif_int_or_float_cast( // __float tidf: i128 -> f64 // __floatuntisf: u128 -> f32 // __floatuntidf: u128 -> f64 - call_float_cvt_intrinsic!("__float{sign}ti{flt}f", "un", if from_signed { + + let name = format!("__float{sign}ti{flt}f", + sign=if from_signed { + "" + } else { + "un" + }, + flt=match to_ty { + types::F32 => "s", + types::F64 => "d", + _ => unreachable!("{:?}", to_ty), + }, + ); + + let from_rust_ty = if from_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 - }, - match to_ty { + }; + + let to_rust_ty = match to_ty { types::F32 => fx.tcx.types.f32, types::F64 => fx.tcx.types.f64, _ => unreachable!(), - }); + }; + + return fx.easy_call( + &name, + &[CValue::by_val(from, fx.layout_of(from_rust_ty))], + to_rust_ty, + ).load_scalar(fx); } // int-like -> float @@ -106,16 +116,37 @@ pub fn clif_int_or_float_cast( // __fix dfti: f64 -> i128 // __fixunssfti: f32 -> u128 // __fixunsdfti: f64 -> u128 - call_float_cvt_intrinsic!("__fix{sign}{flt}fti", "uns", match from_ty { + + let name = format!("__fix{sign}{flt}fti", + sign=if to_signed { + "" + } else { + "uns" + }, + flt=match from_ty { + types::F32 => "s", + types::F64 => "d", + _ => unreachable!("{:?}", to_ty), + }, + ); + + let from_rust_ty = match from_ty { types::F32 => fx.tcx.types.f32, types::F64 => fx.tcx.types.f64, _ => unreachable!(), - }, - if to_signed { + }; + + let to_rust_ty = if to_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 - }); + }; + + return fx.easy_call( + &name, + &[CValue::by_val(from, fx.layout_of(from_rust_ty))], + to_rust_ty, + ).load_scalar(fx); } // float -> int-like From e64da833c9e9d04d751f086fa1438e515d467658 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 18 Aug 2019 17:46:45 +0200 Subject: [PATCH 0842/1566] Add patch for rustc regression Filled as 63687 --- patches/0019-Workaround-rust-regression.patch | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 patches/0019-Workaround-rust-regression.patch diff --git a/patches/0019-Workaround-rust-regression.patch b/patches/0019-Workaround-rust-regression.patch new file mode 100644 index 0000000000000..524af0b39a62e --- /dev/null +++ b/patches/0019-Workaround-rust-regression.patch @@ -0,0 +1,23 @@ +From 8956b4fa10af0df2f8912f6116aa1e970dc0283a Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sun, 18 Aug 2019 17:44:47 +0200 +Subject: [PATCH] Workaround rust regression + +--- + src/liballoc/macros.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs +index 0b5e186..250c419 100644 +--- a/src/liballoc/macros.rs ++++ b/src/liballoc/macros.rs +@@ -98,5 +98,5 @@ macro_rules! vec { + #[macro_export] + #[stable(feature = "rust1", since = "1.0.0")] + macro_rules! format { +- ($($arg:tt)*) => ($crate::fmt::format(::core::format_args!($($arg)*))) ++ ($($arg:tt)*) => ($crate::fmt::format(format_args!($($arg)*))) + } +-- +2.20.1 (Apple Git-117) + From bb634f3c886673ca7785c9c9bf72cec5c3258641 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 21 Aug 2019 14:57:12 +0200 Subject: [PATCH 0843/1566] Always use Linkage::Import for relocations targeting a static --- src/constant.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 960097f2d1372..d1e09cb523997 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -321,8 +321,7 @@ fn define_all_allocs( // Don't push a `TodoItem::Static` here, as it will cause statics used by // multiple crates to be duplicated between them. It isn't necessary anyway, // as it will get pushed by `codegen_static` when necessary. - let linkage = crate::linkage::get_static_ref_linkage(tcx, def_id); - data_id_for_static(tcx, module, def_id, linkage) + data_id_for_static(tcx, module, def_id, Linkage::Import) } }; From 02b68aa74787eabaf98bf9dc6b909cfae7b8f488 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 22 Aug 2019 12:37:24 +0200 Subject: [PATCH 0844/1566] Update dependencies The faerie update fixes macOS build (m4b/faerie#90) --- Cargo.lock | 294 ++++++++--------------------------------------------- Cargo.toml | 3 +- 2 files changed, 46 insertions(+), 251 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e88f150ccc88..744fe5c2fb174 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,22 +5,6 @@ name = "adler32" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "aho-corasick" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ansi_term" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ar" version = "0.7.0" @@ -37,15 +21,6 @@ dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "atty" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "backtrace" version = "0.3.34" @@ -53,8 +28,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -62,8 +37,8 @@ name = "backtrace-sys" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -87,7 +62,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -95,20 +70,6 @@ name = "cfg-if" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "clap" -version = "2.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cranelift" version = "0.36.0" @@ -160,7 +121,7 @@ source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_cli dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", + "faerie 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -206,7 +167,7 @@ dependencies = [ "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-native 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -220,25 +181,13 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "env_logger" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "errno" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -248,23 +197,20 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "faerie" -version = "0.10.1" -source = "git+https://github.com/m4b/faerie.git#926b3765b8f3751fb17f26321626b41b30b894e2" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -295,13 +241,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "flate2" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -311,11 +257,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -360,22 +307,6 @@ dependencies = [ "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "humantime" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "indexmap" version = "1.0.2" @@ -393,7 +324,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.60" +version = "0.2.62" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -401,7 +332,7 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -418,21 +349,16 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "memchr" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -443,17 +369,6 @@ dependencies = [ "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "miniz_oxide_c_api" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nodrop" version = "0.1.13" @@ -464,7 +379,7 @@ name = "object" version = "0.12.0" source = "git+https://github.com/gimli-rs/object.git#79ce87e3fd25ef385326655c5ad151e03d456b0a" dependencies = [ - "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)", "parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -495,11 +410,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "quick-error" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "quote" version = "0.6.13" @@ -513,8 +423,8 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -534,7 +444,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -551,7 +461,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -560,29 +470,13 @@ name = "redox_syscall" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "regex" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "regex-syntax" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "region" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -597,7 +491,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -611,10 +505,10 @@ dependencies = [ "cranelift-faerie 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-simplejit 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "faerie 0.10.1 (git+https://github.com/m4b/faerie.git)", + "faerie 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -668,7 +562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -678,7 +572,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -691,32 +585,7 @@ name = "string-interner" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "structopt" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "structopt-derive" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -756,47 +625,13 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "termcolor" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-segmentation" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-width" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicode-xid" version = "0.1.0" @@ -808,8 +643,8 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "vec_map" -version = "0.8.1" +name = "wasi" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -826,43 +661,22 @@ name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "winapi-util" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "wincolor" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [metadata] "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" -"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ce400c638d48ee0e9ab75aef7997609ec57367ccfe1463f21bf53c3eca67bf46" +"checksum cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "b548a4ee81fccb95919d4e22cfea83c7693ebfd78f0495493178db20b3139da7" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" -"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum cranelift 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" "checksum cranelift-bforest 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" "checksum cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" @@ -874,40 +688,34 @@ dependencies = [ "checksum cranelift-native 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" "checksum cranelift-simplejit 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.10.1 (git+https://github.com/m4b/faerie.git)" = "" +"checksum faerie 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1d2467155f3071b96447d53af110805cadbe9162f5be6c300792fb76c0e54051" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -"checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" +"checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" +"checksum getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6171a6cc63fbabbe27c2b5ee268e8b7fe5dc1eb0dd2dfad537c1dfed6f69117e" "checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)" = "" "checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" "checksum goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ac56b4753b6b8c2e052ca30717e5a09acf1b02a2c1681bf3d883bd660e5d22bd" -"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -"checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d44e80633f007889c7eff624b709ab43c92d708caad982295768a7b13ca3b5eb" +"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" -"checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum object 0.12.0 (git+https://github.com/gimli-rs/object.git)" = "" "checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" @@ -915,38 +723,26 @@ dependencies = [ "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" -"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" -"checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" +"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" +"checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" -"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "16c2cdbf9cc375f15d1b4141bc48aeef444806655cd0e904207edc8d68d86ed7" -"checksum structopt-derive 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "53010261a84b37689f9ed7d395165029f9cc7abb9f56bbfe86bee2597ed25107" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" -"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" -"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd5442abcac6525a045cc8c795aedb60da7a2e5e89c7bf18a0d5357849bb23c7" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" diff --git a/Cargo.toml b/Cargo.toml index ab95a278c0e6f..db374d616ed8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.4.0" -faerie = "0.10.0" +faerie = "0.10.2" #goblin = "0.0.17" ar = "0.7.0" @@ -48,7 +48,6 @@ cranelift-faerie = { git = "https://github.com/bjorn3/cretonne.git", branch = "d cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } [patch.crates-io] -faerie = { git = "https://github.com/m4b/faerie.git" } object = { git = "https://github.com/gimli-rs/object.git" } [profile.dev.overrides."*"] From f6c39fa701f42b9fd266261aec967e2eb6d2a70d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 25 Aug 2019 16:30:36 +0200 Subject: [PATCH 0845/1566] Rustup to rustc 1.39.0-nightly (eeba189cf 2019-08-24) --- build_sysroot/Cargo.toml | 4 +- build_sysroot/build_sysroot.sh | 11 ----- .../rustc-std-workspace-alloc/Cargo.toml | 15 ------- .../rustc-std-workspace-alloc/lib.rs | 5 --- ...0-libtest-Don-t-require-panic_unwind.patch | 41 +++++++++++++++++++ 5 files changed, 44 insertions(+), 32 deletions(-) delete mode 100644 build_sysroot/rustc-std-workspace-alloc/Cargo.toml delete mode 100644 build_sysroot/rustc-std-workspace-alloc/lib.rs create mode 100644 patches/0020-libtest-Don-t-require-panic_unwind.patch diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index c5bf0705c1933..1039f4613efc3 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -8,12 +8,14 @@ core = { path = "./sysroot_src/src/libcore" } compiler_builtins = "0.1" alloc = { path = "./sysroot_src/src/liballoc" } std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind"] } +test = { path = "./sysroot_src/src/libtest" } alloc_system = { path = "./alloc_system" } [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } -rustc-std-workspace-alloc = { path = "./rustc-std-workspace-alloc" } +rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" } +rustc-std-workspace-std = { path = "./sysroot_src/src/tools/rustc-std-workspace-std" } [profile.dev] # FIXME On macOS statics and promoted constants have the wrong alignment. This causes a debug diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 37aa7c1908d9c..26f6607b2aa80 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -29,14 +29,3 @@ fi # Copy files to sysroot mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ - -if [[ "$1" == "--release" ]]; then - channel='release' - RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release --manifest-path ./sysroot_src/src/libtest/Cargo.toml -else - channel='debug' - cargo build --target $TARGET_TRIPLE --manifest-path ./sysroot_src/src/libtest/Cargo.toml -fi - -# Copy files to sysroot -cp -r sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/ diff --git a/build_sysroot/rustc-std-workspace-alloc/Cargo.toml b/build_sysroot/rustc-std-workspace-alloc/Cargo.toml deleted file mode 100644 index 221365373ffab..0000000000000 --- a/build_sysroot/rustc-std-workspace-alloc/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "rustc-std-workspace-alloc" -version = "1.0.0" -authors = ["Alex Crichton "] -license = 'MIT/Apache-2.0' -description = """ -Hack for the compiler's own build system -""" -edition = "2018" - -[lib] -path = "lib.rs" - -[dependencies] -alloc = { path = "../sysroot_src/src/liballoc" } diff --git a/build_sysroot/rustc-std-workspace-alloc/lib.rs b/build_sysroot/rustc-std-workspace-alloc/lib.rs deleted file mode 100644 index cf216ec9d29a7..0000000000000 --- a/build_sysroot/rustc-std-workspace-alloc/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![feature(no_core)] -#![no_core] -#![deny(rust_2018_idioms)] - -pub use ::alloc::*; diff --git a/patches/0020-libtest-Don-t-require-panic_unwind.patch b/patches/0020-libtest-Don-t-require-panic_unwind.patch new file mode 100644 index 0000000000000..4b46914c34bf2 --- /dev/null +++ b/patches/0020-libtest-Don-t-require-panic_unwind.patch @@ -0,0 +1,41 @@ +From 7b30ddc41c71e89d3e6ab6840b0206877d68f201 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sun, 25 Aug 2019 16:23:06 +0200 +Subject: [PATCH] [libtest] Don't require panic_unwind + +--- + src/libtest/lib.rs | 11 ----------- + 1 file changed, 11 deletions(-) + +diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs +index 9bb76f9..c5fe1aa 100644 +--- a/src/libtest/lib.rs ++++ b/src/libtest/lib.rs +@@ -24,7 +24,6 @@ + #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))] + #![feature(nll)] + #![feature(set_stdio)] +-#![feature(panic_unwind)] + #![feature(staged_api)] + #![feature(termination_trait_lib)] + #![feature(test)] +@@ -34,16 +33,6 @@ use getopts; + extern crate libc; + use term; + +-// FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind +-// on aarch64-pc-windows-msvc, or thumbv7a-pc-windows-msvc +-// so we don't link libtest against libunwind (for the time being) +-// even though it means that libtest won't be fully functional on +-// these platforms. +-// +-// See also: https://github.com/rust-lang/rust/issues/54190#issuecomment-422904437 +-#[cfg(not(all(windows, any(target_arch = "aarch64", target_arch = "arm"))))] +-extern crate panic_unwind; +- + pub use self::ColorConfig::*; + use self::NamePadding::*; + use self::OutputLocation::*; +-- +2.20.1 + From e704eb52592be19d4a6417b646d97904cb73468e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 26 Aug 2019 11:03:06 +0200 Subject: [PATCH 0846/1566] Sync discriminant getter and setter with upstream Fixes #683 --- example/mini_core_hello_world.rs | 69 +++++++++++++++++ src/discriminant.rs | 123 +++++++++++++++++-------------- 2 files changed, 138 insertions(+), 54 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 955530c7f919e..5d65dd4d94f50 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -264,4 +264,73 @@ fn main() { static ANOTHER_STATIC: &u8 = &A_STATIC; assert_eq!(*ANOTHER_STATIC, 42); + + check_niche_behavior(); +} + +// Copied ui/issues/issue-61696.rs + +pub enum Infallible {} + +// The check that the `bool` field of `V1` is encoding a "niche variant" +// (i.e. not `V1`, so `V3` or `V4`) used to be mathematically incorrect, +// causing valid `V1` values to be interpreted as other variants. +pub enum E1 { + V1 { f: bool }, + V2 { f: Infallible }, + V3, + V4, +} + +// Computing the discriminant used to be done using the niche type (here `u8`, +// from the `bool` field of `V1`), overflowing for variants with large enough +// indices (`V3` and `V4`), causing them to be interpreted as other variants. +pub enum E2 { + V1 { f: bool }, + + /*_00*/ _01(X), _02(X), _03(X), _04(X), _05(X), _06(X), _07(X), + _08(X), _09(X), _0A(X), _0B(X), _0C(X), _0D(X), _0E(X), _0F(X), + _10(X), _11(X), _12(X), _13(X), _14(X), _15(X), _16(X), _17(X), + _18(X), _19(X), _1A(X), _1B(X), _1C(X), _1D(X), _1E(X), _1F(X), + _20(X), _21(X), _22(X), _23(X), _24(X), _25(X), _26(X), _27(X), + _28(X), _29(X), _2A(X), _2B(X), _2C(X), _2D(X), _2E(X), _2F(X), + _30(X), _31(X), _32(X), _33(X), _34(X), _35(X), _36(X), _37(X), + _38(X), _39(X), _3A(X), _3B(X), _3C(X), _3D(X), _3E(X), _3F(X), + _40(X), _41(X), _42(X), _43(X), _44(X), _45(X), _46(X), _47(X), + _48(X), _49(X), _4A(X), _4B(X), _4C(X), _4D(X), _4E(X), _4F(X), + _50(X), _51(X), _52(X), _53(X), _54(X), _55(X), _56(X), _57(X), + _58(X), _59(X), _5A(X), _5B(X), _5C(X), _5D(X), _5E(X), _5F(X), + _60(X), _61(X), _62(X), _63(X), _64(X), _65(X), _66(X), _67(X), + _68(X), _69(X), _6A(X), _6B(X), _6C(X), _6D(X), _6E(X), _6F(X), + _70(X), _71(X), _72(X), _73(X), _74(X), _75(X), _76(X), _77(X), + _78(X), _79(X), _7A(X), _7B(X), _7C(X), _7D(X), _7E(X), _7F(X), + _80(X), _81(X), _82(X), _83(X), _84(X), _85(X), _86(X), _87(X), + _88(X), _89(X), _8A(X), _8B(X), _8C(X), _8D(X), _8E(X), _8F(X), + _90(X), _91(X), _92(X), _93(X), _94(X), _95(X), _96(X), _97(X), + _98(X), _99(X), _9A(X), _9B(X), _9C(X), _9D(X), _9E(X), _9F(X), + _A0(X), _A1(X), _A2(X), _A3(X), _A4(X), _A5(X), _A6(X), _A7(X), + _A8(X), _A9(X), _AA(X), _AB(X), _AC(X), _AD(X), _AE(X), _AF(X), + _B0(X), _B1(X), _B2(X), _B3(X), _B4(X), _B5(X), _B6(X), _B7(X), + _B8(X), _B9(X), _BA(X), _BB(X), _BC(X), _BD(X), _BE(X), _BF(X), + _C0(X), _C1(X), _C2(X), _C3(X), _C4(X), _C5(X), _C6(X), _C7(X), + _C8(X), _C9(X), _CA(X), _CB(X), _CC(X), _CD(X), _CE(X), _CF(X), + _D0(X), _D1(X), _D2(X), _D3(X), _D4(X), _D5(X), _D6(X), _D7(X), + _D8(X), _D9(X), _DA(X), _DB(X), _DC(X), _DD(X), _DE(X), _DF(X), + _E0(X), _E1(X), _E2(X), _E3(X), _E4(X), _E5(X), _E6(X), _E7(X), + _E8(X), _E9(X), _EA(X), _EB(X), _EC(X), _ED(X), _EE(X), _EF(X), + _F0(X), _F1(X), _F2(X), _F3(X), _F4(X), _F5(X), _F6(X), _F7(X), + _F8(X), _F9(X), _FA(X), _FB(X), _FC(X), _FD(X), _FE(X), _FF(X), + + V3, + V4, +} + +fn check_niche_behavior () { + if let E1::V2 { .. } = (E1::V1 { f: true }) { + unsafe { intrinsics::abort(); } + } + + if let E2::V1 { .. } = E2::V3:: { + unsafe { intrinsics::abort(); } + } } diff --git a/src/discriminant.rs b/src/discriminant.rs index 674486076de72..ea075ece648a7 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -1,3 +1,5 @@ +//! Adapted from https://github.com/rust-lang/rust/blob/d760df5aea483aae041c9a241e7acacf48f75035/src/librustc_codegen_ssa/mir/place.rs + use crate::prelude::*; pub fn codegen_set_discriminant<'tcx>( @@ -6,7 +8,7 @@ pub fn codegen_set_discriminant<'tcx>( variant_index: VariantIdx, ) { let layout = place.layout(); - if layout.for_variant(&*fx, variant_index).abi == layout::Abi::Uninhabited { + if layout.for_variant(fx, variant_index).abi.is_uninhabited() { return; } match layout.variants { @@ -40,16 +42,9 @@ pub fn codegen_set_discriminant<'tcx>( } => { if variant_index != dataful_variant { let niche = place.place_field(fx, mir::Field::new(discr_index)); - //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); - let niche_value = - ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) - .wrapping_add(niche_start); - // FIXME(eddyb) Check the actual primitive type here. - let niche_llval = if niche_value == 0 { - CValue::const_val(fx, niche.layout().ty, 0) - } else { - CValue::const_val(fx, niche.layout().ty, niche_value) - }; + let niche_value = variant_index.as_u32() - niche_variants.start().as_u32(); + let niche_value = u128::from(niche_value).wrapping_add(niche_start); + let niche_llval = CValue::const_val(fx, niche.layout().ty, niche_value); niche.write_cvalue(fx, niche_llval); } } @@ -71,10 +66,8 @@ pub fn codegen_get_discriminant<'tcx>( layout::Variants::Single { index } => { let discr_val = layout .ty - .ty_adt_def() - .map_or(u128::from(index.as_u32()), |def| { - def.discriminant_for_variant(fx.tcx, *index).val - }); + .discriminant_for_variant(fx.tcx, *index) + .map_or(u128::from(index.as_u32()), |discr| discr.val); return CValue::const_val(fx, dest_layout.ty, discr_val); } layout::Variants::Multiple { discr, discr_index, discr_kind, variants: _ } => { @@ -82,16 +75,20 @@ pub fn codegen_get_discriminant<'tcx>( } }; - let discr = value.value_field(fx, mir::Field::new(discr_index)); - let discr_ty = discr.layout().ty; - let lldiscr = discr.load_scalar(fx); - match discr_kind { + let cast_to = fx.clif_type(dest_layout.ty).unwrap(); + + // Read the tag/niche-encoded discriminant from memory. + let encoded_discr = value.value_field(fx, mir::Field::new(discr_index)); + let encoded_discr = encoded_discr.load_scalar(fx); + + // Decode the discriminant (specifically if it's niche-encoded). + match *discr_kind { layout::DiscriminantKind::Tag => { let signed = match discr_scalar.value { layout::Int(_, signed) => signed, - _ => false, + _ => false }; - let val = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), signed); + let val = clif_intcast(fx, encoded_discr, cast_to, signed); return CValue::by_val(val, dest_layout); } layout::DiscriminantKind::Niche { @@ -99,40 +96,58 @@ pub fn codegen_get_discriminant<'tcx>( ref niche_variants, niche_start, } => { - let niche_llty = fx.clif_type(discr_ty).unwrap(); - let dest_clif_ty = fx.clif_type(dest_layout.ty).unwrap(); - if niche_variants.start() == niche_variants.end() { - let b = codegen_icmp_imm(fx, IntCC::Equal, lldiscr, *niche_start as i128); - let if_true = fx - .bcx - .ins() - .iconst(dest_clif_ty, niche_variants.start().as_u32() as i64); - let if_false = fx - .bcx - .ins() - .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); - let val = fx.bcx.ins().select(b, if_true, if_false); - return CValue::by_val(val, dest_layout); + // Rebase from niche values to discriminants, and check + // whether the result is in range for the niche variants. + + // We first compute the "relative discriminant" (wrt `niche_variants`), + // that is, if `n = niche_variants.end() - niche_variants.start()`, + // we remap `niche_start..=niche_start + n` (which may wrap around) + // to (non-wrap-around) `0..=n`, to be able to check whether the + // discriminant corresponds to a niche variant with one comparison. + // We also can't go directly to the (variant index) discriminant + // and check that it is in the range `niche_variants`, because + // that might not fit in the same type, on top of needing an extra + // comparison (see also the comment on `let niche_discr`). + let relative_discr = if niche_start == 0 { + encoded_discr } else { - // Rebase from niche values to discriminant values. - let delta = niche_start.wrapping_sub(niche_variants.start().as_u32() as u128); - let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); - let lldiscr = fx.bcx.ins().isub(lldiscr, delta); - let b = codegen_icmp_imm( - fx, - IntCC::UnsignedLessThanOrEqual, - lldiscr, - i128::from(niche_variants.end().as_u32()), - ); - let if_true = - clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false); - let if_false = fx - .bcx - .ins() - .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); - let val = fx.bcx.ins().select(b, if_true, if_false); - return CValue::by_val(val, dest_layout); - } + // FIXME handle niche_start > i64::max_value() + fx.bcx.ins().iadd_imm(encoded_discr, -i64::try_from(niche_start).unwrap()) + }; + let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32(); + let is_niche = { + codegen_icmp_imm(fx, IntCC::UnsignedLessThanOrEqual, relative_discr, i128::from(relative_max)) + }; + + // NOTE(eddyb) this addition needs to be performed on the final + // type, in case the niche itself can't represent all variant + // indices (e.g. `u8` niche with more than `256` variants, + // but enough uninhabited variants so that the remaining variants + // fit in the niche). + // In other words, `niche_variants.end - niche_variants.start` + // is representable in the niche, but `niche_variants.end` + // might not be, in extreme cases. + let niche_discr = { + let relative_discr = if relative_max == 0 { + // HACK(eddyb) since we have only one niche, we know which + // one it is, and we can avoid having a dynamic value here. + fx.bcx.ins().iconst(cast_to, 0) + } else { + clif_intcast(fx, relative_discr, cast_to, false) + }; + fx.bcx.ins().iadd_imm( + relative_discr, + i64::from(niche_variants.start().as_u32()), + ) + }; + + let dataful_variant = fx.bcx.ins().iconst(cast_to, i64::from(dataful_variant.as_u32())); + let discr = fx.bcx.ins().select( + is_niche, + niche_discr, + dataful_variant, + ); + CValue::by_val(discr, dest_layout) } } } From b9dc950a11509deadf2fa7bf6936184fe6113f4c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 27 Aug 2019 11:01:36 +0200 Subject: [PATCH 0847/1566] Rustup to rustc 1.39.0-nightly (9b91b9c10 2019-08-26) --- src/base.rs | 9 +++++---- src/constant.rs | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/base.rs b/src/base.rs index 54db738031feb..3f0892a315ec4 100644 --- a/src/base.rs +++ b/src/base.rs @@ -558,11 +558,12 @@ pub fn trans_place<'tcx>( let base = match &place.base { PlaceBase::Local(local) => fx.get_local_place(*local), PlaceBase::Static(static_) => match static_.kind { - StaticKind::Static(def_id) => { - crate::constant::codegen_static_ref(fx, def_id, static_.ty) + StaticKind::Static => { + crate::constant::codegen_static_ref(fx, static_.def_id, static_.ty) } - StaticKind::Promoted(promoted) => { - crate::constant::trans_promoted(fx, promoted, static_.ty) + StaticKind::Promoted(promoted, substs) => { + let instance = Instance::new(static_.def_id, fx.monomorphize(&substs)); + crate::constant::trans_promoted(fx, instance, promoted, static_.ty) } } }; diff --git a/src/constant.rs b/src/constant.rs index d1e09cb523997..daec743446570 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -54,13 +54,14 @@ pub fn codegen_static_ref<'tcx>( pub fn trans_promoted<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + instance: Instance<'tcx>, promoted: Promoted, dest_ty: Ty<'tcx>, ) -> CPlace<'tcx> { match fx .tcx .const_eval(ParamEnv::reveal_all().and(GlobalId { - instance: fx.instance, + instance, promoted: Some(promoted), })) { @@ -461,10 +462,11 @@ pub fn mir_operand_get_const_val<'tcx>( }; Some(match &static_.kind { - StaticKind::Static(_) => unimplemented!(), - StaticKind::Promoted(promoted) => { + StaticKind::Static => unimplemented!(), + StaticKind::Promoted(promoted, substs) => { + let instance = Instance::new(static_.def_id, fx.monomorphize(substs)); fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { - instance: fx.instance, + instance, promoted: Some(*promoted), })).unwrap() } From 40629999bcbf230d14a7ac56d4b56a86b8fad3d8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 28 Aug 2019 15:29:10 +0200 Subject: [PATCH 0848/1566] Don't force RETURN_PLACE to stack Speeds up simple-raytracer by 7% (cc #684) --- src/analyze.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index f4624221ca88c..2adaa0b718231 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -15,8 +15,6 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap { flag_map.insert(local, Flags::empty()); } - not_ssa(&mut flag_map, RETURN_PLACE); - for (local, local_decl) in fx.mir.local_decls.iter_enumerated() { if fx.clif_type(local_decl.ty).is_none() { not_ssa(&mut flag_map, local); From 6127632c761b9a658b13c122ba0beb73f4542399 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 28 Aug 2019 16:38:53 +0200 Subject: [PATCH 0849/1566] Use f{32,64}const insts instead of loading from a global value --- src/constant.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/constant.rs b/src/constant.rs index daec743446570..fbc6be97b0607 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -122,6 +122,14 @@ pub fn trans_const_value<'tcx>( let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, rustc::mir::interpret::sign_extend(bits, layout.size)) } + ty::Float(fty) => { + let bits = const_.val.try_to_bits(layout.size).unwrap(); + let val = match fty { + FloatTy::F32 => fx.bcx.ins().f32const(Ieee32::with_bits(u32::try_from(bits).unwrap())), + FloatTy::F64 => fx.bcx.ins().f64const(Ieee64::with_bits(u64::try_from(bits).unwrap())), + }; + CValue::by_val(val, layout) + } ty::FnDef(_def_id, _substs) => CValue::by_ref( fx.bcx .ins() From 1018a34662e0b8d9dfa650ed0ee1dfd84242ac37 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 28 Aug 2019 17:59:48 +0200 Subject: [PATCH 0850/1566] Don't add stack_addr intructions to prelude Speeds up simple-raytracer by 30% (cc #684) Also reduces the size of the simple-raytracer binary from 9.2MB to 8.6MB --- src/abi.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index b0fd9a1d73ac4..0aa8e299bb0b9 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -423,8 +423,7 @@ fn local_place<'tcx>( } } - // Take stack_addr in advance to avoid many duplicate instructions - CPlace::for_addr(place.to_addr(fx), layout) + place }; let prev_place = fx.local_map.insert(local, place); From d9d8c69af1fc9ae0bf22a1be99000303b3f85442 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 29 Aug 2019 11:23:19 +0200 Subject: [PATCH 0851/1566] Split extract layout field of all CPlace variants into a sparate struct --- src/abi.rs | 6 +- src/intrinsics.rs | 20 ++++--- src/lib.rs | 2 +- src/value_and_place.rs | 129 ++++++++++++++++++++++++----------------- 4 files changed, 91 insertions(+), 66 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 0aa8e299bb0b9..75b35b6fac5ab 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -399,8 +399,8 @@ fn local_place<'tcx>( fields: _, largest_niche: _, } = details; - match place { - CPlace::Stack(stack_slot, _) => fx.add_entity_comment( + match *place.inner() { + CPlaceInner::Stack(stack_slot) => fx.add_entity_comment( stack_slot, format!( "{:?}: {:?} size={} align={},{}", @@ -411,7 +411,7 @@ fn local_place<'tcx>( align.pref.bytes(), ), ), - CPlace::NoPlace(_) => fx.add_global_comment(format!( + CPlaceInner::NoPlace => fx.add_global_comment(format!( "zst {:?}: {:?} size={} align={}, {}", local, ty, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 2cec9c57143f9..354513ac57b0e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -565,14 +565,15 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) }; init, () { - if ret.layout().abi == Abi::Uninhabited { + let layout = ret.layout(); + if layout.abi == Abi::Uninhabited { crate::trap::trap_panic(fx, "[panic] Called intrinsic::init for uninhabited type."); return; } - match ret { - CPlace::NoPlace(_layout) => {} - CPlace::Var(var, layout) => { + match *ret.inner() { + CPlaceInner::NoPlace => {} + CPlaceInner::Var(var) => { let clif_ty = fx.clif_type(layout.ty).unwrap(); let val = match clif_ty { types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 0), @@ -596,13 +597,14 @@ pub fn codegen_intrinsic_call<'tcx>( } }; uninit, () { - if ret.layout().abi == Abi::Uninhabited { + let layout = ret.layout(); + if layout.abi == Abi::Uninhabited { crate::trap::trap_panic(fx, "[panic] Called intrinsic::uninit for uninhabited type."); return; } - match ret { - CPlace::NoPlace(_layout) => {}, - CPlace::Var(var, layout) => { + match *ret.inner() { + CPlaceInner::NoPlace => {}, + CPlaceInner::Var(var) => { let clif_ty = fx.clif_type(layout.ty).unwrap(); let val = match clif_ty { types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 42), @@ -618,7 +620,7 @@ pub fn codegen_intrinsic_call<'tcx>( }; fx.bcx.def_var(mir_var(var), val); } - CPlace::Addr(_, _, _) | CPlace::Stack(_, _) => { + CPlaceInner::Addr(_, _) | CPlaceInner::Stack(_) => { // Don't write to `ret`, as the destination memory is already uninitialized. } } diff --git a/src/lib.rs b/src/lib.rs index 21c7f3af2267f..d84a6e8199a5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,7 +102,7 @@ mod prelude { pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; - pub use crate::value_and_place::{CValue, CPlace}; + pub use crate::value_and_place::{CValue, CPlace, CPlaceInner}; pub use crate::{Caches, CodegenCx}; pub struct PrintOnPanic String>(pub F); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index f018ed0a2babe..b300db2ecfcd4 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -163,25 +163,33 @@ impl<'tcx> CValue<'tcx> { /// A place where you can write a value to or read a value from #[derive(Debug, Copy, Clone)] -pub enum CPlace<'tcx> { - Var(Local, TyLayout<'tcx>), - Addr(Value, Option, TyLayout<'tcx>), - Stack(StackSlot, TyLayout<'tcx>), - NoPlace(TyLayout<'tcx>), +pub struct CPlace<'tcx> { + inner: CPlaceInner, + layout: TyLayout<'tcx>, +} + +#[derive(Debug, Copy, Clone)] +pub enum CPlaceInner { + Var(Local), + Addr(Value, Option), + Stack(StackSlot), + NoPlace, } impl<'tcx> CPlace<'tcx> { pub fn layout(&self) -> TyLayout<'tcx> { - match *self { - CPlace::Var(_, layout) - | CPlace::Addr(_, _, layout) - | CPlace::Stack(_, layout) - | CPlace::NoPlace(layout) => layout, - } + self.layout + } + + pub fn inner(&self) -> &CPlaceInner { + &self.inner } pub fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { - CPlace::NoPlace(layout) + CPlace{ + inner: CPlaceInner::NoPlace, + layout + } } pub fn new_stack_slot( @@ -191,7 +199,10 @@ impl<'tcx> CPlace<'tcx> { let layout = fx.layout_of(ty); assert!(!layout.is_unsized()); if layout.size.bytes() == 0 { - return CPlace::NoPlace(layout); + return CPlace { + inner: CPlaceInner::NoPlace, + layout, + }; } let stack_slot = fx.bcx.create_stack_slot(StackSlotData { @@ -199,7 +210,10 @@ impl<'tcx> CPlace<'tcx> { size: layout.size.bytes() as u32, offset: None, }); - CPlace::Stack(stack_slot, layout) + CPlace { + inner: CPlaceInner::Stack(stack_slot), + layout, + } } pub fn new_var( @@ -209,29 +223,39 @@ impl<'tcx> CPlace<'tcx> { ) -> CPlace<'tcx> { fx.bcx .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); - CPlace::Var(local, layout) + CPlace { + inner: CPlaceInner::Var(local), + layout, + } } pub fn for_addr(addr: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { - CPlace::Addr(addr, None, layout) + CPlace { + inner: CPlaceInner::Addr(addr, None), + layout, + } } pub fn for_addr_with_extra(addr: Value, extra: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { - CPlace::Addr(addr, Some(extra), layout) + CPlace { + inner: CPlaceInner::Addr(addr, Some(extra)), + layout, + } } pub fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> { - match self { - CPlace::Var(var, layout) => CValue::by_val(fx.bcx.use_var(mir_var(var)), layout), - CPlace::Addr(addr, extra, layout) => { + let layout = self.layout(); + match self.inner { + CPlaceInner::Var(var) => CValue::by_val(fx.bcx.use_var(mir_var(var)), layout), + CPlaceInner::Addr(addr, extra) => { assert!(extra.is_none(), "unsized values are not yet supported"); CValue::by_ref(addr, layout) } - CPlace::Stack(stack_slot, layout) => CValue::by_ref( + CPlaceInner::Stack(stack_slot) => CValue::by_ref( fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), layout, ), - CPlace::NoPlace(layout) => CValue::by_ref( + CPlaceInner::NoPlace => CValue::by_ref( fx.bcx .ins() .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), @@ -251,14 +275,14 @@ impl<'tcx> CPlace<'tcx> { self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ) -> (Value, Option) { - match self { - CPlace::Addr(addr, extra, _layout) => (addr, extra), - CPlace::Stack(stack_slot, _layout) => ( + match self.inner { + CPlaceInner::Addr(addr, extra) => (addr, extra), + CPlaceInner::Stack(stack_slot) => ( fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None, ), - CPlace::NoPlace(_) => (fx.bcx.ins().iconst(fx.pointer_type, 45), None), - CPlace::Var(_, _) => bug!("Expected CPlace::Addr, found CPlace::Var"), + CPlaceInner::NoPlace => (fx.bcx.ins().iconst(fx.pointer_type, 45), None), + CPlaceInner::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } @@ -327,24 +351,24 @@ impl<'tcx> CPlace<'tcx> { assert_assignable(fx, from_ty, to_ty); - let (addr, dst_layout) = match self { - CPlace::Var(var, _) => { + let dst_layout = self.layout(); + let addr = match self.inner { + CPlaceInner::Var(var) => { let data = from.load_scalar(fx); fx.bcx.def_var(mir_var(var), data); return; } - CPlace::Addr(addr, None, dst_layout) => (addr, dst_layout), - CPlace::Stack(stack_slot, dst_layout) => ( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), - dst_layout, - ), - CPlace::NoPlace(layout) => { - if layout.abi != Abi::Uninhabited { - assert_eq!(layout.size.bytes(), 0, "{:?}", layout); + CPlaceInner::Addr(addr, None) => addr, + CPlaceInner::Stack(stack_slot) => { + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0) + } + CPlaceInner::NoPlace => { + if dst_layout.abi != Abi::Uninhabited { + assert_eq!(dst_layout.size.bytes(), 0, "{:?}", dst_layout); } return; } - CPlace::Addr(_, _, _) => bug!("Can't write value to unsized place {:?}", self), + CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self), }; match from.0 { @@ -395,13 +419,11 @@ impl<'tcx> CPlace<'tcx> { let (base, extra) = self.to_addr_maybe_unsized(fx); let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); - let extra = if field_layout.is_unsized() { - assert!(extra.is_some()); - extra + if field_layout.is_unsized() { + CPlace::for_addr_with_extra(field_ptr, extra.unwrap(), field_layout) } else { - None - }; - CPlace::Addr(field_ptr, extra, field_layout) + CPlace::for_addr(field_ptr, field_layout) + } } pub fn place_index( @@ -420,16 +442,16 @@ impl<'tcx> CPlace<'tcx> { .ins() .imul_imm(index, elem_layout.size.bytes() as i64); - CPlace::Addr(fx.bcx.ins().iadd(addr, offset), None, elem_layout) + CPlace::for_addr(fx.bcx.ins().iadd(addr, offset), elem_layout) } pub fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); if !inner_layout.is_unsized() { - CPlace::Addr(self.to_cvalue(fx).load_scalar(fx), None, inner_layout) + CPlace::for_addr(self.to_cvalue(fx).load_scalar(fx), inner_layout) } else { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); - CPlace::Addr(addr, Some(extra), inner_layout) + CPlace::for_addr_with_extra(addr, extra, inner_layout) } } @@ -446,14 +468,15 @@ impl<'tcx> CPlace<'tcx> { pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { assert!(!self.layout().is_unsized()); - match self { - CPlace::Var(var, _) => CPlace::Var(var, layout), - CPlace::Addr(addr, extra, _) => CPlace::Addr(addr, extra, layout), - CPlace::Stack(stack_slot, _) => CPlace::Stack(stack_slot, layout), - CPlace::NoPlace(_) => { + match self.inner { + CPlaceInner::NoPlace => { assert!(layout.size.bytes() == 0); - CPlace::NoPlace(layout) } + _ => {} + } + CPlace { + inner: self.inner, + layout, } } From f1b6bd9480d21186f1a44b8d8d70a95111a705fb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 29 Aug 2019 11:24:08 +0200 Subject: [PATCH 0852/1566] Update my fork of cranelift for an isplit fix --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 744fe5c2fb174..c70da1e3d53e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,7 +73,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-frontend 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -82,7 +82,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", ] @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-bforest 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-codegen-meta 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", ] @@ -112,12 +112,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" [[package]] name = "cranelift-faerie" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -130,7 +130,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -140,7 +140,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -151,7 +151,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -161,7 +161,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#ba82568fe58b6d54b2a85927aada861629117a79" +source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" dependencies = [ "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", From 556d708f205df7d61ca28258071994e9b20e66c0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 11:42:42 +0200 Subject: [PATCH 0853/1566] Rustup to rustc 1.39.0-nightly (72b2abfd6 2019-08-29) --- src/main_shim.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main_shim.rs b/src/main_shim.rs index 3dc3fad51f501..5af5012279f6a 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -72,7 +72,7 @@ pub fn maybe_create_entry_wrapper( let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); let call_inst = if use_start_lang_item { - let start_def_id = tcx.require_lang_item(StartFnLangItem); + let start_def_id = tcx.require_lang_item(StartFnLangItem, None); let start_instance = Instance::resolve( tcx, ParamEnv::reveal_all(), From b3311ed4d594418632411f17a95cbe7689ab471d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 11:46:07 +0200 Subject: [PATCH 0854/1566] Update Cargo.lock --- Cargo.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c70da1e3d53e0..6b4b995b2ddf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.34" +version = "0.3.35" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -56,7 +56,7 @@ name = "c2-chacha" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -207,7 +207,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -219,7 +219,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -257,7 +257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -268,12 +268,12 @@ dependencies = [ [[package]] name = "gimli" version = "0.19.0" -source = "git+https://github.com/gimli-rs/gimli.git#91e38653f2f4d615d7acc5da1df2fcbec0b50eb0" +source = "git+https://github.com/gimli-rs/gimli.git#1f1a9eb23993d3787a4e3389eade28a104bd91d0" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -309,7 +309,7 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -319,7 +319,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -423,7 +423,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -444,7 +444,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -507,7 +507,7 @@ dependencies = [ "cranelift-simplejit 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", "faerie 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", - "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", @@ -670,7 +670,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" +"checksum backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -696,14 +696,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6171a6cc63fbabbe27c2b5ee268e8b7fe5dc1eb0dd2dfad537c1dfed6f69117e" +"checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872" "checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)" = "" "checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" "checksum goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ac56b4753b6b8c2e052ca30717e5a09acf1b02a2c1681bf3d883bd660e5d22bd" -"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d" +"checksum indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4d6d89e0948bf10c08b9ecc8ac5b83f07f857ebe2c0cbe38de15b4e4f510356" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" From 6427eaf68b5cb9f20b981c393dfd779dd6372cd5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 11:51:33 +0200 Subject: [PATCH 0855/1566] Move abi.rs to abi/mod.rs --- src/{abi.rs => abi/mod.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{abi.rs => abi/mod.rs} (100%) diff --git a/src/abi.rs b/src/abi/mod.rs similarity index 100% rename from src/abi.rs rename to src/abi/mod.rs From 68dcfc1c789f8d10f6d0b3981c64bca309a2481e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 11:58:52 +0200 Subject: [PATCH 0856/1566] Move pass mode handling to abi/pass_mode.rs --- src/abi/mod.rs | 188 +------------------------------------------ src/abi/pass_mode.rs | 168 ++++++++++++++++++++++++++++++++++++++ src/common.rs | 18 +++++ 3 files changed, 189 insertions(+), 185 deletions(-) create mode 100644 src/abi/pass_mode.rs diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 75b35b6fac5ab..f359145f563e7 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -1,152 +1,11 @@ +mod pass_mode; + use std::borrow::Cow; -use rustc::ty::layout::{FloatTy, Integer, Primitive, Scalar}; use rustc_target::spec::abi::Abi; use crate::prelude::*; - -#[derive(Copy, Clone, Debug)] -enum PassMode { - NoPass, - ByVal(Type), - ByValPair(Type, Type), - ByRef, -} - -#[derive(Copy, Clone, Debug)] -enum EmptySinglePair { - Empty, - Single(T), - Pair(T, T), -} - -impl EmptySinglePair { - fn into_iter(self) -> EmptySinglePairIter { - EmptySinglePairIter(self) - } - - fn map(self, mut f: impl FnMut(T) -> U) -> EmptySinglePair { - match self { - Empty => Empty, - Single(v) => Single(f(v)), - Pair(a, b) => Pair(f(a), f(b)), - } - } -} - -struct EmptySinglePairIter(EmptySinglePair); - -impl Iterator for EmptySinglePairIter { - type Item = T; - - fn next(&mut self) -> Option { - match std::mem::replace(&mut self.0, Empty) { - Empty => None, - Single(v) => Some(v), - Pair(a, b) => { - self.0 = Single(b); - Some(a) - } - } - } -} - -impl EmptySinglePair { - fn assert_single(self) -> T { - match self { - Single(v) => v, - _ => panic!("Called assert_single on {:?}", self) - } - } - - fn assert_pair(self) -> (T, T) { - match self { - Pair(a, b) => (a, b), - _ => panic!("Called assert_pair on {:?}", self) - } - } -} - -use EmptySinglePair::*; - -impl PassMode { - fn get_param_ty(self, fx: &FunctionCx) -> EmptySinglePair { - match self { - PassMode::NoPass => Empty, - PassMode::ByVal(clif_type) => Single(clif_type), - PassMode::ByValPair(a, b) => Pair(a, b), - PassMode::ByRef => Single(fx.pointer_type), - } - } -} - -pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { - match scalar.value { - Primitive::Int(int, _sign) => match int { - Integer::I8 => types::I8, - Integer::I16 => types::I16, - Integer::I32 => types::I32, - Integer::I64 => types::I64, - Integer::I128 => types::I128, - }, - Primitive::Float(flt) => match flt { - FloatTy::F32 => types::F32, - FloatTy::F64 => types::F64, - }, - Primitive::Pointer => pointer_ty(tcx), - } -} - -fn get_pass_mode<'tcx>( - tcx: TyCtxt<'tcx>, - layout: TyLayout<'tcx>, -) -> PassMode { - assert!(!layout.is_unsized()); - - if layout.is_zst() { - // WARNING zst arguments must never be passed, as that will break CastKind::ClosureFnPointer - PassMode::NoPass - } else { - match &layout.abi { - layout::Abi::Uninhabited => PassMode::NoPass, - layout::Abi::Scalar(scalar) => { - PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) - } - layout::Abi::ScalarPair(a, b) => { - let a = scalar_to_clif_type(tcx, a.clone()); - let b = scalar_to_clif_type(tcx, b.clone()); - if a == types::I128 && b == types::I128 { - // Returning (i128, i128) by-val-pair would take 4 regs, while only 3 are - // available on x86_64. Cranelift gets confused when too many return params - // are used. - PassMode::ByRef - } else { - PassMode::ByValPair(a, b) - } - } - - // FIXME implement Vector Abi in a cg_llvm compatible way - layout::Abi::Vector { .. } => PassMode::ByRef, - - layout::Abi::Aggregate { .. } => PassMode::ByRef, - } - } -} - -fn adjust_arg_for_abi<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - arg: CValue<'tcx>, -) -> EmptySinglePair { - match get_pass_mode(fx.tcx, arg.layout()) { - PassMode::NoPass => Empty, - PassMode::ByVal(_) => Single(arg.load_scalar(fx)), - PassMode::ByValPair(_, _) => { - let (a, b) = arg.load_scalar_pair(fx); - Pair(a, b) - } - PassMode::ByRef => Single(arg.force_stack(fx)), - } -} +use self::pass_mode::*; fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: bool) -> Signature { let abi = match sig.abi { @@ -431,47 +290,6 @@ fn local_place<'tcx>( fx.local_map[&local] } -fn cvalue_for_param<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - start_ebb: Ebb, - local: mir::Local, - local_field: Option, - arg_ty: Ty<'tcx>, - ssa_flags: crate::analyze::Flags, -) -> Option> { - let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.tcx, fx.layout_of(arg_ty)); - - if let PassMode::NoPass = pass_mode { - return None; - } - - let clif_types = pass_mode.get_param_ty(fx); - let ebb_params = clif_types.map(|t| fx.bcx.append_ebb_param(start_ebb, t)); - - #[cfg(debug_assertions)] - add_arg_comment( - fx, - "arg", - local, - local_field, - ebb_params, - pass_mode, - ssa_flags, - arg_ty, - ); - - match pass_mode { - PassMode::NoPass => unreachable!(), - PassMode::ByVal(_) => Some(CValue::by_val(ebb_params.assert_single(), layout)), - PassMode::ByValPair(_, _) => { - let (a, b) = ebb_params.assert_pair(); - Some(CValue::by_val_pair(a, b, layout)) - } - PassMode::ByRef => Some(CValue::by_ref(ebb_params.assert_single(), layout)), - } -} - pub fn codegen_fn_prelude( fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: Ebb, diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs new file mode 100644 index 0000000000000..c3a479578bccd --- /dev/null +++ b/src/abi/pass_mode.rs @@ -0,0 +1,168 @@ +use crate::prelude::*; + +#[derive(Copy, Clone, Debug)] +pub enum PassMode { + NoPass, + ByVal(Type), + ByValPair(Type, Type), + ByRef, +} + +#[derive(Copy, Clone, Debug)] +pub enum EmptySinglePair { + Empty, + Single(T), + Pair(T, T), +} + +impl EmptySinglePair { + pub fn into_iter(self) -> EmptySinglePairIter { + EmptySinglePairIter(self) + } + + pub fn map(self, mut f: impl FnMut(T) -> U) -> EmptySinglePair { + match self { + Empty => Empty, + Single(v) => Single(f(v)), + Pair(a, b) => Pair(f(a), f(b)), + } + } +} + +pub struct EmptySinglePairIter(EmptySinglePair); + +impl Iterator for EmptySinglePairIter { + type Item = T; + + fn next(&mut self) -> Option { + match std::mem::replace(&mut self.0, Empty) { + Empty => None, + Single(v) => Some(v), + Pair(a, b) => { + self.0 = Single(b); + Some(a) + } + } + } +} + +impl EmptySinglePair { + pub fn assert_single(self) -> T { + match self { + Single(v) => v, + _ => panic!("Called assert_single on {:?}", self) + } + } + + pub fn assert_pair(self) -> (T, T) { + match self { + Pair(a, b) => (a, b), + _ => panic!("Called assert_pair on {:?}", self) + } + } +} + +pub use EmptySinglePair::*; + +impl PassMode { + pub fn get_param_ty(self, fx: &FunctionCx) -> EmptySinglePair { + match self { + PassMode::NoPass => Empty, + PassMode::ByVal(clif_type) => Single(clif_type), + PassMode::ByValPair(a, b) => Pair(a, b), + PassMode::ByRef => Single(fx.pointer_type), + } + } +} + +pub fn get_pass_mode<'tcx>( + tcx: TyCtxt<'tcx>, + layout: TyLayout<'tcx>, +) -> PassMode { + assert!(!layout.is_unsized()); + + if layout.is_zst() { + // WARNING zst arguments must never be passed, as that will break CastKind::ClosureFnPointer + PassMode::NoPass + } else { + match &layout.abi { + layout::Abi::Uninhabited => PassMode::NoPass, + layout::Abi::Scalar(scalar) => { + PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) + } + layout::Abi::ScalarPair(a, b) => { + let a = scalar_to_clif_type(tcx, a.clone()); + let b = scalar_to_clif_type(tcx, b.clone()); + if a == types::I128 && b == types::I128 { + // Returning (i128, i128) by-val-pair would take 4 regs, while only 3 are + // available on x86_64. Cranelift gets confused when too many return params + // are used. + PassMode::ByRef + } else { + PassMode::ByValPair(a, b) + } + } + + // FIXME implement Vector Abi in a cg_llvm compatible way + layout::Abi::Vector { .. } => PassMode::ByRef, + + layout::Abi::Aggregate { .. } => PassMode::ByRef, + } + } +} + +pub fn adjust_arg_for_abi<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + arg: CValue<'tcx>, +) -> EmptySinglePair { + match get_pass_mode(fx.tcx, arg.layout()) { + PassMode::NoPass => Empty, + PassMode::ByVal(_) => Single(arg.load_scalar(fx)), + PassMode::ByValPair(_, _) => { + let (a, b) = arg.load_scalar_pair(fx); + Pair(a, b) + } + PassMode::ByRef => Single(arg.force_stack(fx)), + } +} + +pub fn cvalue_for_param<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + start_ebb: Ebb, + local: mir::Local, + local_field: Option, + arg_ty: Ty<'tcx>, + ssa_flags: crate::analyze::Flags, +) -> Option> { + let layout = fx.layout_of(arg_ty); + let pass_mode = get_pass_mode(fx.tcx, fx.layout_of(arg_ty)); + + if let PassMode::NoPass = pass_mode { + return None; + } + + let clif_types = pass_mode.get_param_ty(fx); + let ebb_params = clif_types.map(|t| fx.bcx.append_ebb_param(start_ebb, t)); + + #[cfg(debug_assertions)] + super::add_arg_comment( + fx, + "arg", + local, + local_field, + ebb_params, + pass_mode, + ssa_flags, + arg_ty, + ); + + match pass_mode { + PassMode::NoPass => unreachable!(), + PassMode::ByVal(_) => Some(CValue::by_val(ebb_params.assert_single(), layout)), + PassMode::ByValPair(_, _) => { + let (a, b) = ebb_params.assert_pair(); + Some(CValue::by_val_pair(a, b, layout)) + } + PassMode::ByRef => Some(CValue::by_ref(ebb_params.assert_single(), layout)), + } +} diff --git a/src/common.rs b/src/common.rs index eb6f204a8d284..6ed979449fe63 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,3 +1,4 @@ +use rustc::ty::layout::{FloatTy, Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; use cranelift::codegen::ir::{Opcode, InstructionData, ValueDef}; @@ -17,6 +18,23 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } } +pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { + match scalar.value { + Primitive::Int(int, _sign) => match int { + Integer::I8 => types::I8, + Integer::I16 => types::I16, + Integer::I32 => types::I32, + Integer::I64 => types::I64, + Integer::I128 => types::I128, + }, + Primitive::Float(flt) => match flt { + FloatTy::F32 => types::F32, + FloatTy::F64 => types::F64, + }, + Primitive::Pointer => pointer_ty(tcx), + } +} + pub fn clif_type_from_ty<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, From 16593d264c7803b78156c02b2ac596f6d98333c7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 12:30:57 +0200 Subject: [PATCH 0857/1566] Move return handling to abi/returning.rs --- src/abi/mod.rs | 144 ++++++++++--------------------------------- src/abi/returning.rs | 111 +++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 113 deletions(-) create mode 100644 src/abi/returning.rs diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f359145f563e7..a724ea2d8ec0b 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -1,3 +1,4 @@ +mod returning; mod pass_mode; use std::borrow::Cow; @@ -7,6 +8,8 @@ use rustc_target::spec::abi::Abi; use crate::prelude::*; use self::pass_mode::*; +pub use self::returning::codegen_return; + fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: bool) -> Signature { let abi = match sig.abi { Abi::System => { @@ -296,35 +299,15 @@ pub fn codegen_fn_prelude( ) { let ssa_analyzed = crate::analyze::analyze(fx); - #[cfg(debug_assertions)] - fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); - - let ret_layout = fx.return_layout(); - let output_pass_mode = get_pass_mode(fx.tcx, fx.return_layout()); - let ret_param = match output_pass_mode { - PassMode::NoPass | PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, - PassMode::ByRef => Some(fx.bcx.append_ebb_param(start_ebb, fx.pointer_type)), - }; - #[cfg(debug_assertions)] { + fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); add_local_header_comment(fx); - let ret_param = match ret_param { - Some(param) => Single(param), - None => Empty, - }; - add_arg_comment( - fx, - "ret", - RETURN_PLACE, - None, - ret_param, - output_pass_mode, - ssa_analyzed[&RETURN_PLACE], - ret_layout.ty, - ); } + self::returning::codegen_return_param(fx, &ssa_analyzed, start_ebb); + + // None means pass_mode == NoPass enum ArgKind<'tcx> { Normal(Option>), @@ -373,27 +356,6 @@ pub fn codegen_fn_prelude( fx.bcx.switch_to_block(start_ebb); - match output_pass_mode { - PassMode::NoPass => { - fx.local_map - .insert(RETURN_PLACE, CPlace::no_place(ret_layout)); - } - PassMode::ByVal(_) | PassMode::ByValPair(_, _) => { - let is_ssa = !ssa_analyzed - .get(&RETURN_PLACE) - .unwrap() - .contains(crate::analyze::Flags::NOT_SSA); - - local_place(fx, RETURN_PLACE, ret_layout, is_ssa); - } - PassMode::ByRef => { - fx.local_map.insert( - RETURN_PLACE, - CPlace::for_addr(ret_param.unwrap(), ret_layout), - ); - } - } - for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); @@ -524,18 +486,6 @@ fn codegen_call_inner<'tcx>( ) { let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - let ret_layout = fx.layout_of(fn_sig.output()); - - let output_pass_mode = get_pass_mode(fx.tcx, fx.layout_of(fn_sig.output())); - let return_ptr = match output_pass_mode { - PassMode::NoPass => None, - PassMode::ByRef => match ret_place { - Some(ret_place) => Some(ret_place.to_addr(fx)), - None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), - }, - PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, - }; - let instance = match fn_ty.sty { ty::FnDef(def_id, substs) => { Some(Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap()) @@ -584,26 +534,30 @@ fn codegen_call_inner<'tcx>( } }; - let call_args: Vec = return_ptr - .into_iter() - .chain(first_arg.into_iter()) - .chain( - args.into_iter() - .skip(1) - .map(|arg| adjust_arg_for_abi(fx, arg).into_iter()) - .flatten(), - ) - .collect::>(); - - let call_inst = if let Some(func_ref) = func_ref { - let sig = fx - .bcx - .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, is_virtual_call)); - fx.bcx.ins().call_indirect(sig, func_ref, &call_args) - } else { - let func_ref = fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); - fx.bcx.ins().call(func_ref, &call_args) - }; + let (call_inst, call_args) = self::returning::codegen_with_call_return_arg(fx, fn_sig, ret_place, |fx, return_ptr| { + let call_args: Vec = return_ptr + .into_iter() + .chain(first_arg.into_iter()) + .chain( + args.into_iter() + .skip(1) + .map(|arg| adjust_arg_for_abi(fx, arg).into_iter()) + .flatten(), + ) + .collect::>(); + + let call_inst = if let Some(func_ref) = func_ref { + let sig = fx + .bcx + .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, is_virtual_call)); + fx.bcx.ins().call_indirect(sig, func_ref, &call_args) + } else { + let func_ref = fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); + fx.bcx.ins().call(func_ref, &call_args) + }; + + (call_inst, call_args) + }); // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { @@ -624,24 +578,6 @@ fn codegen_call_inner<'tcx>( .collect::>(); fx.bcx.func.dfg.signatures[sig_ref].params = abi_params; } - - match output_pass_mode { - PassMode::NoPass => {} - PassMode::ByVal(_) => { - if let Some(ret_place) = ret_place { - let ret_val = fx.bcx.inst_results(call_inst)[0]; - ret_place.write_cvalue(fx, CValue::by_val(ret_val, ret_layout)); - } - } - PassMode::ByValPair(_, _) => { - if let Some(ret_place) = ret_place { - let ret_val_a = fx.bcx.inst_results(call_inst)[0]; - let ret_val_b = fx.bcx.inst_results(call_inst)[1]; - ret_place.write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_layout)); - } - } - PassMode::ByRef => {} - } } pub fn codegen_drop<'tcx>( @@ -693,21 +629,3 @@ pub fn codegen_drop<'tcx>( } } } - -pub fn codegen_return(fx: &mut FunctionCx) { - match get_pass_mode(fx.tcx, fx.return_layout()) { - PassMode::NoPass | PassMode::ByRef => { - fx.bcx.ins().return_(&[]); - } - PassMode::ByVal(_) => { - let place = fx.get_local_place(RETURN_PLACE); - let ret_val = place.to_cvalue(fx).load_scalar(fx); - fx.bcx.ins().return_(&[ret_val]); - } - PassMode::ByValPair(_, _) => { - let place = fx.get_local_place(RETURN_PLACE); - let (ret_val_a, ret_val_b) = place.to_cvalue(fx).load_scalar_pair(fx); - fx.bcx.ins().return_(&[ret_val_a, ret_val_b]); - } - } -} diff --git a/src/abi/returning.rs b/src/abi/returning.rs new file mode 100644 index 0000000000000..45ba48d7c4f99 --- /dev/null +++ b/src/abi/returning.rs @@ -0,0 +1,111 @@ +use crate::prelude::*; +use crate::abi::pass_mode::*; + +pub fn codegen_return_param( + fx: &mut FunctionCx, + ssa_analyzed: &HashMap, + start_ebb: Ebb, +) { + let ret_layout = fx.return_layout(); + let output_pass_mode = get_pass_mode(fx.tcx, fx.return_layout()); + + let ret_param = match output_pass_mode { + PassMode::NoPass => { + fx.local_map + .insert(RETURN_PLACE, CPlace::no_place(ret_layout)); + Empty + } + PassMode::ByVal(_) | PassMode::ByValPair(_, _) => { + let is_ssa = !ssa_analyzed + .get(&RETURN_PLACE) + .unwrap() + .contains(crate::analyze::Flags::NOT_SSA); + + super::local_place(fx, RETURN_PLACE, ret_layout, is_ssa); + + Empty + } + PassMode::ByRef => { + let ret_param = fx.bcx.append_ebb_param(start_ebb, fx.pointer_type); + fx.local_map.insert( + RETURN_PLACE, + CPlace::for_addr(ret_param, ret_layout), + ); + + Single(ret_param) + } + }; + + #[cfg(debug_assertions)] + { + super::add_arg_comment( + fx, + "ret", + RETURN_PLACE, + None, + ret_param, + output_pass_mode, + ssa_analyzed[&RETURN_PLACE], + ret_layout.ty, + ); + } +} + +pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>( + fx: &mut FunctionCx<'_, 'tcx, B>, + fn_sig: FnSig<'tcx>, + ret_place: Option>, + f: impl FnOnce(&mut FunctionCx<'_, 'tcx, B>, Option) -> (Inst, T), +) -> (Inst, T) { + let ret_layout = fx.layout_of(fn_sig.output()); + + let output_pass_mode = get_pass_mode(fx.tcx, ret_layout); + let return_ptr = match output_pass_mode { + PassMode::NoPass => None, + PassMode::ByRef => match ret_place { + Some(ret_place) => Some(ret_place.to_addr(fx)), + None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), + }, + PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, + }; + + let (call_inst, meta) = f(fx, return_ptr); + + match output_pass_mode { + PassMode::NoPass => {} + PassMode::ByVal(_) => { + if let Some(ret_place) = ret_place { + let ret_val = fx.bcx.inst_results(call_inst)[0]; + ret_place.write_cvalue(fx, CValue::by_val(ret_val, ret_layout)); + } + } + PassMode::ByValPair(_, _) => { + if let Some(ret_place) = ret_place { + let ret_val_a = fx.bcx.inst_results(call_inst)[0]; + let ret_val_b = fx.bcx.inst_results(call_inst)[1]; + ret_place.write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_layout)); + } + } + PassMode::ByRef => {} + } + + (call_inst, meta) +} + +pub fn codegen_return(fx: &mut FunctionCx) { + match get_pass_mode(fx.tcx, fx.return_layout()) { + PassMode::NoPass | PassMode::ByRef => { + fx.bcx.ins().return_(&[]); + } + PassMode::ByVal(_) => { + let place = fx.get_local_place(RETURN_PLACE); + let ret_val = place.to_cvalue(fx).load_scalar(fx); + fx.bcx.ins().return_(&[ret_val]); + } + PassMode::ByValPair(_, _) => { + let place = fx.get_local_place(RETURN_PLACE); + let (ret_val_a, ret_val_b) = place.to_cvalue(fx).load_scalar_pair(fx); + fx.bcx.ins().return_(&[ret_val_a, ret_val_b]); + } + } +} From deeae2fce46cba99a2dcce835b85f7d42238c3c8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 12:42:18 +0200 Subject: [PATCH 0858/1566] Small change --- src/abi/mod.rs | 7 +------ src/abi/pass_mode.rs | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index a724ea2d8ec0b..dc6bac0e426be 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -49,12 +49,7 @@ fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: // See https://github.com/rust-lang/rust/blob/37b6a5e5e82497caf5353d9d856e4eb5d14cbe06/src/librustc/ty/layout.rs#L2519-L2572 for more info layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.mk_mut_ptr(tcx.mk_unit()))).unwrap(); } - match get_pass_mode(tcx, layout) { - PassMode::NoPass => Empty, - PassMode::ByVal(clif_ty) => Single(clif_ty), - PassMode::ByValPair(clif_ty_a, clif_ty_b) => Pair(clif_ty_a, clif_ty_b), - PassMode::ByRef => Single(pointer_ty(tcx)), - }.into_iter() + get_pass_mode(tcx, layout).get_param_ty(tcx).into_iter() }).flatten(); let (params, returns) = match get_pass_mode(tcx, tcx.layout_of(ParamEnv::reveal_all().and(output)).unwrap()) { diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index c3a479578bccd..4608562e993e3 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -65,12 +65,12 @@ impl EmptySinglePair { pub use EmptySinglePair::*; impl PassMode { - pub fn get_param_ty(self, fx: &FunctionCx) -> EmptySinglePair { + pub fn get_param_ty(self, tcx: TyCtxt<'_>) -> EmptySinglePair { match self { PassMode::NoPass => Empty, PassMode::ByVal(clif_type) => Single(clif_type), PassMode::ByValPair(a, b) => Pair(a, b), - PassMode::ByRef => Single(fx.pointer_type), + PassMode::ByRef => Single(pointer_ty(tcx)), } } } @@ -141,7 +141,7 @@ pub fn cvalue_for_param<'tcx>( return None; } - let clif_types = pass_mode.get_param_ty(fx); + let clif_types = pass_mode.get_param_ty(fx.tcx); let ebb_params = clif_types.map(|t| fx.bcx.append_ebb_param(start_ebb, t)); #[cfg(debug_assertions)] From d731c4a6a7594cdcbe665b40b4690e109c60bdbf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 14:21:24 +0200 Subject: [PATCH 0859/1566] Move ir comments generation to abi/comments.rs Also list locals stored in ssa vars in the comments --- src/abi/comments.rs | 94 ++++++++++++++++++++++++++++++++++++++++++++ src/abi/mod.rs | 92 ++++--------------------------------------- src/abi/pass_mode.rs | 2 +- src/abi/returning.rs | 22 +++++------ 4 files changed, 112 insertions(+), 98 deletions(-) create mode 100644 src/abi/comments.rs diff --git a/src/abi/comments.rs b/src/abi/comments.rs new file mode 100644 index 0000000000000..674449cf06d52 --- /dev/null +++ b/src/abi/comments.rs @@ -0,0 +1,94 @@ +use std::borrow::Cow; + +use rustc::mir; + +use crate::prelude::*; +use crate::abi::pass_mode::*; + +pub fn add_local_header_comment(fx: &mut FunctionCx) { + fx.add_global_comment(format!( + "msg loc.idx param pass mode ssa flags ty" + )); +} + +pub fn add_arg_comment<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + msg: &str, + local: mir::Local, + local_field: Option, + params: EmptySinglePair, + pass_mode: PassMode, + ssa: crate::analyze::Flags, + ty: Ty<'tcx>, +) { + let local_field = if let Some(local_field) = local_field { + Cow::Owned(format!(".{}", local_field)) + } else { + Cow::Borrowed("") + }; + let params = match params { + Empty => Cow::Borrowed("-"), + Single(param) => Cow::Owned(format!("= {:?}", param)), + Pair(param_a, param_b) => Cow::Owned(format!("= {:?}, {:?}", param_a, param_b)), + }; + let pass_mode = format!("{:?}", pass_mode); + fx.add_global_comment(format!( + "{msg:5}{local:>3}{local_field:<5} {params:10} {pass_mode:36} {ssa:10} {ty:?}", + msg = msg, + local = format!("{:?}", local), + local_field = local_field, + params = params, + pass_mode = pass_mode, + ssa = format!("{:?}", ssa), + ty = ty, + )); +} + +pub fn add_local_place_comments<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + place: CPlace<'tcx>, + local: Local, +) { + let TyLayout { ty, details } = place.layout(); + let ty::layout::LayoutDetails { + size, + align, + abi: _, + variants: _, + fields: _, + largest_niche: _, + } = details; + match *place.inner() { + CPlaceInner::Var(var) => { + assert_eq!(local, var); + fx.add_global_comment(format!( + "ssa {:?}: {:?} size={} align={}, {}", + local, + ty, + size.bytes(), + align.abi.bytes(), + align.pref.bytes(), + )); + } + CPlaceInner::Stack(stack_slot) => fx.add_entity_comment( + stack_slot, + format!( + "{:?}: {:?} size={} align={},{}", + local, + ty, + size.bytes(), + align.abi.bytes(), + align.pref.bytes(), + ), + ), + CPlaceInner::NoPlace => fx.add_global_comment(format!( + "zst {:?}: {:?} size={} align={}, {}", + local, + ty, + size.bytes(), + align.abi.bytes(), + align.pref.bytes(), + )), + CPlaceInner::Addr(_, _) => unreachable!(), + } +} diff --git a/src/abi/mod.rs b/src/abi/mod.rs index dc6bac0e426be..512b1b68ad973 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -1,8 +1,8 @@ +#[cfg(debug_assertions)] +mod comments; mod returning; mod pass_mode; -use std::borrow::Cow; - use rustc_target::spec::abi::Abi; use crate::prelude::*; @@ -193,47 +193,6 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } } -#[cfg(debug_assertions)] -fn add_arg_comment<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - msg: &str, - local: mir::Local, - local_field: Option, - params: EmptySinglePair, - pass_mode: PassMode, - ssa: crate::analyze::Flags, - ty: Ty<'tcx>, -) { - let local_field = if let Some(local_field) = local_field { - Cow::Owned(format!(".{}", local_field)) - } else { - Cow::Borrowed("") - }; - let params = match params { - Empty => Cow::Borrowed("-"), - Single(param) => Cow::Owned(format!("= {:?}", param)), - Pair(param_a, param_b) => Cow::Owned(format!("= {:?}, {:?}", param_a, param_b)), - }; - let pass_mode = format!("{:?}", pass_mode); - fx.add_global_comment(format!( - "{msg:5} {local:>3}{local_field:<5} {params:10} {pass_mode:36} {ssa:10} {ty:?}", - msg = msg, - local = format!("{:?}", local), - local_field = local_field, - params = params, - pass_mode = pass_mode, - ssa = format!("{:?}", ssa), - ty = ty, - )); -} - -#[cfg(debug_assertions)] -fn add_local_header_comment(fx: &mut FunctionCx) { - fx.add_global_comment(format!( - "msg loc.idx param pass mode ssa flags ty" - )); -} - fn local_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, @@ -243,46 +202,12 @@ fn local_place<'tcx>( let place = if is_ssa { CPlace::new_var(fx, local, layout) } else { - let place = CPlace::new_stack_slot(fx, layout.ty); - - #[cfg(debug_assertions)] - { - let TyLayout { ty, details } = layout; - let ty::layout::LayoutDetails { - size, - align, - abi: _, - variants: _, - fields: _, - largest_niche: _, - } = details; - match *place.inner() { - CPlaceInner::Stack(stack_slot) => fx.add_entity_comment( - stack_slot, - format!( - "{:?}: {:?} size={} align={},{}", - local, - ty, - size.bytes(), - align.abi.bytes(), - align.pref.bytes(), - ), - ), - CPlaceInner::NoPlace => fx.add_global_comment(format!( - "zst {:?}: {:?} size={} align={}, {}", - local, - ty, - size.bytes(), - align.abi.bytes(), - align.pref.bytes(), - )), - _ => unreachable!(), - } - } - - place + CPlace::new_stack_slot(fx, layout.ty) }; + #[cfg(debug_assertions)] + self::comments::add_local_place_comments(fx, place, local); + let prev_place = fx.local_map.insert(local, place); debug_assert!(prev_place.is_none()); fx.local_map[&local] @@ -295,10 +220,7 @@ pub fn codegen_fn_prelude( let ssa_analyzed = crate::analyze::analyze(fx); #[cfg(debug_assertions)] - { - fx.add_global_comment(format!("ssa {:?}", ssa_analyzed)); - add_local_header_comment(fx); - } + self::comments::add_local_header_comment(fx); self::returning::codegen_return_param(fx, &ssa_analyzed, start_ebb); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 4608562e993e3..f5c91338842c2 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -145,7 +145,7 @@ pub fn cvalue_for_param<'tcx>( let ebb_params = clif_types.map(|t| fx.bcx.append_ebb_param(start_ebb, t)); #[cfg(debug_assertions)] - super::add_arg_comment( + crate::abi::comments::add_arg_comment( fx, "arg", local, diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 45ba48d7c4f99..465127e9b7196 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -37,18 +37,16 @@ pub fn codegen_return_param( }; #[cfg(debug_assertions)] - { - super::add_arg_comment( - fx, - "ret", - RETURN_PLACE, - None, - ret_param, - output_pass_mode, - ssa_analyzed[&RETURN_PLACE], - ret_layout.ty, - ); - } + crate::abi::comments::add_arg_comment( + fx, + "ret", + RETURN_PLACE, + None, + ret_param, + output_pass_mode, + ssa_analyzed[&RETURN_PLACE], + ret_layout.ty, + ); } pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>( From 76d2e085db71370cb34fc12fc544f46e557e743d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 15:07:15 +0200 Subject: [PATCH 0860/1566] Improve abi ir comments a bit --- src/abi/comments.rs | 31 ++++++++++++++++++------------- src/abi/mod.rs | 9 +++++---- src/abi/pass_mode.rs | 2 -- src/abi/returning.rs | 1 - 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 674449cf06d52..b7932e2ba5804 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -5,20 +5,19 @@ use rustc::mir; use crate::prelude::*; use crate::abi::pass_mode::*; -pub fn add_local_header_comment(fx: &mut FunctionCx) { +pub fn add_args_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(format!( - "msg loc.idx param pass mode ssa flags ty" + "kind loc.idx param pass mode ty" )); } pub fn add_arg_comment<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - msg: &str, + kind: &str, local: mir::Local, local_field: Option, params: EmptySinglePair, pass_mode: PassMode, - ssa: crate::analyze::Flags, ty: Ty<'tcx>, ) { let local_field = if let Some(local_field) = local_field { @@ -33,17 +32,23 @@ pub fn add_arg_comment<'tcx>( }; let pass_mode = format!("{:?}", pass_mode); fx.add_global_comment(format!( - "{msg:5}{local:>3}{local_field:<5} {params:10} {pass_mode:36} {ssa:10} {ty:?}", - msg = msg, + "{kind:5}{local:>3}{local_field:<5} {params:10} {pass_mode:36} {ty:?}", + kind = kind, local = format!("{:?}", local), local_field = local_field, params = params, pass_mode = pass_mode, - ssa = format!("{:?}", ssa), ty = ty, )); } +pub fn add_locals_header_comment(fx: &mut FunctionCx) { + fx.add_global_comment(String::new()); + fx.add_global_comment(format!( + "kind local ty size align (abi,pref)" + )); +} + pub fn add_local_place_comments<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: CPlace<'tcx>, @@ -62,9 +67,9 @@ pub fn add_local_place_comments<'tcx>( CPlaceInner::Var(var) => { assert_eq!(local, var); fx.add_global_comment(format!( - "ssa {:?}: {:?} size={} align={}, {}", - local, - ty, + "ssa {:5} {:20} {:4}b {}, {}", + format!("{:?}", local), + format!("{:?}", ty), size.bytes(), align.abi.bytes(), align.pref.bytes(), @@ -82,9 +87,9 @@ pub fn add_local_place_comments<'tcx>( ), ), CPlaceInner::NoPlace => fx.add_global_comment(format!( - "zst {:?}: {:?} size={} align={}, {}", - local, - ty, + "zst {:5} {:20} {:4}b {}, {}", + format!("{:?}", local), + format!("{:?}", ty), size.bytes(), align.abi.bytes(), align.pref.bytes(), diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 512b1b68ad973..eaf25ef48ec0b 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -220,11 +220,10 @@ pub fn codegen_fn_prelude( let ssa_analyzed = crate::analyze::analyze(fx); #[cfg(debug_assertions)] - self::comments::add_local_header_comment(fx); + self::comments::add_args_header_comment(fx); self::returning::codegen_return_param(fx, &ssa_analyzed, start_ebb); - // None means pass_mode == NoPass enum ArgKind<'tcx> { Normal(Option>), @@ -257,7 +256,6 @@ pub fn codegen_fn_prelude( local, Some(i), arg_ty, - ssa_analyzed[&local], ); params.push(param); } @@ -265,7 +263,7 @@ pub fn codegen_fn_prelude( (local, ArgKind::Spread(params), arg_ty) } else { let param = - cvalue_for_param(fx, start_ebb, local, None, arg_ty, ssa_analyzed[&local]); + cvalue_for_param(fx, start_ebb, local, None, arg_ty); (local, ArgKind::Normal(param), arg_ty) } }) @@ -273,6 +271,9 @@ pub fn codegen_fn_prelude( fx.bcx.switch_to_block(start_ebb); + #[cfg(debug_assertions)] + self::comments::add_locals_header_comment(fx); + for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index f5c91338842c2..411ca23a1f789 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -132,7 +132,6 @@ pub fn cvalue_for_param<'tcx>( local: mir::Local, local_field: Option, arg_ty: Ty<'tcx>, - ssa_flags: crate::analyze::Flags, ) -> Option> { let layout = fx.layout_of(arg_ty); let pass_mode = get_pass_mode(fx.tcx, fx.layout_of(arg_ty)); @@ -152,7 +151,6 @@ pub fn cvalue_for_param<'tcx>( local_field, ebb_params, pass_mode, - ssa_flags, arg_ty, ); diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 465127e9b7196..3d34dbf06e269 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -44,7 +44,6 @@ pub fn codegen_return_param( None, ret_param, output_pass_mode, - ssa_analyzed[&RETURN_PLACE], ret_layout.ty, ); } From 15b9834d7d37d601fd77db11f8852f9ceb0804d0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 15:41:33 +0200 Subject: [PATCH 0861/1566] Don't copy ByRef passed types to local stack slot when not necessary Eg when the local is immutable **and** the type is freeze. This makes the simple raytracer runtime benchmark 1% faster than cg_llvm without optimizations. Before it was 2% slower. cc #691 cc #684 --- example/example.rs | 4 ++++ src/abi/comments.rs | 11 ++++++++++- src/abi/mod.rs | 28 ++++++++++++++++++++++++++++ src/value_and_place.rs | 7 +++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/example/example.rs b/example/example.rs index e8ddc4aaea145..5878e8548d926 100644 --- a/example/example.rs +++ b/example/example.rs @@ -202,3 +202,7 @@ fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 { fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str { &u.1 } + +pub fn reuse_byref_argument_storage(a: (u8, u16, u32)) -> u8 { + a.0 +} diff --git a/src/abi/comments.rs b/src/abi/comments.rs index b7932e2ba5804..77649e40b19ac 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -94,6 +94,15 @@ pub fn add_local_place_comments<'tcx>( align.abi.bytes(), align.pref.bytes(), )), - CPlaceInner::Addr(_, _) => unreachable!(), + CPlaceInner::Addr(addr, None) => fx.add_global_comment(format!( + "reuse {:5} {:20} {:4}b {}, {} storage={}", + format!("{:?}", local), + format!("{:?}", ty), + size.bytes(), + align.abi.bytes(), + align.pref.bytes(), + addr, + )), + CPlaceInner::Addr(_, Some(_)) => unreachable!(), } } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index eaf25ef48ec0b..452776947028c 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -282,6 +282,34 @@ pub fn codegen_fn_prelude( .unwrap() .contains(crate::analyze::Flags::NOT_SSA); + match arg_kind { + ArgKind::Normal(Some(val)) => { + if let Some(addr) = val.try_to_addr() { + let local_decl = &fx.mir.local_decls[local]; + // v this ! is important + let internally_mutable = !val.layout().ty.is_freeze( + fx.tcx, + ParamEnv::reveal_all(), + local_decl.source_info.span, + ); + if local_decl.mutability == mir::Mutability::Not && internally_mutable { + // We wont mutate this argument, so it is fine to borrow the backing storage + // of this argument, to prevent a copy. + + let place = CPlace::for_addr(addr, val.layout()); + + #[cfg(debug_assertions)] + self::comments::add_local_place_comments(fx, place, local); + + let prev_place = fx.local_map.insert(local, place); + debug_assert!(prev_place.is_none()); + continue; + } + } + } + _ => {} + } + let place = local_place(fx, local, layout, is_ssa); match arg_kind { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index b300db2ecfcd4..b1da6e2b4ea0c 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -63,6 +63,13 @@ impl<'tcx> CValue<'tcx> { } } + pub fn try_to_addr(self) -> Option { + match self.0 { + CValueInner::ByRef(addr) => Some(addr), + CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => None, + } + } + /// Load a value with layout.abi of scalar pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; From 5b17cf208330511a0cd9b5f496075f150b7821a4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 30 Aug 2019 17:29:38 +0200 Subject: [PATCH 0862/1566] Add ebobby/simple-raytracer as benchmark cc #684 --- prepare.sh | 10 ++++++++++ test.sh | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/prepare.sh b/prepare.sh index 32cfa4b8c8830..6795558422ff7 100755 --- a/prepare.sh +++ b/prepare.sh @@ -11,3 +11,13 @@ git checkout -- . git checkout 341f207c1071f7290e3f228c710817c280c8dca1 git apply ../crate_patches/regex.patch popd + +git clone https://github.com/ebobby/simple-raytracer || echo "ebobby/simple-raytracer has already been cloned" +pushd simple-raytracer +git checkout -- . +git checkout 804a7a21b9e673a482797aa289a18ed480e4d813 + +# build with cg_llvm for perf comparison +cargo build +mv target/debug/main raytracer_cg_llvm +popd diff --git a/test.sh b/test.sh index b961069e541a5..3b390c386d22f 100755 --- a/test.sh +++ b/test.sh @@ -61,6 +61,14 @@ $RUSTC example/mod_bench.rs --crate-type bin #echo "[BUILD] sysroot in release mode" #./build_sysroot/build_sysroot.sh --release +pushd simple-raytracer +echo "[BENCH] ebobby/simple-raytracer" +cargo clean && ../cargo.sh build +cp ./target/*/debug/main ./raytracer_cg_clif + +hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif +popd + pushd regex echo "[TEST] rust-lang/regex example shootout-regex-dna" ../cargo.sh clean From f481a4b6851f619db4273199074a98b271088173 Mon Sep 17 00:00:00 2001 From: Atul Bhosale Date: Sat, 31 Aug 2019 22:58:09 +0530 Subject: [PATCH 0863/1566] Format code using 'cargo fmt' --- src/abi/comments.rs | 2 +- src/abi/mod.rs | 146 +++++++++++++----------- src/abi/pass_mode.rs | 9 +- src/abi/returning.rs | 8 +- src/archive.rs | 86 +++++++++++---- src/base.rs | 118 ++++++++++++++------ src/cast.rs | 76 +++++-------- src/codegen_i128.rs | 20 +++- src/common.rs | 33 +++--- src/constant.rs | 129 +++++++++++++--------- src/debuginfo.rs | 12 +- src/discriminant.rs | 57 ++++++---- src/driver.rs | 10 +- src/intrinsics.rs | 183 +++++++++++++++++++++---------- src/lib.rs | 39 ++++--- src/linkage.rs | 2 +- src/llvm_intrinsics.rs | 2 +- src/main_shim.rs | 5 +- src/metadata.rs | 72 +++++++----- src/num.rs | 98 +++++++++++++---- src/pretty_clif.rs | 18 +-- src/target_features_whitelist.rs | 10 +- src/trap.rs | 60 +++++++--- src/unsize.rs | 14 +-- src/value_and_place.rs | 108 +++++++++--------- src/vtable.rs | 32 +++--- 26 files changed, 831 insertions(+), 518 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 77649e40b19ac..656731eb97cce 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -2,8 +2,8 @@ use std::borrow::Cow; use rustc::mir; -use crate::prelude::*; use crate::abi::pass_mode::*; +use crate::prelude::*; pub fn add_args_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(format!( diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 452776947028c..0bb422f8cc089 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -1,16 +1,20 @@ #[cfg(debug_assertions)] mod comments; -mod returning; mod pass_mode; +mod returning; use rustc_target::spec::abi::Abi; -use crate::prelude::*; use self::pass_mode::*; +use crate::prelude::*; pub use self::returning::codegen_return; -fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: bool) -> Signature { +fn clif_sig_from_fn_sig<'tcx>( + tcx: TyCtxt<'tcx>, + sig: FnSig<'tcx>, + is_vtable_fn: bool, +) -> Signature { let abi = match sig.abi { Abi::System => { if tcx.sess.target.target.options.is_like_windows { @@ -47,12 +51,18 @@ fn clif_sig_from_fn_sig<'tcx>(tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, is_vtable_fn: if i == 0 && is_vtable_fn { // Virtual calls turn their self param into a thin pointer. // See https://github.com/rust-lang/rust/blob/37b6a5e5e82497caf5353d9d856e4eb5d14cbe06/src/librustc/ty/layout.rs#L2519-L2572 for more info - layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.mk_mut_ptr(tcx.mk_unit()))).unwrap(); + layout = tcx + .layout_of(ParamEnv::reveal_all().and(tcx.mk_mut_ptr(tcx.mk_unit()))) + .unwrap(); } get_pass_mode(tcx, layout).get_param_ty(tcx).into_iter() - }).flatten(); + }) + .flatten(); - let (params, returns) = match get_pass_mode(tcx, tcx.layout_of(ParamEnv::reveal_all().and(output)).unwrap()) { + let (params, returns) = match get_pass_mode( + tcx, + tcx.layout_of(ParamEnv::reveal_all().and(output)).unwrap(), + ) { PassMode::NoPass => (inputs.map(AbiParam::new).collect(), vec![]), PassMode::ByVal(ret_ty) => ( inputs.map(AbiParam::new).collect(), @@ -87,7 +97,8 @@ pub fn get_function_name_and_sig<'tcx>( support_vararg: bool, ) -> (String, Signature) { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); - let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &inst.fn_sig(tcx)); + let fn_sig = + tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &inst.fn_sig(tcx)); if fn_sig.c_variadic && !support_vararg { unimpl!("Variadic function definitions are not yet supported"); } @@ -141,7 +152,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { .module .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); - #[cfg(debug_assertions)] { + #[cfg(debug_assertions)] + { self.add_comment(call_inst, format!("easy_call {}", name)); } let results = self.bcx.inst_results(call_inst); @@ -185,7 +197,10 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } fn self_sig(&self) -> FnSig<'tcx> { - self.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &self.instance.fn_sig(self.tcx)) + self.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &self.instance.fn_sig(self.tcx), + ) } fn return_layout(&self) -> TyLayout<'tcx> { @@ -213,10 +228,7 @@ fn local_place<'tcx>( fx.local_map[&local] } -pub fn codegen_fn_prelude( - fx: &mut FunctionCx<'_, '_, impl Backend>, - start_ebb: Ebb, -) { +pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: Ebb) { let ssa_analyzed = crate::analyze::analyze(fx); #[cfg(debug_assertions)] @@ -250,20 +262,13 @@ pub fn codegen_fn_prelude( let mut params = Vec::new(); for (i, arg_ty) in tupled_arg_tys.types().enumerate() { - let param = cvalue_for_param( - fx, - start_ebb, - local, - Some(i), - arg_ty, - ); + let param = cvalue_for_param(fx, start_ebb, local, Some(i), arg_ty); params.push(param); } (local, ArgKind::Spread(params), arg_ty) } else { - let param = - cvalue_for_param(fx, start_ebb, local, None, arg_ty); + let param = cvalue_for_param(fx, start_ebb, local, None, arg_ty); (local, ArgKind::Normal(param), arg_ty) } }) @@ -354,7 +359,9 @@ pub fn codegen_terminator_call<'tcx>( destination: &Option<(Place<'tcx>, BasicBlock)>, ) { let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); - let sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); + let sig = fx + .tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); let destination = destination .as_ref() @@ -365,7 +372,13 @@ pub fn codegen_terminator_call<'tcx>( ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap(); if fx.tcx.symbol_name(instance).as_str().starts_with("llvm.") { - crate::llvm_intrinsics::codegen_llvm_intrinsic_call(fx, &fx.tcx.symbol_name(instance).as_str(), substs, args, destination); + crate::llvm_intrinsics::codegen_llvm_intrinsic_call( + fx, + &fx.tcx.symbol_name(instance).as_str(), + substs, + args, + destination, + ); return; } @@ -430,7 +443,9 @@ fn codegen_call_inner<'tcx>( args: Vec>, ret_place: Option>, ) { - let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); + let fn_sig = fx + .tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); let instance = match fn_ty.sty { ty::FnDef(def_id, substs) => { @@ -453,7 +468,10 @@ fn codegen_call_inner<'tcx>( let nop_inst = fx.bcx.ins().nop(); fx.add_comment( nop_inst, - format!("virtual call; self arg pass mode: {:?}", get_pass_mode(fx.tcx, args[0].layout())), + format!( + "virtual call; self arg pass mode: {:?}", + get_pass_mode(fx.tcx, args[0].layout()) + ), ); } let (ptr, method) = crate::vtable::get_ptr_and_method_ref(fx, args[0], idx); @@ -461,7 +479,13 @@ fn codegen_call_inner<'tcx>( } // Normal call - Some(_) => (None, args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)).unwrap_or(Empty), false), + Some(_) => ( + None, + args.get(0) + .map(|arg| adjust_arg_for_abi(fx, *arg)) + .unwrap_or(Empty), + false, + ), // Indirect call None => { @@ -474,36 +498,40 @@ fn codegen_call_inner<'tcx>( .load_scalar(fx); ( Some(func), - args.get(0).map(|arg| adjust_arg_for_abi(fx, *arg)).unwrap_or(Empty), + args.get(0) + .map(|arg| adjust_arg_for_abi(fx, *arg)) + .unwrap_or(Empty), false, ) } }; - let (call_inst, call_args) = self::returning::codegen_with_call_return_arg(fx, fn_sig, ret_place, |fx, return_ptr| { - let call_args: Vec = return_ptr - .into_iter() - .chain(first_arg.into_iter()) - .chain( - args.into_iter() - .skip(1) - .map(|arg| adjust_arg_for_abi(fx, arg).into_iter()) - .flatten(), - ) - .collect::>(); + let (call_inst, call_args) = + self::returning::codegen_with_call_return_arg(fx, fn_sig, ret_place, |fx, return_ptr| { + let call_args: Vec = return_ptr + .into_iter() + .chain(first_arg.into_iter()) + .chain( + args.into_iter() + .skip(1) + .map(|arg| adjust_arg_for_abi(fx, arg).into_iter()) + .flatten(), + ) + .collect::>(); - let call_inst = if let Some(func_ref) = func_ref { - let sig = fx - .bcx - .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, is_virtual_call)); - fx.bcx.ins().call_indirect(sig, func_ref, &call_args) - } else { - let func_ref = fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); - fx.bcx.ins().call(func_ref, &call_args) - }; + let call_inst = if let Some(func_ref) = func_ref { + let sig = + fx.bcx + .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, is_virtual_call)); + fx.bcx.ins().call_indirect(sig, func_ref, &call_args) + } else { + let func_ref = + fx.get_function_ref(instance.expect("non-indirect call on non-FnDef type")); + fx.bcx.ins().call(func_ref, &call_args) + }; - (call_inst, call_args) - }); + (call_inst, call_args) + }); // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { @@ -526,10 +554,7 @@ fn codegen_call_inner<'tcx>( } } -pub fn codegen_drop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - drop_place: CPlace<'tcx>, -) { +pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_place: CPlace<'tcx>) { let ty = drop_place.layout().ty; let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty); @@ -542,7 +567,10 @@ pub fn codegen_drop<'tcx>( let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); - let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &drop_fn_ty.fn_sig(fx.tcx)); + let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &drop_fn_ty.fn_sig(fx.tcx), + ); assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); @@ -564,13 +592,7 @@ pub fn codegen_drop<'tcx>( ); drop_place.write_place_ref(fx, arg_place); let arg_value = arg_place.to_cvalue(fx); - codegen_call_inner( - fx, - None, - drop_fn_ty, - vec![arg_value], - None, - ); + codegen_call_inner(fx, None, drop_fn_ty, vec![arg_value], None); } } } diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 411ca23a1f789..64d53566dcc1a 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -50,14 +50,14 @@ impl EmptySinglePair { pub fn assert_single(self) -> T { match self { Single(v) => v, - _ => panic!("Called assert_single on {:?}", self) + _ => panic!("Called assert_single on {:?}", self), } } pub fn assert_pair(self) -> (T, T) { match self { Pair(a, b) => (a, b), - _ => panic!("Called assert_pair on {:?}", self) + _ => panic!("Called assert_pair on {:?}", self), } } } @@ -75,10 +75,7 @@ impl PassMode { } } -pub fn get_pass_mode<'tcx>( - tcx: TyCtxt<'tcx>, - layout: TyLayout<'tcx>, -) -> PassMode { +pub fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> PassMode { assert!(!layout.is_unsized()); if layout.is_zst() { diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 3d34dbf06e269..f827f11df350a 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -1,5 +1,5 @@ -use crate::prelude::*; use crate::abi::pass_mode::*; +use crate::prelude::*; pub fn codegen_return_param( fx: &mut FunctionCx, @@ -27,10 +27,8 @@ pub fn codegen_return_param( } PassMode::ByRef => { let ret_param = fx.bcx.append_ebb_param(start_ebb, fx.pointer_type); - fx.local_map.insert( - RETURN_PLACE, - CPlace::for_addr(ret_param, ret_layout), - ); + fx.local_map + .insert(RETURN_PLACE, CPlace::for_addr(ret_param, ret_layout)); Single(ret_param) } diff --git a/src/archive.rs b/src/archive.rs index 6d76fb14c97c0..7b0cffcfffa1b 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -3,8 +3,8 @@ use std::path::{Path, PathBuf}; use crate::prelude::*; +use rustc_codegen_ssa::back::archive::{find_library, ArchiveBuilder}; use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; -use rustc_codegen_ssa::back::archive::{ArchiveBuilder, find_library}; struct ArchiveConfig<'a> { sess: &'a Session, @@ -16,7 +16,10 @@ struct ArchiveConfig<'a> { #[derive(Debug)] enum ArchiveEntry { - FromArchive { archive_index: usize, entry_index: usize }, + FromArchive { + archive_index: usize, + entry_index: usize, + }, File(PathBuf), } @@ -50,7 +53,10 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let entry = entry.unwrap(); entries.push(( String::from_utf8(entry.header().identifier().to_vec()).unwrap(), - ArchiveEntry::FromArchive { archive_index: 0, entry_index: i }, + ArchiveEntry::FromArchive { + archive_index: 0, + entry_index: i, + }, )); i += 1; } @@ -73,7 +79,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn remove_file(&mut self, name: &str) { - let index = self.entries + let index = self + .entries .iter() .position(|(entry_name, _)| entry_name == name) .expect("Tried to remove file not existing in src archive"); @@ -89,12 +96,23 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { fn add_native_library(&mut self, name: &str) { let location = find_library(name, &self.config.lib_search_paths, self.config.sess); - self.add_archive(location.clone(), |_| false).unwrap_or_else(|e| { - panic!("failed to add native library {}: {}", location.to_string_lossy(), e); - }); + self.add_archive(location.clone(), |_| false) + .unwrap_or_else(|e| { + panic!( + "failed to add native library {}: {}", + location.to_string_lossy(), + e + ); + }); } - fn add_rlib(&mut self, rlib: &Path, name: &str, lto: bool, skip_objects: bool) -> std::io::Result<()> { + fn add_rlib( + &mut self, + rlib: &Path, + name: &str, + lto: bool, + skip_objects: bool, + ) -> std::io::Result<()> { let obj_start = name.to_owned(); self.add_archive(rlib.to_owned(), move |fname: &str| { @@ -147,7 +165,10 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } else if self.config.use_gnu_style_archive { BuilderKind::Gnu(ar::GnuBuilder::new( File::create(&self.config.dst).unwrap(), - self.entries.iter().map(|(name, _)| name.as_bytes().to_vec()).collect(), + self.entries + .iter() + .map(|(name, _)| name.as_bytes().to_vec()) + .collect(), )) } else { BuilderKind::Bsd(ar::Builder::new(File::create(&self.config.dst).unwrap())) @@ -156,8 +177,12 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { // Add all files for (entry_name, entry) in self.entries.into_iter() { match entry { - ArchiveEntry::FromArchive { archive_index, entry_index } => { - let (ref src_archive_path, ref mut src_archive) = self.src_archives[archive_index]; + ArchiveEntry::FromArchive { + archive_index, + entry_index, + } => { + let (ref src_archive_path, ref mut src_archive) = + self.src_archives[archive_index]; let entry = src_archive.jump_to_entry(entry_index).unwrap(); let orig_header = entry.header(); @@ -170,22 +195,33 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { header.set_mode(orig_header.mode()); match builder { - BuilderKind::Bsd(ref mut builder) => builder.append(&header, entry).unwrap(), - BuilderKind::Gnu(ref mut builder) => builder.append(&header, entry).unwrap(), + BuilderKind::Bsd(ref mut builder) => { + builder.append(&header, entry).unwrap() + } + BuilderKind::Gnu(ref mut builder) => { + builder.append(&header, entry).unwrap() + } BuilderKind::NativeAr(archive_file) => { - Command::new("ar").arg("x").arg(src_archive_path).arg(&entry_name).status().unwrap(); + Command::new("ar") + .arg("x") + .arg(src_archive_path) + .arg(&entry_name) + .status() + .unwrap(); add_file_using_ar(archive_file, Path::new(&entry_name)); std::fs::remove_file(entry_name).unwrap(); } } } - ArchiveEntry::File(file) => { - match builder { - BuilderKind::Bsd(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()).unwrap(), - BuilderKind::Gnu(ref mut builder) => builder.append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()).unwrap(), - BuilderKind::NativeAr(archive_file) => add_file_using_ar(archive_file, &file), - } - } + ArchiveEntry::File(file) => match builder { + BuilderKind::Bsd(ref mut builder) => builder + .append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()) + .unwrap(), + BuilderKind::Gnu(ref mut builder) => builder + .append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()) + .unwrap(), + BuilderKind::NativeAr(archive_file) => add_file_using_ar(archive_file, &file), + }, } } @@ -207,7 +243,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { impl<'a> ArArchiveBuilder<'a> { fn add_archive(&mut self, archive_path: PathBuf, mut skip: F) -> std::io::Result<()> - where F: FnMut(&str) -> bool + 'static + where + F: FnMut(&str) -> bool + 'static, { let mut archive = ar::Archive::new(std::fs::File::open(&archive_path)?); let archive_index = self.src_archives.len(); @@ -219,7 +256,10 @@ impl<'a> ArArchiveBuilder<'a> { if !skip(&file_name) { self.entries.push(( file_name, - ArchiveEntry::FromArchive { archive_index, entry_index: i }, + ArchiveEntry::FromArchive { + archive_index, + entry_index: i, + }, )); } i += 1; diff --git a/src/base.rs b/src/base.rs index 3f0892a315ec4..5adf9d3301b57 100644 --- a/src/base.rs +++ b/src/base.rs @@ -72,15 +72,22 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Define function let context = &mut cx.caches.context; context.func = func; - cx.module - .define_function(func_id, context) - .unwrap(); + cx.module.define_function(func_id, context).unwrap(); - let value_ranges = context.build_value_labels_ranges(cx.module.isa()).expect("value location ranges"); + let value_ranges = context + .build_value_labels_ranges(cx.module.isa()) + .expect("value location ranges"); // Write optimized function to file for debugging #[cfg(debug_assertions)] - crate::pretty_clif::write_clif_file(cx.tcx, "opt", instance, &context.func, &clif_comments, Some(&value_ranges)); + crate::pretty_clif::write_clif_file( + cx.tcx, + "opt", + instance, + &context.func, + &clif_comments, + Some(&value_ranges), + ); // Define debuginfo for function let isa = cx.module.isa(); @@ -164,7 +171,14 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } else { fx.bcx.ins().brz(cond, target, &[]); }; - trap_panic(fx, format!("[panic] Assert {:?} at {:?} failed.", msg, bb_data.terminator().source_info.span)); + trap_panic( + fx, + format!( + "[panic] Assert {:?} at {:?} failed.", + msg, + bb_data.terminator().source_info.span + ), + ); } TerminatorKind::SwitchInt { @@ -272,7 +286,8 @@ fn trans_stmt<'tcx>( let rhs = trans_operand(fx, rhs); let res = if !fx.tcx.sess.overflow_checks() { - let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); + let val = + crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); CValue::by_val_pair(val, is_overflow, lval.layout()) } else { @@ -293,9 +308,7 @@ fn trans_stmt<'tcx>( let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); fx.bcx.ins().bint(types::I8, res) } - ty::Uint(_) | ty::Int(_) => { - fx.bcx.ins().bnot(val) - } + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().bnot(val), _ => unimplemented!("un op Not for {:?}", layout.ty), } } @@ -304,7 +317,12 @@ fn trans_stmt<'tcx>( let clif_ty = fx.clif_type(layout.ty).unwrap(); if clif_ty == types::I128 { // FIXME implement it - crate::trap::trap_unreachable_ret_value(fx, layout, "i128 neg is not yet supported").load_scalar(fx) + crate::trap::trap_unreachable_ret_value( + fx, + layout, + "i128 neg is not yet supported", + ) + .load_scalar(fx) } else { let zero = fx.bcx.ins().iconst(clif_ty, 0); fx.bcx.ins().isub(zero, val) @@ -343,10 +361,19 @@ fn trans_stmt<'tcx>( let operand = trans_operand(fx, operand); let from_ty = operand.layout().ty; - fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, 'tcx, impl Backend>, ty: Ty<'tcx>) -> bool { - ty - .builtin_deref(true) - .map(|ty::TypeAndMut {ty: pointee_ty, mutbl: _ }| fx.layout_of(pointee_ty).is_unsized()) + fn is_fat_ptr<'tcx>( + fx: &FunctionCx<'_, 'tcx, impl Backend>, + ty: Ty<'tcx>, + ) -> bool { + ty.builtin_deref(true) + .map( + |ty::TypeAndMut { + ty: pointee_ty, + mutbl: _, + }| { + fx.layout_of(pointee_ty).is_unsized() + }, + ) .unwrap_or(false) } @@ -363,17 +390,27 @@ fn trans_stmt<'tcx>( // enum -> discriminant value assert!(adt_def.is_enum()); match to_ty.sty { - ty::Uint(_) | ty::Int(_) => {}, + ty::Uint(_) | ty::Int(_) => {} _ => unreachable!("cast adt {} -> {}", from_ty, to_ty), } - let discr = crate::discriminant::codegen_get_discriminant(fx, operand, fx.layout_of(to_ty)); + let discr = crate::discriminant::codegen_get_discriminant( + fx, + operand, + fx.layout_of(to_ty), + ); lval.write_cvalue(fx, discr); } else { let to_clif_ty = fx.clif_type(to_ty).unwrap(); let from = operand.load_scalar(fx); - let res = clif_int_or_float_cast(fx, from, type_sign(from_ty), to_clif_ty, type_sign(to_ty)); + let res = clif_int_or_float_cast( + fx, + from, + type_sign(from_ty), + to_clif_ty, + type_sign(to_ty), + ); lval.write_cvalue(fx, CValue::by_val(res, dest_layout)); } } @@ -391,9 +428,7 @@ fn trans_stmt<'tcx>( let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); } - _ => { - bug!("{} cannot be cast to a fn ptr", operand.layout().ty) - } + _ => bug!("{} cannot be cast to a fn ptr", operand.layout().ty), } } Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _ty) => { @@ -403,7 +438,8 @@ fn trans_stmt<'tcx>( Rvalue::Discriminant(place) => { let place = trans_place(fx, place); let value = place.to_cvalue(fx); - let discr = crate::discriminant::codegen_get_discriminant(fx, value, dest_layout); + let discr = + crate::discriminant::codegen_get_discriminant(fx, value, dest_layout); lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => { @@ -478,15 +514,19 @@ fn trans_stmt<'tcx>( StatementKind::InlineAsm(asm) => { use syntax::ast::Name; - let InlineAsm { asm, outputs: _, inputs: _ } = &**asm; + let InlineAsm { + asm, + outputs: _, + inputs: _, + } = &**asm; let rustc::hir::InlineAsm { asm: asm_code, // Name - outputs, // Vec - inputs, // Vec - clobbers, // Vec - volatile, // bool - alignstack, // bool - dialect: _, // syntax::ast::AsmDialect + outputs, // Vec + inputs, // Vec + clobbers, // Vec + volatile, // bool + alignstack, // bool + dialect: _, // syntax::ast::AsmDialect asm_str_style: _, } = asm; match &*asm_code.as_str() { @@ -494,7 +534,10 @@ fn trans_stmt<'tcx>( assert_eq!(inputs, &[Name::intern("{eax}"), Name::intern("{ecx}")]); assert_eq!(outputs.len(), 4); - for (i, c) in (&["={eax}", "={ebx}", "={ecx}", "={edx}"]).iter().enumerate() { + for (i, c) in (&["={eax}", "={ebx}", "={ecx}", "={edx}"]) + .iter() + .enumerate() + { assert_eq!(&outputs[i].constraint.as_str(), c); assert!(!outputs[i].is_rw); assert!(!outputs[i].is_indirect); @@ -505,7 +548,10 @@ fn trans_stmt<'tcx>( assert!(!volatile); assert!(!alignstack); - crate::trap::trap_unimplemented(fx, "__cpuid_count arch intrinsic is not supported"); + crate::trap::trap_unimplemented( + fx, + "__cpuid_count arch intrinsic is not supported", + ); } "xgetbv" => { assert_eq!(inputs, &[Name::intern("{ecx}")]); @@ -565,7 +611,7 @@ pub fn trans_place<'tcx>( let instance = Instance::new(static_.def_id, fx.monomorphize(&substs)); crate::constant::trans_promoted(fx, instance, promoted, static_.ty) } - } + }, }; trans_place_projection(fx, base, &place.projection) @@ -615,7 +661,9 @@ pub fn trans_place_projection<'tcx>( let len = crate::constant::force_eval_const(fx, len) .eval_usize(fx.tcx, ParamEnv::reveal_all()); CPlace::for_addr( - fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + fx.bcx + .ins() + .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), ) } @@ -624,7 +672,9 @@ pub fn trans_place_projection<'tcx>( let (ptr, len) = base.to_addr_maybe_unsized(fx); let len = len.unwrap(); CPlace::for_addr_with_extra( - fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + fx.bcx + .ins() + .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), base.layout(), ) diff --git a/src/cast.rs b/src/cast.rs index 1285bf8c00cab..41503ea86c835 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -40,9 +40,7 @@ pub fn clif_intcast( fx.bcx.ins().ireduce(to, lsb) } } - (_, _) => { - fx.bcx.ins().ireduce(to, val) - } + (_, _) => fx.bcx.ins().ireduce(to, val), } } @@ -71,13 +69,10 @@ pub fn clif_int_or_float_cast( // __floatuntisf: u128 -> f32 // __floatuntidf: u128 -> f64 - let name = format!("__float{sign}ti{flt}f", - sign=if from_signed { - "" - } else { - "un" - }, - flt=match to_ty { + let name = format!( + "__float{sign}ti{flt}f", + sign = if from_signed { "" } else { "un" }, + flt = match to_ty { types::F32 => "s", types::F64 => "d", _ => unreachable!("{:?}", to_ty), @@ -96,11 +91,13 @@ pub fn clif_int_or_float_cast( _ => unreachable!(), }; - return fx.easy_call( - &name, - &[CValue::by_val(from, fx.layout_of(from_rust_ty))], - to_rust_ty, - ).load_scalar(fx); + return fx + .easy_call( + &name, + &[CValue::by_val(from, fx.layout_of(from_rust_ty))], + to_rust_ty, + ) + .load_scalar(fx); } // int-like -> float @@ -117,13 +114,10 @@ pub fn clif_int_or_float_cast( // __fixunssfti: f32 -> u128 // __fixunsdfti: f64 -> u128 - let name = format!("__fix{sign}{flt}fti", - sign=if to_signed { - "" - } else { - "uns" - }, - flt=match from_ty { + let name = format!( + "__fix{sign}{flt}fti", + sign = if to_signed { "" } else { "uns" }, + flt = match from_ty { types::F32 => "s", types::F64 => "d", _ => unreachable!("{:?}", to_ty), @@ -142,11 +136,13 @@ pub fn clif_int_or_float_cast( fx.tcx.types.u128 }; - return fx.easy_call( - &name, - &[CValue::by_val(from, fx.layout_of(from_rust_ty))], - to_rust_ty, - ).load_scalar(fx); + return fx + .easy_call( + &name, + &[CValue::by_val(from, fx.layout_of(from_rust_ty))], + to_rust_ty, + ) + .load_scalar(fx); } // float -> int-like @@ -162,24 +158,12 @@ pub fn clif_int_or_float_cast( let max_val = fx.bcx.ins().iconst(types::I32, max); let val = if to_signed { - let has_underflow = fx.bcx.ins().icmp_imm( - IntCC::SignedLessThan, - val, - min, - ); - let has_overflow = fx.bcx.ins().icmp_imm( - IntCC::SignedGreaterThan, - val, - max, - ); + let has_underflow = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, val, min); + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThan, val, max); let bottom_capped = fx.bcx.ins().select(has_underflow, min_val, val); fx.bcx.ins().select(has_overflow, max_val, bottom_capped) } else { - let has_overflow = fx.bcx.ins().icmp_imm( - IntCC::UnsignedGreaterThan, - val, - max, - ); + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, val, max); fx.bcx.ins().select(has_overflow, max_val, val) }; fx.bcx.ins().ireduce(to_ty, val) @@ -193,12 +177,8 @@ pub fn clif_int_or_float_cast( } else if from_ty.is_float() && to_ty.is_float() { // float -> float match (from_ty, to_ty) { - (types::F32, types::F64) => { - fx.bcx.ins().fpromote(types::F64, from) - } - (types::F64, types::F32) => { - fx.bcx.ins().fdemote(types::F32, from) - } + (types::F32, types::F64) => fx.bcx.ins().fpromote(types::F64, from), + (types::F64, types::F32) => fx.bcx.ins().fdemote(types::F32, from), _ => from, } } else { diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index d8632e2f4aa94..6653b4e2d91f5 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -30,7 +30,7 @@ pub fn maybe_codegen<'tcx>( fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty) } else { fx.easy_call("__rust_u128_addo", &[lhs, rhs], out_ty) - }) + }); } BinOp::Sub => { let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); @@ -38,7 +38,7 @@ pub fn maybe_codegen<'tcx>( fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty) } else { fx.easy_call("__rust_u128_subo", &[lhs, rhs], out_ty) - }) + }); } BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { @@ -50,7 +50,11 @@ pub fn maybe_codegen<'tcx>( fx.easy_call("__rust_u128_mulo", &[lhs, rhs], out_ty) } } else { - let val_ty = if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }; + let val_ty = if is_signed { + fx.tcx.types.i128 + } else { + fx.tcx.types.u128 + }; fx.easy_call("__multi3", &[lhs, rhs], val_ty) }; return Some(res); @@ -111,17 +115,21 @@ pub fn maybe_codegen<'tcx>( Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.i128))) } (BinOp::Shl, _) => { - let val_ty = if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }; + let val_ty = if is_signed { + fx.tcx.types.i128 + } else { + fx.tcx.types.u128 + }; let val = fx.bcx.ins().iconcat(all_zeros, lhs_lsb); Some(CValue::by_val(val, fx.layout_of(val_ty))) } - _ => None + _ => None, }; if let Some(val) = val { if let Some(is_overflow) = is_overflow { let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); let val = val.load_scalar(fx); - return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) + return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))); } else { return Some(val); } diff --git a/src/common.rs b/src/common.rs index 6ed979449fe63..67af9506b79e9 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,7 +1,7 @@ use rustc::ty::layout::{FloatTy, Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; -use cranelift::codegen::ir::{Opcode, InstructionData, ValueDef}; +use cranelift::codegen::ir::{InstructionData, Opcode, ValueDef}; use crate::prelude::*; @@ -35,10 +35,7 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { } } -pub fn clif_type_from_ty<'tcx>( - tcx: TyCtxt<'tcx>, - ty: Ty<'tcx>, -) -> Option { +pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { Some(match ty.sty { ty::Bool => types::I8, ty::Uint(size) => match size { @@ -184,7 +181,8 @@ fn resolve_normal_value_imm(func: &Function, val: Value) -> Option { if let InstructionData::UnaryImm { opcode: Opcode::Iconst, imm, - } = func.dfg[inst] { + } = func.dfg[inst] + { Some(imm.into()) } else { None @@ -199,7 +197,8 @@ fn resolve_128bit_value_imm(func: &Function, val: Value) -> Option { if let InstructionData::Binary { opcode: Opcode::Iconcat, args: [lsb, msb], - } = func.dfg[inst] { + } = func.dfg[inst] + { (lsb, msb) } else { return None; @@ -225,10 +224,9 @@ pub fn resolve_value_imm(func: &Function, val: Value) -> Option { pub fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { assert!(ty.is_int()); let min = match (ty, signed) { - (types::I8 , false) - | (types::I16, false) - | (types::I32, false) - | (types::I64, false) => 0i64, + (types::I8, false) | (types::I16, false) | (types::I32, false) | (types::I64, false) => { + 0i64 + } (types::I8, true) => i8::min_value() as i64, (types::I16, true) => i16::min_value() as i64, (types::I32, true) => i32::min_value() as i64, @@ -287,11 +285,14 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { fn layout_of(&self, ty: Ty<'tcx>) -> TyLayout<'tcx> { let ty = self.monomorphize(&ty); - self.tcx.layout_of(ParamEnv::reveal_all().and(&ty)) - .unwrap_or_else(|e| if let layout::LayoutError::SizeOverflow(_) = e { - self.tcx.sess.fatal(&e.to_string()) - } else { - bug!("failed to get layout for `{}`: {}", ty, e) + self.tcx + .layout_of(ParamEnv::reveal_all().and(&ty)) + .unwrap_or_else(|e| { + if let layout::LayoutError::SizeOverflow(_) = e { + self.tcx.sess.fatal(&e.to_string()) + } else { + bug!("failed to get layout for `{}`: {}", ty, e) + } }) } } diff --git a/src/constant.rs b/src/constant.rs index fbc6be97b0607..1397758c27660 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,12 +1,11 @@ use std::borrow::Cow; use rustc::mir::interpret::{ - read_target_uint, AllocId, GlobalAlloc, Allocation, ConstValue, InterpResult, GlobalId, Scalar, + read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, GlobalId, InterpResult, Scalar, }; -use rustc::ty::{Const, layout::Align}; +use rustc::ty::{layout::Align, Const}; use rustc_mir::interpret::{ - InterpCx, ImmTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, - StackPopCleanup, + ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, }; use cranelift_module::*; @@ -26,11 +25,7 @@ enum TodoItem { } impl ConstantCx { - pub fn finalize( - mut self, - tcx: TyCtxt<'_>, - module: &mut Module, - ) { + pub fn finalize(mut self, tcx: TyCtxt<'_>, module: &mut Module) { //println!("todo {:?}", self.todo); define_all_allocs(tcx, module, &mut self); //println!("done {:?}", self.done); @@ -58,25 +53,20 @@ pub fn trans_promoted<'tcx>( promoted: Promoted, dest_ty: Ty<'tcx>, ) -> CPlace<'tcx> { - match fx - .tcx - .const_eval(ParamEnv::reveal_all().and(GlobalId { - instance, - promoted: Some(promoted), - })) - { + match fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { + instance, + promoted: Some(promoted), + })) { Ok(const_) => { let cplace = trans_const_place(fx, const_); debug_assert_eq!(cplace.layout(), fx.layout_of(dest_ty)); cplace } - Err(_) => { - crate::trap::trap_unreachable_ret_place( - fx, - fx.layout_of(dest_ty), - "[panic] Tried to get value of promoted value with errored during const eval.", - ) - } + Err(_) => crate::trap::trap_unreachable_ret_place( + fx, + fx.layout_of(dest_ty), + "[panic] Tried to get value of promoted value with errored during const eval.", + ), } } @@ -120,13 +110,23 @@ pub fn trans_const_value<'tcx>( } ty::Int(_) => { let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val(fx, ty, rustc::mir::interpret::sign_extend(bits, layout.size)) + CValue::const_val( + fx, + ty, + rustc::mir::interpret::sign_extend(bits, layout.size), + ) } ty::Float(fty) => { let bits = const_.val.try_to_bits(layout.size).unwrap(); let val = match fty { - FloatTy::F32 => fx.bcx.ins().f32const(Ieee32::with_bits(u32::try_from(bits).unwrap())), - FloatTy::F64 => fx.bcx.ins().f64const(Ieee64::with_bits(u64::try_from(bits).unwrap())), + FloatTy::F32 => fx + .bcx + .ins() + .f32const(Ieee32::with_bits(u32::try_from(bits).unwrap())), + FloatTy::F64 => fx + .bcx + .ins() + .f64const(Ieee64::with_bits(u64::try_from(bits).unwrap())), }; CValue::by_val(val, layout) } @@ -170,7 +170,9 @@ fn trans_const_place<'tcx>( )?; let ptr = ecx.allocate(op.layout, MemoryKind::Stack); ecx.copy_op(op, ptr.into())?; - let alloc = ecx.memory().get(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; + let alloc = ecx + .memory() + .get(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) }; let alloc = result().expect("unable to convert ConstValue to Allocation"); @@ -182,9 +184,18 @@ fn trans_const_place<'tcx>( cplace_for_dataid(fx, const_.ty, data_id) } -fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId, align: Align) -> DataId { +fn data_id_for_alloc_id( + module: &mut Module, + alloc_id: AllocId, + align: Align, +) -> DataId { module - .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, Some(align.bytes() as u8)) + .declare_data( + &format!("__alloc_{}", alloc_id.0), + Linkage::Local, + false, + Some(align.bytes() as u8), + ) .unwrap() } @@ -202,16 +213,29 @@ fn data_id_for_static( } else { !ty.is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) }; - let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes(); + let align = tcx + .layout_of(ParamEnv::reveal_all().and(ty)) + .unwrap() + .align + .pref + .bytes(); let data_id = module - .declare_data(&*symbol_name, linkage, is_mutable, Some(align.try_into().unwrap())) + .declare_data( + &*symbol_name, + linkage, + is_mutable, + Some(align.try_into().unwrap()), + ) .unwrap(); if linkage == Linkage::Preemptible { if let ty::RawPtr(_) = ty.sty { } else { - tcx.sess.span_fatal(tcx.def_span(def_id), "must have type `*const T` or `*mut T` due to `#[linkage]` attribute") + tcx.sess.span_fatal( + tcx.def_span(def_id), + "must have type `*const T` or `*mut T` due to `#[linkage]` attribute", + ) } let mut data_ctx = DataContext::new(); @@ -243,11 +267,7 @@ fn cplace_for_dataid<'tcx>( CPlace::for_addr(global_ptr, layout) } -fn define_all_allocs( - tcx: TyCtxt<'_>, - module: &mut Module, - cx: &mut ConstantCx, -) { +fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mut ConstantCx) { let memory = Memory::::new(tcx.at(DUMMY_SP), ()); while let Some(todo_item) = pop_set(&mut cx.todo) { @@ -277,11 +297,16 @@ fn define_all_allocs( _ => bug!("static const eval returned {:#?}", const_), }; - let data_id = data_id_for_static(tcx, module, def_id, if tcx.is_reachable_non_generic(def_id) { - Linkage::Export - } else { - Linkage::Local - }); + let data_id = data_id_for_static( + tcx, + module, + def_id, + if tcx.is_reachable_non_generic(def_id) { + Linkage::Export + } else { + Linkage::Local + }, + ); (data_id, alloc) } }; @@ -395,10 +420,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn find_foreign_static( - _: TyCtxt<'tcx>, - _: DefId, - ) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { + fn find_foreign_static(_: TyCtxt<'tcx>, _: DefId) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { panic!(); } @@ -411,10 +433,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn ptr_to_int( - _: &Memory<'mir, 'tcx, Self>, - _: Pointer<()>, - ) -> InterpResult<'tcx, u64> { + fn ptr_to_int(_: &Memory<'mir, 'tcx, Self>, _: Pointer<()>) -> InterpResult<'tcx, u64> { panic!(); } @@ -473,10 +492,12 @@ pub fn mir_operand_get_const_val<'tcx>( StaticKind::Static => unimplemented!(), StaticKind::Promoted(promoted, substs) => { let instance = Instance::new(static_.def_id, fx.monomorphize(substs)); - fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { - instance, - promoted: Some(*promoted), - })).unwrap() + fx.tcx + .const_eval(ParamEnv::reveal_all().and(GlobalId { + instance, + promoted: Some(*promoted), + })) + .unwrap() } }) } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 74cc58a0c431b..0ded96cec8a58 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -30,11 +30,7 @@ fn line_program_add_file( FileName::Real(path) => { let dir_name = path.parent().unwrap().to_str().unwrap().as_bytes(); let dir_id = if !dir_name.is_empty() { - let dir_name = LineString::new( - dir_name, - line_program.encoding(), - line_strings, - ); + let dir_name = LineString::new(dir_name, line_program.encoding(), line_strings); line_program.add_directory(dir_name) } else { line_program.default_directory() @@ -196,7 +192,11 @@ impl<'tcx> DebugContext<'tcx> { let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { artifact - .declare_with(id.name(), Decl::section(SectionKind::Debug), section.writer.take()) + .declare_with( + id.name(), + Decl::section(SectionKind::Debug), + section.writer.take(), + ) .unwrap(); } Ok(()) diff --git a/src/discriminant.rs b/src/discriminant.rs index ea075ece648a7..ccc474401b62f 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -33,11 +33,12 @@ pub fn codegen_set_discriminant<'tcx>( layout::Variants::Multiple { discr: _, discr_index, - discr_kind: layout::DiscriminantKind::Niche { - dataful_variant, - ref niche_variants, - niche_start, - }, + discr_kind: + layout::DiscriminantKind::Niche { + dataful_variant, + ref niche_variants, + niche_start, + }, variants: _, } => { if variant_index != dataful_variant { @@ -59,7 +60,11 @@ pub fn codegen_get_discriminant<'tcx>( let layout = value.layout(); if layout.abi == layout::Abi::Uninhabited { - return trap_unreachable_ret_value(fx, dest_layout, "[panic] Tried to get discriminant for uninhabited type."); + return trap_unreachable_ret_value( + fx, + dest_layout, + "[panic] Tried to get discriminant for uninhabited type.", + ); } let (discr_scalar, discr_index, discr_kind) = match &layout.variants { @@ -70,9 +75,12 @@ pub fn codegen_get_discriminant<'tcx>( .map_or(u128::from(index.as_u32()), |discr| discr.val); return CValue::const_val(fx, dest_layout.ty, discr_val); } - layout::Variants::Multiple { discr, discr_index, discr_kind, variants: _ } => { - (discr, *discr_index, discr_kind) - } + layout::Variants::Multiple { + discr, + discr_index, + discr_kind, + variants: _, + } => (discr, *discr_index, discr_kind), }; let cast_to = fx.clif_type(dest_layout.ty).unwrap(); @@ -86,7 +94,7 @@ pub fn codegen_get_discriminant<'tcx>( layout::DiscriminantKind::Tag => { let signed = match discr_scalar.value { layout::Int(_, signed) => signed, - _ => false + _ => false, }; let val = clif_intcast(fx, encoded_discr, cast_to, signed); return CValue::by_val(val, dest_layout); @@ -112,11 +120,18 @@ pub fn codegen_get_discriminant<'tcx>( encoded_discr } else { // FIXME handle niche_start > i64::max_value() - fx.bcx.ins().iadd_imm(encoded_discr, -i64::try_from(niche_start).unwrap()) + fx.bcx + .ins() + .iadd_imm(encoded_discr, -i64::try_from(niche_start).unwrap()) }; let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32(); let is_niche = { - codegen_icmp_imm(fx, IntCC::UnsignedLessThanOrEqual, relative_discr, i128::from(relative_max)) + codegen_icmp_imm( + fx, + IntCC::UnsignedLessThanOrEqual, + relative_discr, + i128::from(relative_max), + ) }; // NOTE(eddyb) this addition needs to be performed on the final @@ -135,18 +150,16 @@ pub fn codegen_get_discriminant<'tcx>( } else { clif_intcast(fx, relative_discr, cast_to, false) }; - fx.bcx.ins().iadd_imm( - relative_discr, - i64::from(niche_variants.start().as_u32()), - ) + fx.bcx + .ins() + .iadd_imm(relative_discr, i64::from(niche_variants.start().as_u32())) }; - let dataful_variant = fx.bcx.ins().iconst(cast_to, i64::from(dataful_variant.as_u32())); - let discr = fx.bcx.ins().select( - is_niche, - niche_discr, - dataful_variant, - ); + let dataful_variant = fx + .bcx + .ins() + .iconst(cast_to, i64::from(dataful_variant.as_u32())); + let discr = fx.bcx.ins().select(is_niche, niche_discr, dataful_variant); CValue::by_val(discr, dest_layout) } } diff --git a/src/driver.rs b/src/driver.rs index 0662762e220cd..f78ea1ef76548 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -109,7 +109,9 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { Linkage::NotLinked | Linkage::IncludedFromDylib => {} Linkage::Static => { let name = tcx.crate_name(cnum); - let mut err = tcx.sess.struct_err(&format!("Can't load static lib {}", name.as_str())); + let mut err = tcx + .sess + .struct_err(&format!("Can't load static lib {}", name.as_str())); err.note("rustc_codegen_cranelift can only load dylibs in JIT mode."); err.emit(); } @@ -222,8 +224,10 @@ fn run_aot( .as_str() .to_string(); - let mut metadata_artifact = - faerie::Artifact::new(crate::build_isa(tcx.sess, true).triple().clone(), metadata_cgu_name.clone()); + let mut metadata_artifact = faerie::Artifact::new( + crate::build_isa(tcx.sess, true).triple().clone(), + metadata_cgu_name.clone(), + ); crate::metadata::write_metadata(tcx, &mut metadata_artifact); let tmp_file = tcx diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 354513ac57b0e..215790e5d93ff 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -138,7 +138,10 @@ pub fn lane_type_and_count<'tcx>( assert!(layout.ty.is_simd()); let lane_count = match layout.fields { layout::FieldPlacement::Array { stride: _, count } => u32::try_from(count).unwrap(), - _ => panic!("Non vector type {:?} passed to or returned from simd_* intrinsic {}", layout.ty, intrinsic), + _ => panic!( + "Non vector type {:?} passed to or returned from simd_* intrinsic {}", + layout.ty, intrinsic + ), }; let lane_layout = layout.field(fx, 0); (lane_layout, lane_count) @@ -150,7 +153,13 @@ pub fn simd_for_each_lane<'tcx, B: Backend>( x: CValue<'tcx>, y: CValue<'tcx>, ret: CPlace<'tcx>, - f: impl Fn(&mut FunctionCx<'_, 'tcx, B>, TyLayout<'tcx>, TyLayout<'tcx>, Value, Value) -> CValue<'tcx>, + f: impl Fn( + &mut FunctionCx<'_, 'tcx, B>, + TyLayout<'tcx>, + TyLayout<'tcx>, + Value, + Value, + ) -> CValue<'tcx>, ) { assert_eq!(x.layout(), y.layout()); let layout = x.layout(); @@ -184,7 +193,10 @@ pub fn bool_to_zero_or_max_uint<'tcx>( }; let zero = fx.bcx.ins().iconst(int_ty, 0); - let max = fx.bcx.ins().iconst(int_ty, (u64::max_value() >> (64 - int_ty.bits())) as i64); + let max = fx + .bcx + .ins() + .iconst(int_ty, (u64::max_value() >> (64 - int_ty.bits())) as i64); let mut res = crate::common::codegen_select(&mut fx.bcx, val, max, zero); if ty.is_float() { @@ -196,83 +208,131 @@ pub fn bool_to_zero_or_max_uint<'tcx>( macro_rules! simd_cmp { ($fx:expr, $intrinsic:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { - ty::Uint(_) | ty::Int(_) => codegen_icmp(fx, IntCC::$cc, x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) - }); + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, res_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) | ty::Int(_) => codegen_icmp(fx, IntCC::$cc, x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) + }, + ); }; ($fx:expr, $intrinsic:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { - ty::Uint(_) => codegen_icmp(fx, IntCC::$cc_u, x_lane, y_lane), - ty::Int(_) => codegen_icmp(fx, IntCC::$cc_s, x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) - }); + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, res_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) => codegen_icmp(fx, IntCC::$cc_u, x_lane, y_lane), + ty::Int(_) => codegen_icmp(fx, IntCC::$cc_s, x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) + }, + ); }; - } macro_rules! simd_int_binop { ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { - ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }); + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); }; ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { - ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), - ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }); + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); }; } macro_rules! simd_int_flt_binop { ($fx:expr, $intrinsic:expr, $op:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { - ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), - ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }); + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), + ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); }; ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { - ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), - ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), - ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }); + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), + ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); }; } macro_rules! simd_flt_binop { ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane($fx, $intrinsic, $x, $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { - ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }); - } + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.sty { + ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); + }; } pub fn codegen_intrinsic_call<'tcx>( @@ -297,7 +357,10 @@ pub fn codegen_intrinsic_call<'tcx>( trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); } "transmute" => { - trap_unreachable(fx, "[corruption] Called intrinsic::transmute with uninhabited argument."); + trap_unreachable( + fx, + "[corruption] Called intrinsic::transmute with uninhabited argument.", + ); } _ => unimplemented!("unsupported instrinsic {}", intrinsic), } diff --git a/src/lib.rs b/src/lib.rs index d84a6e8199a5a..f90941d7ba43b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,8 +71,8 @@ mod prelude { }; pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout, VariantIdx}; pub use rustc::ty::{ - self, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, - TypeAndMut, TypeFoldable, + self, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, + TypeFoldable, }; pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, @@ -102,7 +102,7 @@ mod prelude { pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; pub use crate::trap::*; pub use crate::unimpl::{unimpl, with_unimpl_span}; - pub use crate::value_and_place::{CValue, CPlace, CPlaceInner}; + pub use crate::value_and_place::{CPlace, CPlaceInner, CValue}; pub use crate::{Caches, CodegenCx}; pub struct PrintOnPanic String>(pub F); @@ -175,14 +175,18 @@ impl CodegenBackend for CraneliftCodegenBackend { if tcx.sess.opts.actually_rustdoc { // rustdoc needs to be able to document functions that use all the features, so // whitelist them all - tcx.arena.alloc(target_features_whitelist::all_known_features() - .map(|(a, b)| (a.to_string(), b)) - .collect()) + tcx.arena.alloc( + target_features_whitelist::all_known_features() + .map(|(a, b)| (a.to_string(), b)) + .collect(), + ) } else { - tcx.arena.alloc(target_features_whitelist::target_feature_whitelist(tcx.sess) - .iter() - .map(|&(a, b)| (a.to_string(), b)) - .collect()) + tcx.arena.alloc( + target_features_whitelist::target_feature_whitelist(tcx.sess) + .iter() + .map(|&(a, b)| (a.to_string(), b)) + .collect(), + ) } }; } @@ -252,11 +256,16 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box, - module: &mut Module, -) { +pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { use rustc::middle::lang_items::StartFnLangItem; use rustc::session::config::EntryFnType; diff --git a/src/metadata.rs b/src/metadata.rs index 265a160e7a8e4..8d17922725aa7 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,9 +1,9 @@ use std::fs::File; use std::path::Path; +use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc::session::config; use rustc::ty::TyCtxt; -use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc_codegen_ssa::METADATA_FILENAME; use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::rustc_erase_owner; @@ -41,40 +41,44 @@ impl MetadataLoader for CraneliftMetadataLoader { use object::Object; let file = std::fs::read(path).map_err(|e| format!("read:{:?}", e))?; let file = object::File::parse(&file).map_err(|e| format!("parse: {:?}", e))?; - let buf = file.section_data_by_name(".rustc").ok_or("no .rustc section")?.into_owned(); + let buf = file + .section_data_by_name(".rustc") + .ok_or("no .rustc section")? + .into_owned(); let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); Ok(rustc_erase_owner!(buf.map_owner_box())) } } // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 -pub fn write_metadata( - tcx: TyCtxt<'_>, - artifact: &mut faerie::Artifact -) -> EncodedMetadata { - use std::io::Write; - use flate2::Compression; +pub fn write_metadata(tcx: TyCtxt<'_>, artifact: &mut faerie::Artifact) -> EncodedMetadata { use flate2::write::DeflateEncoder; + use flate2::Compression; + use std::io::Write; #[derive(PartialEq, Eq, PartialOrd, Ord)] enum MetadataKind { None, Uncompressed, - Compressed + Compressed, } - let kind = tcx.sess.crate_types.borrow().iter().map(|ty| { - match *ty { - config::CrateType::Executable | - config::CrateType::Staticlib | - config::CrateType::Cdylib => MetadataKind::None, + let kind = tcx + .sess + .crate_types + .borrow() + .iter() + .map(|ty| match *ty { + config::CrateType::Executable + | config::CrateType::Staticlib + | config::CrateType::Cdylib => MetadataKind::None, config::CrateType::Rlib => MetadataKind::Uncompressed, - config::CrateType::Dylib | - config::CrateType::ProcMacro => MetadataKind::Compressed, - } - }).max().unwrap_or(MetadataKind::None); + config::CrateType::Dylib | config::CrateType::ProcMacro => MetadataKind::Compressed, + }) + .max() + .unwrap_or(MetadataKind::None); if kind == MetadataKind::None { return EncodedMetadata::new(); @@ -88,19 +92,27 @@ pub fn write_metadata( assert!(kind == MetadataKind::Compressed); let mut compressed = tcx.metadata_encoding_version(); DeflateEncoder::new(&mut compressed, Compression::fast()) - .write_all(&metadata.raw_data).unwrap(); + .write_all(&metadata.raw_data) + .unwrap(); - artifact.declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)).unwrap(); - artifact.define_with_symbols(".rustc", compressed, { - let mut map = std::collections::BTreeMap::new(); - // FIXME implement faerie elf backend section custom symbols - // For MachO this is necessary to prevent the linker from throwing away the .rustc section, - // but for ELF it isn't. - if tcx.sess.target.target.options.is_like_osx { - map.insert(rustc::middle::exported_symbols::metadata_symbol_name(tcx), 0); - } - map - }).unwrap(); + artifact + .declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)) + .unwrap(); + artifact + .define_with_symbols(".rustc", compressed, { + let mut map = std::collections::BTreeMap::new(); + // FIXME implement faerie elf backend section custom symbols + // For MachO this is necessary to prevent the linker from throwing away the .rustc section, + // but for ELF it isn't. + if tcx.sess.target.target.options.is_like_osx { + map.insert( + rustc::middle::exported_symbols::metadata_symbol_name(tcx), + 0, + ); + } + map + }) + .unwrap(); metadata } diff --git a/src/num.rs b/src/num.rs index ef1ab328be505..7cd99b4b76f1b 100644 --- a/src/num.rs +++ b/src/num.rs @@ -5,11 +5,35 @@ pub fn bin_op_to_intcc(bin_op: BinOp, signed: bool) -> Option { use IntCC::*; Some(match bin_op { Eq => Equal, - Lt => if signed { SignedLessThan } else { UnsignedLessThan}, - Le => if signed { SignedLessThanOrEqual } else { UnsignedLessThanOrEqual}, + Lt => { + if signed { + SignedLessThan + } else { + UnsignedLessThan + } + } + Le => { + if signed { + SignedLessThanOrEqual + } else { + UnsignedLessThanOrEqual + } + } Ne => NotEqual, - Ge => if signed { SignedGreaterThanOrEqual } else { UnsignedGreaterThanOrEqual }, - Gt => if signed { SignedGreaterThan } else { UnsignedGreaterThan }, + Ge => { + if signed { + SignedGreaterThanOrEqual + } else { + UnsignedGreaterThanOrEqual + } + } + Gt => { + if signed { + SignedGreaterThan + } else { + UnsignedGreaterThan + } + } _ => return None, }) } @@ -41,9 +65,9 @@ pub fn codegen_binop<'tcx>( let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); - let (lhs, rhs) = if - (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (in_lhs.layout().ty.sty == fx.tcx.types.i8.sty || in_lhs.layout().ty.sty == fx.tcx.types.i16.sty) + let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) + && (in_lhs.layout().ty.sty == fx.tcx.types.i8.sty + || in_lhs.layout().ty.sty == fx.tcx.types.i16.sty) { // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. ( @@ -64,14 +88,15 @@ pub fn codegen_binop<'tcx>( match in_lhs.layout().ty.sty { ty::Bool => crate::num::trans_bool_binop(fx, bin_op, in_lhs, in_rhs), - ty::Uint(_) | ty::Int(_)=> { - crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs) - } + ty::Uint(_) | ty::Int(_) => crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs), ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs), - ty::RawPtr(..) | ty::FnPtr(..) => { - crate::num::trans_ptr_binop(fx, bin_op, in_lhs, in_rhs) - } - _ => unimplemented!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty), + ty::RawPtr(..) | ty::FnPtr(..) => crate::num::trans_ptr_binop(fx, bin_op, in_lhs, in_rhs), + _ => unimplemented!( + "{:?}({:?}, {:?})", + bin_op, + in_lhs.layout().ty, + in_rhs.layout().ty + ), } } @@ -124,8 +149,20 @@ pub fn trans_int_binop<'tcx>( BinOp::Add => b.iadd(lhs, rhs), BinOp::Sub => b.isub(lhs, rhs), BinOp::Mul => b.imul(lhs, rhs), - BinOp::Div => if signed { b.sdiv(lhs, rhs) } else { b.udiv(lhs, rhs) }, - BinOp::Rem => if signed { b.srem(lhs, rhs) } else { b.urem(lhs, rhs) }, + BinOp::Div => { + if signed { + b.sdiv(lhs, rhs) + } else { + b.udiv(lhs, rhs) + } + } + BinOp::Rem => { + if signed { + b.srem(lhs, rhs) + } else { + b.urem(lhs, rhs) + } + } BinOp::BitXor => b.bxor(lhs, rhs), BinOp::BitAnd => b.band(lhs, rhs), BinOp::BitOr => b.bor(lhs, rhs), @@ -144,7 +181,12 @@ pub fn trans_int_binop<'tcx>( } } // Compare binops handles by `codegen_binop`. - _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty), + _ => unreachable!( + "{:?}({:?}, {:?})", + bin_op, + in_lhs.layout().ty, + in_rhs.layout().ty + ), }; CValue::by_val(val, in_lhs.layout()) @@ -239,7 +281,11 @@ pub fn trans_checked_int_binop<'tcx>( }; let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); - let out_place = CPlace::new_stack_slot(fx, fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter())); + let out_place = CPlace::new_stack_slot( + fx, + fx.tcx + .mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter()), + ); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); @@ -341,14 +387,24 @@ pub fn trans_ptr_binop<'tcx>( BinOp::Lt | BinOp::Le | BinOp::Ge | BinOp::Gt => { let ptr_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_ptr, rhs_ptr); - let ptr_cmp = fx.bcx.ins().icmp(bin_op_to_intcc(bin_op, false).unwrap(), lhs_ptr, rhs_ptr); - let extra_cmp = fx.bcx.ins().icmp(bin_op_to_intcc(bin_op, false).unwrap(), lhs_extra, rhs_extra); + let ptr_cmp = + fx.bcx + .ins() + .icmp(bin_op_to_intcc(bin_op, false).unwrap(), lhs_ptr, rhs_ptr); + let extra_cmp = fx.bcx.ins().icmp( + bin_op_to_intcc(bin_op, false).unwrap(), + lhs_extra, + rhs_extra, + ); fx.bcx.ins().select(ptr_eq, extra_cmp, ptr_cmp) } _ => panic!("bin_op {:?} on ptr", bin_op), }; - CValue::by_val(fx.bcx.ins().bint(types::I8, res), fx.layout_of(fx.tcx.types.bool)) + CValue::by_val( + fx.bcx.ins().bint(types::I8, res), + fx.layout_of(fx.tcx.types.bool), + ) } } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 597789b1f0ba2..0179f51eede3c 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -4,11 +4,7 @@ use std::fmt; use cranelift::codegen::{ entity::SecondaryMap, - ir::{ - self, - entities::AnyEntity, - function::DisplayFunctionAnnotations, - }, + ir::{self, entities::AnyEntity, function::DisplayFunctionAnnotations}, write::{FuncWriter, PlainWriter}, ValueLabelsRanges, }; @@ -82,7 +78,13 @@ impl CommentWriter { global_comments: vec![ format!("symbol {}", tcx.symbol_name(instance).as_str()), format!("instance {:?}", instance), - format!("sig {:?}", tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &instance.fn_sig(tcx))), + format!( + "sig {:?}", + tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &instance.fn_sig(tcx) + ) + ), String::new(), ], entity_comments: HashMap::new(), @@ -218,7 +220,9 @@ pub fn write_clif_file<'tcx>( &mut clif, &func, &DisplayFunctionAnnotations { - isa: Some(&*crate::build_isa(tcx.sess, true /* PIC doesn't matter here */)), + isa: Some(&*crate::build_isa( + tcx.sess, true, /* PIC doesn't matter here */ + )), value_ranges, }, ) diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index 8049b615be227..3626905db997e 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -115,8 +115,10 @@ const WASM_WHITELIST: &[(&str, Option)] = &[ /// /// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this /// iterator! -pub fn all_known_features() -> impl Iterator)> { - ARM_WHITELIST.iter().cloned() +pub fn all_known_features() -> impl Iterator)> { + ARM_WHITELIST + .iter() + .cloned() .chain(AARCH64_WHITELIST.iter().cloned()) .chain(X86_WHITELIST.iter().cloned()) .chain(HEXAGON_WHITELIST.iter().cloned()) @@ -125,9 +127,7 @@ pub fn all_known_features() -> impl Iterator) .chain(WASM_WHITELIST.iter().cloned()) } -pub fn target_feature_whitelist(sess: &Session) - -> &'static [(&'static str, Option)] -{ +pub fn target_feature_whitelist(sess: &Session) -> &'static [(&'static str, Option)] { match &*sess.target.target.arch { "arm" => ARM_WHITELIST, "aarch64" => AARCH64_WHITELIST, diff --git a/src/trap.rs b/src/trap.rs index c4e2cf35766bc..0ff9d39d78a2e 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -1,13 +1,21 @@ use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { - let puts = fx.module.declare_function("puts", Linkage::Import, &Signature { - call_conv: CallConv::SystemV, - params: vec![AbiParam::new(pointer_ty(fx.tcx))], - returns: vec![], - }).unwrap(); + let puts = fx + .module + .declare_function( + "puts", + Linkage::Import, + &Signature { + call_conv: CallConv::SystemV, + params: vec![AbiParam::new(pointer_ty(fx.tcx))], + returns: vec![], + }, + ) + .unwrap(); let puts = fx.module.declare_func_in_func(puts, &mut fx.bcx.func); - #[cfg(debug_assertions)] { + #[cfg(debug_assertions)] + { fx.add_entity_comment(puts, "puts"); } @@ -15,13 +23,22 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); let mut data_ctx = DataContext::new(); data_ctx.define(real_msg.as_bytes().to_vec().into_boxed_slice()); - let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false, None).unwrap(); + let msg_id = fx + .module + .declare_data( + &(symbol_name.as_str().to_string() + msg), + Linkage::Local, + false, + None, + ) + .unwrap(); // Ignore DuplicateDefinition error, as the data will be the same let _ = fx.module.define_data(msg_id, &data_ctx); let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); - #[cfg(debug_assertions)] { + #[cfg(debug_assertions)] + { fx.add_entity_comment(local_msg_id, msg); } let msg_ptr = fx.bcx.ins().global_value(pointer_ty(fx.tcx), local_msg_id); @@ -31,7 +48,10 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms /// Use this when `rustc_codegen_llvm` would insert a call to the panic handler. /// /// Trap code: user0 -pub fn trap_panic(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { +pub fn trap_panic( + fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, + msg: impl AsRef, +) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::User(0)); } @@ -40,7 +60,10 @@ pub fn trap_panic(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, m /// so you can **not** add instructions to it afterwards. /// /// Trap code: user65535 -pub fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { +pub fn trap_unreachable( + fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, + msg: impl AsRef, +) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::User(!0)); } @@ -50,7 +73,10 @@ pub fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backe /// to it afterwards. /// /// Trap code: user65535 -pub fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef) { +pub fn trap_unimplemented( + fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, + msg: impl AsRef, +) { codegen_print(fx, msg.as_ref()); let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); @@ -59,7 +85,11 @@ pub fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Bac /// Like `trap_unreachable` but returns a fake value of the specified type. /// /// Trap code: user65535 -pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef) -> CValue<'tcx> { +pub fn trap_unreachable_ret_value<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, + dest_layout: TyLayout<'tcx>, + msg: impl AsRef, +) -> CValue<'tcx> { trap_unimplemented(fx, msg); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); CValue::by_ref(zero, dest_layout) @@ -68,7 +98,11 @@ pub fn trap_unreachable_ret_value<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl crane /// Like `trap_unreachable` but returns a fake place for the specified type. /// /// Trap code: user65535 -pub fn trap_unreachable_ret_place<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef) -> CPlace<'tcx> { +pub fn trap_unreachable_ret_place<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, + dest_layout: TyLayout<'tcx>, + msg: impl AsRef, +) -> CPlace<'tcx> { trap_unimplemented(fx, msg); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); CPlace::for_addr(zero, dest_layout) diff --git a/src/unsize.rs b/src/unsize.rs index c692f0c88aa5f..cd1b5be99a06d 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -15,15 +15,13 @@ pub fn unsized_info<'tcx>( old_info: Option, ) -> Value { let (source, target) = - fx.tcx.struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); + fx.tcx + .struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); match (&source.sty, &target.sty) { - (&ty::Array(_, len), &ty::Slice(_)) => fx - .bcx - .ins() - .iconst( - fx.pointer_type, - len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64, - ), + (&ty::Array(_, len), &ty::Slice(_)) => fx.bcx.ins().iconst( + fx.pointer_type, + len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64, + ), (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker // traits, and hence never actually require an actual diff --git a/src/value_and_place.rs b/src/value_and_place.rs index b1da6e2b4ea0c..09db4b144002d 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -19,7 +19,10 @@ fn codegen_field<'tcx>( } fn scalar_pair_calculate_b_offset(tcx: TyCtxt<'_>, a_scalar: &Scalar, b_scalar: &Scalar) -> i32 { - let b_offset = a_scalar.value.size(&tcx).align_to(b_scalar.value.align(&tcx).abi); + let b_offset = a_scalar + .value + .size(&tcx) + .align_to(b_scalar.value.align(&tcx).abi); b_offset.bytes().try_into().unwrap() } @@ -88,7 +91,10 @@ impl<'tcx> CValue<'tcx> { } /// Load a value pair with layout.abi of scalar pair - pub fn load_scalar_pair<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Value, Value) { + pub fn load_scalar_pair<'a>( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + ) -> (Value, Value) { let layout = self.1; match self.0 { CValueInner::ByRef(addr) => { @@ -100,12 +106,7 @@ impl<'tcx> CValue<'tcx> { let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); - let val2 = fx.bcx.ins().load( - clif_ty2, - MemFlags::new(), - addr, - b_offset, - ); + let val2 = fx.bcx.ins().load(clif_ty2, MemFlags::new(), addr, b_offset); (val1, val2) } CValueInner::ByVal(_) => bug!("Please use load_scalar for ByVal"), @@ -144,20 +145,29 @@ impl<'tcx> CValue<'tcx> { let val = match ty.sty { ty::TyKind::Uint(UintTy::U128) | ty::TyKind::Int(IntTy::I128) => { let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64); - let msb = fx.bcx.ins().iconst(types::I64, (const_val >> 64) as u64 as i64); + let msb = fx + .bcx + .ins() + .iconst(types::I64, (const_val >> 64) as u64 as i64); fx.bcx.ins().iconcat(lsb, msb) } ty::TyKind::Bool => { - assert!(const_val == 0 || const_val == 1, "Invalid bool 0x{:032X}", const_val); + assert!( + const_val == 0 || const_val == 1, + "Invalid bool 0x{:032X}", + const_val + ); fx.bcx.ins().iconst(types::I8, const_val as i64) } - ty::TyKind::Uint(_) | ty::TyKind::Ref(..) | ty::TyKind::RawPtr(.. )=> { - fx.bcx.ins().iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64) - } - ty::TyKind::Int(_) => { - fx.bcx.ins().iconst(clif_ty, const_val as i128 as i64) - } - _ => panic!("CValue::const_val for non bool/integer/pointer type {:?} is not allowed", ty), + ty::TyKind::Uint(_) | ty::TyKind::Ref(..) | ty::TyKind::RawPtr(..) => fx + .bcx + .ins() + .iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64), + ty::TyKind::Int(_) => fx.bcx.ins().iconst(clif_ty, const_val as i128 as i64), + _ => panic!( + "CValue::const_val for non bool/integer/pointer type {:?} is not allowed", + ty + ), }; CValue::by_val(val, layout) @@ -193,9 +203,9 @@ impl<'tcx> CPlace<'tcx> { } pub fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { - CPlace{ + CPlace { inner: CPlaceInner::NoPlace, - layout + layout, } } @@ -299,7 +309,11 @@ impl<'tcx> CPlace<'tcx> { let from_ty = from.layout().ty; let to_ty = self.layout().ty; - fn assert_assignable<'tcx>(fx: &FunctionCx<'_, 'tcx, impl Backend>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { + fn assert_assignable<'tcx>( + fx: &FunctionCx<'_, 'tcx, impl Backend>, + from_ty: Ty<'tcx>, + to_ty: Ty<'tcx>, + ) { match (&from_ty.sty, &to_ty.sty) { (ty::Ref(_, t, MutImmutable), ty::Ref(_, u, MutImmutable)) | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutImmutable)) @@ -308,9 +322,10 @@ impl<'tcx> CPlace<'tcx> { // &mut T -> &T is allowed // &'a T -> &'b T is allowed } - (ty::Ref(_, _, MutImmutable), ty::Ref(_, _, MutMutable)) => { - panic!("Cant assign value of type {} to place of type {}", from_ty, to_ty) - } + (ty::Ref(_, _, MutImmutable), ty::Ref(_, _, MutMutable)) => panic!( + "Cant assign value of type {} to place of type {}", + from_ty, to_ty + ), (ty::FnPtr(_), ty::FnPtr(_)) => { let from_sig = fx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), @@ -328,14 +343,12 @@ impl<'tcx> CPlace<'tcx> { // fn(&T) -> for<'l> fn(&'l T) is allowed } (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { - let from_traits = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - from_traits, - ); - let to_traits = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - to_traits, - ); + let from_traits = fx + .tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), from_traits); + let to_traits = fx + .tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), to_traits); assert_eq!( from_traits, to_traits, "Can't write trait object of incompatible traits {:?} to place with traits {:?}\n\n{:#?}", @@ -382,24 +395,17 @@ impl<'tcx> CPlace<'tcx> { CValueInner::ByVal(val) => { fx.bcx.ins().store(MemFlags::new(), val, addr, 0); } - CValueInner::ByValPair(value, extra) => { - match dst_layout.abi { - Abi::ScalarPair(ref a_scalar, ref b_scalar) => { - let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); - fx.bcx.ins().store(MemFlags::new(), value, addr, 0); - fx.bcx.ins().store( - MemFlags::new(), - extra, - addr, - b_offset, - ); - } - _ => bug!( - "Non ScalarPair abi {:?} for ByValPair CValue", - dst_layout.abi - ), + CValueInner::ByValPair(value, extra) => match dst_layout.abi { + Abi::ScalarPair(ref a_scalar, ref b_scalar) => { + let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); + fx.bcx.ins().store(MemFlags::new(), value, addr, 0); + fx.bcx.ins().store(MemFlags::new(), extra, addr, b_offset); } - } + _ => bug!( + "Non ScalarPair abi {:?} for ByValPair CValue", + dst_layout.abi + ), + }, CValueInner::ByRef(from_addr) => { let src_layout = from.1; let size = dst_layout.size.bytes(); @@ -468,7 +474,11 @@ impl<'tcx> CPlace<'tcx> { dest.write_cvalue(fx, ptr); } else { let (value, extra) = self.to_addr_maybe_unsized(fx); - let ptr = CValue::by_val_pair(value, extra.expect("unsized type without metadata"), dest.layout()); + let ptr = CValue::by_val_pair( + value, + extra.expect("unsized type without metadata"), + dest.layout(), + ); dest.write_cvalue(fx, ptr); } } diff --git a/src/vtable.rs b/src/vtable.rs index fc601130710bf..155237a402f0c 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -6,10 +6,7 @@ const DROP_FN_INDEX: usize = 0; const SIZE_INDEX: usize = 1; const ALIGN_INDEX: usize = 2; -pub fn drop_fn_of_obj( - fx: &mut FunctionCx<'_, '_, impl Backend>, - vtable: Value, -) -> Value { +pub fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -19,10 +16,7 @@ pub fn drop_fn_of_obj( ) } -pub fn size_of_obj( - fx: &mut FunctionCx<'_, '_, impl Backend>, - vtable: Value, -) -> Value { +pub fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -32,10 +26,7 @@ pub fn size_of_obj( ) } -pub fn min_align_of_obj( - fx: &mut FunctionCx<'_, '_, impl Backend>, - vtable: Value, -) -> Value { +pub fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -86,11 +77,8 @@ fn build_vtable<'tcx>( let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; - let drop_in_place_fn = import_function( - tcx, - fx.module, - Instance::resolve_drop_in_place(tcx, ty), - ); + let drop_in_place_fn = + import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, ty)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -136,7 +124,15 @@ fn build_vtable<'tcx>( &format!("vtable.{:?}.for.{:?}", trait_ref, ty), Linkage::Local, false, - Some(fx.tcx.data_layout.pointer_align.pref.bytes().try_into().unwrap()) + Some( + fx.tcx + .data_layout + .pointer_align + .pref + .bytes() + .try_into() + .unwrap(), + ), ) .unwrap(); From cd0e8622823573342f9b7eac33e239b328ae5d85 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Sep 2019 11:17:01 +0200 Subject: [PATCH 0864/1566] Update ar Fixes #672 --- Cargo.lock | 9 +++------ Cargo.toml | 2 +- src/archive.rs | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b4b995b2ddf4..9c3f0680bab61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,11 +7,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ar" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "arrayvec" @@ -498,7 +495,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", @@ -668,7 +665,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" -"checksum ar 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c1afd66a96a235fa8eeec0ee757ec0d2c0db7cb89b4e04ae159f37952b97bd5" +"checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" diff --git a/Cargo.toml b/Cargo.toml index db374d616ed8c..b47a2449693c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ target-lexicon = "0.4.0" faerie = "0.10.2" #goblin = "0.0.17" -ar = "0.7.0" +ar = "0.8.0" bitflags = "1.1.0" byteorder = "1.2.7" libc = "0.2.53" diff --git a/src/archive.rs b/src/archive.rs index 7b0cffcfffa1b..252976930e4a5 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -39,7 +39,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { sess, dst: output.to_path_buf(), lib_search_paths: archive_search_paths(sess), - use_native_ar: true, // FIXME fix rust-ar to not emit corrupted archive files. + use_native_ar: false, // FIXME test for linux and System V derivatives instead use_gnu_style_archive: !sess.target.target.options.is_like_osx, }; From a2e905f22d52780ae9b8f54ffafb166b28326648 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 2 Sep 2019 19:50:21 +0200 Subject: [PATCH 0865/1566] Correctly align offset for dst field projections Fixes #681 --- example/dst-field-align.rs | 67 ++++++++++++++++++++++++++++++++++++++ src/value_and_place.rs | 54 +++++++++++++++++++++++++----- test.sh | 4 +++ 3 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 example/dst-field-align.rs diff --git a/example/dst-field-align.rs b/example/dst-field-align.rs new file mode 100644 index 0000000000000..6c338e99912ec --- /dev/null +++ b/example/dst-field-align.rs @@ -0,0 +1,67 @@ +// run-pass +#![allow(dead_code)] +struct Foo { + a: u16, + b: T +} + +trait Bar { + fn get(&self) -> usize; +} + +impl Bar for usize { + fn get(&self) -> usize { *self } +} + +struct Baz { + a: T +} + +struct HasDrop { + ptr: Box, + data: T +} + +fn main() { + // Test that zero-offset works properly + let b : Baz = Baz { a: 7 }; + assert_eq!(b.a.get(), 7); + let b : &Baz = &b; + assert_eq!(b.a.get(), 7); + + // Test that the field is aligned properly + let f : Foo = Foo { a: 0, b: 11 }; + assert_eq!(f.b.get(), 11); + let ptr1 : *const u8 = &f.b as *const _ as *const u8; + + let f : &Foo = &f; + let ptr2 : *const u8 = &f.b as *const _ as *const u8; + assert_eq!(f.b.get(), 11); + + // The pointers should be the same + assert_eq!(ptr1, ptr2); + + // Test that nested DSTs work properly + let f : Foo> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; + assert_eq!(f.b.b.get(), 17); + let f : &Foo> = &f; + assert_eq!(f.b.b.get(), 17); + + // Test that get the pointer via destructuring works + + let f : Foo = Foo { a: 0, b: 11 }; + let f : &Foo = &f; + let &Foo { a: _, b: ref bar } = f; + assert_eq!(bar.get(), 11); + + // Make sure that drop flags don't screw things up + + let d : HasDrop> = HasDrop { + ptr: Box::new(0), + data: Baz { a: [1,2,3,4] } + }; + assert_eq!([1,2,3,4], d.data.a); + + let d : &HasDrop> = &d; + assert_eq!(&[1,2,3,4], &d.data.a); +} diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 09db4b144002d..d6ae021a44d54 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -3,18 +3,54 @@ use crate::prelude::*; fn codegen_field<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, base: Value, + extra: Option, layout: TyLayout<'tcx>, field: mir::Field, ) -> (Value, TyLayout<'tcx>) { let field_offset = layout.fields.offset(field.index()); - let field_ty = layout.field(&*fx, field.index()); - if field_offset.bytes() > 0 { - ( - fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), - field_ty, - ) + let field_layout = layout.field(&*fx, field.index()); + + let simple = |fx: &mut FunctionCx<_>| { + if field_offset.bytes() > 0 { + ( + fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), + field_layout, + ) + } else { + (base, field_layout) + } + }; + + if let Some(extra) = extra { + if !field_layout.is_unsized() { + return simple(fx); + } + match field_layout.ty.sty { + ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(fx), + ty::Adt(def, _) if def.repr.packed() => { + assert_eq!(layout.align.abi.bytes(), 1); + return simple(fx); + } + _ => { + // We have to align the offset for DST's + let unaligned_offset = field_offset.bytes(); + let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout.ty, extra); + + let one = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 1); + let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); + let and_lhs = fx.bcx.ins().iadd_imm(align_sub_1, unaligned_offset as i64); + let zero = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 0); + let and_rhs = fx.bcx.ins().isub(zero, unsized_align); + let offset = fx.bcx.ins().band(and_lhs, and_rhs); + + ( + fx.bcx.ins().iadd(base, offset), + field_layout, + ) + } + } } else { - (base, field_ty) + simple(fx) } } @@ -125,7 +161,7 @@ impl<'tcx> CValue<'tcx> { _ => bug!("place_field for {:?}", self), }; - let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + let (field_ptr, field_layout) = codegen_field(fx, base, None, layout, field); CValue::by_ref(field_ptr, field_layout) } @@ -431,7 +467,7 @@ impl<'tcx> CPlace<'tcx> { let layout = self.layout(); let (base, extra) = self.to_addr_maybe_unsized(fx); - let (field_ptr, field_layout) = codegen_field(fx, base, layout, field); + let (field_ptr, field_layout) = codegen_field(fx, base, extra, layout, field); if field_layout.is_unsized() { CPlace::for_addr_with_extra(field_ptr, extra.unwrap(), field_layout) } else { diff --git a/test.sh b/test.sh index 3b390c386d22f..532a96945a622 100755 --- a/test.sh +++ b/test.sh @@ -50,6 +50,10 @@ $RUSTC example/alloc_example.rs --crate-type bin jit std_example example/std_example.rs +echo "[AOT] dst_field_align" +$RUSTC example/dst-field-align.rs -Zmir-opt-level=2 --crate-name dst_field_align --crate-type bin +./target/out/dst_field_align + echo "[AOT] std_example" $RUSTC example/std_example.rs --crate-type bin ./target/out/std_example From bfb49e7d19040dddc0a544fc52dcfb4ec99ab98e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Sep 2019 10:51:00 +0200 Subject: [PATCH 0866/1566] Rustup to rustc 1.39.0-nightly (6e19f3f38 2019-09-06) --- src/abi/mod.rs | 6 +++--- src/base.rs | 2 +- src/constant.rs | 8 ++++---- src/driver.rs | 2 +- src/pretty_clif.rs | 4 ++-- src/trap.rs | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 0bb422f8cc089..f4bb31e126ae2 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -103,7 +103,7 @@ pub fn get_function_name_and_sig<'tcx>( unimpl!("Variadic function definitions are not yet supported"); } let sig = clif_sig_from_fn_sig(tcx, fn_sig, false); - (tcx.symbol_name(inst).as_str().to_string(), sig) + (tcx.symbol_name(inst).name.as_str().to_string(), sig) } /// Instance must be monomorphized @@ -371,10 +371,10 @@ pub fn codegen_terminator_call<'tcx>( let instance = ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap(); - if fx.tcx.symbol_name(instance).as_str().starts_with("llvm.") { + if fx.tcx.symbol_name(instance).name.as_str().starts_with("llvm.") { crate::llvm_intrinsics::codegen_llvm_intrinsic_call( fx, - &fx.tcx.symbol_name(instance).as_str(), + &fx.tcx.symbol_name(instance).name.as_str(), substs, args, destination, diff --git a/src/base.rs b/src/base.rs index 5adf9d3301b57..48fe920204e7b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -570,7 +570,7 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } - _ if fx.tcx.symbol_name(fx.instance).as_str() == "__rust_probestack" => { + _ if fx.tcx.symbol_name(fx.instance).name.as_str() == "__rust_probestack" => { crate::trap::trap_unimplemented(fx, "__rust_probestack is not supported"); } _ => unimpl!("Inline assembly is not supported"), diff --git a/src/constant.rs b/src/constant.rs index 1397758c27660..639bb9e5aded5 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -206,7 +206,7 @@ fn data_id_for_static( linkage: Linkage, ) -> DataId { let instance = Instance::mono(tcx, def_id); - let symbol_name = tcx.symbol_name(instance).as_str(); + let symbol_name = tcx.symbol_name(instance).name.as_str(); let ty = instance.ty(tcx); let is_mutable = if tcx.is_mutable_static(def_id) { true @@ -318,19 +318,19 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let mut data_ctx = DataContext::new(); - let mut bytes = alloc.bytes.to_vec(); + let mut bytes = alloc.inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); // The machO backend of faerie doesn't align data objects correctly unless we do this. while bytes.len() as u64 % 16 != 0 { bytes.push(0xde); } data_ctx.define(bytes.into_boxed_slice()); - for &(offset, (_tag, reloc)) in alloc.relocations.iter() { + for &(offset, (_tag, reloc)) in alloc.relocations().iter() { let addend = { let endianness = tcx.data_layout.endian; let offset = offset.bytes() as usize; let ptr_size = tcx.data_layout.pointer_size; - let bytes = &alloc.bytes[offset..offset + ptr_size.bytes() as usize]; + let bytes = &alloc.inspect_with_undef_and_ptr_outside_interpreter(offset..offset + ptr_size.bytes() as usize); read_target_uint(endianness, bytes).unwrap() }; diff --git a/src/driver.rs b/src/driver.rs index f78ea1ef76548..7c69b0981562a 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -322,7 +322,7 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( match mono_item { MonoItem::Fn(inst) => { let _inst_guard = - PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).as_str())); + PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name.as_str())); debug_assert!(!inst.substs.needs_infer()); let _mir_guard = PrintOnPanic(|| { match inst.def { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 0179f51eede3c..1dd1157bfaa4a 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -76,7 +76,7 @@ impl CommentWriter { pub fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self { CommentWriter { global_comments: vec![ - format!("symbol {}", tcx.symbol_name(instance).as_str()), + format!("symbol {}", tcx.symbol_name(instance).name.as_str()), format!("instance {:?}", instance), format!( "sig {:?}", @@ -205,7 +205,7 @@ pub fn write_clif_file<'tcx>( ) { use std::io::Write; - let symbol_name = tcx.symbol_name(instance).as_str(); + let symbol_name = tcx.symbol_name(instance).name.as_str(); let clif_file_name = format!( "{}/{}__{}.{}.clif", concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), diff --git a/src/trap.rs b/src/trap.rs index 0ff9d39d78a2e..7309332a1571d 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -26,7 +26,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let msg_id = fx .module .declare_data( - &(symbol_name.as_str().to_string() + msg), + &(symbol_name.name.as_str().to_string() + msg), Linkage::Local, false, None, From 629f7ab4a32e6afea7563698ad7278bbd1e67ee4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 20 Aug 2019 13:37:49 +0200 Subject: [PATCH 0867/1566] Don't perform neg overflow checks when they are disabled --- src/base.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/base.rs b/src/base.rs index 48fe920204e7b..68ca6cffbef6c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -162,6 +162,13 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { target, cleanup: _, } => { + if !fx.tcx.sess.overflow_checks() { + if let mir::interpret::PanicInfo::OverflowNeg = *msg { + let target = fx.get_ebb(*target); + fx.bcx.ins().jump(target, &[]); + continue; + } + } let cond = trans_operand(fx, cond).load_scalar(fx); // TODO HACK brz/brnz for i8/i16 is not yet implemented let cond = fx.bcx.ins().uextend(types::I32, cond); From b0e5c78ad2c4e0b7fba996e77972268c5a33a011 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 31 Aug 2019 16:00:46 +0200 Subject: [PATCH 0868/1566] Disable inline assembly in core::hint::black_box --- ...le-inline-assembly-in-hint-spin_loop.patch | 30 ------------ ...3-Disable-inline-assembly-in-libcore.patch | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+), 30 deletions(-) delete mode 100644 patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch create mode 100644 patches/0003-Disable-inline-assembly-in-libcore.patch diff --git a/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch b/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch deleted file mode 100644 index a96ac09f971e0..0000000000000 --- a/patches/0003-Disable-inline-assembly-in-hint-spin_loop.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 50ce3e454d5721cb534a9e9bb73c82246b930bab Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 19 Jan 2019 11:46:43 +0100 -Subject: [PATCH] Disable inline assembly in hint::spin_loop - ---- - src/libcore/hint.rs | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs -index ad5a207..04712b8 100644 ---- a/src/libcore/hint.rs -+++ b/src/libcore/hint.rs -@@ -62,6 +62,7 @@ pub unsafe fn unreachable_unchecked() -> ! { - #[inline] - #[unstable(feature = "renamed_spin_loop", issue = "55002")] - pub fn spin_loop() { -+ /* - #[cfg( - all( - any(target_arch = "x86", target_arch = "x86_64"), -@@ -71,4 +72,5 @@ pub fn spin_loop() { - unsafe { crate::arch::arm::__yield() }; - } - } -+ */ - } --- -2.17.2 (Apple Git-113) - diff --git a/patches/0003-Disable-inline-assembly-in-libcore.patch b/patches/0003-Disable-inline-assembly-in-libcore.patch new file mode 100644 index 0000000000000..527dbda821c94 --- /dev/null +++ b/patches/0003-Disable-inline-assembly-in-libcore.patch @@ -0,0 +1,49 @@ +From 50ce3e454d5721cb534a9e9bb73c82246b930bab Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 19 Jan 2019 11:46:43 +0100 +Subject: [PATCH] Disable inline assembly in libcore + +--- + src/libcore/hint.rs | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs +index ad5a207..04712b8 100644 +--- a/src/libcore/hint.rs ++++ b/src/libcore/hint.rs +@@ -62,6 +62,7 @@ pub unsafe fn unreachable_unchecked() -> ! { + #[inline] + #[unstable(feature = "renamed_spin_loop", issue = "55002")] + pub fn spin_loop() { ++ /* + #[cfg( + all( + any(target_arch = "x86", target_arch = "x86_64"), +@@ -71,4 +72,5 @@ pub fn spin_loop() { + unsafe { crate::arch::arm::__yield() }; + } + } ++ */ + } +diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs +index ce35181..7d3f6a5 100644 +--- a/src/libcore/hint.rs ++++ b/src/libcore/hint.rs +@@ -128,6 +128,7 @@ pub fn black_box(dummy: T) -> T { + // this. LLVM's intepretation of inline assembly is that it's, well, a black + // box. This isn't the greatest implementation since it probably deoptimizes + // more than we want, but it's so far good enough. ++/* + #[cfg(not(any( + target_arch = "asmjs", + all( +@@ -139,6 +140,7 @@ pub fn black_box(dummy: T) -> T { + asm!("" : : "r"(&dummy)); + return dummy; + } ++*/ + + // Not all platforms support inline assembly so try to do something without + // inline assembly which in theory still hinders at least some optimizations +-- +2.17.2 (Apple Git-113) From ce0be229d7fe5935d50368d43229ba8fe9de6795 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Sep 2019 20:07:55 +0200 Subject: [PATCH 0869/1566] Use upstream cranelift --- Cargo.lock | 158 ++++++++++++++++++++++---------------------- Cargo.toml | 10 +-- src/allocator.rs | 11 ++- src/base.rs | 12 ++-- src/codegen_i128.rs | 2 +- src/common.rs | 2 +- src/main_shim.rs | 13 ++-- src/trap.rs | 2 +- 8 files changed, 101 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c3f0680bab61..bbf2431db3d1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,104 +69,104 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-frontend 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-bforest 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-codegen-meta 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-entity" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" [[package]] name = "cranelift-faerie" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "faerie 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.36.0" -source = "git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128#e1f9de3c2b631933e79419bd5626c3f49abaebe1" +version = "0.42.0" +source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" dependencies = [ - "cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-native 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", + "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -199,16 +199,16 @@ dependencies = [ [[package]] name = "faerie" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -286,17 +286,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "goblin" -version = "0.0.23" +version = "0.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -498,17 +488,17 @@ dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-faerie 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "cranelift-simplejit 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)", - "faerie 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -579,7 +569,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "string-interner" -version = "0.6.3" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", @@ -616,6 +606,16 @@ dependencies = [ "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "target-lexicon" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tempfile" version = "3.1.0" @@ -674,20 +674,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "b548a4ee81fccb95919d4e22cfea83c7693ebfd78f0495493178db20b3139da7" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" -"checksum cranelift 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-bforest 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-codegen 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-codegen-meta 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-entity 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-faerie 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-frontend 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-module 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-native 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" -"checksum cranelift-simplejit 0.36.0 (git+https://github.com/bjorn3/cretonne.git?branch=do_not_remove_cg_clif_i128)" = "" +"checksum cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1d2467155f3071b96447d53af110805cadbe9162f5be6c300792fb76c0e54051" +"checksum faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "875d78b92b2a4d9e1e2c7eeccfa30a327d2ee6434db3beb8fd6fd92f41898bc4" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" @@ -696,8 +696,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872" "checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)" = "" -"checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" -"checksum goblin 0.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "ac56b4753b6b8c2e052ca30717e5a09acf1b02a2c1681bf3d883bd660e5d22bd" +"checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" "checksum indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4d6d89e0948bf10c08b9ecc8ac5b83f07f857ebe2c0cbe38de15b4e4f510356" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" @@ -732,10 +731,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum string-interner 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abb38a0d8fe673c40b10b6b75abcb076a958cc10fb894f14993d9737c4c87000" +"checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" +"checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" diff --git a/Cargo.toml b/Cargo.toml index b47a2449693c5..823279d56f5dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,8 @@ crate-type = ["dylib"] cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } -target-lexicon = "0.4.0" -faerie = "0.10.2" +target-lexicon = "0.8.1" +faerie = "0.11.0" #goblin = "0.0.17" ar = "0.8.0" @@ -28,12 +28,6 @@ indexmap = "1.0.2" object = "0.12.0" libloading = "0.5.1" -[patch."https://github.com/CraneStation/cranelift.git"] -cranelift = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } -cranelift-module = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } -cranelift-simplejit = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } -cranelift-faerie = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" } - # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] #cranelift = { path = "../cranelift/cranelift-umbrella" } diff --git a/src/allocator.rs b/src/allocator.rs index b3b2b53444d17..d4a1f1a49faf5 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -73,10 +73,8 @@ pub fn codegen_inner(module: &mut Module, kind: Allocato .unwrap(); let mut ctx = Context::new(); - ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); - { - let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); + ctx.func = { + let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig.clone())); let ebb = bcx.create_ebb(); bcx.switch_to_block(ebb); @@ -92,8 +90,9 @@ pub fn codegen_inner(module: &mut Module, kind: Allocato let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error bcx.ins().return_(&results); bcx.seal_all_blocks(); - bcx.finalize(); - } + bcx.finalize() + }; + module.define_function(func_id, &mut ctx).unwrap(); } } diff --git a/src/base.rs b/src/base.rs index 68ca6cffbef6c..81735ef7a6275 100644 --- a/src/base.rs +++ b/src/base.rs @@ -19,10 +19,8 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( .as_mut() .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig)); - // Make FunctionBuilder - let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); - let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); + // FIXME reuse Function and FunctionBuilder between multiple trans_fn calls + let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig)); // Predefine ebb's let start_ebb = bcx.create_ebb(); @@ -58,6 +56,9 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( codegen_fn_content(&mut fx); }); + fx.bcx.seal_all_blocks(); + let func = fx.bcx.finalize(); + // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; let clif_comments = fx.clif_comments; @@ -238,9 +239,6 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } }; } - - fx.bcx.seal_all_blocks(); - fx.bcx.finalize(); } fn trans_stmt<'tcx>( diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 6653b4e2d91f5..2d2aa7e1a1d71 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -98,7 +98,7 @@ pub fn maybe_codegen<'tcx>( // Optimize `val >> 64`, because compiler_builtins uses it to deconstruct an 128bit // integer into its lsb and msb. // https://github.com/rust-lang-nursery/compiler-builtins/blob/79a6a1603d5672cbb9187ff41ff4d9b5048ac1cb/src/int/mod.rs#L217 - if let Some(64) = resolve_value_imm(fx.bcx.func, rhs_val) { + if let Some(64) = resolve_value_imm(&fx.bcx.func, rhs_val) { let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); let all_zeros = fx.bcx.ins().iconst(types::I64, 0); let val = match (bin_op, is_signed) { diff --git a/src/common.rs b/src/common.rs index 67af9506b79e9..fbb60713bd0d9 100644 --- a/src/common.rs +++ b/src/common.rs @@ -269,7 +269,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub instance: Instance<'tcx>, pub mir: &'tcx Body<'tcx>, - pub bcx: FunctionBuilder<'clif>, + pub bcx: FunctionBuilder, pub ebb_map: HashMap, pub local_map: HashMap>, diff --git a/src/main_shim.rs b/src/main_shim.rs index b619cb9b0adb0..ae2e16690b764 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -56,10 +56,10 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module, module: &mut Module, ms // Ignore DuplicateDefinition error, as the data will be the same let _ = fx.module.define_data(msg_id, &data_ctx); - let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); + let local_msg_id = fx.module.declare_data_in_func(msg_id, &mut fx.bcx.func); #[cfg(debug_assertions)] { fx.add_entity_comment(local_msg_id, msg); From 3a8dd34831904825ffaba50c1cbbf6343cb2059b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 10 Sep 2019 20:37:16 +0200 Subject: [PATCH 0870/1566] Update Cranelift --- Cargo.lock | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bbf2431db3d1d..6f59c62e448fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -87,7 +87,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -95,13 +95,14 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -109,12 +110,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" [[package]] name = "cranelift-faerie" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -127,17 +128,18 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -148,7 +150,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -158,7 +160,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#08475219ca1aa1d23c80e89534f35fbc99fbe0d7" +source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -562,6 +564,11 @@ dependencies = [ "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "smallvec" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "stable_deref_trait" version = "1.1.1" @@ -730,6 +737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" From 3e78ca957ef7ed07f2504f32ea973f248dafcd10 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Sep 2019 20:01:05 +0200 Subject: [PATCH 0871/1566] Rustup to rustc 1.39.0-nightly (f0b58fcf0 2019-09-11) --- build_sysroot/Cargo.toml | 2 +- patches/0019-Workaround-rust-regression.patch | 23 ------------------- 2 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 patches/0019-Workaround-rust-regression.patch diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 1039f4613efc3..24feabb2226c3 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -7,7 +7,7 @@ version = "0.0.0" core = { path = "./sysroot_src/src/libcore" } compiler_builtins = "0.1" alloc = { path = "./sysroot_src/src/liballoc" } -std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind"] } +std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind", "backtrace"] } test = { path = "./sysroot_src/src/libtest" } alloc_system = { path = "./alloc_system" } diff --git a/patches/0019-Workaround-rust-regression.patch b/patches/0019-Workaround-rust-regression.patch deleted file mode 100644 index 524af0b39a62e..0000000000000 --- a/patches/0019-Workaround-rust-regression.patch +++ /dev/null @@ -1,23 +0,0 @@ -From 8956b4fa10af0df2f8912f6116aa1e970dc0283a Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sun, 18 Aug 2019 17:44:47 +0200 -Subject: [PATCH] Workaround rust regression - ---- - src/liballoc/macros.rs | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs -index 0b5e186..250c419 100644 ---- a/src/liballoc/macros.rs -+++ b/src/liballoc/macros.rs -@@ -98,5 +98,5 @@ macro_rules! vec { - #[macro_export] - #[stable(feature = "rust1", since = "1.0.0")] - macro_rules! format { -- ($($arg:tt)*) => ($crate::fmt::format(::core::format_args!($($arg)*))) -+ ($($arg:tt)*) => ($crate::fmt::format(format_args!($($arg)*))) - } --- -2.20.1 (Apple Git-117) - From 48da36d7a88be5040e8be34cc7404deec9aa8ce0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Sep 2019 20:22:02 +0200 Subject: [PATCH 0872/1566] Update dependencies --- Cargo.lock | 120 ++++++++++++++++++++++++----------------------------- Cargo.toml | 3 -- 2 files changed, 54 insertions(+), 69 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f59c62e448fb..c999d444b89ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,7 +20,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.35" +version = "0.3.37" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -34,7 +34,7 @@ name = "backtrace-sys" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -59,7 +59,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.40" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -87,7 +87,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -102,7 +102,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -110,12 +110,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" [[package]] name = "cranelift-faerie" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -128,7 +128,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -139,7 +139,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -150,7 +150,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -160,7 +160,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#302bcf3fbbf61bb404d8cfc206fd8e6d776bf126" +source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -169,7 +169,7 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -187,7 +187,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -206,7 +206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -218,7 +218,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -256,12 +256,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -272,14 +272,14 @@ dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "goblin" version = "0.0.22" -source = "git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83#e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -298,7 +298,7 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -321,8 +321,8 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -346,7 +346,7 @@ name = "miniz-sys" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -366,13 +366,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" version = "0.12.0" -source = "git+https://github.com/gimli-rs/object.git#79ce87e3fd25ef385326655c5ad151e03d456b0a" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)", + "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -412,10 +411,10 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -425,15 +424,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -441,7 +440,7 @@ name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -450,7 +449,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -467,7 +466,7 @@ dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -475,7 +474,7 @@ name = "remove_dir_all" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -496,10 +495,10 @@ dependencies = [ "cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", - "indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.12.0 (git+https://github.com/gimli-rs/object.git)", + "object 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -551,7 +550,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -561,7 +560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -579,7 +578,7 @@ name = "string-interner" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -603,16 +602,6 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "target-lexicon" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "target-lexicon" version = "0.8.1" @@ -633,7 +622,7 @@ dependencies = [ "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -648,12 +637,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasi" -version = "0.5.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -674,12 +663,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" +"checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "b548a4ee81fccb95919d4e22cfea83c7693ebfd78f0495493178db20b3139da7" +"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -700,11 +689,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872" +"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" "checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" -"checksum goblin 0.0.22 (git+https://github.com/m4b/goblin?rev=e57f2d4e3a089dca89c63bcfc0dbde3e6d647f83)" = "" +"checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" -"checksum indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4d6d89e0948bf10c08b9ecc8ac5b83f07f857ebe2c0cbe38de15b4e4f510356" +"checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" @@ -714,7 +703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum object 0.12.0 (git+https://github.com/gimli-rs/object.git)" = "" +"checksum object 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df4af347f5ac3d0e83e78c26be33cd10e8e874dcb68517a909ad802ba50a90b5" "checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" @@ -722,7 +711,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" @@ -735,19 +724,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" +"checksum serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "f4473e8506b213730ff2061073b48fa51dcc66349219e2e7c5608f0296a1d95a" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb" "checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -"checksum wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd5442abcac6525a045cc8c795aedb60da7a2e5e89c7bf18a0d5357849bb23c7" -"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" +"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 823279d56f5dc..b647e7d47c200 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,8 +41,5 @@ libloading = "0.5.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } -[patch.crates-io] -object = { git = "https://github.com/gimli-rs/object.git" } - [profile.dev.overrides."*"] opt-level = 3 From d0614412f2fb298f02466bd5c0fa8de60f176cca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Sep 2019 20:22:09 +0200 Subject: [PATCH 0873/1566] Remove simple-raytracer too in clean_all.sh --- clean_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clean_all.sh b/clean_all.sh index ced73acc57972..a77d1486fe283 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -2,4 +2,4 @@ set -e rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/,Cargo.lock} perf.data{,.old} -rm -rf regex/ +rm -rf regex/ simple-raytracer/ From 78d39117f03f485da92baeaf49b1d338b0422ca5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Sep 2019 20:27:10 +0200 Subject: [PATCH 0874/1566] Update Readme.md --- Readme.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index d26e453b2a25e..0e9f761cce010 100644 --- a/Readme.md +++ b/Readme.md @@ -15,23 +15,24 @@ $ ./test.sh `$cg_clif_dir` is the directory you cloned this repo into in the following instruction. -### Rustc +### Cargo ```bash -$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs +$ $cg_clif_dir/cargo.sh run ``` -### Cargo +### Rustc ```bash -$ RUSTFLAGS="-Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.dylib --sysroot $cg_clif_dir/build_sysroot/sysroot" cargo run +$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs ``` + ## Not yet supported -* Good non-rust abi support ([vectors are passed by-ref](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) +* Good non-rust abi support ([several problems](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) * Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) -* Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444)) +* Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444), not coming soon) * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171), some basic things work) ## Troubleshooting From 3ee184f2aa8c48fdf8d92b35fe72e311d81d9053 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Sep 2019 20:44:48 +0200 Subject: [PATCH 0875/1566] Update object to 0.14.0 --- Cargo.lock | 26 ++++++++------------------ Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c999d444b89ce..650136db8cdc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,16 +276,6 @@ dependencies = [ "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "goblin" -version = "0.0.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "goblin" version = "0.0.24" @@ -365,19 +355,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" -version = "0.12.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.40.2 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-wasm" -version = "0.38.0" +version = "0.40.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -498,7 +489,7 @@ dependencies = [ "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -691,7 +682,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" "checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" -"checksum goblin 0.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "7f55d53401eb2fd30afd025c570b1946b6966344acf21b42e31286f3bf89e6a8" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" @@ -703,8 +693,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum object 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df4af347f5ac3d0e83e78c26be33cd10e8e874dcb68517a909ad802ba50a90b5" -"checksum parity-wasm 0.38.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d7e522a7f994cc4ae32970b1ce0d99ecf91b8e1df080517a26faa6d2e2ee62" +"checksum object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81afbc5773e99efe9533d8a539dfac37e531dcd0f4eeb41584bae03ccf76d4c2" +"checksum parity-wasm 0.40.2 (registry+https://github.com/rust-lang/crates.io-index)" = "49d1e33551976be5345d2ecbfe995830719746c7f0902f0880a13d40e215f851" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" diff --git a/Cargo.toml b/Cargo.toml index b647e7d47c200..f707f92b6ee44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ libc = "0.2.53" tempfile = "3.0.7" gimli = { git = "https://github.com/gimli-rs/gimli.git" } indexmap = "1.0.2" -object = "0.12.0" +object = "0.14.0" libloading = "0.5.1" # Uncomment to use local checkout of cranelift From af4009d8c8b3093655b85c8a7450a3bc7d02eab9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Sep 2019 21:03:26 +0200 Subject: [PATCH 0876/1566] Rustup to rustc 1.39.0-nightly (eb48d6bde 2019-09-12) --- src/archive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/archive.rs b/src/archive.rs index 252976930e4a5..5363c97675c3b 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -94,7 +94,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { )); } - fn add_native_library(&mut self, name: &str) { + fn add_native_library(&mut self, name: syntax::ast::Name) { let location = find_library(name, &self.config.lib_search_paths, self.config.sess); self.add_archive(location.clone(), |_| false) .unwrap_or_else(|e| { From 6ea4cbdf1bbe0a7db018f4acd0258e13734b0338 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Sep 2019 11:21:18 +0200 Subject: [PATCH 0877/1566] Rustup to rustc 1.39.0-nightly (a6946a817 2019-09-13) --- src/analyze.rs | 6 ++- src/base.rs | 136 +++++++++++++++++++++++------------------------- src/constant.rs | 2 +- 3 files changed, 70 insertions(+), 74 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index 2adaa0b718231..63b268597fe5c 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -24,8 +24,10 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap { for bb in fx.mir.basic_blocks().iter() { for stmt in bb.statements.iter() { match &stmt.kind { - Assign(_, rval) => match &**rval { - Rvalue::Ref(_, _, place) => analyze_non_ssa_place(&mut flag_map, place), + Assign(place_and_rval) => match &place_and_rval.1 { + Rvalue::Ref(_, _, place) => { + analyze_non_ssa_place(&mut flag_map, place); + } _ => {} }, _ => {} diff --git a/src/base.rs b/src/base.rs index 81735ef7a6275..f1840f2012575 100644 --- a/src/base.rs +++ b/src/base.rs @@ -267,10 +267,10 @@ fn trans_stmt<'tcx>( let place = trans_place(fx, place); crate::discriminant::codegen_set_discriminant(fx, place, *variant_index); } - StatementKind::Assign(to_place, rval) => { - let lval = trans_place(fx, to_place); + StatementKind::Assign(to_place_and_rval) => { + let lval = trans_place(fx, &to_place_and_rval.0); let dest_layout = lval.layout(); - match &**rval { + match &to_place_and_rval.1 { Rvalue::Use(operand) => { let val = trans_operand(fx, operand); lval.write_cvalue(fx, val); @@ -506,7 +506,7 @@ fn trans_stmt<'tcx>( to.write_cvalue(fx, operand); } } - _ => unimpl!("shouldn't exist at trans {:?}", rval), + _ => unimpl!("shouldn't exist at trans {:?}", to_place_and_rval.1), }, } } @@ -606,7 +606,7 @@ pub fn trans_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: &Place<'tcx>, ) -> CPlace<'tcx> { - let base = match &place.base { + let mut cplace = match &place.base { PlaceBase::Local(local) => fx.get_local_place(*local), PlaceBase::Static(static_) => match static_.kind { StaticKind::Static => { @@ -619,76 +619,70 @@ pub fn trans_place<'tcx>( }, }; - trans_place_projection(fx, base, &place.projection) -} - -pub fn trans_place_projection<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - base: CPlace<'tcx>, - projection: &Option>>, -) -> CPlace<'tcx> { - let projection = if let Some(projection) = projection { - projection - } else { - return base; - }; - - let base = trans_place_projection(fx, base, &projection.base); - - match projection.elem { - ProjectionElem::Deref => base.place_deref(fx), - ProjectionElem::Field(field, _ty) => base.place_field(fx, field), - ProjectionElem::Index(local) => { - let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx); - base.place_index(fx, index) - } - ProjectionElem::ConstantIndex { - offset, - min_length: _, - from_end, - } => { - let index = if !from_end { - fx.bcx.ins().iconst(fx.pointer_type, offset as i64) - } else { - let len = codegen_array_len(fx, base); - fx.bcx.ins().iadd_imm(len, -(offset as i64)) - }; - base.place_index(fx, index) - } - ProjectionElem::Subslice { from, to } => { - // These indices are generated by slice patterns. - // slice[from:-to] in Python terms. - - match base.layout().ty.sty { - ty::Array(elem_ty, len) => { - let elem_layout = fx.layout_of(elem_ty); - let ptr = base.to_addr(fx); - let len = crate::constant::force_eval_const(fx, len) - .eval_usize(fx.tcx, ParamEnv::reveal_all()); - CPlace::for_addr( - fx.bcx - .ins() - .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), - fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), - ) - } - ty::Slice(elem_ty) => { - let elem_layout = fx.layout_of(elem_ty); - let (ptr, len) = base.to_addr_maybe_unsized(fx); - let len = len.unwrap(); - CPlace::for_addr_with_extra( - fx.bcx - .ins() - .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), - fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), - base.layout(), - ) + for elem in &*place.projection { + match *elem { + PlaceElem::Deref => { + cplace = cplace.place_deref(fx); + } + PlaceElem::Field(field, _ty) => { + cplace = cplace.place_field(fx, field); + } + PlaceElem::Index(local) => { + let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx); + cplace = cplace.place_index(fx, index); + } + PlaceElem::ConstantIndex { + offset, + min_length: _, + from_end, + } => { + let index = if !from_end { + fx.bcx.ins().iconst(fx.pointer_type, offset as i64) + } else { + let len = codegen_array_len(fx, cplace); + fx.bcx.ins().iadd_imm(len, -(offset as i64)) + }; + cplace = cplace.place_index(fx, index); + } + PlaceElem::Subslice { from, to } => { + // These indices are generated by slice patterns. + // slice[from:-to] in Python terms. + + match cplace.layout().ty.sty { + ty::Array(elem_ty, len) => { + let elem_layout = fx.layout_of(elem_ty); + let ptr = cplace.to_addr(fx); + let len = crate::constant::force_eval_const(fx, len) + .eval_usize(fx.tcx, ParamEnv::reveal_all()); + cplace = CPlace::for_addr( + fx.bcx + .ins() + .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), + ); + } + ty::Slice(elem_ty) => { + let elem_layout = fx.layout_of(elem_ty); + let (ptr, len) = cplace.to_addr_maybe_unsized(fx); + let len = len.unwrap(); + cplace = CPlace::for_addr_with_extra( + fx.bcx + .ins() + .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), + cplace.layout(), + ); + } + _ => unreachable!(), } - _ => unreachable!(), + } + PlaceElem::Downcast(_adt_def, variant) => { + cplace = cplace.downcast_variant(fx, variant); } } - ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant), } + + cplace } pub fn trans_operand<'tcx>( diff --git a/src/constant.rs b/src/constant.rs index 639bb9e5aded5..f064a2c0a3d4e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -482,7 +482,7 @@ pub fn mir_operand_get_const_val<'tcx>( Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)), }; - assert!(place.projection.is_none()); + assert!(place.projection.is_empty()); let static_ = match &place.base { PlaceBase::Static(static_) => static_, PlaceBase::Local(_) => return None, From 8f12b8754231e63d751616574e82142a6a8ae69b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Sep 2019 12:13:23 +0200 Subject: [PATCH 0878/1566] Implement shl and shr overflow checks cc #6 --- src/num.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/num.rs b/src/num.rs index 7cd99b4b76f1b..417b9b5f7172d 100644 --- a/src/num.rs +++ b/src/num.rs @@ -258,8 +258,10 @@ pub fn trans_checked_int_binop<'tcx>( } BinOp::Shl => { let val = fx.bcx.ins().ishl(lhs, rhs); - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); + let ty = fx.bcx.func.dfg.value_type(val); + let max_shift = i64::from(ty.bits()) - 1; + let has_overflow = + fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift); (val, has_overflow) } BinOp::Shr => { @@ -268,8 +270,10 @@ pub fn trans_checked_int_binop<'tcx>( } else { fx.bcx.ins().sshr(lhs, rhs) }; - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); + let ty = fx.bcx.func.dfg.value_type(val); + let max_shift = i64::from(ty.bits()) - 1; + let has_overflow = + fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift); (val, has_overflow) } _ => bug!( From 554a1aa0ba702d4a438ccd291d882ea3a3d27cd8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Sep 2019 12:49:23 +0200 Subject: [PATCH 0879/1566] Reenable debug assertions for libstd on macOS m4b/faerie#91 has been merged --- build_sysroot/Cargo.toml | 6 ------ example/mini_core_hello_world.rs | 6 +----- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 24feabb2226c3..f28a46245e8cf 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -17,11 +17,5 @@ rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" } rustc-std-workspace-std = { path = "./sysroot_src/src/tools/rustc-std-workspace-std" } -[profile.dev] -# FIXME On macOS statics and promoted constants have the wrong alignment. This causes a debug -# assertion in `copy_nonoverlapping` to panic. -debug-assertions = false - [profile.release] debug = true -debug-assertions = false diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 5d65dd4d94f50..18362ee036b9e 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -137,11 +137,7 @@ fn main() { let slice = &[0, 1] as &[i32]; let slice_ptr = slice as *const [i32] as *const i32; - // FIXME On macOS statics and promoted constants have the wrong alignment. This causes this - // assertion to fail. - if cfg!(not(target_os = "macos")) { - assert_eq!(slice_ptr as usize % 4, 0); - } + assert_eq!(slice_ptr as usize % 4, 0); //return; From b267995f397e84da051e5620e8b200a3e27f992b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Sep 2019 15:15:06 +0200 Subject: [PATCH 0880/1566] Cleanup --- src/driver.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 7c69b0981562a..84f3b1a52344c 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -164,8 +164,7 @@ fn run_aot( module }; - let emit_module = |name: &str, - kind: ModuleKind, + let emit_module = |kind: ModuleKind, mut module: Module, debug: Option| { module.finalize_definitions(); @@ -177,11 +176,11 @@ fn run_aot( let tmp_file = tcx .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, Some(name)); + .temp_path(OutputType::Object, Some(&artifact.name)); let obj = artifact.emit().unwrap(); std::fs::write(&tmp_file, obj).unwrap(); CompiledModule { - name: name.to_string(), + name: artifact.name, kind, object: Some(tmp_file), bytecode: None, @@ -208,7 +207,7 @@ fn run_aot( tcx.sess.abort_if_errors(); - let mut allocator_module = new_module("allocator_shim.o".to_string()); + let mut allocator_module = new_module("allocator_shim".to_string()); let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); rustc_incremental::assert_dep_graph(tcx); @@ -251,14 +250,12 @@ fn run_aot( Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module( - "dummy_name", ModuleKind::Regular, faerie_module, debug, )], allocator_module: if created_alloc_shim { Some(emit_module( - "allocator_shim", ModuleKind::Allocator, allocator_module, None, From c34ada7cca0607831dfae955214bc0b95f2ec312 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Sep 2019 17:53:36 +0200 Subject: [PATCH 0881/1566] Fix foreign type handling --- src/base.rs | 5 ++--- src/common.rs | 18 ++++++++++++++---- src/num.rs | 12 +++--------- src/value_and_place.rs | 16 ++++++++-------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/base.rs b/src/base.rs index f1840f2012575..fe50d2a2dc490 100644 --- a/src/base.rs +++ b/src/base.rs @@ -365,6 +365,7 @@ fn trans_stmt<'tcx>( Rvalue::Cast(CastKind::Misc, operand, to_ty) => { let operand = trans_operand(fx, operand); let from_ty = operand.layout().ty; + let to_ty = fx.monomorphize(to_ty); fn is_fat_ptr<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, @@ -375,9 +376,7 @@ fn trans_stmt<'tcx>( |ty::TypeAndMut { ty: pointee_ty, mutbl: _, - }| { - fx.layout_of(pointee_ty).is_unsized() - }, + }| has_ptr_meta(fx.tcx, pointee_ty), ) .unwrap_or(false) } diff --git a/src/common.rs b/src/common.rs index fbb60713bd0d9..2044930560973 100644 --- a/src/common.rs +++ b/src/common.rs @@ -60,11 +60,11 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option types::F64, }, ty::FnPtr(_) => pointer_ty(tcx), - ty::RawPtr(TypeAndMut { ty, mutbl: _ }) | ty::Ref(_, ty, _) => { - if ty.is_sized(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) { - pointer_ty(tcx) - } else { + ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => { + if has_ptr_meta(tcx, pointee_ty) { return None; + } else { + pointer_ty(tcx) } } ty::Param(_) => bug!("ty param {:?}", ty), @@ -72,6 +72,16 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { + let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc::hir::Mutability::MutImmutable }); + match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi { + Abi::Scalar(_) => false, + Abi::ScalarPair(_, _) => true, + abi => unreachable!("Abi of ptr to {:?} is {:?}???", ty, abi), + } +} + pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: Value) -> Value { let lhs_ty = bcx.func.dfg.value_type(lhs); let rhs_ty = bcx.func.dfg.value_type(rhs); diff --git a/src/num.rs b/src/num.rs index 417b9b5f7172d..442ff48550c71 100644 --- a/src/num.rs +++ b/src/num.rs @@ -347,14 +347,9 @@ pub fn trans_ptr_binop<'tcx>( in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { - let not_fat = match in_lhs.layout().ty.sty { - ty::RawPtr(TypeAndMut { ty, mutbl: _ }) => { - ty.is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all()) - } - ty::FnPtr(..) => true, - _ => bug!("trans_ptr_binop on non ptr"), - }; - if not_fat { + let pointee_ty = in_lhs.layout().ty.builtin_deref(true).unwrap().ty; + + if !has_ptr_meta(fx.tcx, pointee_ty) { match bin_op { BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { let lhs = in_lhs.load_scalar(fx); @@ -364,7 +359,6 @@ pub fn trans_ptr_binop<'tcx>( } BinOp::Offset => { let (base, offset) = (in_lhs, in_rhs.load_scalar(fx)); - let pointee_ty = base.layout().ty.builtin_deref(true).unwrap().ty; let pointee_size = fx.layout_of(pointee_ty).size.bytes(); let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); let base_val = base.load_scalar(fx); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index d6ae021a44d54..caf41bd1425a0 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -136,7 +136,7 @@ impl<'tcx> CValue<'tcx> { CValueInner::ByRef(addr) => { let (a_scalar, b_scalar) = match &layout.abi { layout::Abi::ScalarPair(a, b) => (a, b), - _ => unreachable!(), + _ => unreachable!("load_scalar_pair({:?})", self), }; let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); @@ -496,19 +496,16 @@ impl<'tcx> CPlace<'tcx> { pub fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); - if !inner_layout.is_unsized() { - CPlace::for_addr(self.to_cvalue(fx).load_scalar(fx), inner_layout) - } else { + if has_ptr_meta(fx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); CPlace::for_addr_with_extra(addr, extra, inner_layout) + } else { + CPlace::for_addr(self.to_cvalue(fx).load_scalar(fx), inner_layout) } } pub fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - if !self.layout().is_unsized() { - let ptr = CValue::by_val(self.to_addr(fx), dest.layout()); - dest.write_cvalue(fx, ptr); - } else { + if has_ptr_meta(fx.tcx, self.layout().ty) { let (value, extra) = self.to_addr_maybe_unsized(fx); let ptr = CValue::by_val_pair( value, @@ -516,6 +513,9 @@ impl<'tcx> CPlace<'tcx> { dest.layout(), ); dest.write_cvalue(fx, ptr); + } else { + let ptr = CValue::by_val(self.to_addr(fx), dest.layout()); + dest.write_cvalue(fx, ptr); } } From 77d33c1707277931e81ad0dea058e4bfc0b89b91 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 15 Sep 2019 18:15:40 +0200 Subject: [PATCH 0882/1566] Fix trans_ptr_binop for fn() --- src/num.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/num.rs b/src/num.rs index 442ff48550c71..49df9b3ac9c5e 100644 --- a/src/num.rs +++ b/src/num.rs @@ -347,9 +347,11 @@ pub fn trans_ptr_binop<'tcx>( in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { - let pointee_ty = in_lhs.layout().ty.builtin_deref(true).unwrap().ty; + let is_thin_ptr = in_lhs.layout().ty.builtin_deref(true).map(|TypeAndMut { ty, mutbl: _}| { + !has_ptr_meta(fx.tcx, ty) + }).unwrap_or(true); - if !has_ptr_meta(fx.tcx, pointee_ty) { + if is_thin_ptr { match bin_op { BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { let lhs = in_lhs.load_scalar(fx); @@ -358,6 +360,7 @@ pub fn trans_ptr_binop<'tcx>( return codegen_compare_bin_op(fx, bin_op, false, lhs, rhs); } BinOp::Offset => { + let pointee_ty = in_lhs.layout().ty.builtin_deref(true).unwrap().ty; let (base, offset) = (in_lhs, in_rhs.load_scalar(fx)); let pointee_size = fx.layout_of(pointee_ty).size.bytes(); let ptr_diff = fx.bcx.ins().imul_imm(offset, pointee_size as i64); From 41a54f584a705a84bded64c83d2328f07cb57ac5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2019 04:54:02 +0000 Subject: [PATCH 0883/1566] Bump rand from 0.7.0 to 0.7.1 Bumps [rand](https://github.com/rust-random/rand) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand/compare/0.7.0...0.7.1) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 650136db8cdc5..49c89d1ad6bda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -399,7 +399,7 @@ dependencies = [ [[package]] name = "rand" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -610,7 +610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -699,7 +699,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" +"checksum rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "59cea0d944b32347a1863e95942fd6ebdb486afb4f038119494f2860380c1d51" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" From a9ff5d91aa6977c700b68821b717cc7d22c4e433 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2019 04:54:31 +0000 Subject: [PATCH 0884/1566] Bump cranelift from `4c7e3c3` to `8945b82` Bumps [cranelift](https://github.com/CraneStation/cranelift) from `4c7e3c3` to `8945b82`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/4c7e3c3f1e338b9a0732fff00711c1c970e80459...8945b82f92642f621d32fead437abd174b52f709) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 650136db8cdc5..822f9186fed1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -87,7 +87,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -102,7 +102,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -110,12 +110,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" [[package]] name = "cranelift-faerie" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -128,7 +128,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -139,7 +139,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -150,7 +150,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -160,7 +160,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#4c7e3c3f1e338b9a0732fff00711c1c970e80459" +source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" dependencies = [ "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", From 2e2c8f8bbfbdbbaa94066031a223e138a8aad573 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Sep 2019 09:54:23 +0200 Subject: [PATCH 0885/1566] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 0e9f761cce010..acd14b09254ba 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ -# Work in progress cranelift codegen backend for rust +# WIP Cranelift codegen backend for rust -> ⚠⚠⚠ This doesn't do much useful yet ⚠⚠⚠ +> ⚠⚠⚠ Threads and certain kinds of FFI don't work yet. ⚠⚠⚠ ## Building From fdfb1eda2cc959259bbfa1882f921ee60264b62c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Sep 2019 11:30:29 +0200 Subject: [PATCH 0886/1566] Rustup to rustc 1.39.0-nightly (97e58c0d3 2019-09-20) --- src/abi/mod.rs | 2 +- src/intrinsics.rs | 55 ++++++++++++----------------------------------- 2 files changed, 15 insertions(+), 42 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f4bb31e126ae2..f5d5445dab445 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -384,7 +384,7 @@ pub fn codegen_terminator_call<'tcx>( match instance.def { InstanceDef::Intrinsic(_) => { - crate::intrinsics::codegen_intrinsic_call(fx, def_id, substs, args, destination); + crate::intrinsics::codegen_intrinsic_call(fx, instance, args, destination); return; } InstanceDef::DropGlue(_, None) => { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 215790e5d93ff..21bd8365eb2b5 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1,7 +1,5 @@ use crate::prelude::*; -use rustc::ty::subst::SubstsRef; - macro intrinsic_pat { (_) => { _ @@ -337,11 +335,13 @@ macro_rules! simd_flt_binop { pub fn codegen_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - def_id: DefId, - substs: SubstsRef<'tcx>, + instance: Instance<'tcx>, args: &[mir::Operand<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, ) { + let def_id = instance.def_id(); + let substs = instance.substs; + let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; @@ -368,7 +368,6 @@ pub fn codegen_intrinsic_call<'tcx>( } }; - let u64_layout = fx.layout_of(fx.tcx.types.u64); let usize_layout = fx.layout_of(fx.tcx.types.usize); call_intrinsic_match! { @@ -448,11 +447,6 @@ pub fn codegen_intrinsic_call<'tcx>( let discr = crate::discriminant::codegen_get_discriminant(fx, val, ret.layout()); ret.write_cvalue(fx, discr); }; - size_of, () { - let size_of = fx.layout_of(T).size.bytes(); - let size_of = CValue::const_val(fx, usize_layout.ty, size_of.into()); - ret.write_cvalue(fx, size_of); - }; size_of_val, (c ptr) { let layout = fx.layout_of(T); let size = if layout.is_unsized() { @@ -467,11 +461,6 @@ pub fn codegen_intrinsic_call<'tcx>( }; ret.write_cvalue(fx, CValue::by_val(size, usize_layout)); }; - min_align_of, () { - let min_align = fx.layout_of(T).align.abi.bytes(); - let min_align = CValue::const_val(fx, usize_layout.ty, min_align.into()); - ret.write_cvalue(fx, min_align); - }; min_align_of_val, (c ptr) { let layout = fx.layout_of(T); let align = if layout.is_unsized() { @@ -486,23 +475,6 @@ pub fn codegen_intrinsic_call<'tcx>( }; ret.write_cvalue(fx, CValue::by_val(align, usize_layout)); }; - pref_align_of, () { - let pref_align = fx.layout_of(T).align.pref.bytes(); - let pref_align = CValue::const_val(fx, usize_layout.ty, pref_align.into()); - ret.write_cvalue(fx, pref_align); - }; - - - type_id, () { - let type_id = fx.tcx.type_id_hash(T); - let type_id = CValue::const_val(fx, u64_layout.ty, type_id.into()); - ret.write_cvalue(fx, type_id); - }; - type_name, () { - let type_name = fx.tcx.type_name(T); - let type_name = crate::constant::trans_const_value(fx, type_name); - ret.write_cvalue(fx, type_name); - }; _ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) { // FIXME trap on overflow @@ -814,15 +786,6 @@ pub fn codegen_intrinsic_call<'tcx>( let res = CValue::by_val(swap(&mut fx.bcx, arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - needs_drop, () { - let needs_drop = if T.needs_drop(fx.tcx, ParamEnv::reveal_all()) { - 1 - } else { - 0 - }; - let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop); - ret.write_cvalue(fx, needs_drop); - }; panic_if_uninhabited, () { if fx.layout_of(T).abi.is_uninhabited() { crate::trap::trap_panic(fx, "[panic] Called intrinsic::panic_if_uninhabited for uninhabited type."); @@ -843,6 +806,16 @@ pub fn codegen_intrinsic_call<'tcx>( dest.write_cvalue(fx, val); }; + size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () { + let gid = rustc::mir::interpret::GlobalId { + instance, + promoted: None, + }; + let const_val = fx.tcx.const_eval(ParamEnv::reveal_all().and(gid)).unwrap(); + let val = crate::constant::trans_const_value(fx, const_val); + ret.write_cvalue(fx, val); + }; + _ if intrinsic.starts_with("atomic_fence"), () {}; _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; _ if intrinsic.starts_with("atomic_load"), (c ptr) { From f2c574aebf1f6c763a3e2b62e44b60135a05cd9b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Sep 2019 11:32:11 +0200 Subject: [PATCH 0887/1566] Add extern type pointer cast tests --- example/mini_core_hello_world.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 18362ee036b9e..76387e8c036b0 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -1,6 +1,6 @@ // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs -#![feature(no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns, never_type, linkage)] +#![feature(no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns, never_type, linkage, extern_types)] #![no_core] #![allow(dead_code)] @@ -262,6 +262,20 @@ fn main() { assert_eq!(*ANOTHER_STATIC, 42); check_niche_behavior(); + + extern "C" { + type ExternType; + } + + struct ExternTypeWrapper { + _a: ExternType, + } + + let nullptr = 0 as *const (); + let extern_nullptr = nullptr as *const ExternTypeWrapper; + extern_nullptr as *const (); + let slice_ptr = &[] as *const [u8]; + slice_ptr as *const u8; } // Copied ui/issues/issue-61696.rs From 3a7aa6c0fafa5d0b4954b2b48897db73860da166 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Sep 2019 14:27:38 +0200 Subject: [PATCH 0888/1566] Reduce time required to build from scratch in dev mode * Disable wasm reading of object * Use tempfile bundled with rustc * Don't optimize and don't generate debuginfo for build scripts and some build deps Before: 354s (5m 45s) After: 207s (3m 27s) --- Cargo.lock | 117 ----------------------------------------------------- Cargo.toml | 32 +++++++++++++-- src/lib.rs | 1 + 3 files changed, 30 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 653b962419c04..e5bf8121cfc61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,15 +48,6 @@ name = "byteorder" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "c2-chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cc" version = "1.0.45" @@ -254,16 +245,6 @@ name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "getrandom" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "gimli" version = "0.19.0" @@ -296,11 +277,6 @@ name = "itoa" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.62" @@ -360,27 +336,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-wasm 0.40.2 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parity-wasm" -version = "0.40.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "plain" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "ppv-lite86" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "proc-macro2" version = "0.4.30" @@ -397,43 +362,6 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "raw-cpuid" version = "6.1.0" @@ -444,11 +372,6 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "redox_syscall" -version = "0.1.56" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "region" version = "2.1.2" @@ -460,14 +383,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "remove_dir_all" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rustc-demangle" version = "0.1.16" @@ -491,7 +406,6 @@ dependencies = [ "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -603,19 +517,6 @@ dependencies = [ "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicode-xid" version = "0.1.0" @@ -626,11 +527,6 @@ name = "uuid" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "wasi" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "winapi" version = "0.3.8" @@ -658,7 +554,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" "checksum cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -680,12 +575,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" "checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" @@ -694,19 +587,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81afbc5773e99efe9533d8a539dfac37e531dcd0f4eeb41584bae03ccf76d4c2" -"checksum parity-wasm 0.40.2 (registry+https://github.com/rust-lang/crates.io-index)" = "49d1e33551976be5345d2ecbfe995830719746c7f0902f0880a13d40e215f851" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -"checksum rand 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "59cea0d944b32347a1863e95942fd6ebdb486afb4f038119494f2860380c1d51" -"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" -"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" @@ -722,10 +607,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" -"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" -"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index f707f92b6ee44..6cae573c8bdbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,12 +22,15 @@ ar = "0.8.0" bitflags = "1.1.0" byteorder = "1.2.7" libc = "0.2.53" -tempfile = "3.0.7" gimli = { git = "https://github.com/gimli-rs/gimli.git" } indexmap = "1.0.2" -object = "0.14.0" libloading = "0.5.1" +[dependencies.object] +version = "0.14.0" +default-features = false +features = ["compression", "read", "std"] # We don't need WASM support + # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] #cranelift = { path = "../cranelift/cranelift-umbrella" } @@ -41,5 +44,28 @@ libloading = "0.5.1" [target.'cfg(not(target_arch = "wasm32"))'.dependencies] cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } -[profile.dev.overrides."*"] +[profile.dev] +# By compiling dependencies with optimizations, performing tests gets much faster. opt-level = 3 + +[profile.dev.overrides."rustc_codegen_cranelift"] +# Disabling optimizations for cg_clif itself makes compilation after a change faster. +opt-level = 0 + +# Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the +# execution time of build scripts is so fast that optimizing them slows down the total build time. +[profile.dev.build-override] +opt-level = 0 +debug = false + +[profile.dev.overrides.cranelift-codegen-meta] +opt-level = 0 +debug = false + +[profile.dev.overrides.syn] +opt-level = 0 +debug = false + +[profile.dev.overrides.synstructure] +opt-level = 0 +debug = false diff --git a/src/lib.rs b/src/lib.rs index f90941d7ba43b..34e60dbd8c594 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ #![allow(intra_doc_link_resolution_failure)] extern crate flate2; +extern crate tempfile; extern crate rustc; extern crate rustc_codegen_ssa; extern crate rustc_codegen_utils; From dbeca5090148289480039b8700a4ceb61243151b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 22 Sep 2019 16:05:22 +0200 Subject: [PATCH 0889/1566] Misc cleanup --- src/lib.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 34e60dbd8c594..94fc7156af011 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,7 +225,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); - let target_cpu = ::target_lexicon::HOST.to_string(); + let target_cpu = target_triple(sess).to_string(); link_binary::>( sess, &codegen_results, @@ -239,14 +239,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn target_triple(sess: &Session) -> target_lexicon::Triple { - let mut target = &*sess.target.target.llvm_target; - - // FIXME add support for x86_64-apple-macosx10.7.0 to target-lexicon - if target.starts_with("x86_64-apple-macosx") { - target = "x86_64-apple-darwin"; - } - - target.parse().unwrap() + sess.target.target.llvm_target.parse().unwrap() } fn build_isa(sess: &Session, enable_pic: bool) -> Box { @@ -269,9 +262,6 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box Date: Sun, 22 Sep 2019 16:21:00 +0200 Subject: [PATCH 0890/1566] Wrap linker invocation in time() --- src/lib.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 94fc7156af011..fca9fdde16988 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,14 +225,18 @@ impl CodegenBackend for CraneliftCodegenBackend { .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); - let target_cpu = target_triple(sess).to_string(); - link_binary::>( - sess, - &codegen_results, - outputs, - &codegen_results.crate_name.as_str(), - &target_cpu, - ); + sess.profiler(|p| p.start_activity("link_crate")); + rustc::util::common::time(sess, "linking", || { + let target_cpu = target_triple(sess).to_string(); + link_binary::>( + sess, + &codegen_results, + outputs, + &codegen_results.crate_name.as_str(), + &target_cpu, + ); + }); + sess.profiler(|p| p.end_activity("link_crate")); Ok(()) } From 1e5cea09d5b3177ec79d8c4ddbbad0b739108601 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 22 Sep 2019 16:47:45 +0200 Subject: [PATCH 0891/1566] Add profile code around metadata object generation cc #719 --- src/driver.rs | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 84f3b1a52344c..2d00860ba206c 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -215,26 +215,32 @@ fn run_aot( rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); let metadata_module = if need_metadata_module { - use rustc::mir::mono::CodegenUnitNameBuilder; - - let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); - let metadata_cgu_name = cgu_name_builder - .build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")) - .as_str() - .to_string(); - - let mut metadata_artifact = faerie::Artifact::new( - crate::build_isa(tcx.sess, true).triple().clone(), - metadata_cgu_name.clone(), - ); - crate::metadata::write_metadata(tcx, &mut metadata_artifact); - - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Metadata, Some(&metadata_cgu_name)); - - let obj = metadata_artifact.emit().unwrap(); - std::fs::write(&tmp_file, obj).unwrap(); + tcx.sess.profiler(|p| p.start_activity("codegen crate metadata")); + let (metadata_cgu_name, tmp_file) = rustc::util::common::time(tcx.sess, "write compressed metadata", || { + use rustc::mir::mono::CodegenUnitNameBuilder; + + let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); + let metadata_cgu_name = cgu_name_builder + .build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")) + .as_str() + .to_string(); + + let mut metadata_artifact = faerie::Artifact::new( + crate::build_isa(tcx.sess, true).triple().clone(), + metadata_cgu_name.clone(), + ); + crate::metadata::write_metadata(tcx, &mut metadata_artifact); + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Metadata, Some(&metadata_cgu_name)); + + let obj = metadata_artifact.emit().unwrap(); + std::fs::write(&tmp_file, obj).unwrap(); + + (metadata_cgu_name, tmp_file) + }); + tcx.sess.profiler(|p| p.end_activity("codegen crate metadata")); Some(CompiledModule { name: metadata_cgu_name, From 3d87b5c5769a16beca0d26fbb2c3111bb6b2b93f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2019 11:59:13 +0200 Subject: [PATCH 0892/1566] Bump serde from 1.0.100 to 1.0.101 (#725) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.100 to 1.0.101. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.100...v1.0.101) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5bf8121cfc61..62e0be26abe62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.100" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -465,7 +465,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -483,7 +483,7 @@ name = "string-interner" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -599,7 +599,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "f4473e8506b213730ff2061073b48fa51dcc66349219e2e7c5608f0296a1d95a" +"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" From e64ff476811df439e104be903d245ba543f5824f Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2019 11:59:35 +0200 Subject: [PATCH 0893/1566] Bump adler32 from 1.0.3 to 1.0.4 (#721) Bumps [adler32](https://github.com/remram44/adler32-rs) from 1.0.3 to 1.0.4. - [Release notes](https://github.com/remram44/adler32-rs/releases) - [Commits](https://github.com/remram44/adler32-rs/compare/1.0.3...1.0.4) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 62e0be26abe62..88c44c18e9be8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ # It is not intended for manual editing. [[package]] name = "adler32" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -321,7 +321,7 @@ name = "miniz_oxide" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -547,7 +547,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" +"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" From cbd65b24d542e0c456f04ac927218120b15a267e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2019 12:00:04 +0200 Subject: [PATCH 0894/1566] Bump gimli from `1f1a9eb` to `7e76a9d` (#722) Bumps [gimli](https://github.com/gimli-rs/gimli) from `1f1a9eb` to `7e76a9d`. - [Release notes](https://github.com/gimli-rs/gimli/releases) - [Commits](https://github.com/gimli-rs/gimli/compare/1f1a9eb23993d3787a4e3389eade28a104bd91d0...7e76a9d56623da413f4fc2ea0e553cafe51bbfb8) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 88c44c18e9be8..97463d483b9b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,7 +248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.19.0" -source = "git+https://github.com/gimli-rs/gimli.git#1f1a9eb23993d3787a4e3389eade28a104bd91d0" +source = "git+https://github.com/gimli-rs/gimli.git#7e76a9d56623da413f4fc2ea0e553cafe51bbfb8" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", From 44792f108949048c8945a29e6eee6a35c282f210 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Sep 2019 11:13:40 +0200 Subject: [PATCH 0895/1566] Rustup to rustc 1.40.0-nightly (084beb83e 2019-09-27) --- patches/0017-Fix-libtest-compilation.patch | 16 ++++++-- src/abi/mod.rs | 14 +++---- src/allocator.rs | 6 +-- src/base.rs | 16 ++++---- src/common.rs | 4 +- src/constant.rs | 4 +- src/driver.rs | 48 ++++++++++++---------- src/intrinsics.rs | 14 +++---- src/lib.rs | 2 - src/llvm_intrinsics.rs | 2 +- src/num.rs | 10 ++--- src/unsize.rs | 10 ++--- src/value_and_place.rs | 8 ++-- 13 files changed, 82 insertions(+), 72 deletions(-) diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index de035f52f33f6..05a71d697ab62 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -11,7 +11,7 @@ diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 810a98e..4fdde0e 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs -@@ -1441,11 +1441,11 @@ pub fn run_test( +@@ -1441,12 +1441,12 @@ pub fn run_test( return; } @@ -20,18 +20,26 @@ index 810a98e..4fdde0e 100644 desc: TestDesc, monitor_ch: Sender, nocapture: bool, + report_time: bool, - testfn: Box, + testfn: F, concurrency: Concurrent, ) { // Buffer for capturing standard I/O -@@ -1500,15 +1500,14 @@ pub fn run_test( +@@ -1500,23 +1500,15 @@ pub fn run_test( (benchfn.clone())(harness) }); } - DynTestFn(f) => { - let cb = move || __rust_begin_short_backtrace(f); -- run_test_inner(desc, monitor_ch, opts.nocapture, Box::new(cb), concurrency) +- run_test_inner( +- desc, +- monitor_ch, +- opts.nocapture, +- opts.report_time, +- Box::new(cb), +- concurrency, +- ) + DynTestFn(_f) => { + unimplemented!(); } @@ -39,6 +47,7 @@ index 810a98e..4fdde0e 100644 desc, monitor_ch, opts.nocapture, + opts.report_time, - Box::new(move || __rust_begin_short_backtrace(f)), + move || __rust_begin_short_backtrace(f), concurrency, @@ -46,4 +55,3 @@ index 810a98e..4fdde0e 100644 } -- 2.11.0 - diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f5d5445dab445..30d59949df814 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -30,7 +30,7 @@ fn clif_sig_from_fn_sig<'tcx>( Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); - let extra_args = match sig.inputs().last().unwrap().sty { + let extra_args = match sig.inputs().last().unwrap().kind { ty::Tuple(ref tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; @@ -177,7 +177,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { }) .unzip(); let return_layout = self.layout_of(return_ty); - let return_tys = if let ty::Tuple(tup) = return_ty.sty { + let return_tys = if let ty::Tuple(tup) = return_ty.kind { tup.types().map(|ty| self.clif_type(ty).unwrap()).collect() } else { vec![self.clif_type(return_ty).unwrap()] @@ -255,7 +255,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: // to reconstruct it into a tuple local variable, from multiple // individual function arguments. - let tupled_arg_tys = match arg_ty.sty { + let tupled_arg_tys = match arg_ty.kind { ty::Tuple(ref tys) => tys, _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), }; @@ -367,7 +367,7 @@ pub fn codegen_terminator_call<'tcx>( .as_ref() .map(|&(ref place, bb)| (trans_place(fx, place), bb)); - if let ty::FnDef(def_id, substs) = fn_ty.sty { + 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(); @@ -405,7 +405,7 @@ pub fn codegen_terminator_call<'tcx>( let pack_arg = trans_operand(fx, &args[1]); let mut args = Vec::new(); args.push(self_arg); - match pack_arg.layout().ty.sty { + match pack_arg.layout().ty.kind { ty::Tuple(ref tupled_arguments) => { for (i, _) in tupled_arguments.iter().enumerate() { args.push(pack_arg.value_field(fx, mir::Field::new(i))); @@ -447,7 +447,7 @@ fn codegen_call_inner<'tcx>( .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - let instance = match fn_ty.sty { + let instance = match fn_ty.kind { ty::FnDef(def_id, substs) => { Some(Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap()) } @@ -562,7 +562,7 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac // we don't actually need to drop anything } else { let drop_fn_ty = drop_fn.ty(fx.tcx); - match ty.sty { + match ty.kind { ty::Dynamic(..) => { let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); diff --git a/src/allocator.rs b/src/allocator.rs index d4a1f1a49faf5..f4ba22b7d1a24 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -13,14 +13,14 @@ use crate::prelude::*; use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created -pub fn codegen(sess: &Session, module: &mut Module) -> bool { - let any_dynamic_crate = sess.dependency_formats.borrow().iter().any(|(_, list)| { +pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { + let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| { use rustc::middle::dependency_format::Linkage; list.iter().any(|&linkage| linkage == Linkage::Dynamic) }); if any_dynamic_crate { false - } else if let Some(kind) = *sess.allocator_kind.get() { + } else if let Some(kind) = *tcx.sess.allocator_kind.get() { codegen_inner(module, kind); true } else { diff --git a/src/base.rs b/src/base.rs index fe50d2a2dc490..e58ab93158a71 100644 --- a/src/base.rs +++ b/src/base.rs @@ -307,7 +307,7 @@ fn trans_stmt<'tcx>( let val = operand.load_scalar(fx); let res = match un_op { UnOp::Not => { - match layout.ty.sty { + match layout.ty.kind { ty::Bool => { let val = fx.bcx.ins().uextend(types::I32, val); // WORKAROUND for CraneStation/cranelift#466 let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); @@ -317,7 +317,7 @@ fn trans_stmt<'tcx>( _ => unimplemented!("un op Not for {:?}", layout.ty), } } - UnOp::Neg => match layout.ty.sty { + UnOp::Neg => match layout.ty.kind { ty::Int(_) => { let clif_ty = fx.clif_type(layout.ty).unwrap(); if clif_ty == types::I128 { @@ -343,7 +343,7 @@ fn trans_stmt<'tcx>( let layout = fx.layout_of(ty); match fx .monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)) - .sty + .kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( @@ -390,10 +390,10 @@ fn trans_stmt<'tcx>( let (ptr, _extra) = operand.load_scalar_pair(fx); lval.write_cvalue(fx, CValue::by_val(ptr, dest_layout)) } - } else if let ty::Adt(adt_def, _substs) = from_ty.sty { + } else if let ty::Adt(adt_def, _substs) = from_ty.kind { // enum -> discriminant value assert!(adt_def.is_enum()); - match to_ty.sty { + match to_ty.kind { ty::Uint(_) | ty::Int(_) => {} _ => unreachable!("cast adt {} -> {}", from_ty, to_ty), } @@ -420,7 +420,7 @@ fn trans_stmt<'tcx>( } Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), operand, _ty) => { let operand = trans_operand(fx, operand); - match operand.layout().ty.sty { + match operand.layout().ty.kind { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( fx.tcx, @@ -587,7 +587,7 @@ fn codegen_array_len<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: CPlace<'tcx>, ) -> Value { - match place.layout().ty.sty { + match place.layout().ty.kind { ty::Array(_elem_ty, len) => { let len = crate::constant::force_eval_const(fx, len) .eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64; @@ -647,7 +647,7 @@ pub fn trans_place<'tcx>( // These indices are generated by slice patterns. // slice[from:-to] in Python terms. - match cplace.layout().ty.sty { + match cplace.layout().ty.kind { ty::Array(elem_ty, len) => { let elem_layout = fx.layout_of(elem_ty); let ptr = cplace.to_addr(fx); diff --git a/src/common.rs b/src/common.rs index 2044930560973..85778f4c8e98d 100644 --- a/src/common.rs +++ b/src/common.rs @@ -36,7 +36,7 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { } pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { - Some(match ty.sty { + Some(match ty.kind { ty::Bool => types::I8, ty::Uint(size) => match size { UintTy::U8 => types::I8, @@ -262,7 +262,7 @@ pub fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { } pub fn type_sign(ty: Ty<'_>) -> bool { - match ty.sty { + match ty.kind { ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) | ty::Char | ty::Uint(..) | ty::Bool => false, ty::Int(..) => true, ty::Float(..) => false, // `signed` is unused for floats diff --git a/src/constant.rs b/src/constant.rs index f064a2c0a3d4e..9a1685038bd1e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -103,7 +103,7 @@ pub fn trans_const_value<'tcx>( ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); - match ty.sty { + match ty.kind { ty::Bool | ty::Uint(_) => { let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val(fx, ty, bits) @@ -230,7 +230,7 @@ fn data_id_for_static( .unwrap(); if linkage == Linkage::Preemptible { - if let ty::RawPtr(_) = ty.sty { + if let ty::RawPtr(_) = ty.kind { } else { tcx.sess.span_fatal( tcx.def_span(def_id), diff --git a/src/driver.rs b/src/driver.rs index 2d00860ba206c..d58e13bec6759 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -68,7 +68,7 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { .unwrap(); codegen_cgus(tcx, &mut jit_module, &mut None, log); - crate::allocator::codegen(tcx.sess, &mut jit_module); + crate::allocator::codegen(tcx, &mut jit_module); jit_module.finalize_definitions(); tcx.sess.abort_if_errors(); @@ -101,8 +101,12 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { let mut dylib_paths = Vec::new(); let crate_info = CrateInfo::new(tcx); - let formats = tcx.sess.dependency_formats.borrow(); - let data = formats.get(&CrateType::Executable).unwrap(); + let formats = tcx.dependency_formats(LOCAL_CRATE); + let data = &formats + .iter() + .find(|(crate_type, _data)| *crate_type == CrateType::Executable) + .unwrap() + .1; for &(cnum, _) in &crate_info.used_crates_dynamic { let src = &crate_info.used_crate_source[&cnum]; match data[cnum.as_usize() - 1] { @@ -167,26 +171,26 @@ fn run_aot( let emit_module = |kind: ModuleKind, mut module: Module, debug: Option| { - module.finalize_definitions(); - let mut artifact = module.finish().artifact; + module.finalize_definitions(); + let mut artifact = module.finish().artifact; - if let Some(mut debug) = debug { - debug.emit(&mut artifact); - } + if let Some(mut debug) = debug { + debug.emit(&mut artifact); + } - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, Some(&artifact.name)); - let obj = artifact.emit().unwrap(); - std::fs::write(&tmp_file, obj).unwrap(); - CompiledModule { - name: artifact.name, - kind, - object: Some(tmp_file), - bytecode: None, - bytecode_compressed: None, - } - }; + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(&artifact.name)); + let obj = artifact.emit().unwrap(); + std::fs::write(&tmp_file, obj).unwrap(); + CompiledModule { + name: artifact.name, + kind, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + } + }; let mut faerie_module = new_module("some_file".to_string()); @@ -208,7 +212,7 @@ fn run_aot( tcx.sess.abort_if_errors(); let mut allocator_module = new_module("allocator_shim".to_string()); - let created_alloc_shim = crate::allocator::codegen(tcx.sess, &mut allocator_module); + let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module); rustc_incremental::assert_dep_graph(tcx); rustc_incremental::save_dep_graph(tcx); diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 21bd8365eb2b5..f55dd7d875fe4 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -213,7 +213,7 @@ macro_rules! simd_cmp { $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Uint(_) | ty::Int(_) => codegen_icmp(fx, IntCC::$cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; @@ -229,7 +229,7 @@ macro_rules! simd_cmp { $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Uint(_) => codegen_icmp(fx, IntCC::$cc_u, x_lane, y_lane), ty::Int(_) => codegen_icmp(fx, IntCC::$cc_s, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), @@ -249,7 +249,7 @@ macro_rules! simd_int_binop { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; @@ -265,7 +265,7 @@ macro_rules! simd_int_binop { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), @@ -285,7 +285,7 @@ macro_rules! simd_int_flt_binop { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), @@ -302,7 +302,7 @@ macro_rules! simd_int_flt_binop { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), @@ -323,7 +323,7 @@ macro_rules! simd_flt_binop { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; diff --git a/src/lib.rs b/src/lib.rs index fca9fdde16988..2464bca1c0a61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,6 @@ extern crate rustc_target; extern crate syntax; use std::any::Any; -use std::sync::mpsc; use rustc::dep_graph::DepGraph; use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; @@ -200,7 +199,6 @@ impl CodegenBackend for CraneliftCodegenBackend { tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, - _rx: mpsc::Receiver>, ) -> Box { rustc_codegen_utils::check_for_rustc_errors_attr(tcx); diff --git a/src/llvm_intrinsics.rs b/src/llvm_intrinsics.rs index e367a165bf605..b281c3d186d26 100644 --- a/src/llvm_intrinsics.rs +++ b/src/llvm_intrinsics.rs @@ -87,7 +87,7 @@ pub fn codegen_llvm_intrinsic_call<'tcx>( }; simd_for_each_lane(fx, intrinsic, x, y, ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.sty { + let res_lane = match lane_layout.ty.kind { ty::Float(_) => fx.bcx.ins().fcmp(flt_cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; diff --git a/src/num.rs b/src/num.rs index 49df9b3ac9c5e..5dee1d8c2abb4 100644 --- a/src/num.rs +++ b/src/num.rs @@ -59,15 +59,15 @@ pub fn codegen_binop<'tcx>( ) -> CValue<'tcx> { match bin_op { BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { - match in_lhs.layout().ty.sty { + match in_lhs.layout().ty.kind { ty::Bool | ty::Uint(_) | ty::Int(_) | ty::Char => { let signed = type_sign(in_lhs.layout().ty); let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (in_lhs.layout().ty.sty == fx.tcx.types.i8.sty - || in_lhs.layout().ty.sty == fx.tcx.types.i16.sty) + && (in_lhs.layout().ty.kind == fx.tcx.types.i8.kind + || in_lhs.layout().ty.kind == fx.tcx.types.i16.kind) { // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. ( @@ -86,7 +86,7 @@ pub fn codegen_binop<'tcx>( _ => {} } - match in_lhs.layout().ty.sty { + match in_lhs.layout().ty.kind { ty::Bool => crate::num::trans_bool_binop(fx, bin_op, in_lhs, in_rhs), ty::Uint(_) | ty::Int(_) => crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs), ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs), @@ -314,7 +314,7 @@ pub fn trans_float_binop<'tcx>( BinOp::Mul => b.fmul(lhs, rhs), BinOp::Div => b.fdiv(lhs, rhs), BinOp::Rem => { - let name = match in_lhs.layout().ty.sty { + let name = match in_lhs.layout().ty.kind { ty::Float(FloatTy::F32) => "fmodf", ty::Float(FloatTy::F64) => "fmod", _ => bug!(), diff --git a/src/unsize.rs b/src/unsize.rs index cd1b5be99a06d..6d497b188669f 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -17,7 +17,7 @@ pub fn unsized_info<'tcx>( let (source, target) = fx.tcx .struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); - match (&source.sty, &target.sty) { + match (&source.kind, &target.kind) { (&ty::Array(_, len), &ty::Slice(_)) => fx.bcx.ins().iconst( fx.pointer_type, len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64, @@ -44,7 +44,7 @@ pub fn unsize_thin_ptr<'tcx>( src_ty: Ty<'tcx>, dst_ty: Ty<'tcx>, ) -> (Value, Value) { - match (&src_ty.sty, &dst_ty.sty) { + match (&src_ty.kind, &dst_ty.kind) { (&ty::Ref(_, a, _), &ty::Ref(_, b, _)) | (&ty::Ref(_, a, _), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { @@ -105,7 +105,7 @@ pub fn coerce_unsized_into<'tcx>( }; dst.write_cvalue(fx, CValue::by_val_pair(base, info, dst.layout())); }; - match (&src_ty.sty, &dst_ty.sty) { + match (&src_ty.kind, &dst_ty.kind) { (&ty::Ref(..), &ty::Ref(..)) | (&ty::Ref(..), &ty::RawPtr(..)) | (&ty::RawPtr(..), &ty::RawPtr(..)) => coerce_ptr(), @@ -154,7 +154,7 @@ pub fn size_and_align_of_dst<'tcx>( .iconst(fx.pointer_type, layout.align.abi.bytes() as i64); return (size, align); } - match ty.sty { + match ty.kind { ty::Dynamic(..) => { // load size/align from vtable ( @@ -200,7 +200,7 @@ pub fn size_and_align_of_dst<'tcx>( let size = fx.bcx.ins().iadd_imm(unsized_size, sized_size as i64); // Packed types ignore the alignment of their fields. - if let ty::Adt(def, _) = ty.sty { + if let ty::Adt(def, _) = ty.kind { if def.repr.packed() { unsized_align = sized_align; } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index caf41bd1425a0..c152b8d3c5122 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -25,7 +25,7 @@ fn codegen_field<'tcx>( if !field_layout.is_unsized() { return simple(fx); } - match field_layout.ty.sty { + match field_layout.ty.kind { ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(fx), ty::Adt(def, _) if def.repr.packed() => { assert_eq!(layout.align.abi.bytes(), 1); @@ -178,7 +178,7 @@ impl<'tcx> CValue<'tcx> { let clif_ty = fx.clif_type(ty).unwrap(); let layout = fx.layout_of(ty); - let val = match ty.sty { + let val = match ty.kind { ty::TyKind::Uint(UintTy::U128) | ty::TyKind::Int(IntTy::I128) => { let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64); let msb = fx @@ -350,7 +350,7 @@ impl<'tcx> CPlace<'tcx> { from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, ) { - match (&from_ty.sty, &to_ty.sty) { + match (&from_ty.kind, &to_ty.kind) { (ty::Ref(_, t, MutImmutable), ty::Ref(_, u, MutImmutable)) | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutImmutable)) | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutMutable)) => { @@ -480,7 +480,7 @@ impl<'tcx> CPlace<'tcx> { fx: &mut FunctionCx<'_, 'tcx, impl Backend>, index: Value, ) -> CPlace<'tcx> { - let (elem_layout, addr) = match self.layout().ty.sty { + let (elem_layout, addr) = match self.layout().ty.kind { ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_addr(fx)), ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_addr_maybe_unsized(fx).0), _ => bug!("place_index({:?})", self.layout().ty), From 0db605040ebc4efb29b70a049edeefc18af8d6f8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Sep 2019 17:00:27 +0200 Subject: [PATCH 0896/1566] Use CallConv::triple_default instead of hard coding SystemV Fixes #718 --- src/abi/mod.rs | 10 +++++----- src/allocator.rs | 6 +++--- src/driver.rs | 2 +- src/intrinsics.rs | 2 +- src/lib.rs | 8 ++++++-- src/main_shim.rs | 2 +- src/trap.rs | 2 +- 7 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 30d59949df814..8d4038065e946 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -26,8 +26,8 @@ fn clif_sig_from_fn_sig<'tcx>( abi => abi, }; let (call_conv, inputs, output): (CallConv, Vec, Ty) = match abi { - Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), - Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), + Abi::Rust => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()), + Abi::C => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().kind { @@ -36,10 +36,10 @@ fn clif_sig_from_fn_sig<'tcx>( }; let mut inputs: Vec = vec![sig.inputs()[0]]; inputs.extend(extra_args.types()); - (CallConv::SystemV, inputs, sig.output()) + (crate::default_call_conv(tcx.sess), inputs, sig.output()) } Abi::System => unreachable!(), - Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), + Abi::RustIntrinsic => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()), _ => unimplemented!("unsupported abi {:?}", sig.abi), }; @@ -142,7 +142,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let sig = Signature { params: input_tys.iter().cloned().map(AbiParam::new).collect(), returns: output_tys.iter().cloned().map(AbiParam::new).collect(), - call_conv: CallConv::SystemV, + call_conv: crate::default_call_conv(self.tcx.sess), }; let func_id = self .module diff --git a/src/allocator.rs b/src/allocator.rs index f4ba22b7d1a24..c4222a858aba5 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -21,14 +21,14 @@ pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> if any_dynamic_crate { false } else if let Some(kind) = *tcx.sess.allocator_kind.get() { - codegen_inner(module, kind); + codegen_inner(tcx.sess, module, kind); true } else { false } } -pub fn codegen_inner(module: &mut Module, kind: AllocatorKind) { +pub fn codegen_inner(sess: &Session, module: &mut Module, kind: AllocatorKind) { let usize_ty = module.target_config().pointer_type(); for method in ALLOCATOR_METHODS { @@ -55,7 +55,7 @@ pub fn codegen_inner(module: &mut Module, kind: Allocato }; let sig = Signature { - call_conv: CallConv::SystemV, + call_conv: crate::default_call_conv(sess), params: arg_tys.iter().cloned().map(AbiParam::new).collect(), returns: output.into_iter().map(AbiParam::new).collect(), }; diff --git a/src/driver.rs b/src/driver.rs index d58e13bec6759..c8b1720850009 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -61,7 +61,7 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { returns: vec![AbiParam::new( jit_module.target_config().pointer_type(), /*isize*/ )], - call_conv: CallConv::SystemV, + call_conv: crate::default_call_conv(tcx.sess), }; let main_func_id = jit_module .declare_function("main", Linkage::Import, &sig) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index f55dd7d875fe4..44aa2151a7541 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1063,7 +1063,7 @@ pub fn codegen_intrinsic_call<'tcx>( try, (v f, v data, v _local_ptr) { // FIXME once unwinding is supported, change this to actually catch panics let f_sig = fx.bcx.func.import_signature(Signature { - call_conv: cranelift::codegen::isa::CallConv::SystemV, + call_conv: crate::default_call_conv(fx.tcx.sess), params: vec![AbiParam::new(fx.bcx.func.dfg.value_type(data))], returns: vec![], }); diff --git a/src/lib.rs b/src/lib.rs index 2464bca1c0a61..efa666bc9ebba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -225,7 +225,7 @@ impl CodegenBackend for CraneliftCodegenBackend { sess.profiler(|p| p.start_activity("link_crate")); rustc::util::common::time(sess, "linking", || { - let target_cpu = target_triple(sess).to_string(); + let target_cpu = crate::target_triple(sess).to_string(); link_binary::>( sess, &codegen_results, @@ -244,6 +244,10 @@ fn target_triple(sess: &Session) -> target_lexicon::Triple { sess.target.target.llvm_target.parse().unwrap() } +fn default_call_conv(sess: &Session) -> CallConv { + CallConv::triple_default(&target_triple(sess)) +} + fn build_isa(sess: &Session, enable_pic: bool) -> Box { let mut flags_builder = settings::builder(); if enable_pic { @@ -279,7 +283,7 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box, module: &mut Module, ms "puts", Linkage::Import, &Signature { - call_conv: CallConv::SystemV, + call_conv: crate::default_call_conv(fx.tcx.sess), params: vec![AbiParam::new(pointer_ty(fx.tcx))], returns: vec![], }, From 1b6706c9245dc1948498acc7af10263a8408c018 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Sep 2019 17:01:17 +0200 Subject: [PATCH 0897/1566] Call cg_ssa::base::provide_both in provide{,_extern} --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index efa666bc9ebba..81b03ba5f35d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,6 +169,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn provide(&self, providers: &mut Providers) { rustc_codegen_utils::symbol_names::provide(providers); rustc_codegen_ssa::back::symbol_export::provide(providers); + rustc_codegen_ssa::base::provide_both(providers); providers.target_features_whitelist = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); @@ -192,6 +193,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn provide_extern(&self, providers: &mut Providers) { rustc_codegen_ssa::back::symbol_export::provide_extern(providers); + rustc_codegen_ssa::base::provide_both(providers); } fn codegen_crate<'tcx>( From e676998b6180f48333300de065e156ad166bb7b5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 3 Oct 2019 16:24:06 +0200 Subject: [PATCH 0898/1566] Rustup to rustc 1.40.0-nightly (084beb83e 2019-09-27) --- patches/0017-Fix-libtest-compilation.patch | 82 ++++++++++++++----- .../0018-test-Force-single-thread-mode.patch | 34 -------- ...0-libtest-Don-t-require-panic_unwind.patch | 41 ---------- 3 files changed, 60 insertions(+), 97 deletions(-) delete mode 100644 patches/0018-test-Force-single-thread-mode.patch delete mode 100644 patches/0020-libtest-Don-t-require-panic_unwind.patch diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index 05a71d697ab62..ee550af83012e 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -1,32 +1,77 @@ -From a25405f1fc4a168c9c370524be48aff8c8ebc529 Mon Sep 17 00:00:00 2001 +From e77c222bb7ec0a99a69dcbb039c75fd1ea9db368 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Wed, 12 Jun 2019 18:07:23 +0200 +Date: Thu, 3 Oct 2019 16:22:21 +0200 Subject: [PATCH] Fix libtest compilation --- - src/libtest/lib.rs | 11 +++++------ - 1 file changed, 5 insertions(+), 6 deletions(-) + src/libtest/lib.rs | 30 +++++------------------------- + 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs -index 810a98e..4fdde0e 100644 +index e441514..8e8b4df 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs -@@ -1441,12 +1441,12 @@ pub fn run_test( - return; - } +@@ -24,7 +24,6 @@ + #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))] + #![feature(nll)] + #![feature(set_stdio)] +-#![feature(panic_unwind)] + #![feature(staged_api)] + #![feature(termination_trait_lib)] + #![feature(test)] +@@ -34,16 +33,6 @@ use getopts; + extern crate libc; + use term; -- fn run_test_inner( -+ fn run_test_inner( - desc: TestDesc, +-// FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind +-// on aarch64-pc-windows-msvc, or thumbv7a-pc-windows-msvc +-// so we don't link libtest against libunwind (for the time being) +-// even though it means that libtest won't be fully functional on +-// these platforms. +-// +-// See also: https://github.com/rust-lang/rust/issues/54190#issuecomment-422904437 +-#[cfg(not(all(windows, any(target_arch = "aarch64", target_arch = "arm"))))] +-extern crate panic_unwind; +- + pub use self::ColorConfig::*; + use self::NamePadding::*; + use self::OutputLocation::*; +@@ -61,7 +50,6 @@ use std::fmt; + use std::fs::File; + use std::io; + use std::io::prelude::*; +-use std::panic::{catch_unwind, AssertUnwindSafe}; + use std::path::PathBuf; + use std::process; + use std::process::Termination; +@@ -1434,7 +1422,7 @@ pub fn run_test( monitor_ch: Sender, nocapture: bool, report_time: bool, - testfn: Box, -+ testfn: F, ++ testfn: Box, concurrency: Concurrent, ) { // Buffer for capturing standard I/O -@@ -1500,23 +1500,15 @@ pub fn run_test( +@@ -1457,7 +1445,7 @@ pub fn run_test( + } else { + None + }; +- let result = catch_unwind(AssertUnwindSafe(testfn)); ++ let result = Ok(testfn()); + let exec_time = start.map(|start| { + let duration = start.elapsed(); + TestExecTime(duration) +@@ -1478,7 +1466,7 @@ pub fn run_test( + // If the platform is single-threaded we're just going to run + // the test synchronously, regardless of the concurrency + // level. +- let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32"); ++ let supports_threads = false; + if concurrency == Concurrent::Yes && supports_threads { + let cfg = thread::Builder::new().name(name.as_slice().to_owned()); + cfg.spawn(runtest).unwrap(); +@@ -1498,16 +1486,8 @@ pub fn run_test( (benchfn.clone())(harness) }); } @@ -45,13 +90,6 @@ index 810a98e..4fdde0e 100644 } StaticTestFn(f) => run_test_inner( desc, - monitor_ch, - opts.nocapture, - opts.report_time, -- Box::new(move || __rust_begin_short_backtrace(f)), -+ move || __rust_begin_short_backtrace(f), - concurrency, - ), - } -- -2.11.0 +2.20.1 + diff --git a/patches/0018-test-Force-single-thread-mode.patch b/patches/0018-test-Force-single-thread-mode.patch deleted file mode 100644 index 19cead46ff718..0000000000000 --- a/patches/0018-test-Force-single-thread-mode.patch +++ /dev/null @@ -1,34 +0,0 @@ -From e275a6ac96bedda2d57296914f2bb736e1e4154c Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Fri, 9 Aug 2019 13:16:55 +0200 -Subject: [PATCH] [test] Force single thread mode - ---- - src/libtest/lib.rs | 11 +---------- - 1 file changed, 1 insertion(+), 10 deletions(-) - -diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs -index 8d74d9a..c7a3c23 100644 ---- a/src/libtest/lib.rs -+++ b/src/libtest/lib.rs -@@ -1419,16 +1419,7 @@ pub fn run_test( - .unwrap(); - }; - -- // If the platform is single-threaded we're just going to run -- // the test synchronously, regardless of the concurrency -- // level. -- let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32"); -- if concurrency == Concurrent::Yes && supports_threads { -- let cfg = thread::Builder::new().name(name.as_slice().to_owned()); -- cfg.spawn(runtest).unwrap(); -- } else { -- runtest(); -- } -+ runtest(); - } - - match testfn { --- -2.20.1 - diff --git a/patches/0020-libtest-Don-t-require-panic_unwind.patch b/patches/0020-libtest-Don-t-require-panic_unwind.patch deleted file mode 100644 index 4b46914c34bf2..0000000000000 --- a/patches/0020-libtest-Don-t-require-panic_unwind.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 7b30ddc41c71e89d3e6ab6840b0206877d68f201 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sun, 25 Aug 2019 16:23:06 +0200 -Subject: [PATCH] [libtest] Don't require panic_unwind - ---- - src/libtest/lib.rs | 11 ----------- - 1 file changed, 11 deletions(-) - -diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs -index 9bb76f9..c5fe1aa 100644 ---- a/src/libtest/lib.rs -+++ b/src/libtest/lib.rs -@@ -24,7 +24,6 @@ - #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))] - #![feature(nll)] - #![feature(set_stdio)] --#![feature(panic_unwind)] - #![feature(staged_api)] - #![feature(termination_trait_lib)] - #![feature(test)] -@@ -34,16 +33,6 @@ use getopts; - extern crate libc; - use term; - --// FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind --// on aarch64-pc-windows-msvc, or thumbv7a-pc-windows-msvc --// so we don't link libtest against libunwind (for the time being) --// even though it means that libtest won't be fully functional on --// these platforms. --// --// See also: https://github.com/rust-lang/rust/issues/54190#issuecomment-422904437 --#[cfg(not(all(windows, any(target_arch = "aarch64", target_arch = "arm"))))] --extern crate panic_unwind; -- - pub use self::ColorConfig::*; - use self::NamePadding::*; - use self::OutputLocation::*; --- -2.20.1 - From 0f938f68a58fb187e1d5f1173dcaa6dbc1a19552 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 3 Oct 2019 17:22:01 +0200 Subject: [PATCH 0899/1566] Rustup to rustc 1.40.0-nightly (2daa404e9 2019-10-02) --- config.sh | 2 +- patches/0017-Fix-libtest-compilation.patch | 104 ++++++++++----------- src/driver.rs | 3 +- src/lib.rs | 10 +- 4 files changed, 60 insertions(+), 59 deletions(-) diff --git a/config.sh b/config.sh index 43280c091419a..4b7fe76d690b7 100644 --- a/config.sh +++ b/config.sh @@ -12,7 +12,7 @@ fi TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") -export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index ee550af83012e..05b5675d43b33 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -1,68 +1,35 @@ -From e77c222bb7ec0a99a69dcbb039c75fd1ea9db368 Mon Sep 17 00:00:00 2001 +From e06143d3373293d0490df482261cd4a842f1a5c5 Mon Sep 17 00:00:00 2001 From: bjorn3 -Date: Thu, 3 Oct 2019 16:22:21 +0200 +Date: Thu, 3 Oct 2019 16:51:34 +0200 Subject: [PATCH] Fix libtest compilation --- - src/libtest/lib.rs | 30 +++++------------------------- - 1 file changed, 5 insertions(+), 25 deletions(-) + src/libtest/lib.rs | 28 ++++++++-------------------- + 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs -index e441514..8e8b4df 100644 +index 8b76080..9e65de2 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs -@@ -24,7 +24,6 @@ - #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))] - #![feature(nll)] - #![feature(set_stdio)] --#![feature(panic_unwind)] - #![feature(staged_api)] - #![feature(termination_trait_lib)] - #![feature(test)] -@@ -34,16 +33,6 @@ use getopts; - extern crate libc; - use term; - --// FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind --// on aarch64-pc-windows-msvc, or thumbv7a-pc-windows-msvc --// so we don't link libtest against libunwind (for the time being) --// even though it means that libtest won't be fully functional on --// these platforms. --// --// See also: https://github.com/rust-lang/rust/issues/54190#issuecomment-422904437 --#[cfg(not(all(windows, any(target_arch = "aarch64", target_arch = "arm"))))] --extern crate panic_unwind; -- - pub use self::ColorConfig::*; - use self::NamePadding::*; - use self::OutputLocation::*; -@@ -61,7 +50,6 @@ use std::fmt; +@@ -52,7 +52,7 @@ use std::fmt; use std::fs::File; use std::io; use std::io::prelude::*; --use std::panic::{catch_unwind, AssertUnwindSafe}; +-use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}; ++use std::panic::{self, PanicInfo}; use std::path::PathBuf; use std::process; - use std::process::Termination; -@@ -1434,7 +1422,7 @@ pub fn run_test( - monitor_ch: Sender, - nocapture: bool, + use std::process::{ExitStatus, Command, Termination}; +@@ -1493,7 +1493,7 @@ pub fn run_test( report_time: bool, + strategy: RunStrategy, + monitor_ch: Sender, - testfn: Box, + testfn: Box, concurrency: Concurrent, ) { - // Buffer for capturing standard I/O -@@ -1457,7 +1445,7 @@ pub fn run_test( - } else { - None - }; -- let result = catch_unwind(AssertUnwindSafe(testfn)); -+ let result = Ok(testfn()); - let exec_time = start.map(|start| { - let duration = start.elapsed(); - TestExecTime(duration) -@@ -1478,7 +1466,7 @@ pub fn run_test( + let name = desc.name.clone(); +@@ -1509,7 +1509,7 @@ pub fn run_test( // If the platform is single-threaded we're just going to run // the test synchronously, regardless of the concurrency // level. @@ -71,25 +38,56 @@ index e441514..8e8b4df 100644 if concurrency == Concurrent::Yes && supports_threads { let cfg = thread::Builder::new().name(name.as_slice().to_owned()); cfg.spawn(runtest).unwrap(); -@@ -1498,16 +1486,8 @@ pub fn run_test( +@@ -1531,20 +1531,8 @@ pub fn run_test( (benchfn.clone())(harness) }); } - DynTestFn(f) => { -- let cb = move || __rust_begin_short_backtrace(f); +- match strategy { +- RunStrategy::InProcess => (), +- _ => panic!("Cannot run dynamic test fn out-of-process"), +- }; - run_test_inner( - desc, -- monitor_ch, - opts.nocapture, - opts.report_time, -- Box::new(cb), -- concurrency, -- ) +- strategy, +- monitor_ch, +- Box::new(move || __rust_begin_short_backtrace(f)), +- concurrency +- ); + DynTestFn(_f) => { + unimplemented!(); } StaticTestFn(f) => run_test_inner( desc, +@@ -1604,7 +1592,7 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult { + fn run_test_in_process(desc: TestDesc, + nocapture: bool, + report_time: bool, +- testfn: Box, ++ testfn: Box, + monitor_ch: Sender) { + // Buffer for capturing standard I/O + let data = Arc::new(Mutex::new(Vec::new())); +@@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc, + } else { + None + }; +- let result = catch_unwind(AssertUnwindSafe(testfn)); ++ let result = Ok::<(), Box>(testfn()); + let exec_time = start.map(|start| { + let duration = start.elapsed(); + TestExecTime(duration) +@@ -1688,7 +1676,7 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender) -> ! { ++fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box) -> ! { + let builtin_panic_hook = panic::take_hook(); + let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| { + let test_result = match panic_info { -- 2.20.1 diff --git a/src/driver.rs b/src/driver.rs index c8b1720850009..f02ba35904ff9 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -219,7 +219,7 @@ fn run_aot( rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); let metadata_module = if need_metadata_module { - tcx.sess.profiler(|p| p.start_activity("codegen crate metadata")); + let _timer = tcx.prof.generic_activity("codegen crate metadata"); let (metadata_cgu_name, tmp_file) = rustc::util::common::time(tcx.sess, "write compressed metadata", || { use rustc::mir::mono::CodegenUnitNameBuilder; @@ -244,7 +244,6 @@ fn run_aot( (metadata_cgu_name, tmp_file) }); - tcx.sess.profiler(|p| p.end_activity("codegen crate metadata")); Some(CompiledModule { name: metadata_cgu_name, diff --git a/src/lib.rs b/src/lib.rs index 81b03ba5f35d8..17b667daf0e49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,6 +10,7 @@ extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_fs_util; extern crate rustc_incremental; +extern crate rustc_index; extern crate rustc_mir; extern crate rustc_target; extern crate syntax; @@ -74,11 +75,14 @@ mod prelude { self, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; + pub use rustc_data_structures::{ fx::{FxHashMap, FxHashSet}, - indexed_vec::Idx, sync::Lrc, }; + + pub use rustc_index::vec::Idx; + pub use rustc_mir::monomorphize::collector; pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; @@ -225,7 +229,8 @@ impl CodegenBackend for CraneliftCodegenBackend { .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); - sess.profiler(|p| p.start_activity("link_crate")); + let _timer = sess.prof.generic_activity("link_crate"); + rustc::util::common::time(sess, "linking", || { let target_cpu = crate::target_triple(sess).to_string(); link_binary::>( @@ -236,7 +241,6 @@ impl CodegenBackend for CraneliftCodegenBackend { &target_cpu, ); }); - sess.profiler(|p| p.end_activity("link_crate")); Ok(()) } From 8cee28db3e3a585022666bc0cec3b6702a448f65 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Sep 2019 17:49:11 +0200 Subject: [PATCH 0900/1566] Switch back to crates.io version of gimli Fixes #727 --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97463d483b9b6..1757ded68b229 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,7 +248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.19.0" -source = "git+https://github.com/gimli-rs/gimli.git#7e76a9d56623da413f4fc2ea0e553cafe51bbfb8" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -400,7 +400,7 @@ dependencies = [ "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", + "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -575,7 +575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" +"checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" diff --git a/Cargo.toml b/Cargo.toml index 6cae573c8bdbd..74e1dda7e0404 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ ar = "0.8.0" bitflags = "1.1.0" byteorder = "1.2.7" libc = "0.2.53" -gimli = { git = "https://github.com/gimli-rs/gimli.git" } +gimli = "0.19.0" indexmap = "1.0.2" libloading = "0.5.1" @@ -38,7 +38,7 @@ features = ["compression", "read", "std"] # We don't need WASM support #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } #cranelift-faerie = { path = "../cranelift/cranelift-faerie" } -#[patch."https://github.com/gimli-rs/gimli.git"] +#[patch.crates-io] #gimli = { path = "../" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] From 58a9b648e830bef11864db8f657a2eac944ea552 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Sep 2019 17:59:27 +0200 Subject: [PATCH 0901/1566] Update cranelift, faerie and target-lexicon --- Cargo.lock | 108 ++++++++++++++++++++++++-------------------- src/allocator.rs | 11 +++-- src/base.rs | 12 +++-- src/codegen_i128.rs | 2 +- src/common.rs | 2 +- src/main_shim.rs | 13 +++--- src/trap.rs | 2 +- 7 files changed, 80 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1757ded68b229..780571887c45d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,29 +60,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -92,24 +93,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] +[[package]] +name = "cranelift-codegen-shared" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" + [[package]] name = "cranelift-entity" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" [[package]] name = "cranelift-faerie" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -118,10 +125,10 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -129,33 +136,33 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -395,10 +402,10 @@ dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -556,16 +563,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" -"checksum cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" diff --git a/src/allocator.rs b/src/allocator.rs index c4222a858aba5..29e3ceb3a5a57 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -73,8 +73,10 @@ pub fn codegen_inner(sess: &Session, module: &mut Module .unwrap(); let mut ctx = Context::new(); - ctx.func = { - let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig.clone())); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); + { + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); let ebb = bcx.create_ebb(); bcx.switch_to_block(ebb); @@ -90,9 +92,8 @@ pub fn codegen_inner(sess: &Session, module: &mut Module let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error bcx.ins().return_(&results); bcx.seal_all_blocks(); - bcx.finalize() - }; - + bcx.finalize(); + } module.define_function(func_id, &mut ctx).unwrap(); } } diff --git a/src/base.rs b/src/base.rs index e58ab93158a71..7cb079567f1e6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -19,8 +19,10 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( .as_mut() .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig)); - // FIXME reuse Function and FunctionBuilder between multiple trans_fn calls - let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig)); + // Make FunctionBuilder + let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); // Predefine ebb's let start_ebb = bcx.create_ebb(); @@ -56,9 +58,6 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( codegen_fn_content(&mut fx); }); - fx.bcx.seal_all_blocks(); - let func = fx.bcx.finalize(); - // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; let clif_comments = fx.clif_comments; @@ -239,6 +238,9 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } }; } + + fx.bcx.seal_all_blocks(); + fx.bcx.finalize(); } fn trans_stmt<'tcx>( diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 2d2aa7e1a1d71..6653b4e2d91f5 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -98,7 +98,7 @@ pub fn maybe_codegen<'tcx>( // Optimize `val >> 64`, because compiler_builtins uses it to deconstruct an 128bit // integer into its lsb and msb. // https://github.com/rust-lang-nursery/compiler-builtins/blob/79a6a1603d5672cbb9187ff41ff4d9b5048ac1cb/src/int/mod.rs#L217 - if let Some(64) = resolve_value_imm(&fx.bcx.func, rhs_val) { + if let Some(64) = resolve_value_imm(fx.bcx.func, rhs_val) { let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); let all_zeros = fx.bcx.ins().iconst(types::I64, 0); let val = match (bin_op, is_signed) { diff --git a/src/common.rs b/src/common.rs index 85778f4c8e98d..3ebae0506c5c1 100644 --- a/src/common.rs +++ b/src/common.rs @@ -279,7 +279,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub instance: Instance<'tcx>, pub mir: &'tcx Body<'tcx>, - pub bcx: FunctionBuilder, + pub bcx: FunctionBuilder<'clif>, pub ebb_map: HashMap, pub local_map: HashMap>, diff --git a/src/main_shim.rs b/src/main_shim.rs index 788b65a823026..17783b01d26aa 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -56,10 +56,10 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module, module: &mut Module, ms // Ignore DuplicateDefinition error, as the data will be the same let _ = fx.module.define_data(msg_id, &data_ctx); - let local_msg_id = fx.module.declare_data_in_func(msg_id, &mut fx.bcx.func); + let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); #[cfg(debug_assertions)] { fx.add_entity_comment(local_msg_id, msg); From 39796d162ee1e3477480f0bb5f66ecb70ae49d8a Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2019 20:30:18 +0200 Subject: [PATCH 0902/1566] Bump cranelift from `c7fd5d9` to `ee6fe21` (#742) Bumps [cranelift](https://github.com/CraneStation/cranelift) from `c7fd5d9` to `ee6fe21`. - [Release notes](https://github.com/CraneStation/cranelift/releases) - [Commits](https://github.com/CraneStation/cranelift/compare/c7fd5d9a47198ecf87c06716b351909417fecf6f...ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 780571887c45d..843d6b23ca1ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,7 +61,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -78,7 +78,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -103,17 +103,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" [[package]] name = "cranelift-entity" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" [[package]] name = "cranelift-faerie" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -126,7 +126,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -137,7 +137,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -158,7 +158,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" +source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", From 721fe3b43c93927ab2cd4bcf99daeb5f157cdc54 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 4 Oct 2019 14:39:14 +0200 Subject: [PATCH 0903/1566] Predefine all local functions before codegen Otherwise only calls to previously codegened functions use relative addressing instead of the GOT Fixes #692 --- src/driver.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/driver.rs b/src/driver.rs index f02ba35904ff9..b8e91b9365767 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -307,7 +307,19 @@ fn codegen_mono_items<'tcx>( mono_items: FxHashMap, (RLinkage, Visibility)>, ) { let mut cx = CodegenCx::new(tcx, module, debug_context); + time("codegen mono items", move || { + for (&mono_item, &(linkage, visibility)) in &mono_items { + match mono_item { + MonoItem::Fn(instance) => { + let (name, sig) = get_function_name_and_sig(tcx, instance, false); + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + cx.module.declare_function(&name, linkage, &sig).unwrap(); + } + MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} + } + } + for (mono_item, (linkage, visibility)) in mono_items { crate::unimpl::try_unimpl(tcx, log, || { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); From b0de88b741ee6d6453ee9a4c83f488f792d6d2eb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 4 Oct 2019 14:57:07 +0200 Subject: [PATCH 0904/1566] Use DisplayFunctionAnnotations::default() --- src/pretty_clif.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 1dd1157bfaa4a..0216ba11c37a4 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -253,11 +253,7 @@ impl<'a, 'tcx, B: Backend + 'static> fmt::Debug for FunctionCx<'_, 'tcx, B> { &mut &self.clif_comments, &mut clif, &self.bcx.func, - // FIXME use DisplayFunctionAnnotations::default() instead - &DisplayFunctionAnnotations { - isa: None, - value_ranges: None, - }, + &DisplayFunctionAnnotations::default(), ) .unwrap(); writeln!(f, "\n{}", clif) From a31ec018e8db9aa950327a731bc2207370b61dee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 4 Oct 2019 21:11:00 +0200 Subject: [PATCH 0905/1566] Update Cranelift --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 843d6b23ca1ca..cee77496ced76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,7 +61,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -78,7 +78,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -103,17 +103,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" [[package]] name = "cranelift-entity" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" [[package]] name = "cranelift-faerie" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -126,7 +126,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -137,7 +137,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -158,7 +158,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#ee6fe21f924179466dd10c7b5b1e3c8e2422a7fa" +source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" dependencies = [ "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", From 8bb81fdc3b8507a0537231d0636dc3964dc44b94 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 4 Oct 2019 21:11:58 +0200 Subject: [PATCH 0906/1566] Update dependencies --- Cargo.lock | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cee77496ced76..ce707861fe8ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,11 +20,11 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.37" +version = "0.3.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -40,7 +40,7 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -55,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -175,7 +175,7 @@ name = "crc32fast" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -216,7 +216,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -238,12 +238,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "flate2" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -303,7 +303,7 @@ name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -314,15 +314,6 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "miniz-sys" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "miniz_oxide" version = "0.3.2" @@ -341,7 +332,7 @@ name = "object" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -374,7 +365,7 @@ name = "raw-cpuid" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -384,7 +375,7 @@ name = "region" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -400,7 +391,7 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -467,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_json" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -521,7 +512,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -557,12 +548,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" -"checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" +"checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" -"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" +"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" -"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -581,7 +572,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -"checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" +"checksum flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" @@ -591,7 +582,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" "checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81afbc5773e99efe9533d8a539dfac37e531dcd0f4eeb41584bae03ccf76d4c2" @@ -608,7 +598,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" -"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" From b5d29a8c5889a0cbbab6511352e81ff47691ce61 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Oct 2019 10:41:15 +0200 Subject: [PATCH 0907/1566] Rustup to rustc 1.40.0-nightly (787005079 2019-10-04) --- ...3-Disable-inline-assembly-in-libcore.patch | 20 ------------------- src/base.rs | 6 ++++++ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/patches/0003-Disable-inline-assembly-in-libcore.patch b/patches/0003-Disable-inline-assembly-in-libcore.patch index 527dbda821c94..dce18ec1ad98e 100644 --- a/patches/0003-Disable-inline-assembly-in-libcore.patch +++ b/patches/0003-Disable-inline-assembly-in-libcore.patch @@ -25,25 +25,5 @@ index ad5a207..04712b8 100644 } + */ } -diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs -index ce35181..7d3f6a5 100644 ---- a/src/libcore/hint.rs -+++ b/src/libcore/hint.rs -@@ -128,6 +128,7 @@ pub fn black_box(dummy: T) -> T { - // this. LLVM's intepretation of inline assembly is that it's, well, a black - // box. This isn't the greatest implementation since it probably deoptimizes - // more than we want, but it's so far good enough. -+/* - #[cfg(not(any( - target_arch = "asmjs", - all( -@@ -139,6 +140,7 @@ pub fn black_box(dummy: T) -> T { - asm!("" : : "r"(&dummy)); - return dummy; - } -+*/ - - // Not all platforms support inline assembly so try to do something without - // inline assembly which in theory still hinders at least some optimizations -- 2.17.2 (Apple Git-113) diff --git a/src/base.rs b/src/base.rs index 7cb079567f1e6..96f3b783d9170 100644 --- a/src/base.rs +++ b/src/base.rs @@ -536,6 +536,12 @@ fn trans_stmt<'tcx>( asm_str_style: _, } = asm; match &*asm_code.as_str() { + "" => { + assert_eq!(inputs, &[Name::intern("r")]); + assert!(outputs.is_empty(), "{:?}", outputs); + + // Black box + } "cpuid" | "cpuid\n" => { assert_eq!(inputs, &[Name::intern("{eax}"), Name::intern("{ecx}")]); From 6129921529e2b4787a0d206244c7a858622b8d6d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Oct 2019 15:51:43 +0200 Subject: [PATCH 0908/1566] More 128bit support * UnOp::Neg * ctpop * bitreverse Also replaces `if let Some(64u128) = ...` with `if ... = Some(u64u128)` to be able to compile cg_clif using cg_clif, as cranelift_frontend::Switch doesn't support i128 yet. --- src/base.rs | 27 ++++++++++----------------- src/codegen_i128.rs | 2 +- src/intrinsics.rs | 22 ++++++++++++++++++++-- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/base.rs b/src/base.rs index 96f3b783d9170..1a78f33ae7363 100644 --- a/src/base.rs +++ b/src/base.rs @@ -313,33 +313,26 @@ fn trans_stmt<'tcx>( ty::Bool => { let val = fx.bcx.ins().uextend(types::I32, val); // WORKAROUND for CraneStation/cranelift#466 let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); - fx.bcx.ins().bint(types::I8, res) + CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout) + } + ty::Uint(_) | ty::Int(_) => { + CValue::by_val(fx.bcx.ins().bnot(val), layout) } - ty::Uint(_) | ty::Int(_) => fx.bcx.ins().bnot(val), _ => unimplemented!("un op Not for {:?}", layout.ty), } } UnOp::Neg => match layout.ty.kind { ty::Int(_) => { - let clif_ty = fx.clif_type(layout.ty).unwrap(); - if clif_ty == types::I128 { - // FIXME implement it - crate::trap::trap_unreachable_ret_value( - fx, - layout, - "i128 neg is not yet supported", - ) - .load_scalar(fx) - } else { - let zero = fx.bcx.ins().iconst(clif_ty, 0); - fx.bcx.ins().isub(zero, val) - } + let zero = CValue::const_val(fx, layout.ty, 0); + crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand) + } + ty::Float(_) => { + CValue::by_val(fx.bcx.ins().fneg(val), layout) } - ty::Float(_) => fx.bcx.ins().fneg(val), _ => unimplemented!("un op Neg for {:?}", layout.ty), }, }; - lval.write_cvalue(fx, CValue::by_val(res, layout)); + lval.write_cvalue(fx, res); } Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, ty) => { let layout = fx.layout_of(ty); diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 6653b4e2d91f5..be0ed1668f859 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -98,7 +98,7 @@ pub fn maybe_codegen<'tcx>( // Optimize `val >> 64`, because compiler_builtins uses it to deconstruct an 128bit // integer into its lsb and msb. // https://github.com/rust-lang-nursery/compiler-builtins/blob/79a6a1603d5672cbb9187ff41ff4d9b5048ac1cb/src/int/mod.rs#L217 - if let Some(64) = resolve_value_imm(fx.bcx.func, rhs_val) { + if resolve_value_imm(fx.bcx.func, rhs_val) == Some(64) { let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); let all_zeros = fx.bcx.ins().iconst(types::I64, 0); let val = match (bin_op, is_signed) { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 44aa2151a7541..0910b878890cb 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -700,11 +700,29 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, res); }; ctpop, (v arg) { - let res = CValue::by_val(fx.bcx.ins().popcnt(arg), fx.layout_of(T)); + let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { + let (lo, hi) = fx.bcx.ins().isplit(arg); + let lo_popcnt = fx.bcx.ins().popcnt(lo); + let hi_popcnt = fx.bcx.ins().popcnt(hi); + let popcnt = fx.bcx.ins().iadd(lo_popcnt, hi_popcnt); + crate::cast::clif_intcast(fx, popcnt, types::I128, false) + } else { + fx.bcx.ins().popcnt(arg) + }; + let res = CValue::by_val(res, fx.layout_of(T)); ret.write_cvalue(fx, res); }; bitreverse, (v arg) { - let res = CValue::by_val(fx.bcx.ins().bitrev(arg), fx.layout_of(T)); + let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { + let (lo, hi) = fx.bcx.ins().isplit(arg); + let lo_bitrev = fx.bcx.ins().bitrev(lo); + let hi_bitrev = fx.bcx.ins().bitrev(hi); + let bitrev = fx.bcx.ins().iconcat(hi_bitrev, lo_bitrev); + crate::cast::clif_intcast(fx, bitrev, types::I128, false) + } else { + fx.bcx.ins().bitrev(arg) + }; + let res = CValue::by_val(res, fx.layout_of(T)); ret.write_cvalue(fx, res); }; bswap, (v arg) { From 75db7cc49de7342420dce56528136319bc02bad0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Oct 2019 17:31:46 +0200 Subject: [PATCH 0909/1566] Remove logfile support from unimpl.rs I haven't used it in months --- src/base.rs | 8 +++----- src/driver.rs | 24 +++++++----------------- src/lib.rs | 2 +- src/unimpl.rs | 38 ++++++++++---------------------------- test.sh | 2 -- 5 files changed, 21 insertions(+), 53 deletions(-) diff --git a/src/base.rs b/src/base.rs index 1a78f33ae7363..81750efd169e8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -53,10 +53,8 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( source_info_set: indexmap::IndexSet::new(), }; - with_unimpl_span(fx.mir.span, || { - crate::abi::codegen_fn_prelude(&mut fx, start_ebb); - codegen_fn_content(&mut fx); - }); + crate::abi::codegen_fn_prelude(&mut fx, start_ebb); + codegen_fn_content(&mut fx); // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; @@ -500,7 +498,7 @@ fn trans_stmt<'tcx>( to.write_cvalue(fx, operand); } } - _ => unimpl!("shouldn't exist at trans {:?}", to_place_and_rval.1), + _ => unreachable!("shouldn't exist at trans {:?}", to_place_and_rval.1), }, } } diff --git a/src/driver.rs b/src/driver.rs index b8e91b9365767..19f53ebda1314 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -1,6 +1,5 @@ use std::any::Any; use std::ffi::CString; -use std::fs::File; use std::os::raw::{c_char, c_int}; use rustc::middle::cstore::EncodedMetadata; @@ -20,27 +19,21 @@ pub fn codegen_crate( ) -> Box { tcx.sess.abort_if_errors(); - let mut log = if cfg!(debug_assertions) { - Some(File::create(concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/log.txt")).unwrap()) - } else { - None - }; - if std::env::var("SHOULD_RUN").is_ok() && tcx.sess.crate_types.get().contains(&CrateType::Executable) { #[cfg(not(target_arch = "wasm32"))] - let _: ! = run_jit(tcx, &mut log); + let _: ! = run_jit(tcx); #[cfg(target_arch = "wasm32")] panic!("jit not supported on wasm"); } - run_aot(tcx, metadata, need_metadata_module, &mut log) + run_aot(tcx, metadata, need_metadata_module) } #[cfg(not(target_arch = "wasm32"))] -fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { +fn run_jit(tcx: TyCtxt<'_>) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; let imported_symbols = load_imported_symbols_for_jit(tcx); @@ -67,7 +60,7 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option) -> ! { .declare_function("main", Linkage::Import, &sig) .unwrap(); - codegen_cgus(tcx, &mut jit_module, &mut None, log); + codegen_cgus(tcx, &mut jit_module, &mut None); crate::allocator::codegen(tcx, &mut jit_module); jit_module.finalize_definitions(); @@ -152,7 +145,6 @@ fn run_aot( tcx: TyCtxt<'_>, metadata: EncodedMetadata, need_metadata_module: bool, - log: &mut Option, ) -> Box { let new_module = |name: String| { let module: Module = Module::new( @@ -207,7 +199,7 @@ fn run_aot( None }; - codegen_cgus(tcx, &mut faerie_module, &mut debug, log); + codegen_cgus(tcx, &mut faerie_module, &mut debug); tcx.sess.abort_if_errors(); @@ -285,7 +277,6 @@ fn codegen_cgus<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, debug: &mut Option>, - log: &mut Option, ) { let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); let mono_items = cgus @@ -294,7 +285,7 @@ fn codegen_cgus<'tcx>( .flatten() .collect::>(); - codegen_mono_items(tcx, module, debug.as_mut(), log, mono_items); + codegen_mono_items(tcx, module, debug.as_mut(), mono_items); crate::main_shim::maybe_create_entry_wrapper(tcx, module); } @@ -303,7 +294,6 @@ fn codegen_mono_items<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, debug_context: Option<&mut DebugContext<'tcx>>, - log: &mut Option, mono_items: FxHashMap, (RLinkage, Visibility)>, ) { let mut cx = CodegenCx::new(tcx, module, debug_context); @@ -321,7 +311,7 @@ fn codegen_mono_items<'tcx>( } for (mono_item, (linkage, visibility)) in mono_items { - crate::unimpl::try_unimpl(tcx, log, || { + crate::unimpl::try_unimpl(tcx, mono_item.to_string(tcx, true), || { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); trans_mono_item(&mut cx, mono_item, linkage); }); diff --git a/src/lib.rs b/src/lib.rs index 17b667daf0e49..60b113ade0d56 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,7 +105,7 @@ mod prelude { pub use crate::common::*; pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; pub use crate::trap::*; - pub use crate::unimpl::{unimpl, with_unimpl_span}; + pub use crate::unimpl::unimpl; pub use crate::value_and_place::{CPlace, CPlaceInner, CValue}; pub use crate::{Caches, CodegenCx}; diff --git a/src/unimpl.rs b/src/unimpl.rs index 81fc5b125c497..3e7dddc6445dc 100644 --- a/src/unimpl.rs +++ b/src/unimpl.rs @@ -2,15 +2,11 @@ //! a non-fatal error on not yet implemented things. use std::cell::RefCell; -use std::fs::File; -use std::io::Write; - -use syntax::source_map::Span; use rustc::ty::TyCtxt; thread_local! { - static SPAN_STACK: RefCell> = RefCell::new(vec![]); + static CURRENT_MSG: RefCell = RefCell::new(String::new()); } // Just public, because of the unimpl macro @@ -24,35 +20,21 @@ pub macro unimpl($($tt:tt)*) { panic!(NonFatal(format!($($tt)*))); } -pub fn try_unimpl(tcx: TyCtxt, log: &mut Option, f: impl FnOnce()) { - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); +pub fn try_unimpl(tcx: TyCtxt, msg: String, f: impl FnOnce()) { + CURRENT_MSG.with(|current_msg| { + let old = std::mem::replace(&mut *current_msg.borrow_mut(), msg); + + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); - if let Err(err) = res { - SPAN_STACK.with(|span_stack| { + if let Err(err) = res { match err.downcast::() { Ok(non_fatal) => { - if cfg!(debug_assertions) { - writeln!( - log.as_mut().unwrap(), - "{} at {:?}", - &non_fatal.0, - span_stack.borrow() - ) - .unwrap(); - } - tcx.sess.err(&non_fatal.0) + tcx.sess.err(&format!("at {}: {}", current_msg.borrow(), non_fatal.0)); } Err(err) => ::std::panic::resume_unwind(err), } - span_stack.borrow_mut().clear(); - }); - } -} + } -pub fn with_unimpl_span(span: Span, f: impl FnOnce()) { - SPAN_STACK.with(|span_stack| { - span_stack.borrow_mut().push(span); - f(); - span_stack.borrow_mut().pop(); + *current_msg.borrow_mut() = old; }); } diff --git a/test.sh b/test.sh index 532a96945a622..f32ec10268e6b 100755 --- a/test.sh +++ b/test.sh @@ -100,5 +100,3 @@ hyperfine --runs ${COMPILE_RUNS:-100} "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_ echo echo "[BENCH RUN] mod_bench" hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* - -cat target/out/log.txt | sort | uniq -c From 82fde5b62281fa51a72bb4fbbf4324ca623a68d1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 6 Oct 2019 17:52:23 +0200 Subject: [PATCH 0910/1566] Remove bitflags dependency --- Cargo.lock | 1 - Cargo.toml | 1 - src/abi/mod.rs | 10 ++-------- src/abi/returning.rs | 8 +++----- src/analyze.rs | 26 ++++++++++++-------------- 5 files changed, 17 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce707861fe8ef..c6b8ab0e39861 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -391,7 +391,6 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/Cargo.toml b/Cargo.toml index 74e1dda7e0404..66256cd68e14f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ faerie = "0.11.0" #goblin = "0.0.17" ar = "0.8.0" -bitflags = "1.1.0" byteorder = "1.2.7" libc = "0.2.53" gimli = "0.19.0" diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 8d4038065e946..dcd9a6ab932df 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -282,10 +282,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); - let is_ssa = !ssa_analyzed - .get(&local) - .unwrap() - .contains(crate::analyze::Flags::NOT_SSA); + let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa; match arg_kind { ArgKind::Normal(Some(val)) => { @@ -339,10 +336,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: let ty = fx.mir.local_decls[local].ty; let layout = fx.layout_of(ty); - let is_ssa = !ssa_analyzed - .get(&local) - .unwrap() - .contains(crate::analyze::Flags::NOT_SSA); + let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa; local_place(fx, local, layout, is_ssa); } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index f827f11df350a..762327934065b 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -3,7 +3,7 @@ use crate::prelude::*; pub fn codegen_return_param( fx: &mut FunctionCx, - ssa_analyzed: &HashMap, + ssa_analyzed: &HashMap, start_ebb: Ebb, ) { let ret_layout = fx.return_layout(); @@ -16,10 +16,8 @@ pub fn codegen_return_param( Empty } PassMode::ByVal(_) | PassMode::ByValPair(_, _) => { - let is_ssa = !ssa_analyzed - .get(&RETURN_PLACE) - .unwrap() - .contains(crate::analyze::Flags::NOT_SSA); + let is_ssa = + *ssa_analyzed.get(&RETURN_PLACE).unwrap() == crate::analyze::SsaKind::Ssa; super::local_place(fx, RETURN_PLACE, ret_layout, is_ssa); diff --git a/src/analyze.rs b/src/analyze.rs index 63b268597fe5c..fe58eaa18bb87 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -2,22 +2,20 @@ use crate::prelude::*; use rustc::mir::StatementKind::*; -bitflags::bitflags! { - pub struct Flags: u8 { - const NOT_SSA = 0b00000001; - } +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +pub enum SsaKind { + NotSsa, + Ssa, } -pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap { +pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap { let mut flag_map = HashMap::new(); - for local in fx.mir.local_decls.indices() { - flag_map.insert(local, Flags::empty()); - } - for (local, local_decl) in fx.mir.local_decls.iter_enumerated() { - if fx.clif_type(local_decl.ty).is_none() { - not_ssa(&mut flag_map, local); + if fx.clif_type(local_decl.ty).is_some() { + flag_map.insert(local, SsaKind::Ssa); + } else { + flag_map.insert(local, SsaKind::NotSsa); } } @@ -46,13 +44,13 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap { flag_map } -fn analyze_non_ssa_place(flag_map: &mut HashMap, place: &Place) { +fn analyze_non_ssa_place(flag_map: &mut HashMap, place: &Place) { match place.base { PlaceBase::Local(local) => not_ssa(flag_map, local), _ => {} } } -fn not_ssa>(flag_map: &mut HashMap, local: L) { - *flag_map.get_mut(local.borrow()).unwrap() |= Flags::NOT_SSA; +fn not_ssa>(flag_map: &mut HashMap, local: L) { + *flag_map.get_mut(local.borrow()).unwrap() = SsaKind::NotSsa; } From e948c1b6721c08a0ab45b66394f52e01af01a050 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2019 19:43:48 +0200 Subject: [PATCH 0911/1566] Bump miniz_oxide from 0.3.2 to 0.3.3 (#744) Bumps [miniz_oxide](https://github.com/Frommi/miniz_oxide) from 0.3.2 to 0.3.3. - [Release notes](https://github.com/Frommi/miniz_oxide/releases) - [Commits](https://github.com/Frommi/miniz_oxide/commits) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6b8ab0e39861..a297938f24f8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -244,7 +244,7 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -316,7 +316,7 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -581,7 +581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum miniz_oxide 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7108aff85b876d06f22503dcce091e29f76733b2bfdd91eebce81f5e68203a10" +"checksum miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "304f66c19be2afa56530fa7c39796192eef38618da8d19df725ad7c6d6b2aaae" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81afbc5773e99efe9533d8a539dfac37e531dcd0f4eeb41584bae03ccf76d4c2" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" From fc261aa2f5a08be85049aea1c5de6b2036307369 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 9 Oct 2019 20:34:25 +0200 Subject: [PATCH 0912/1566] Update Cranelift --- Cargo.lock | 110 ++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a297938f24f8d..37820bb901037 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,30 +60,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -93,30 +93,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" [[package]] name = "cranelift-entity" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" [[package]] name = "cranelift-faerie" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -125,10 +125,10 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -136,33 +136,33 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.44.0" -source = "git+https://github.com/CraneStation/cranelift.git#01201b110d55142c80bc34c2832a3c8823c94e60" +version = "0.45.0" +source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" dependencies = [ - "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -392,10 +392,10 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -553,17 +553,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-shared 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From f0c774e05d3ce268f845349f09317a229cd91481 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Oct 2019 18:39:12 +0200 Subject: [PATCH 0913/1566] Rustup to rustc 1.40.0-nightly (237d54ff6 2019-10-15) --- patches/0017-Fix-libtest-compilation.patch | 41 ++++++++++++---------- src/common.rs | 1 + src/lib.rs | 9 +---- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index 05b5675d43b33..b7a7267cd7877 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -21,14 +21,14 @@ index 8b76080..9e65de2 100644 use std::process; use std::process::{ExitStatus, Command, Termination}; @@ -1493,7 +1493,7 @@ pub fn run_test( - report_time: bool, - strategy: RunStrategy, + fn run_test_inner( + desc: TestDesc, monitor_ch: Sender, - testfn: Box, + testfn: Box, - concurrency: Concurrent, + opts: TestRunOpts, ) { - let name = desc.name.clone(); + let concurrency = opts.concurrency; @@ -1509,7 +1509,7 @@ pub fn run_test( // If the platform is single-threaded we're just going to run // the test synchronously, regardless of the concurrency @@ -38,7 +38,7 @@ index 8b76080..9e65de2 100644 if concurrency == Concurrent::Yes && supports_threads { let cfg = thread::Builder::new().name(name.as_slice().to_owned()); cfg.spawn(runtest).unwrap(); -@@ -1531,20 +1531,8 @@ pub fn run_test( +@@ -1531,17 +1531,8 @@ pub fn run_test( (benchfn.clone())(harness) }); } @@ -49,25 +49,25 @@ index 8b76080..9e65de2 100644 - }; - run_test_inner( - desc, -- opts.nocapture, -- opts.report_time, -- strategy, - monitor_ch, - Box::new(move || __rust_begin_short_backtrace(f)), -- concurrency +- test_run_opts, - ); + DynTestFn(_f) => { + unimplemented!(); } StaticTestFn(f) => run_test_inner( desc, -@@ -1604,7 +1592,7 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult { - fn run_test_in_process(desc: TestDesc, - nocapture: bool, - report_time: bool, -- testfn: Box, -+ testfn: Box, - monitor_ch: Sender) { +@@ -1604,10 +1592,10 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult { + fn run_test_in_process( + desc: TestDesc, + nocapture: bool, + report_time: bool, +- testfn: Box, ++ testfn: Box, + monitor_ch: Sender, + time_opts: Option, + ) { // Buffer for capturing standard I/O let data = Arc::new(Mutex::new(Vec::new())); @@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc, @@ -79,12 +79,15 @@ index 8b76080..9e65de2 100644 let exec_time = start.map(|start| { let duration = start.elapsed(); TestExecTime(duration) -@@ -1688,7 +1676,7 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender) -> ! { -+fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box) -> ! { + fn run_test_in_spawned_subprocess( + desc: TestDesc, +- testfn: Box, ++ testfn: Box, + ) -> ! { let builtin_panic_hook = panic::take_hook(); let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| { let test_result = match panic_info { diff --git a/src/common.rs b/src/common.rs index 3ebae0506c5c1..ff38c71fde9cc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -333,6 +333,7 @@ impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend> BackendTypes for FunctionCx<'_, 'tcx, B> { type Value = Value; + type Function = Value; type BasicBlock = Ebb; type Type = Type; type Funclet = !; diff --git a/src/lib.rs b/src/lib.rs index 60b113ade0d56..489ea71d33bda 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,10 +171,6 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn provide(&self, providers: &mut Providers) { - rustc_codegen_utils::symbol_names::provide(providers); - rustc_codegen_ssa::back::symbol_export::provide(providers); - rustc_codegen_ssa::base::provide_both(providers); - providers.target_features_whitelist = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); if tcx.sess.opts.actually_rustdoc { @@ -195,10 +191,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } }; } - fn provide_extern(&self, providers: &mut Providers) { - rustc_codegen_ssa::back::symbol_export::provide_extern(providers); - rustc_codegen_ssa::base::provide_both(providers); - } + fn provide_extern(&self, _providers: &mut Providers) {} fn codegen_crate<'tcx>( &self, From 59893d899f3062ca320f02d680e0be133affd118 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Oct 2019 19:01:39 +0200 Subject: [PATCH 0914/1566] Update Cranelift --- Cargo.lock | 110 ++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37820bb901037..c7c6da37dd4f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,30 +60,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-bforest 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-shared 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -93,30 +93,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-codegen-shared 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" [[package]] name = "cranelift-entity" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" [[package]] name = "cranelift-faerie" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -125,10 +125,10 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -136,33 +136,33 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.45.0" -source = "git+https://github.com/CraneStation/cranelift.git#b5783cfe0a1fee31d1d9375d60f7a0d8828df133" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" dependencies = [ - "cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -392,10 +392,10 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.45.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -553,17 +553,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-shared 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.45.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 0934dc84fd73d32b4964d6f80390bc9582e9152b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Oct 2019 19:13:11 +0200 Subject: [PATCH 0915/1566] Update dependencies --- Cargo.lock | 127 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7c6da37dd4f6..dab1e3f3860f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,10 +12,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "arrayvec" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", + "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -25,7 +25,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -35,12 +35,12 @@ version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bitflags" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -84,8 +84,8 @@ dependencies = [ "cranelift-codegen-meta 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -118,7 +118,7 @@ dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -141,7 +141,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -164,7 +164,7 @@ dependencies = [ "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -184,7 +184,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -194,7 +194,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -202,7 +202,7 @@ name = "faerie" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -213,22 +213,22 @@ dependencies = [ [[package]] name = "failure" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "failure_derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -243,7 +243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -257,7 +257,7 @@ name = "gimli" version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -286,7 +286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.62" +version = "0.2.64" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -311,7 +311,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -324,7 +324,7 @@ dependencies = [ [[package]] name = "nodrop" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -352,6 +352,14 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "proc-macro2" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quote" version = "0.6.13" @@ -360,12 +368,20 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "raw-cpuid" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -375,8 +391,8 @@ name = "region" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -399,7 +415,7 @@ dependencies = [ "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -415,7 +431,7 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -461,7 +477,7 @@ version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -493,15 +509,25 @@ dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" -version = "0.10.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -509,8 +535,8 @@ name = "target-lexicon" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -519,6 +545,11 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "uuid" version = "0.7.4" @@ -546,10 +577,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" -"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" +"checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" -"checksum bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a606a02debe2813760609f57a64a2ffd27d9fdf5b2f133eaca0b248dd92cdd2" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" @@ -568,8 +599,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "875d78b92b2a4d9e1e2c7eeccfa30a327d2ee6434db3beb8fd6fd92f41898bc4" -"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" -"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" +"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" +"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" @@ -577,21 +608,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +"checksum libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "304f66c19be2afa56530fa7c39796192eef38618da8d19df725ad7c6d6b2aaae" -"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" +"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81afbc5773e99efe9533d8a539dfac37e531dcd0f4eeb41584bae03ccf76d4c2" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" +"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -602,9 +635,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -"checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" +"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" "checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" From 8243a370d21a6d7b69c8d7fc11d2f2fc3e939297 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 18 Oct 2019 18:31:26 +0200 Subject: [PATCH 0916/1566] Rustup to rustc 1.40.0-nightly (fa0f7d008 2019-10-17) --- src/allocator.rs | 2 +- src/constant.rs | 2 +- src/lib.rs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 29e3ceb3a5a57..07294e8cfec9f 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -10,7 +10,7 @@ use crate::prelude::*; -use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; +use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { diff --git a/src/constant.rs b/src/constant.rs index 9a1685038bd1e..2f0f930574c5e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -171,7 +171,7 @@ fn trans_const_place<'tcx>( let ptr = ecx.allocate(op.layout, MemoryKind::Stack); ecx.copy_op(op, ptr.into())?; let alloc = ecx - .memory() + .memory .get(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) }; diff --git a/src/lib.rs b/src/lib.rs index 489ea71d33bda..866a3d31146b2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ extern crate rustc_index; extern crate rustc_mir; extern crate rustc_target; extern crate syntax; +extern crate syntax_expand; use std::any::Any; From f9ff604d966ff9fa180ac171b27ef5bd7db43eb1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Oct 2019 20:48:09 +0200 Subject: [PATCH 0917/1566] Make dylib metadata write backend agnostic --- Cargo.lock | 15 +++++++++++++++ Cargo.toml | 4 +++- src/backend.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + src/metadata.rs | 27 ++++++++------------------- 5 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 src/backend.rs diff --git a/Cargo.lock b/Cargo.lock index dab1e3f3860f9..d67181bd56284 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,6 +155,17 @@ dependencies = [ "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "cranelift-object" +version = "0.46.1" +source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +dependencies = [ + "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cranelift-simplejit" version = "0.46.1" @@ -332,8 +343,10 @@ name = "object" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -411,6 +424,7 @@ dependencies = [ "cranelift 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-faerie 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-object 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -594,6 +608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cranelift-frontend 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-native 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-object 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-simplejit 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" diff --git a/Cargo.toml b/Cargo.toml index 66256cd68e14f..f3b9e84378867 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ crate-type = ["dylib"] cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } +cranelift-object = { git = "https://github.com/CraneStation/cranelift.git" } target-lexicon = "0.8.1" faerie = "0.11.0" @@ -28,7 +29,7 @@ libloading = "0.5.1" [dependencies.object] version = "0.14.0" default-features = false -features = ["compression", "read", "std"] # We don't need WASM support +features = ["compression", "read", "std", "write"] # We don't need WASM support # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] @@ -36,6 +37,7 @@ features = ["compression", "read", "std"] # We don't need WASM support #cranelift-module = { path = "../cranelift/cranelift-module" } #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } #cranelift-faerie = { path = "../cranelift/cranelift-faerie" } +#cranelift-object = { path = "../cranelift/cranelift-object" } #[patch.crates-io] #gimli = { path = "../" } diff --git a/src/backend.rs b/src/backend.rs new file mode 100644 index 0000000000000..f070e95f535e0 --- /dev/null +++ b/src/backend.rs @@ -0,0 +1,48 @@ +pub trait Product { + fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool); +} + +impl Product for faerie::Artifact { + fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool) { + self + .declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)) + .unwrap(); + self + .define_with_symbols(".rustc", data, { + let mut map = std::collections::BTreeMap::new(); + // FIXME implement faerie elf backend section custom symbols + // For MachO this is necessary to prevent the linker from throwing away the .rustc section, + // but for ELF it isn't. + if is_like_osx { + map.insert( + symbol_name, + 0, + ); + } + map + }) + .unwrap(); + } +} + +impl Product for object::write::Object { + fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool) { + let segment = self.segment_name(object::write::StandardSegment::Data).to_vec(); + let section_id = self.add_section(segment, b".rustc".to_vec(), object::SectionKind::Data); + let offset = self.append_section_data(section_id, &data, 1); + // FIXME implement faerie elf backend section custom symbols + // For MachO this is necessary to prevent the linker from throwing away the .rustc section, + // but for ELF it isn't. + if is_like_osx { + self.add_symbol(object::write::Symbol { + name: symbol_name.into_bytes(), + value: offset, + size: data.len() as u64, + kind: object::SymbolKind::Data, + scope: object::SymbolScope::Compilation, + weak: false, + section: Some(section_id), + }); + } + } +} diff --git a/src/lib.rs b/src/lib.rs index 866a3d31146b2..7e68f10ede03f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,6 +35,7 @@ mod allocator; mod analyze; mod archive; mod base; +mod backend; mod cast; mod codegen_i128; mod common; diff --git a/src/metadata.rs b/src/metadata.rs index 8d17922725aa7..76c86e73853f0 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -9,6 +9,8 @@ use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::rustc_erase_owner; use rustc_target::spec::Target; +use crate::backend::Product; + pub struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { @@ -51,7 +53,7 @@ impl MetadataLoader for CraneliftMetadataLoader { } // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 -pub fn write_metadata(tcx: TyCtxt<'_>, artifact: &mut faerie::Artifact) -> EncodedMetadata { +pub fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) -> EncodedMetadata { use flate2::write::DeflateEncoder; use flate2::Compression; use std::io::Write; @@ -95,24 +97,11 @@ pub fn write_metadata(tcx: TyCtxt<'_>, artifact: &mut faerie::Artifact) -> Encod .write_all(&metadata.raw_data) .unwrap(); - artifact - .declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)) - .unwrap(); - artifact - .define_with_symbols(".rustc", compressed, { - let mut map = std::collections::BTreeMap::new(); - // FIXME implement faerie elf backend section custom symbols - // For MachO this is necessary to prevent the linker from throwing away the .rustc section, - // but for ELF it isn't. - if tcx.sess.target.target.options.is_like_osx { - map.insert( - rustc::middle::exported_symbols::metadata_symbol_name(tcx), - 0, - ); - } - map - }) - .unwrap(); + product.add_rustc_section( + rustc::middle::exported_symbols::metadata_symbol_name(tcx), + compressed, + tcx.sess.target.target.options.is_like_osx, + ); metadata } From 5873127ec2b1d748bb673c0193682a563fcb6fe0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Oct 2019 21:21:20 +0200 Subject: [PATCH 0918/1566] Make debuginfo writing backend agnostic --- src/backend.rs | 107 +++++++++++++++++++++++++++++++++++++++++++++-- src/base.rs | 2 +- src/debuginfo.rs | 60 +++++++++----------------- src/metadata.rs | 4 +- 4 files changed, 126 insertions(+), 47 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index f070e95f535e0..429c48ba0e389 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,8 +1,21 @@ -pub trait Product { +use std::collections::HashMap; + +use cranelift_module::FuncId; + +use faerie::*; +use object::{SectionKind, RelocationKind, RelocationEncoding}; +use object::write::*; +use cranelift_object::*; + +use gimli::SectionId; + +use crate::debuginfo::{DebugReloc, DebugRelocName}; + +pub trait WriteMetadata { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool); } -impl Product for faerie::Artifact { +impl WriteMetadata for faerie::Artifact { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool) { self .declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)) @@ -25,7 +38,7 @@ impl Product for faerie::Artifact { } } -impl Product for object::write::Object { +impl WriteMetadata for object::write::Object { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool) { let segment = self.segment_name(object::write::StandardSegment::Data).to_vec(); let section_id = self.add_section(segment, b".rustc".to_vec(), object::SectionKind::Data); @@ -46,3 +59,91 @@ impl Product for object::write::Object { } } } + +pub trait WriteDebugInfo { + type SectionId; + + fn add_debug_section(&mut self, name: SectionId, data: Vec) -> Self::SectionId; + fn add_debug_reloc( + &mut self, + section_map: &HashMap, + symbol_map: &indexmap::IndexSet<(String, FuncId)>, + from: &Self::SectionId, + reloc: &DebugReloc, + ); +} + +impl WriteDebugInfo for Artifact { + type SectionId = SectionId; + + fn add_debug_section(&mut self, id: SectionId, data: Vec) -> SectionId { + self.declare_with(id.name(), Decl::section(faerie::SectionKind::Debug), data).unwrap(); + id + } + + fn add_debug_reloc( + &mut self, + _section_map: &HashMap, + symbol_map: &indexmap::IndexSet<(String, FuncId)>, + from: &Self::SectionId, + reloc: &DebugReloc, + ) { + self + .link_with( + faerie::Link { + from: from.name(), + to: match reloc.name { + DebugRelocName::Section(id) => id.name(), + DebugRelocName::Symbol(index) => &symbol_map.get_index(index).unwrap().0, + }, + at: u64::from(reloc.offset), + }, + faerie::Reloc::Debug { + size: reloc.size, + addend: reloc.addend as i32, + }, + ) + .expect("faerie relocation error"); + } +} + +impl WriteDebugInfo for ObjectProduct { + type SectionId = (object::write::SectionId, object::write::SymbolId); + + fn add_debug_section( + &mut self, + id: SectionId, + data: Vec, + ) -> (object::write::SectionId, object::write::SymbolId) { + let segment = self.object.segment_name(StandardSegment::Debug).to_vec(); + let name = id.name().as_bytes().to_vec(); + let section_id = self.object.add_section(segment, name, SectionKind::Debug); + self.object.section_mut(section_id).set_data(data, 1); + let symbol_id = self.object.section_symbol(section_id); + (section_id, symbol_id) + } + + fn add_debug_reloc( + &mut self, + section_map: &HashMap, + symbol_map: &indexmap::IndexSet<(String, FuncId)>, + from: &Self::SectionId, + reloc: &DebugReloc, + ) { + let symbol = match reloc.name { + DebugRelocName::Section(id) => section_map.get(&id).unwrap().1, + DebugRelocName::Symbol(id) => { + let (_func_name, func_id) = symbol_map.get_index(id).unwrap(); + self.function_symbol(*func_id) + } + }; + self.object.add_relocation(from.0, Relocation { + offset: u64::from(reloc.offset), + symbol, + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: reloc.size * 8, + addend: reloc.addend, + }).unwrap(); + } +} diff --git a/src/base.rs b/src/base.rs index 81750efd169e8..ef32dafb2efc5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -17,7 +17,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut debug_context = cx .debug_context .as_mut() - .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig)); + .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, func_id, &name, &sig)); // Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 0ded96cec8a58..d2705c6a2c74c 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -1,5 +1,7 @@ use crate::prelude::*; +use crate::backend::WriteDebugInfo; + use std::marker::PhantomData; use syntax::source_map::FileName; @@ -10,8 +12,6 @@ use gimli::write::{ }; use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, SectionId}; -use faerie::*; - fn target_endian(tcx: TyCtxt) -> RunTimeEndian { use rustc::ty::layout::Endian; @@ -56,31 +56,22 @@ fn line_program_add_file( } #[derive(Clone)] -struct DebugReloc { - offset: u32, - size: u8, - name: DebugRelocName, - addend: i64, +pub struct DebugReloc { + pub offset: u32, + pub size: u8, + pub name: DebugRelocName, + pub addend: i64, } #[derive(Clone)] -enum DebugRelocName { +pub enum DebugRelocName { Section(SectionId), Symbol(usize), } -impl DebugReloc { - fn name<'a>(&self, ctx: &'a DebugContext) -> &'a str { - match self.name { - DebugRelocName::Section(id) => id.name(), - DebugRelocName::Symbol(index) => ctx.symbols.get_index(index).unwrap(), - } - } -} - pub struct DebugContext<'tcx> { endian: RunTimeEndian, - symbols: indexmap::IndexSet, + symbols: indexmap::IndexSet<(String, FuncId)>, dwarf: DwarfUnit, unit_range_list: RangeList, @@ -177,7 +168,7 @@ impl<'tcx> DebugContext<'tcx> { ); } - pub fn emit(&mut self, artifact: &mut Artifact) { + pub fn emit(&mut self, product: &mut P) { let unit_range_list_id = self.dwarf.unit.ranges.add(self.unit_range_list.clone()); let root = self.dwarf.unit.root(); let root = self.dwarf.unit.get_mut(root); @@ -189,34 +180,20 @@ impl<'tcx> DebugContext<'tcx> { let mut sections = Sections::new(WriterRelocate::new(self)); self.dwarf.write(&mut sections).unwrap(); + let mut section_map = HashMap::new(); let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { - artifact - .declare_with( - id.name(), - Decl::section(SectionKind::Debug), - section.writer.take(), - ) - .unwrap(); + let section_id = product.add_debug_section(id, section.writer.take()); + section_map.insert(id, section_id); } Ok(()) }); let _: Result<()> = sections.for_each(|id, section| { - for reloc in §ion.relocs { - artifact - .link_with( - faerie::Link { - from: id.name(), - to: reloc.name(self), - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); + if let Some(section_id) = section_map.get(&id) { + for reloc in §ion.relocs { + product.add_debug_reloc(§ion_map, &self.symbols, section_id, reloc); + } } Ok(()) }); @@ -235,10 +212,11 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { tcx: TyCtxt<'tcx>, debug_context: &'a mut DebugContext<'tcx>, mir: &Body, + func_id: FuncId, name: &str, _sig: &Signature, ) -> Self { - let (symbol, _) = debug_context.symbols.insert_full(name.to_string()); + let (symbol, _) = debug_context.symbols.insert_full((name.to_string(), func_id)); // FIXME: add to appropriate scope intead of root let scope = debug_context.dwarf.unit.root(); diff --git a/src/metadata.rs b/src/metadata.rs index 76c86e73853f0..f15e1682d13d3 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -9,7 +9,7 @@ use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::rustc_erase_owner; use rustc_target::spec::Target; -use crate::backend::Product; +use crate::backend::WriteMetadata; pub struct CraneliftMetadataLoader; @@ -53,7 +53,7 @@ impl MetadataLoader for CraneliftMetadataLoader { } // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 -pub fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) -> EncodedMetadata { +pub fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) -> EncodedMetadata { use flate2::write::DeflateEncoder; use flate2::Compression; use std::io::Write; From 0471ed27766724e0bed9d96d4f107f3c12280828 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 18 Oct 2019 17:19:13 +0200 Subject: [PATCH 0919/1566] Add support for object::write --- Cargo.toml | 5 +++- src/backend.rs | 76 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/driver.rs | 59 +++++++++++++++++++-------------------- src/lib.rs | 2 +- 4 files changed, 107 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f3b9e84378867..0da280f24e299 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,9 @@ edition = "2018" [lib] crate-type = ["dylib"] +[features] +backend_object = ["object/write"] + [dependencies] # These have to be in sync with each other cranelift = { git = "https://github.com/CraneStation/cranelift.git" } @@ -29,7 +32,7 @@ libloading = "0.5.1" [dependencies.object] version = "0.14.0" default-features = false -features = ["compression", "read", "std", "write"] # We don't need WASM support +features = ["compression", "read", "std"] # We don't need WASM support # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] diff --git a/src/backend.rs b/src/backend.rs index 429c48ba0e389..449e2a5cc265e 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,10 +1,13 @@ use std::collections::HashMap; -use cranelift_module::FuncId; +use rustc::session::Session; + +use cranelift_module::{FuncId, Module}; use faerie::*; use object::{SectionKind, RelocationKind, RelocationEncoding}; use object::write::*; +use cranelift_faerie::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection}; use cranelift_object::*; use gimli::SectionId; @@ -73,11 +76,11 @@ pub trait WriteDebugInfo { ); } -impl WriteDebugInfo for Artifact { +impl WriteDebugInfo for FaerieProduct { type SectionId = SectionId; fn add_debug_section(&mut self, id: SectionId, data: Vec) -> SectionId { - self.declare_with(id.name(), Decl::section(faerie::SectionKind::Debug), data).unwrap(); + self.artifact.declare_with(id.name(), Decl::section(faerie::SectionKind::Debug), data).unwrap(); id } @@ -89,6 +92,7 @@ impl WriteDebugInfo for Artifact { reloc: &DebugReloc, ) { self + .artifact .link_with( faerie::Link { from: from.name(), @@ -147,3 +151,69 @@ impl WriteDebugInfo for ObjectProduct { }).unwrap(); } } + +pub trait Emit { + fn emit(self) -> Vec; +} + +impl Emit for FaerieProduct { + fn emit(self) -> Vec { + self.artifact.emit().unwrap() + } +} + +impl Emit for ObjectProduct { + fn emit(self) -> Vec { + self.object.write().unwrap() + } +} + +#[cfg(not(feature = "backend_object"))] +pub fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Artifact)) -> Vec { + let mut metadata_artifact = faerie::Artifact::new( + crate::build_isa(sess, true).triple().clone(), + name.to_string(), + ); + f(&mut metadata_artifact); + metadata_artifact.emit().unwrap() +} + +#[cfg(feature = "backend_object")] +pub fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec { + let triple = crate::build_isa(sess, true).triple().clone(); + let mut metadata_object = + object::write::Object::new(triple.binary_format, triple.architecture); + metadata_object.add_file_symbol(name.as_bytes().to_vec()); + f(&mut metadata_object); + metadata_object.write().unwrap() +} + +pub type Backend = impl cranelift_module::Backend; + +#[cfg(not(feature = "backend_object"))] +pub fn make_module(sess: &Session, name: String) -> Module { + let module: Module = Module::new( + FaerieBuilder::new( + crate::build_isa(sess, true), + name + ".o", + FaerieTrapCollection::Disabled, + cranelift_module::default_libcall_names(), + ) + .unwrap(), + ); + module +} + +#[cfg(feature = "backend_object")] +pub fn make_module(sess: &Session, name: String) -> Module { + let module: Module = Module::new( + ObjectBuilder::new( + crate::build_isa(sess, true), + name + ".o", + ObjectTrapCollection::Disabled, + cranelift_module::default_libcall_names(), + ) + .unwrap(), + ); + module +} diff --git a/src/driver.rs b/src/driver.rs index 19f53ebda1314..b26da23da907e 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -8,10 +8,10 @@ use rustc::session::config::{DebugInfo, OutputType}; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; -use cranelift_faerie::*; - use crate::prelude::*; +use crate::backend::{Emit, WriteDebugInfo}; + pub fn codegen_crate( tcx: TyCtxt<'_>, metadata: EncodedMetadata, @@ -147,36 +147,34 @@ fn run_aot( need_metadata_module: bool, ) -> Box { let new_module = |name: String| { - let module: Module = Module::new( - FaerieBuilder::new( - crate::build_isa(tcx.sess, true), - name + ".o", - FaerieTrapCollection::Disabled, - cranelift_module::default_libcall_names(), - ) - .unwrap(), - ); + let module = crate::backend::make_module(tcx.sess, name); assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); module }; - let emit_module = |kind: ModuleKind, - mut module: Module, - debug: Option| { + fn emit_module( + tcx: TyCtxt<'_>, + name: String, + kind: ModuleKind, + mut module: Module, + debug: Option, + ) -> CompiledModule + where B::Product: Emit + WriteDebugInfo, + { module.finalize_definitions(); - let mut artifact = module.finish().artifact; + let mut product = module.finish(); if let Some(mut debug) = debug { - debug.emit(&mut artifact); + debug.emit(&mut product); } let tmp_file = tcx .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, Some(&artifact.name)); - let obj = artifact.emit().unwrap(); + .temp_path(OutputType::Object, Some(&name)); + let obj = product.emit(); std::fs::write(&tmp_file, obj).unwrap(); CompiledModule { - name: artifact.name, + name: name, kind, object: Some(tmp_file), bytecode: None, @@ -184,7 +182,7 @@ fn run_aot( } }; - let mut faerie_module = new_module("some_file".to_string()); + let mut module = new_module("some_file".to_string()); let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None // macOS debuginfo doesn't work yet (see #303) @@ -192,14 +190,14 @@ fn run_aot( { let debug = DebugContext::new( tcx, - faerie_module.target_config().pointer_type().bytes() as u8, + module.target_config().pointer_type().bytes() as u8, ); Some(debug) } else { None }; - codegen_cgus(tcx, &mut faerie_module, &mut debug); + codegen_cgus(tcx, &mut module, &mut debug); tcx.sess.abort_if_errors(); @@ -221,17 +219,14 @@ fn run_aot( .as_str() .to_string(); - let mut metadata_artifact = faerie::Artifact::new( - crate::build_isa(tcx.sess, true).triple().clone(), - metadata_cgu_name.clone(), - ); - crate::metadata::write_metadata(tcx, &mut metadata_artifact); - let tmp_file = tcx .output_filenames(LOCAL_CRATE) .temp_path(OutputType::Metadata, Some(&metadata_cgu_name)); - let obj = metadata_artifact.emit().unwrap(); + let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| { + crate::metadata::write_metadata(tcx, object); + }); + std::fs::write(&tmp_file, obj).unwrap(); (metadata_cgu_name, tmp_file) @@ -251,12 +246,16 @@ fn run_aot( Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module( + tcx, + "some_file".to_string(), ModuleKind::Regular, - faerie_module, + module, debug, )], allocator_module: if created_alloc_shim { Some(emit_module( + tcx, + "allocator_shim".to_string(), ModuleKind::Allocator, allocator_module, None, diff --git a/src/lib.rs b/src/lib.rs index 7e68f10ede03f..169397f14a575 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, never_type, decl_macro)] +#![feature(rustc_private, never_type, decl_macro, type_alias_impl_trait, associated_type_bounds)] #![allow(intra_doc_link_resolution_failure)] extern crate flate2; From ecd9c4f2e32e88ec7fc06eaf85f758917494e632 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Oct 2019 10:52:56 +0200 Subject: [PATCH 0920/1566] FIx review comments --- src/backend.rs | 38 +++++++++++++++++--------------------- src/debuginfo.rs | 6 +++--- src/driver.rs | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index 449e2a5cc265e..60cf43da1b91f 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -42,24 +42,21 @@ impl WriteMetadata for faerie::Artifact { } impl WriteMetadata for object::write::Object { - fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool) { + fn add_rustc_section(&mut self, symbol_name: String, data: Vec, _is_like_osx: bool) { let segment = self.segment_name(object::write::StandardSegment::Data).to_vec(); let section_id = self.add_section(segment, b".rustc".to_vec(), object::SectionKind::Data); let offset = self.append_section_data(section_id, &data, 1); - // FIXME implement faerie elf backend section custom symbols - // For MachO this is necessary to prevent the linker from throwing away the .rustc section, - // but for ELF it isn't. - if is_like_osx { - self.add_symbol(object::write::Symbol { - name: symbol_name.into_bytes(), - value: offset, - size: data.len() as u64, - kind: object::SymbolKind::Data, - scope: object::SymbolScope::Compilation, - weak: false, - section: Some(section_id), - }); - } + // For MachO and probably PE this is necessary to prevent the linker from throwing away the + // .rustc section. For ELF this isn't necessary, but it also doesn't harm. + self.add_symbol(object::write::Symbol { + name: symbol_name.into_bytes(), + value: offset, + size: data.len() as u64, + kind: object::SymbolKind::Data, + scope: object::SymbolScope::Compilation, + weak: false, + section: Some(section_id), + }); } } @@ -70,7 +67,7 @@ pub trait WriteDebugInfo { fn add_debug_reloc( &mut self, section_map: &HashMap, - symbol_map: &indexmap::IndexSet<(String, FuncId)>, + symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ); @@ -87,7 +84,7 @@ impl WriteDebugInfo for FaerieProduct { fn add_debug_reloc( &mut self, _section_map: &HashMap, - symbol_map: &indexmap::IndexSet<(String, FuncId)>, + symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ) { @@ -98,7 +95,7 @@ impl WriteDebugInfo for FaerieProduct { from: from.name(), to: match reloc.name { DebugRelocName::Section(id) => id.name(), - DebugRelocName::Symbol(index) => &symbol_map.get_index(index).unwrap().0, + DebugRelocName::Symbol(index) => &symbol_map.get_index(index).unwrap().1, }, at: u64::from(reloc.offset), }, @@ -130,15 +127,14 @@ impl WriteDebugInfo for ObjectProduct { fn add_debug_reloc( &mut self, section_map: &HashMap, - symbol_map: &indexmap::IndexSet<(String, FuncId)>, + symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ) { let symbol = match reloc.name { DebugRelocName::Section(id) => section_map.get(&id).unwrap().1, DebugRelocName::Symbol(id) => { - let (_func_name, func_id) = symbol_map.get_index(id).unwrap(); - self.function_symbol(*func_id) + self.function_symbol(*symbol_map.get_index(id).unwrap().0) } }; self.object.add_relocation(from.0, Relocation { diff --git a/src/debuginfo.rs b/src/debuginfo.rs index d2705c6a2c74c..762fa8668bfba 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -71,7 +71,7 @@ pub enum DebugRelocName { pub struct DebugContext<'tcx> { endian: RunTimeEndian, - symbols: indexmap::IndexSet<(String, FuncId)>, + symbols: indexmap::IndexMap, dwarf: DwarfUnit, unit_range_list: RangeList, @@ -133,7 +133,7 @@ impl<'tcx> DebugContext<'tcx> { DebugContext { endian: target_endian(tcx), - symbols: indexmap::IndexSet::new(), + symbols: indexmap::IndexMap::new(), dwarf, unit_range_list: RangeList(Vec::new()), @@ -216,7 +216,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { name: &str, _sig: &Signature, ) -> Self { - let (symbol, _) = debug_context.symbols.insert_full((name.to_string(), func_id)); + let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string()); // FIXME: add to appropriate scope intead of root let scope = debug_context.dwarf.unit.root(); diff --git a/src/driver.rs b/src/driver.rs index b26da23da907e..215ae071c3f66 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -174,7 +174,7 @@ fn run_aot( let obj = product.emit(); std::fs::write(&tmp_file, obj).unwrap(); CompiledModule { - name: name, + name, kind, object: Some(tmp_file), bytecode: None, From bb5cefe83806b66838cf4ec5c9ea54919c7708b9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Oct 2019 10:56:35 +0200 Subject: [PATCH 0921/1566] Test object::write backend on travis --- .travis.yml | 3 +++ Cargo.toml | 4 ++-- src/backend.rs | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e73e9933976f6..548230651ccb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,3 +21,6 @@ env: - RUST_BACKTRACE=1 # Reduce amount of benchmark runs as they are slow. - COMPILE_RUNS=2 RUN_RUNS=2 + CG_CLIF_COMPILE_FLAGS: + - "" + - "--features backend_object" diff --git a/Cargo.toml b/Cargo.toml index 0da280f24e299..86347a006d7d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,14 +10,14 @@ edition = "2018" crate-type = ["dylib"] [features] -backend_object = ["object/write"] +backend_object = ["object/write", "cranelift-object"] [dependencies] # These have to be in sync with each other cranelift = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } -cranelift-object = { git = "https://github.com/CraneStation/cranelift.git" } +cranelift-object = { git = "https://github.com/CraneStation/cranelift.git", optional = true } target-lexicon = "0.8.1" faerie = "0.11.0" diff --git a/src/backend.rs b/src/backend.rs index 60cf43da1b91f..94b1cd7d58340 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -5,9 +5,13 @@ use rustc::session::Session; use cranelift_module::{FuncId, Module}; use faerie::*; +#[cfg(feature = "backend_object")] use object::{SectionKind, RelocationKind, RelocationEncoding}; +#[cfg(feature = "backend_object")] use object::write::*; use cranelift_faerie::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection}; + +#[cfg(feature = "backend_object")] use cranelift_object::*; use gimli::SectionId; @@ -41,6 +45,7 @@ impl WriteMetadata for faerie::Artifact { } } +#[cfg(feature = "backend_object")] impl WriteMetadata for object::write::Object { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, _is_like_osx: bool) { let segment = self.segment_name(object::write::StandardSegment::Data).to_vec(); @@ -108,6 +113,7 @@ impl WriteDebugInfo for FaerieProduct { } } +#[cfg(feature = "backend_object")] impl WriteDebugInfo for ObjectProduct { type SectionId = (object::write::SectionId, object::write::SymbolId); @@ -158,6 +164,7 @@ impl Emit for FaerieProduct { } } +#[cfg(feature = "backend_object")] impl Emit for ObjectProduct { fn emit(self) -> Vec { self.object.write().unwrap() From 4d7f70318a3e1729a1fa9e1884c719676c0d885a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Oct 2019 11:08:16 +0200 Subject: [PATCH 0922/1566] Fix metadata symbol scope It should be exported from the generated dylib --- src/backend.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.rs b/src/backend.rs index 94b1cd7d58340..ccb95624badf2 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -58,7 +58,7 @@ impl WriteMetadata for object::write::Object { value: offset, size: data.len() as u64, kind: object::SymbolKind::Data, - scope: object::SymbolScope::Compilation, + scope: object::SymbolScope::Dynamic, weak: false, section: Some(section_id), }); From 1901571d864941ca42cdb62165a4cb0c58afe5ec Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Oct 2019 11:10:34 +0200 Subject: [PATCH 0923/1566] Fix travis ci config --- .travis.yml | 6 +++--- test.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 548230651ccb2..765739785568e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,6 @@ env: - RUST_BACKTRACE=1 # Reduce amount of benchmark runs as they are slow. - COMPILE_RUNS=2 RUN_RUNS=2 - CG_CLIF_COMPILE_FLAGS: - - "" - - "--features backend_object" + jobs: + - "CG_CLIF_COMPILE_FLAGS=" + - "CG_CLIF_COMPILE_FLAGS='--features backend_object'" diff --git a/test.sh b/test.sh index f32ec10268e6b..773b7c296d429 100755 --- a/test.sh +++ b/test.sh @@ -4,10 +4,10 @@ set -e if [[ "$1" == "--release" ]]; then export CHANNEL='release' - cargo build --release + cargo build --release $CG_CLIF_COMPILE_FLAGS else export CHANNEL='debug' - cargo build + cargo build $CG_CLIF_COMPILE_FLAGS fi source config.sh From dda5ea883a2191b16e08ba1a455a5776acbe57d0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 19 Oct 2019 15:37:07 +0200 Subject: [PATCH 0924/1566] Fix debuginfo for machO This only fixes it when using object::write as backend, and not when using faerie. There were two problems: * object::write doesn't replace .debug_info with __debug_info, unlike faerie * machO requires section relative relocations, and not symbol relative relocations. When using symbol relative relocations, the linker interprets the relocations as section relative. Thus writing the wrong values to the debug sections. Fixes #303 --- src/backend.rs | 25 ++++++++++++++++++++----- src/driver.rs | 5 +---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index ccb95624badf2..3ed6e08f49778 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,4 +1,5 @@ use std::collections::HashMap; +use std::convert::TryFrom; use rustc::session::Session; @@ -122,8 +123,13 @@ impl WriteDebugInfo for ObjectProduct { id: SectionId, data: Vec, ) -> (object::write::SectionId, object::write::SymbolId) { + let name = if self.object.format() == target_lexicon::BinaryFormat::Macho { + id.name().replace('.', "__") // machO expects __debug_info instead of .debug_info + } else { + id.name().to_string() + }.into_bytes(); + let segment = self.object.segment_name(StandardSegment::Debug).to_vec(); - let name = id.name().as_bytes().to_vec(); let section_id = self.object.add_section(segment, name, SectionKind::Debug); self.object.section_mut(section_id).set_data(data, 1); let symbol_id = self.object.section_symbol(section_id); @@ -137,10 +143,19 @@ impl WriteDebugInfo for ObjectProduct { from: &Self::SectionId, reloc: &DebugReloc, ) { - let symbol = match reloc.name { - DebugRelocName::Section(id) => section_map.get(&id).unwrap().1, + let (symbol, symbol_offset) = match reloc.name { + DebugRelocName::Section(id) => { + (section_map.get(&id).unwrap().1, 0) + } DebugRelocName::Symbol(id) => { - self.function_symbol(*symbol_map.get_index(id).unwrap().0) + let symbol_id = self.function_symbol(*symbol_map.get_index(id).unwrap().0); + let symbol = self.object.symbol(symbol_id); + + // A symbol gets a section assigned when `add_symbol_data` is called. + let section = symbol.section.expect("Symbol not defined"); + let symbol_offset = symbol.value; + + (self.object.section_symbol(section), symbol_offset) } }; self.object.add_relocation(from.0, Relocation { @@ -149,7 +164,7 @@ impl WriteDebugInfo for ObjectProduct { kind: RelocationKind::Absolute, encoding: RelocationEncoding::Generic, size: reloc.size * 8, - addend: reloc.addend, + addend: i64::try_from(symbol_offset).unwrap() + reloc.addend, }).unwrap(); } } diff --git a/src/driver.rs b/src/driver.rs index 215ae071c3f66..22271460b02ba 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -184,10 +184,7 @@ fn run_aot( let mut module = new_module("some_file".to_string()); - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None - // macOS debuginfo doesn't work yet (see #303) - && !tcx.sess.target.target.options.is_like_osx - { + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { let debug = DebugContext::new( tcx, module.target_config().pointer_type().bytes() as u8, From 853651430824b49ab1e995b6bdcf2705badb99b1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 25 Oct 2019 21:24:50 +0200 Subject: [PATCH 0925/1566] Rustup to rustc 1.40.0-nightly (10a52c25c 2019-10-24) --- Cargo.toml | 8 +++---- example/mini_core.rs | 13 ++++++++--- example/mini_core_hello_world.rs | 2 +- patches/0017-Fix-libtest-compilation.patch | 26 +++++++++++----------- prepare.sh | 2 +- src/common.rs | 6 +++-- src/debuginfo.rs | 4 ++-- 7 files changed, 35 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 86347a006d7d9..e0a33638139d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } # By compiling dependencies with optimizations, performing tests gets much faster. opt-level = 3 -[profile.dev.overrides."rustc_codegen_cranelift"] +[profile.dev.package.rustc_codegen_cranelift] # Disabling optimizations for cg_clif itself makes compilation after a change faster. opt-level = 0 @@ -62,14 +62,14 @@ opt-level = 0 opt-level = 0 debug = false -[profile.dev.overrides.cranelift-codegen-meta] +[profile.dev.package.cranelift-codegen-meta] opt-level = 0 debug = false -[profile.dev.overrides.syn] +[profile.dev.package.syn] opt-level = 0 debug = false -[profile.dev.overrides.synstructure] +[profile.dev.package.synstructure] opt-level = 0 debug = false diff --git a/example/mini_core.rs b/example/mini_core.rs index a271cb6e62ef9..1d8942c6ab2c9 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,6 +1,6 @@ #![feature( no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, - untagged_unions, decl_macro, rustc_attrs + untagged_unions, decl_macro, rustc_attrs, transparent_unions )] #![no_core] #![allow(dead_code)] @@ -448,10 +448,17 @@ pub trait Drop { fn drop(&mut self); } -#[allow(unions_with_drop_fields)] +#[lang = "manually_drop"] +#[repr(transparent)] +pub struct ManuallyDrop { + pub value: T, +} + +#[lang = "maybe_uninit"] +#[repr(transparent)] pub union MaybeUninit { pub uninit: (), - pub value: T, + pub value: ManuallyDrop, } pub mod intrinsics { diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 76387e8c036b0..fdc71af443748 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -196,7 +196,7 @@ fn main() { } unsafe fn uninitialized() -> T { - MaybeUninit { uninit: () }.value + MaybeUninit { uninit: () }.value.value } zeroed::<(u8, u8)>(); diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index b7a7267cd7877..c76e2e2f8b42d 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -12,18 +12,18 @@ index 8b76080..9e65de2 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -52,7 +52,7 @@ use std::fmt; - use std::fs::File; - use std::io; - use std::io::prelude::*; --use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}; -+use std::panic::{self, PanicInfo}; - use std::path::PathBuf; - use std::process; - use std::process::{ExitStatus, Command, Termination}; + env, + io, + io::prelude::Write, +- panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}, ++ panic::{self, PanicInfo}, + process, + process::{Command, Termination}, + sync::mpsc::{channel, Sender}, @@ -1493,7 +1493,7 @@ pub fn run_test( fn run_test_inner( desc: TestDesc, - monitor_ch: Sender, + monitor_ch: Sender, - testfn: Box, + testfn: Box, opts: TestRunOpts, @@ -65,8 +65,8 @@ index 8b76080..9e65de2 100644 report_time: bool, - testfn: Box, + testfn: Box, - monitor_ch: Sender, - time_opts: Option, + monitor_ch: Sender, + time_opts: Option, ) { // Buffer for capturing standard I/O let data = Arc::new(Mutex::new(Vec::new())); @@ -75,12 +75,12 @@ index 8b76080..9e65de2 100644 None }; - let result = catch_unwind(AssertUnwindSafe(testfn)); -+ let result = Ok::<(), Box>(testfn()); ++ let result = Ok::<(), Box>(testfn()); let exec_time = start.map(|start| { let duration = start.elapsed(); TestExecTime(duration) @@ -1688,10 +1676,10 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender { pub clif_comments: crate::pretty_clif::CommentWriter, pub constants_cx: &'clif mut crate::constant::ConstantCx, pub caches: &'clif mut Caches<'tcx>, - pub source_info_set: indexmap::IndexSet, + + // FIXME switch back to `SourceInfo`, once it derives `Eq` and `Hash` again. + pub source_info_set: indexmap::IndexSet<(Span, mir::SourceScope)>, } impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { @@ -365,7 +367,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub fn set_debug_loc(&mut self, source_info: mir::SourceInfo) { - let (index, _) = self.source_info_set.insert_full(source_info); + let (index, _) = self.source_info_set.insert_full((source_info.span, source_info.scope)); self.bcx.set_srcloc(SourceLoc::new(index as u32)); } } diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 762fa8668bfba..e6d133c64510c 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -252,7 +252,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { tcx: TyCtxt, context: &Context, isa: &dyn cranelift::codegen::isa::TargetIsa, - source_info_set: &indexmap::IndexSet, + source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, ) { let line_program = &mut self.debug_context.dwarf.unit.line_program; @@ -292,7 +292,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { line_program.row().address_offset = offset as u64; if !srcloc.is_default() { let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); - create_row_for_span(line_program, source_info.span); + create_row_for_span(line_program, source_info.0); } else { create_row_for_span(line_program, self.mir_span); } From 40178f6d3c6d8a5a336b1841a1dc15016eccab05 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 25 Oct 2019 22:01:31 +0200 Subject: [PATCH 0926/1566] Changes for gimli-rs/object#133 --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++++ src/backend.rs | 8 +------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d67181bd56284..9d40b14f0bf1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,7 +162,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.14.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -341,7 +341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/gimli-rs/object.git#50391629ce0691dda4fb6ea57cf920cee80130c6" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -431,7 +431,7 @@ dependencies = [ "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.14.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -629,7 +629,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "304f66c19be2afa56530fa7c39796192eef38618da8d19df725ad7c6d6b2aaae" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -"checksum object 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81afbc5773e99efe9533d8a539dfac37e531dcd0f4eeb41584bae03ccf76d4c2" +"checksum object 0.14.0 (git+https://github.com/gimli-rs/object.git)" = "" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" diff --git a/Cargo.toml b/Cargo.toml index e0a33638139d2..3c2c4c8d8ec99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,10 @@ features = ["compression", "read", "std"] # We don't need WASM support #[patch.crates-io] #gimli = { path = "../" } +[patch.crates-io] +# FIXME switch back to crates.io once gimli-rs/object#133 is published +object = { git = "https://github.com/gimli-rs/object.git" } + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } diff --git a/src/backend.rs b/src/backend.rs index 3ed6e08f49778..305248182b5c4 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -149,13 +149,7 @@ impl WriteDebugInfo for ObjectProduct { } DebugRelocName::Symbol(id) => { let symbol_id = self.function_symbol(*symbol_map.get_index(id).unwrap().0); - let symbol = self.object.symbol(symbol_id); - - // A symbol gets a section assigned when `add_symbol_data` is called. - let section = symbol.section.expect("Symbol not defined"); - let symbol_offset = symbol.value; - - (self.object.section_symbol(section), symbol_offset) + self.object.symbol_section_and_offset(symbol_id).expect("Debug reloc for undef sym???") } }; self.object.add_relocation(from.0, Relocation { From ab5542e0cc1e79e00eab539fd62896dfabda462c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Oct 2019 19:07:07 +0100 Subject: [PATCH 0927/1566] Update dependencies --- Cargo.lock | 79 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d40b14f0bf1a..d685ecd1f0e31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,24 +18,29 @@ dependencies = [ "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "backtrace" -version = "0.3.38" +version = "0.3.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -50,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -175,7 +180,7 @@ dependencies = [ "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-native 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -195,7 +200,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -205,7 +210,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -215,7 +220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -227,7 +232,7 @@ name = "failure" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -254,8 +259,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -271,7 +276,7 @@ dependencies = [ "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -287,8 +292,11 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "itoa" @@ -297,7 +305,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.64" +version = "0.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -305,7 +313,7 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -322,12 +330,12 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "miniz_oxide" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -346,7 +354,7 @@ dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -395,7 +403,7 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -405,7 +413,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -428,8 +436,8 @@ dependencies = [ "cranelift-simplejit 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.14.0 (git+https://github.com/gimli-rs/object.git)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -482,7 +490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.101" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -492,7 +500,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -510,7 +518,7 @@ name = "string-interner" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -592,11 +600,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -"checksum backtrace 0.3.38 (registry+https://github.com/rust-lang/crates.io-index)" = "690a62be8920ccf773ee00ef0968649b0e724cda8bd5b12286302b4ae955fdf5" -"checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" +"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" +"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" +"checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cranelift 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum cranelift-bforest 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" @@ -621,13 +630,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" -"checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" +"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum libc 0.2.64 (registry+https://github.com/rust-lang/crates.io-index)" = "74dfca3d9957906e8d1e6a0b641dc9a59848e793f1da2165889fd4f62d10d79c" +"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum miniz_oxide 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "304f66c19be2afa56530fa7c39796192eef38618da8d19df725ad7c6d6b2aaae" +"checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.14.0 (git+https://github.com/gimli-rs/object.git)" = "" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" @@ -644,7 +653,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" +"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" "checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" From 62d1082190662d7efaf4350ee3d2ce661565421a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 Nov 2019 20:08:42 +0100 Subject: [PATCH 0928/1566] Update cranelift and object --- Cargo.lock | 65 +++++++++++++++++++++++++++++++++++------------------- Cargo.toml | 10 +++------ 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d685ecd1f0e31..6ad54f5e86cad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -75,7 +75,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -83,23 +83,22 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-bforest 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -108,17 +107,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" [[package]] name = "cranelift-entity" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" [[package]] name = "cranelift-faerie" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -131,7 +130,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -142,39 +141,39 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "object 0.14.0 (git+https://github.com/gimli-rs/object.git)", + "object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#387593d6c94d291e614c08d7a03f77b40efa451d" +source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", @@ -348,8 +347,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" -version = "0.14.0" -source = "git+https://github.com/gimli-rs/object.git#50391629ce0691dda4fb6ea57cf920cee80130c6" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -399,7 +398,7 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "6.1.0" +version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -439,7 +438,7 @@ dependencies = [ "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.14.0 (git+https://github.com/gimli-rs/object.git)", + "object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -562,6 +561,24 @@ dependencies = [ "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thiserror" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "thiserror-impl 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unicode-xid" version = "0.1.0" @@ -638,13 +655,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -"checksum object 0.14.0 (git+https://github.com/gimli-rs/object.git)" = "" +"checksum object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "973befa444477065996ee5692b920ebe38299f115d191a4df03f0e872bbb6aef" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" +"checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" @@ -662,6 +679,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" "checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" "checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" +"checksum thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fe148fa0fc3363a27092d48f7787363ded15bb8623c5d5dd4e2e9f23e4b21bc" +"checksum thiserror-impl 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "258da67e99e590650fa541ac6be764313d23e80cefb6846b516deb8de6b6d921" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" diff --git a/Cargo.toml b/Cargo.toml index 3c2c4c8d8ec99..9f7875b4c7ea5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ backend_object = ["object/write", "cranelift-object"] [dependencies] # These have to be in sync with each other -cranelift = { git = "https://github.com/CraneStation/cranelift.git" } +cranelift = { git = "https://github.com/CraneStation/cranelift.git", default-features = false, features = ["std"] } cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-object = { git = "https://github.com/CraneStation/cranelift.git", optional = true } @@ -30,13 +30,13 @@ indexmap = "1.0.2" libloading = "0.5.1" [dependencies.object] -version = "0.14.0" +version = "0.15.0" default-features = false features = ["compression", "read", "std"] # We don't need WASM support # Uncomment to use local checkout of cranelift #[patch."https://github.com/CraneStation/cranelift.git"] -#cranelift = { path = "../cranelift/cranelift-umbrella" } +#cranelift = { path = "../cranelift/cranelift-umbrella", default-features = false, features = ["std"] } #cranelift-module = { path = "../cranelift/cranelift-module" } #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } #cranelift-faerie = { path = "../cranelift/cranelift-faerie" } @@ -45,10 +45,6 @@ features = ["compression", "read", "std"] # We don't need WASM support #[patch.crates-io] #gimli = { path = "../" } -[patch.crates-io] -# FIXME switch back to crates.io once gimli-rs/object#133 is published -object = { git = "https://github.com/gimli-rs/object.git" } - [target.'cfg(not(target_arch = "wasm32"))'.dependencies] cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } From 7f3da30e2c33c54b21b1eedfc5ef7f1bd2324886 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 Nov 2019 20:12:03 +0100 Subject: [PATCH 0929/1566] Update dependencies --- Cargo.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ad54f5e86cad..4468e08d231ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -134,7 +134,7 @@ source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184 dependencies = [ "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -240,9 +240,9 @@ name = "failure_derive" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -374,7 +374,7 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -393,7 +393,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -504,7 +504,7 @@ dependencies = [ [[package]] name = "smallvec" -version = "0.6.10" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -532,10 +532,10 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -545,9 +545,9 @@ name = "synstructure" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -574,9 +574,9 @@ name = "thiserror-impl" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -658,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "973befa444477065996ee5692b920ebe38299f115d191a4df03f0e872bbb6aef" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" +"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" @@ -672,11 +672,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" "checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" -"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" +"checksum smallvec 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "533e29e15d0748f28afbaf4ff7cab44d73e483a8e50b38c40bd13b7f3d48f542" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7bedb3320d0f3035594b0b723c8a28d7d336a3eda3881db79e61d676fb644c" "checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" "checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" "checksum thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fe148fa0fc3363a27092d48f7787363ded15bb8623c5d5dd4e2e9f23e4b21bc" From 0cad01f239b232e55169c9337da11661e22210f9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 Nov 2019 20:22:59 +0100 Subject: [PATCH 0930/1566] Rustup to rustc 1.40.0-nightly (aa4e57ca8 2019-10-31) --- src/allocator.rs | 2 +- src/constant.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/allocator.rs b/src/allocator.rs index 07294e8cfec9f..3be28e233ad54 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -10,7 +10,7 @@ use crate::prelude::*; -use syntax_expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; +use syntax::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { diff --git a/src/constant.rs b/src/constant.rs index 2f0f930574c5e..3cf0e05e44626 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -413,6 +413,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn call_intrinsic( _: &mut InterpCx<'mir, 'tcx, Self>, + _: Span, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: PlaceTy<'tcx>, From 74ea53f1fbac83ee44addc6a3c08d152344aa356 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 6 Nov 2019 20:48:29 +0100 Subject: [PATCH 0931/1566] Update cranelift --- Cargo.lock | 214 +++++++++++++++++++++++++++++++++-------------------- Cargo.toml | 2 +- 2 files changed, 134 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4468e08d231ec..7f69982b1493b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,123 +65,124 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-bforest 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-bforest 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" [[package]] name = "cranelift-entity" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" [[package]] name = "cranelift-faerie" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.46.1" -source = "git+https://github.com/CraneStation/cranelift.git#34c86f71ccded11d0184bfc1bc307c3422c70a00" +version = "0.48.0" +source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" dependencies = [ - "cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -214,16 +215,16 @@ dependencies = [ [[package]] name = "faerie" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -289,6 +290,16 @@ dependencies = [ "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "goblin" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "indexmap" version = "1.3.0" @@ -345,6 +356,19 @@ name = "nodrop" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "object" +version = "0.15.0" +source = "git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056#cba3ed4932e4c594c5eab4f5ef6c51838f4a5056" +dependencies = [ + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "object" version = "0.15.0" @@ -428,18 +452,18 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-object 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.46.1 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-object 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -464,6 +488,14 @@ dependencies = [ "scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "scroll" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "scroll_derive" version = "0.9.5" @@ -474,6 +506,16 @@ dependencies = [ "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "scroll_derive" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "semver" version = "0.9.0" @@ -504,7 +546,7 @@ dependencies = [ [[package]] name = "smallvec" -version = "0.6.12" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -561,6 +603,11 @@ dependencies = [ "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "target-lexicon" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "thiserror" version = "1.0.4" @@ -624,22 +671,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-shared 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-object 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.46.1 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-shared 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-object 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "875d78b92b2a4d9e1e2c7eeccfa30a327d2ee6434db3beb8fd6fd92f41898bc4" +"checksum faerie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e294a3d0adf44f553fcf5fc2b76b211e6e80215c1095b949f84a46759e79db75" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" @@ -647,6 +694,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" +"checksum goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d093f4f925df6c16e4f3f1e75511a6e48ea3bcbca16f9857c03eaac3b1bc9e11" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" @@ -655,6 +703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +"checksum object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)" = "" "checksum object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "973befa444477065996ee5692b920ebe38299f115d191a4df03f0e872bbb6aef" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" @@ -666,19 +715,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" +"checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" "checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" +"checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" "checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" "checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" -"checksum smallvec 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "533e29e15d0748f28afbaf4ff7cab44d73e483a8e50b38c40bd13b7f3d48f542" +"checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7bedb3320d0f3035594b0b723c8a28d7d336a3eda3881db79e61d676fb644c" "checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" "checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" +"checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" "checksum thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fe148fa0fc3363a27092d48f7787363ded15bb8623c5d5dd4e2e9f23e4b21bc" "checksum thiserror-impl 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "258da67e99e590650fa541ac6be764313d23e80cefb6846b516deb8de6b6d921" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/Cargo.toml b/Cargo.toml index 9f7875b4c7ea5..fe7277de8f849 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ cranelift = { git = "https://github.com/CraneStation/cranelift.git", default-fea cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-object = { git = "https://github.com/CraneStation/cranelift.git", optional = true } -target-lexicon = "0.8.1" +target-lexicon = "0.9.0" faerie = "0.11.0" #goblin = "0.0.17" From 5407b51aa71f13b2d0deabd873c0a828cb8cd28f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 9 Nov 2019 11:14:18 +0100 Subject: [PATCH 0932/1566] Rustup to rustc 1.40.0-nightly (9e346646e 2019-11-08) --- example/std_example.rs | 2 ++ src/abi/mod.rs | 3 ++- src/base.rs | 8 +++++++- src/common.rs | 19 ++++++++++++++----- src/constant.rs | 4 ++-- src/intrinsics.rs | 16 ++++++++++++++++ 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 71b2a34b61d56..50f794733e327 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -71,6 +71,8 @@ fn main() { let _a = 1u32 << 2u8; + println!("{:?}", unsafe { std::intrinsics::caller_location() }); + unsafe { test_simd(); } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index dcd9a6ab932df..881174646afe7 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -351,6 +351,7 @@ pub fn codegen_terminator_call<'tcx>( func: &Operand<'tcx>, args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, + span: Span, ) { let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); let sig = fx @@ -378,7 +379,7 @@ pub fn codegen_terminator_call<'tcx>( match instance.def { InstanceDef::Intrinsic(_) => { - crate::intrinsics::codegen_intrinsic_call(fx, instance, args, destination); + crate::intrinsics::codegen_intrinsic_call(fx, instance, args, destination, span); return; } InstanceDef::DropGlue(_, None) => { diff --git a/src/base.rs b/src/base.rs index ef32dafb2efc5..007ff5390de5d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -208,7 +208,13 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, from_hir_call: _, } => { - crate::abi::codegen_terminator_call(fx, func, args, destination); + crate::abi::codegen_terminator_call( + fx, + func, + args, + destination, + bb_data.terminator().source_info.span, + ); } TerminatorKind::Resume | TerminatorKind::Abort => { trap_unreachable(fx, "[corruption] Unwinding bb reached."); diff --git a/src/common.rs b/src/common.rs index c3563dc0533f9..838c8d3315bfc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,4 +1,4 @@ -use rustc::ty::layout::{FloatTy, Integer, Primitive}; +use rustc::ty::layout::{Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; use cranelift::codegen::ir::{InstructionData, Opcode, ValueDef}; @@ -27,10 +27,8 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { Integer::I64 => types::I64, Integer::I128 => types::I128, }, - Primitive::Float(flt) => match flt { - FloatTy::F32 => types::F32, - FloatTy::F64 => types::F64, - }, + Primitive::F32 => types::F32, + Primitive::F64 => types::F64, Primitive::Pointer => pointer_ty(tcx), } } @@ -370,4 +368,15 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let (index, _) = self.source_info_set.insert_full((source_info.span, source_info.scope)); self.bcx.set_srcloc(SourceLoc::new(index as u32)); } + + pub fn get_caller_location(&mut self, span: Span) -> CValue<'tcx> { + let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); + let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo()); + let const_loc = self.tcx.const_caller_location(( + syntax::symbol::Symbol::intern(&caller.file.name.to_string()), + caller.line as u32, + caller.col_display as u32 + 1, + )); + crate::constant::trans_const_value(self, const_loc) + } } diff --git a/src/constant.rs b/src/constant.rs index 3cf0e05e44626..d366cf4bf88ce 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -172,7 +172,7 @@ fn trans_const_place<'tcx>( ecx.copy_op(op, ptr.into())?; let alloc = ecx .memory - .get(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; + .get_raw(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) }; let alloc = result().expect("unable to convert ConstValue to Allocation"); @@ -274,7 +274,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let (data_id, alloc) = match todo_item { TodoItem::Alloc(alloc_id) => { //println!("alloc_id {}", alloc_id); - let alloc = memory.get(alloc_id).unwrap(); + let alloc = memory.get_raw(alloc_id).unwrap(); let data_id = data_id_for_alloc_id(module, alloc_id, alloc.align); (data_id, alloc) } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 0910b878890cb..211c8a2443d4a 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -338,6 +338,7 @@ pub fn codegen_intrinsic_call<'tcx>( instance: Instance<'tcx>, args: &[mir::Operand<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, + span: Span, ) { let def_id = instance.def_id(); let substs = instance.substs; @@ -834,6 +835,21 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, val); }; + ptr_offset_from, (v ptr, v base) { + let isize_layout = fx.layout_of(fx.tcx.types.isize); + + let pointee_size: u64 = fx.layout_of(T).size.bytes(); + let diff = fx.bcx.ins().isub(ptr, base); + // FIXME this can be an exact division. + let val = CValue::by_val(fx.bcx.ins().udiv_imm(diff, pointee_size as i64), isize_layout); + ret.write_cvalue(fx, val); + }; + + caller_location, () { + let caller_location = fx.get_caller_location(span); + ret.write_cvalue(fx, caller_location); + }; + _ if intrinsic.starts_with("atomic_fence"), () {}; _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; _ if intrinsic.starts_with("atomic_load"), (c ptr) { From bef2d8836fa361c5b41bae3d73cc991163385b51 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 9 Nov 2019 15:50:48 +0100 Subject: [PATCH 0933/1566] Fix backend_object build --- Cargo.lock | 119 +---------------------------------------------------- Cargo.toml | 4 ++ 2 files changed, 6 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f69982b1493b..fb791f488c1d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,16 +280,6 @@ dependencies = [ "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "goblin" -version = "0.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "goblin" version = "0.1.0" @@ -308,11 +298,6 @@ dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "itoa" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "libc" version = "0.2.65" @@ -362,6 +347,7 @@ version = "0.15.0" source = "git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056#cba3ed4932e4c594c5eab4f5ef6c51838f4a5056" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -369,33 +355,11 @@ dependencies = [ "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "object" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "plain" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "proc-macro2" version = "1.0.6" @@ -404,14 +368,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "quote" version = "1.0.2" @@ -462,7 +418,7 @@ dependencies = [ "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -474,20 +430,6 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "ryu" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scroll" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "scroll" version = "0.10.1" @@ -496,16 +438,6 @@ dependencies = [ "scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "scroll_derive" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "scroll_derive" version = "0.10.1" @@ -534,16 +466,6 @@ name = "serde" version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "serde_json" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "smallvec" version = "1.0.0" @@ -562,16 +484,6 @@ dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syn" version = "1.0.7" @@ -593,16 +505,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "target-lexicon" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "target-lexicon" version = "0.9.0" @@ -626,11 +528,6 @@ dependencies = [ "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicode-xid" version = "0.2.0" @@ -693,10 +590,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" -"checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" "checksum goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d093f4f925df6c16e4f3f1e75511a6e48ea3bcbca16f9857c03eaac3b1bc9e11" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" -"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" @@ -704,36 +599,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)" = "" -"checksum object 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "973befa444477065996ee5692b920ebe38299f115d191a4df03f0e872bbb6aef" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" "checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" -"checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" -"checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" -"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" -"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7bedb3320d0f3035594b0b723c8a28d7d336a3eda3881db79e61d676fb644c" "checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" -"checksum target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7975cb2c6f37d77b190bc5004a2bb015971464756fde9514651a525ada2a741a" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" "checksum thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fe148fa0fc3363a27092d48f7787363ded15bb8623c5d5dd4e2e9f23e4b21bc" "checksum thiserror-impl 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "258da67e99e590650fa541ac6be764313d23e80cefb6846b516deb8de6b6d921" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" diff --git a/Cargo.toml b/Cargo.toml index fe7277de8f849..749573ec5d7e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,10 @@ indexmap = "1.0.2" libloading = "0.5.1" [dependencies.object] +# FIXME remove git and rev once cranelift switches back to a crates.io release of object +git = "https://github.com/gimli-rs/object" +rev = "cba3ed4932e4c594c5eab4f5ef6c51838f4a5056" + version = "0.15.0" default-features = false features = ["compression", "read", "std"] # We don't need WASM support From c0ec688daf7ebe8cd3ff5093c88fc0b2aeb22981 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Nov 2019 20:34:42 +0100 Subject: [PATCH 0934/1566] Rustup to rustc 1.40.0-nightly (3fc30d884 2019-11-10) --- src/base.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 007ff5390de5d..cb22606ec2698 100644 --- a/src/base.rs +++ b/src/base.rs @@ -356,7 +356,8 @@ fn trans_stmt<'tcx>( } } Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), operand, ty) - | Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, ty) => { + | Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, ty) + | Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, ty) => { let operand = trans_operand(fx, operand); let layout = fx.layout_of(ty); lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); From ff7507e014e3f334d8e61c39319181a424b0f6ee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Nov 2019 20:39:47 +0100 Subject: [PATCH 0935/1566] Update Cranelift and faerie --- Cargo.lock | 130 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb791f488c1d4..2aefb947a1f87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,31 +65,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-shared 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,31 +98,31 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen-shared 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" [[package]] name = "cranelift-entity" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" [[package]] name = "cranelift-faerie" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -130,10 +130,10 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -141,44 +141,44 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", "object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.48.0" -source = "git+https://github.com/CraneStation/cranelift.git#a3a90156a4935b5c8cfa93ba8a18f4326b5323c6" +version = "0.49.0" +source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" dependencies = [ - "cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -215,7 +215,7 @@ dependencies = [ [[package]] name = "faerie" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -408,12 +408,12 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-object 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.48.0 (git+https://github.com/CraneStation/cranelift.git)", - "faerie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-object 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", @@ -568,22 +568,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-shared 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-object 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.48.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-shared 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-object 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e294a3d0adf44f553fcf5fc2b76b211e6e80215c1095b949f84a46759e79db75" +"checksum faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01fed63609767c70e34203201032c249d60a24578a67ef0ce7cc13ff010e9cf2" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" diff --git a/Cargo.toml b/Cargo.toml index 749573ec5d7e1..320f15f245abb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } cranelift-object = { git = "https://github.com/CraneStation/cranelift.git", optional = true } target-lexicon = "0.9.0" -faerie = "0.11.0" +faerie = "0.12.0" #goblin = "0.0.17" ar = "0.8.0" From 177b0d2f578353fe026c6fa4810bd9427e385a99 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 14 Nov 2019 21:13:40 +0100 Subject: [PATCH 0936/1566] Rustup to rustc 1.41.0-nightly (ded5ee001 2019-11-13) --- build_sysroot/Cargo.toml | 2 +- src/abi/mod.rs | 2 +- src/allocator.rs | 2 +- src/common.rs | 2 +- src/constant.rs | 10 +++++++--- src/value_and_place.rs | 8 ++++---- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index f28a46245e8cf..2935a8bd3d334 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -5,7 +5,7 @@ version = "0.0.0" [dependencies] core = { path = "./sysroot_src/src/libcore" } -compiler_builtins = "0.1" +compiler_builtins = "=0.1.20" # FIXME use "0.1" once libstd has updated for the latest version alloc = { path = "./sysroot_src/src/liballoc" } std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind", "backtrace"] } test = { path = "./sysroot_src/src/libtest" } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 881174646afe7..9e3e4f82a39b9 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -581,7 +581,7 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac &ty::RegionKind::ReErased, TypeAndMut { ty, - mutbl: crate::rustc::hir::Mutability::MutMutable, + mutbl: crate::rustc::hir::Mutability::Mutable, }, ), ); diff --git a/src/allocator.rs b/src/allocator.rs index 3be28e233ad54..8031367b23bb2 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -20,7 +20,7 @@ pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> }); if any_dynamic_crate { false - } else if let Some(kind) = *tcx.sess.allocator_kind.get() { + } else if let Some(kind) = tcx.allocator_kind() { codegen_inner(tcx.sess, module, kind); true } else { diff --git a/src/common.rs b/src/common.rs index 838c8d3315bfc..1bd8afed5087d 100644 --- a/src/common.rs +++ b/src/common.rs @@ -72,7 +72,7 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { - let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc::hir::Mutability::MutImmutable }); + let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc::hir::Mutability::Immutable }); match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi { Abi::Scalar(_) => false, Abi::ScalarPair(_, _) => true, diff --git a/src/constant.rs b/src/constant.rs index d366cf4bf88ce..6ccc4692947fd 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -6,6 +6,7 @@ use rustc::mir::interpret::{ use rustc::ty::{layout::Align, Const}; use rustc_mir::interpret::{ ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, + StackPopInfo, }; use cranelift_module::*; @@ -407,6 +408,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { _: &[OpTy<'tcx>], _: Option>, _: Option, + _: Option, ) -> InterpResult<'tcx, Option<&'mir Body<'tcx>>> { panic!(); } @@ -416,7 +418,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { _: Span, _: Instance<'tcx>, _: &[OpTy<'tcx>], - _: PlaceTy<'tcx>, + _: Option>, + _: Option, + _: Option, ) -> InterpResult<'tcx> { panic!(); } @@ -469,8 +473,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { Ok(()) } - fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: ()) -> InterpResult<'tcx> { - Ok(()) + fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: (), _: bool) -> InterpResult<'tcx, StackPopInfo> { + Ok(StackPopInfo::Normal) } } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index c152b8d3c5122..fcee67bfec6e4 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -351,14 +351,14 @@ impl<'tcx> CPlace<'tcx> { to_ty: Ty<'tcx>, ) { match (&from_ty.kind, &to_ty.kind) { - (ty::Ref(_, t, MutImmutable), ty::Ref(_, u, MutImmutable)) - | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutImmutable)) - | (ty::Ref(_, t, MutMutable), ty::Ref(_, u, MutMutable)) => { + (ty::Ref(_, t, Immutable), ty::Ref(_, u, Immutable)) + | (ty::Ref(_, t, Mutable), ty::Ref(_, u, Immutable)) + | (ty::Ref(_, t, Mutable), ty::Ref(_, u, Mutable)) => { assert_assignable(fx, t, u); // &mut T -> &T is allowed // &'a T -> &'b T is allowed } - (ty::Ref(_, _, MutImmutable), ty::Ref(_, _, MutMutable)) => panic!( + (ty::Ref(_, _, Immutable), ty::Ref(_, _, Mutable)) => panic!( "Cant assign value of type {} to place of type {}", from_ty, to_ty ), From 1f8a646592d6e372b614cb94724deaea1753464b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 14 Nov 2019 21:32:18 +0100 Subject: [PATCH 0937/1566] Update cranelift and update git url for move to bytecodealliance Fixes #796 --- Cargo.lock | 166 +++++++++++++++++++++++++++++++++++++---------------- Cargo.toml | 12 ++-- 2 files changed, 123 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2aefb947a1f87..c2d458cb8e016 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,30 +66,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-bforest" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-shared 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-meta 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -99,29 +99,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen-shared 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +dependencies = [ + "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cranelift-entity" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" [[package]] name = "cranelift-faerie" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -131,9 +135,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -142,10 +146,10 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -153,9 +157,9 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -163,10 +167,10 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -174,11 +178,11 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.49.0" -source = "git+https://github.com/CraneStation/cranelift.git#5d617f5e96dd91d87c5af38cf7fb8eae547c29a3" +source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -355,6 +359,25 @@ dependencies = [ "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "packed_struct" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "packed_struct_codegen" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "plain" version = "0.2.3" @@ -368,6 +391,11 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "quote" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "quote" version = "1.0.2" @@ -408,11 +436,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-object 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.49.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-faerie 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -466,6 +494,16 @@ name = "serde" version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "serde_derive" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "smallvec" version = "1.0.0" @@ -484,6 +522,16 @@ dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", + "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syn" version = "1.0.7" @@ -494,6 +542,14 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "synom" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synstructure" version = "0.12.1" @@ -528,6 +584,11 @@ dependencies = [ "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicode-xid" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-xid" version = "0.2.0" @@ -568,18 +629,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-shared 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-object 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.49.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-faerie 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" @@ -599,8 +660,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)" = "" +"checksum packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90caf80e74380d94f2aabc83edb900b49123b3132442fb147f9155c87a756281" +"checksum packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f6fda15ebe37b7b28889bd4aa75bb134652eaec9eb99d1bf02f806fca4357fc" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" +"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" @@ -611,14 +675,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" +"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" +"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7bedb3320d0f3035594b0b723c8a28d7d336a3eda3881db79e61d676fb644c" +"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" "checksum thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fe148fa0fc3363a27092d48f7787363ded15bb8623c5d5dd4e2e9f23e4b21bc" "checksum thiserror-impl 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "258da67e99e590650fa541ac6be764313d23e80cefb6846b516deb8de6b6d921" +"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" diff --git a/Cargo.toml b/Cargo.toml index 320f15f245abb..5c980c40a3c0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,10 +14,10 @@ backend_object = ["object/write", "cranelift-object"] [dependencies] # These have to be in sync with each other -cranelift = { git = "https://github.com/CraneStation/cranelift.git", default-features = false, features = ["std"] } -cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" } -cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" } -cranelift-object = { git = "https://github.com/CraneStation/cranelift.git", optional = true } +cranelift = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } +cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } +cranelift-faerie = { git = "https://github.com/bytecodealliance/cranelift/" } +cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/", optional = true } target-lexicon = "0.9.0" faerie = "0.12.0" @@ -39,7 +39,7 @@ default-features = false features = ["compression", "read", "std"] # We don't need WASM support # Uncomment to use local checkout of cranelift -#[patch."https://github.com/CraneStation/cranelift.git"] +#[patch."https://github.com/bytecodealliance/cranelift/"] #cranelift = { path = "../cranelift/cranelift-umbrella", default-features = false, features = ["std"] } #cranelift-module = { path = "../cranelift/cranelift-module" } #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } @@ -50,7 +50,7 @@ features = ["compression", "read", "std"] # We don't need WASM support #gimli = { path = "../" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -cranelift-simplejit = { git = "https://github.com/CraneStation/cranelift.git" } +cranelift-simplejit = { git = "https://github.com/bytecodealliance/cranelift/" } [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. From 42f86204326f9a9ce537136875af7d78a7e965fd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 14 Nov 2019 21:38:08 +0100 Subject: [PATCH 0938/1566] Update dependencies --- Cargo.lock | 60 +++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2d458cb8e016..e55bc6a4a9208 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ name = "backtrace-sys" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -93,7 +93,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -128,7 +128,7 @@ dependencies = [ "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -151,7 +151,7 @@ dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -223,7 +223,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -247,8 +247,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -258,7 +258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "flate2" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -286,7 +286,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -312,7 +312,7 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -351,8 +351,8 @@ version = "0.15.0" source = "git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056#cba3ed4932e4c594c5eab4f5ef6c51838f4a5056" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -410,7 +410,7 @@ version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -473,7 +473,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -501,7 +501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -534,7 +534,7 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -552,12 +552,12 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -568,20 +568,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "thiserror" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thiserror-impl 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror-impl" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -627,7 +627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum cc 1.0.46 (registry+https://github.com/rust-lang/crates.io-index)" = "0213d356d3c4ea2c18c40b037c3be23cd639825c18f25ee670ac7813beeef99c" +"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cranelift 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-bforest 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" @@ -648,10 +648,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -"checksum flate2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ad3c5233c9a940c8719031b423d7e6c16af66e031cb0420b0896f5245bf181d3" +"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" -"checksum goblin 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d093f4f925df6c16e4f3f1e75511a6e48ea3bcbca16f9857c03eaac3b1bc9e11" +"checksum goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6040506480da04a63de51a478e8021892d65d8411f29b2a422c2648bdd8bcb" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" @@ -680,12 +680,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7bedb3320d0f3035594b0b723c8a28d7d336a3eda3881db79e61d676fb644c" +"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" -"checksum thiserror 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9fe148fa0fc3363a27092d48f7787363ded15bb8623c5d5dd4e2e9f23e4b21bc" -"checksum thiserror-impl 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "258da67e99e590650fa541ac6be764313d23e80cefb6846b516deb8de6b6d921" +"checksum thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f9fb62ff737e573b1e677459bea6fd023cd5d6e868c3242d3cdf3ef2f0554824" +"checksum thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "24069c0ba08aab54289d6a25f5036d94afc61e1538bbc42ae5501df141c9027d" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" From 0c026853f55cda044cd42c385ac0f771a51d964c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 15 Nov 2019 20:47:22 +0100 Subject: [PATCH 0939/1566] Rustup to rustc 1.41.0-nightly (82cf3a448 2019-11-14) --- src/constant.rs | 8 ++++---- src/intrinsics.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 6ccc4692947fd..e0d3a873f7c13 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, GlobalId, InterpResult, Scalar, }; -use rustc::ty::{layout::Align, Const}; +use rustc::ty::{layout::Align, Const, ConstKind}; use rustc_mir::interpret::{ ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, StackPopInfo, @@ -84,7 +84,7 @@ pub fn force_eval_const<'tcx>( const_: &'tcx Const, ) -> &'tcx Const<'tcx> { match const_.val { - ConstValue::Unevaluated(def_id, ref substs) => { + ConstKind::Unevaluated(def_id, ref substs) => { let param_env = ParamEnv::reveal_all(); let substs = fx.monomorphize(substs); let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap(); @@ -176,7 +176,7 @@ fn trans_const_place<'tcx>( .get_raw(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) }; - let alloc = result().expect("unable to convert ConstValue to Allocation"); + let alloc = result().expect("unable to convert ConstKind to Allocation"); //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); @@ -294,7 +294,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let const_ = tcx.const_eval(ParamEnv::reveal_all().and(cid)).unwrap(); let alloc = match const_.val { - ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc, + ConstKind::Value(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", const_), }; diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 211c8a2443d4a..421160a34faf7 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1004,7 +1004,7 @@ pub fn codegen_intrinsic_call<'tcx>( let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_shuffle* idx not const"); let idx_bytes = match idx_const.val { - ConstValue::ByRef { alloc, offset } => { + ty::ConstKind::Value(ConstValue::ByRef { alloc, offset }) => { let ptr = Pointer::new(AllocId(0 /* dummy */), offset); let size = Size::from_bytes(4 * u64::from(ret_lane_count) /* size_of([u32; ret_lane_count]) */); alloc.get_bytes(fx, ptr, size).unwrap() From d2eafd858fa0d69bcdc5fca5e667ce296da9d1f5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Nov 2019 15:22:43 +0100 Subject: [PATCH 0940/1566] Update Cranelift --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e55bc6a4a9208..6d54a9554bba8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-frontend 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -75,7 +75,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -83,7 +83,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen-shared 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -108,7 +108,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -117,12 +117,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" [[package]] name = "cranelift-faerie" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,7 +146,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -157,7 +157,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -167,7 +167,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -178,7 +178,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#047e1eed82080299ed160344d2ee11a4af2de8eb" +source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" dependencies = [ "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", From b0bcb23eb497bbfbf20ab4b0b36b6fe37fbd7368 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Nov 2019 16:44:26 +0100 Subject: [PATCH 0941/1566] Fix signed cast to 128bit integer --- example/std_example.rs | 7 ++++++- src/cast.rs | 10 +++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 50f794733e327..d6734e7449884 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -53,7 +53,12 @@ fn main() { assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128); assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 >> 64, 0xFEDCBA98765432u128); assert_eq!(0xFEDCBA987654321123456789ABCDEFu128 as i128 >> 64, 0xFEDCBA98765432i128); - assert_eq!(353985398u128 * 932490u128, 330087843781020u128); + + let tmp = 353985398u128; + assert_eq!(tmp * 932490u128, 330087843781020u128); + + let tmp = -0x1234_5678_9ABC_DEF0i64; + assert_eq!(tmp as i128, -0x1234_5678_9ABC_DEF0i128); // Check that all u/i128 <-> float casts work correctly. let houndred_u128 = 100u128; diff --git a/src/cast.rs b/src/cast.rs index 41503ea86c835..870c316f41d3b 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -13,15 +13,19 @@ pub fn clif_intcast( // extend (_, types::I128) => { - let wider = if from == types::I64 { + let lo = if from == types::I64 { val } else if signed { fx.bcx.ins().sextend(types::I64, val) } else { fx.bcx.ins().uextend(types::I64, val) }; - let zero = fx.bcx.ins().iconst(types::I64, 0); - fx.bcx.ins().iconcat(wider, zero) + let hi = if signed { + fx.bcx.ins().sshr_imm(lo, 63) + } else { + fx.bcx.ins().iconst(types::I64, 0) + }; + fx.bcx.ins().iconcat(lo, hi) } (_, _) if to.wider_or_equal(from) => { if signed { From 0219f218db666ed597d279d6258b31fc611ae42a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 16 Nov 2019 16:54:47 +0100 Subject: [PATCH 0942/1566] Remove FIXME --- src/cast.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cast.rs b/src/cast.rs index 870c316f41d3b..d945ad7d054bf 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -63,7 +63,9 @@ pub fn clif_int_or_float_cast( fx, from, to_ty, - from_signed, // FIXME is this correct? + // This is correct as either from_signed == to_signed (=> this is trivially correct) + // Or from_clif_ty == to_clif_ty, which means this is a no-op. + from_signed, ) } else if from_ty.is_int() && to_ty.is_float() { if from_ty == types::I128 { From cdab96d05c5bcfd33969ac200af9046c44ff30e1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 22 Nov 2019 15:56:40 +0100 Subject: [PATCH 0943/1566] Rustup to rustc 1.41.0-nightly (53712f863 2019-11-21) --- src/base.rs | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index cb22606ec2698..33ae97ef652f6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -523,7 +523,7 @@ fn trans_stmt<'tcx>( outputs: _, inputs: _, } = &**asm; - let rustc::hir::InlineAsm { + let rustc::hir::InlineAsmInner { asm: asm_code, // Name outputs, // Vec inputs, // Vec diff --git a/src/lib.rs b/src/lib.rs index 169397f14a575..3d30185f945b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, never_type, decl_macro, type_alias_impl_trait, associated_type_bounds)] +#![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds)] #![allow(intra_doc_link_resolution_failure)] extern crate flate2; From 7a27ded57ffc54ef2bf75651d6e3d44af8ae6021 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Nov 2019 15:06:23 +0100 Subject: [PATCH 0944/1566] Enable object backend by default --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 5c980c40a3c0f..1a39e2498692d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ edition = "2018" crate-type = ["dylib"] [features] +default = ["backend_object"] backend_object = ["object/write", "cranelift-object"] [dependencies] From fc826a75257b528d0a555d470c8abb0aadc84da0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 23 Nov 2019 15:10:29 +0100 Subject: [PATCH 0945/1566] Benchmark simple-raytracer compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [BENCH COMPILE] ebobby/simple-raytracer Benchmark #1: RUSTFLAGS='' cargo build --target x86_64-apple-darwin Time (mean ± σ): 16.539 s ± 0.781 s [User: 46.043 s, System: 3.822 s] Range (min … max): 15.057 s … 17.566 s 10 runs Benchmark #2: ../cargo.sh build Time (mean ± σ): 14.550 s ± 0.443 s [User: 25.856 s, System: 4.214 s] Range (min … max): 14.208 s … 15.751 s 10 runs Summary '../cargo.sh build' ran 1.14 ± 0.06 times faster than 'RUSTFLAGS='' cargo build --target x86_64-apple-darwin' [BENCH RUN] ebobby/simple-raytracer Benchmark #1: ./raytracer_cg_llvm Time (mean ± σ): 6.436 s ± 0.022 s [User: 6.392 s, System: 0.018 s] Range (min … max): 6.408 s … 6.466 s 10 runs Benchmark #2: ./raytracer_cg_clif Time (mean ± σ): 9.604 s ± 0.088 s [User: 9.547 s, System: 0.023 s] Range (min … max): 9.503 s … 9.742 s 10 runs Summary './raytracer_cg_llvm' ran 1.49 ± 0.01 times faster than './raytracer_cg_clif' --- test.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index 773b7c296d429..1f87c7203e301 100755 --- a/test.sh +++ b/test.sh @@ -66,10 +66,13 @@ $RUSTC example/mod_bench.rs --crate-type bin #./build_sysroot/build_sysroot.sh --release pushd simple-raytracer -echo "[BENCH] ebobby/simple-raytracer" -cargo clean && ../cargo.sh build -cp ./target/*/debug/main ./raytracer_cg_clif +echo "[BENCH COMPILE] ebobby/simple-raytracer" +hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug" \ + "RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \ + "../cargo.sh build" +echo "[BENCH RUN] ebobby/simple-raytracer" +cp ./target/*/debug/main ./raytracer_cg_clif hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif popd From 4a8b0ca2748509d7a5156a5ac30ccccab7cdd906 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Nov 2019 14:56:51 +0100 Subject: [PATCH 0946/1566] Correctly align returned addr for to_addr on NoPlace --- src/value_and_place.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index fcee67bfec6e4..142795a91eb50 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -334,7 +334,15 @@ impl<'tcx> CPlace<'tcx> { fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), None, ), - CPlaceInner::NoPlace => (fx.bcx.ins().iconst(fx.pointer_type, 45), None), + CPlaceInner::NoPlace => { + ( + fx.bcx.ins().iconst( + fx.pointer_type, + i64::try_from(self.layout.align.pref.bytes()).unwrap(), + ), + None + ) + } CPlaceInner::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } From 53e083323257d0d79d9f0b2d365232a3c1f085ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Nov 2019 15:30:28 +0100 Subject: [PATCH 0947/1566] Implement log10f* intrinsics --- src/intrinsics.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 421160a34faf7..bee22daef5349 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -387,6 +387,8 @@ pub fn codegen_intrinsic_call<'tcx>( logf64(flt) -> f64 => log, log2f32(flt) -> f32 => log2f, log2f64(flt) -> f64 => log2, + log10f32(flt) -> f32 => log10f, + log10f64(flt) -> f64 => log10, fabsf32(flt) -> f32 => fabsf, fabsf64(flt) -> f64 => fabs, fmaf32(x, y, z) -> f32 => fmaf, From e9d3569e08987e3d034a6c239d71ef8ec15c7cf2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Nov 2019 15:44:39 +0100 Subject: [PATCH 0948/1566] Run libcore tests --- build_sysroot/build_sysroot.sh | 1 - build_sysroot/prepare_sysroot_src.sh | 3 +- example/std_example.rs | 4 + ...022-core-Disable-not-compiling-tests.patch | 123 ++++++++++++ patches/0023-core-Ignore-failing-tests.patch | 183 ++++++++++++++++++ test.sh | 5 + 6 files changed, 317 insertions(+), 2 deletions(-) create mode 100644 patches/0022-core-Disable-not-compiling-tests.patch create mode 100644 patches/0023-core-Ignore-failing-tests.patch diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 26f6607b2aa80..ff122e21e4f8f 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -12,7 +12,6 @@ popd >/dev/null # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true -rm -r sysroot_src/src/{libcore,libtest}/target/ || true rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true rm -r sysroot/ 2>/dev/null || true diff --git a/build_sysroot/prepare_sysroot_src.sh b/build_sysroot/prepare_sysroot_src.sh index c96c3b36ba203..882454754ed82 100755 --- a/build_sysroot/prepare_sysroot_src.sh +++ b/build_sysroot/prepare_sysroot_src.sh @@ -24,7 +24,8 @@ git commit -m "Initial commit" -q for file in $(ls ../../patches/ | grep -v patcha); do echo "[GIT] apply" $file git apply ../../patches/$file -git commit --no-gpg-sign -am "Patch $file" +git add -A +git commit --no-gpg-sign -m "Patch $file" done popd diff --git a/example/std_example.rs b/example/std_example.rs index d6734e7449884..eccffc621406f 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,4 +1,5 @@ #![feature(core_intrinsics)] +#![feature(is_sorted)] use std::arch::x86_64::*; use std::io::Write; @@ -76,6 +77,9 @@ fn main() { let _a = 1u32 << 2u8; + let empty: [i32; 0] = []; + assert!(empty.is_sorted()); + println!("{:?}", unsafe { std::intrinsics::caller_location() }); unsafe { diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch new file mode 100644 index 0000000000000..77cdd0c56e98e --- /dev/null +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -0,0 +1,123 @@ +From f6befc4bb51d84f5f1cf35938a168c953d421350 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sun, 24 Nov 2019 15:10:23 +0100 +Subject: [PATCH] [core] Disable not compiling tests + +--- + src/libcore/tests/Cargo.toml | 8 ++++++++ + src/libcore/tests/num/flt2dec/mod.rs | 1 - + src/libcore/tests/num/int_macros.rs | 2 ++ + src/libcore/tests/num/uint_macros.rs | 2 ++ + src/libcore/tests/ptr.rs | 2 ++ + src/libcore/tests/slice.rs | 2 ++ + 6 files changed, 16 insertions(+), 1 deletion(-) + create mode 100644 src/libcore/tests/Cargo.toml + +diff --git a/src/libcore/tests/Cargo.toml b/src/libcore/tests/Cargo.toml +new file mode 100644 +index 0000000..46fd999 +--- /dev/null ++++ b/src/libcore/tests/Cargo.toml +@@ -0,0 +1,8 @@ ++[package] ++name = "core" ++version = "0.0.0" ++edition = "2018" ++ ++[lib] ++name = "coretests" ++path = "lib.rs" +diff --git a/src/libcore/tests/num/flt2dec/mod.rs b/src/libcore/tests/num/flt2dec/mod.rs +index a35897e..f0bf645 100644 +--- a/src/libcore/tests/num/flt2dec/mod.rs ++++ b/src/libcore/tests/num/flt2dec/mod.rs +@@ -13,7 +13,6 @@ mod strategy { + mod dragon; + mod grisu; + } +-mod random; + + pub fn decode_finite(v: T) -> Decoded { + match decode(v).1 { +diff --git a/src/libcore/tests/num/int_macros.rs b/src/libcore/tests/num/int_macros.rs +index 0475aeb..9558198 100644 +--- a/src/libcore/tests/num/int_macros.rs ++++ b/src/libcore/tests/num/int_macros.rs +@@ -88,6 +88,7 @@ mod tests { + assert_eq!(C.count_zeros(), bits as u32 - 5); + } + ++ /* + #[test] + fn test_rotate() { + assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); +@@ -112,6 +113,7 @@ mod tests { + assert_eq!(B.rotate_left(64), B); + assert_eq!(C.rotate_left(64), C); + } ++ */ + + #[test] + fn test_swap_bytes() { +diff --git a/src/libcore/tests/num/uint_macros.rs b/src/libcore/tests/num/uint_macros.rs +index 04ed14f..a6e372e 100644 +--- a/src/libcore/tests/num/uint_macros.rs ++++ b/src/libcore/tests/num/uint_macros.rs +@@ -52,6 +52,7 @@ mod tests { + assert!(C.count_zeros() == bits as u32 - 5); + } + ++ /* + #[test] + fn test_rotate() { + assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); +@@ -76,6 +77,7 @@ mod tests { + assert_eq!(B.rotate_left(64), B); + assert_eq!(C.rotate_left(64), C); + } ++ */ + + #[test] + fn test_swap_bytes() { +diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs +index 1a6be3a..42dbd59 100644 +--- a/src/libcore/tests/ptr.rs ++++ b/src/libcore/tests/ptr.rs +@@ -250,6 +250,7 @@ fn test_unsized_nonnull() { + assert!(ys == zs); + } + ++/* + #[test] + #[allow(warnings)] + // Have a symbol for the test below. It doesn’t need to be an actual variadic function, match the +@@ -289,6 +290,7 @@ fn write_unaligned_drop() { + } + DROPS.with(|d| assert_eq!(*d.borrow(), [0])); + } ++*/ + + #[test] + #[cfg(not(miri))] // Miri does not compute a maximal `mid` for `align_offset` +diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs +index 6609bc3..241b497 100644 +--- a/src/libcore/tests/slice.rs ++++ b/src/libcore/tests/slice.rs +@@ -1209,6 +1209,7 @@ fn brute_force_rotate_test_1() { + } + } + ++/* + #[test] + #[cfg(not(target_arch = "wasm32"))] + fn sort_unstable() { +@@ -1394,6 +1395,7 @@ fn partition_at_index() { + v.partition_at_index(0); + assert!(v == [0xDEADBEEF]); + } ++*/ + + #[test] + #[should_panic(expected = "index 0 greater than length of slice")] +-- +2.21.0 (Apple Git-122) diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch new file mode 100644 index 0000000000000..d5e4656926044 --- /dev/null +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -0,0 +1,183 @@ +From dd82e95c9de212524e14fc60155de1ae40156dfc Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sun, 24 Nov 2019 15:34:06 +0100 +Subject: [PATCH] [core] Ignore failing tests + +--- + src/libcore/tests/iter.rs | 4 ++++ + src/libcore/tests/num/bignum.rs | 10 ++++++++++ + src/libcore/tests/num/mod.rs | 5 +++-- + src/libcore/tests/time.rs | 1 + + 4 files changed, 18 insertions(+), 2 deletions(-) + +diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs +index c9096b7..be37fcd 100644 +--- a/src/libcore/tests/iter.rs ++++ b/src/libcore/tests/iter.rs +@@ -342,6 +342,7 @@ fn test_iterator_step_by_nth() { + } + + #[test] ++#[ignore] + fn test_iterator_step_by_nth_overflow() { + #[cfg(target_pointer_width = "8")] + type Bigger = u16; +@@ -2184,6 +2185,7 @@ fn test_range_inclusive_folds() { + } + + #[test] ++#[ignore] + fn test_range_size_hint() { + use core::usize::MAX as UMAX; + assert_eq!((0..0usize).size_hint(), (0, Some(0))); +@@ -2210,6 +2212,7 @@ fn test_range_size_hint() { + } + + #[test] ++#[ignore] + fn test_range_inclusive_size_hint() { + use core::usize::MAX as UMAX; + assert_eq!((1..=0usize).size_hint(), (0, Some(0))); +@@ -2305,6 +2308,7 @@ fn test_repeat_with_take_collect() { + } + + #[test] ++#[ignore] + fn test_successors() { + let mut powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10)); + assert_eq!(powers_of_10.by_ref().collect::>(), &[1, 10, 100, 1_000, 10_000]); +diff --git a/src/libcore/tests/num/bignum.rs b/src/libcore/tests/num/bignum.rs +index b9e15ec..32f6de8 100644 +--- a/src/libcore/tests/num/bignum.rs ++++ b/src/libcore/tests/num/bignum.rs +@@ -3,6 +3,7 @@ use core::num::bignum::tests::Big8x3 as Big; + + #[test] + #[should_panic] ++#[ignore] + fn test_from_u64_overflow() { + Big::from_u64(0x1000000); + } +@@ -19,12 +20,14 @@ fn test_add() { + + #[test] + #[should_panic] ++#[ignore] + fn test_add_overflow_1() { + Big::from_small(1).add(&Big::from_u64(0xffffff)); + } + + #[test] + #[should_panic] ++#[ignore] + fn test_add_overflow_2() { + Big::from_u64(0xffffff).add(&Big::from_small(1)); + } +@@ -42,6 +45,7 @@ fn test_add_small() { + + #[test] + #[should_panic] ++#[ignore] + fn test_add_small_overflow() { + Big::from_u64(0xffffff).add_small(1); + } +@@ -76,6 +80,7 @@ fn test_mul_small() { + + #[test] + #[should_panic] ++#[ignore] + fn test_mul_small_overflow() { + Big::from_u64(0x800000).mul_small(2); + } +@@ -118,12 +123,14 @@ fn test_mul_pow5() { + + #[test] + #[should_panic] ++#[ignore] + fn test_mul_pow5_overflow_1() { + Big::from_small(1).mul_pow5(12); + } + + #[test] + #[should_panic] ++#[ignore] + fn test_mul_pow5_overflow_2() { + Big::from_small(230).mul_pow5(8); + } +@@ -141,12 +148,14 @@ fn test_mul_digits() { + + #[test] + #[should_panic] ++#[ignore] + fn test_mul_digits_overflow_1() { + Big::from_u64(0x800000).mul_digits(&[2]); + } + + #[test] + #[should_panic] ++#[ignore] + fn test_mul_digits_overflow_2() { + Big::from_u64(0x1000).mul_digits(&[0, 0x10]); + } +@@ -206,6 +215,7 @@ fn test_get_bit() { + + #[test] + #[should_panic] ++#[ignore] + fn test_get_bit_out_of_range() { + Big::from_small(42).get_bit(24); + } +diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs +index a17c094..5bb11d2 100644 +--- a/src/libcore/tests/num/mod.rs ++++ b/src/libcore/tests/num/mod.rs +@@ -63,6 +63,7 @@ pub fn test_num(ten: T, two: T) where + } + + #[test] ++#[ignore] + fn from_str_issue7588() { + let u : Option = u8::from_str_radix("1000", 10).ok(); + assert_eq!(u, None); +@@ -613,11 +614,9 @@ test_impl_try_from_signed_to_unsigned_err! { test_try_i64u32, i64, u32 } + test_impl_try_from_signed_to_unsigned_err! { test_try_i128u8, i128, u8 } + test_impl_try_from_signed_to_unsigned_err! { test_try_i128u16, i128, u16 } + test_impl_try_from_signed_to_unsigned_err! { test_try_i128u32, i128, u32 } +-test_impl_try_from_signed_to_unsigned_err! { test_try_i128u64, i128, u64 } + + assume_usize_width! { + test_impl_try_from_signed_to_unsigned_err! { test_try_isizeu8, isize, u8 } +- test_impl_try_from_signed_to_unsigned_err! { test_try_i128usize, i128, usize } + + cfg_block! { + #[cfg(target_pointer_width = "16")] { +@@ -640,6 +639,7 @@ macro_rules! test_float { + ($modname: ident, $fty: ty, $inf: expr, $neginf: expr, $nan: expr) => { mod $modname { + // FIXME(nagisa): these tests should test for sign of -0.0 + #[test] ++ #[ignore] + fn min() { + assert_eq!((0.0 as $fty).min(0.0), 0.0); + assert_eq!((-0.0 as $fty).min(-0.0), -0.0); +@@ -662,6 +662,7 @@ macro_rules! test_float { + assert!(($nan as $fty).min($nan).is_nan()); + } + #[test] ++ #[ignore] + fn max() { + assert_eq!((0.0 as $fty).max(0.0), 0.0); + assert_eq!((-0.0 as $fty).max(-0.0), -0.0); +diff --git a/src/libcore/tests/time.rs b/src/libcore/tests/time.rs +index fac70c4..9107a02 100644 +--- a/src/libcore/tests/time.rs ++++ b/src/libcore/tests/time.rs +@@ -127,6 +127,7 @@ fn mul() { + } + + #[test] ++#[ignore] + fn checked_mul() { + assert_eq!(Duration::new(0, 1).checked_mul(2), Some(Duration::new(0, 2))); + assert_eq!(Duration::new(1, 1).checked_mul(3), Some(Duration::new(3, 3))); +-- +2.21.0 (Apple Git-122) diff --git a/test.sh b/test.sh index 1f87c7203e301..1211461ac0e9a 100755 --- a/test.sh +++ b/test.sh @@ -76,6 +76,11 @@ cp ./target/*/debug/main ./raytracer_cg_clif hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif popd +pushd build_sysroot/sysroot_src/src/libcore/tests +rm -r sysroot_src/src/**/*/target/ || true +cargo test +popd + pushd regex echo "[TEST] rust-lang/regex example shootout-regex-dna" ../cargo.sh clean From c3df8b185b2832303b6989b18879cd8236fe594e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 24 Nov 2019 16:30:15 +0100 Subject: [PATCH 0949/1566] Rustup to rustc 1.41.0-nightly (0c987c5c0 2019-11-23) --- src/constant.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index e0d3a873f7c13..1f0a39540d14d 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -356,7 +356,12 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu // Don't push a `TodoItem::Static` here, as it will cause statics used by // multiple crates to be duplicated between them. It isn't necessary anyway, // as it will get pushed by `codegen_static` when necessary. - data_id_for_static(tcx, module, def_id, Linkage::Import) + data_id_for_static( + tcx, + module, + def_id, + crate::linkage::get_static_ref_linkage(tcx, def_id), + ) } }; From e51a5cf01c2feca40109a659d4e4ebbbc9477195 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2019 05:02:10 +0000 Subject: [PATCH 0950/1566] Bump cranelift from `bed9a72` to `0b40b11` Bumps [cranelift](https://github.com/bytecodealliance/cranelift) from `bed9a72` to `0b40b11`. - [Release notes](https://github.com/bytecodealliance/cranelift/releases) - [Commits](https://github.com/bytecodealliance/cranelift/compare/bed9a72a777f1b972e58ad250ead851585d9ab1e...0b40b114f66702478148f1184c768307b9599870) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 122 ++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d54a9554bba8..432850885ca4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,31 +65,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-bforest" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-meta 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-shared 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-meta 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,17 +98,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen-shared 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -116,16 +116,16 @@ dependencies = [ [[package]] name = "cranelift-entity" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" [[package]] name = "cranelift-faerie" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -134,10 +134,10 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -145,44 +145,44 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.49.0" -source = "git+https://github.com/bytecodealliance/cranelift/#bed9a72a777f1b972e58ad250ead851585d9ab1e" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" dependencies = [ - "cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -436,11 +436,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-faerie 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -629,18 +629,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-bforest 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-faerie 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.49.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 6055b85a31d211aec3a6bb4eb12a6e60262dac25 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Nov 2019 20:49:02 +0100 Subject: [PATCH 0951/1566] Update Cranelift --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 432850885ca4c..a402f907e486a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -75,7 +75,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -83,7 +83,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -108,7 +108,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -117,12 +117,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" [[package]] name = "cranelift-faerie" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,7 +146,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -157,7 +157,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -167,7 +167,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -178,7 +178,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0b40b114f66702478148f1184c768307b9599870" +source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", From 65f69d10853be9e386749b08c26abd4e84193f25 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 26 Nov 2019 20:55:03 +0100 Subject: [PATCH 0952/1566] Update dependencies --- Cargo.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a402f907e486a..a9b557979222d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,7 +93,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -151,7 +151,7 @@ dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -364,8 +364,8 @@ name = "packed_struct" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -491,12 +491,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -519,7 +519,7 @@ name = "string-interner" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -568,15 +568,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "thiserror" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror-impl" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -674,8 +674,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" -"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8" +"checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" +"checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" @@ -684,8 +684,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" -"checksum thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f9fb62ff737e573b1e677459bea6fd023cd5d6e868c3242d3cdf3ef2f0554824" -"checksum thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "24069c0ba08aab54289d6a25f5036d94afc61e1538bbc42ae5501df141c9027d" +"checksum thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cc6b305ec0e323c7b6cfff6098a22516e0063d0bb7c3d88660a890217dca099a" +"checksum thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45ba8d810d9c48fc456b7ad54574e8bfb7c7918a57ad7a6e6a0985d7959e8597" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" From f0bb30f8a1ac6107555dfc8fe830d42f469af7f8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Nov 2019 21:35:03 +0100 Subject: [PATCH 0953/1566] Rustup to rustc 1.41.0-nightly (25d8a9494 2019-11-29) --- src/constant.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 1f0a39540d14d..ab099292bf480 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -411,8 +411,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { _: &mut InterpCx<'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], - _: Option>, - _: Option, + _: Option<(PlaceTy<'tcx>, BasicBlock)>, _: Option, ) -> InterpResult<'tcx, Option<&'mir Body<'tcx>>> { panic!(); @@ -423,8 +422,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { _: Span, _: Instance<'tcx>, _: &[OpTy<'tcx>], - _: Option>, - _: Option, + _: Option<(PlaceTy<'tcx>, BasicBlock)>, _: Option, ) -> InterpResult<'tcx> { panic!(); @@ -468,7 +466,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { _: &mut InterpCx<'mir, 'tcx, Self>, _: !, _: &[OpTy<'tcx, ()>], - _: Option>, + _: Option<(PlaceTy<'tcx, ()>, BasicBlock)>, _: Option, ) -> InterpResult<'tcx> { unreachable!(); From c6086a8fd7489fa6cf18b7dd0baf73cf21386c77 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 5 Dec 2019 21:00:57 +0100 Subject: [PATCH 0954/1566] Rustup to rustc 1.41.0-nightly (6d77e45f0 2019-12-04) --- Cargo.toml | 2 - example/mini_core.rs | 17 ++++- .../0015-Remove-usage-of-unsized-locals.patch | 5 +- src/abi/mod.rs | 67 ++++++++++++++++++- src/base.rs | 2 +- src/constant.rs | 17 +++-- src/pretty_clif.rs | 2 +- test.sh | 2 +- 8 files changed, 98 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1a39e2498692d..b6e55b35720da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,3 @@ -cargo-features = ["profile-overrides"] - [package] name = "rustc_codegen_cranelift" version = "0.1.0" diff --git a/example/mini_core.rs b/example/mini_core.rs index 1d8942c6ab2c9..1912cc50a218e 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,6 +1,6 @@ #![feature( no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, - untagged_unions, decl_macro, rustc_attrs, transparent_unions + untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_traits )] #![no_core] #![allow(dead_code)] @@ -76,7 +76,13 @@ unsafe impl<'a, T: ?Sized> Sync for &'a T {} unsafe impl Sync for [u8; 16] {} #[lang = "freeze"] -trait Freeze {} +unsafe auto trait Freeze {} + +unsafe impl Freeze for PhantomData {} +unsafe impl Freeze for *const T {} +unsafe impl Freeze for *mut T {} +unsafe impl Freeze for &T {} +unsafe impl Freeze for &mut T {} #[lang = "not"] pub trait Not { @@ -538,3 +544,10 @@ pub macro line() { /* compiler built-in */ } pub macro cfg() { /* compiler built-in */ } pub static A_STATIC: u8 = 42; + +#[lang = "panic_location"] +struct PanicLocation { + file: &'static str, + line: u32, + column: u32, +} diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch index 14504cce09ff7..02ecaa7a99451 100644 --- a/patches/0015-Remove-usage-of-unsized-locals.patch +++ b/patches/0015-Remove-usage-of-unsized-locals.patch @@ -98,10 +98,9 @@ diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index f4a1783..362b537 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs -@@ -40,6 +40,8 @@ impl Thread { +@@ -40,5 +40,7 @@ impl Thread { // unsafe: see thread::Builder::spawn_unchecked for safety requirements - pub unsafe fn new(stack: usize, p: Box) - -> io::Result { + pub unsafe fn new(stack: usize, p: Box) -> io::Result { + panic!("Threads are not yet supported, because cranelift doesn't support atomics."); + let p = box p; diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 9e3e4f82a39b9..31e667095fa65 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -10,6 +10,69 @@ use crate::prelude::*; pub use self::returning::codegen_return; +// Copied from https://github.com/rust-lang/rust/blob/c2f4c57296f0d929618baed0b0d6eb594abf01eb/src/librustc/ty/layout.rs#L2349 +pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { + let ty = instance.ty(tcx); + match ty.kind { + ty::FnDef(..) | + // Shims currently have type FnPtr. Not sure this should remain. + ty::FnPtr(_) => { + let mut sig = ty.fn_sig(tcx); + if let ty::InstanceDef::VtableShim(..) = instance.def { + // Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`. + sig = sig.map_bound(|mut sig| { + let mut inputs_and_output = sig.inputs_and_output.to_vec(); + inputs_and_output[0] = tcx.mk_mut_ptr(inputs_and_output[0]); + sig.inputs_and_output = tcx.intern_type_list(&inputs_and_output); + sig + }); + } + sig + } + ty::Closure(def_id, substs) => { + let sig = substs.as_closure().sig(def_id, tcx); + + let env_ty = tcx.closure_env_ty(def_id, substs).unwrap(); + sig.map_bound(|sig| tcx.mk_fn_sig( + std::iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), + sig.output(), + sig.c_variadic, + sig.unsafety, + sig.abi + )) + } + ty::Generator(def_id, substs, _) => { + let sig = substs.as_generator().poly_sig(def_id, tcx); + + let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); + let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty); + + let pin_did = tcx.lang_items().pin_type().unwrap(); + let pin_adt_ref = tcx.adt_def(pin_did); + let pin_substs = tcx.intern_substs(&[env_ty.into()]); + let env_ty = tcx.mk_adt(pin_adt_ref, pin_substs); + + sig.map_bound(|sig| { + let state_did = tcx.lang_items().gen_state().unwrap(); + let state_adt_ref = tcx.adt_def(state_did); + let state_substs = tcx.intern_substs(&[ + sig.yield_ty.into(), + sig.return_ty.into(), + ]); + let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); + + tcx.mk_fn_sig(std::iter::once(env_ty), + ret_ty, + false, + rustc::hir::Unsafety::Normal, + rustc_target::spec::abi::Abi::Rust + ) + }) + } + _ => bug!("unexpected type {:?} in Instance::fn_sig", ty) + } +} + fn clif_sig_from_fn_sig<'tcx>( tcx: TyCtxt<'tcx>, sig: FnSig<'tcx>, @@ -98,7 +161,7 @@ pub fn get_function_name_and_sig<'tcx>( ) -> (String, Signature) { assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); let fn_sig = - tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &inst.fn_sig(tcx)); + tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_sig_for_fn_abi(tcx, inst)); if fn_sig.c_variadic && !support_vararg { unimpl!("Variadic function definitions are not yet supported"); } @@ -199,7 +262,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { fn self_sig(&self) -> FnSig<'tcx> { self.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &self.instance.fn_sig(self.tcx), + &fn_sig_for_fn_abi(self.tcx, self.instance), ) } diff --git a/src/base.rs b/src/base.rs index 33ae97ef652f6..7c7dd24126358 100644 --- a/src/base.rs +++ b/src/base.rs @@ -9,7 +9,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( ) { let tcx = cx.tcx; - let mir = tcx.instance_mir(instance.def); + let mir = *tcx.instance_mir(instance.def); // Declare function let (name, sig) = get_function_name_and_sig(tcx, instance, false); diff --git a/src/constant.rs b/src/constant.rs index ab099292bf480..dade64b348a29 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -5,8 +5,8 @@ use rustc::mir::interpret::{ }; use rustc::ty::{layout::Align, Const, ConstKind}; use rustc_mir::interpret::{ - ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, - StackPopInfo, + ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PanicInfo, PlaceTy, Pointer, + StackPopCleanup, StackPopInfo, }; use cranelift_module::*; @@ -407,7 +407,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn find_fn( + fn find_mir_or_eval_fn( _: &mut InterpCx<'mir, 'tcx, Self>, _: Instance<'tcx>, _: &[OpTy<'tcx>], @@ -449,7 +449,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn tag_allocation<'b>( + fn init_allocation_extra<'b>( _: &(), _: AllocId, alloc: Cow<'b, Allocation>, @@ -479,6 +479,15 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: (), _: bool) -> InterpResult<'tcx, StackPopInfo> { Ok(StackPopInfo::Normal) } + + fn assert_panic( + _: &mut InterpCx<'mir, 'tcx, Self>, + _: Span, + _: &PanicInfo>, + _: Option, + ) -> InterpResult<'tcx> { + unreachable!() + } } pub fn mir_operand_get_const_val<'tcx>( diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 0216ba11c37a4..f595d384f4f2c 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -82,7 +82,7 @@ impl CommentWriter { "sig {:?}", tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &instance.fn_sig(tcx) + &crate::abi::fn_sig_for_fn_abi(tcx, instance) ) ), String::new(), diff --git a/test.sh b/test.sh index 1211461ac0e9a..05ba16ea31cb0 100755 --- a/test.sh +++ b/test.sh @@ -67,7 +67,7 @@ $RUSTC example/mod_bench.rs --crate-type bin pushd simple-raytracer echo "[BENCH COMPILE] ebobby/simple-raytracer" -hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug" \ +hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \ "RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \ "../cargo.sh build" From d14ad3588470cfe57cd1b14ca79758838254db4e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 8 Dec 2019 11:32:03 +0100 Subject: [PATCH 0955/1566] Rustup to rustc 1.41.0-nightly (5c5c8eb86 2019-12-07) --- patches/0017-Fix-libtest-compilation.patch | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index c76e2e2f8b42d..ffde7ec3b6222 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -71,9 +71,9 @@ index 8b76080..9e65de2 100644 // Buffer for capturing standard I/O let data = Arc::new(Mutex::new(Vec::new())); @@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc, - } else { - None }; + + let start = report_time.then(Instant::now); - let result = catch_unwind(AssertUnwindSafe(testfn)); + let result = Ok::<(), Box>(testfn()); let exec_time = start.map(|start| { @@ -93,4 +93,3 @@ index 8b76080..9e65de2 100644 let test_result = match panic_info { -- 2.20.1 - From 0cbcccf4c1022d568a47a3e43c347730126924c2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 8 Dec 2019 11:51:18 +0100 Subject: [PATCH 0956/1566] Update Cranelift --- Cargo.lock | 40 ++++++++++++++++++++-------------------- Cargo.toml | 6 +----- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9b557979222d..25c06fa05eb76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -75,7 +75,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -83,7 +83,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -108,7 +108,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -117,12 +117,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" [[package]] name = "cranelift-faerie" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,7 +146,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -157,7 +157,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -167,18 +167,18 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)", + "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c54fc845c45b2929bdf36635c90a363e380cf805" +source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -347,8 +347,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" -version = "0.15.0" -source = "git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056#cba3ed4932e4c594c5eab4f5ef6c51838f4a5056" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -356,7 +356,7 @@ dependencies = [ "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -446,7 +446,7 @@ dependencies = [ "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)", + "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -596,7 +596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uuid" -version = "0.7.4" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -659,7 +659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -"checksum object 0.15.0 (git+https://github.com/gimli-rs/object?rev=cba3ed4932e4c594c5eab4f5ef6c51838f4a5056)" = "" +"checksum object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3c61759aa254402e53c79a68dc519cda1ceee2ff2b6d70b3e58bf64ac2f03e3" "checksum packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90caf80e74380d94f2aabc83edb900b49123b3132442fb147f9155c87a756281" "checksum packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f6fda15ebe37b7b28889bd4aa75bb134652eaec9eb99d1bf02f806fca4357fc" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" @@ -688,7 +688,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45ba8d810d9c48fc456b7ad54574e8bfb7c7918a57ad7a6e6a0985d7959e8597" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" +"checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index b6e55b35720da..fc06285c56651 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,11 +29,7 @@ indexmap = "1.0.2" libloading = "0.5.1" [dependencies.object] -# FIXME remove git and rev once cranelift switches back to a crates.io release of object -git = "https://github.com/gimli-rs/object" -rev = "cba3ed4932e4c594c5eab4f5ef6c51838f4a5056" - -version = "0.15.0" +version = "0.16.0" default-features = false features = ["compression", "read", "std"] # We don't need WASM support From 88277f983afd1d5d71f0135ae27dd1faabf15202 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 8 Dec 2019 11:52:04 +0100 Subject: [PATCH 0957/1566] Remove some workarounds for missing inst legalizations --- src/base.rs | 2 -- src/common.rs | 15 --------------- src/intrinsics.rs | 38 +++++++++++--------------------------- 3 files changed, 11 insertions(+), 44 deletions(-) diff --git a/src/base.rs b/src/base.rs index 7c7dd24126358..28f55a6cc6d28 100644 --- a/src/base.rs +++ b/src/base.rs @@ -168,8 +168,6 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } } let cond = trans_operand(fx, cond).load_scalar(fx); - // TODO HACK brz/brnz for i8/i16 is not yet implemented - let cond = fx.bcx.ins().uextend(types::I32, cond); let target = fx.get_ebb(*target); if *expected { fx.bcx.ins().brnz(cond, target, &[]); diff --git a/src/common.rs b/src/common.rs index 1bd8afed5087d..f3b7fc925eeb8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -80,21 +80,6 @@ pub fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { } } -pub fn codegen_select(bcx: &mut FunctionBuilder, cond: Value, lhs: Value, rhs: Value) -> Value { - let lhs_ty = bcx.func.dfg.value_type(lhs); - let rhs_ty = bcx.func.dfg.value_type(rhs); - assert_eq!(lhs_ty, rhs_ty); - if lhs_ty == types::I8 || lhs_ty == types::I16 { - // FIXME workaround for missing encoding for select.i8 - let lhs = bcx.ins().uextend(types::I32, lhs); - let rhs = bcx.ins().uextend(types::I32, rhs); - let res = bcx.ins().select(cond, lhs, rhs); - bcx.ins().ireduce(lhs_ty, res) - } else { - bcx.ins().select(cond, lhs, rhs) - } -} - pub fn codegen_icmp( fx: &mut FunctionCx<'_, '_, impl Backend>, intcc: IntCC, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index bee22daef5349..4ad6ae91f928e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -118,7 +118,7 @@ macro_rules! atomic_minmax { // Compare let is_eq = codegen_icmp($fx, IntCC::SignedGreaterThan, old, $src); - let new = codegen_select(&mut $fx.bcx, is_eq, old, $src); + let new = $fx.bcx.ins().select(is_eq, old, $src); // Write new $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); @@ -195,7 +195,7 @@ pub fn bool_to_zero_or_max_uint<'tcx>( .bcx .ins() .iconst(int_ty, (u64::max_value() >> (64 - int_ty.bits())) as i64); - let mut res = crate::common::codegen_select(&mut fx.bcx, val, max, zero); + let mut res = fx.bcx.ins().select(val, max, zero); if ty.is_float() { res = fx.bcx.ins().bitcast(ty, res); @@ -553,19 +553,19 @@ pub fn codegen_intrinsic_call<'tcx>( let max = fx.bcx.ins().iconst(clif_ty, max); let val = match (intrinsic, signed) { - ("saturating_add", false) => codegen_select(&mut fx.bcx, has_overflow, max, val), - ("saturating_sub", false) => codegen_select(&mut fx.bcx, has_overflow, min, val), + ("saturating_add", false) => fx.bcx.ins().select(has_overflow, max, val), + ("saturating_sub", false) => fx.bcx.ins().select(has_overflow, min, val), ("saturating_add", true) => { let rhs = rhs.load_scalar(fx); let rhs_ge_zero = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThanOrEqual, rhs, 0); - let sat_val = codegen_select(&mut fx.bcx, rhs_ge_zero, max, min); - codegen_select(&mut fx.bcx, has_overflow, sat_val, val) + let sat_val = fx.bcx.ins().select(rhs_ge_zero, max, min); + fx.bcx.ins().select(has_overflow, sat_val, val) } ("saturating_sub", true) => { let rhs = rhs.load_scalar(fx); let rhs_ge_zero = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThanOrEqual, rhs, 0); - let sat_val = codegen_select(&mut fx.bcx, rhs_ge_zero, min, max); - codegen_select(&mut fx.bcx, has_overflow, sat_val, val) + let sat_val = fx.bcx.ins().select(rhs_ge_zero, min, max); + fx.bcx.ins().select(has_overflow, sat_val, val) } _ => unreachable!(), }; @@ -703,28 +703,12 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, res); }; ctpop, (v arg) { - let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { - let (lo, hi) = fx.bcx.ins().isplit(arg); - let lo_popcnt = fx.bcx.ins().popcnt(lo); - let hi_popcnt = fx.bcx.ins().popcnt(hi); - let popcnt = fx.bcx.ins().iadd(lo_popcnt, hi_popcnt); - crate::cast::clif_intcast(fx, popcnt, types::I128, false) - } else { - fx.bcx.ins().popcnt(arg) - }; + let res = fx.bcx.ins().popcnt(arg); let res = CValue::by_val(res, fx.layout_of(T)); ret.write_cvalue(fx, res); }; bitreverse, (v arg) { - let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { - let (lo, hi) = fx.bcx.ins().isplit(arg); - let lo_bitrev = fx.bcx.ins().bitrev(lo); - let hi_bitrev = fx.bcx.ins().bitrev(hi); - let bitrev = fx.bcx.ins().iconcat(hi_bitrev, lo_bitrev); - crate::cast::clif_intcast(fx, bitrev, types::I128, false) - } else { - fx.bcx.ins().bitrev(arg) - }; + let res = fx.bcx.ins().bitrev(arg); let res = CValue::by_val(res, fx.layout_of(T)); ret.write_cvalue(fx, res); }; @@ -881,7 +865,7 @@ pub fn codegen_intrinsic_call<'tcx>( // Compare let is_eq = codegen_icmp(fx, IntCC::Equal, old, test_old); - let new = crate::common::codegen_select(&mut fx.bcx, is_eq, new, old); // Keep old if not equal to test_old + let new = fx.bcx.ins().select(is_eq, new, old); // Keep old if not equal to test_old // Write new fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); From e1613a69d4136559e8bb76bd191a21091c63efc4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 11:33:57 +0100 Subject: [PATCH 0958/1566] Rustup to rustc 1.41.0-nightly (a605441e0 2019-12-15) --- ...3-Disable-inline-assembly-in-libcore.patch | 6 +-- ...022-core-Disable-not-compiling-tests.patch | 50 +++++++++---------- src/base.rs | 3 +- src/lib.rs | 2 +- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/patches/0003-Disable-inline-assembly-in-libcore.patch b/patches/0003-Disable-inline-assembly-in-libcore.patch index dce18ec1ad98e..5174e4d08e950 100644 --- a/patches/0003-Disable-inline-assembly-in-libcore.patch +++ b/patches/0003-Disable-inline-assembly-in-libcore.patch @@ -16,9 +16,9 @@ index ad5a207..04712b8 100644 #[unstable(feature = "renamed_spin_loop", issue = "55002")] pub fn spin_loop() { + /* - #[cfg( - all( - any(target_arch = "x86", target_arch = "x86_64"), + #[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2"))] + { + #[cfg(target_arch = "x86")] @@ -71,4 +72,5 @@ pub fn spin_loop() { unsafe { crate::arch::arm::__yield() }; } diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch index 77cdd0c56e98e..e001ba766fcdb 100644 --- a/patches/0022-core-Disable-not-compiling-tests.patch +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -44,41 +44,41 @@ index 0475aeb..9558198 100644 --- a/src/libcore/tests/num/int_macros.rs +++ b/src/libcore/tests/num/int_macros.rs @@ -88,6 +88,7 @@ mod tests { - assert_eq!(C.count_zeros(), bits as u32 - 5); - } + assert_eq!(C.count_zeros(), bits as u32 - 5); + } -+ /* - #[test] - fn test_rotate() { - assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); ++ /* + #[test] + fn test_rotate() { + assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); @@ -112,6 +113,7 @@ mod tests { - assert_eq!(B.rotate_left(64), B); - assert_eq!(C.rotate_left(64), C); - } -+ */ + assert_eq!(B.rotate_left(64), B); + assert_eq!(C.rotate_left(64), C); + } ++ */ - #[test] - fn test_swap_bytes() { + #[test] + fn test_swap_bytes() { diff --git a/src/libcore/tests/num/uint_macros.rs b/src/libcore/tests/num/uint_macros.rs index 04ed14f..a6e372e 100644 --- a/src/libcore/tests/num/uint_macros.rs +++ b/src/libcore/tests/num/uint_macros.rs @@ -52,6 +52,7 @@ mod tests { - assert!(C.count_zeros() == bits as u32 - 5); - } + assert!(C.count_zeros() == bits as u32 - 5); + } -+ /* - #[test] - fn test_rotate() { - assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); ++ /* + #[test] + fn test_rotate() { + assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A); @@ -76,6 +77,7 @@ mod tests { - assert_eq!(B.rotate_left(64), B); - assert_eq!(C.rotate_left(64), C); - } -+ */ + assert_eq!(B.rotate_left(64), B); + assert_eq!(C.rotate_left(64), C); + } ++ */ - #[test] - fn test_swap_bytes() { + #[test] + fn test_swap_bytes() { diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs index 1a6be3a..42dbd59 100644 --- a/src/libcore/tests/ptr.rs @@ -98,7 +98,7 @@ index 1a6be3a..42dbd59 100644 +*/ #[test] - #[cfg(not(miri))] // Miri does not compute a maximal `mid` for `align_offset` + #[cfg_attr(miri, ignore)] // Miri does not compute a maximal `mid` for `align_offset` diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 6609bc3..241b497 100644 --- a/src/libcore/tests/slice.rs diff --git a/src/base.rs b/src/base.rs index 28f55a6cc6d28..705629888aa7f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -647,7 +647,7 @@ pub fn trans_place<'tcx>( }; cplace = cplace.place_index(fx, index); } - PlaceElem::Subslice { from, to } => { + PlaceElem::Subslice { from, to, from_end } => { // These indices are generated by slice patterns. // slice[from:-to] in Python terms. @@ -665,6 +665,7 @@ pub fn trans_place<'tcx>( ); } ty::Slice(elem_ty) => { + assert!(from_end, "slice subslices should be `from_end`"); let elem_layout = fx.layout_of(elem_ty); let (ptr, len) = cplace.to_addr_maybe_unsized(fx); let len = len.unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 3d30185f945b8..cc8216f0efae5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds)] +#![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds, never_type)] #![allow(intra_doc_link_resolution_failure)] extern crate flate2; From b97df0b07fb925f7b0894b661afaad2413a3242e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 11:50:20 +0100 Subject: [PATCH 0959/1566] Fix Linux libtest --- ...g-initialization-on-linux-to-not-req.patch | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch diff --git a/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch b/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch new file mode 100644 index 0000000000000..5300c590b2a1c --- /dev/null +++ b/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch @@ -0,0 +1,29 @@ +From eaa0c3eac2067c7c08913653ebef10c103c1255f Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Mon, 16 Dec 2019 11:46:10 +0100 +Subject: [PATCH] [libstd] Revert arg initialization on linux to not require + #[link_section] + +--- + src/libstd/sys/unix/args.rs | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs +index 2ed1585..b4b021a 100644 +--- a/src/libstd/sys/unix/args.rs ++++ b/src/libstd/sys/unix/args.rs +@@ -83,10 +83,7 @@ mod imp { + // On Linux-GNU, we rely on `ARGV_INIT_ARRAY` below to initialize + // `ARGC` and `ARGV`. But in Miri that does not actually happen so we + // still initialize here. +- #[cfg(any( +- miri, +- not(all(target_os = "linux", target_env = "gnu")) +- ))] ++ // `#[link_section]` is not yet supported by cg_clif + really_init(_argc, _argv); + } + +-- +2.20.1 + From 83431367d9ce6d3bc82e29836853d134817db194 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 12:00:29 +0100 Subject: [PATCH 0960/1566] Update Cranelift --- Cargo.lock | 92 +++++++----------------------------------------------- 1 file changed, 12 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25c06fa05eb76..0e3530c446694 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -75,7 +75,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -83,7 +83,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -108,21 +108,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" -dependencies = [ - "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", -] +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" [[package]] name = "cranelift-entity" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" [[package]] name = "cranelift-faerie" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -135,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,7 +142,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -157,7 +153,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -167,7 +163,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -178,7 +174,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#4727b70b67abfa4f3ae1c276454a0da7a76e1d49" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -359,25 +355,6 @@ dependencies = [ "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "packed_struct" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "packed_struct_codegen" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "plain" version = "0.2.3" @@ -391,11 +368,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "quote" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "quote" version = "1.0.2" @@ -494,16 +466,6 @@ name = "serde" version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "serde_derive" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "smallvec" version = "1.0.0" @@ -522,16 +484,6 @@ dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "syn" -version = "0.11.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syn" version = "1.0.8" @@ -542,14 +494,6 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "synom" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "synstructure" version = "0.12.3" @@ -584,11 +528,6 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "unicode-xid" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "unicode-xid" version = "0.2.0" @@ -660,11 +599,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3c61759aa254402e53c79a68dc519cda1ceee2ff2b6d70b3e58bf64ac2f03e3" -"checksum packed_struct 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90caf80e74380d94f2aabc83edb900b49123b3132442fb147f9155c87a756281" -"checksum packed_struct_codegen 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9f6fda15ebe37b7b28889bd4aa75bb134652eaec9eb99d1bf02f806fca4357fc" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" @@ -675,18 +611,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" -"checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" -"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" -"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" "checksum thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cc6b305ec0e323c7b6cfff6098a22516e0063d0bb7c3d88660a890217dca099a" "checksum thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45ba8d810d9c48fc456b7ad54574e8bfb7c7918a57ad7a6e6a0985d7959e8597" -"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" From 306bf8ec1c13f22523e6aea74718357674bc30aa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 12:03:58 +0100 Subject: [PATCH 0961/1566] Update dependencies --- Cargo.lock | 88 +++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e3530c446694..d535dce562b86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -39,8 +39,8 @@ name = "backtrace-sys" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -55,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -90,10 +90,10 @@ dependencies = [ "cranelift-codegen-meta 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -124,7 +124,7 @@ dependencies = [ "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -134,7 +134,7 @@ version = "0.51.0" source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -146,8 +146,8 @@ source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e19 dependencies = [ "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -180,7 +180,7 @@ dependencies = [ "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -200,7 +200,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -210,7 +210,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -219,9 +219,9 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -243,7 +243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -259,7 +259,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -282,10 +282,10 @@ dependencies = [ [[package]] name = "goblin" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -300,7 +300,7 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.65" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -308,13 +308,13 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -325,7 +325,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -348,7 +348,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -382,7 +382,7 @@ version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -392,7 +392,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -416,7 +416,7 @@ dependencies = [ "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -445,7 +445,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -463,7 +463,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -481,12 +481,12 @@ name = "string-interner" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -501,7 +501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -512,20 +512,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "thiserror" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror-impl" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -566,7 +566,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" +"checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" @@ -590,11 +590,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" -"checksum goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6040506480da04a63de51a478e8021892d65d8411f29b2a422c2648bdd8bcb" +"checksum goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88a79ef1f0dad46fd78075b6f80f92d97710eddf87b3e18a15a66761e8942672" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" -"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "1b9ad466a945c9c40f6f9a449c55675547e59bc75a2722d4689042ab3ae80c9c" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" @@ -610,15 +610,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" +"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" -"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" +"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" -"checksum thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cc6b305ec0e323c7b6cfff6098a22516e0063d0bb7c3d88660a890217dca099a" -"checksum thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45ba8d810d9c48fc456b7ad54574e8bfb7c7918a57ad7a6e6a0985d7959e8597" +"checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" +"checksum thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" From c0aedfef96b62302a2c2410d0214d94da5dff647 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 9 Nov 2019 16:42:21 +0100 Subject: [PATCH 0962/1566] [WIP] debuginfo for locals --- src/base.rs | 1 + src/debuginfo.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ src/value_and_place.rs | 6 +++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 705629888aa7f..91c2587331315 100644 --- a/src/base.rs +++ b/src/base.rs @@ -21,6 +21,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); + func.collect_debug_info(); let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); diff --git a/src/debuginfo.rs b/src/debuginfo.rs index e6d133c64510c..0998236e58229 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -305,6 +305,48 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64)); + { + let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); + + for (value_label, value_loc_ranges) in value_labels_ranges.iter() { + let live_ranges = RangeList( + Some(Range::BaseAddress { + address: Address::Symbol { + symbol: self.symbol, + addend: 0, + }, + }) + .into_iter() + .chain( + value_loc_ranges + .iter() + .map(|val_loc_range| Range::OffsetPair { + begin: u64::from(val_loc_range.start), + end: u64::from(val_loc_range.end), + }), + ) + .collect(), + ); + let live_ranges_id = self.debug_context.dwarf.unit.ranges.add(live_ranges); + + let var_id = self + .debug_context + .dwarf + .unit + .add(self.entry_id, gimli::DW_TAG_variable); + let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); + + var_entry.set( + gimli::DW_AT_ranges, + AttributeValue::RangeListRef(live_ranges_id), + ); + var_entry.set( + gimli::DW_AT_name, + AttributeValue::String(format!("{:?}", value_label).into_bytes()), + ); + } + } + self.debug_context .unit_range_list .0 diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 142795a91eb50..8016a802dab30 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -299,7 +299,11 @@ impl<'tcx> CPlace<'tcx> { pub fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> { let layout = self.layout(); match self.inner { - CPlaceInner::Var(var) => CValue::by_val(fx.bcx.use_var(mir_var(var)), layout), + CPlaceInner::Var(var) => { + let val = fx.bcx.use_var(mir_var(var)); + fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + CValue::by_val(val, layout) + } CPlaceInner::Addr(addr, extra) => { assert!(extra.is_none(), "unsized values are not yet supported"); CValue::by_ref(addr, layout) From a962835685d0cc02b9749bd8f1f89236796f55a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 9 Nov 2019 18:40:11 +0100 Subject: [PATCH 0963/1566] [WIP] debuginfo: Add types for locals --- src/base.rs | 2 +- src/debuginfo.rs | 77 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/base.rs b/src/base.rs index 91c2587331315..bb0ffb51bcec1 100644 --- a/src/base.rs +++ b/src/base.rs @@ -17,7 +17,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut debug_context = cx .debug_context .as_mut() - .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, func_id, &name, &sig)); + .map(|debug_context| FunctionDebugContext::new(debug_context, mir, func_id, &name, &sig)); // Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 0998236e58229..b3de6449ff4b4 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -70,13 +70,15 @@ pub enum DebugRelocName { } pub struct DebugContext<'tcx> { + tcx: TyCtxt<'tcx>, + endian: RunTimeEndian, symbols: indexmap::IndexMap, dwarf: DwarfUnit, unit_range_list: RangeList, - _dummy: PhantomData<&'tcx ()>, + types: HashMap, UnitEntryId>, } impl<'tcx> DebugContext<'tcx> { @@ -132,18 +134,20 @@ impl<'tcx> DebugContext<'tcx> { } DebugContext { + tcx, + endian: target_endian(tcx), symbols: indexmap::IndexMap::new(), dwarf, unit_range_list: RangeList(Vec::new()), - _dummy: PhantomData, + types: HashMap::new(), } } - fn emit_location(&mut self, tcx: TyCtxt<'tcx>, entry_id: UnitEntryId, span: Span) { - let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { + let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file( &mut self.dwarf.unit.line_program, @@ -168,6 +172,58 @@ impl<'tcx> DebugContext<'tcx> { ); } + fn dwarf_ty(&mut self, ty: Ty<'tcx>) -> UnitEntryId { + if let Some(type_id) = self.types.get(ty) { + return *type_id; + } + + let new_entry = |dwarf: &mut DwarfUnit, tag| { + dwarf.unit.add(dwarf.unit.root(), tag) + }; + + let primtive = |dwarf: &mut DwarfUnit, ate| { + let type_id = new_entry(dwarf, gimli::DW_TAG_base_type); + let type_entry = dwarf.unit.get_mut(type_id); + type_entry.set(gimli::DW_AT_encoding, AttributeValue::Encoding(ate)); + type_id + }; + + let type_id = match ty.kind { + ty::Bool => primtive(&mut self.dwarf, gimli::DW_ATE_boolean), + ty::Char => primtive(&mut self.dwarf, gimli::DW_ATE_UTF), + ty::Uint(_) => primtive(&mut self.dwarf, gimli::DW_ATE_unsigned), + ty::Int(_) => primtive(&mut self.dwarf, gimli::DW_ATE_signed), + ty::Float(_) => primtive(&mut self.dwarf, gimli::DW_ATE_float), + ty::Ref(_, pointee_ty, mutbl) | ty::RawPtr(ty::TypeAndMut { ty: pointee_ty, mutbl }) => { + let type_id = new_entry(&mut self.dwarf, gimli::DW_TAG_pointer_type); + + // Ensure that type is inserted before recursing to avoid duplicates + self.types.insert(ty, type_id); + + let pointee = self.dwarf_ty(pointee_ty); + + let type_entry = self.dwarf.unit.get_mut(type_id); + + //type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc::hir::Mutability::MutMutable)); + type_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(pointee)); + + type_id + } + _ => new_entry(&mut self.dwarf, gimli::DW_TAG_structure_type), + }; + let name = format!("{}", ty); + let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + + let type_entry = self.dwarf.unit.get_mut(type_id); + + type_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); + type_entry.set(gimli::DW_AT_byte_size, AttributeValue::Udata(layout.size.bytes())); + + self.types.insert(ty, type_id); + + type_id + } + pub fn emit(&mut self, product: &mut P) { let unit_range_list_id = self.dwarf.unit.ranges.add(self.unit_range_list.clone()); let root = self.dwarf.unit.root(); @@ -205,13 +261,13 @@ pub struct FunctionDebugContext<'a, 'tcx> { entry_id: UnitEntryId, symbol: usize, mir_span: Span, + local_decls: rustc_index::vec::IndexVec>, } impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub fn new( - tcx: TyCtxt<'tcx>, debug_context: &'a mut DebugContext<'tcx>, - mir: &Body, + mir: &'tcx Body, func_id: FuncId, name: &str, _sig: &Signature, @@ -237,13 +293,14 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { AttributeValue::Address(Address::Symbol { symbol, addend: 0 }), ); - debug_context.emit_location(tcx, entry_id, mir.span); + debug_context.emit_location(entry_id, mir.span); FunctionDebugContext { debug_context, entry_id, symbol, mir_span: mir.span, + local_decls: mir.local_decls.clone(), } } @@ -329,6 +386,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { ); let live_ranges_id = self.debug_context.dwarf.unit.ranges.add(live_ranges); + let local_type = self.debug_context.dwarf_ty(self.local_decls[mir::Local::from_u32(value_label.as_u32())].ty); + let var_id = self .debug_context .dwarf @@ -344,6 +403,10 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { gimli::DW_AT_name, AttributeValue::String(format!("{:?}", value_label).into_bytes()), ); + var_entry.set( + gimli::DW_AT_type, + AttributeValue::ThisUnitEntryRef(local_type), + ); } } From 21f0dfd014fc5996b6f88b9565656f63b2f65c99 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Nov 2019 20:49:20 +0100 Subject: [PATCH 0964/1566] Monomorphize locals --- src/base.rs | 4 ++-- src/debuginfo.rs | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/base.rs b/src/base.rs index bb0ffb51bcec1..ed587bf739d5b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -17,7 +17,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut debug_context = cx .debug_context .as_mut() - .map(|debug_context| FunctionDebugContext::new(debug_context, mir, func_id, &name, &sig)); + .map(|debug_context| FunctionDebugContext::new(debug_context, instance, func_id, &name, &sig)); // Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); @@ -92,7 +92,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let isa = cx.module.isa(); debug_context .as_mut() - .map(|x| x.define(tcx, context, isa, &source_info_set)); + .map(|x| x.define(context, isa, &source_info_set)); // Clear context to make it usable for the next function context.clear(); diff --git a/src/debuginfo.rs b/src/debuginfo.rs index b3de6449ff4b4..8de7ab673849d 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -260,18 +260,20 @@ pub struct FunctionDebugContext<'a, 'tcx> { debug_context: &'a mut DebugContext<'tcx>, entry_id: UnitEntryId, symbol: usize, - mir_span: Span, - local_decls: rustc_index::vec::IndexVec>, + instance: Instance<'tcx>, + mir: &'tcx mir::Body<'tcx>, } impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub fn new( debug_context: &'a mut DebugContext<'tcx>, - mir: &'tcx Body, + instance: Instance<'tcx>, func_id: FuncId, name: &str, _sig: &Signature, ) -> Self { + let mir = debug_context.tcx.instance_mir(instance.def); + let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string()); // FIXME: add to appropriate scope intead of root @@ -299,18 +301,19 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { debug_context, entry_id, symbol, - mir_span: mir.span, - local_decls: mir.local_decls.clone(), + instance, + mir, } } pub fn define( &mut self, - tcx: TyCtxt, context: &Context, isa: &dyn cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, ) { + let tcx = self.debug_context.tcx; + let line_program = &mut self.debug_context.dwarf.unit.line_program; line_program.begin_sequence(Some(Address::Symbol { @@ -351,7 +354,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); create_row_for_span(line_program, source_info.0); } else { - create_row_for_span(line_program, self.mir_span); + create_row_for_span(line_program, self.mir.span); } end = offset + size; } @@ -386,7 +389,12 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { ); let live_ranges_id = self.debug_context.dwarf.unit.ranges.add(live_ranges); - let local_type = self.debug_context.dwarf_ty(self.local_decls[mir::Local::from_u32(value_label.as_u32())].ty); + let local_ty = tcx.subst_and_normalize_erasing_regions( + self.instance.substs, + ty::ParamEnv::reveal_all(), + &self.mir.local_decls[mir::Local::from_u32(value_label.as_u32())].ty, + ); + let local_type = self.debug_context.dwarf_ty(local_ty); let var_id = self .debug_context From 3fed8800575297814370e4a16ff7edbf7746dba6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 11 Nov 2019 21:43:57 +0100 Subject: [PATCH 0965/1566] [WIP] Set local DW_AT_location --- src/debuginfo.rs | 128 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 122 insertions(+), 6 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 8de7ab673849d..7530c7c21e1ec 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -6,11 +6,15 @@ use std::marker::PhantomData; use syntax::source_map::FileName; +use cranelift::codegen::ir::{StackSlots, ValueLoc}; +use cranelift::codegen::isa::RegUnit; + use gimli::write::{ - Address, AttributeValue, DwarfUnit, EndianVec, FileId, LineProgram, LineString, - LineStringTable, Range, RangeList, Result, Sections, UnitEntryId, Writer, + self, Address, AttributeValue, DwarfUnit, EndianVec, Expression, FileId, LineProgram, + LineString, LineStringTable, Location, LocationList, Range, RangeList, Result, Sections, + UnitEntryId, Writer, }; -use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, SectionId}; +use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, SectionId, X86_64}; fn target_endian(tcx: TyCtxt) -> RunTimeEndian { use rustc::ty::layout::Endian; @@ -380,9 +384,9 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { .chain( value_loc_ranges .iter() - .map(|val_loc_range| Range::OffsetPair { - begin: u64::from(val_loc_range.start), - end: u64::from(val_loc_range.end), + .map(|value_loc_range| Range::OffsetPair { + begin: u64::from(value_loc_range.start), + end: u64::from(value_loc_range.end), }), ) .collect(), @@ -415,6 +419,34 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(local_type), ); + + + let loc_list = LocationList( + Some(Location::BaseAddress { + address: Address::Symbol { + symbol: self.symbol, + addend: 0, + }, + }) + .into_iter() + .chain( + value_loc_ranges + .iter() + .map(|value_loc_range| Location::OffsetPair { + begin: u64::from(value_loc_range.start), + end: u64::from(value_loc_range.end), + data: Expression(translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap()), + }), + ) + .collect(), + ); + let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list); + + let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); + var_entry.set( + gimli::DW_AT_location, + AttributeValue::LocationListRef(loc_list_id), + ); } } @@ -510,3 +542,87 @@ impl Writer for WriterRelocate { self.write_udata_at(offset, 0, size) } } + + + + + + +// Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137 + +fn map_reg(reg: RegUnit) -> Register { + static mut REG_X86_MAP: Option> = None; + // FIXME lazy initialization? + unsafe { + if REG_X86_MAP.is_none() { + REG_X86_MAP = Some(HashMap::new()); + } + if let Some(val) = REG_X86_MAP.as_mut().unwrap().get(®) { + return *val; + } + let result = match reg { + 0 => X86_64::RAX, + 1 => X86_64::RCX, + 2 => X86_64::RDX, + 3 => X86_64::RBX, + 4 => X86_64::RSP, + 5 => X86_64::RBP, + 6 => X86_64::RSI, + 7 => X86_64::RDI, + 8 => X86_64::R8, + 9 => X86_64::R9, + 10 => X86_64::R10, + 11 => X86_64::R11, + 12 => X86_64::R12, + 13 => X86_64::R13, + 14 => X86_64::R14, + 15 => X86_64::R15, + 16 => X86_64::XMM0, + 17 => X86_64::XMM1, + 18 => X86_64::XMM2, + 19 => X86_64::XMM3, + 20 => X86_64::XMM4, + 21 => X86_64::XMM5, + 22 => X86_64::XMM6, + 23 => X86_64::XMM7, + 24 => X86_64::XMM8, + 25 => X86_64::XMM9, + 26 => X86_64::XMM10, + 27 => X86_64::XMM11, + 28 => X86_64::XMM12, + 29 => X86_64::XMM13, + 30 => X86_64::XMM14, + 31 => X86_64::XMM15, + _ => panic!("unknown x86_64 register {}", reg), + }; + REG_X86_MAP.as_mut().unwrap().insert(reg, result); + result + } +} + +fn translate_loc(loc: ValueLoc, stack_slots: &StackSlots) -> Option> { + match loc { + ValueLoc::Reg(reg) => { + let machine_reg = map_reg(reg).0 as u8; + assert!(machine_reg <= 32); // FIXME + Some(vec![gimli::constants::DW_OP_reg0.0 + machine_reg]) + } + ValueLoc::Stack(ss) => { + if let Some(ss_offset) = stack_slots[ss].offset { + let endian = gimli::RunTimeEndian::Little; + let mut writer = write::EndianVec::new(endian); + writer + .write_u8(gimli::constants::DW_OP_breg0.0 + X86_64::RBP.0 as u8) + .expect("bp wr"); + writer.write_sleb128(ss_offset as i64 + 16).expect("ss wr"); + writer + .write_u8(gimli::constants::DW_OP_deref.0 as u8) + .expect("bp wr"); + let buf = writer.into_vec(); + return Some(buf); + } + None + } + _ => None, + } +} From 50f7110cb69458fa996ed88f17e1210ff0fc24f3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 20:31:53 +0100 Subject: [PATCH 0966/1566] Fix local value reading LLDB doesn't understand base address entries --- src/debuginfo.rs | 56 +++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 7530c7c21e1ec..d671715790a65 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -373,26 +373,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); for (value_label, value_loc_ranges) in value_labels_ranges.iter() { - let live_ranges = RangeList( - Some(Range::BaseAddress { - address: Address::Symbol { - symbol: self.symbol, - addend: 0, - }, - }) - .into_iter() - .chain( - value_loc_ranges - .iter() - .map(|value_loc_range| Range::OffsetPair { - begin: u64::from(value_loc_range.start), - end: u64::from(value_loc_range.end), - }), - ) - .collect(), - ); - let live_ranges_id = self.debug_context.dwarf.unit.ranges.add(live_ranges); - let local_ty = tcx.subst_and_normalize_erasing_regions( self.instance.substs, ty::ParamEnv::reveal_all(), @@ -407,10 +387,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { .add(self.entry_id, gimli::DW_TAG_variable); let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); - var_entry.set( - gimli::DW_AT_ranges, - AttributeValue::RangeListRef(live_ranges_id), - ); var_entry.set( gimli::DW_AT_name, AttributeValue::String(format!("{:?}", value_label).into_bytes()), @@ -420,25 +396,23 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { AttributeValue::ThisUnitEntryRef(local_type), ); - let loc_list = LocationList( - Some(Location::BaseAddress { - address: Address::Symbol { - symbol: self.symbol, - addend: 0, - }, - }) - .into_iter() - .chain( - value_loc_ranges - .iter() - .map(|value_loc_range| Location::OffsetPair { - begin: u64::from(value_loc_range.start), - end: u64::from(value_loc_range.end), + value_loc_ranges + .iter() + .map(|value_loc_range| { + Location::StartEnd { + begin: Address::Symbol { + symbol: self.symbol, + addend: i64::from(value_loc_range.start), + }, + end: Address::Symbol { + symbol: self.symbol, + addend: i64::from(value_loc_range.end), + }, data: Expression(translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap()), - }), - ) - .collect(), + } + }) + .collect(), ); let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list); From 62c3ca28e1e7d69541a3884e57ec33df7836c936 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 20:43:34 +0100 Subject: [PATCH 0967/1566] Extract local definition from FunctionDebugContext::define --- src/debuginfo.rs | 60 +++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index d671715790a65..63a95e7e0e72b 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -2,8 +2,6 @@ use crate::prelude::*; use crate::backend::WriteDebugInfo; -use std::marker::PhantomData; - use syntax::source_map::FileName; use cranelift::codegen::ir::{StackSlots, ValueLoc}; @@ -310,6 +308,41 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { } } + fn define_local(&mut self, local: mir::Local) -> UnitEntryId { + let local_decl = &self.mir.local_decls[local]; + + let ty = self.debug_context.tcx.subst_and_normalize_erasing_regions( + self.instance.substs, + ty::ParamEnv::reveal_all(), + &local_decl.ty, + ); + let dw_ty = self.debug_context.dwarf_ty(ty); + + let name = if let Some(name) = local_decl.name { + format!("{}{:?}", name.as_str(), local) + } else { + format!("{:?}", local) + }; + + let var_id = self + .debug_context + .dwarf + .unit + .add(self.entry_id, gimli::DW_TAG_variable); + let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); + + var_entry.set( + gimli::DW_AT_name, + AttributeValue::String(name.into_bytes()), + ); + var_entry.set( + gimli::DW_AT_type, + AttributeValue::ThisUnitEntryRef(dw_ty), + ); + + var_id + } + pub fn define( &mut self, context: &Context, @@ -373,28 +406,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); for (value_label, value_loc_ranges) in value_labels_ranges.iter() { - let local_ty = tcx.subst_and_normalize_erasing_regions( - self.instance.substs, - ty::ParamEnv::reveal_all(), - &self.mir.local_decls[mir::Local::from_u32(value_label.as_u32())].ty, - ); - let local_type = self.debug_context.dwarf_ty(local_ty); - - let var_id = self - .debug_context - .dwarf - .unit - .add(self.entry_id, gimli::DW_TAG_variable); - let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); - - var_entry.set( - gimli::DW_AT_name, - AttributeValue::String(format!("{:?}", value_label).into_bytes()), - ); - var_entry.set( - gimli::DW_AT_type, - AttributeValue::ThisUnitEntryRef(local_type), - ); + let var_id = self.define_local(mir::Local::from_u32(value_label.as_u32())); let loc_list = LocationList( value_loc_ranges From d07fe816af78de1578e9f915012b6485c2928f38 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 20:44:20 +0100 Subject: [PATCH 0968/1566] Move debuginfo.rs to debuginfo/mod.rs --- src/{debuginfo.rs => debuginfo/mod.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{debuginfo.rs => debuginfo/mod.rs} (100%) diff --git a/src/debuginfo.rs b/src/debuginfo/mod.rs similarity index 100% rename from src/debuginfo.rs rename to src/debuginfo/mod.rs From ed758912d31c159c26768a4603db55372f948b82 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 20:52:32 +0100 Subject: [PATCH 0969/1566] Split debuginfo/emit.rs part out of debuginfo/mod.rs --- src/debuginfo/emit.rs | 135 +++++++++++++++++++++++++++++++++++++++++ src/debuginfo/mod.rs | 137 +++--------------------------------------- 2 files changed, 142 insertions(+), 130 deletions(-) create mode 100644 src/debuginfo/emit.rs diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs new file mode 100644 index 0000000000000..2b6dc9f669f30 --- /dev/null +++ b/src/debuginfo/emit.rs @@ -0,0 +1,135 @@ +use std::collections::HashMap; + +use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer}; +use gimli::{RunTimeEndian, SectionId}; + +use crate::backend::WriteDebugInfo; + +use super::DebugContext; + +impl DebugContext<'_> { + pub fn emit(&mut self, product: &mut P) { + let unit_range_list_id = self.dwarf.unit.ranges.add(self.unit_range_list.clone()); + let root = self.dwarf.unit.root(); + let root = self.dwarf.unit.get_mut(root); + root.set( + gimli::DW_AT_ranges, + AttributeValue::RangeListRef(unit_range_list_id), + ); + + let mut sections = Sections::new(WriterRelocate::new(self)); + self.dwarf.write(&mut sections).unwrap(); + + let mut section_map = HashMap::new(); + let _: Result<()> = sections.for_each_mut(|id, section| { + if !section.writer.slice().is_empty() { + let section_id = product.add_debug_section(id, section.writer.take()); + section_map.insert(id, section_id); + } + Ok(()) + }); + + let _: Result<()> = sections.for_each(|id, section| { + if let Some(section_id) = section_map.get(&id) { + for reloc in §ion.relocs { + product.add_debug_reloc(§ion_map, &self.symbols, section_id, reloc); + } + } + Ok(()) + }); + } +} + +#[derive(Clone)] +pub struct DebugReloc { + pub offset: u32, + pub size: u8, + pub name: DebugRelocName, + pub addend: i64, +} + +#[derive(Clone)] +pub enum DebugRelocName { + Section(SectionId), + Symbol(usize), +} + +#[derive(Clone)] +struct WriterRelocate { + relocs: Vec, + writer: EndianVec, +} + +impl WriterRelocate { + fn new(ctx: &DebugContext) -> Self { + WriterRelocate { + relocs: Vec::new(), + writer: EndianVec::new(ctx.endian), + } + } +} + +impl Writer for WriterRelocate { + type Endian = RunTimeEndian; + + fn endian(&self) -> Self::Endian { + self.writer.endian() + } + + fn len(&self) -> usize { + self.writer.len() + } + + fn write(&mut self, bytes: &[u8]) -> Result<()> { + self.writer.write(bytes) + } + + fn write_at(&mut self, offset: usize, bytes: &[u8]) -> Result<()> { + self.writer.write_at(offset, bytes) + } + + fn write_address(&mut self, address: Address, size: u8) -> Result<()> { + match address { + Address::Constant(val) => self.write_udata(val, size), + Address::Symbol { symbol, addend } => { + let offset = self.len() as u64; + self.relocs.push(DebugReloc { + offset: offset as u32, + size, + name: DebugRelocName::Symbol(symbol), + addend: addend as i64, + }); + self.write_udata(0, size) + } + } + } + + // TODO: implement write_eh_pointer + + fn write_offset(&mut self, val: usize, section: SectionId, size: u8) -> Result<()> { + let offset = self.len() as u32; + self.relocs.push(DebugReloc { + offset, + size, + name: DebugRelocName::Section(section), + addend: val as i64, + }); + self.write_udata(0, size) + } + + fn write_offset_at( + &mut self, + offset: usize, + val: usize, + section: SectionId, + size: u8, + ) -> Result<()> { + self.relocs.push(DebugReloc { + offset: offset as u32, + size, + name: DebugRelocName::Section(section), + addend: val as i64, + }); + self.write_udata_at(offset, 0, size) + } +} diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 63a95e7e0e72b..3ab03a411c8b4 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,6 +1,6 @@ -use crate::prelude::*; +mod emit; -use crate::backend::WriteDebugInfo; +use crate::prelude::*; use syntax::source_map::FileName; @@ -8,11 +8,12 @@ use cranelift::codegen::ir::{StackSlots, ValueLoc}; use cranelift::codegen::isa::RegUnit; use gimli::write::{ - self, Address, AttributeValue, DwarfUnit, EndianVec, Expression, FileId, LineProgram, - LineString, LineStringTable, Location, LocationList, Range, RangeList, Result, Sections, - UnitEntryId, Writer, + self, Address, AttributeValue, DwarfUnit, Expression, FileId, LineProgram, LineString, + LineStringTable, Location, LocationList, Range, RangeList, UnitEntryId, Writer, }; -use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, SectionId, X86_64}; +use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, X86_64}; + +pub use emit::{DebugReloc, DebugRelocName}; fn target_endian(tcx: TyCtxt) -> RunTimeEndian { use rustc::ty::layout::Endian; @@ -57,20 +58,6 @@ fn line_program_add_file( } } -#[derive(Clone)] -pub struct DebugReloc { - pub offset: u32, - pub size: u8, - pub name: DebugRelocName, - pub addend: i64, -} - -#[derive(Clone)] -pub enum DebugRelocName { - Section(SectionId), - Symbol(usize), -} - pub struct DebugContext<'tcx> { tcx: TyCtxt<'tcx>, @@ -225,37 +212,6 @@ impl<'tcx> DebugContext<'tcx> { type_id } - - pub fn emit(&mut self, product: &mut P) { - let unit_range_list_id = self.dwarf.unit.ranges.add(self.unit_range_list.clone()); - let root = self.dwarf.unit.root(); - let root = self.dwarf.unit.get_mut(root); - root.set( - gimli::DW_AT_ranges, - AttributeValue::RangeListRef(unit_range_list_id), - ); - - let mut sections = Sections::new(WriterRelocate::new(self)); - self.dwarf.write(&mut sections).unwrap(); - - let mut section_map = HashMap::new(); - let _: Result<()> = sections.for_each_mut(|id, section| { - if !section.writer.slice().is_empty() { - let section_id = product.add_debug_section(id, section.writer.take()); - section_map.insert(id, section_id); - } - Ok(()) - }); - - let _: Result<()> = sections.for_each(|id, section| { - if let Some(section_id) = section_map.get(&id) { - for reloc in §ion.relocs { - product.add_debug_reloc(§ion_map, &self.symbols, section_id, reloc); - } - } - Ok(()) - }); - } } pub struct FunctionDebugContext<'a, 'tcx> { @@ -449,85 +405,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { } } -#[derive(Clone)] -struct WriterRelocate { - relocs: Vec, - writer: EndianVec, -} - -impl WriterRelocate { - fn new(ctx: &DebugContext) -> Self { - WriterRelocate { - relocs: Vec::new(), - writer: EndianVec::new(ctx.endian), - } - } -} - -impl Writer for WriterRelocate { - type Endian = RunTimeEndian; - - fn endian(&self) -> Self::Endian { - self.writer.endian() - } - - fn len(&self) -> usize { - self.writer.len() - } - - fn write(&mut self, bytes: &[u8]) -> Result<()> { - self.writer.write(bytes) - } - - fn write_at(&mut self, offset: usize, bytes: &[u8]) -> Result<()> { - self.writer.write_at(offset, bytes) - } - - fn write_address(&mut self, address: Address, size: u8) -> Result<()> { - match address { - Address::Constant(val) => self.write_udata(val, size), - Address::Symbol { symbol, addend } => { - let offset = self.len() as u64; - self.relocs.push(DebugReloc { - offset: offset as u32, - size, - name: DebugRelocName::Symbol(symbol), - addend: addend as i64, - }); - self.write_udata(0, size) - } - } - } - - // TODO: implement write_eh_pointer - - fn write_offset(&mut self, val: usize, section: SectionId, size: u8) -> Result<()> { - let offset = self.len() as u32; - self.relocs.push(DebugReloc { - offset, - size, - name: DebugRelocName::Section(section), - addend: val as i64, - }); - self.write_udata(0, size) - } - - fn write_offset_at( - &mut self, - offset: usize, - val: usize, - section: SectionId, - size: u8, - ) -> Result<()> { - self.relocs.push(DebugReloc { - offset: offset as u32, - size, - name: DebugRelocName::Section(section), - addend: val as i64, - }); - self.write_udata_at(offset, 0, size) - } -} From beda7870fb0f813e69e7803c612f865079625235 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 21:08:08 +0100 Subject: [PATCH 0970/1566] Split debuginfo/line_info.rs from debuginfo/mod.rs --- src/debuginfo/line_info.rs | 149 +++++++++++++++++++++++++++++++++++++ src/debuginfo/mod.rs | 138 +--------------------------------- 2 files changed, 153 insertions(+), 134 deletions(-) create mode 100644 src/debuginfo/line_info.rs diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs new file mode 100644 index 0000000000000..dc380c623f6a1 --- /dev/null +++ b/src/debuginfo/line_info.rs @@ -0,0 +1,149 @@ +use crate::prelude::*; + +use syntax::source_map::FileName; + +use gimli::write::{ + Address, AttributeValue, FileId, LineProgram, LineString, + LineStringTable, Range, UnitEntryId, +}; + +fn line_program_add_file( + line_program: &mut LineProgram, + line_strings: &mut LineStringTable, + file: &FileName, +) -> FileId { + match file { + FileName::Real(path) => { + let dir_name = path.parent().unwrap().to_str().unwrap().as_bytes(); + let dir_id = if !dir_name.is_empty() { + let dir_name = LineString::new(dir_name, line_program.encoding(), line_strings); + line_program.add_directory(dir_name) + } else { + line_program.default_directory() + }; + let file_name = LineString::new( + path.file_name().unwrap().to_str().unwrap().as_bytes(), + line_program.encoding(), + line_strings, + ); + line_program.add_file(file_name, dir_id, None) + } + // FIXME give more appropriate file names + _ => { + let dir_id = line_program.default_directory(); + let dummy_file_name = LineString::new( + file.to_string().into_bytes(), + line_program.encoding(), + line_strings, + ); + line_program.add_file(dummy_file_name, dir_id, None) + } + } +} + +impl<'tcx> DebugContext<'tcx> { + pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { + let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo()); + + let file_id = line_program_add_file( + &mut self.dwarf.unit.line_program, + &mut self.dwarf.line_strings, + &loc.file.name, + ); + + let entry = self.dwarf.unit.get_mut(entry_id); + + entry.set( + gimli::DW_AT_decl_file, + AttributeValue::FileIndex(Some(file_id)), + ); + entry.set( + gimli::DW_AT_decl_line, + AttributeValue::Udata(loc.line as u64), + ); + // FIXME: probably omit this + entry.set( + gimli::DW_AT_decl_column, + AttributeValue::Udata(loc.col.to_usize() as u64), + ); + } +} + +impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { + pub(crate) fn create_debug_lines( + &mut self, + context: &Context, + isa: &dyn cranelift::codegen::isa::TargetIsa, + source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, + ) { + let tcx = self.debug_context.tcx; + + let line_program = &mut self.debug_context.dwarf.unit.line_program; + + line_program.begin_sequence(Some(Address::Symbol { + symbol: self.symbol, + addend: 0, + })); + + let encinfo = isa.encoding_info(); + let func = &context.func; + let mut ebbs = func.layout.ebbs().collect::>(); + ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase + + let line_strings = &mut self.debug_context.dwarf.line_strings; + let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { + let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); + + /*println!( + "srcloc {:>04X} {}:{}:{}", + line_program.row().address_offset, + file.display(), + loc.line, + loc.col.to_u32() + );*/ + + line_program.row().file = file_id; + line_program.row().line = loc.line as u64; + line_program.row().column = loc.col.to_u32() as u64 + 1; + line_program.generate_row(); + }; + + let mut end = 0; + for ebb in ebbs { + for (offset, inst, size) in func.inst_offsets(ebb, &encinfo) { + let srcloc = func.srclocs[inst]; + line_program.row().address_offset = offset as u64; + if !srcloc.is_default() { + let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); + create_row_for_span(line_program, source_info.0); + } else { + create_row_for_span(line_program, self.mir.span); + } + end = offset + size; + } + } + + line_program.end_sequence(end as u64); + + let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); + entry.set( + gimli::DW_AT_low_pc, + AttributeValue::Address(Address::Symbol { symbol: self.symbol, addend: 0 }), + ); + entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64)); + + self.debug_context.emit_location(self.entry_id, self.mir.span); + + self.debug_context + .unit_range_list + .0 + .push(Range::StartLength { + begin: Address::Symbol { + symbol: self.symbol, + addend: 0, + }, + length: end as u64, + }); + } +} diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 3ab03a411c8b4..f710f90e7f45a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,15 +1,14 @@ mod emit; +mod line_info; use crate::prelude::*; -use syntax::source_map::FileName; - use cranelift::codegen::ir::{StackSlots, ValueLoc}; use cranelift::codegen::isa::RegUnit; use gimli::write::{ - self, Address, AttributeValue, DwarfUnit, Expression, FileId, LineProgram, LineString, - LineStringTable, Location, LocationList, Range, RangeList, UnitEntryId, Writer, + self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, + Location, LocationList, RangeList, UnitEntryId, Writer, }; use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, X86_64}; @@ -24,40 +23,6 @@ fn target_endian(tcx: TyCtxt) -> RunTimeEndian { } } -fn line_program_add_file( - line_program: &mut LineProgram, - line_strings: &mut LineStringTable, - file: &FileName, -) -> FileId { - match file { - FileName::Real(path) => { - let dir_name = path.parent().unwrap().to_str().unwrap().as_bytes(); - let dir_id = if !dir_name.is_empty() { - let dir_name = LineString::new(dir_name, line_program.encoding(), line_strings); - line_program.add_directory(dir_name) - } else { - line_program.default_directory() - }; - let file_name = LineString::new( - path.file_name().unwrap().to_str().unwrap().as_bytes(), - line_program.encoding(), - line_strings, - ); - line_program.add_file(file_name, dir_id, None) - } - // FIXME give more appropriate file names - _ => { - let dir_id = line_program.default_directory(); - let dummy_file_name = LineString::new( - file.to_string().into_bytes(), - line_program.encoding(), - line_strings, - ); - line_program.add_file(dummy_file_name, dir_id, None) - } - } -} - pub struct DebugContext<'tcx> { tcx: TyCtxt<'tcx>, @@ -135,32 +100,6 @@ impl<'tcx> DebugContext<'tcx> { } } - fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { - let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo()); - - let file_id = line_program_add_file( - &mut self.dwarf.unit.line_program, - &mut self.dwarf.line_strings, - &loc.file.name, - ); - - let entry = self.dwarf.unit.get_mut(entry_id); - - entry.set( - gimli::DW_AT_decl_file, - AttributeValue::FileIndex(Some(file_id)), - ); - entry.set( - gimli::DW_AT_decl_line, - AttributeValue::Udata(loc.line as u64), - ); - // FIXME: probably omit this - entry.set( - gimli::DW_AT_decl_column, - AttributeValue::Udata(loc.col.to_usize() as u64), - ); - } - fn dwarf_ty(&mut self, ty: Ty<'tcx>) -> UnitEntryId { if let Some(type_id) = self.types.get(ty) { return *type_id; @@ -248,13 +187,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { AttributeValue::StringRef(name_id), ); - entry.set( - gimli::DW_AT_low_pc, - AttributeValue::Address(Address::Symbol { symbol, addend: 0 }), - ); - - debug_context.emit_location(entry_id, mir.span); - FunctionDebugContext { debug_context, entry_id, @@ -305,58 +237,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { isa: &dyn cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, ) { - let tcx = self.debug_context.tcx; - - let line_program = &mut self.debug_context.dwarf.unit.line_program; - - line_program.begin_sequence(Some(Address::Symbol { - symbol: self.symbol, - addend: 0, - })); - - let encinfo = isa.encoding_info(); - let func = &context.func; - let mut ebbs = func.layout.ebbs().collect::>(); - ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase - - let line_strings = &mut self.debug_context.dwarf.line_strings; - let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { - let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); - let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); - - /*println!( - "srcloc {:>04X} {}:{}:{}", - line_program.row().address_offset, - file.display(), - loc.line, - loc.col.to_u32() - );*/ - - line_program.row().file = file_id; - line_program.row().line = loc.line as u64; - line_program.row().column = loc.col.to_u32() as u64 + 1; - line_program.generate_row(); - }; - - let mut end = 0; - for ebb in ebbs { - for (offset, inst, size) in func.inst_offsets(ebb, &encinfo) { - let srcloc = func.srclocs[inst]; - line_program.row().address_offset = offset as u64; - if !srcloc.is_default() { - let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); - create_row_for_span(line_program, source_info.0); - } else { - create_row_for_span(line_program, self.mir.span); - } - end = offset + size; - } - } - - line_program.end_sequence(end as u64); - - let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64)); + self.create_debug_lines(context, isa, source_info_set); { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); @@ -391,17 +272,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { ); } } - - self.debug_context - .unit_range_list - .0 - .push(Range::StartLength { - begin: Address::Symbol { - symbol: self.symbol, - addend: 0, - }, - length: end as u64, - }); } } From c5c6ce87d239c0599c87e73481983b9ec6680cb1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 21:10:51 +0100 Subject: [PATCH 0971/1566] Small change --- src/debuginfo/line_info.rs | 15 ++++----------- src/debuginfo/mod.rs | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index dc380c623f6a1..8eef761465b12 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -2,6 +2,8 @@ use crate::prelude::*; use syntax::source_map::FileName; +use cranelift::codegen::binemit::CodeOffset; + use gimli::write::{ Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, Range, UnitEntryId, @@ -75,7 +77,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { context: &Context, isa: &dyn cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, - ) { + ) -> CodeOffset { let tcx = self.debug_context.tcx; let line_program = &mut self.debug_context.dwarf.unit.line_program; @@ -135,15 +137,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { self.debug_context.emit_location(self.entry_id, self.mir.span); - self.debug_context - .unit_range_list - .0 - .push(Range::StartLength { - begin: Address::Symbol { - symbol: self.symbol, - addend: 0, - }, - length: end as u64, - }); + end } } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index f710f90e7f45a..c62dad9c357df 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -8,7 +8,7 @@ use cranelift::codegen::isa::RegUnit; use gimli::write::{ self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, - Location, LocationList, RangeList, UnitEntryId, Writer, + Location, LocationList, Range, RangeList, UnitEntryId, Writer, }; use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, X86_64}; @@ -237,7 +237,18 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { isa: &dyn cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, ) { - self.create_debug_lines(context, isa, source_info_set); + let end = self.create_debug_lines(context, isa, source_info_set); + + self.debug_context + .unit_range_list + .0 + .push(Range::StartLength { + begin: Address::Symbol { + symbol: self.symbol, + addend: 0, + }, + length: end as u64, + }); { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); From d8e9148c2e07be8c2d65d87d84a88e9fd5a63c39 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 21:13:15 +0100 Subject: [PATCH 0972/1566] Rustfmt debuginfo --- src/debuginfo/line_info.rs | 11 +++-- src/debuginfo/mod.rs | 91 ++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 8eef761465b12..174cf0b93fe4f 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -5,8 +5,7 @@ use syntax::source_map::FileName; use cranelift::codegen::binemit::CodeOffset; use gimli::write::{ - Address, AttributeValue, FileId, LineProgram, LineString, - LineStringTable, Range, UnitEntryId, + Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, Range, UnitEntryId, }; fn line_program_add_file( @@ -131,11 +130,15 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); entry.set( gimli::DW_AT_low_pc, - AttributeValue::Address(Address::Symbol { symbol: self.symbol, addend: 0 }), + AttributeValue::Address(Address::Symbol { + symbol: self.symbol, + addend: 0, + }), ); entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64)); - self.debug_context.emit_location(self.entry_id, self.mir.span); + self.debug_context + .emit_location(self.entry_id, self.mir.span); end } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index c62dad9c357df..e8b3cbe36eb4d 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -7,8 +7,8 @@ use cranelift::codegen::ir::{StackSlots, ValueLoc}; use cranelift::codegen::isa::RegUnit; use gimli::write::{ - self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, - Location, LocationList, Range, RangeList, UnitEntryId, Writer, + self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, + LocationList, Range, RangeList, UnitEntryId, Writer, }; use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, X86_64}; @@ -105,9 +105,7 @@ impl<'tcx> DebugContext<'tcx> { return *type_id; } - let new_entry = |dwarf: &mut DwarfUnit, tag| { - dwarf.unit.add(dwarf.unit.root(), tag) - }; + let new_entry = |dwarf: &mut DwarfUnit, tag| dwarf.unit.add(dwarf.unit.root(), tag); let primtive = |dwarf: &mut DwarfUnit, ate| { let type_id = new_entry(dwarf, gimli::DW_TAG_base_type); @@ -122,7 +120,11 @@ impl<'tcx> DebugContext<'tcx> { ty::Uint(_) => primtive(&mut self.dwarf, gimli::DW_ATE_unsigned), ty::Int(_) => primtive(&mut self.dwarf, gimli::DW_ATE_signed), ty::Float(_) => primtive(&mut self.dwarf, gimli::DW_ATE_float), - ty::Ref(_, pointee_ty, mutbl) | ty::RawPtr(ty::TypeAndMut { ty: pointee_ty, mutbl }) => { + ty::Ref(_, pointee_ty, mutbl) + | ty::RawPtr(ty::TypeAndMut { + ty: pointee_ty, + mutbl, + }) => { let type_id = new_entry(&mut self.dwarf, gimli::DW_TAG_pointer_type); // Ensure that type is inserted before recursing to avoid duplicates @@ -145,7 +147,10 @@ impl<'tcx> DebugContext<'tcx> { let type_entry = self.dwarf.unit.get_mut(type_id); type_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); - type_entry.set(gimli::DW_AT_byte_size, AttributeValue::Udata(layout.size.bytes())); + type_entry.set( + gimli::DW_AT_byte_size, + AttributeValue::Udata(layout.size.bytes()), + ); self.types.insert(ty, type_id); @@ -219,14 +224,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { .add(self.entry_id, gimli::DW_TAG_variable); let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); - var_entry.set( - gimli::DW_AT_name, - AttributeValue::String(name.into_bytes()), - ); - var_entry.set( - gimli::DW_AT_type, - AttributeValue::ThisUnitEntryRef(dw_ty), - ); + var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); + var_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(dw_ty)); var_id } @@ -250,38 +249,36 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { length: end as u64, }); - { - let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); - - for (value_label, value_loc_ranges) in value_labels_ranges.iter() { - let var_id = self.define_local(mir::Local::from_u32(value_label.as_u32())); - - let loc_list = LocationList( - value_loc_ranges - .iter() - .map(|value_loc_range| { - Location::StartEnd { - begin: Address::Symbol { - symbol: self.symbol, - addend: i64::from(value_loc_range.start), - }, - end: Address::Symbol { - symbol: self.symbol, - addend: i64::from(value_loc_range.end), - }, - data: Expression(translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap()), - } - }) - .collect(), - ); - let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list); - - let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); - var_entry.set( - gimli::DW_AT_location, - AttributeValue::LocationListRef(loc_list_id), - ); - } + let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); + + for (value_label, value_loc_ranges) in value_labels_ranges.iter() { + let var_id = self.define_local(mir::Local::from_u32(value_label.as_u32())); + + let loc_list = LocationList( + value_loc_ranges + .iter() + .map(|value_loc_range| Location::StartEnd { + begin: Address::Symbol { + symbol: self.symbol, + addend: i64::from(value_loc_range.start), + }, + end: Address::Symbol { + symbol: self.symbol, + addend: i64::from(value_loc_range.end), + }, + data: Expression( + translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(), + ), + }) + .collect(), + ); + let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list); + + let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); + var_entry.set( + gimli::DW_AT_location, + AttributeValue::LocationListRef(loc_list_id), + ); } } } From 8edbbc45f7d2ec2d61a9a7a5d9b4d968810cbce6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 12 Nov 2019 21:36:31 +0100 Subject: [PATCH 0973/1566] Implement local reading for locals on stack --- src/base.rs | 5 +-- src/debuginfo/line_info.rs | 2 +- src/debuginfo/mod.rs | 73 ++++++++++++++++++++++++-------------- 3 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/base.rs b/src/base.rs index ed587bf739d5b..441d875ef21d4 100644 --- a/src/base.rs +++ b/src/base.rs @@ -17,7 +17,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut debug_context = cx .debug_context .as_mut() - .map(|debug_context| FunctionDebugContext::new(debug_context, instance, func_id, &name, &sig)); + .map(|debug_context| FunctionDebugContext::new(debug_context, instance, func_id, &name)); // Make FunctionBuilder let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); @@ -61,6 +61,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let instance = fx.instance; let clif_comments = fx.clif_comments; let source_info_set = fx.source_info_set; + let local_map = fx.local_map; #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &func, &clif_comments, None); @@ -92,7 +93,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let isa = cx.module.isa(); debug_context .as_mut() - .map(|x| x.define(context, isa, &source_info_set)); + .map(|x| x.define(context, isa, &source_info_set, local_map)); // Clear context to make it usable for the next function context.clear(); diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 174cf0b93fe4f..e64344bfe6f23 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -5,7 +5,7 @@ use syntax::source_map::FileName; use cranelift::codegen::binemit::CodeOffset; use gimli::write::{ - Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, Range, UnitEntryId, + Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, UnitEntryId, }; fn line_program_add_file( diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index e8b3cbe36eb4d..1c1e5762bfaa3 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -172,7 +172,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { instance: Instance<'tcx>, func_id: FuncId, name: &str, - _sig: &Signature, ) -> Self { let mir = debug_context.tcx.instance_mir(instance.def); @@ -235,6 +234,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { context: &Context, isa: &dyn cranelift::codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, + local_map: HashMap>, ) { let end = self.create_debug_lines(context, isa, source_info_set); @@ -251,34 +251,53 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); - for (value_label, value_loc_ranges) in value_labels_ranges.iter() { - let var_id = self.define_local(mir::Local::from_u32(value_label.as_u32())); - - let loc_list = LocationList( - value_loc_ranges - .iter() - .map(|value_loc_range| Location::StartEnd { - begin: Address::Symbol { - symbol: self.symbol, - addend: i64::from(value_loc_range.start), - }, - end: Address::Symbol { - symbol: self.symbol, - addend: i64::from(value_loc_range.end), - }, - data: Expression( - translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(), - ), - }) - .collect(), - ); - let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list); + for (local, _local_decl) in self.mir.local_decls.iter_enumerated() { + let var_id = self.define_local(local); + let value_label = cranelift::codegen::ir::ValueLabel::from_u32(local.as_u32()); + + let location = match local_map[&local].inner() { + CPlaceInner::Var(_) => { + if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { + let loc_list = LocationList( + value_loc_ranges + .iter() + .map(|value_loc_range| Location::StartEnd { + begin: Address::Symbol { + symbol: self.symbol, + addend: i64::from(value_loc_range.start), + }, + end: Address::Symbol { + symbol: self.symbol, + addend: i64::from(value_loc_range.end), + }, + data: Expression( + translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(), + ), + }) + .collect(), + ); + let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list); + + AttributeValue::LocationListRef(loc_list_id) + } else { + // FIXME set value labels for unused locals + + AttributeValue::Exprloc(Expression(vec![])) + } + } + CPlaceInner::Addr(_, _) => { + // FIXME implement this (used by arguments and returns) + + AttributeValue::Exprloc(Expression(vec![])) + } + CPlaceInner::Stack(stack_slot) => { + AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())) + } + CPlaceInner::NoPlace => AttributeValue::Exprloc(Expression(vec![])), + }; let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); - var_entry.set( - gimli::DW_AT_location, - AttributeValue::LocationListRef(loc_list_id), - ); + var_entry.set(gimli::DW_AT_location, location); } } } From 4826320680e2b5545f1920f2a6209fbffc9b0547 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 12:06:52 +0100 Subject: [PATCH 0974/1566] Add debuginfo test --- test.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 05ba16ea31cb0..cae3955e5d134 100755 --- a/test.sh +++ b/test.sh @@ -31,11 +31,16 @@ $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib -JIT_ARGS="abc bcd" jit mini_core_hello_world example/mini_core_hello_world.rs +#JIT_ARGS="abc bcd" jit mini_core_hello_world example/mini_core_hello_world.rs echo "[AOT] mini_core_hello_world" -$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin +$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g ./target/out/mini_core_hello_world abc bcd +if lldb -v; then +(echo "break set -n main"; echo "run"; sleep 1; echo "si -c 21"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd +fi + +exit 1 echo "[AOT] arbitrary_self_types_pointers_and_wrappers" $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin From 0244d19ebbc286940cb454769394637b50d9c73b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 15 Nov 2019 21:07:18 +0100 Subject: [PATCH 0975/1566] Fix translate_loc for ValueLoc::Stack --- src/debuginfo/mod.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 1c1e5762bfaa3..59c5c9ac12c6a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -375,9 +375,6 @@ fn translate_loc(loc: ValueLoc, stack_slots: &StackSlots) -> Option> { .write_u8(gimli::constants::DW_OP_breg0.0 + X86_64::RBP.0 as u8) .expect("bp wr"); writer.write_sleb128(ss_offset as i64 + 16).expect("ss wr"); - writer - .write_u8(gimli::constants::DW_OP_deref.0 as u8) - .expect("bp wr"); let buf = writer.into_vec(); return Some(buf); } From ab7ad2caebff43356df1b2060021945dfc6ced4e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 15 Nov 2019 21:07:54 +0100 Subject: [PATCH 0976/1566] Use set_val_label before every def_var --- src/intrinsics.rs | 2 ++ src/value_and_place.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 4ad6ae91f928e..840b4bf0db29e 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -625,6 +625,7 @@ pub fn codegen_intrinsic_call<'tcx>( } _ => panic!("clif_type returned {}", clif_ty), }; + fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), val); } _ => { @@ -656,6 +657,7 @@ pub fn codegen_intrinsic_call<'tcx>( } _ => panic!("clif_type returned {}", clif_ty), }; + fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), val); } CPlaceInner::Addr(_, _) | CPlaceInner::Stack(_) => { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 8016a802dab30..64fd30def0687 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -423,6 +423,7 @@ impl<'tcx> CPlace<'tcx> { let addr = match self.inner { CPlaceInner::Var(var) => { let data = from.load_scalar(fx); + fx.bcx.set_val_label(data, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), data); return; } From 08217d1bdeaa9de9d72f718036ca5ac93e4a5c4e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 15 Nov 2019 21:32:52 +0100 Subject: [PATCH 0977/1566] Emit DW_TAG_structure_type including fields for structs --- src/debuginfo/mod.rs | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 59c5c9ac12c6a..c636906afdf28 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -107,19 +107,22 @@ impl<'tcx> DebugContext<'tcx> { let new_entry = |dwarf: &mut DwarfUnit, tag| dwarf.unit.add(dwarf.unit.root(), tag); - let primtive = |dwarf: &mut DwarfUnit, ate| { + let primitive = |dwarf: &mut DwarfUnit, ate| { let type_id = new_entry(dwarf, gimli::DW_TAG_base_type); let type_entry = dwarf.unit.get_mut(type_id); type_entry.set(gimli::DW_AT_encoding, AttributeValue::Encoding(ate)); type_id }; + let name = format!("{}", ty); + let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + let type_id = match ty.kind { - ty::Bool => primtive(&mut self.dwarf, gimli::DW_ATE_boolean), - ty::Char => primtive(&mut self.dwarf, gimli::DW_ATE_UTF), - ty::Uint(_) => primtive(&mut self.dwarf, gimli::DW_ATE_unsigned), - ty::Int(_) => primtive(&mut self.dwarf, gimli::DW_ATE_signed), - ty::Float(_) => primtive(&mut self.dwarf, gimli::DW_ATE_float), + ty::Bool => primitive(&mut self.dwarf, gimli::DW_ATE_boolean), + ty::Char => primitive(&mut self.dwarf, gimli::DW_ATE_UTF), + ty::Uint(_) => primitive(&mut self.dwarf, gimli::DW_ATE_unsigned), + ty::Int(_) => primitive(&mut self.dwarf, gimli::DW_ATE_signed), + ty::Float(_) => primitive(&mut self.dwarf, gimli::DW_ATE_float), ty::Ref(_, pointee_ty, mutbl) | ty::RawPtr(ty::TypeAndMut { ty: pointee_ty, @@ -139,10 +142,35 @@ impl<'tcx> DebugContext<'tcx> { type_id } + ty::Adt(adt_def, _substs) if adt_def.is_struct() && !layout.is_unsized() => { + let type_id = new_entry(&mut self.dwarf, gimli::DW_TAG_structure_type); + + // Ensure that type is inserted before recursing to avoid duplicates + self.types.insert(ty, type_id); + + let variant = adt_def.non_enum_variant(); + + for (field_idx, field_def) in variant.fields.iter().enumerate() { + let field_offset = layout.fields.offset(field_idx); + let field_layout = layout.field(&layout::LayoutCx { + tcx: self.tcx, + param_env: ParamEnv::reveal_all(), + }, field_idx).unwrap(); + + let field_type = self.dwarf_ty(field_layout.ty); + + let field_id = self.dwarf.unit.add(type_id, gimli::DW_TAG_member); + let field_entry = self.dwarf.unit.get_mut(field_id); + + field_entry.set(gimli::DW_AT_name, AttributeValue::String(field_def.ident.as_str().to_string().into_bytes())); + field_entry.set(gimli::DW_AT_data_member_location, AttributeValue::Udata(field_offset.bytes())); + field_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(field_type)); + } + + type_id + } _ => new_entry(&mut self.dwarf, gimli::DW_TAG_structure_type), }; - let name = format!("{}", ty); - let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); let type_entry = self.dwarf.unit.get_mut(type_id); From c84ff8504a6a6ba630abc7f67dad2552f1984006 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 15 Nov 2019 21:58:47 +0100 Subject: [PATCH 0978/1566] Change test script --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index cae3955e5d134..7c7803af0b86f 100755 --- a/test.sh +++ b/test.sh @@ -37,7 +37,7 @@ echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g ./target/out/mini_core_hello_world abc bcd if lldb -v; then -(echo "break set -n main"; echo "run"; sleep 1; echo "si -c 21"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd +(echo "break set -n main"; echo "run"; sleep 1; echo "si -c 35"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd fi exit 1 From b86eb2e8ba3f442a2168406fc75e1f41cdc9ccc7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Nov 2019 20:34:55 +0100 Subject: [PATCH 0979/1566] Some optimizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Only format global _comments when debug_assertions are enabled * Only call build_value_labels_ranges in base.rs when debug_assertions are enabled Benchmark #1: CHANNEL='pre' ../cargo.sh build Time (mean ± σ): 17.657 s ± 1.050 s [User: 31.871 s, System: 3.014 s] Range (min … max): 16.907 s … 20.394 s 10 runs Benchmark #2: ../cargo.sh build Time (mean ± σ): 16.640 s ± 0.255 s [User: 30.238 s, System: 2.965 s] Range (min … max): 16.413 s … 17.186 s 10 runs Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options. Summary '../cargo.sh build' ran 1.06 ± 0.07 times faster than 'CHANNEL='pre' ../cargo.sh build' --- src/base.rs | 26 ++++++++++++++------------ src/pretty_clif.rs | 12 +++++++++--- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/base.rs b/src/base.rs index 441d875ef21d4..243852f1d2bef 100644 --- a/src/base.rs +++ b/src/base.rs @@ -74,20 +74,22 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( context.func = func; cx.module.define_function(func_id, context).unwrap(); - let value_ranges = context - .build_value_labels_ranges(cx.module.isa()) - .expect("value location ranges"); - // Write optimized function to file for debugging #[cfg(debug_assertions)] - crate::pretty_clif::write_clif_file( - cx.tcx, - "opt", - instance, - &context.func, - &clif_comments, - Some(&value_ranges), - ); + { + let value_ranges = context + .build_value_labels_ranges(cx.module.isa()) + .expect("value location ranges"); + + crate::pretty_clif::write_clif_file( + cx.tcx, + "opt", + instance, + &context.func, + &clif_comments, + Some(&value_ranges), + ); + } // Define debuginfo for function let isa = cx.module.isa(); diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index f595d384f4f2c..64359f3899f53 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -74,8 +74,8 @@ pub struct CommentWriter { impl CommentWriter { pub fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self { - CommentWriter { - global_comments: vec![ + let mut global_comments = if cfg!(debug_assertions) { + vec![ format!("symbol {}", tcx.symbol_name(instance).name.as_str()), format!("instance {:?}", instance), format!( @@ -86,7 +86,13 @@ impl CommentWriter { ) ), String::new(), - ], + ] + } else { + vec![] + }; + + CommentWriter { + global_comments, entity_comments: HashMap::new(), inst_comments: HashMap::new(), } From 7a4fe12d31a72d956a63f69bf945f7e9e5898e52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 28 Nov 2019 21:35:03 +0100 Subject: [PATCH 0980/1566] Rustup to rustc 1.41.0-nightly (e87a205c2 2019-11-27) --- src/debuginfo/mod.rs | 126 ++++++++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 54 deletions(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index c636906afdf28..50cae4d46e2ca 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -3,8 +3,9 @@ mod line_info; use crate::prelude::*; -use cranelift::codegen::ir::{StackSlots, ValueLoc}; +use cranelift::codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift::codegen::isa::RegUnit; +use cranelift::codegen::ValueLocRange; use gimli::write::{ self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, @@ -228,22 +229,14 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { } } - fn define_local(&mut self, local: mir::Local) -> UnitEntryId { - let local_decl = &self.mir.local_decls[local]; - + fn define_local(&mut self, name: String, ty: Ty<'tcx>) -> UnitEntryId { let ty = self.debug_context.tcx.subst_and_normalize_erasing_regions( self.instance.substs, ty::ParamEnv::reveal_all(), - &local_decl.ty, + &ty, ); let dw_ty = self.debug_context.dwarf_ty(ty); - let name = if let Some(name) = local_decl.name { - format!("{}{:?}", name.as_str(), local) - } else { - format!("{:?}", local) - }; - let var_id = self .debug_context .dwarf @@ -280,57 +273,82 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); for (local, _local_decl) in self.mir.local_decls.iter_enumerated() { - let var_id = self.define_local(local); - let value_label = cranelift::codegen::ir::ValueLabel::from_u32(local.as_u32()); - - let location = match local_map[&local].inner() { - CPlaceInner::Var(_) => { - if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { - let loc_list = LocationList( - value_loc_ranges - .iter() - .map(|value_loc_range| Location::StartEnd { - begin: Address::Symbol { - symbol: self.symbol, - addend: i64::from(value_loc_range.start), - }, - end: Address::Symbol { - symbol: self.symbol, - addend: i64::from(value_loc_range.end), - }, - data: Expression( - translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(), - ), - }) - .collect(), - ); - let loc_list_id = self.debug_context.dwarf.unit.locations.add(loc_list); - - AttributeValue::LocationListRef(loc_list_id) - } else { - // FIXME set value labels for unused locals - - AttributeValue::Exprloc(Expression(vec![])) - } - } - CPlaceInner::Addr(_, _) => { - // FIXME implement this (used by arguments and returns) - - AttributeValue::Exprloc(Expression(vec![])) - } - CPlaceInner::Stack(stack_slot) => { - AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())) - } - CPlaceInner::NoPlace => AttributeValue::Exprloc(Expression(vec![])), - }; + let var_id = self.define_local(format!("{:?}", local), &self.mir.local_decls[local].ty); + + let location = place_location( + self, + context, + &local_map, + &value_labels_ranges, + Place { + base: PlaceBase::Local(local), + projection: ty::List::empty(), + }, + ); let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); var_entry.set(gimli::DW_AT_location, location); } + + // FIXME create locals for all entries in mir.var_debug_info } } +fn place_location<'a, 'tcx>( + func_debug_ctx: &mut FunctionDebugContext<'a, 'tcx>, + context: &Context, + local_map: &HashMap>, + value_labels_ranges: &HashMap>, + place: Place<'tcx>, +) -> AttributeValue { + assert!(place.projection.is_empty()); // FIXME implement them + let cplace = match place.base { + PlaceBase::Local(local) => local_map[&local], + PlaceBase::Static(_) => bug!("Unenforced invariant that the place is based on a Local violated: {:?}", place), + }; + + match cplace.inner() { + CPlaceInner::Var(local) => { + let value_label = cranelift::codegen::ir::ValueLabel::from_u32(local.as_u32()); + if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { + let loc_list = LocationList( + value_loc_ranges + .iter() + .map(|value_loc_range| Location::StartEnd { + begin: Address::Symbol { + symbol: func_debug_ctx.symbol, + addend: i64::from(value_loc_range.start), + }, + end: Address::Symbol { + symbol: func_debug_ctx.symbol, + addend: i64::from(value_loc_range.end), + }, + data: Expression( + translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(), + ), + }) + .collect(), + ); + let loc_list_id = func_debug_ctx.debug_context.dwarf.unit.locations.add(loc_list); + + AttributeValue::LocationListRef(loc_list_id) + } else { + // FIXME set value labels for unused locals + + AttributeValue::Exprloc(Expression(vec![])) + } + } + CPlaceInner::Addr(_, _) => { + // FIXME implement this (used by arguments and returns) + AttributeValue::Exprloc(Expression(vec![])) + } + CPlaceInner::Stack(stack_slot) => { + AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())) + } + CPlaceInner::NoPlace => AttributeValue::Exprloc(Expression(vec![])), + } +} From 74ca55d23091565444ce64fe4c8dbd6fc0783f56 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 12:11:14 +0100 Subject: [PATCH 0981/1566] Rustup --- src/debuginfo/mod.rs | 2 +- test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 50cae4d46e2ca..9e04566a20854 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -202,7 +202,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { func_id: FuncId, name: &str, ) -> Self { - let mir = debug_context.tcx.instance_mir(instance.def); + let mir = *debug_context.tcx.instance_mir(instance.def); let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string()); diff --git a/test.sh b/test.sh index 7c7803af0b86f..4f393ad179720 100755 --- a/test.sh +++ b/test.sh @@ -37,7 +37,7 @@ echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g ./target/out/mini_core_hello_world abc bcd if lldb -v; then -(echo "break set -n main"; echo "run"; sleep 1; echo "si -c 35"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd +(echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd fi exit 1 From beda104a2b828616ce5691577bf0d8750c641ce0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 12:12:51 +0100 Subject: [PATCH 0982/1566] Disable local debuginfo for now --- src/debuginfo/mod.rs | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 9e04566a20854..bb3f26f9fee9d 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -270,24 +270,27 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { length: end as u64, }); - let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); - - for (local, _local_decl) in self.mir.local_decls.iter_enumerated() { - let var_id = self.define_local(format!("{:?}", local), &self.mir.local_decls[local].ty); - - let location = place_location( - self, - context, - &local_map, - &value_labels_ranges, - Place { - base: PlaceBase::Local(local), - projection: ty::List::empty(), - }, - ); + // FIXME make it more reliable and implement scopes before re-enabling this. + if false { + let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); + + for (local, _local_decl) in self.mir.local_decls.iter_enumerated() { + let var_id = self.define_local(format!("{:?}", local), &self.mir.local_decls[local].ty); + + let location = place_location( + self, + context, + &local_map, + &value_labels_ranges, + Place { + base: PlaceBase::Local(local), + projection: ty::List::empty(), + }, + ); - let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); - var_entry.set(gimli::DW_AT_location, location); + let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); + var_entry.set(gimli::DW_AT_location, location); + } } // FIXME create locals for all entries in mir.var_debug_info From 3e50a831e59ee56d63fe72f350759e4ba6099bf8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 13:23:41 +0100 Subject: [PATCH 0983/1566] Optimize line_program_add_file --- src/debuginfo/line_info.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index e64344bfe6f23..e21b0b026c891 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -1,3 +1,6 @@ +use std::ffi::OsStr; +use std::path::{Component, Path}; + use crate::prelude::*; use syntax::source_map::FileName; @@ -8,6 +11,30 @@ use gimli::write::{ Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, UnitEntryId, }; +// OPTIMIZATION: It is cheaper to do this in one pass than using `.parent()` and `.file_name()`. +fn split_path_dir_and_file(path: &Path) -> (&Path, &OsStr) { + let mut iter = path.components(); + let file_name = match iter.next_back() { + Some(Component::Normal(p)) => p, + component => { + panic!("Path component {:?} of path {} is an invalid filename", component, path.display()); + } + }; + let parent = iter.as_path(); + (parent, file_name) +} + +// OPTIMIZATION: Avoid UTF-8 validation on UNIX. +fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] { + #[cfg(unix)] { + use std::os::unix::ffi::OsStrExt; + return path.as_bytes(); + } + #[cfg(not(unix))] { + return path.to_str().unwrap().as_bytes(); + } +} + fn line_program_add_file( line_program: &mut LineProgram, line_strings: &mut LineStringTable, @@ -15,7 +42,10 @@ fn line_program_add_file( ) -> FileId { match file { FileName::Real(path) => { - let dir_name = path.parent().unwrap().to_str().unwrap().as_bytes(); + let (dir_path, file_name) = split_path_dir_and_file(path); + let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str()); + let file_name = osstr_as_utf8_bytes(file_name); + let dir_id = if !dir_name.is_empty() { let dir_name = LineString::new(dir_name, line_program.encoding(), line_strings); line_program.add_directory(dir_name) @@ -23,7 +53,7 @@ fn line_program_add_file( line_program.default_directory() }; let file_name = LineString::new( - path.file_name().unwrap().to_str().unwrap().as_bytes(), + file_name, line_program.encoding(), line_strings, ); From 856079bcaa2303fe941c44d6787139e8929bd871 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 16 Dec 2019 21:47:13 +0100 Subject: [PATCH 0984/1566] Fix testing when lldb is not installed --- test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index 4f393ad179720..79655b60b4f96 100755 --- a/test.sh +++ b/test.sh @@ -36,9 +36,9 @@ $RUSTC example/example.rs --crate-type lib echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g ./target/out/mini_core_hello_world abc bcd -if lldb -v; then -(echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd -fi +lldb -v && \ + (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") \ + | lldb -- ./target/out/mini_core_hello_world abc bcd exit 1 From ad1f885002cade0044cdb6fff9de21e0a910c584 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Dec 2019 13:23:28 +0100 Subject: [PATCH 0985/1566] [OPT] Don't call .to_string() on MonoItem's --- src/driver.rs | 2 +- src/unimpl.rs | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 22271460b02ba..0166f9ea5bae5 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -307,7 +307,7 @@ fn codegen_mono_items<'tcx>( } for (mono_item, (linkage, visibility)) in mono_items { - crate::unimpl::try_unimpl(tcx, mono_item.to_string(tcx, true), || { + crate::unimpl::try_unimpl(tcx, || { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); trans_mono_item(&mut cx, mono_item, linkage); }); diff --git a/src/unimpl.rs b/src/unimpl.rs index 3e7dddc6445dc..b668235e75e82 100644 --- a/src/unimpl.rs +++ b/src/unimpl.rs @@ -1,14 +1,8 @@ //! The unimpl! macro is defined here. It is used to generate //! a non-fatal error on not yet implemented things. -use std::cell::RefCell; - use rustc::ty::TyCtxt; -thread_local! { - static CURRENT_MSG: RefCell = RefCell::new(String::new()); -} - // Just public, because of the unimpl macro #[doc(hidden)] pub struct NonFatal(pub String); @@ -20,21 +14,15 @@ pub macro unimpl($($tt:tt)*) { panic!(NonFatal(format!($($tt)*))); } -pub fn try_unimpl(tcx: TyCtxt, msg: String, f: impl FnOnce()) { - CURRENT_MSG.with(|current_msg| { - let old = std::mem::replace(&mut *current_msg.borrow_mut(), msg); +pub fn try_unimpl(tcx: TyCtxt, f: impl FnOnce()) { + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); - - if let Err(err) = res { - match err.downcast::() { - Ok(non_fatal) => { - tcx.sess.err(&format!("at {}: {}", current_msg.borrow(), non_fatal.0)); - } - Err(err) => ::std::panic::resume_unwind(err), + if let Err(err) = res { + match err.downcast::() { + Ok(non_fatal) => { + tcx.sess.err(&non_fatal.0); } + Err(err) => ::std::panic::resume_unwind(err), } - - *current_msg.borrow_mut() = old; - }); + } } From d502f8e65223ac63fd1e617a6e69028a9fa6ce22 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Dec 2019 15:03:32 +0100 Subject: [PATCH 0986/1566] [OPT] Avoid calling target_triple for every call to codegen --- src/abi/mod.rs | 25 +++++++++++++------------ src/allocator.rs | 2 +- src/base.rs | 2 +- src/common.rs | 4 ++++ src/driver.rs | 5 +++-- src/intrinsics.rs | 2 +- src/lib.rs | 4 ---- src/main_shim.rs | 5 +++-- src/trap.rs | 2 +- 9 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 31e667095fa65..416ed3ebe49a0 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -75,6 +75,7 @@ pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> t fn clif_sig_from_fn_sig<'tcx>( tcx: TyCtxt<'tcx>, + triple: &target_lexicon::Triple, sig: FnSig<'tcx>, is_vtable_fn: bool, ) -> Signature { @@ -89,8 +90,8 @@ fn clif_sig_from_fn_sig<'tcx>( abi => abi, }; let (call_conv, inputs, output): (CallConv, Vec, Ty) = match abi { - Abi::Rust => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()), - Abi::C => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()), + Abi::Rust => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), + Abi::C => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().kind { @@ -99,10 +100,10 @@ fn clif_sig_from_fn_sig<'tcx>( }; let mut inputs: Vec = vec![sig.inputs()[0]]; inputs.extend(extra_args.types()); - (crate::default_call_conv(tcx.sess), inputs, sig.output()) + (CallConv::triple_default(triple), inputs, sig.output()) } Abi::System => unreachable!(), - Abi::RustIntrinsic => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()), + Abi::RustIntrinsic => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), _ => unimplemented!("unsupported abi {:?}", sig.abi), }; @@ -156,6 +157,7 @@ fn clif_sig_from_fn_sig<'tcx>( pub fn get_function_name_and_sig<'tcx>( tcx: TyCtxt<'tcx>, + triple: &target_lexicon::Triple, inst: Instance<'tcx>, support_vararg: bool, ) -> (String, Signature) { @@ -165,7 +167,7 @@ pub fn get_function_name_and_sig<'tcx>( if fn_sig.c_variadic && !support_vararg { unimpl!("Variadic function definitions are not yet supported"); } - let sig = clif_sig_from_fn_sig(tcx, fn_sig, false); + let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, false); (tcx.symbol_name(inst).name.as_str().to_string(), sig) } @@ -175,7 +177,7 @@ pub fn import_function<'tcx>( module: &mut Module, inst: Instance<'tcx>, ) -> FuncId { - let (name, sig) = get_function_name_and_sig(tcx, inst, true); + let (name, sig) = get_function_name_and_sig(tcx, module.isa().triple(), inst, true); module .declare_function(&name, Linkage::Import, &sig) .unwrap() @@ -205,7 +207,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let sig = Signature { params: input_tys.iter().cloned().map(AbiParam::new).collect(), returns: output_tys.iter().cloned().map(AbiParam::new).collect(), - call_conv: crate::default_call_conv(self.tcx.sess), + call_conv: CallConv::triple_default(self.triple()), }; let func_id = self .module @@ -579,8 +581,8 @@ fn codegen_call_inner<'tcx>( let call_inst = if let Some(func_ref) = func_ref { let sig = - fx.bcx - .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, is_virtual_call)); + clif_sig_from_fn_sig(fx.tcx, fx.triple(), fn_sig, is_virtual_call); + let sig = fx.bcx.import_signature(sig); fx.bcx.ins().call_indirect(sig, func_ref, &call_args) } else { let func_ref = @@ -632,9 +634,8 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); - let sig = fx - .bcx - .import_signature(clif_sig_from_fn_sig(fx.tcx, fn_sig, true)); + let sig = clif_sig_from_fn_sig(fx.tcx, fx.triple(), fn_sig, true); + let sig = fx.bcx.import_signature(sig); fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); } _ => { diff --git a/src/allocator.rs b/src/allocator.rs index 8031367b23bb2..df0f5d1543463 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -55,7 +55,7 @@ pub fn codegen_inner(sess: &Session, module: &mut Module }; let sig = Signature { - call_conv: crate::default_call_conv(sess), + call_conv: CallConv::triple_default(module.isa().triple()), params: arg_tys.iter().cloned().map(AbiParam::new).collect(), returns: output.into_iter().map(AbiParam::new).collect(), }; diff --git a/src/base.rs b/src/base.rs index 243852f1d2bef..16a90becd621c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -12,7 +12,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mir = *tcx.instance_mir(instance.def); // Declare function - let (name, sig) = get_function_name_and_sig(tcx, instance, false); + let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); let mut debug_context = cx .debug_context diff --git a/src/common.rs b/src/common.rs index f3b7fc925eeb8..455bc99ff22b2 100644 --- a/src/common.rs +++ b/src/common.rs @@ -364,4 +364,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { )); crate::constant::trans_const_value(self, const_loc) } + + pub fn triple(&self) -> &target_lexicon::Triple { + self.module.isa().triple() + } } diff --git a/src/driver.rs b/src/driver.rs index 0166f9ea5bae5..0a5916a552f5d 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -54,7 +54,7 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { returns: vec![AbiParam::new( jit_module.target_config().pointer_type(), /*isize*/ )], - call_conv: crate::default_call_conv(tcx.sess), + call_conv: CallConv::triple_default(&crate::target_triple(tcx.sess)), }; let main_func_id = jit_module .declare_function("main", Linkage::Import, &sig) @@ -298,7 +298,8 @@ fn codegen_mono_items<'tcx>( for (&mono_item, &(linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { - let (name, sig) = get_function_name_and_sig(tcx, instance, false); + let (name, sig) = + get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); cx.module.declare_function(&name, linkage, &sig).unwrap(); } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 840b4bf0db29e..e609abee1e808 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -1085,7 +1085,7 @@ pub fn codegen_intrinsic_call<'tcx>( try, (v f, v data, v _local_ptr) { // FIXME once unwinding is supported, change this to actually catch panics let f_sig = fx.bcx.func.import_signature(Signature { - call_conv: crate::default_call_conv(fx.tcx.sess), + call_conv: CallConv::triple_default(fx.triple()), params: vec![AbiParam::new(fx.bcx.func.dfg.value_type(data))], returns: vec![], }); diff --git a/src/lib.rs b/src/lib.rs index cc8216f0efae5..5b1b923968770 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -245,10 +245,6 @@ fn target_triple(sess: &Session) -> target_lexicon::Triple { sess.target.target.llvm_target.parse().unwrap() } -fn default_call_conv(sess: &Session) -> CallConv { - CallConv::triple_default(&target_triple(sess)) -} - fn build_isa(sess: &Session, enable_pic: bool) -> Box { let mut flags_builder = settings::builder(); if enable_pic { diff --git a/src/main_shim.rs b/src/main_shim.rs index 17783b01d26aa..8577845037dbc 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -41,7 +41,7 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module, module: &mut Module, ms "puts", Linkage::Import, &Signature { - call_conv: crate::default_call_conv(fx.tcx.sess), + call_conv: CallConv::triple_default(fx.triple()), params: vec![AbiParam::new(pointer_ty(fx.tcx))], returns: vec![], }, From f10514f01850fe96f70f7f0047092e14220452a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Dec 2019 16:37:57 +0100 Subject: [PATCH 0987/1566] Really fix CI --- test.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test.sh b/test.sh index 79655b60b4f96..0d770b74b4b3b 100755 --- a/test.sh +++ b/test.sh @@ -36,9 +36,7 @@ $RUSTC example/example.rs --crate-type lib echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g ./target/out/mini_core_hello_world abc bcd -lldb -v && \ - (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") \ - | lldb -- ./target/out/mini_core_hello_world abc bcd +# (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd exit 1 From d79965f0750d1ca99de12a9b71d349752282e651 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Dec 2019 16:55:29 +0100 Subject: [PATCH 0988/1566] Third try to fix CI --- test.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/test.sh b/test.sh index 0d770b74b4b3b..0d7fd71ff4ac6 100755 --- a/test.sh +++ b/test.sh @@ -38,8 +38,6 @@ $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --cra ./target/out/mini_core_hello_world abc bcd # (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd -exit 1 - echo "[AOT] arbitrary_self_types_pointers_and_wrappers" $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin ./target/out/arbitrary_self_types_pointers_and_wrappers From 172522c2e7f4e84b0e618241b8c14aa8a8b3c08d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Dec 2019 16:58:34 +0100 Subject: [PATCH 0989/1566] [OPT] Push fx.monomorphize to the callers of fx.layout_of This prevents some repeated monomorphizations --- src/abi/mod.rs | 4 ++-- src/base.rs | 31 +++++++++++++++---------------- src/common.rs | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 416ed3ebe49a0..329bdea79e8d3 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -353,7 +353,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: ArgKind::Normal(Some(val)) => { if let Some(addr) = val.try_to_addr() { let local_decl = &fx.mir.local_decls[local]; - // v this ! is important + // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( fx.tcx, ParamEnv::reveal_all(), @@ -398,7 +398,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: } for local in fx.mir.vars_and_temps_iter() { - let ty = fx.mir.local_decls[local].ty; + let ty = fx.monomorphize(&fx.mir.local_decls[local].ty); let layout = fx.layout_of(ty); let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa; diff --git a/src/base.rs b/src/base.rs index 16a90becd621c..00e5d965d9438 100644 --- a/src/base.rs +++ b/src/base.rs @@ -340,29 +340,27 @@ fn trans_stmt<'tcx>( }; lval.write_cvalue(fx, res); } - Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, ty) => { - let layout = fx.layout_of(ty); - match fx - .monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)) - .kind - { + Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, to_ty) => { + let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)); + let to_layout = fx.layout_of(fx.monomorphize(to_ty)); + match from_ty.kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap(), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); - lval.write_cvalue(fx, CValue::by_val(func_addr, layout)); + lval.write_cvalue(fx, CValue::by_val(func_addr, to_layout)); } - _ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", ty), + _ => bug!("Trying to ReifyFnPointer on non FnDef {:?}", from_ty), } } - Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), operand, ty) - | Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, ty) - | Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, ty) => { + Rvalue::Cast(CastKind::Pointer(PointerCast::UnsafeFnPointer), operand, to_ty) + | Rvalue::Cast(CastKind::Pointer(PointerCast::MutToConstPointer), operand, to_ty) + | Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, to_ty) => { + let to_layout = fx.layout_of(fx.monomorphize(to_ty)); let operand = trans_operand(fx, operand); - let layout = fx.layout_of(ty); - lval.write_cvalue(fx, operand.unchecked_cast_to(layout)); + lval.write_cvalue(fx, operand.unchecked_cast_to(to_layout)); } Rvalue::Cast(CastKind::Misc, operand, to_ty) => { let operand = trans_operand(fx, operand); @@ -420,7 +418,7 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, CValue::by_val(res, dest_layout)); } } - Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), operand, _ty) => { + Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), operand, _to_ty) => { let operand = trans_operand(fx, operand); match operand.layout().ty.kind { ty::Closure(def_id, substs) => { @@ -437,7 +435,7 @@ fn trans_stmt<'tcx>( _ => bug!("{} cannot be cast to a fn ptr", operand.layout().ty), } } - Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _ty) => { + Rvalue::Cast(CastKind::Pointer(PointerCast::Unsize), operand, _to_ty) => { let operand = trans_operand(fx, operand); operand.unsize_value(fx, lval); } @@ -466,6 +464,7 @@ fn trans_stmt<'tcx>( use rustc::middle::lang_items::ExchangeMallocFnLangItem; let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); + let content_ty = fx.monomorphize(content_ty); let layout = fx.layout_of(content_ty); let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64); let llalign = fx @@ -494,7 +493,7 @@ fn trans_stmt<'tcx>( .layout() .ty .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all())); - let ty_size = fx.layout_of(ty).size.bytes(); + let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size.into()); lval.write_cvalue(fx, val); } diff --git a/src/common.rs b/src/common.rs index 455bc99ff22b2..c3a8b708ab6e9 100644 --- a/src/common.rs +++ b/src/common.rs @@ -279,7 +279,7 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { type TyLayout = TyLayout<'tcx>; fn layout_of(&self, ty: Ty<'tcx>) -> TyLayout<'tcx> { - let ty = self.monomorphize(&ty); + assert!(!ty.needs_subst()); self.tcx .layout_of(ParamEnv::reveal_all().and(&ty)) .unwrap_or_else(|e| { From 86cdd1909b9727e0874233a3876a2228c3c4c6e1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Dec 2019 17:49:12 +0100 Subject: [PATCH 0990/1566] [OPT] Use IndexVec instead of HashMap in ssa analysis --- src/abi/mod.rs | 4 ++-- src/abi/returning.rs | 5 ++--- src/analyze.rs | 19 +++++++++---------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 329bdea79e8d3..44a1d25a31259 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -347,7 +347,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: for (local, arg_kind, ty) in func_params { let layout = fx.layout_of(ty); - let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa; + let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; match arg_kind { ArgKind::Normal(Some(val)) => { @@ -401,7 +401,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: let ty = fx.monomorphize(&fx.mir.local_decls[local].ty); let layout = fx.layout_of(ty); - let is_ssa = *ssa_analyzed.get(&local).unwrap() == crate::analyze::SsaKind::Ssa; + let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; local_place(fx, local, layout, is_ssa); } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 762327934065b..b2f39bef13c6a 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -3,7 +3,7 @@ use crate::prelude::*; pub fn codegen_return_param( fx: &mut FunctionCx, - ssa_analyzed: &HashMap, + ssa_analyzed: &rustc_index::vec::IndexVec, start_ebb: Ebb, ) { let ret_layout = fx.return_layout(); @@ -16,8 +16,7 @@ pub fn codegen_return_param( Empty } PassMode::ByVal(_) | PassMode::ByValPair(_, _) => { - let is_ssa = - *ssa_analyzed.get(&RETURN_PLACE).unwrap() == crate::analyze::SsaKind::Ssa; + let is_ssa = ssa_analyzed[RETURN_PLACE] == crate::analyze::SsaKind::Ssa; super::local_place(fx, RETURN_PLACE, ret_layout, is_ssa); diff --git a/src/analyze.rs b/src/analyze.rs index fe58eaa18bb87..4d7d637eaa8e5 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -1,6 +1,7 @@ use crate::prelude::*; use rustc::mir::StatementKind::*; +use rustc_index::vec::IndexVec; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum SsaKind { @@ -8,16 +9,14 @@ pub enum SsaKind { Ssa, } -pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap { - let mut flag_map = HashMap::new(); - - for (local, local_decl) in fx.mir.local_decls.iter_enumerated() { +pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { + let mut flag_map = fx.mir.local_decls.iter().map(|local_decl| { if fx.clif_type(local_decl.ty).is_some() { - flag_map.insert(local, SsaKind::Ssa); + SsaKind::Ssa } else { - flag_map.insert(local, SsaKind::NotSsa); + SsaKind::NotSsa } - } + }).collect::>(); for bb in fx.mir.basic_blocks().iter() { for stmt in bb.statements.iter() { @@ -44,13 +43,13 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap flag_map } -fn analyze_non_ssa_place(flag_map: &mut HashMap, place: &Place) { +fn analyze_non_ssa_place(flag_map: &mut IndexVec, place: &Place) { match place.base { PlaceBase::Local(local) => not_ssa(flag_map, local), _ => {} } } -fn not_ssa>(flag_map: &mut HashMap, local: L) { - *flag_map.get_mut(local.borrow()).unwrap() = SsaKind::NotSsa; +fn not_ssa(flag_map: &mut IndexVec, local: Local) { + flag_map[local] = SsaKind::NotSsa; } From 1c79cf4c0afe968c2af87a8a6803478cb66fe7a0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Dec 2019 18:41:13 +0100 Subject: [PATCH 0991/1566] [OPT] Use RETURN_PLACE instead of fn_sig.output() to get return layout --- src/abi/mod.rs | 11 ----------- src/abi/returning.rs | 12 +++++++----- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 44a1d25a31259..c33bb249f256c 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -260,17 +260,6 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { _ => unreachable!(), } } - - fn self_sig(&self) -> FnSig<'tcx> { - self.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - &fn_sig_for_fn_abi(self.tcx, self.instance), - ) - } - - fn return_layout(&self) -> TyLayout<'tcx> { - self.layout_of(self.self_sig().output()) - } } fn local_place<'tcx>( diff --git a/src/abi/returning.rs b/src/abi/returning.rs index b2f39bef13c6a..9286787d8b6d5 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -1,15 +1,17 @@ use crate::abi::pass_mode::*; use crate::prelude::*; +fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyLayout<'tcx> { + fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty)) +} + pub fn codegen_return_param( fx: &mut FunctionCx, ssa_analyzed: &rustc_index::vec::IndexVec, start_ebb: Ebb, ) { - let ret_layout = fx.return_layout(); - let output_pass_mode = get_pass_mode(fx.tcx, fx.return_layout()); - - let ret_param = match output_pass_mode { + let ret_layout = return_layout(fx); + let ret_param = match get_pass_mode(fx.tcx, ret_layout) { PassMode::NoPass => { fx.local_map .insert(RETURN_PLACE, CPlace::no_place(ret_layout)); @@ -85,7 +87,7 @@ pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>( } pub fn codegen_return(fx: &mut FunctionCx) { - match get_pass_mode(fx.tcx, fx.return_layout()) { + match get_pass_mode(fx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef => { fx.bcx.ins().return_(&[]); } From bfff2a50fdcf96a3a3f26a345833c083902460f1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Dec 2019 20:25:05 +0100 Subject: [PATCH 0992/1566] Fix debug build --- src/abi/returning.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 9286787d8b6d5..f80a5d3cb8449 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -11,7 +11,8 @@ pub fn codegen_return_param( start_ebb: Ebb, ) { let ret_layout = return_layout(fx); - let ret_param = match get_pass_mode(fx.tcx, ret_layout) { + let ret_pass_mode = get_pass_mode(fx.tcx, ret_layout); + let ret_param = match ret_pass_mode { PassMode::NoPass => { fx.local_map .insert(RETURN_PLACE, CPlace::no_place(ret_layout)); @@ -40,7 +41,7 @@ pub fn codegen_return_param( RETURN_PLACE, None, ret_param, - output_pass_mode, + ret_pass_mode, ret_layout.ty, ); } From 79ec8948d8b33c028647c6fe7df3426b8ff4987f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Dec 2019 20:26:41 +0100 Subject: [PATCH 0993/1566] Fix some warnings --- src/allocator.rs | 4 ++-- src/pretty_clif.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index df0f5d1543463..cfcb091afb5a2 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -21,14 +21,14 @@ pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> if any_dynamic_crate { false } else if let Some(kind) = tcx.allocator_kind() { - codegen_inner(tcx.sess, module, kind); + codegen_inner(module, kind); true } else { false } } -pub fn codegen_inner(sess: &Session, module: &mut Module, kind: AllocatorKind) { +pub fn codegen_inner(module: &mut Module, kind: AllocatorKind) { let usize_ty = module.target_config().pointer_type(); for method in ALLOCATOR_METHODS { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 64359f3899f53..97bb2e0caecb4 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -74,7 +74,7 @@ pub struct CommentWriter { impl CommentWriter { pub fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self { - let mut global_comments = if cfg!(debug_assertions) { + let global_comments = if cfg!(debug_assertions) { vec![ format!("symbol {}", tcx.symbol_name(instance).name.as_str()), format!("instance {:?}", instance), From 8d2db1b75d445263d63b002dd1df502e18cd3d65 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Dec 2019 20:41:07 +0100 Subject: [PATCH 0994/1566] Monomorphize type of promoted --- src/base.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 00e5d965d9438..68f9bc342b0a5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -616,11 +616,13 @@ pub fn trans_place<'tcx>( PlaceBase::Local(local) => fx.get_local_place(*local), PlaceBase::Static(static_) => match static_.kind { StaticKind::Static => { + // Statics can't be generic, so `static_.ty` doesn't need to be monomorphized. crate::constant::codegen_static_ref(fx, static_.def_id, static_.ty) } StaticKind::Promoted(promoted, substs) => { let instance = Instance::new(static_.def_id, fx.monomorphize(&substs)); - crate::constant::trans_promoted(fx, instance, promoted, static_.ty) + let ty = fx.monomorphize(&static_.ty); + crate::constant::trans_promoted(fx, instance, promoted, ty) } }, }; From a528e3730240c6da598fc71954314235fa6a11bb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 12:01:55 +0100 Subject: [PATCH 0995/1566] Fix codegen of ctlz and cttz intrinsics --- src/intrinsics.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index e609abee1e808..80049a2a55f10 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -681,7 +681,8 @@ pub fn codegen_intrinsic_call<'tcx>( let msb_lz = fx.bcx.ins().clz(msb); let msb_is_zero = fx.bcx.ins().icmp_imm(IntCC::Equal, msb, 0); let lsb_lz_plus_64 = fx.bcx.ins().iadd_imm(lsb_lz, 64); - fx.bcx.ins().select(msb_is_zero, lsb_lz_plus_64, msb_lz) + let res = fx.bcx.ins().select(msb_is_zero, lsb_lz_plus_64, msb_lz); + fx.bcx.ins().uextend(types::I128, res) } else { fx.bcx.ins().clz(arg) }; @@ -697,7 +698,8 @@ pub fn codegen_intrinsic_call<'tcx>( let msb_tz = fx.bcx.ins().ctz(msb); let lsb_is_zero = fx.bcx.ins().icmp_imm(IntCC::Equal, lsb, 0); let msb_tz_plus_64 = fx.bcx.ins().iadd_imm(msb_tz, 64); - fx.bcx.ins().select(lsb_is_zero, msb_tz_plus_64, lsb_tz) + let res = fx.bcx.ins().select(lsb_is_zero, msb_tz_plus_64, lsb_tz); + fx.bcx.ins().uextend(types::I128, res) } else { fx.bcx.ins().ctz(arg) }; From a125b6253610dc4e94bfd584eba869f45e749853 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 12:13:07 +0100 Subject: [PATCH 0996/1566] [OPT] Don't force return value of call to stack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Benchmark #1: ./simple_raytracer_before Time (mean ± σ): 14.420 s ± 0.568 s [User: 14.376 s, System: 0.026 s] Range (min … max): 13.730 s … 15.170 s 10 runs Benchmark #2: simple_raytracer_after Time (mean ± σ): 13.679 s ± 0.576 s [User: 13.628 s, System: 0.020 s] Range (min … max): 12.761 s … 14.552 s 10 runs Summary './simple_raytracer_after' ran 1.05 ± 0.06 times faster than './simple_raytracer_before' --- src/analyze.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index 4d7d637eaa8e5..d118665b92bb3 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -30,14 +30,6 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec {} } } - - match &bb.terminator().kind { - TerminatorKind::Call { - destination: Some((place, _)), - .. - } => analyze_non_ssa_place(&mut flag_map, place), - _ => {} - } } flag_map From 76cfa333beca458039740752a439bb96c4c20191 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 12:24:48 +0100 Subject: [PATCH 0997/1566] Fix init and uninit intrinsics for u/i128 --- src/intrinsics.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 80049a2a55f10..e05d32ffd7965 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -615,6 +615,10 @@ pub fn codegen_intrinsic_call<'tcx>( let clif_ty = fx.clif_type(layout.ty).unwrap(); let val = match clif_ty { types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 0), + types::I128 => { + let zero = fx.bcx.ins().iconst(types::I64, 0); + fx.bcx.ins().iconcat(zero, zero) + } types::F32 => { let zero = fx.bcx.ins().iconst(types::I32, 0); fx.bcx.ins().bitcast(types::F32, zero) @@ -647,6 +651,11 @@ pub fn codegen_intrinsic_call<'tcx>( let clif_ty = fx.clif_type(layout.ty).unwrap(); let val = match clif_ty { types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 42), + types::I128 => { + let zero = fx.bcx.ins().iconst(types::I64, 0); + let fourty_two = fx.bcx.ins().iconst(types::I64, 42); + fx.bcx.ins().iconcat(fourty_two, zero) + } types::F32 => { let zero = fx.bcx.ins().iconst(types::I32, 0xdeadbeef); fx.bcx.ins().bitcast(types::F32, zero) From 967709f31a025e402a68a6ab2744d0d5a51432ad Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 16:02:47 +0100 Subject: [PATCH 0998/1566] [OPT] Use load and store offsets instead of iadd_imm --- src/abi/comments.rs | 6 +- src/abi/mod.rs | 6 +- src/abi/pass_mode.rs | 2 +- src/abi/returning.rs | 2 +- src/base.rs | 18 ++--- src/constant.rs | 6 +- src/intrinsics.rs | 14 ++-- src/lib.rs | 2 + src/pointer.rs | 101 ++++++++++++++++++++++++++++ src/trap.rs | 6 +- src/value_and_place.rs | 146 ++++++++++++++++++++++------------------- test.sh | 4 +- 12 files changed, 210 insertions(+), 103 deletions(-) create mode 100644 src/pointer.rs diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 656731eb97cce..3fc5b2f0bc85b 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -94,14 +94,14 @@ pub fn add_local_place_comments<'tcx>( align.abi.bytes(), align.pref.bytes(), )), - CPlaceInner::Addr(addr, None) => fx.add_global_comment(format!( - "reuse {:5} {:20} {:4}b {}, {} storage={}", + CPlaceInner::Addr(ptr, None) => fx.add_global_comment(format!( + "reuse {:5} {:20} {:4}b {}, {} storage={:?}", format!("{:?}", local), format!("{:?}", ty), size.bytes(), align.abi.bytes(), align.pref.bytes(), - addr, + ptr, )), CPlaceInner::Addr(_, Some(_)) => unreachable!(), } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index c33bb249f256c..f11e343581c57 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -250,9 +250,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let ret_vals = self.lib_call(name, input_tys, return_tys, &args); match *ret_vals { [] => CValue::by_ref( - self.bcx - .ins() - .iconst(self.pointer_type, self.pointer_type.bytes() as i64), + Pointer::const_addr(self, self.pointer_type.bytes() as i64), return_layout, ), [val] => CValue::by_val(val, return_layout), @@ -352,7 +350,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: // We wont mutate this argument, so it is fine to borrow the backing storage // of this argument, to prevent a copy. - let place = CPlace::for_addr(addr, val.layout()); + let place = CPlace::for_ptr(Pointer::new(addr), val.layout()); #[cfg(debug_assertions)] self::comments::add_local_place_comments(fx, place, local); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 64d53566dcc1a..9c43f2c80af0f 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -158,6 +158,6 @@ pub fn cvalue_for_param<'tcx>( let (a, b) = ebb_params.assert_pair(); Some(CValue::by_val_pair(a, b, layout)) } - PassMode::ByRef => Some(CValue::by_ref(ebb_params.assert_single(), layout)), + PassMode::ByRef => Some(CValue::by_ref(Pointer::new(ebb_params.assert_single()), layout)), } } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index f80a5d3cb8449..489f52b306fb9 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -28,7 +28,7 @@ pub fn codegen_return_param( PassMode::ByRef => { let ret_param = fx.bcx.append_ebb_param(start_ebb, fx.pointer_type); fx.local_map - .insert(RETURN_PLACE, CPlace::for_addr(ret_param, ret_layout)); + .insert(RETURN_PLACE, CPlace::for_ptr(Pointer::new(ret_param), ret_layout)); Single(ret_param) } diff --git a/src/base.rs b/src/base.rs index 68f9bc342b0a5..db7ebd075350c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -601,7 +601,7 @@ fn codegen_array_len<'tcx>( fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place - .to_addr_maybe_unsized(fx) + .to_ptr_maybe_unsized(fx) .1 .expect("Length metadata for slice place"), _ => bug!("Rvalue::Len({:?})", place), @@ -659,25 +659,21 @@ pub fn trans_place<'tcx>( match cplace.layout().ty.kind { ty::Array(elem_ty, len) => { let elem_layout = fx.layout_of(elem_ty); - let ptr = cplace.to_addr(fx); + let ptr = cplace.to_ptr(fx); let len = crate::constant::force_eval_const(fx, len) .eval_usize(fx.tcx, ParamEnv::reveal_all()); - cplace = CPlace::for_addr( - fx.bcx - .ins() - .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + cplace = CPlace::for_ptr( + ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), ); } ty::Slice(elem_ty) => { assert!(from_end, "slice subslices should be `from_end`"); let elem_layout = fx.layout_of(elem_ty); - let (ptr, len) = cplace.to_addr_maybe_unsized(fx); + let (ptr, len) = cplace.to_ptr_maybe_unsized(fx); let len = len.unwrap(); - cplace = CPlace::for_addr_with_extra( - fx.bcx - .ins() - .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64), + cplace = CPlace::for_ptr_with_extra( + ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), cplace.layout(), ); diff --git a/src/constant.rs b/src/constant.rs index dade64b348a29..53e0941d7e9c1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -132,9 +132,7 @@ pub fn trans_const_value<'tcx>( CValue::by_val(val, layout) } ty::FnDef(_def_id, _substs) => CValue::by_ref( - fx.bcx - .ins() - .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), + crate::pointer::Pointer::const_addr(fx, fx.pointer_type.bytes() as i64), layout, ), _ => trans_const_place(fx, const_).to_cvalue(fx), @@ -265,7 +263,7 @@ fn cplace_for_dataid<'tcx>( let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); let layout = fx.layout_of(fx.monomorphize(&ty)); assert!(!layout.is_unsized(), "unsized statics aren't supported"); - CPlace::for_addr(global_ptr, layout) + CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout) } fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mut ConstantCx) { diff --git a/src/intrinsics.rs b/src/intrinsics.rs index e05d32ffd7965..af0f8b0be6f92 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -446,7 +446,7 @@ pub fn codegen_intrinsic_call<'tcx>( }; discriminant_value, (c ptr) { let pointee_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); - let val = CValue::by_ref(ptr.load_scalar(fx), pointee_layout); + let val = CValue::by_ref(Pointer::new(ptr.load_scalar(fx)), pointee_layout); let discr = crate::discriminant::codegen_get_discriminant(fx, val, ret.layout()); ret.write_cvalue(fx, discr); }; @@ -598,7 +598,7 @@ pub fn codegen_intrinsic_call<'tcx>( transmute, (c from) { assert_eq!(from.layout().ty, src_ty); - let addr = from.force_stack(fx); + let addr = Pointer::new(from.force_stack(fx)); let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) }; @@ -815,12 +815,12 @@ pub fn codegen_intrinsic_call<'tcx>( // Cranelift treats loads as volatile by default let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); - let val = CValue::by_ref(ptr.load_scalar(fx), inner_layout); + let val = CValue::by_ref(Pointer::new(ptr.load_scalar(fx)), inner_layout); ret.write_cvalue(fx, val); }; volatile_store, (v ptr, c val) { // Cranelift treats stores as volatile by default - let dest = CPlace::for_addr(ptr, val.layout()); + let dest = CPlace::for_ptr(Pointer::new(ptr), val.layout()); dest.write_cvalue(fx, val); }; @@ -854,11 +854,11 @@ pub fn codegen_intrinsic_call<'tcx>( _ if intrinsic.starts_with("atomic_load"), (c ptr) { let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); - let val = CValue::by_ref(ptr.load_scalar(fx), inner_layout); + let val = CValue::by_ref(Pointer::new(ptr.load_scalar(fx)), inner_layout); ret.write_cvalue(fx, val); }; _ if intrinsic.starts_with("atomic_store"), (v ptr, c val) { - let dest = CPlace::for_addr(ptr, val.layout()); + let dest = CPlace::for_ptr(Pointer::new(ptr), val.layout()); dest.write_cvalue(fx, val); }; _ if intrinsic.starts_with("atomic_xchg"), (v ptr, c src) { @@ -868,7 +868,7 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, CValue::by_val(old, fx.layout_of(T))); // Write new - let dest = CPlace::for_addr(ptr, src.layout()); + let dest = CPlace::for_ptr(Pointer::new(ptr), src.layout()); dest.write_cvalue(fx, src); }; _ if intrinsic.starts_with("atomic_cxchg"), (v ptr, v test_old, v new) { // both atomic_cxchg_* and atomic_cxchgweak_* diff --git a/src/lib.rs b/src/lib.rs index 5b1b923968770..dedad3b79c1f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,6 +49,7 @@ mod llvm_intrinsics; mod main_shim; mod metadata; mod num; +mod pointer; mod pretty_clif; mod target_features_whitelist; mod trap; @@ -106,6 +107,7 @@ mod prelude { pub use crate::cast::*; pub use crate::common::*; pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; + pub use crate::pointer::Pointer; pub use crate::trap::*; pub use crate::unimpl::unimpl; pub use crate::value_and_place::{CPlace, CPlaceInner, CValue}; diff --git a/src/pointer.rs b/src/pointer.rs new file mode 100644 index 0000000000000..cadf57255cc9e --- /dev/null +++ b/src/pointer.rs @@ -0,0 +1,101 @@ +use crate::prelude::*; + +use cranelift::codegen::ir::immediates::Offset32; + +#[derive(Copy, Clone, Debug)] +pub struct Pointer { + base_addr: Value, + offset: Offset32, +} + +impl Pointer { + pub fn new(addr: Value) -> Self { + Pointer { + base_addr: addr, + offset: Offset32::new(0), + } + } + + pub fn const_addr<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, addr: i64) -> Self { + let addr = fx.bcx.ins().iconst(fx.pointer_type, addr); + Pointer { + base_addr: addr, + offset: Offset32::new(0), + } + } + + pub fn get_addr<'a, 'tcx>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { + let offset: i64 = self.offset.into(); + if offset == 0 { + self.base_addr + } else { + fx.bcx.ins().iadd_imm(self.base_addr, offset) + } + } + + pub fn get_addr_and_offset(self) -> (Value, Offset32) { + (self.base_addr, self.offset) + } + + pub fn offset<'a, 'tcx>( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + extra_offset: Offset32, + ) -> Self { + self.offset_i64(fx, extra_offset.into()) + } + + pub fn offset_i64<'a, 'tcx>( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + extra_offset: i64, + ) -> Self { + if let Some(new_offset) = self.offset.try_add_i64(extra_offset) { + Pointer { + base_addr: self.base_addr, + offset: new_offset, + } + } else { + let base_offset: i64 = self.offset.into(); + if let Some(new_offset) = base_offset.checked_add(extra_offset){ + let addr = fx.bcx.ins().iadd_imm(self.base_addr, new_offset); + Pointer { + base_addr: addr, + offset: Offset32::new(0), + } + } else { + panic!("self.offset ({}) + extra_offset ({}) not representable in i64", base_offset, extra_offset); + } + } + } + + pub fn offset_value<'a, 'tcx>( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + extra_offset: Value, + ) -> Self { + let base_addr = fx.bcx.ins().iadd(self.base_addr, extra_offset); + Pointer { + base_addr, + offset: self.offset, + } + } + + pub fn load<'a, 'tcx>( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + ty: Type, + flags: MemFlags, + ) -> Value { + fx.bcx.ins().load(ty, flags, self.base_addr, self.offset) + } + + pub fn store<'a, 'tcx>( + self, + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + value: Value, + flags: MemFlags, + ) { + fx.bcx.ins().store(flags, value, self.base_addr, self.offset); + } +} diff --git a/src/trap.rs b/src/trap.rs index 64d88bc48ce00..e297b27debb3d 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -91,8 +91,7 @@ pub fn trap_unreachable_ret_value<'tcx>( msg: impl AsRef, ) -> CValue<'tcx> { trap_unimplemented(fx, msg); - let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); - CValue::by_ref(zero, dest_layout) + CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout) } /// Like `trap_unreachable` but returns a fake place for the specified type. @@ -104,6 +103,5 @@ pub fn trap_unreachable_ret_place<'tcx>( msg: impl AsRef, ) -> CPlace<'tcx> { trap_unimplemented(fx, msg); - let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); - CPlace::for_addr(zero, dest_layout) + CPlace::for_ptr(Pointer::const_addr(fx, 0), dest_layout) } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 64fd30def0687..2d3248b94fa55 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -1,24 +1,22 @@ use crate::prelude::*; +use cranelift::codegen::ir::immediates::Offset32; + fn codegen_field<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - base: Value, + base: Pointer, extra: Option, layout: TyLayout<'tcx>, field: mir::Field, -) -> (Value, TyLayout<'tcx>) { +) -> (Pointer, TyLayout<'tcx>) { let field_offset = layout.fields.offset(field.index()); let field_layout = layout.field(&*fx, field.index()); let simple = |fx: &mut FunctionCx<_>| { - if field_offset.bytes() > 0 { - ( - fx.bcx.ins().iadd_imm(base, field_offset.bytes() as i64), - field_layout, - ) - } else { - (base, field_layout) - } + ( + base.offset_i64(fx, i64::try_from(field_offset.bytes()).unwrap()), + field_layout, + ) }; if let Some(extra) = extra { @@ -44,7 +42,7 @@ fn codegen_field<'tcx>( let offset = fx.bcx.ins().band(and_lhs, and_rhs); ( - fx.bcx.ins().iadd(base, offset), + base.offset_value(fx, offset), field_layout, ) } @@ -54,12 +52,12 @@ fn codegen_field<'tcx>( } } -fn scalar_pair_calculate_b_offset(tcx: TyCtxt<'_>, a_scalar: &Scalar, b_scalar: &Scalar) -> i32 { +fn scalar_pair_calculate_b_offset(tcx: TyCtxt<'_>, a_scalar: &Scalar, b_scalar: &Scalar) -> Offset32 { let b_offset = a_scalar .value .size(&tcx) .align_to(b_scalar.value.align(&tcx).abi); - b_offset.bytes().try_into().unwrap() + Offset32::new(b_offset.bytes().try_into().unwrap()) } /// A read-only value @@ -68,14 +66,14 @@ pub struct CValue<'tcx>(CValueInner, TyLayout<'tcx>); #[derive(Debug, Copy, Clone)] enum CValueInner { - ByRef(Value), + ByRef(Pointer), ByVal(Value), ByValPair(Value, Value), } impl<'tcx> CValue<'tcx> { - pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue(CValueInner::ByRef(value), layout) + pub fn by_ref(ptr: Pointer, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue(CValueInner::ByRef(ptr), layout) } pub fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { @@ -93,7 +91,7 @@ impl<'tcx> CValue<'tcx> { pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; match self.0 { - CValueInner::ByRef(value) => value, + CValueInner::ByRef(ptr) => ptr.get_addr(fx), CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => { let cplace = CPlace::new_stack_slot(fx, layout.ty); cplace.write_cvalue(fx, self); @@ -104,7 +102,14 @@ impl<'tcx> CValue<'tcx> { pub fn try_to_addr(self) -> Option { match self.0 { - CValueInner::ByRef(addr) => Some(addr), + CValueInner::ByRef(ptr) => { + let (base_addr, offset) = ptr.get_addr_and_offset(); + if offset == Offset32::new(0) { + Some(base_addr) + } else { + None + } + } CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => None, } } @@ -113,13 +118,13 @@ impl<'tcx> CValue<'tcx> { pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; match self.0 { - CValueInner::ByRef(addr) => { + CValueInner::ByRef(ptr) => { let scalar = match layout.abi { layout::Abi::Scalar(ref scalar) => scalar.clone(), _ => unreachable!(), }; let clif_ty = scalar_to_clif_type(fx.tcx, scalar); - fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0) + ptr.load(fx, clif_ty, MemFlags::new()) } CValueInner::ByVal(value) => value, CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), @@ -133,7 +138,7 @@ impl<'tcx> CValue<'tcx> { ) -> (Value, Value) { let layout = self.1; match self.0 { - CValueInner::ByRef(addr) => { + CValueInner::ByRef(ptr) => { let (a_scalar, b_scalar) = match &layout.abi { layout::Abi::ScalarPair(a, b) => (a, b), _ => unreachable!("load_scalar_pair({:?})", self), @@ -141,8 +146,8 @@ impl<'tcx> CValue<'tcx> { let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); - let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0); - let val2 = fx.bcx.ins().load(clif_ty2, MemFlags::new(), addr, b_offset); + let val1 = ptr.load(fx, clif_ty1, MemFlags::new()); + let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); (val1, val2) } CValueInner::ByVal(_) => bug!("Please use load_scalar for ByVal"), @@ -156,12 +161,12 @@ impl<'tcx> CValue<'tcx> { field: mir::Field, ) -> CValue<'tcx> { let layout = self.1; - let base = match self.0 { - CValueInner::ByRef(addr) => addr, + let ptr = match self.0 { + CValueInner::ByRef(ptr) => ptr, _ => bug!("place_field for {:?}", self), }; - let (field_ptr, field_layout) = codegen_field(fx, base, None, layout, field); + let (field_ptr, field_layout) = codegen_field(fx, ptr, None, layout, field); CValue::by_ref(field_ptr, field_layout) } @@ -224,7 +229,7 @@ pub struct CPlace<'tcx> { #[derive(Debug, Copy, Clone)] pub enum CPlaceInner { Var(Local), - Addr(Value, Option), + Addr(Pointer, Option), Stack(StackSlot), NoPlace, } @@ -282,16 +287,16 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn for_addr(addr: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub fn for_ptr(ptr: Pointer, layout: TyLayout<'tcx>) -> CPlace<'tcx> { CPlace { - inner: CPlaceInner::Addr(addr, None), + inner: CPlaceInner::Addr(ptr, None), layout, } } - pub fn for_addr_with_extra(addr: Value, extra: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub fn for_ptr_with_extra(ptr: Pointer, extra: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { CPlace { - inner: CPlaceInner::Addr(addr, Some(extra)), + inner: CPlaceInner::Addr(ptr, Some(extra)), layout, } } @@ -304,53 +309,60 @@ impl<'tcx> CPlace<'tcx> { fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); CValue::by_val(val, layout) } - CPlaceInner::Addr(addr, extra) => { + CPlaceInner::Addr(ptr, extra) => { assert!(extra.is_none(), "unsized values are not yet supported"); - CValue::by_ref(addr, layout) + CValue::by_ref(ptr, layout) } CPlaceInner::Stack(stack_slot) => CValue::by_ref( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + Pointer::new(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0)), layout, ), CPlaceInner::NoPlace => CValue::by_ref( - fx.bcx - .ins() - .iconst(fx.pointer_type, fx.pointer_type.bytes() as i64), + Pointer::const_addr(fx, i64::try_from(self.layout.align.pref.bytes()).unwrap()), layout, ), } } - pub fn to_addr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { - match self.to_addr_maybe_unsized(fx) { - (addr, None) => addr, + pub fn to_ptr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { + match self.to_ptr_maybe_unsized(fx) { + (ptr, None) => ptr, (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), } } - pub fn to_addr_maybe_unsized( + pub fn to_addr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + self.to_ptr(fx).get_addr(fx) + } + + pub fn to_ptr_maybe_unsized( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ) -> (Value, Option) { + ) -> (Pointer, Option) { match self.inner { - CPlaceInner::Addr(addr, extra) => (addr, extra), + CPlaceInner::Addr(ptr, extra) => (ptr, extra), CPlaceInner::Stack(stack_slot) => ( - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + Pointer::new(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0)), None, ), CPlaceInner::NoPlace => { ( - fx.bcx.ins().iconst( - fx.pointer_type, - i64::try_from(self.layout.align.pref.bytes()).unwrap(), - ), - None + Pointer::const_addr(fx, i64::try_from(self.layout.align.pref.bytes()).unwrap()), + None, ) } CPlaceInner::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), } } + pub fn to_addr_maybe_unsized( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + ) -> (Value, Option) { + let (ptr, extra) = self.to_ptr_maybe_unsized(fx); + (ptr.get_addr(fx), extra) + } + pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { use rustc::hir::Mutability::*; @@ -420,16 +432,16 @@ impl<'tcx> CPlace<'tcx> { assert_assignable(fx, from_ty, to_ty); let dst_layout = self.layout(); - let addr = match self.inner { + let to_ptr = match self.inner { CPlaceInner::Var(var) => { let data = from.load_scalar(fx); fx.bcx.set_val_label(data, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), data); return; } - CPlaceInner::Addr(addr, None) => addr, + CPlaceInner::Addr(ptr, None) => ptr, CPlaceInner::Stack(stack_slot) => { - fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0) + Pointer::new(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0)) } CPlaceInner::NoPlace => { if dst_layout.abi != Abi::Uninhabited { @@ -442,27 +454,29 @@ impl<'tcx> CPlace<'tcx> { match from.0 { CValueInner::ByVal(val) => { - fx.bcx.ins().store(MemFlags::new(), val, addr, 0); + to_ptr.store(fx, val, MemFlags::new()); } CValueInner::ByValPair(value, extra) => match dst_layout.abi { Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); - fx.bcx.ins().store(MemFlags::new(), value, addr, 0); - fx.bcx.ins().store(MemFlags::new(), extra, addr, b_offset); + to_ptr.store(fx, value, MemFlags::new()); + to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); } _ => bug!( "Non ScalarPair abi {:?} for ByValPair CValue", dst_layout.abi ), }, - CValueInner::ByRef(from_addr) => { + CValueInner::ByRef(from_ptr) => { + let from_addr = from_ptr.get_addr(fx); + let to_addr = to_ptr.get_addr(fx); let src_layout = from.1; let size = dst_layout.size.bytes(); let src_align = src_layout.align.abi.bytes() as u8; let dst_align = dst_layout.align.abi.bytes() as u8; fx.bcx.emit_small_memcpy( fx.module.target_config(), - addr, + to_addr, from_addr, size, dst_align, @@ -478,13 +492,13 @@ impl<'tcx> CPlace<'tcx> { field: mir::Field, ) -> CPlace<'tcx> { let layout = self.layout(); - let (base, extra) = self.to_addr_maybe_unsized(fx); + let (base, extra) = self.to_ptr_maybe_unsized(fx); let (field_ptr, field_layout) = codegen_field(fx, base, extra, layout, field); if field_layout.is_unsized() { - CPlace::for_addr_with_extra(field_ptr, extra.unwrap(), field_layout) + CPlace::for_ptr_with_extra(field_ptr, extra.unwrap(), field_layout) } else { - CPlace::for_addr(field_ptr, field_layout) + CPlace::for_ptr(field_ptr, field_layout) } } @@ -493,9 +507,9 @@ impl<'tcx> CPlace<'tcx> { fx: &mut FunctionCx<'_, 'tcx, impl Backend>, index: Value, ) -> CPlace<'tcx> { - let (elem_layout, addr) = match self.layout().ty.kind { - ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_addr(fx)), - ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_addr_maybe_unsized(fx).0), + let (elem_layout, ptr) = match self.layout().ty.kind { + ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_ptr(fx)), + ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_ptr_maybe_unsized(fx).0), _ => bug!("place_index({:?})", self.layout().ty), }; @@ -504,16 +518,16 @@ impl<'tcx> CPlace<'tcx> { .ins() .imul_imm(index, elem_layout.size.bytes() as i64); - CPlace::for_addr(fx.bcx.ins().iadd(addr, offset), elem_layout) + CPlace::for_ptr(ptr.offset_value(fx, offset), elem_layout) } pub fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); if has_ptr_meta(fx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); - CPlace::for_addr_with_extra(addr, extra, inner_layout) + CPlace::for_ptr_with_extra(Pointer::new(addr), extra, inner_layout) } else { - CPlace::for_addr(self.to_cvalue(fx).load_scalar(fx), inner_layout) + CPlace::for_ptr(Pointer::new(self.to_cvalue(fx).load_scalar(fx)), inner_layout) } } diff --git a/test.sh b/test.sh index 0d7fd71ff4ac6..88a86bcf40460 100755 --- a/test.sh +++ b/test.sh @@ -78,8 +78,8 @@ hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif popd pushd build_sysroot/sysroot_src/src/libcore/tests -rm -r sysroot_src/src/**/*/target/ || true -cargo test +rm -r ./target || true +../../../../../cargo.sh test popd pushd regex From 696053e69f398ecd395e6a74fd58ba634368f57f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 16:16:28 +0100 Subject: [PATCH 0999/1566] Set memflags for vtable loads --- src/vtable.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/vtable.rs b/src/vtable.rs index 155237a402f0c..c12dff3cdc6b3 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -6,11 +6,17 @@ const DROP_FN_INDEX: usize = 0; const SIZE_INDEX: usize = 1; const ALIGN_INDEX: usize = 2; +fn vtable_memflags() -> MemFlags { + let mut flags = MemFlags::trusted(); // A vtable access is always aligned and will never trap. + flags.set_readonly(); // A vtable is always read-only. + flags +} + pub fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), - MemFlags::new(), + vtable_memflags(), vtable, (DROP_FN_INDEX * usize_size) as i32, ) @@ -20,7 +26,7 @@ pub fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), - MemFlags::new(), + vtable_memflags(), vtable, (SIZE_INDEX * usize_size) as i32, ) @@ -30,7 +36,7 @@ pub fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), - MemFlags::new(), + vtable_memflags(), vtable, (ALIGN_INDEX * usize_size) as i32, ) @@ -45,7 +51,7 @@ pub fn get_ptr_and_method_ref<'tcx>( let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( pointer_ty(fx.tcx), - MemFlags::new(), + vtable_memflags(), vtable, ((idx + 3) * usize_size as usize) as i32, ); From 8f5ef6172c520df95779e5da509989e8233053bf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 19:10:08 +0100 Subject: [PATCH 1000/1566] Remove to_addr and to_addr_maybe_unsized --- src/abi/mod.rs | 3 ++- src/abi/pass_mode.rs | 2 +- src/abi/returning.rs | 2 +- src/intrinsics.rs | 4 ++-- src/value_and_place.rs | 24 ++++++------------------ 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f11e343581c57..c626ddfc18411 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -611,7 +611,8 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac let drop_fn_ty = drop_fn.ty(fx.tcx); match ty.kind { ty::Dynamic(..) => { - let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx); + let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(fx); + let ptr = ptr.get_addr(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 9c43f2c80af0f..d37f05cd98652 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -119,7 +119,7 @@ pub fn adjust_arg_for_abi<'tcx>( let (a, b) = arg.load_scalar_pair(fx); Pair(a, b) } - PassMode::ByRef => Single(arg.force_stack(fx)), + PassMode::ByRef => Single(arg.force_stack(fx).get_addr(fx)), } } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 489f52b306fb9..d566a51766496 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -58,7 +58,7 @@ pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>( let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef => match ret_place { - Some(ret_place) => Some(ret_place.to_addr(fx)), + Some(ret_place) => Some(ret_place.to_ptr(fx).get_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), }, PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, diff --git a/src/intrinsics.rs b/src/intrinsics.rs index af0f8b0be6f92..44118edb6fd52 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -598,7 +598,7 @@ pub fn codegen_intrinsic_call<'tcx>( transmute, (c from) { assert_eq!(from.layout().ty, src_ty); - let addr = Pointer::new(from.force_stack(fx)); + let addr = from.force_stack(fx); let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) }; @@ -633,7 +633,7 @@ pub fn codegen_intrinsic_call<'tcx>( fx.bcx.def_var(mir_var(var), val); } _ => { - let addr = ret.to_addr(fx); + let addr = ret.to_ptr(fx).get_addr(fx); let layout = ret.layout(); fx.bcx.emit_small_memset(fx.module.target_config(), addr, 0, layout.size.bytes(), 1); } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 2d3248b94fa55..df690468ccbbc 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -88,14 +88,14 @@ impl<'tcx> CValue<'tcx> { self.1 } - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { let layout = self.1; match self.0 { - CValueInner::ByRef(ptr) => ptr.get_addr(fx), + CValueInner::ByRef(ptr) => ptr, CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => { let cplace = CPlace::new_stack_slot(fx, layout.ty); cplace.write_cvalue(fx, self); - cplace.to_addr(fx) + cplace.to_ptr(fx) } } } @@ -331,10 +331,6 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn to_addr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { - self.to_ptr(fx).get_addr(fx) - } - pub fn to_ptr_maybe_unsized( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, @@ -355,14 +351,6 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn to_addr_maybe_unsized( - self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ) -> (Value, Option) { - let (ptr, extra) = self.to_ptr_maybe_unsized(fx); - (ptr.get_addr(fx), extra) - } - pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { use rustc::hir::Mutability::*; @@ -533,15 +521,15 @@ impl<'tcx> CPlace<'tcx> { pub fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if has_ptr_meta(fx.tcx, self.layout().ty) { - let (value, extra) = self.to_addr_maybe_unsized(fx); + let (ptr, extra) = self.to_ptr_maybe_unsized(fx); let ptr = CValue::by_val_pair( - value, + ptr.get_addr(fx), extra.expect("unsized type without metadata"), dest.layout(), ); dest.write_cvalue(fx, ptr); } else { - let ptr = CValue::by_val(self.to_addr(fx), dest.layout()); + let ptr = CValue::by_val(self.to_ptr(fx).get_addr(fx), dest.layout()); dest.write_cvalue(fx, ptr); } } From fbbc910ddc00a9b88071aae0aa0d9bce64a3a1cc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 19:11:06 +0100 Subject: [PATCH 1001/1566] [OPT] Emit stack_{load,store} where possible --- src/pointer.rs | 91 +++++++++++++++++++++++++++++++++--------- src/value_and_place.rs | 17 ++++---- 2 files changed, 81 insertions(+), 27 deletions(-) diff --git a/src/pointer.rs b/src/pointer.rs index cadf57255cc9e..3899dd15fa43d 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -4,14 +4,27 @@ use cranelift::codegen::ir::immediates::Offset32; #[derive(Copy, Clone, Debug)] pub struct Pointer { - base_addr: Value, + base: PointerBase, offset: Offset32, } +#[derive(Copy, Clone, Debug)] +enum PointerBase { + Addr(Value), + Stack(StackSlot), +} + impl Pointer { pub fn new(addr: Value) -> Self { Pointer { - base_addr: addr, + base: PointerBase::Addr(addr), + offset: Offset32::new(0), + } + } + + pub fn stack_slot(stack_slot: StackSlot) -> Self { + Pointer { + base: PointerBase::Stack(stack_slot), offset: Offset32::new(0), } } @@ -19,22 +32,30 @@ impl Pointer { pub fn const_addr<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, addr: i64) -> Self { let addr = fx.bcx.ins().iconst(fx.pointer_type, addr); Pointer { - base_addr: addr, + base: PointerBase::Addr(addr), offset: Offset32::new(0), } } pub fn get_addr<'a, 'tcx>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { - let offset: i64 = self.offset.into(); - if offset == 0 { - self.base_addr - } else { - fx.bcx.ins().iadd_imm(self.base_addr, offset) + match self.base { + PointerBase::Addr(base_addr) => { + let offset: i64 = self.offset.into(); + if offset == 0 { + base_addr + } else { + fx.bcx.ins().iadd_imm(base_addr, offset) + } + } + PointerBase::Stack(stack_slot) => fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, self.offset), } } - pub fn get_addr_and_offset(self) -> (Value, Offset32) { - (self.base_addr, self.offset) + pub fn try_get_addr_and_offset(self) -> Option<(Value, Offset32)> { + match self.base { + PointerBase::Addr(addr) => Some((addr, self.offset)), + PointerBase::Stack(_) => None, + } } pub fn offset<'a, 'tcx>( @@ -52,15 +73,19 @@ impl Pointer { ) -> Self { if let Some(new_offset) = self.offset.try_add_i64(extra_offset) { Pointer { - base_addr: self.base_addr, + base: self.base, offset: new_offset, } } else { let base_offset: i64 = self.offset.into(); if let Some(new_offset) = base_offset.checked_add(extra_offset){ - let addr = fx.bcx.ins().iadd_imm(self.base_addr, new_offset); + let base_addr = match self.base { + PointerBase::Addr(addr) => addr, + PointerBase::Stack(stack_slot) => fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + }; + let addr = fx.bcx.ins().iadd_imm(base_addr, new_offset); Pointer { - base_addr: addr, + base: PointerBase::Addr(addr), offset: Offset32::new(0), } } else { @@ -74,10 +99,18 @@ impl Pointer { fx: &mut FunctionCx<'a, 'tcx, impl Backend>, extra_offset: Value, ) -> Self { - let base_addr = fx.bcx.ins().iadd(self.base_addr, extra_offset); - Pointer { - base_addr, - offset: self.offset, + match self.base { + PointerBase::Addr(addr) => Pointer { + base: PointerBase::Addr(fx.bcx.ins().iadd(addr, extra_offset)), + offset: self.offset, + }, + PointerBase::Stack(stack_slot) => { + let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, self.offset); + Pointer { + base: PointerBase::Addr(fx.bcx.ins().iadd(base_addr, extra_offset)), + offset: Offset32::new(0), + } + } } } @@ -87,7 +120,16 @@ impl Pointer { ty: Type, flags: MemFlags, ) -> Value { - fx.bcx.ins().load(ty, flags, self.base_addr, self.offset) + match self.base { + PointerBase::Addr(base_addr) => fx.bcx.ins().load(ty, flags, base_addr, self.offset), + PointerBase::Stack(stack_slot) => if ty == types::I128 { + // WORKAROUND for stack_load.i128 not being implemented + let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); + fx.bcx.ins().load(ty, flags, base_addr, self.offset) + } else { + fx.bcx.ins().stack_load(ty, stack_slot, self.offset) + } + } } pub fn store<'a, 'tcx>( @@ -96,6 +138,17 @@ impl Pointer { value: Value, flags: MemFlags, ) { - fx.bcx.ins().store(flags, value, self.base_addr, self.offset); + match self.base { + PointerBase::Addr(base_addr) => { + fx.bcx.ins().store(flags, value, base_addr, self.offset); + } + PointerBase::Stack(stack_slot) => if fx.bcx.func.dfg.value_type(value) == types::I128 { + // WORKAROUND for stack_load.i128 not being implemented + let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); + fx.bcx.ins().store(flags, value, base_addr, self.offset); + } else { + fx.bcx.ins().stack_store(value, stack_slot, self.offset); + } + } } } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index df690468ccbbc..8a497df1e7e93 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -103,9 +103,12 @@ impl<'tcx> CValue<'tcx> { pub fn try_to_addr(self) -> Option { match self.0 { CValueInner::ByRef(ptr) => { - let (base_addr, offset) = ptr.get_addr_and_offset(); - if offset == Offset32::new(0) { - Some(base_addr) + if let Some((base_addr, offset)) = ptr.try_get_addr_and_offset() { + if offset == Offset32::new(0) { + Some(base_addr) + } else { + None + } } else { None } @@ -314,7 +317,7 @@ impl<'tcx> CPlace<'tcx> { CValue::by_ref(ptr, layout) } CPlaceInner::Stack(stack_slot) => CValue::by_ref( - Pointer::new(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0)), + Pointer::stack_slot(stack_slot), layout, ), CPlaceInner::NoPlace => CValue::by_ref( @@ -338,7 +341,7 @@ impl<'tcx> CPlace<'tcx> { match self.inner { CPlaceInner::Addr(ptr, extra) => (ptr, extra), CPlaceInner::Stack(stack_slot) => ( - Pointer::new(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0)), + Pointer::stack_slot(stack_slot), None, ), CPlaceInner::NoPlace => { @@ -428,9 +431,7 @@ impl<'tcx> CPlace<'tcx> { return; } CPlaceInner::Addr(ptr, None) => ptr, - CPlaceInner::Stack(stack_slot) => { - Pointer::new(fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0)) - } + CPlaceInner::Stack(stack_slot) => Pointer::stack_slot(stack_slot), CPlaceInner::NoPlace => { if dst_layout.abi != Abi::Uninhabited { assert_eq!(dst_layout.size.bytes(), 0, "{:?}", dst_layout); From 81eb73365e798f949e40cd0da8026c1a408ce07e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 21:34:46 +0100 Subject: [PATCH 1002/1566] Update Cranelift --- Cargo.lock | 122 ++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d535dce562b86..1974e795f6dae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,31 +65,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-bforest" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-meta 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,30 +98,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" [[package]] name = "cranelift-entity" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" [[package]] name = "cranelift-faerie" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -130,10 +130,10 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -141,44 +141,44 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -408,11 +408,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -568,18 +568,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 3d363d54fd2ec4a5cfc8f4859a968ccf3dcdab69 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 21:39:21 +0100 Subject: [PATCH 1003/1566] Update log dependency --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1974e795f6dae..f05766f013d09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ "cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -134,7 +134,7 @@ version = "0.52.0" source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -146,7 +146,7 @@ source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -221,7 +221,7 @@ dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -285,7 +285,7 @@ name = "goblin" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "log" -version = "0.4.10" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -594,7 +594,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "1b9ad466a945c9c40f6f9a449c55675547e59bc75a2722d4689042ab3ae80c9c" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" From ad72afaad351101d45c1b5b8bb2fb51be66b28d7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 22:00:12 +0100 Subject: [PATCH 1004/1566] Remove CPlaceInner::Stack --- src/abi/comments.rs | 11 ----------- src/debuginfo/mod.rs | 6 +++--- src/intrinsics.rs | 2 +- src/value_and_place.rs | 12 +----------- 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 3fc5b2f0bc85b..a1634bdacfe7d 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -75,17 +75,6 @@ pub fn add_local_place_comments<'tcx>( align.pref.bytes(), )); } - CPlaceInner::Stack(stack_slot) => fx.add_entity_comment( - stack_slot, - format!( - "{:?}: {:?} size={} align={},{}", - local, - ty, - size.bytes(), - align.abi.bytes(), - align.pref.bytes(), - ), - ), CPlaceInner::NoPlace => fx.add_global_comment(format!( "zst {:5} {:20} {:4}b {}, {}", format!("{:?}", local), diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index bb3f26f9fee9d..3e69ba1a6cca1 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -345,9 +345,9 @@ fn place_location<'a, 'tcx>( // FIXME implement this (used by arguments and returns) AttributeValue::Exprloc(Expression(vec![])) - } - CPlaceInner::Stack(stack_slot) => { - AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())) + + // For PointerBase::Stack: + //AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())) } CPlaceInner::NoPlace => AttributeValue::Exprloc(Expression(vec![])), } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 44118edb6fd52..7cabb7caa0726 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -669,7 +669,7 @@ pub fn codegen_intrinsic_call<'tcx>( fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), val); } - CPlaceInner::Addr(_, _) | CPlaceInner::Stack(_) => { + CPlaceInner::Addr(_, _) => { // Don't write to `ret`, as the destination memory is already uninitialized. } } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 8a497df1e7e93..4ac81648700f0 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -233,7 +233,6 @@ pub struct CPlace<'tcx> { pub enum CPlaceInner { Var(Local), Addr(Pointer, Option), - Stack(StackSlot), NoPlace, } @@ -272,7 +271,7 @@ impl<'tcx> CPlace<'tcx> { offset: None, }); CPlace { - inner: CPlaceInner::Stack(stack_slot), + inner: CPlaceInner::Addr(Pointer::stack_slot(stack_slot), None), layout, } } @@ -316,10 +315,6 @@ impl<'tcx> CPlace<'tcx> { assert!(extra.is_none(), "unsized values are not yet supported"); CValue::by_ref(ptr, layout) } - CPlaceInner::Stack(stack_slot) => CValue::by_ref( - Pointer::stack_slot(stack_slot), - layout, - ), CPlaceInner::NoPlace => CValue::by_ref( Pointer::const_addr(fx, i64::try_from(self.layout.align.pref.bytes()).unwrap()), layout, @@ -340,10 +335,6 @@ impl<'tcx> CPlace<'tcx> { ) -> (Pointer, Option) { match self.inner { CPlaceInner::Addr(ptr, extra) => (ptr, extra), - CPlaceInner::Stack(stack_slot) => ( - Pointer::stack_slot(stack_slot), - None, - ), CPlaceInner::NoPlace => { ( Pointer::const_addr(fx, i64::try_from(self.layout.align.pref.bytes()).unwrap()), @@ -431,7 +422,6 @@ impl<'tcx> CPlace<'tcx> { return; } CPlaceInner::Addr(ptr, None) => ptr, - CPlaceInner::Stack(stack_slot) => Pointer::stack_slot(stack_slot), CPlaceInner::NoPlace => { if dst_layout.abi != Abi::Uninhabited { assert_eq!(dst_layout.size.bytes(), 0, "{:?}", dst_layout); From dd675a26fdfb9d3340cfda28236408f3cde20a51 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Dec 2019 22:03:32 +0100 Subject: [PATCH 1005/1566] Revert "Update Cranelift" This reverts commit 81eb73365e798f949e40cd0da8026c1a408ce07e. Caused SIGSEGV: https://github.com/bytecodealliance/cranelift/issues/1305 --- Cargo.lock | 114 ++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f05766f013d09..670a5c015e5c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,32 +65,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-bforest" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ - "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,30 +98,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ - "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" [[package]] name = "cranelift-entity" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" [[package]] name = "cranelift-faerie" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -130,55 +130,55 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#e0d317249194f51a80c97a856f96eea1560c5435" +version = "0.51.0" +source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -408,11 +408,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -568,18 +568,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 24859948034772efeba917bccb568ec3e67c108e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Dec 2019 11:22:12 +0100 Subject: [PATCH 1006/1566] Rustup to rustc 1.42.0-nightly (01a46509a 2019-12-20) --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index db7ebd075350c..8bc5525160dbe 100644 --- a/src/base.rs +++ b/src/base.rs @@ -283,7 +283,7 @@ fn trans_stmt<'tcx>( let val = trans_operand(fx, operand); lval.write_cvalue(fx, val); } - Rvalue::Ref(_, _, place) => { + Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { let place = trans_place(fx, place); place.write_place_ref(fx, lval); } From e63a94fca6cf6809938b4dbcda69b2d064614129 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 22 Dec 2019 14:49:10 +0100 Subject: [PATCH 1007/1566] Rustup to rustc 1.42.0-nightly (fc5deca21 2019-12-21) --- src/abi/mod.rs | 2 +- src/common.rs | 2 +- src/debuginfo/mod.rs | 2 +- src/value_and_place.rs | 10 ++++------ test.sh | 3 ++- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index c626ddfc18411..28cc04bd484ec 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -633,7 +633,7 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac &ty::RegionKind::ReErased, TypeAndMut { ty, - mutbl: crate::rustc::hir::Mutability::Mutable, + mutbl: crate::rustc::hir::Mutability::Mut, }, ), ); diff --git a/src/common.rs b/src/common.rs index c3a8b708ab6e9..d0c3385df6c14 100644 --- a/src/common.rs +++ b/src/common.rs @@ -72,7 +72,7 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { - let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc::hir::Mutability::Immutable }); + let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc::hir::Mutability::Not }); match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi { Abi::Scalar(_) => false, Abi::ScalarPair(_, _) => true, diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 3e69ba1a6cca1..2e40e7c4cadf6 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -138,7 +138,7 @@ impl<'tcx> DebugContext<'tcx> { let type_entry = self.dwarf.unit.get_mut(type_id); - //type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc::hir::Mutability::MutMutable)); + //type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc::hir::Mutability::Mut)); type_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(pointee)); type_id diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 4ac81648700f0..b1e96d2ce2c08 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -346,8 +346,6 @@ impl<'tcx> CPlace<'tcx> { } pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { - use rustc::hir::Mutability::*; - let from_ty = from.layout().ty; let to_ty = self.layout().ty; @@ -357,14 +355,14 @@ impl<'tcx> CPlace<'tcx> { to_ty: Ty<'tcx>, ) { match (&from_ty.kind, &to_ty.kind) { - (ty::Ref(_, t, Immutable), ty::Ref(_, u, Immutable)) - | (ty::Ref(_, t, Mutable), ty::Ref(_, u, Immutable)) - | (ty::Ref(_, t, Mutable), ty::Ref(_, u, Mutable)) => { + (ty::Ref(_, t, Mutability::Not), ty::Ref(_, u, Mutability::Not)) + | (ty::Ref(_, t, Mutability::Mut), ty::Ref(_, u, Mutability::Not)) + | (ty::Ref(_, t, Mutability::Mut), ty::Ref(_, u, Mutability::Mut)) => { assert_assignable(fx, t, u); // &mut T -> &T is allowed // &'a T -> &'b T is allowed } - (ty::Ref(_, _, Immutable), ty::Ref(_, _, Mutable)) => panic!( + (ty::Ref(_, _, Mutability::Not), ty::Ref(_, _, Mutability::Mut)) => panic!( "Cant assign value of type {} to place of type {}", from_ty, to_ty ), diff --git a/test.sh b/test.sh index 88a86bcf40460..e502a20db5bef 100755 --- a/test.sh +++ b/test.sh @@ -52,7 +52,8 @@ $RUSTC example/alloc_example.rs --crate-type bin jit std_example example/std_example.rs echo "[AOT] dst_field_align" -$RUSTC example/dst-field-align.rs -Zmir-opt-level=2 --crate-name dst_field_align --crate-type bin +# FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. +$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin ./target/out/dst_field_align echo "[AOT] std_example" From df641e1679882274e8eb82b45d60f6fe2250952b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 22 Dec 2019 14:43:24 +0100 Subject: [PATCH 1008/1566] Update Cranelift bytecodealliance/cranelift#1305 has been fixed. --- Cargo.lock | 114 ++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 670a5c015e5c6..93e0ed3816844 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,32 +65,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-bforest" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ - "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,30 +98,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ - "cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" [[package]] name = "cranelift-entity" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" [[package]] name = "cranelift-faerie" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -130,55 +130,55 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/cranelift/#ec787eb281bb2e18e191508c17abe694e91f0677" +version = "0.52.0" +source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" dependencies = [ - "cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -408,11 +408,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -568,18 +568,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-bforest 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-faerie 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.51.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 15a310345d955f06dcb989a510d6613be2443a6e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 22 Dec 2019 15:27:25 +0100 Subject: [PATCH 1009/1566] Improve local ir comments --- src/abi/comments.rs | 54 ++++++++++++++++++++++----------------------- src/pointer.rs | 6 ++++- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index a1634bdacfe7d..41c74ef4a3340 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -45,7 +45,7 @@ pub fn add_arg_comment<'tcx>( pub fn add_locals_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(String::new()); fx.add_global_comment(format!( - "kind local ty size align (abi,pref)" + "kind local ty size align (abi,pref)" )); } @@ -63,35 +63,33 @@ pub fn add_local_place_comments<'tcx>( fields: _, largest_niche: _, } = details; - match *place.inner() { + + let (kind, extra) = match *place.inner() { CPlaceInner::Var(var) => { assert_eq!(local, var); - fx.add_global_comment(format!( - "ssa {:5} {:20} {:4}b {}, {}", - format!("{:?}", local), - format!("{:?}", ty), - size.bytes(), - align.abi.bytes(), - align.pref.bytes(), - )); + ("ssa", std::borrow::Cow::Borrowed("")) } - CPlaceInner::NoPlace => fx.add_global_comment(format!( - "zst {:5} {:20} {:4}b {}, {}", - format!("{:?}", local), - format!("{:?}", ty), - size.bytes(), - align.abi.bytes(), - align.pref.bytes(), - )), - CPlaceInner::Addr(ptr, None) => fx.add_global_comment(format!( - "reuse {:5} {:20} {:4}b {}, {} storage={:?}", - format!("{:?}", local), - format!("{:?}", ty), - size.bytes(), - align.abi.bytes(), - align.pref.bytes(), - ptr, - )), + CPlaceInner::NoPlace => ("zst", "".into()), + CPlaceInner::Addr(ptr, None) => match ptr.base_and_offset() { + (crate::pointer::PointerBase::Addr(addr), offset) => { + ("reuse", format!("storage={}{}", addr, offset).into()) + } + (crate::pointer::PointerBase::Stack(stack_slot), offset) => { + ("stack", format!("storage={}{}", stack_slot, offset).into()) + } + }, CPlaceInner::Addr(_, Some(_)) => unreachable!(), - } + }; + + fx.add_global_comment(format!( + "{:<5} {:5} {:30} {:4}b {}, {}{}{}", + kind, + format!("{:?}", local), + format!("{:?}", ty), + size.bytes(), + align.abi.bytes(), + align.pref.bytes(), + if extra.is_empty() { "" } else { " " }, + extra, + )); } diff --git a/src/pointer.rs b/src/pointer.rs index 3899dd15fa43d..f47d5e9be9ba1 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -9,7 +9,7 @@ pub struct Pointer { } #[derive(Copy, Clone, Debug)] -enum PointerBase { +pub enum PointerBase { Addr(Value), Stack(StackSlot), } @@ -37,6 +37,10 @@ impl Pointer { } } + pub fn base_and_offset(self) -> (PointerBase, Offset32) { + (self.base, self.offset) + } + pub fn get_addr<'a, 'tcx>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { match self.base { PointerBase::Addr(base_addr) => { From 82b52a8744ae2bed947399544647761658af007f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 13:25:22 +0100 Subject: [PATCH 1010/1566] Rustup to rustc 1.42.0-nightly (9b98af84c 2019-12-22) --- src/constant.rs | 29 +++++------------------------ src/intrinsics.rs | 7 ++----- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 53e0941d7e9c1..f63a5021d1e56 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use rustc::mir::interpret::{ - read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, GlobalId, InterpResult, Scalar, + read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, }; use rustc::ty::{layout::Align, Const, ConstKind}; use rustc_mir::interpret::{ @@ -54,10 +54,7 @@ pub fn trans_promoted<'tcx>( promoted: Promoted, dest_ty: Ty<'tcx>, ) -> CPlace<'tcx> { - match fx.tcx.const_eval(ParamEnv::reveal_all().and(GlobalId { - instance, - promoted: Some(promoted), - })) { + match fx.tcx.const_eval_promoted(instance, promoted) { Ok(const_) => { let cplace = trans_const_place(fx, const_); debug_assert_eq!(cplace.layout(), fx.layout_of(dest_ty)); @@ -85,14 +82,8 @@ pub fn force_eval_const<'tcx>( ) -> &'tcx Const<'tcx> { match const_.val { ConstKind::Unevaluated(def_id, ref substs) => { - let param_env = ParamEnv::reveal_all(); let substs = fx.monomorphize(substs); - let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap(); - let cid = GlobalId { - instance, - promoted: None, - }; - fx.tcx.const_eval(param_env.and(cid)).unwrap() + fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def_id, substs, None).unwrap() } _ => fx.monomorphize(&const_), } @@ -284,12 +275,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu continue; } - let instance = ty::Instance::mono(tcx, def_id); - let cid = GlobalId { - instance, - promoted: None, - }; - let const_ = tcx.const_eval(ParamEnv::reveal_all().and(cid)).unwrap(); + let const_ = tcx.const_eval_poly(def_id).unwrap(); let alloc = match const_.val { ConstKind::Value(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc, @@ -507,12 +493,7 @@ pub fn mir_operand_get_const_val<'tcx>( StaticKind::Static => unimplemented!(), StaticKind::Promoted(promoted, substs) => { let instance = Instance::new(static_.def_id, fx.monomorphize(substs)); - fx.tcx - .const_eval(ParamEnv::reveal_all().and(GlobalId { - instance, - promoted: Some(*promoted), - })) - .unwrap() + fx.tcx.const_eval_promoted(instance, *promoted).unwrap() } }) } diff --git a/src/intrinsics.rs b/src/intrinsics.rs index 7cabb7caa0726..2f689af22cab6 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics.rs @@ -825,11 +825,8 @@ pub fn codegen_intrinsic_call<'tcx>( }; size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () { - let gid = rustc::mir::interpret::GlobalId { - instance, - promoted: None, - }; - let const_val = fx.tcx.const_eval(ParamEnv::reveal_all().and(gid)).unwrap(); + let const_val = + fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); let val = crate::constant::trans_const_value(fx, const_val); ret.write_cvalue(fx, val); }; From f0b553df5af662a225d49af9eb0cdbb9d07b4687 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2019 12:50:16 +0000 Subject: [PATCH 1011/1566] Bump smallvec from 1.0.0 to 1.1.0 Bumps [smallvec](https://github.com/servo/rust-smallvec) from 1.0.0 to 1.1.0. - [Release notes](https://github.com/servo/rust-smallvec/releases) - [Commits](https://github.com/servo/rust-smallvec/compare/v1.0.0...v1.1.0) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93e0ed3816844..f3e359eac037b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,7 +91,7 @@ dependencies = [ "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -135,7 +135,7 @@ source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5d dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -468,7 +468,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "smallvec" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -611,7 +611,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" -"checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" +"checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" From 67a0fdad19b3dacdc7f088b3fcec7e21d3a364d8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Nov 2019 20:45:32 +0100 Subject: [PATCH 1012/1566] Make llvm_intrinsics a submodule of intrinsics --- src/abi/mod.rs | 2 +- src/{llvm_intrinsics.rs => intrinsics/llvm.rs} | 0 src/{intrinsics.rs => intrinsics/mod.rs} | 10 ++++++---- src/lib.rs | 1 - 4 files changed, 7 insertions(+), 6 deletions(-) rename src/{llvm_intrinsics.rs => intrinsics/llvm.rs} (100%) rename src/{intrinsics.rs => intrinsics/mod.rs} (99%) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 28cc04bd484ec..087cced93a348 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -419,7 +419,7 @@ pub fn codegen_terminator_call<'tcx>( ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap(); if fx.tcx.symbol_name(instance).name.as_str().starts_with("llvm.") { - crate::llvm_intrinsics::codegen_llvm_intrinsic_call( + crate::intrinsics::llvm::codegen_llvm_intrinsic_call( fx, &fx.tcx.symbol_name(instance).name.as_str(), substs, diff --git a/src/llvm_intrinsics.rs b/src/intrinsics/llvm.rs similarity index 100% rename from src/llvm_intrinsics.rs rename to src/intrinsics/llvm.rs diff --git a/src/intrinsics.rs b/src/intrinsics/mod.rs similarity index 99% rename from src/intrinsics.rs rename to src/intrinsics/mod.rs index 2f689af22cab6..7e4144d29e101 100644 --- a/src/intrinsics.rs +++ b/src/intrinsics/mod.rs @@ -1,3 +1,5 @@ +pub mod llvm; + use crate::prelude::*; macro intrinsic_pat { @@ -35,7 +37,7 @@ macro intrinsic_substs { } } -pub macro intrinsic_match { +macro intrinsic_match { ($fx:expr, $intrinsic:expr, $substs:expr, $args:expr, _ => $unknown:block; $( @@ -128,7 +130,7 @@ macro_rules! atomic_minmax { }; } -pub fn lane_type_and_count<'tcx>( +fn lane_type_and_count<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, intrinsic: &str, @@ -145,7 +147,7 @@ pub fn lane_type_and_count<'tcx>( (lane_layout, lane_count) } -pub fn simd_for_each_lane<'tcx, B: Backend>( +fn simd_for_each_lane<'tcx, B: Backend>( fx: &mut FunctionCx<'_, 'tcx, B>, intrinsic: &str, x: CValue<'tcx>, @@ -177,7 +179,7 @@ pub fn simd_for_each_lane<'tcx, B: Backend>( } } -pub fn bool_to_zero_or_max_uint<'tcx>( +fn bool_to_zero_or_max_uint<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, val: Value, diff --git a/src/lib.rs b/src/lib.rs index dedad3b79c1f6..7d67de73ae291 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,7 +45,6 @@ mod discriminant; mod driver; mod intrinsics; mod linkage; -mod llvm_intrinsics; mod main_shim; mod metadata; mod num; From d89f307ea251d78df4457140cdc23f335940885c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Nov 2019 20:58:33 +0100 Subject: [PATCH 1013/1566] Move simd intrinsics to intrinsics/simd.rs --- src/intrinsics/mod.rs | 246 +++++++++-------------------------------- src/intrinsics/simd.rs | 171 ++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+), 196 deletions(-) create mode 100644 src/intrinsics/simd.rs diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 7e4144d29e101..ca10399cb9cb8 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -1,4 +1,5 @@ pub mod llvm; +mod simd; use crate::prelude::*; @@ -70,7 +71,7 @@ macro intrinsic_match { } } -macro_rules! call_intrinsic_match { +macro call_intrinsic_match { ($fx:expr, $intrinsic:expr, $substs:expr, $ret:expr, $destination:expr, $args:expr, $( $name:ident($($arg:ident),*) -> $ty:ident => $func:ident, )*) => { @@ -102,32 +103,28 @@ macro_rules! call_intrinsic_match { } } -macro_rules! atomic_binop_return_old { - ($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) => { - let clif_ty = $fx.clif_type($T).unwrap(); - let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); - let new = $fx.bcx.ins().$op(old, $src); - $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); - $ret.write_cvalue($fx, CValue::by_val(old, $fx.layout_of($T))); - }; +macro atomic_binop_return_old($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) { + let clif_ty = $fx.clif_type($T).unwrap(); + let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); + let new = $fx.bcx.ins().$op(old, $src); + $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); + $ret.write_cvalue($fx, CValue::by_val(old, $fx.layout_of($T))); } -macro_rules! atomic_minmax { - ($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ret:ident) => { - // Read old - let clif_ty = $fx.clif_type($T).unwrap(); - let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); +macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ret:ident) { + // Read old + let clif_ty = $fx.clif_type($T).unwrap(); + let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); - // Compare - let is_eq = codegen_icmp($fx, IntCC::SignedGreaterThan, old, $src); - let new = $fx.bcx.ins().select(is_eq, old, $src); + // Compare + let is_eq = codegen_icmp($fx, IntCC::SignedGreaterThan, old, $src); + let new = $fx.bcx.ins().select(is_eq, old, $src); - // Write new - $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); + // Write new + $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); - let ret_val = CValue::by_val(old, $ret.layout()); - $ret.write_cvalue($fx, ret_val); - }; + let ret_val = CValue::by_val(old, $ret.layout()); + $ret.write_cvalue($fx, ret_val); } fn lane_type_and_count<'tcx>( @@ -206,7 +203,7 @@ fn bool_to_zero_or_max_uint<'tcx>( CValue::by_val(res, layout) } -macro_rules! simd_cmp { +macro simd_cmp { ($fx:expr, $intrinsic:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane( $fx, @@ -222,7 +219,7 @@ macro_rules! simd_cmp { bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) }, ); - }; + }, ($fx:expr, $intrinsic:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane( $fx, @@ -239,10 +236,10 @@ macro_rules! simd_cmp { bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) }, ); - }; + }, } -macro_rules! simd_int_binop { +macro simd_int_binop { ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane( $fx, @@ -258,7 +255,7 @@ macro_rules! simd_int_binop { CValue::by_val(res_lane, ret_lane_layout) }, ); - }; + }, ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane( $fx, @@ -275,10 +272,10 @@ macro_rules! simd_int_binop { CValue::by_val(res_lane, ret_lane_layout) }, ); - }; + }, } -macro_rules! simd_int_flt_binop { +macro simd_int_flt_binop { ($fx:expr, $intrinsic:expr, $op:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane( $fx, @@ -295,7 +292,7 @@ macro_rules! simd_int_flt_binop { CValue::by_val(res_lane, ret_lane_layout) }, ); - }; + }, ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { simd_for_each_lane( $fx, @@ -313,26 +310,24 @@ macro_rules! simd_int_flt_binop { CValue::by_val(res_lane, ret_lane_layout) }, ); - }; + }, } -macro_rules! simd_flt_binop { - ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane( - $fx, - $intrinsic, - $x, - $y, - $ret, - |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { - ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }, - ); - }; +macro simd_flt_binop($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { + simd_for_each_lane( + $fx, + $intrinsic, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.kind { + ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); } pub fn codegen_intrinsic_call<'tcx>( @@ -371,6 +366,13 @@ pub fn codegen_intrinsic_call<'tcx>( } }; + if intrinsic.starts_with("simd_") { + self::simd::codegen_simd_intrinsic_call(fx, instance, args, ret, span); + let ret_ebb = fx.get_ebb(destination.expect("SIMD intrinsics don't diverge").1); + fx.bcx.ins().jump(ret_ebb, &[]); + return; + } + let usize_layout = fx.layout_of(fx.tcx.types.usize); call_intrinsic_match! { @@ -944,154 +946,6 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, val); }; - simd_cast, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fx, a.layout(), intrinsic); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); - assert_eq!(lane_count, ret_lane_count); - - let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); - - let from_signed = type_sign(lane_layout.ty); - let to_signed = type_sign(ret_lane_layout.ty); - - for lane in 0..lane_count { - let lane = mir::Field::new(lane.try_into().unwrap()); - - let a_lane = a.value_field(fx, lane).load_scalar(fx); - let res = clif_int_or_float_cast(fx, a_lane, from_signed, ret_lane_ty, to_signed); - ret.place_field(fx, lane).write_cvalue(fx, CValue::by_val(res, ret_lane_layout)); - } - }; - - simd_eq, (c x, c y) { - simd_cmp!(fx, intrinsic, Equal(x, y) -> ret); - }; - simd_ne, (c x, c y) { - simd_cmp!(fx, intrinsic, NotEqual(x, y) -> ret); - }; - simd_lt, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedLessThan|SignedLessThan(x, y) -> ret); - }; - simd_le, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedLessThanOrEqual|SignedLessThanOrEqual(x, y) -> ret); - }; - simd_gt, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedGreaterThan|SignedGreaterThan(x, y) -> ret); - }; - simd_ge, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret); - }; - - // simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U - _ if intrinsic.starts_with("simd_shuffle"), (c x, c y, o idx) { - let n: u32 = intrinsic["simd_shuffle".len()..].parse().unwrap(); - - assert_eq!(x.layout(), y.layout()); - let layout = x.layout(); - - let (lane_type, lane_count) = lane_type_and_count(fx, layout, intrinsic); - let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); - - assert_eq!(lane_type, ret_lane_type); - assert_eq!(n, ret_lane_count); - - let total_len = lane_count * 2; - - let indexes = { - use rustc::mir::interpret::*; - let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_shuffle* idx not const"); - - let idx_bytes = match idx_const.val { - ty::ConstKind::Value(ConstValue::ByRef { alloc, offset }) => { - let ptr = Pointer::new(AllocId(0 /* dummy */), offset); - let size = Size::from_bytes(4 * u64::from(ret_lane_count) /* size_of([u32; ret_lane_count]) */); - alloc.get_bytes(fx, ptr, size).unwrap() - } - _ => unreachable!("{:?}", idx_const), - }; - - (0..ret_lane_count).map(|i| { - let i = usize::try_from(i).unwrap(); - let idx = rustc::mir::interpret::read_target_uint( - fx.tcx.data_layout.endian, - &idx_bytes[4*i.. 4*i + 4], - ).expect("read_target_uint"); - u32::try_from(idx).expect("try_from u32") - }).collect::>() - }; - - for &idx in &indexes { - assert!(idx < total_len, "idx {} out of range 0..{}", idx, total_len); - } - - for (out_idx, in_idx) in indexes.into_iter().enumerate() { - let in_lane = if in_idx < lane_count { - x.value_field(fx, mir::Field::new(in_idx.try_into().unwrap())) - } else { - y.value_field(fx, mir::Field::new((in_idx - lane_count).try_into().unwrap())) - }; - let out_lane = ret.place_field(fx, mir::Field::new(out_idx)); - out_lane.write_cvalue(fx, in_lane); - } - }; - - simd_extract, (c v, o idx) { - let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { - idx_const - } else { - fx.tcx.sess.span_warn( - fx.mir.span, - "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", - ); - crate::trap::trap_panic(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); - return; - }; - - let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx, v.layout(), intrinsic); - if idx >= lane_count.into() { - fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); - } - - let ret_lane = v.value_field(fx, mir::Field::new(idx.try_into().unwrap())); - ret.write_cvalue(fx, ret_lane); - }; - - simd_add, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, iadd|fadd(x, y) -> ret); - }; - simd_sub, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, isub|fsub(x, y) -> ret); - }; - simd_mul, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, imul|fmul(x, y) -> ret); - }; - simd_div, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, udiv|sdiv|fdiv(x, y) -> ret); - }; - simd_shl, (c x, c y) { - simd_int_binop!(fx, intrinsic, ishl(x, y) -> ret); - }; - simd_shr, (c x, c y) { - simd_int_binop!(fx, intrinsic, ushr|sshr(x, y) -> ret); - }; - simd_and, (c x, c y) { - simd_int_binop!(fx, intrinsic, band(x, y) -> ret); - }; - simd_or, (c x, c y) { - simd_int_binop!(fx, intrinsic, bor(x, y) -> ret); - }; - simd_xor, (c x, c y) { - simd_int_binop!(fx, intrinsic, bxor(x, y) -> ret); - }; - - simd_fmin, (c x, c y) { - simd_flt_binop!(fx, intrinsic, fmin(x, y) -> ret); - }; - simd_fmax, (c x, c y) { - simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret); - }; - try, (v f, v data, v _local_ptr) { // FIXME once unwinding is supported, change this to actually catch panics let f_sig = fx.bcx.func.import_signature(Signature { diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs new file mode 100644 index 0000000000000..2b6447de894f3 --- /dev/null +++ b/src/intrinsics/simd.rs @@ -0,0 +1,171 @@ +use crate::prelude::*; +use super::*; + +pub fn codegen_simd_intrinsic_call<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + instance: Instance<'tcx>, + args: &[mir::Operand<'tcx>], + ret: CPlace<'tcx>, + span: Span, +) { + let def_id = instance.def_id(); + let substs = instance.substs; + + let intrinsic = fx.tcx.item_name(def_id).as_str(); + let intrinsic = &intrinsic[..]; + + intrinsic_match! { + fx, intrinsic, substs, args, + _ => { + fx.tcx.sess.fatal(&format!("Unknown SIMD intrinsic {}", intrinsic)); + }; + + simd_cast, (c a) { + let (lane_layout, lane_count) = lane_type_and_count(fx, a.layout(), intrinsic); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + assert_eq!(lane_count, ret_lane_count); + + let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); + + let from_signed = type_sign(lane_layout.ty); + let to_signed = type_sign(ret_lane_layout.ty); + + for lane in 0..lane_count { + let lane = mir::Field::new(lane.try_into().unwrap()); + + let a_lane = a.value_field(fx, lane).load_scalar(fx); + let res = clif_int_or_float_cast(fx, a_lane, from_signed, ret_lane_ty, to_signed); + ret.place_field(fx, lane).write_cvalue(fx, CValue::by_val(res, ret_lane_layout)); + } + }; + + simd_eq, (c x, c y) { + simd_cmp!(fx, intrinsic, Equal(x, y) -> ret); + }; + simd_ne, (c x, c y) { + simd_cmp!(fx, intrinsic, NotEqual(x, y) -> ret); + }; + simd_lt, (c x, c y) { + simd_cmp!(fx, intrinsic, UnsignedLessThan|SignedLessThan(x, y) -> ret); + }; + simd_le, (c x, c y) { + simd_cmp!(fx, intrinsic, UnsignedLessThanOrEqual|SignedLessThanOrEqual(x, y) -> ret); + }; + simd_gt, (c x, c y) { + simd_cmp!(fx, intrinsic, UnsignedGreaterThan|SignedGreaterThan(x, y) -> ret); + }; + simd_ge, (c x, c y) { + simd_cmp!(fx, intrinsic, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret); + }; + + // simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U + _ if intrinsic.starts_with("simd_shuffle"), (c x, c y, o idx) { + let n: u32 = intrinsic["simd_shuffle".len()..].parse().unwrap(); + + assert_eq!(x.layout(), y.layout()); + let layout = x.layout(); + + let (lane_type, lane_count) = lane_type_and_count(fx, layout, intrinsic); + let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + + assert_eq!(lane_type, ret_lane_type); + assert_eq!(n, ret_lane_count); + + let total_len = lane_count * 2; + + let indexes = { + use rustc::mir::interpret::*; + let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_shuffle* idx not const"); + + let idx_bytes = match idx_const.val { + ty::ConstKind::Value(ConstValue::ByRef { alloc, offset }) => { + let ptr = Pointer::new(AllocId(0 /* dummy */), offset); + let size = Size::from_bytes(4 * u64::from(ret_lane_count) /* size_of([u32; ret_lane_count]) */); + alloc.get_bytes(fx, ptr, size).unwrap() + } + _ => unreachable!("{:?}", idx_const), + }; + + (0..ret_lane_count).map(|i| { + let i = usize::try_from(i).unwrap(); + let idx = rustc::mir::interpret::read_target_uint( + fx.tcx.data_layout.endian, + &idx_bytes[4*i.. 4*i + 4], + ).expect("read_target_uint"); + u32::try_from(idx).expect("try_from u32") + }).collect::>() + }; + + for &idx in &indexes { + assert!(idx < total_len, "idx {} out of range 0..{}", idx, total_len); + } + + for (out_idx, in_idx) in indexes.into_iter().enumerate() { + let in_lane = if in_idx < lane_count { + x.value_field(fx, mir::Field::new(in_idx.try_into().unwrap())) + } else { + y.value_field(fx, mir::Field::new((in_idx - lane_count).try_into().unwrap())) + }; + let out_lane = ret.place_field(fx, mir::Field::new(out_idx)); + out_lane.write_cvalue(fx, in_lane); + } + }; + + simd_extract, (c v, o idx) { + let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { + idx_const + } else { + fx.tcx.sess.span_warn( + fx.mir.span, + "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", + ); + crate::trap::trap_panic(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); + return; + }; + + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); + let (_lane_type, lane_count) = lane_type_and_count(fx, v.layout(), intrinsic); + if idx >= lane_count.into() { + fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); + } + + let ret_lane = v.value_field(fx, mir::Field::new(idx.try_into().unwrap())); + ret.write_cvalue(fx, ret_lane); + }; + + simd_add, (c x, c y) { + simd_int_flt_binop!(fx, intrinsic, iadd|fadd(x, y) -> ret); + }; + simd_sub, (c x, c y) { + simd_int_flt_binop!(fx, intrinsic, isub|fsub(x, y) -> ret); + }; + simd_mul, (c x, c y) { + simd_int_flt_binop!(fx, intrinsic, imul|fmul(x, y) -> ret); + }; + simd_div, (c x, c y) { + simd_int_flt_binop!(fx, intrinsic, udiv|sdiv|fdiv(x, y) -> ret); + }; + simd_shl, (c x, c y) { + simd_int_binop!(fx, intrinsic, ishl(x, y) -> ret); + }; + simd_shr, (c x, c y) { + simd_int_binop!(fx, intrinsic, ushr|sshr(x, y) -> ret); + }; + simd_and, (c x, c y) { + simd_int_binop!(fx, intrinsic, band(x, y) -> ret); + }; + simd_or, (c x, c y) { + simd_int_binop!(fx, intrinsic, bor(x, y) -> ret); + }; + simd_xor, (c x, c y) { + simd_int_binop!(fx, intrinsic, bxor(x, y) -> ret); + }; + + simd_fmin, (c x, c y) { + simd_flt_binop!(fx, intrinsic, fmin(x, y) -> ret); + }; + simd_fmax, (c x, c y) { + simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret); + }; + } +} From 047eaf14ba7306511cf350d079c912ff840c566d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Dec 2019 12:27:11 +0100 Subject: [PATCH 1014/1566] Rustup to rustc 1.42.0-nightly (9ae6cedb8 2019-12-23) --- patches/0017-Fix-libtest-compilation.patch | 13 ++++---- patches/0023-core-Ignore-failing-tests.patch | 30 +++++++++---------- ...g-initialization-on-linux-to-not-req.patch | 7 ++--- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index ffde7ec3b6222..5592818474ebe 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -12,8 +12,8 @@ index 8b76080..9e65de2 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -52,7 +52,7 @@ use std::fmt; - env, - io, + use std::{ + env, io, io::prelude::Write, - panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}, + panic::{self, PanicInfo}, @@ -79,15 +79,12 @@ index 8b76080..9e65de2 100644 let exec_time = start.map(|start| { let duration = start.elapsed(); TestExecTime(duration) -@@ -1688,10 +1676,10 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender, -+ testfn: Box, - ) -> ! { +-fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box) -> ! { ++fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box) -> ! { let builtin_panic_hook = panic::take_hook(); let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| { let test_result = match panic_info { diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index d5e4656926044..f5473834f0b45 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -137,7 +137,7 @@ index a17c094..5bb11d2 100644 #[test] +#[ignore] fn from_str_issue7588() { - let u : Option = u8::from_str_radix("1000", 10).ok(); + let u: Option = u8::from_str_radix("1000", 10).ok(); assert_eq!(u, None); @@ -613,11 +614,9 @@ test_impl_try_from_signed_to_unsigned_err! { test_try_i64u32, i64, u32 } test_impl_try_from_signed_to_unsigned_err! { test_try_i128u8, i128, u8 } @@ -152,21 +152,21 @@ index a17c094..5bb11d2 100644 cfg_block! { #[cfg(target_pointer_width = "16")] { @@ -640,6 +639,7 @@ macro_rules! test_float { - ($modname: ident, $fty: ty, $inf: expr, $neginf: expr, $nan: expr) => { mod $modname { - // FIXME(nagisa): these tests should test for sign of -0.0 - #[test] -+ #[ignore] - fn min() { - assert_eq!((0.0 as $fty).min(0.0), 0.0); - assert_eq!((-0.0 as $fty).min(-0.0), -0.0); + mod $modname { + // FIXME(nagisa): these tests should test for sign of -0.0 + #[test] ++ #[ignore] + fn min() { + assert_eq!((0.0 as $fty).min(0.0), 0.0); + assert_eq!((-0.0 as $fty).min(-0.0), -0.0); @@ -662,6 +662,7 @@ macro_rules! test_float { - assert!(($nan as $fty).min($nan).is_nan()); - } - #[test] -+ #[ignore] - fn max() { - assert_eq!((0.0 as $fty).max(0.0), 0.0); - assert_eq!((-0.0 as $fty).max(-0.0), -0.0); + assert!(($nan as $fty).min($nan).is_nan()); + } + #[test] ++ #[ignore] + fn max() { + assert_eq!((0.0 as $fty).max(0.0), 0.0); + assert_eq!((-0.0 as $fty).max(-0.0), -0.0); diff --git a/src/libcore/tests/time.rs b/src/libcore/tests/time.rs index fac70c4..9107a02 100644 --- a/src/libcore/tests/time.rs diff --git a/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch b/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch index 5300c590b2a1c..599da32ee8288 100644 --- a/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch +++ b/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch @@ -12,14 +12,11 @@ diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs index 2ed1585..b4b021a 100644 --- a/src/libstd/sys/unix/args.rs +++ b/src/libstd/sys/unix/args.rs -@@ -83,10 +83,7 @@ mod imp { +@@ -83,7 +83,7 @@ mod imp { // On Linux-GNU, we rely on `ARGV_INIT_ARRAY` below to initialize // `ARGC` and `ARGV`. But in Miri that does not actually happen so we // still initialize here. -- #[cfg(any( -- miri, -- not(all(target_os = "linux", target_env = "gnu")) -- ))] +- #[cfg(any(miri, not(all(target_os = "linux", target_env = "gnu"))))] + // `#[link_section]` is not yet supported by cg_clif really_init(_argc, _argv); } From 399cada762d5c2f8cdedb9efa8e7e7fb8059cd85 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Dec 2019 12:40:18 +0100 Subject: [PATCH 1015/1566] Directly depend on cranelift_{codegen,frontend} Fixes #838 --- Cargo.lock | 13 ++----------- Cargo.toml | 6 ++++-- src/abi/mod.rs | 2 ++ src/base.rs | 6 +++--- src/common.rs | 2 +- src/debuginfo/line_info.rs | 4 ++-- src/debuginfo/mod.rs | 10 +++++----- src/intrinsics/mod.rs | 4 ++-- src/lib.rs | 19 +++++++++++-------- src/pointer.rs | 2 +- src/pretty_clif.rs | 6 +++--- src/value_and_place.rs | 6 +++--- 12 files changed, 39 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3e359eac037b..a8432a186f382 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -63,15 +63,6 @@ name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "cranelift" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" -dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", -] - [[package]] name = "cranelift-bforest" version = "0.52.0" @@ -408,8 +399,9 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -568,7 +560,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" diff --git a/Cargo.toml b/Cargo.toml index fc06285c56651..efe56bffdca72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ backend_object = ["object/write", "cranelift-object"] [dependencies] # These have to be in sync with each other -cranelift = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } +cranelift-codegen = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } +cranelift-frontend = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-faerie = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/", optional = true } @@ -35,7 +36,8 @@ features = ["compression", "read", "std"] # We don't need WASM support # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/cranelift/"] -#cranelift = { path = "../cranelift/cranelift-umbrella", default-features = false, features = ["std"] } +#cranelift-codegen = { path = "../cranelift/cranelift-codegen", default-features = false, features = ["std"] } +#cranelift-frontend = { path = "../cranelift/cranelift-frontend", default-features = false, features = ["std"] } #cranelift-module = { path = "../cranelift/cranelift-module" } #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } #cranelift-faerie = { path = "../cranelift/cranelift-faerie" } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 087cced93a348..9911f20655cb4 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -5,6 +5,8 @@ mod returning; use rustc_target::spec::abi::Abi; +use cranelift_codegen::ir::AbiParam; + use self::pass_mode::*; use crate::prelude::*; diff --git a/src/base.rs b/src/base.rs index 8bc5525160dbe..8cb3c2d150e93 100644 --- a/src/base.rs +++ b/src/base.rs @@ -103,11 +103,11 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { let flags = settings::Flags::new(settings::builder()); - match ::cranelift::codegen::verify_function(&func, &flags) { + match ::cranelift_codegen::verify_function(&func, &flags) { Ok(_) => {} Err(err) => { tcx.sess.err(&format!("{:?}", err)); - let pretty_error = ::cranelift::codegen::print_errors::pretty_verifier_error( + let pretty_error = ::cranelift_codegen::print_errors::pretty_verifier_error( &func, None, Some(Box::new(writer)), @@ -195,7 +195,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { targets, } => { let discr = trans_operand(fx, discr).load_scalar(fx); - let mut switch = ::cranelift::frontend::Switch::new(); + let mut switch = ::cranelift_frontend::Switch::new(); for (i, value) in values.iter().enumerate() { let ebb = fx.get_ebb(targets[i]); switch.set_entry(*value as u64, ebb); diff --git a/src/common.rs b/src/common.rs index d0c3385df6c14..9506d4b5224d8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,7 +1,7 @@ use rustc::ty::layout::{Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; -use cranelift::codegen::ir::{InstructionData, Opcode, ValueDef}; +use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use crate::prelude::*; diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index e21b0b026c891..63acb3b4e8fce 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -5,7 +5,7 @@ use crate::prelude::*; use syntax::source_map::FileName; -use cranelift::codegen::binemit::CodeOffset; +use cranelift_codegen::binemit::CodeOffset; use gimli::write::{ Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, UnitEntryId, @@ -104,7 +104,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub(crate) fn create_debug_lines( &mut self, context: &Context, - isa: &dyn cranelift::codegen::isa::TargetIsa, + isa: &dyn cranelift_codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, ) -> CodeOffset { let tcx = self.debug_context.tcx; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 2e40e7c4cadf6..3d4e200f00c9e 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -3,9 +3,9 @@ mod line_info; use crate::prelude::*; -use cranelift::codegen::ir::{StackSlots, ValueLabel, ValueLoc}; -use cranelift::codegen::isa::RegUnit; -use cranelift::codegen::ValueLocRange; +use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; +use cranelift_codegen::isa::RegUnit; +use cranelift_codegen::ValueLocRange; use gimli::write::{ self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, @@ -253,7 +253,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub fn define( &mut self, context: &Context, - isa: &dyn cranelift::codegen::isa::TargetIsa, + isa: &dyn cranelift_codegen::isa::TargetIsa, source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, local_map: HashMap>, ) { @@ -312,7 +312,7 @@ fn place_location<'a, 'tcx>( match cplace.inner() { CPlaceInner::Var(local) => { - let value_label = cranelift::codegen::ir::ValueLabel::from_u32(local.as_u32()); + let value_label = cranelift_codegen::ir::ValueLabel::from_u32(local.as_u32()); if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { let loc_list = LocationList( value_loc_ranges diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index ca10399cb9cb8..2e1584e3efa6e 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -633,7 +633,7 @@ pub fn codegen_intrinsic_call<'tcx>( } _ => panic!("clif_type returned {}", clif_ty), }; - fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), val); } _ => { @@ -670,7 +670,7 @@ pub fn codegen_intrinsic_call<'tcx>( } _ => panic!("clif_type returned {}", clif_ty), }; - fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), val); } CPlaceInner::Addr(_, _) => { diff --git a/src/lib.rs b/src/lib.rs index 7d67de73ae291..9337d07ffc798 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,7 +25,7 @@ use rustc::ty::query::Providers; use rustc::util::common::ErrorReported; use rustc_codegen_utils::codegen_backend::CodegenBackend; -use cranelift::codegen::settings; +use cranelift_codegen::settings; use crate::constant::ConstantCx; use crate::prelude::*; @@ -91,12 +91,15 @@ mod prelude { pub use rustc_codegen_ssa::traits::*; pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; - pub use cranelift::codegen::ir::{ - condcodes::IntCC, function::Function, ExternalName, FuncRef, Inst, SourceLoc, StackSlot, - }; - pub use cranelift::codegen::isa::CallConv; - pub use cranelift::codegen::Context; - pub use cranelift::prelude::*; + pub use cranelift_codegen::Context; + pub use cranelift_codegen::ir::{AbiParam, Ebb, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; + pub use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; + pub use cranelift_codegen::ir::function::Function; + pub use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; + pub use cranelift_codegen::ir::types; + pub use cranelift_codegen::isa::{self, CallConv}; + pub use cranelift_codegen::settings::{self, Configurable}; + pub use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; pub use cranelift_module::{ self, Backend, DataContext, DataId, FuncId, FuncOrDataId, Linkage, Module, }; @@ -283,7 +286,7 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box( ); let mut clif = String::new(); - cranelift::codegen::write::decorate_function( + cranelift_codegen::write::decorate_function( &mut clif_comments, &mut clif, &func, @@ -255,7 +255,7 @@ impl<'a, 'tcx, B: Backend + 'static> fmt::Debug for FunctionCx<'_, 'tcx, B> { writeln!(f, "{:?}", self.local_map)?; let mut clif = String::new(); - ::cranelift::codegen::write::decorate_function( + ::cranelift_codegen::write::decorate_function( &mut &self.clif_comments, &mut clif, &self.bcx.func, diff --git a/src/value_and_place.rs b/src/value_and_place.rs index b1e96d2ce2c08..df59fb8302c71 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use cranelift::codegen::ir::immediates::Offset32; +use cranelift_codegen::ir::immediates::Offset32; fn codegen_field<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, @@ -308,7 +308,7 @@ impl<'tcx> CPlace<'tcx> { match self.inner { CPlaceInner::Var(var) => { let val = fx.bcx.use_var(mir_var(var)); - fx.bcx.set_val_label(val, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); CValue::by_val(val, layout) } CPlaceInner::Addr(ptr, extra) => { @@ -415,7 +415,7 @@ impl<'tcx> CPlace<'tcx> { let to_ptr = match self.inner { CPlaceInner::Var(var) => { let data = from.load_scalar(fx); - fx.bcx.set_val_label(data, cranelift::codegen::ir::ValueLabel::from_u32(var.as_u32())); + fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), data); return; } From 7ff01a4d59779609992aad947264abcc64617917 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Dec 2019 12:44:07 +0100 Subject: [PATCH 1016/1566] Use mir::SourceInfo again in FunctionCx.source_info_set Fixes #800 --- src/common.rs | 5 ++--- src/debuginfo/line_info.rs | 4 ++-- src/debuginfo/mod.rs | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/common.rs b/src/common.rs index 9506d4b5224d8..b14e8af79a8d8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -270,8 +270,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub constants_cx: &'clif mut crate::constant::ConstantCx, pub caches: &'clif mut Caches<'tcx>, - // FIXME switch back to `SourceInfo`, once it derives `Eq` and `Hash` again. - pub source_info_set: indexmap::IndexSet<(Span, mir::SourceScope)>, + pub source_info_set: indexmap::IndexSet, } impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { @@ -350,7 +349,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub fn set_debug_loc(&mut self, source_info: mir::SourceInfo) { - let (index, _) = self.source_info_set.insert_full((source_info.span, source_info.scope)); + let (index, _) = self.source_info_set.insert_full(source_info); self.bcx.set_srcloc(SourceLoc::new(index as u32)); } diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 63acb3b4e8fce..e61bafaa6f10c 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -105,7 +105,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { &mut self, context: &Context, isa: &dyn cranelift_codegen::isa::TargetIsa, - source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, + source_info_set: &indexmap::IndexSet, ) -> CodeOffset { let tcx = self.debug_context.tcx; @@ -147,7 +147,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { line_program.row().address_offset = offset as u64; if !srcloc.is_default() { let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); - create_row_for_span(line_program, source_info.0); + create_row_for_span(line_program, source_info.span); } else { create_row_for_span(line_program, self.mir.span); } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 3d4e200f00c9e..506cbc91c02af 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -254,7 +254,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { &mut self, context: &Context, isa: &dyn cranelift_codegen::isa::TargetIsa, - source_info_set: &indexmap::IndexSet<(Span, mir::SourceScope)>, + source_info_set: &indexmap::IndexSet, local_map: HashMap>, ) { let end = self.create_debug_lines(context, isa, source_info_set); From ca93bcba5dd0936ce0464483771292335cbccac1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Nov 2019 21:15:43 +0100 Subject: [PATCH 1017/1566] Improve lane_type_and_count --- src/intrinsics/llvm.rs | 2 +- src/intrinsics/mod.rs | 19 +++++++++---------- src/intrinsics/simd.rs | 10 +++++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index b281c3d186d26..a59793637d3dc 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -36,7 +36,7 @@ pub fn codegen_llvm_intrinsic_call<'tcx>( // Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8` llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb | llvm.x86.sse2.movmsk.pd, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fx, a.layout(), intrinsic); + let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, a.layout()); let lane_ty = fx.clif_type(lane_layout.ty).unwrap(); assert!(lane_count <= 32); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 2e1584e3efa6e..42eda4b2370a3 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -127,20 +127,19 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ $ret.write_cvalue($fx, ret_val); } -fn lane_type_and_count<'tcx>( - fx: &FunctionCx<'_, 'tcx, impl Backend>, +pub fn lane_type_and_count<'tcx>( + tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>, - intrinsic: &str, ) -> (TyLayout<'tcx>, u32) { assert!(layout.ty.is_simd()); let lane_count = match layout.fields { layout::FieldPlacement::Array { stride: _, count } => u32::try_from(count).unwrap(), - _ => panic!( - "Non vector type {:?} passed to or returned from simd_* intrinsic {}", - layout.ty, intrinsic - ), + _ => unreachable!("lane_type_and_count({:?})", layout), }; - let lane_layout = layout.field(fx, 0); + let lane_layout = layout.field(&ty::layout::LayoutCx { + tcx, + param_env: ParamEnv::reveal_all(), + }, 0).unwrap(); (lane_layout, lane_count) } @@ -161,8 +160,8 @@ fn simd_for_each_lane<'tcx, B: Backend>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fx, layout, intrinsic); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 2b6447de894f3..441fa2d8bdbea 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -21,8 +21,8 @@ pub fn codegen_simd_intrinsic_call<'tcx>( }; simd_cast, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fx, a.layout(), intrinsic); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, a.layout()); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); @@ -65,8 +65,8 @@ pub fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_type, lane_count) = lane_type_and_count(fx, layout, intrinsic); - let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx, ret.layout(), intrinsic); + let (lane_type, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); assert_eq!(lane_type, ret_lane_type); assert_eq!(n, ret_lane_count); @@ -124,7 +124,7 @@ pub fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx, v.layout(), intrinsic); + let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, v.layout()); if idx >= lane_count.into() { fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); } From 2920cc48e6c11208eb2519e0d7687a1794e22829 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 15:48:43 +0100 Subject: [PATCH 1018/1566] Fix SSA analysis for value types with PassMode::ByRef --- src/abi/mod.rs | 2 +- src/abi/returning.rs | 8 ++++++++ src/analyze.rs | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 9911f20655cb4..fc860010813ac 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -10,7 +10,7 @@ use cranelift_codegen::ir::AbiParam; use self::pass_mode::*; use crate::prelude::*; -pub use self::returning::codegen_return; +pub use self::returning::{can_return_to_ssa_var, codegen_return}; // Copied from https://github.com/rust-lang/rust/blob/c2f4c57296f0d929618baed0b0d6eb594abf01eb/src/librustc/ty/layout.rs#L2349 pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { diff --git a/src/abi/returning.rs b/src/abi/returning.rs index d566a51766496..a503c6d795a07 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -5,6 +5,14 @@ fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyLay fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty)) } +pub fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyLayout<'tcx>) -> bool { + match get_pass_mode(tcx, dest_layout) { + PassMode::NoPass | PassMode::ByVal(_) => true, + // FIXME Make it possible to return ByValPair and ByRef to an ssa var. + PassMode::ByValPair(_, _) | PassMode::ByRef => false + } +} + pub fn codegen_return_param( fx: &mut FunctionCx, ssa_analyzed: &rustc_index::vec::IndexVec, diff --git a/src/analyze.rs b/src/analyze.rs index d118665b92bb3..3bebf0ed77724 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -30,6 +30,18 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec {} } } + + match &bb.terminator().kind { + TerminatorKind::Call { destination, .. } => { + if let Some((dest_place, _dest_bb)) = destination { + let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty)); + if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) { + analyze_non_ssa_place(&mut flag_map, dest_place); + } + } + } + _ => {} + } } flag_map From c3daf6d220e5751e2de592b94141cef9d1cca055 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 16:48:43 +0100 Subject: [PATCH 1019/1566] Add clif ir comment for write_cvalue --- src/abi/mod.rs | 1 + src/value_and_place.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index fc860010813ac..cde362e183473 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -329,6 +329,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: .collect::>(); fx.bcx.switch_to_block(start_ebb); + fx.bcx.ins().nop(); #[cfg(debug_assertions)] self::comments::add_locals_header_comment(fx); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index df59fb8302c71..fbc59f2706cfd 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -346,6 +346,19 @@ impl<'tcx> CPlace<'tcx> { } pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { + #[cfg(debug_assertions)] + { + use cranelift_codegen::cursor::{Cursor, CursorPosition}; + let cur_ebb = match fx.bcx.cursor().position() { + CursorPosition::After(ebb) => ebb, + _ => unreachable!(), + }; + fx.add_comment( + fx.bcx.func.layout.last_inst(cur_ebb).unwrap(), + format!("write_cvalue: {:?} <- {:?}",self, from), + ); + } + let from_ty = from.layout().ty; let to_ty = self.layout().ty; From 73fd31129136f1ad204084a51dc6f84f645d3c62 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 Nov 2019 21:29:34 +0100 Subject: [PATCH 1020/1566] [WIP] Real simd support --- src/common.rs | 13 +++++++++++++ src/intrinsics/llvm.rs | 2 +- src/intrinsics/mod.rs | 42 +++++++++++++++++++++++++++++++++++------- src/intrinsics/simd.rs | 21 +++++++-------------- src/value_and_place.rs | 9 ++++++--- 5 files changed, 62 insertions(+), 25 deletions(-) diff --git a/src/common.rs b/src/common.rs index b14e8af79a8d8..41533d9b62069 100644 --- a/src/common.rs +++ b/src/common.rs @@ -66,6 +66,19 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option bug!("ty param {:?}", ty), + _ if ty.is_simd() => { + let (lane_type, lane_count) = crate::intrinsics::lane_type_and_count( + tcx, + tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(), + ); + let lane_type = clif_type_from_ty(tcx, lane_type.ty)?; + let simd_type = lane_type.by(u16::try_from(lane_count).unwrap()); + if simd_type.map(|t| t.bits()) == Some(128) { + return simd_type; + } else { + return None; // Not yet implemented + } + } _ => return None, }) } diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index a59793637d3dc..3e7c99a9ab602 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -86,7 +86,7 @@ pub fn codegen_llvm_intrinsic_call<'tcx>( kind => unreachable!("kind {:?}", kind), }; - simd_for_each_lane(fx, intrinsic, x, y, ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { + simd_pair_for_each_lane(fx, intrinsic, x, y, ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = match lane_layout.ty.kind { ty::Float(_) => fx.bcx.ins().fcmp(flt_cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 42eda4b2370a3..89f5a39f0d6af 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -144,6 +144,34 @@ pub fn lane_type_and_count<'tcx>( } fn simd_for_each_lane<'tcx, B: Backend>( + fx: &mut FunctionCx<'_, 'tcx, B>, + intrinsic: &str, + val: CValue<'tcx>, + ret: CPlace<'tcx>, + f: impl Fn( + &mut FunctionCx<'_, 'tcx, B>, + TyLayout<'tcx>, + TyLayout<'tcx>, + Value, + ) -> CValue<'tcx>, +) { + let layout = val.layout(); + + let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); + assert_eq!(lane_count, ret_lane_count); + + for lane_idx in 0..lane_count { + let lane_idx = mir::Field::new(lane_idx.try_into().unwrap()); + let lane = val.value_field(fx, lane_idx).load_scalar(fx); + + let res_lane = f(fx, lane_layout, ret_lane_layout, lane); + + ret.place_field(fx, lane_idx).write_cvalue(fx, res_lane); + } +} + +fn simd_pair_for_each_lane<'tcx, B: Backend>( fx: &mut FunctionCx<'_, 'tcx, B>, intrinsic: &str, x: CValue<'tcx>, @@ -204,7 +232,7 @@ fn bool_to_zero_or_max_uint<'tcx>( macro simd_cmp { ($fx:expr, $intrinsic:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane( + simd_pair_for_each_lane( $fx, $intrinsic, $x, @@ -220,7 +248,7 @@ macro simd_cmp { ); }, ($fx:expr, $intrinsic:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane( + simd_pair_for_each_lane( $fx, $intrinsic, $x, @@ -240,7 +268,7 @@ macro simd_cmp { macro simd_int_binop { ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane( + simd_pair_for_each_lane( $fx, $intrinsic, $x, @@ -256,7 +284,7 @@ macro simd_int_binop { ); }, ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane( + simd_pair_for_each_lane( $fx, $intrinsic, $x, @@ -276,7 +304,7 @@ macro simd_int_binop { macro simd_int_flt_binop { ($fx:expr, $intrinsic:expr, $op:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane( + simd_pair_for_each_lane( $fx, $intrinsic, $x, @@ -293,7 +321,7 @@ macro simd_int_flt_binop { ); }, ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_for_each_lane( + simd_pair_for_each_lane( $fx, $intrinsic, $x, @@ -313,7 +341,7 @@ macro simd_int_flt_binop { } macro simd_flt_binop($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { - simd_for_each_lane( + simd_pair_for_each_lane( $fx, $intrinsic, $x, diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 441fa2d8bdbea..1dbe1f33c8630 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -21,22 +21,15 @@ pub fn codegen_simd_intrinsic_call<'tcx>( }; simd_cast, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, a.layout()); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); - assert_eq!(lane_count, ret_lane_count); + simd_for_each_lane(fx, intrinsic, a, ret, |fx, lane_layout, ret_lane_layout, lane| { + let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); - let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); + let from_signed = type_sign(lane_layout.ty); + let to_signed = type_sign(ret_lane_layout.ty); - let from_signed = type_sign(lane_layout.ty); - let to_signed = type_sign(ret_lane_layout.ty); - - for lane in 0..lane_count { - let lane = mir::Field::new(lane.try_into().unwrap()); - - let a_lane = a.value_field(fx, lane).load_scalar(fx); - let res = clif_int_or_float_cast(fx, a_lane, from_signed, ret_lane_ty, to_signed); - ret.place_field(fx, lane).write_cvalue(fx, CValue::by_val(res, ret_lane_layout)); - } + let ret_lane = clif_int_or_float_cast(fx, lane, from_signed, ret_lane_ty, to_signed); + CValue::by_val(ret_lane, ret_lane_layout) + }); }; simd_eq, (c x, c y) { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index fbc59f2706cfd..5ae1e9b06afba 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -122,11 +122,14 @@ impl<'tcx> CValue<'tcx> { let layout = self.1; match self.0 { CValueInner::ByRef(ptr) => { - let scalar = match layout.abi { - layout::Abi::Scalar(ref scalar) => scalar.clone(), + let clif_ty = match layout.abi { + layout::Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), + layout::Abi::Vector { ref element, count } => { + scalar_to_clif_type(fx.tcx, element.clone()) + .by(u16::try_from(count).unwrap()).unwrap() + } _ => unreachable!(), }; - let clif_ty = scalar_to_clif_type(fx.tcx, scalar); ptr.load(fx, clif_ty, MemFlags::new()) } CValueInner::ByVal(value) => value, From 78cdcd62be95069569ec75f9c099e7632f1e7e9e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 15:56:03 +0100 Subject: [PATCH 1021/1566] Don't limit vector size --- src/common.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/common.rs b/src/common.rs index 41533d9b62069..6bef21afff212 100644 --- a/src/common.rs +++ b/src/common.rs @@ -72,12 +72,7 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option return None, }) From dadfbeab6c9d09d44f97181e32bec765ecd9b5bb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 15:56:20 +0100 Subject: [PATCH 1022/1566] Don't use stack_{load,store} for vectors --- src/pointer.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pointer.rs b/src/pointer.rs index 7483d4cc6a50e..8ba9582f55468 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -126,8 +126,8 @@ impl Pointer { ) -> Value { match self.base { PointerBase::Addr(base_addr) => fx.bcx.ins().load(ty, flags, base_addr, self.offset), - PointerBase::Stack(stack_slot) => if ty == types::I128 { - // WORKAROUND for stack_load.i128 not being implemented + PointerBase::Stack(stack_slot) => if ty == types::I128 || ty.is_vector() { + // WORKAROUND for stack_load.i128 and stack_load.iXxY not being implemented let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); fx.bcx.ins().load(ty, flags, base_addr, self.offset) } else { @@ -146,12 +146,15 @@ impl Pointer { PointerBase::Addr(base_addr) => { fx.bcx.ins().store(flags, value, base_addr, self.offset); } - PointerBase::Stack(stack_slot) => if fx.bcx.func.dfg.value_type(value) == types::I128 { - // WORKAROUND for stack_load.i128 not being implemented - let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); - fx.bcx.ins().store(flags, value, base_addr, self.offset); - } else { - fx.bcx.ins().stack_store(value, stack_slot, self.offset); + PointerBase::Stack(stack_slot) => { + let val_ty = fx.bcx.func.dfg.value_type(value); + if val_ty == types::I128 || val_ty.is_vector() { + // WORKAROUND for stack_store.i128 and stack_store.iXxY not being implemented + let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); + fx.bcx.ins().store(flags, value, base_addr, self.offset); + } else { + fx.bcx.ins().stack_store(value, stack_slot, self.offset); + } } } } From f8e846dee0cfc0de4a30605df6611855721ca537 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 16:48:19 +0100 Subject: [PATCH 1023/1566] Add load_vector function --- src/common.rs | 8 -------- src/value_and_place.rs | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/common.rs b/src/common.rs index 6bef21afff212..b14e8af79a8d8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -66,14 +66,6 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option bug!("ty param {:?}", ty), - _ if ty.is_simd() => { - let (lane_type, lane_count) = crate::intrinsics::lane_type_and_count( - tcx, - tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(), - ); - let lane_type = clif_type_from_ty(tcx, lane_type.ty)?; - return lane_type.by(u16::try_from(lane_count).unwrap()); - } _ => return None, }) } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 5ae1e9b06afba..1d6e55b913771 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -161,6 +161,24 @@ impl<'tcx> CValue<'tcx> { } } + /// Load a value with layout.abi of vector + pub fn load_vector<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + let layout = self.1; + match self.0 { + CValueInner::ByRef(ptr) => { + let clif_ty = match layout.abi { + layout::Abi::Vector { ref element, count } => { + scalar_to_clif_type(fx.tcx, element.clone()).by(u16::try_from(count).unwrap()).unwrap() + } + _ => unreachable!(), + }; + ptr.load(fx, clif_ty, MemFlags::new()) + } + CValueInner::ByVal(value) => value, + CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), + } + } + pub fn value_field<'a>( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, From 5e984a32d9b8a381d0b7f192f4a915aac59f18db Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 17:11:57 +0100 Subject: [PATCH 1024/1566] Use simd instructions for int and float simd intrinsics --- src/intrinsics/mod.rs | 106 +++++++++++++----------------------------- 1 file changed, 32 insertions(+), 74 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 89f5a39f0d6af..8ce0c87730dcd 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -268,93 +268,51 @@ macro simd_cmp { macro simd_int_binop { ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_pair_for_each_lane( - $fx, - $intrinsic, - $x, - $y, - $ret, - |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { - ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }, - ); + simd_int_binop!($fx, $intrinsic, $op|$op($x, $y) -> $ret); }, ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_pair_for_each_lane( - $fx, - $intrinsic, - $x, - $y, - $ret, - |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { - ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), - ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }, - ); + let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); + let x_val = $x.load_vector($fx); + let y_val = $y.load_vector($fx); + + let res = match lane_layout.ty.kind { + ty::Uint(_) => $fx.bcx.ins().$op_u(x_val, y_val), + ty::Int(_) => $fx.bcx.ins().$op_s(x_val, y_val), + _ => unreachable!("{:?}", lane_layout.ty), + }; + $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); }, } macro simd_int_flt_binop { ($fx:expr, $intrinsic:expr, $op:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_pair_for_each_lane( - $fx, - $intrinsic, - $x, - $y, - $ret, - |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { - ty::Uint(_) | ty::Int(_) => fx.bcx.ins().$op(x_lane, y_lane), - ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }, - ); + simd_int_flt_binop!($fx, $intrinsic, $op|$op|$op_f($x, $y) -> $ret); }, ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_pair_for_each_lane( - $fx, - $intrinsic, - $x, - $y, - $ret, - |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { - ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), - ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), - ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }, - ); + let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); + let x_val = $x.load_vector($fx); + let y_val = $y.load_vector($fx); + + let res = match lane_layout.ty.kind { + ty::Uint(_) => $fx.bcx.ins().$op_u(x_val, y_val), + ty::Int(_) => $fx.bcx.ins().$op_s(x_val, y_val), + ty::Float(_) => $fx.bcx.ins().$op_f(x_val, y_val), + _ => unreachable!("{:?}", lane_layout.ty), + }; + $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); }, } macro simd_flt_binop($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { - simd_pair_for_each_lane( - $fx, - $intrinsic, - $x, - $y, - $ret, - |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { - ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - CValue::by_val(res_lane, ret_lane_layout) - }, - ); + let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); + let x_val = $x.load_vector($fx); + let y_val = $y.load_vector($fx); + + let res = match lane_layout.ty.kind { + ty::Float(_) => $fx.bcx.ins().$op(x_val, y_val), + _ => unreachable!("{:?}", lane_layout.ty), + }; + $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); } pub fn codegen_intrinsic_call<'tcx>( From b35a5da4ea15a826908fc07d0d77ca9ef292ac78 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 17:19:14 +0100 Subject: [PATCH 1025/1566] Remove vector support from load_scalar --- src/value_and_place.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 1d6e55b913771..8593af61edbcc 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -122,14 +122,11 @@ impl<'tcx> CValue<'tcx> { let layout = self.1; match self.0 { CValueInner::ByRef(ptr) => { - let clif_ty = match layout.abi { - layout::Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), - layout::Abi::Vector { ref element, count } => { - scalar_to_clif_type(fx.tcx, element.clone()) - .by(u16::try_from(count).unwrap()).unwrap() - } + let scalar = match layout.abi { + layout::Abi::Scalar(ref scalar) => scalar.clone(), _ => unreachable!(), }; + let clif_ty = scalar_to_clif_type(fx.tcx, scalar); ptr.load(fx, clif_ty, MemFlags::new()) } CValueInner::ByVal(value) => value, From 9eb943648106d674b62f388365de056109a8319c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 17:20:24 +0100 Subject: [PATCH 1026/1566] Fix indentation --- src/intrinsics/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 8ce0c87730dcd..395596eb06237 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -305,14 +305,14 @@ macro simd_int_flt_binop { macro simd_flt_binop($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); - let x_val = $x.load_vector($fx); - let y_val = $y.load_vector($fx); + let x_val = $x.load_vector($fx); + let y_val = $y.load_vector($fx); - let res = match lane_layout.ty.kind { - ty::Float(_) => $fx.bcx.ins().$op(x_val, y_val), - _ => unreachable!("{:?}", lane_layout.ty), - }; - $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); + let res = match lane_layout.ty.kind { + ty::Float(_) => $fx.bcx.ins().$op(x_val, y_val), + _ => unreachable!("{:?}", lane_layout.ty), + }; + $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); } pub fn codegen_intrinsic_call<'tcx>( From 0ebc14cc40ba01ffd7a12920f4582dd44a77a3ed Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 23 Dec 2019 17:25:32 +0100 Subject: [PATCH 1027/1566] Remove unused macro args --- src/intrinsics/mod.rs | 14 +++++++------- src/intrinsics/simd.rs | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 395596eb06237..0128298220607 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -267,10 +267,10 @@ macro simd_cmp { } macro simd_int_binop { - ($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_int_binop!($fx, $intrinsic, $op|$op($x, $y) -> $ret); + ($fx:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_int_binop!($fx, $op|$op($x, $y) -> $ret); }, - ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { + ($fx:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); let x_val = $x.load_vector($fx); let y_val = $y.load_vector($fx); @@ -285,10 +285,10 @@ macro simd_int_binop { } macro simd_int_flt_binop { - ($fx:expr, $intrinsic:expr, $op:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - simd_int_flt_binop!($fx, $intrinsic, $op|$op|$op_f($x, $y) -> $ret); + ($fx:expr, $op:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { + simd_int_flt_binop!($fx, $op|$op|$op_f($x, $y) -> $ret); }, - ($fx:expr, $intrinsic:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { + ($fx:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); let x_val = $x.load_vector($fx); let y_val = $y.load_vector($fx); @@ -303,7 +303,7 @@ macro simd_int_flt_binop { }, } -macro simd_flt_binop($fx:expr, $intrinsic:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { +macro simd_flt_binop($fx:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); let x_val = $x.load_vector($fx); let y_val = $y.load_vector($fx); diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 1dbe1f33c8630..1870192e2241a 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -127,38 +127,38 @@ pub fn codegen_simd_intrinsic_call<'tcx>( }; simd_add, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, iadd|fadd(x, y) -> ret); + simd_int_flt_binop!(fx, iadd|fadd(x, y) -> ret); }; simd_sub, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, isub|fsub(x, y) -> ret); + simd_int_flt_binop!(fx, isub|fsub(x, y) -> ret); }; simd_mul, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, imul|fmul(x, y) -> ret); + simd_int_flt_binop!(fx, imul|fmul(x, y) -> ret); }; simd_div, (c x, c y) { - simd_int_flt_binop!(fx, intrinsic, udiv|sdiv|fdiv(x, y) -> ret); + simd_int_flt_binop!(fx, udiv|sdiv|fdiv(x, y) -> ret); }; simd_shl, (c x, c y) { - simd_int_binop!(fx, intrinsic, ishl(x, y) -> ret); + simd_int_binop!(fx, ishl(x, y) -> ret); }; simd_shr, (c x, c y) { - simd_int_binop!(fx, intrinsic, ushr|sshr(x, y) -> ret); + simd_int_binop!(fx, ushr|sshr(x, y) -> ret); }; simd_and, (c x, c y) { - simd_int_binop!(fx, intrinsic, band(x, y) -> ret); + simd_int_binop!(fx, band(x, y) -> ret); }; simd_or, (c x, c y) { - simd_int_binop!(fx, intrinsic, bor(x, y) -> ret); + simd_int_binop!(fx, bor(x, y) -> ret); }; simd_xor, (c x, c y) { - simd_int_binop!(fx, intrinsic, bxor(x, y) -> ret); + simd_int_binop!(fx, bxor(x, y) -> ret); }; simd_fmin, (c x, c y) { - simd_flt_binop!(fx, intrinsic, fmin(x, y) -> ret); + simd_flt_binop!(fx, fmin(x, y) -> ret); }; simd_fmax, (c x, c y) { - simd_flt_binop!(fx, intrinsic, fmax(x, y) -> ret); + simd_flt_binop!(fx, fmax(x, y) -> ret); }; } } From 30a760dda293b6c7d7266252e22fc0887eb26ed7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 25 Dec 2019 12:38:18 +0100 Subject: [PATCH 1028/1566] Make it possible it use value_field for SIMD values stored ByVal --- src/intrinsics/mod.rs | 12 +++++----- src/value_and_place.rs | 52 ++++++++++++++++++++---------------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 0128298220607..4ba1ae5061677 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -272,8 +272,8 @@ macro simd_int_binop { }, ($fx:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); - let x_val = $x.load_vector($fx); - let y_val = $y.load_vector($fx); + let x_val = $x.load_scalar($fx); + let y_val = $y.load_scalar($fx); let res = match lane_layout.ty.kind { ty::Uint(_) => $fx.bcx.ins().$op_u(x_val, y_val), @@ -290,8 +290,8 @@ macro simd_int_flt_binop { }, ($fx:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); - let x_val = $x.load_vector($fx); - let y_val = $y.load_vector($fx); + let x_val = $x.load_scalar($fx); + let y_val = $y.load_scalar($fx); let res = match lane_layout.ty.kind { ty::Uint(_) => $fx.bcx.ins().$op_u(x_val, y_val), @@ -305,8 +305,8 @@ macro simd_int_flt_binop { macro simd_flt_binop($fx:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); - let x_val = $x.load_vector($fx); - let y_val = $y.load_vector($fx); + let x_val = $x.load_scalar($fx); + let y_val = $y.load_scalar($fx); let res = match lane_layout.ty.kind { ty::Float(_) => $fx.bcx.ins().$op(x_val, y_val), diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 8593af61edbcc..cb23c814b5d2d 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -122,11 +122,14 @@ impl<'tcx> CValue<'tcx> { let layout = self.1; match self.0 { CValueInner::ByRef(ptr) => { - let scalar = match layout.abi { - layout::Abi::Scalar(ref scalar) => scalar.clone(), + let clif_ty = match layout.abi { + layout::Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), + layout::Abi::Vector { ref element, count } => { + scalar_to_clif_type(fx.tcx, element.clone()) + .by(u16::try_from(count).unwrap()).unwrap() + } _ => unreachable!(), }; - let clif_ty = scalar_to_clif_type(fx.tcx, scalar); ptr.load(fx, clif_ty, MemFlags::new()) } CValueInner::ByVal(value) => value, @@ -158,37 +161,32 @@ impl<'tcx> CValue<'tcx> { } } - /// Load a value with layout.abi of vector - pub fn load_vector<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { - let layout = self.1; - match self.0 { - CValueInner::ByRef(ptr) => { - let clif_ty = match layout.abi { - layout::Abi::Vector { ref element, count } => { - scalar_to_clif_type(fx.tcx, element.clone()).by(u16::try_from(count).unwrap()).unwrap() - } - _ => unreachable!(), - }; - ptr.load(fx, clif_ty, MemFlags::new()) - } - CValueInner::ByVal(value) => value, - CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), - } - } - pub fn value_field<'a>( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, ) -> CValue<'tcx> { let layout = self.1; - let ptr = match self.0 { - CValueInner::ByRef(ptr) => ptr, + match self.0 { + CValueInner::ByVal(val) => { + match layout.abi { + layout::Abi::Vector { element: _, count } => { + let count = u8::try_from(count).expect("SIMD type with more than 255 lanes???"); + let field = u8::try_from(field.index()).unwrap(); + assert!(field < count); + let lane = fx.bcx.ins().extractlane(val, field); + let field_layout = layout.field(&*fx, usize::from(field)); + CValue::by_val(lane, field_layout) + } + _ => unreachable!("value_field for ByVal with abi {:?}", layout.abi), + } + } + CValueInner::ByRef(ptr) => { + let (field_ptr, field_layout) = codegen_field(fx, ptr, None, layout, field); + CValue::by_ref(field_ptr, field_layout) + } _ => bug!("place_field for {:?}", self), - }; - - let (field_ptr, field_layout) = codegen_field(fx, ptr, None, layout, field); - CValue::by_ref(field_ptr, field_layout) + } } pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { From 8bf5cd345edf85080ff831eed1b63ac2a8906a04 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 10:57:49 +0100 Subject: [PATCH 1029/1566] Rustup to rustc 1.42.0-nightly (74c4e6a98 2019-12-27) --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index f63a5021d1e56..8621209765fb9 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -162,7 +162,7 @@ fn trans_const_place<'tcx>( ecx.copy_op(op, ptr.into())?; let alloc = ecx .memory - .get_raw(ptr.to_ref().to_scalar()?.to_ptr()?.alloc_id)?; + .get_raw(ptr.to_ref().to_scalar()?.assert_ptr().alloc_id)?; Ok(fx.tcx.intern_const_alloc(alloc.clone())) }; let alloc = result().expect("unable to convert ConstKind to Allocation"); From 958c58545f0fa8753e8ba978174dc55b577fa605 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 11:10:21 +0100 Subject: [PATCH 1030/1566] Only codegen a trap for functions with uninhabited arguments Fixes #847 --- src/base.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 8cb3c2d150e93..6fc4f2ecddbff 100644 --- a/src/base.rs +++ b/src/base.rs @@ -54,8 +54,15 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( source_info_set: indexmap::IndexSet::new(), }; - crate::abi::codegen_fn_prelude(&mut fx, start_ebb); - codegen_fn_content(&mut fx); + if fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()) { + let entry_block = fx.bcx.create_ebb(); + fx.bcx.append_ebb_params_for_function_params(entry_block); + fx.bcx.switch_to_block(entry_block); + crate::trap::trap_unreachable(&mut fx, "function has uninhabited argument"); + } else { + crate::abi::codegen_fn_prelude(&mut fx, start_ebb); + codegen_fn_content(&mut fx); + } // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; From 50d749770836ddb001944eb3ffa37675881c48e8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 12:13:04 +0100 Subject: [PATCH 1031/1566] Write scalars separately for Abi::ScalarPair in write_cvalue This makes it easier to perform store to load forwarding --- src/value_and_place.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index cb23c814b5d2d..17beb96b1d202 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -458,21 +458,33 @@ impl<'tcx> CPlace<'tcx> { CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self), }; + match self.layout().abi { + // FIXME make Abi::Vector work too + Abi::Scalar(_) => { + let val = from.load_scalar(fx); + to_ptr.store(fx, val, MemFlags::new()); + return; + } + Abi::ScalarPair(ref a_scalar, ref b_scalar) => { + let (value, extra) = from.load_scalar_pair(fx); + let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); + to_ptr.store(fx, value, MemFlags::new()); + to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); + return; + } + _ => {} + } + match from.0 { CValueInner::ByVal(val) => { to_ptr.store(fx, val, MemFlags::new()); } - CValueInner::ByValPair(value, extra) => match dst_layout.abi { - Abi::ScalarPair(ref a_scalar, ref b_scalar) => { - let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); - to_ptr.store(fx, value, MemFlags::new()); - to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); - } - _ => bug!( + CValueInner::ByValPair(value, extra) => { + bug!( "Non ScalarPair abi {:?} for ByValPair CValue", dst_layout.abi - ), - }, + ); + } CValueInner::ByRef(from_ptr) => { let from_addr = from_ptr.get_addr(fx); let to_addr = to_ptr.get_addr(fx); From 7e6d533af2f2210a65fdddcb0cb1fdfad2d9391f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 15:47:58 +0100 Subject: [PATCH 1032/1566] Rustup to rustc 1.42.0-nightly (a9dd56ff9 2019-12-30) --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 9337d07ffc798..b01659eeb36ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,6 @@ extern crate rustc_index; extern crate rustc_mir; extern crate rustc_target; extern crate syntax; -extern crate syntax_expand; use std::any::Any; From 7564a043d0349df2d92bc4962f1c824c4cee09d0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 15:53:18 +0100 Subject: [PATCH 1033/1566] Fix some warnings --- src/intrinsics/llvm.rs | 2 +- src/intrinsics/mod.rs | 8 ++------ src/intrinsics/simd.rs | 14 +++++++------- src/value_and_place.rs | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index 3e7c99a9ab602..5b3deb52baade 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -86,7 +86,7 @@ pub fn codegen_llvm_intrinsic_call<'tcx>( kind => unreachable!("kind {:?}", kind), }; - simd_pair_for_each_lane(fx, intrinsic, x, y, ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { + simd_pair_for_each_lane(fx, x, y, ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = match lane_layout.ty.kind { ty::Float(_) => fx.bcx.ins().fcmp(flt_cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 4ba1ae5061677..e17c38a8ef794 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -145,7 +145,6 @@ pub fn lane_type_and_count<'tcx>( fn simd_for_each_lane<'tcx, B: Backend>( fx: &mut FunctionCx<'_, 'tcx, B>, - intrinsic: &str, val: CValue<'tcx>, ret: CPlace<'tcx>, f: impl Fn( @@ -173,7 +172,6 @@ fn simd_for_each_lane<'tcx, B: Backend>( fn simd_pair_for_each_lane<'tcx, B: Backend>( fx: &mut FunctionCx<'_, 'tcx, B>, - intrinsic: &str, x: CValue<'tcx>, y: CValue<'tcx>, ret: CPlace<'tcx>, @@ -231,10 +229,9 @@ fn bool_to_zero_or_max_uint<'tcx>( } macro simd_cmp { - ($fx:expr, $intrinsic:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { + ($fx:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { simd_pair_for_each_lane( $fx, - $intrinsic, $x, $y, $ret, @@ -247,10 +244,9 @@ macro simd_cmp { }, ); }, - ($fx:expr, $intrinsic:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { + ($fx:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { simd_pair_for_each_lane( $fx, - $intrinsic, $x, $y, $ret, diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 1870192e2241a..17b6f230c88ad 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -21,7 +21,7 @@ pub fn codegen_simd_intrinsic_call<'tcx>( }; simd_cast, (c a) { - simd_for_each_lane(fx, intrinsic, a, ret, |fx, lane_layout, ret_lane_layout, lane| { + simd_for_each_lane(fx, a, ret, |fx, lane_layout, ret_lane_layout, lane| { let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); let from_signed = type_sign(lane_layout.ty); @@ -33,22 +33,22 @@ pub fn codegen_simd_intrinsic_call<'tcx>( }; simd_eq, (c x, c y) { - simd_cmp!(fx, intrinsic, Equal(x, y) -> ret); + simd_cmp!(fx, Equal(x, y) -> ret); }; simd_ne, (c x, c y) { - simd_cmp!(fx, intrinsic, NotEqual(x, y) -> ret); + simd_cmp!(fx, NotEqual(x, y) -> ret); }; simd_lt, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedLessThan|SignedLessThan(x, y) -> ret); + simd_cmp!(fx, UnsignedLessThan|SignedLessThan(x, y) -> ret); }; simd_le, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedLessThanOrEqual|SignedLessThanOrEqual(x, y) -> ret); + simd_cmp!(fx, UnsignedLessThanOrEqual|SignedLessThanOrEqual(x, y) -> ret); }; simd_gt, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedGreaterThan|SignedGreaterThan(x, y) -> ret); + simd_cmp!(fx, UnsignedGreaterThan|SignedGreaterThan(x, y) -> ret); }; simd_ge, (c x, c y) { - simd_cmp!(fx, intrinsic, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret); + simd_cmp!(fx, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret); }; // simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 17beb96b1d202..39eb7d2470744 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -479,7 +479,7 @@ impl<'tcx> CPlace<'tcx> { CValueInner::ByVal(val) => { to_ptr.store(fx, val, MemFlags::new()); } - CValueInner::ByValPair(value, extra) => { + CValueInner::ByValPair(_, _) => { bug!( "Non ScalarPair abi {:?} for ByValPair CValue", dst_layout.abi From 8b82f4f9898d317e16dcfaec9191ad9bfde74639 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 26 Dec 2019 13:37:10 +0100 Subject: [PATCH 1034/1566] [WIP] Add stack2reg optimization pass --- example/mini_core.rs | 4 + src/base.rs | 8 +- src/lib.rs | 1 + src/optimize/mod.rs | 15 +++ src/optimize/stack2reg.rs | 222 ++++++++++++++++++++++++++++++++++++++ src/value_and_place.rs | 13 --- test.sh | 15 +-- 7 files changed, 256 insertions(+), 22 deletions(-) create mode 100644 src/optimize/mod.rs create mode 100644 src/optimize/stack2reg.rs diff --git a/example/mini_core.rs b/example/mini_core.rs index 1912cc50a218e..f649c945c0590 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -394,6 +394,10 @@ pub trait FnMut: FnOnce { #[lang = "panic"] pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! { + panic_inner(&_msg); +} + +pub fn panic_inner(_msg: &&str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort(); diff --git a/src/base.rs b/src/base.rs index 6fc4f2ecddbff..a59231141095b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -66,7 +66,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; - let clif_comments = fx.clif_comments; + let mut clif_comments = fx.clif_comments; let source_info_set = fx.source_info_set; let local_map = fx.local_map; @@ -76,6 +76,8 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Verify function verify_func(tcx, &clif_comments, &func); + crate::optimize::optimize_function(cx.tcx, instance, &mut func, &mut clif_comments); + // Define function let context = &mut cx.caches.context; context.func = func; @@ -108,7 +110,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( context.clear(); } -fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { +pub fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { let flags = settings::Flags::new(settings::builder()); match ::cranelift_codegen::verify_function(&func, &flags) { Ok(_) => {} @@ -265,7 +267,7 @@ fn trans_stmt<'tcx>( fx.set_debug_loc(stmt.source_info); - #[cfg(debug_assertions)] + #[cfg(false_debug_assertions)] match &stmt.kind { StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful _ => { diff --git a/src/lib.rs b/src/lib.rs index b01659eeb36ed..02cfe160370e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,6 +47,7 @@ mod linkage; mod main_shim; mod metadata; mod num; +mod optimize; mod pointer; mod pretty_clif; mod target_features_whitelist; diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs new file mode 100644 index 0000000000000..f1ced869d26dc --- /dev/null +++ b/src/optimize/mod.rs @@ -0,0 +1,15 @@ +use crate::prelude::*; + +mod stack2reg; + +pub fn optimize_function<'tcx>( + tcx: TyCtxt<'tcx>, + instance: Instance<'tcx>, + func: &mut Function, + clif_comments: &mut crate::pretty_clif::CommentWriter, +) { + self::stack2reg::optimize_function(func, clif_comments, format!("{:?}", instance)); + #[cfg(debug_assertions)] + crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &*func, &*clif_comments, None); + crate::base::verify_func(tcx, &*clif_comments, &*func); +} diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs new file mode 100644 index 0000000000000..1737696c13e3d --- /dev/null +++ b/src/optimize/stack2reg.rs @@ -0,0 +1,222 @@ +use cranelift_codegen::cursor::{Cursor, FuncCursor}; +use cranelift_codegen::ir::{Opcode, InstructionData, ValueDef}; +use cranelift_codegen::ir::immediates::Offset32; +use cranelift_codegen::entity::SecondaryMap; + +use crate::prelude::*; + +pub(super) fn optimize_function( + func: &mut Function, + clif_comments: &mut crate::pretty_clif::CommentWriter, + name: String, // FIXME remove +) { + let mut stack_addr_insts = SecondaryMap::new(); + let mut stack_load_store_insts = SecondaryMap::new(); + + let mut cursor = FuncCursor::new(func); + while let Some(_ebb) = cursor.next_ebb() { + while let Some(inst) = cursor.next_inst() { + match cursor.func.dfg[inst] { + // Record all stack_addr, stack_load and stack_store instructions. + InstructionData::StackLoad { + opcode: Opcode::StackAddr, + stack_slot: _, + offset: _, + } => { + stack_addr_insts[inst] = true; + } + InstructionData::StackLoad { + opcode: Opcode::StackLoad, + stack_slot: _, + offset: _, + } => { + stack_load_store_insts[inst] = true; + } + InstructionData::StackStore { + opcode: Opcode::StackStore, + arg: _, + stack_slot: _, + offset: _, + } => { + stack_load_store_insts[inst] = true; + } + + // Turn load and store into stack_load and stack_store when possible. + InstructionData::Load { opcode: Opcode::Load, arg: addr, flags: _, offset } => { + if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { + continue; // WORKAROUD: stack_load.i128 not yet implemented + } + if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { + if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { + let ty = cursor.func.dfg.ctrl_typevar(inst); + cursor.func.dfg.replace(inst).stack_load(ty, stack_slot, combined_offset); + stack_load_store_insts[inst] = true; + } + } + } + InstructionData::Store { opcode: Opcode::Store, args: [value, addr], flags: _, offset } => { + if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { + continue; // WORKAROUND: stack_store.i128 not yet implemented + } + if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { + if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { + cursor.func.dfg.replace(inst).stack_store(value, stack_slot, combined_offset); + stack_load_store_insts[inst] = true; + } + } + } + _ => {} + } + } + } + + let mut used_stack_addr_insts = SecondaryMap::new(); + + let mut cursor = FuncCursor::new(func); + while let Some(_ebb) = cursor.next_ebb() { + while let Some(inst) = cursor.next_inst() { + for &arg in cursor.func.dfg.inst_args(inst) { + if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { + if cursor.func.dfg[arg_origin].opcode() == Opcode::StackAddr { + used_stack_addr_insts[arg_origin] = true; + } + } + } + } + } + + /*println!( + "stack_addr: [{}] ([{}] used)\nstack_load/stack_store: [{}]", + bool_secondary_map_to_string(&stack_addr_insts), + bool_secondary_map_to_string(&used_stack_addr_insts), + bool_secondary_map_to_string(&stack_load_store_insts), + );*/ + + for inst in used_stack_addr_insts.keys().filter(|&inst| used_stack_addr_insts[inst]) { + assert!(stack_addr_insts[inst]); + } + + // Replace all unused stack_addr instructions with nop. + for inst in stack_addr_insts.keys() { + if stack_addr_insts[inst] && !used_stack_addr_insts[inst] { + func.dfg.detach_results(inst); + func.dfg.replace(inst).nop(); + stack_addr_insts[inst] = false; + } + } + + //println!("stack_addr (after): [{}]", bool_secondary_map_to_string(&stack_addr_insts)); + + let mut stack_slot_usage_map: SecondaryMap> = SecondaryMap::new(); + for inst in stack_load_store_insts.keys().filter(|&inst| stack_load_store_insts[inst]) { + match func.dfg[inst] { + InstructionData::StackLoad { + opcode: Opcode::StackLoad, + stack_slot, + offset: _, + } => { + stack_slot_usage_map[stack_slot].insert(inst); + } + InstructionData::StackStore { + opcode: Opcode::StackStore, + arg: _, + stack_slot, + offset: _, + } => { + stack_slot_usage_map[stack_slot].insert(inst); + } + ref data => unreachable!("{:?}", data), + } + } + for inst in stack_addr_insts.keys().filter(|&inst| stack_addr_insts[inst]) { + match func.dfg[inst] { + InstructionData::StackLoad { + opcode: Opcode::StackAddr, + stack_slot, + offset: _, + } => { + stack_slot_usage_map[stack_slot].insert(inst); + } + ref data => unreachable!("{:?}", data), + } + } + + //println!("{:?}\n", stack_slot_usage_map); + + for (stack_slot, users) in stack_slot_usage_map.iter_mut() { + let mut is_addr_leaked = false; + let mut is_loaded = false; + let mut is_stored = false; + for &user in users.iter() { + match func.dfg[user] { + InstructionData::StackLoad { + opcode: Opcode::StackAddr, + stack_slot, + offset: _, + } => { + is_addr_leaked = true; + } + InstructionData::StackLoad { + opcode: Opcode::StackLoad, + stack_slot, + offset: _, + } => { + is_loaded = true; + } + InstructionData::StackStore { + opcode: Opcode::StackStore, + arg: _, + stack_slot, + offset: _, + } => { + is_stored = true; + } + ref data => unreachable!("{:?}", data), + } + } + + if is_addr_leaked || (is_loaded && is_stored) { + continue; + } + + if is_loaded { + println!("[{}] [BUG?] Reading uninitialized memory", name); + } else { + // Stored value never read; just remove reads. + for &user in users.iter() { + println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot); + func.dfg.replace(user).nop(); + } + } + } +} + +fn try_get_stack_slot_and_offset_for_addr(func: &Function, addr: Value) -> Option<(StackSlot, Offset32)> { + if let ValueDef::Result(addr_inst, 0) = func.dfg.value_def(addr) { + if let InstructionData::StackLoad { + opcode: Opcode::StackAddr, + stack_slot, + offset, + } = func.dfg[addr_inst] { + return Some((stack_slot, offset)); + } + } + None +} + +fn bool_secondary_map_to_string(map: &SecondaryMap) -> String + where E: cranelift_codegen::entity::EntityRef + std::fmt::Display, +{ + map + .keys() + .filter_map(|inst| { + // EntitySet::keys returns all possible entities until the last entity inserted. + if map[inst] { + Some(format!("{}", inst)) + } else { + None + } + }) + .collect::>() + .join(", ") +} diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 39eb7d2470744..6f0c615c9502a 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -362,19 +362,6 @@ impl<'tcx> CPlace<'tcx> { } pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { - #[cfg(debug_assertions)] - { - use cranelift_codegen::cursor::{Cursor, CursorPosition}; - let cur_ebb = match fx.bcx.cursor().position() { - CursorPosition::After(ebb) => ebb, - _ => unreachable!(), - }; - fx.add_comment( - fx.bcx.func.layout.last_inst(cur_ebb).unwrap(), - format!("write_cvalue: {:?} <- {:?}",self, from), - ); - } - let from_ty = from.layout().ty; let to_ty = self.layout().ty; diff --git a/test.sh b/test.sh index e502a20db5bef..98171bc0f6a3e 100755 --- a/test.sh +++ b/test.sh @@ -4,10 +4,10 @@ set -e if [[ "$1" == "--release" ]]; then export CHANNEL='release' - cargo build --release $CG_CLIF_COMPILE_FLAGS + cargo rustc --release $CG_CLIF_COMPILE_FLAGS -- -Clink-args=-fuse-ld=lld else export CHANNEL='debug' - cargo build $CG_CLIF_COMPILE_FLAGS + cargo rustc $CG_CLIF_COMPILE_FLAGS -- -Clink-args=-fuse-ld=lld fi source config.sh @@ -28,6 +28,8 @@ mkdir -p target/out/clif echo "[BUILD] mini_core" $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib +#exit 1 + echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib @@ -69,15 +71,16 @@ $RUSTC example/mod_bench.rs --crate-type bin pushd simple-raytracer echo "[BENCH COMPILE] ebobby/simple-raytracer" -hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \ - "RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \ - "../cargo.sh build" +rm -r target/x86_64*/ +../cargo.sh build echo "[BENCH RUN] ebobby/simple-raytracer" cp ./target/*/debug/main ./raytracer_cg_clif -hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif +hyperfine --runs ${RUN_RUNS:-10} ./raytracer_* popd +exit 1 + pushd build_sysroot/sysroot_src/src/libcore/tests rm -r ./target || true ../../../../../cargo.sh test From b6642e5cd8766c2bd8b6af616529c9ce28722931 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 14:55:11 +0100 Subject: [PATCH 1035/1566] Re-order some code --- src/optimize/stack2reg.rs | 88 ++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 38 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 1737696c13e3d..4840ef7b0596d 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -10,38 +10,11 @@ pub(super) fn optimize_function( clif_comments: &mut crate::pretty_clif::CommentWriter, name: String, // FIXME remove ) { - let mut stack_addr_insts = SecondaryMap::new(); - let mut stack_load_store_insts = SecondaryMap::new(); - + // Turn load and store into stack_load and stack_store when possible. let mut cursor = FuncCursor::new(func); while let Some(_ebb) = cursor.next_ebb() { while let Some(inst) = cursor.next_inst() { match cursor.func.dfg[inst] { - // Record all stack_addr, stack_load and stack_store instructions. - InstructionData::StackLoad { - opcode: Opcode::StackAddr, - stack_slot: _, - offset: _, - } => { - stack_addr_insts[inst] = true; - } - InstructionData::StackLoad { - opcode: Opcode::StackLoad, - stack_slot: _, - offset: _, - } => { - stack_load_store_insts[inst] = true; - } - InstructionData::StackStore { - opcode: Opcode::StackStore, - arg: _, - stack_slot: _, - offset: _, - } => { - stack_load_store_insts[inst] = true; - } - - // Turn load and store into stack_load and stack_store when possible. InstructionData::Load { opcode: Opcode::Load, arg: addr, flags: _, offset } => { if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { continue; // WORKAROUD: stack_load.i128 not yet implemented @@ -50,7 +23,6 @@ pub(super) fn optimize_function( if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { let ty = cursor.func.dfg.ctrl_typevar(inst); cursor.func.dfg.replace(inst).stack_load(ty, stack_slot, combined_offset); - stack_load_store_insts[inst] = true; } } } @@ -61,7 +33,6 @@ pub(super) fn optimize_function( if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { cursor.func.dfg.replace(inst).stack_store(value, stack_slot, combined_offset); - stack_load_store_insts[inst] = true; } } } @@ -70,27 +41,63 @@ pub(super) fn optimize_function( } } + // Record all stack_addr, stack_load and stack_store instructions. Also record all stack_addr + // and stack_load insts whose result is used. + let mut stack_addr_insts = SecondaryMap::new(); let mut used_stack_addr_insts = SecondaryMap::new(); + let mut stack_load_insts = SecondaryMap::new(); + let mut used_stack_load_insts = SecondaryMap::new(); + let mut stack_store_insts = SecondaryMap::new(); let mut cursor = FuncCursor::new(func); while let Some(_ebb) = cursor.next_ebb() { while let Some(inst) = cursor.next_inst() { + match cursor.func.dfg[inst] { + InstructionData::StackLoad { + opcode: Opcode::StackAddr, + stack_slot: _, + offset: _, + } => { + stack_addr_insts[inst] = true; + } + InstructionData::StackLoad { + opcode: Opcode::StackLoad, + stack_slot: _, + offset: _, + } => { + stack_load_insts[inst] = true; + } + InstructionData::StackStore { + opcode: Opcode::StackStore, + arg: _, + stack_slot: _, + offset: _, + } => { + stack_store_insts[inst] = true; + } + _ => {} + } + for &arg in cursor.func.dfg.inst_args(inst) { if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { - if cursor.func.dfg[arg_origin].opcode() == Opcode::StackAddr { - used_stack_addr_insts[arg_origin] = true; + match cursor.func.dfg[arg_origin].opcode() { + Opcode::StackAddr => used_stack_addr_insts[arg_origin] = true, + Opcode::StackLoad => used_stack_load_insts[arg_origin] = true, + _ => {} } } } } } - /*println!( - "stack_addr: [{}] ([{}] used)\nstack_load/stack_store: [{}]", + println!( + "stack_addr: [{}] ([{}] used)\nstack_load: [{}] ([{}] used)\nstack_store: [{}]", bool_secondary_map_to_string(&stack_addr_insts), bool_secondary_map_to_string(&used_stack_addr_insts), - bool_secondary_map_to_string(&stack_load_store_insts), - );*/ + bool_secondary_map_to_string(&stack_load_insts), + bool_secondary_map_to_string(&used_stack_load_insts), + bool_secondary_map_to_string(&stack_store_insts), + ); for inst in used_stack_addr_insts.keys().filter(|&inst| used_stack_addr_insts[inst]) { assert!(stack_addr_insts[inst]); @@ -108,7 +115,7 @@ pub(super) fn optimize_function( //println!("stack_addr (after): [{}]", bool_secondary_map_to_string(&stack_addr_insts)); let mut stack_slot_usage_map: SecondaryMap> = SecondaryMap::new(); - for inst in stack_load_store_insts.keys().filter(|&inst| stack_load_store_insts[inst]) { + for inst in stack_load_insts.keys().filter(|&inst| stack_load_insts[inst]) { match func.dfg[inst] { InstructionData::StackLoad { opcode: Opcode::StackLoad, @@ -117,6 +124,11 @@ pub(super) fn optimize_function( } => { stack_slot_usage_map[stack_slot].insert(inst); } + ref data => unreachable!("{:?}", data), + } + } + for inst in stack_store_insts.keys().filter(|&inst| stack_store_insts[inst]) { + match func.dfg[inst] { InstructionData::StackStore { opcode: Opcode::StackStore, arg: _, @@ -141,7 +153,7 @@ pub(super) fn optimize_function( } } - //println!("{:?}\n", stack_slot_usage_map); + println!("{:?}\n", stack_slot_usage_map); for (stack_slot, users) in stack_slot_usage_map.iter_mut() { let mut is_addr_leaked = false; From 73961709d623cc46ec39458f46a7173e189cda66 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 15:02:10 +0100 Subject: [PATCH 1036/1566] Outline combine_stack_addr_with_load_store and remove unused stack_load insts --- src/optimize/stack2reg.rs | 78 ++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 4840ef7b0596d..d44e5b706bcdf 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -10,36 +10,7 @@ pub(super) fn optimize_function( clif_comments: &mut crate::pretty_clif::CommentWriter, name: String, // FIXME remove ) { - // Turn load and store into stack_load and stack_store when possible. - let mut cursor = FuncCursor::new(func); - while let Some(_ebb) = cursor.next_ebb() { - while let Some(inst) = cursor.next_inst() { - match cursor.func.dfg[inst] { - InstructionData::Load { opcode: Opcode::Load, arg: addr, flags: _, offset } => { - if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { - continue; // WORKAROUD: stack_load.i128 not yet implemented - } - if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { - if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { - let ty = cursor.func.dfg.ctrl_typevar(inst); - cursor.func.dfg.replace(inst).stack_load(ty, stack_slot, combined_offset); - } - } - } - InstructionData::Store { opcode: Opcode::Store, args: [value, addr], flags: _, offset } => { - if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { - continue; // WORKAROUND: stack_store.i128 not yet implemented - } - if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { - if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { - cursor.func.dfg.replace(inst).stack_store(value, stack_slot, combined_offset); - } - } - } - _ => {} - } - } - } + combine_stack_addr_with_load_store(func); // Record all stack_addr, stack_load and stack_store instructions. Also record all stack_addr // and stack_load insts whose result is used. @@ -112,6 +83,20 @@ pub(super) fn optimize_function( } } + for inst in used_stack_load_insts.keys().filter(|&inst| used_stack_load_insts[inst]) { + assert!(stack_load_insts[inst]); + } + + // Replace all unused stack_load instructions with nop. + for inst in stack_load_insts.keys() { + if stack_load_insts[inst] && !used_stack_load_insts[inst] { + func.dfg.detach_results(inst); + func.dfg.replace(inst).nop(); + stack_load_insts[inst] = false; + } + } + + //println!("stack_addr (after): [{}]", bool_secondary_map_to_string(&stack_addr_insts)); let mut stack_slot_usage_map: SecondaryMap> = SecondaryMap::new(); @@ -203,6 +188,39 @@ pub(super) fn optimize_function( } } +fn combine_stack_addr_with_load_store(func: &mut Function) { + // Turn load and store into stack_load and stack_store when possible. + let mut cursor = FuncCursor::new(func); + while let Some(_ebb) = cursor.next_ebb() { + while let Some(inst) = cursor.next_inst() { + match cursor.func.dfg[inst] { + InstructionData::Load { opcode: Opcode::Load, arg: addr, flags: _, offset } => { + if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { + continue; // WORKAROUD: stack_load.i128 not yet implemented + } + if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { + if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { + let ty = cursor.func.dfg.ctrl_typevar(inst); + cursor.func.dfg.replace(inst).stack_load(ty, stack_slot, combined_offset); + } + } + } + InstructionData::Store { opcode: Opcode::Store, args: [value, addr], flags: _, offset } => { + if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { + continue; // WORKAROUND: stack_store.i128 not yet implemented + } + if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { + if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { + cursor.func.dfg.replace(inst).stack_store(value, stack_slot, combined_offset); + } + } + } + _ => {} + } + } + } +} + fn try_get_stack_slot_and_offset_for_addr(func: &Function, addr: Value) -> Option<(StackSlot, Offset32)> { if let ValueDef::Result(addr_inst, 0) = func.dfg.value_def(addr) { if let InstructionData::StackLoad { From c84b1fee0980493a65880234c96577985fa193e3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 15:14:42 +0100 Subject: [PATCH 1037/1566] Record users of stack_addr and stack_load return values --- src/optimize/stack2reg.rs | 50 +++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index d44e5b706bcdf..2951cd76ef249 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -1,3 +1,5 @@ +use std::collections::HashSet; + use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::ir::{Opcode, InstructionData, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; @@ -15,9 +17,9 @@ pub(super) fn optimize_function( // Record all stack_addr, stack_load and stack_store instructions. Also record all stack_addr // and stack_load insts whose result is used. let mut stack_addr_insts = SecondaryMap::new(); - let mut used_stack_addr_insts = SecondaryMap::new(); + let mut stack_addr_insts_users = SecondaryMap::>::new(); let mut stack_load_insts = SecondaryMap::new(); - let mut used_stack_load_insts = SecondaryMap::new(); + let mut stack_load_insts_users = SecondaryMap::>::new(); let mut stack_store_insts = SecondaryMap::new(); let mut cursor = FuncCursor::new(func); @@ -52,8 +54,12 @@ pub(super) fn optimize_function( for &arg in cursor.func.dfg.inst_args(inst) { if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { match cursor.func.dfg[arg_origin].opcode() { - Opcode::StackAddr => used_stack_addr_insts[arg_origin] = true, - Opcode::StackLoad => used_stack_load_insts[arg_origin] = true, + Opcode::StackAddr => { + stack_addr_insts_users[arg_origin].insert(inst); + } + Opcode::StackLoad => { + stack_load_insts_users[arg_origin].insert(inst); + } _ => {} } } @@ -62,34 +68,35 @@ pub(super) fn optimize_function( } println!( - "stack_addr: [{}] ([{}] used)\nstack_load: [{}] ([{}] used)\nstack_store: [{}]", + "{}:\nstack_addr: [{}] ({{{}}} used)\nstack_load: [{}] ([{{{}}}] used)\nstack_store: [{}]", + name, bool_secondary_map_to_string(&stack_addr_insts), - bool_secondary_map_to_string(&used_stack_addr_insts), + usage_secondary_map_to_string(&stack_addr_insts_users), bool_secondary_map_to_string(&stack_load_insts), - bool_secondary_map_to_string(&used_stack_load_insts), + usage_secondary_map_to_string(&stack_load_insts_users), bool_secondary_map_to_string(&stack_store_insts), ); - for inst in used_stack_addr_insts.keys().filter(|&inst| used_stack_addr_insts[inst]) { + for inst in stack_addr_insts_users.keys().filter(|&inst| !stack_addr_insts_users[inst].is_empty()) { assert!(stack_addr_insts[inst]); } // Replace all unused stack_addr instructions with nop. for inst in stack_addr_insts.keys() { - if stack_addr_insts[inst] && !used_stack_addr_insts[inst] { + if stack_addr_insts[inst] && stack_addr_insts_users[inst].is_empty() { func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); stack_addr_insts[inst] = false; } } - for inst in used_stack_load_insts.keys().filter(|&inst| used_stack_load_insts[inst]) { + for inst in stack_load_insts_users.keys().filter(|&inst| !stack_load_insts_users[inst].is_empty()) { assert!(stack_load_insts[inst]); } // Replace all unused stack_load instructions with nop. for inst in stack_load_insts.keys() { - if stack_load_insts[inst] && !used_stack_load_insts[inst] { + if stack_load_insts[inst] && !stack_addr_insts_users[inst].is_empty() { func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); stack_load_insts[inst] = false; @@ -138,7 +145,7 @@ pub(super) fn optimize_function( } } - println!("{:?}\n", stack_slot_usage_map); + println!("stack slot usage: {{{}}}", usage_secondary_map_to_string(&stack_slot_usage_map)); for (stack_slot, users) in stack_slot_usage_map.iter_mut() { let mut is_addr_leaked = false; @@ -186,6 +193,8 @@ pub(super) fn optimize_function( } } } + + println!(); } fn combine_stack_addr_with_load_store(func: &mut Function) { @@ -250,3 +259,20 @@ fn bool_secondary_map_to_string(map: &SecondaryMap) -> String .collect::>() .join(", ") } + +fn usage_secondary_map_to_string(map: &SecondaryMap>) -> String + where E: cranelift_codegen::entity::EntityRef + std::fmt::Display, +{ + map + .keys() + .filter_map(|inst| { + // EntitySet::keys returns all possible entities until the last entity inserted. + if !map[inst].is_empty() { + Some(format!("{}: {:?}", inst, map[inst])) + } else { + None + } + }) + .collect::>() + .join(", ") +} From 5047856f00ebdd1accec01e629d23164a1557645 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 15:40:44 +0100 Subject: [PATCH 1038/1566] Use BTreeSet and BTreeMap instead of SecondaryMap --- src/optimize/stack2reg.rs | 125 ++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 71 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 2951cd76ef249..f103ff18081df 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -1,12 +1,27 @@ -use std::collections::HashSet; +use std::collections::{BTreeMap, BTreeSet, HashSet}; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::ir::{Opcode, InstructionData, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; -use cranelift_codegen::entity::SecondaryMap; use crate::prelude::*; +/// Workaround for `StackSlot` not implementing `Ord`. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +struct OrdStackSlot(StackSlot); + +impl PartialOrd for OrdStackSlot { + fn partial_cmp(&self, rhs: &Self) -> Option { + self.0.as_u32().partial_cmp(&rhs.0.as_u32()) + } +} + +impl Ord for OrdStackSlot { + fn cmp(&self, rhs: &Self) -> std::cmp::Ordering { + self.0.as_u32().cmp(&rhs.0.as_u32()) + } +} + pub(super) fn optimize_function( func: &mut Function, clif_comments: &mut crate::pretty_clif::CommentWriter, @@ -16,11 +31,11 @@ pub(super) fn optimize_function( // Record all stack_addr, stack_load and stack_store instructions. Also record all stack_addr // and stack_load insts whose result is used. - let mut stack_addr_insts = SecondaryMap::new(); - let mut stack_addr_insts_users = SecondaryMap::>::new(); - let mut stack_load_insts = SecondaryMap::new(); - let mut stack_load_insts_users = SecondaryMap::>::new(); - let mut stack_store_insts = SecondaryMap::new(); + let mut stack_addr_insts = BTreeSet::new(); + let mut stack_addr_insts_users = BTreeMap::>::new(); + let mut stack_load_insts = BTreeSet::new(); + let mut stack_load_insts_users = BTreeMap::>::new(); + let mut stack_store_insts = BTreeSet::new(); let mut cursor = FuncCursor::new(func); while let Some(_ebb) = cursor.next_ebb() { @@ -31,14 +46,14 @@ pub(super) fn optimize_function( stack_slot: _, offset: _, } => { - stack_addr_insts[inst] = true; + stack_addr_insts.insert(inst); } InstructionData::StackLoad { opcode: Opcode::StackLoad, stack_slot: _, offset: _, } => { - stack_load_insts[inst] = true; + stack_load_insts.insert(inst); } InstructionData::StackStore { opcode: Opcode::StackStore, @@ -46,7 +61,7 @@ pub(super) fn optimize_function( stack_slot: _, offset: _, } => { - stack_store_insts[inst] = true; + stack_store_insts.insert(inst); } _ => {} } @@ -55,10 +70,10 @@ pub(super) fn optimize_function( if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { match cursor.func.dfg[arg_origin].opcode() { Opcode::StackAddr => { - stack_addr_insts_users[arg_origin].insert(inst); + stack_addr_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); } Opcode::StackLoad => { - stack_load_insts_users[arg_origin].insert(inst); + stack_load_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); } _ => {} } @@ -68,58 +83,60 @@ pub(super) fn optimize_function( } println!( - "{}:\nstack_addr: [{}] ({{{}}} used)\nstack_load: [{}] ([{{{}}}] used)\nstack_store: [{}]", + "{}:\nstack_addr: {:?} ({:?} used)\nstack_load: {:?} ({:?} used)\nstack_store: {:?}", name, - bool_secondary_map_to_string(&stack_addr_insts), - usage_secondary_map_to_string(&stack_addr_insts_users), - bool_secondary_map_to_string(&stack_load_insts), - usage_secondary_map_to_string(&stack_load_insts_users), - bool_secondary_map_to_string(&stack_store_insts), + stack_addr_insts, + stack_addr_insts_users, + stack_load_insts, + stack_load_insts_users, + stack_store_insts, ); - for inst in stack_addr_insts_users.keys().filter(|&inst| !stack_addr_insts_users[inst].is_empty()) { - assert!(stack_addr_insts[inst]); + for inst in stack_addr_insts_users.keys() { + assert!(stack_addr_insts.contains(inst)); } // Replace all unused stack_addr instructions with nop. - for inst in stack_addr_insts.keys() { - if stack_addr_insts[inst] && stack_addr_insts_users[inst].is_empty() { + // FIXME remove clone + for &inst in stack_addr_insts.clone().iter() { + if stack_addr_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); - stack_addr_insts[inst] = false; + stack_addr_insts.remove(&inst); } } - for inst in stack_load_insts_users.keys().filter(|&inst| !stack_load_insts_users[inst].is_empty()) { - assert!(stack_load_insts[inst]); + for inst in stack_load_insts_users.keys() { + assert!(stack_load_insts.contains(inst)); } // Replace all unused stack_load instructions with nop. - for inst in stack_load_insts.keys() { - if stack_load_insts[inst] && !stack_addr_insts_users[inst].is_empty() { + // FIXME remove clone + for &inst in stack_load_insts.clone().iter() { + if !stack_addr_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); - stack_load_insts[inst] = false; + stack_load_insts.remove(&inst); } } //println!("stack_addr (after): [{}]", bool_secondary_map_to_string(&stack_addr_insts)); - let mut stack_slot_usage_map: SecondaryMap> = SecondaryMap::new(); - for inst in stack_load_insts.keys().filter(|&inst| stack_load_insts[inst]) { + let mut stack_slot_usage_map: BTreeMap> = BTreeMap::new(); + for &inst in stack_load_insts.iter() { match func.dfg[inst] { InstructionData::StackLoad { opcode: Opcode::StackLoad, stack_slot, offset: _, } => { - stack_slot_usage_map[stack_slot].insert(inst); + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(HashSet::new).insert(inst); } ref data => unreachable!("{:?}", data), } } - for inst in stack_store_insts.keys().filter(|&inst| stack_store_insts[inst]) { + for &inst in stack_store_insts.iter() { match func.dfg[inst] { InstructionData::StackStore { opcode: Opcode::StackStore, @@ -127,25 +144,25 @@ pub(super) fn optimize_function( stack_slot, offset: _, } => { - stack_slot_usage_map[stack_slot].insert(inst); + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(HashSet::new).insert(inst); } ref data => unreachable!("{:?}", data), } } - for inst in stack_addr_insts.keys().filter(|&inst| stack_addr_insts[inst]) { + for &inst in stack_addr_insts.iter() { match func.dfg[inst] { InstructionData::StackLoad { opcode: Opcode::StackAddr, stack_slot, offset: _, } => { - stack_slot_usage_map[stack_slot].insert(inst); + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(HashSet::new).insert(inst); } ref data => unreachable!("{:?}", data), } } - println!("stack slot usage: {{{}}}", usage_secondary_map_to_string(&stack_slot_usage_map)); + println!("stack slot usage: {:?}", stack_slot_usage_map); for (stack_slot, users) in stack_slot_usage_map.iter_mut() { let mut is_addr_leaked = false; @@ -188,7 +205,7 @@ pub(super) fn optimize_function( } else { // Stored value never read; just remove reads. for &user in users.iter() { - println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot); + println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); func.dfg.replace(user).nop(); } } @@ -242,37 +259,3 @@ fn try_get_stack_slot_and_offset_for_addr(func: &Function, addr: Value) -> Optio } None } - -fn bool_secondary_map_to_string(map: &SecondaryMap) -> String - where E: cranelift_codegen::entity::EntityRef + std::fmt::Display, -{ - map - .keys() - .filter_map(|inst| { - // EntitySet::keys returns all possible entities until the last entity inserted. - if map[inst] { - Some(format!("{}", inst)) - } else { - None - } - }) - .collect::>() - .join(", ") -} - -fn usage_secondary_map_to_string(map: &SecondaryMap>) -> String - where E: cranelift_codegen::entity::EntityRef + std::fmt::Display, -{ - map - .keys() - .filter_map(|inst| { - // EntitySet::keys returns all possible entities until the last entity inserted. - if !map[inst].is_empty() { - Some(format!("{}: {:?}", inst, map[inst])) - } else { - None - } - }) - .collect::>() - .join(", ") -} From 9d77cb95e164addcf924f65b0c80465c5cebe776 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 15:55:39 +0100 Subject: [PATCH 1039/1566] Merge stack_{addr,load}_insts_users --- src/optimize/stack2reg.rs | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index f103ff18081df..314561cb7d7e9 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -31,10 +31,9 @@ pub(super) fn optimize_function( // Record all stack_addr, stack_load and stack_store instructions. Also record all stack_addr // and stack_load insts whose result is used. + let mut stack_addr_load_insts_users = BTreeMap::>::new(); let mut stack_addr_insts = BTreeSet::new(); - let mut stack_addr_insts_users = BTreeMap::>::new(); let mut stack_load_insts = BTreeSet::new(); - let mut stack_load_insts_users = BTreeMap::>::new(); let mut stack_store_insts = BTreeSet::new(); let mut cursor = FuncCursor::new(func); @@ -69,11 +68,8 @@ pub(super) fn optimize_function( for &arg in cursor.func.dfg.inst_args(inst) { if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { match cursor.func.dfg[arg_origin].opcode() { - Opcode::StackAddr => { - stack_addr_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); - } - Opcode::StackLoad => { - stack_load_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); + Opcode::StackAddr | Opcode::StackLoad => { + stack_addr_load_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); } _ => {} } @@ -83,37 +79,34 @@ pub(super) fn optimize_function( } println!( - "{}:\nstack_addr: {:?} ({:?} used)\nstack_load: {:?} ({:?} used)\nstack_store: {:?}", + "{}:\nstack_addr/stack_load users: {:?}\nstack_addr: {:?}\nstack_load: {:?}\nstack_store: {:?}", name, + stack_addr_load_insts_users, stack_addr_insts, - stack_addr_insts_users, stack_load_insts, - stack_load_insts_users, stack_store_insts, ); - for inst in stack_addr_insts_users.keys() { - assert!(stack_addr_insts.contains(inst)); + for inst in stack_addr_load_insts_users.keys() { + assert!(stack_addr_insts.contains(inst) || stack_load_insts.contains(inst)); } // Replace all unused stack_addr instructions with nop. // FIXME remove clone for &inst in stack_addr_insts.clone().iter() { - if stack_addr_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + println!("Removing unused stack_addr {}", inst); func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); stack_addr_insts.remove(&inst); } } - for inst in stack_load_insts_users.keys() { - assert!(stack_load_insts.contains(inst)); - } - // Replace all unused stack_load instructions with nop. // FIXME remove clone for &inst in stack_load_insts.clone().iter() { - if !stack_addr_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + println!("Removing unused stack_load {}", inst); func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); stack_load_insts.remove(&inst); From a8daa7115e3f5f78dba547061cd4fe6a2f716c0e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 16:27:05 +0100 Subject: [PATCH 1040/1566] Group by stack slot earlier --- src/optimize/stack2reg.rs | 149 +++++++++++--------------------------- 1 file changed, 42 insertions(+), 107 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 314561cb7d7e9..34f75e7da00dc 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -1,4 +1,5 @@ use std::collections::{BTreeMap, BTreeSet, HashSet}; +use std::ops::Not; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::ir::{Opcode, InstructionData, ValueDef}; @@ -22,6 +23,13 @@ impl Ord for OrdStackSlot { } } +#[derive(Debug, Default)] +struct StackSlotUsage { + stack_addr: HashSet, + stack_load: HashSet, + stack_store: HashSet, +} + pub(super) fn optimize_function( func: &mut Function, clif_comments: &mut crate::pretty_clif::CommentWriter, @@ -31,10 +39,8 @@ pub(super) fn optimize_function( // Record all stack_addr, stack_load and stack_store instructions. Also record all stack_addr // and stack_load insts whose result is used. - let mut stack_addr_load_insts_users = BTreeMap::>::new(); - let mut stack_addr_insts = BTreeSet::new(); - let mut stack_load_insts = BTreeSet::new(); - let mut stack_store_insts = BTreeSet::new(); + let mut stack_addr_load_insts_users = HashMap::>::new(); + let mut stack_slot_usage_map = BTreeMap::::new(); let mut cursor = FuncCursor::new(func); while let Some(_ebb) = cursor.next_ebb() { @@ -42,25 +48,25 @@ pub(super) fn optimize_function( match cursor.func.dfg[inst] { InstructionData::StackLoad { opcode: Opcode::StackAddr, - stack_slot: _, + stack_slot, offset: _, } => { - stack_addr_insts.insert(inst); + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_addr.insert(inst); } InstructionData::StackLoad { opcode: Opcode::StackLoad, - stack_slot: _, + stack_slot, offset: _, } => { - stack_load_insts.insert(inst); + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_load.insert(inst); } InstructionData::StackStore { opcode: Opcode::StackStore, arg: _, - stack_slot: _, + stack_slot, offset: _, } => { - stack_store_insts.insert(inst); + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_store.insert(inst); } _ => {} } @@ -79,125 +85,54 @@ pub(super) fn optimize_function( } println!( - "{}:\nstack_addr/stack_load users: {:?}\nstack_addr: {:?}\nstack_load: {:?}\nstack_store: {:?}", + "{}:\nstack_addr/stack_load users: {:?}\nstack slot usage: {:?}", name, stack_addr_load_insts_users, - stack_addr_insts, - stack_load_insts, - stack_store_insts, + stack_slot_usage_map, ); for inst in stack_addr_load_insts_users.keys() { - assert!(stack_addr_insts.contains(inst) || stack_load_insts.contains(inst)); - } - - // Replace all unused stack_addr instructions with nop. - // FIXME remove clone - for &inst in stack_addr_insts.clone().iter() { - if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - println!("Removing unused stack_addr {}", inst); - func.dfg.detach_results(inst); - func.dfg.replace(inst).nop(); - stack_addr_insts.remove(&inst); - } - } - - // Replace all unused stack_load instructions with nop. - // FIXME remove clone - for &inst in stack_load_insts.clone().iter() { - if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - println!("Removing unused stack_load {}", inst); - func.dfg.detach_results(inst); - func.dfg.replace(inst).nop(); - stack_load_insts.remove(&inst); + let mut is_recorded_stack_addr_or_stack_load = false; + for stack_slot_users in stack_slot_usage_map.values() { + is_recorded_stack_addr_or_stack_load |= stack_slot_users.stack_addr.contains(inst) || stack_slot_users.stack_load.contains(inst); } + assert!(is_recorded_stack_addr_or_stack_load); } - - //println!("stack_addr (after): [{}]", bool_secondary_map_to_string(&stack_addr_insts)); - - let mut stack_slot_usage_map: BTreeMap> = BTreeMap::new(); - for &inst in stack_load_insts.iter() { - match func.dfg[inst] { - InstructionData::StackLoad { - opcode: Opcode::StackLoad, - stack_slot, - offset: _, - } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(HashSet::new).insert(inst); - } - ref data => unreachable!("{:?}", data), - } - } - for &inst in stack_store_insts.iter() { - match func.dfg[inst] { - InstructionData::StackStore { - opcode: Opcode::StackStore, - arg: _, - stack_slot, - offset: _, - } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(HashSet::new).insert(inst); + // Replace all unused stack_addr and stack_load instructions with nop. + for stack_slot_users in stack_slot_usage_map.values_mut() { + // FIXME remove clone + for &inst in stack_slot_users.stack_addr.clone().iter() { + if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + println!("Removing unused stack_addr {}", inst); + func.dfg.detach_results(inst); + func.dfg.replace(inst).nop(); + stack_slot_users.stack_addr.remove(&inst); } - ref data => unreachable!("{:?}", data), } - } - for &inst in stack_addr_insts.iter() { - match func.dfg[inst] { - InstructionData::StackLoad { - opcode: Opcode::StackAddr, - stack_slot, - offset: _, - } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(HashSet::new).insert(inst); + + for &inst in stack_slot_users.stack_load.clone().iter() { + if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + println!("Removing unused stack_addr {}", inst); + func.dfg.detach_results(inst); + func.dfg.replace(inst).nop(); + stack_slot_users.stack_load.remove(&inst); } - ref data => unreachable!("{:?}", data), } } - println!("stack slot usage: {:?}", stack_slot_usage_map); + println!("stack slot usage (after): {:?}", stack_slot_usage_map); for (stack_slot, users) in stack_slot_usage_map.iter_mut() { - let mut is_addr_leaked = false; - let mut is_loaded = false; - let mut is_stored = false; - for &user in users.iter() { - match func.dfg[user] { - InstructionData::StackLoad { - opcode: Opcode::StackAddr, - stack_slot, - offset: _, - } => { - is_addr_leaked = true; - } - InstructionData::StackLoad { - opcode: Opcode::StackLoad, - stack_slot, - offset: _, - } => { - is_loaded = true; - } - InstructionData::StackStore { - opcode: Opcode::StackStore, - arg: _, - stack_slot, - offset: _, - } => { - is_stored = true; - } - ref data => unreachable!("{:?}", data), - } - } - - if is_addr_leaked || (is_loaded && is_stored) { + if users.stack_addr.is_empty().not() || (users.stack_load.is_empty().not() && users.stack_store.is_empty().not()) { continue; } - if is_loaded { + if users.stack_load.is_empty().not() { println!("[{}] [BUG?] Reading uninitialized memory", name); } else { // Stored value never read; just remove reads. - for &user in users.iter() { + for user in users.stack_store.drain() { println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); func.dfg.replace(user).nop(); } From 943b81bb409dd9239f14992aaa75f8ae2a564e62 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 16:37:49 +0100 Subject: [PATCH 1041/1566] Extract remove_unused_stack_addr_and_stack_load --- src/optimize/stack2reg.rs | 105 ++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 34f75e7da00dc..2e531d1cb551a 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -37,9 +37,7 @@ pub(super) fn optimize_function( ) { combine_stack_addr_with_load_store(func); - // Record all stack_addr, stack_load and stack_store instructions. Also record all stack_addr - // and stack_load insts whose result is used. - let mut stack_addr_load_insts_users = HashMap::>::new(); + // Record all stack_addr, stack_load and stack_store instructions. let mut stack_slot_usage_map = BTreeMap::::new(); let mut cursor = FuncCursor::new(func); @@ -70,56 +68,12 @@ pub(super) fn optimize_function( } _ => {} } - - for &arg in cursor.func.dfg.inst_args(inst) { - if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { - match cursor.func.dfg[arg_origin].opcode() { - Opcode::StackAddr | Opcode::StackLoad => { - stack_addr_load_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); - } - _ => {} - } - } - } } } - println!( - "{}:\nstack_addr/stack_load users: {:?}\nstack slot usage: {:?}", - name, - stack_addr_load_insts_users, - stack_slot_usage_map, - ); - - for inst in stack_addr_load_insts_users.keys() { - let mut is_recorded_stack_addr_or_stack_load = false; - for stack_slot_users in stack_slot_usage_map.values() { - is_recorded_stack_addr_or_stack_load |= stack_slot_users.stack_addr.contains(inst) || stack_slot_users.stack_load.contains(inst); - } - assert!(is_recorded_stack_addr_or_stack_load); - } - - // Replace all unused stack_addr and stack_load instructions with nop. - for stack_slot_users in stack_slot_usage_map.values_mut() { - // FIXME remove clone - for &inst in stack_slot_users.stack_addr.clone().iter() { - if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - println!("Removing unused stack_addr {}", inst); - func.dfg.detach_results(inst); - func.dfg.replace(inst).nop(); - stack_slot_users.stack_addr.remove(&inst); - } - } + println!("{}:\nstack slot usage: {:?}", name, stack_slot_usage_map); - for &inst in stack_slot_users.stack_load.clone().iter() { - if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - println!("Removing unused stack_addr {}", inst); - func.dfg.detach_results(inst); - func.dfg.replace(inst).nop(); - stack_slot_users.stack_load.remove(&inst); - } - } - } + remove_unused_stack_addr_and_stack_load(func, &mut stack_slot_usage_map); println!("stack slot usage (after): {:?}", stack_slot_usage_map); @@ -175,6 +129,59 @@ fn combine_stack_addr_with_load_store(func: &mut Function) { } } +fn remove_unused_stack_addr_and_stack_load(func: &mut Function, stack_slot_usage_map: &mut BTreeMap) { + // FIXME incrementally rebuild on each call? + let mut stack_addr_load_insts_users = HashMap::>::new(); + + let mut cursor = FuncCursor::new(func); + while let Some(_ebb) = cursor.next_ebb() { + while let Some(inst) = cursor.next_inst() { + for &arg in cursor.func.dfg.inst_args(inst) { + if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { + match cursor.func.dfg[arg_origin].opcode() { + Opcode::StackAddr | Opcode::StackLoad => { + stack_addr_load_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); + } + _ => {} + } + } + } + } + } + + println!("stack_addr/stack_load users: {:?}", stack_addr_load_insts_users); + + for inst in stack_addr_load_insts_users.keys() { + let mut is_recorded_stack_addr_or_stack_load = false; + for stack_slot_users in stack_slot_usage_map.values() { + is_recorded_stack_addr_or_stack_load |= stack_slot_users.stack_addr.contains(inst) || stack_slot_users.stack_load.contains(inst); + } + assert!(is_recorded_stack_addr_or_stack_load); + } + + // Replace all unused stack_addr and stack_load instructions with nop. + for stack_slot_users in stack_slot_usage_map.values_mut() { + // FIXME remove clone + for &inst in stack_slot_users.stack_addr.clone().iter() { + if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + println!("Removing unused stack_addr {}", inst); + func.dfg.detach_results(inst); + func.dfg.replace(inst).nop(); + stack_slot_users.stack_addr.remove(&inst); + } + } + + for &inst in stack_slot_users.stack_load.clone().iter() { + if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { + println!("Removing unused stack_addr {}", inst); + func.dfg.detach_results(inst); + func.dfg.replace(inst).nop(); + stack_slot_users.stack_load.remove(&inst); + } + } + } +} + fn try_get_stack_slot_and_offset_for_addr(func: &Function, addr: Value) -> Option<(StackSlot, Offset32)> { if let ValueDef::Result(addr_inst, 0) = func.dfg.value_def(addr) { if let InstructionData::StackLoad { From be6cdb28d0ac896478cf784478a41b9e2c1c5234 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 16:50:41 +0100 Subject: [PATCH 1042/1566] Refactor stack_store removal --- src/optimize/stack2reg.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 2e531d1cb551a..70917436003ac 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -78,17 +78,25 @@ pub(super) fn optimize_function( println!("stack slot usage (after): {:?}", stack_slot_usage_map); for (stack_slot, users) in stack_slot_usage_map.iter_mut() { - if users.stack_addr.is_empty().not() || (users.stack_load.is_empty().not() && users.stack_store.is_empty().not()) { + if users.stack_addr.is_empty().not() { + // Stack addr leaked; there may be unknown loads and stores. + // FIXME use stacked borrows to optimize continue; } - if users.stack_load.is_empty().not() { - println!("[{}] [BUG?] Reading uninitialized memory", name); - } else { - // Stored value never read; just remove reads. - for user in users.stack_store.drain() { - println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); - func.dfg.replace(user).nop(); + let is_loaded = users.stack_load.is_empty().not(); + let is_stored = users.stack_store.is_empty().not(); + match (is_loaded, is_stored) { + (true, true) => {} // FIXME perform store to load optimization + (true, false) => println!("[{}] [BUG?] Reading uninitialized memory", name), + (false, _) => { + // Never loaded; can safely remove all stores and the stack slot. + for user in users.stack_store.drain() { + println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); + func.dfg.replace(user).nop(); + } + + // FIXME make stack_slot zero sized. } } } From 7d35db53196f5170374482700a71ffee51186c10 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Dec 2019 21:13:27 +0100 Subject: [PATCH 1043/1566] [WIP] Implement basic stack store to load forwarding --- src/optimize/stack2reg.rs | 93 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 3 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 70917436003ac..d368d50a03259 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -1,8 +1,8 @@ -use std::collections::{BTreeMap, BTreeSet, HashSet}; +use std::collections::{BTreeMap, HashSet}; use std::ops::Not; use cranelift_codegen::cursor::{Cursor, FuncCursor}; -use cranelift_codegen::ir::{Opcode, InstructionData, ValueDef}; +use cranelift_codegen::ir::{InstructionData, Opcode, ProgramOrder, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; use crate::prelude::*; @@ -87,7 +87,44 @@ pub(super) fn optimize_function( let is_loaded = users.stack_load.is_empty().not(); let is_stored = users.stack_store.is_empty().not(); match (is_loaded, is_stored) { - (true, true) => {} // FIXME perform store to load optimization + (true, true) => { + for load in users.stack_load.clone().drain() { + let load_ebb = func.layout.inst_ebb(load).unwrap(); + let loaded_value = func.dfg.inst_results(load)[0]; + let loaded_type = func.dfg.value_type(loaded_value); + + let potential_stores = users.stack_store.iter().cloned().filter(|&store| { + match spatial_overlap(func, load, store) { + SpatialOverlap::No => false, // Can never be the source of the loaded value. + SpatialOverlap::Partial | SpatialOverlap::Full => true, + } + }).filter(|&store| { + if load_ebb == func.layout.inst_ebb(store).unwrap() { + func.layout.cmp(store, load) == std::cmp::Ordering::Less + } else { + true // FIXME + } + }).collect::>(); + for &store in &potential_stores { + println!("Potential store -> load forwarding {} -> {} ({:?})", func.dfg.display_inst(store, None), func.dfg.display_inst(load, None), spatial_overlap(func, load, store)); + } + match *potential_stores { + [] => println!("[{}] [BUG?] Reading uninitialized memory", name), + [store] if spatial_overlap(func, load, store) == SpatialOverlap::Full => { + let store_ebb = func.layout.inst_ebb(store).unwrap(); + let stored_value = func.dfg.inst_args(store)[0]; + let stored_type = func.dfg.value_type(stored_value); + if stored_type == loaded_type && store_ebb == load_ebb { + println!("Store to load forward {} -> {}", store, load); + func.dfg.detach_results(load); + func.dfg.replace(load).nop(); + func.dfg.change_to_alias(loaded_value, stored_value); + } + } + _ => {} // FIXME implement this + } + } + } (true, false) => println!("[{}] [BUG?] Reading uninitialized memory", name), (false, _) => { // Never loaded; can safely remove all stores and the stack slot. @@ -202,3 +239,53 @@ fn try_get_stack_slot_and_offset_for_addr(func: &Function, addr: Value) -> Optio } None } + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +enum SpatialOverlap { + No, + Partial, + Full, +} + +fn spatial_overlap(func: &Function, src: Inst, dest: Inst) -> SpatialOverlap { + fn inst_info(func: &Function, inst: Inst) -> (StackSlot, Offset32, u32) { + match func.dfg[inst] { + InstructionData::StackLoad { + opcode: Opcode::StackAddr, + stack_slot, + offset, + } + | InstructionData::StackLoad { + opcode: Opcode::StackLoad, + stack_slot, + offset, + } + | InstructionData::StackStore { + opcode: Opcode::StackStore, + stack_slot, + offset, + arg: _, + } => (stack_slot, offset, func.dfg.ctrl_typevar(inst).bytes()), + _ => unreachable!("{:?}", func.dfg[inst]), + } + } + + let (src_ss, src_offset, src_size) = inst_info(func, src); + let (dest_ss, dest_offset, dest_size) = inst_info(func, dest); + + if src_ss != dest_ss { + return SpatialOverlap::No; + } + + if src_offset == dest_offset && src_size == dest_size { + return SpatialOverlap::Full; + } + + let src_end: i64 = src_offset.try_add_i64(i64::from(src_size)).unwrap().into(); + let dest_end: i64 = dest_offset.try_add_i64(i64::from(dest_size)).unwrap().into(); + if src_end <= dest_offset.into() || dest_end <= src_offset.into() { + return SpatialOverlap::No; + } + + SpatialOverlap::Partial +} From c5f42aef1d7a7c0e4097fc0e8f76fff47b8d32b8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 11:36:00 +0100 Subject: [PATCH 1044/1566] Run dead stack_store removal after stack_store to stack_load forwarding --- src/optimize/stack2reg.rs | 89 +++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index d368d50a03259..edf507b9760ba 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -84,58 +84,55 @@ pub(super) fn optimize_function( continue; } - let is_loaded = users.stack_load.is_empty().not(); - let is_stored = users.stack_store.is_empty().not(); - match (is_loaded, is_stored) { - (true, true) => { - for load in users.stack_load.clone().drain() { - let load_ebb = func.layout.inst_ebb(load).unwrap(); - let loaded_value = func.dfg.inst_results(load)[0]; - let loaded_type = func.dfg.value_type(loaded_value); - - let potential_stores = users.stack_store.iter().cloned().filter(|&store| { - match spatial_overlap(func, load, store) { - SpatialOverlap::No => false, // Can never be the source of the loaded value. - SpatialOverlap::Partial | SpatialOverlap::Full => true, - } - }).filter(|&store| { - if load_ebb == func.layout.inst_ebb(store).unwrap() { - func.layout.cmp(store, load) == std::cmp::Ordering::Less - } else { - true // FIXME - } - }).collect::>(); - for &store in &potential_stores { - println!("Potential store -> load forwarding {} -> {} ({:?})", func.dfg.display_inst(store, None), func.dfg.display_inst(load, None), spatial_overlap(func, load, store)); - } - match *potential_stores { - [] => println!("[{}] [BUG?] Reading uninitialized memory", name), - [store] if spatial_overlap(func, load, store) == SpatialOverlap::Full => { - let store_ebb = func.layout.inst_ebb(store).unwrap(); - let stored_value = func.dfg.inst_args(store)[0]; - let stored_type = func.dfg.value_type(stored_value); - if stored_type == loaded_type && store_ebb == load_ebb { - println!("Store to load forward {} -> {}", store, load); - func.dfg.detach_results(load); - func.dfg.replace(load).nop(); - func.dfg.change_to_alias(loaded_value, stored_value); - } - } - _ => {} // FIXME implement this - } + for load in users.stack_load.clone().drain() { + let load_ebb = func.layout.inst_ebb(load).unwrap(); + let loaded_value = func.dfg.inst_results(load)[0]; + let loaded_type = func.dfg.value_type(loaded_value); + + let potential_stores = users.stack_store.iter().cloned().filter(|&store| { + match spatial_overlap(func, load, store) { + SpatialOverlap::No => false, // Can never be the source of the loaded value. + SpatialOverlap::Partial | SpatialOverlap::Full => true, + } + }).filter(|&store| { + if load_ebb == func.layout.inst_ebb(store).unwrap() { + func.layout.cmp(store, load) == std::cmp::Ordering::Less + } else { + true // FIXME } + }).collect::>(); + for &store in &potential_stores { + println!("Potential store -> load forwarding {} -> {} ({:?})", func.dfg.display_inst(store, None), func.dfg.display_inst(load, None), spatial_overlap(func, load, store)); } - (true, false) => println!("[{}] [BUG?] Reading uninitialized memory", name), - (false, _) => { - // Never loaded; can safely remove all stores and the stack slot. - for user in users.stack_store.drain() { - println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); - func.dfg.replace(user).nop(); + match *potential_stores { + [] => println!("[{}] [BUG?] Reading uninitialized memory", name), + [store] if spatial_overlap(func, load, store) == SpatialOverlap::Full => { + let store_ebb = func.layout.inst_ebb(store).unwrap(); + let stored_value = func.dfg.inst_args(store)[0]; + let stored_type = func.dfg.value_type(stored_value); + if stored_type == loaded_type && store_ebb == load_ebb { + println!("Store to load forward {} -> {}", store, load); + func.dfg.detach_results(load); + func.dfg.replace(load).nop(); + func.dfg.change_to_alias(loaded_value, stored_value); + users.stack_load.remove(&load); + } } + _ => {} // FIXME implement this + } + } - // FIXME make stack_slot zero sized. + if users.stack_load.is_empty() { + // Never loaded; can safely remove all stores and the stack slot. + for user in users.stack_store.drain() { + println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); + func.dfg.replace(user).nop(); } } + + if users.stack_store.is_empty() && users.stack_load.is_empty() { + // FIXME make stack_slot zero sized. + } } println!(); From b0814a3fd88fcacf28eceb2174b0ac35facfccf4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 12:41:03 +0100 Subject: [PATCH 1045/1566] Check for cross-ebb temporal overlap between loads and stores --- src/base.rs | 8 +++-- src/optimize/mod.rs | 8 ++--- src/optimize/stack2reg.rs | 65 +++++++++++++++++++++++++++------------ 3 files changed, 54 insertions(+), 27 deletions(-) diff --git a/src/base.rs b/src/base.rs index a59231141095b..0adca5bee8b11 100644 --- a/src/base.rs +++ b/src/base.rs @@ -76,11 +76,13 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Verify function verify_func(tcx, &clif_comments, &func); - crate::optimize::optimize_function(cx.tcx, instance, &mut func, &mut clif_comments); - - // Define function let context = &mut cx.caches.context; context.func = func; + + // Perform rust specific optimizations + crate::optimize::optimize_function(cx.tcx, instance, context, &mut clif_comments); + + // Define function cx.module.define_function(func_id, context).unwrap(); // Write optimized function to file for debugging diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index f1ced869d26dc..64400e8886a0f 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -5,11 +5,11 @@ mod stack2reg; pub fn optimize_function<'tcx>( tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, - func: &mut Function, + ctx: &mut Context, clif_comments: &mut crate::pretty_clif::CommentWriter, ) { - self::stack2reg::optimize_function(func, clif_comments, format!("{:?}", instance)); + self::stack2reg::optimize_function(ctx, clif_comments, format!("{:?}", instance)); #[cfg(debug_assertions)] - crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &*func, &*clif_comments, None); - crate::base::verify_func(tcx, &*clif_comments, &*func); + crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None); + crate::base::verify_func(tcx, &*clif_comments, &ctx.func); } diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index edf507b9760ba..26d74c70bdab4 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -2,6 +2,7 @@ use std::collections::{BTreeMap, HashSet}; use std::ops::Not; use cranelift_codegen::cursor::{Cursor, FuncCursor}; +use cranelift_codegen::entity::EntitySet; use cranelift_codegen::ir::{InstructionData, Opcode, ProgramOrder, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; @@ -31,16 +32,18 @@ struct StackSlotUsage { } pub(super) fn optimize_function( - func: &mut Function, + ctx: &mut Context, clif_comments: &mut crate::pretty_clif::CommentWriter, name: String, // FIXME remove ) { - combine_stack_addr_with_load_store(func); + ctx.flowgraph(); // Compute cfg and domtree. + + combine_stack_addr_with_load_store(&mut ctx.func); // Record all stack_addr, stack_load and stack_store instructions. let mut stack_slot_usage_map = BTreeMap::::new(); - let mut cursor = FuncCursor::new(func); + let mut cursor = FuncCursor::new(&mut ctx.func); while let Some(_ebb) = cursor.next_ebb() { while let Some(inst) = cursor.next_inst() { match cursor.func.dfg[inst] { @@ -73,7 +76,7 @@ pub(super) fn optimize_function( println!("{}:\nstack slot usage: {:?}", name, stack_slot_usage_map); - remove_unused_stack_addr_and_stack_load(func, &mut stack_slot_usage_map); + remove_unused_stack_addr_and_stack_load(&mut ctx.func, &mut stack_slot_usage_map); println!("stack slot usage (after): {:?}", stack_slot_usage_map); @@ -85,36 +88,58 @@ pub(super) fn optimize_function( } for load in users.stack_load.clone().drain() { - let load_ebb = func.layout.inst_ebb(load).unwrap(); - let loaded_value = func.dfg.inst_results(load)[0]; - let loaded_type = func.dfg.value_type(loaded_value); + let load_ebb = ctx.func.layout.inst_ebb(load).unwrap(); + let loaded_value = ctx.func.dfg.inst_results(load)[0]; + let loaded_type = ctx.func.dfg.value_type(loaded_value); let potential_stores = users.stack_store.iter().cloned().filter(|&store| { - match spatial_overlap(func, load, store) { + // Check if the store modified some memory accessed by the load. + + match spatial_overlap(&ctx.func, load, store) { SpatialOverlap::No => false, // Can never be the source of the loaded value. SpatialOverlap::Partial | SpatialOverlap::Full => true, } }).filter(|&store| { - if load_ebb == func.layout.inst_ebb(store).unwrap() { - func.layout.cmp(store, load) == std::cmp::Ordering::Less + // Check if the store may have happened before the load. + + let store_ebb = ctx.func.layout.inst_ebb(store).unwrap(); + if load_ebb == store_ebb { + ctx.func.layout.cmp(store, load) == std::cmp::Ordering::Less } else { - true // FIXME + // FIXME O(stack_load count * ebb count) + // FIXME reuse memory allocations + let mut visited = EntitySet::new(); + let mut todo = EntitySet::new(); + todo.insert(load_ebb); + while let Some(ebb) = todo.pop() { + if visited.contains(ebb) { + continue; + } + visited.insert(ebb); + if ebb == store_ebb { + return true; + } + for bb in ctx.cfg.pred_iter(ebb) { + todo.insert(bb.ebb); + } + } + false } }).collect::>(); for &store in &potential_stores { - println!("Potential store -> load forwarding {} -> {} ({:?})", func.dfg.display_inst(store, None), func.dfg.display_inst(load, None), spatial_overlap(func, load, store)); + println!("Potential store -> load forwarding {} -> {} ({:?})", ctx.func.dfg.display_inst(store, None), ctx.func.dfg.display_inst(load, None), spatial_overlap(func, load, store)); } match *potential_stores { [] => println!("[{}] [BUG?] Reading uninitialized memory", name), - [store] if spatial_overlap(func, load, store) == SpatialOverlap::Full => { - let store_ebb = func.layout.inst_ebb(store).unwrap(); - let stored_value = func.dfg.inst_args(store)[0]; - let stored_type = func.dfg.value_type(stored_value); + [store] if spatial_overlap(&ctx.func, load, store) == SpatialOverlap::Full => { + let store_ebb = ctx.func.layout.inst_ebb(store).unwrap(); + let stored_value = ctx.func.dfg.inst_args(store)[0]; + let stored_type = ctx.func.dfg.value_type(stored_value); if stored_type == loaded_type && store_ebb == load_ebb { println!("Store to load forward {} -> {}", store, load); - func.dfg.detach_results(load); - func.dfg.replace(load).nop(); - func.dfg.change_to_alias(loaded_value, stored_value); + ctx.func.dfg.detach_results(load); + ctx.func.dfg.replace(load).nop(); + ctx.func.dfg.change_to_alias(loaded_value, stored_value); users.stack_load.remove(&load); } } @@ -126,7 +151,7 @@ pub(super) fn optimize_function( // Never loaded; can safely remove all stores and the stack slot. for user in users.stack_store.drain() { println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); - func.dfg.replace(user).nop(); + ctx.func.dfg.replace(user).nop(); } } From 9022e09a3e23e3dd81ad7fe4b8a3c177aa6cc344 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 13:00:28 +0100 Subject: [PATCH 1046/1566] Fix compilation --- src/optimize/stack2reg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 26d74c70bdab4..7a2b2e36c039d 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -127,7 +127,7 @@ pub(super) fn optimize_function( } }).collect::>(); for &store in &potential_stores { - println!("Potential store -> load forwarding {} -> {} ({:?})", ctx.func.dfg.display_inst(store, None), ctx.func.dfg.display_inst(load, None), spatial_overlap(func, load, store)); + println!("Potential store -> load forwarding {} -> {} ({:?})", ctx.func.dfg.display_inst(store, None), ctx.func.dfg.display_inst(load, None), spatial_overlap(ctx.func, load, store)); } match *potential_stores { [] => println!("[{}] [BUG?] Reading uninitialized memory", name), From 7579663199a6f44545b5b5bb448d3b7d5ecfb88c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 15:52:42 +0100 Subject: [PATCH 1047/1566] Extract temporal_order function --- src/optimize/stack2reg.rs | 90 ++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 7a2b2e36c039d..64f7ab0450368 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -74,6 +74,8 @@ pub(super) fn optimize_function( } } + // FIXME Repeat following instructions until fixpoint. + println!("{}:\nstack slot usage: {:?}", name, stack_slot_usage_map); remove_unused_stack_addr_and_stack_load(&mut ctx.func, &mut stack_slot_usage_map); @@ -100,38 +102,23 @@ pub(super) fn optimize_function( SpatialOverlap::Partial | SpatialOverlap::Full => true, } }).filter(|&store| { - // Check if the store may have happened before the load. - - let store_ebb = ctx.func.layout.inst_ebb(store).unwrap(); - if load_ebb == store_ebb { - ctx.func.layout.cmp(store, load) == std::cmp::Ordering::Less - } else { - // FIXME O(stack_load count * ebb count) - // FIXME reuse memory allocations - let mut visited = EntitySet::new(); - let mut todo = EntitySet::new(); - todo.insert(load_ebb); - while let Some(ebb) = todo.pop() { - if visited.contains(ebb) { - continue; - } - visited.insert(ebb); - if ebb == store_ebb { - return true; - } - for bb in ctx.cfg.pred_iter(ebb) { - todo.insert(bb.ebb); - } - } - false + match temporal_order(&*ctx, load, store) { + TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. + TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, } }).collect::>(); for &store in &potential_stores { - println!("Potential store -> load forwarding {} -> {} ({:?})", ctx.func.dfg.display_inst(store, None), ctx.func.dfg.display_inst(load, None), spatial_overlap(ctx.func, load, store)); + println!( + "Potential store -> load forwarding {} -> {} ({:?}, {:?})", + ctx.func.dfg.display_inst(store, None), + ctx.func.dfg.display_inst(load, None), + spatial_overlap(&ctx.func, store, load), + temporal_order(&*ctx, store, load), + ); } match *potential_stores { [] => println!("[{}] [BUG?] Reading uninitialized memory", name), - [store] if spatial_overlap(&ctx.func, load, store) == SpatialOverlap::Full => { + [store] if spatial_overlap(&ctx.func, load, store) == SpatialOverlap::Full && temporal_order(&ctx, load, store) == TemporalOrder::DefinitivelyBefore => { let store_ebb = ctx.func.layout.inst_ebb(store).unwrap(); let stored_value = ctx.func.dfg.inst_args(store)[0]; let stored_type = ctx.func.dfg.value_type(stored_value); @@ -149,6 +136,7 @@ pub(super) fn optimize_function( if users.stack_load.is_empty() { // Never loaded; can safely remove all stores and the stack slot. + // FIXME also remove stores when there is always a next store before a load. for user in users.stack_store.drain() { println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); ctx.func.dfg.replace(user).nop(); @@ -292,6 +280,8 @@ fn spatial_overlap(func: &Function, src: Inst, dest: Inst) -> SpatialOverlap { } } + debug_assert_ne!(src, dest); + let (src_ss, src_offset, src_size) = inst_info(func, src); let (dest_ss, dest_offset, dest_size) = inst_info(func, dest); @@ -311,3 +301,51 @@ fn spatial_overlap(func: &Function, src: Inst, dest: Inst) -> SpatialOverlap { SpatialOverlap::Partial } + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +enum TemporalOrder { + /// `src` will never be executed before `dest`. + NeverBefore, + + /// `src` may be executed before `dest`. + MaybeBefore, + + /// `src` will always be executed before `dest`. + /// There may still be other instructions in between. + DefinitivelyBefore, +} + +fn temporal_order(ctx: &Context, src: Inst, dest: Inst) -> TemporalOrder { + debug_assert_ne!(src, dest); + + let src_ebb = ctx.func.layout.inst_ebb(src).unwrap(); + let dest_ebb = ctx.func.layout.inst_ebb(dest).unwrap(); + if src_ebb == dest_ebb { + use std::cmp::Ordering::*; + match ctx.func.layout.cmp(src, dest) { + Less => TemporalOrder::DefinitivelyBefore, + Equal => unreachable!(), + Greater => TemporalOrder::MaybeBefore, // FIXME use dominator to check for loops + } + } else { + // FIXME O(stack_load count * ebb count) + // FIXME reuse memory allocations + // FIXME return DefinitivelyBefore is src dominates dest + let mut visited = EntitySet::new(); + let mut todo = EntitySet::new(); + todo.insert(dest_ebb); + while let Some(ebb) = todo.pop() { + if visited.contains(ebb) { + continue; + } + visited.insert(ebb); + if ebb == src_ebb { + return TemporalOrder::MaybeBefore; + } + for bb in ctx.cfg.pred_iter(ebb) { + todo.insert(bb.ebb); + } + } + TemporalOrder::NeverBefore + } +} From 6320c65484b69b9141d9e47781a2e1b086be743a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 16:11:04 +0100 Subject: [PATCH 1048/1566] Fix temporal_order argument order for store to load forwarding --- src/optimize/stack2reg.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 64f7ab0450368..8f27ad7c55711 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -116,9 +116,10 @@ pub(super) fn optimize_function( temporal_order(&*ctx, store, load), ); } + match *potential_stores { [] => println!("[{}] [BUG?] Reading uninitialized memory", name), - [store] if spatial_overlap(&ctx.func, load, store) == SpatialOverlap::Full && temporal_order(&ctx, load, store) == TemporalOrder::DefinitivelyBefore => { + [store] if spatial_overlap(&ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&ctx, store, load) == TemporalOrder::DefinitivelyBefore => { let store_ebb = ctx.func.layout.inst_ebb(store).unwrap(); let stored_value = ctx.func.dfg.inst_args(store)[0]; let stored_type = ctx.func.dfg.value_type(stored_value); From df7f68236c7f64449e4b236cd95fb30c53f4cbec Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 17:51:22 +0100 Subject: [PATCH 1049/1566] Remove stack_store without following stack_load --- src/optimize/stack2reg.rs | 47 ++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 8f27ad7c55711..cbf95eae61865 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -76,11 +76,9 @@ pub(super) fn optimize_function( // FIXME Repeat following instructions until fixpoint. - println!("{}:\nstack slot usage: {:?}", name, stack_slot_usage_map); - remove_unused_stack_addr_and_stack_load(&mut ctx.func, &mut stack_slot_usage_map); - println!("stack slot usage (after): {:?}", stack_slot_usage_map); + println!("stack slot usage: {:?}", stack_slot_usage_map); for (stack_slot, users) in stack_slot_usage_map.iter_mut() { if users.stack_addr.is_empty().not() { @@ -95,8 +93,6 @@ pub(super) fn optimize_function( let loaded_type = ctx.func.dfg.value_type(loaded_value); let potential_stores = users.stack_store.iter().cloned().filter(|&store| { - // Check if the store modified some memory accessed by the load. - match spatial_overlap(&ctx.func, load, store) { SpatialOverlap::No => false, // Can never be the source of the loaded value. SpatialOverlap::Partial | SpatialOverlap::Full => true, @@ -107,6 +103,7 @@ pub(super) fn optimize_function( TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, } }).collect::>(); + for &store in &potential_stores { println!( "Potential store -> load forwarding {} -> {} ({:?}, {:?})", @@ -120,6 +117,7 @@ pub(super) fn optimize_function( match *potential_stores { [] => println!("[{}] [BUG?] Reading uninitialized memory", name), [store] if spatial_overlap(&ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&ctx, store, load) == TemporalOrder::DefinitivelyBefore => { + // Only one store could have been the origin of the value. let store_ebb = ctx.func.layout.inst_ebb(store).unwrap(); let stored_value = ctx.func.dfg.inst_args(store)[0]; let stored_type = ctx.func.dfg.value_type(stored_value); @@ -135,12 +133,35 @@ pub(super) fn optimize_function( } } - if users.stack_load.is_empty() { - // Never loaded; can safely remove all stores and the stack slot. - // FIXME also remove stores when there is always a next store before a load. - for user in users.stack_store.drain() { - println!("[{}] Remove dead stack store {} of {}", name, user, stack_slot.0); - ctx.func.dfg.replace(user).nop(); + for store in users.stack_store.clone().drain() { + let potential_loads = users.stack_load.iter().cloned().filter(|&load| { + match spatial_overlap(&ctx.func, store, load) { + SpatialOverlap::No => false, // Can never be the source of the loaded value. + SpatialOverlap::Partial | SpatialOverlap::Full => true, + } + }).filter(|&load| { + match temporal_order(&*ctx, store, load) { + TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. + TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, + } + }).collect::>(); + + for &load in &potential_loads { + println!( + "Potential load from store {} <- {} ({:?}, {:?})", + ctx.func.dfg.display_inst(load, None), + ctx.func.dfg.display_inst(store, None), + spatial_overlap(&ctx.func, store, load), + temporal_order(&*ctx, store, load), + ); + } + + if potential_loads.is_empty() { + // Never loaded; can safely remove all stores and the stack slot. + // FIXME also remove stores when there is always a next store before a load. + println!("[{}] Remove dead stack store {} of {}", name, ctx.func.dfg.display_inst(store, None), stack_slot.0); + ctx.func.dfg.replace(store).nop(); + users.stack_store.remove(&store); } } @@ -205,8 +226,6 @@ fn remove_unused_stack_addr_and_stack_load(func: &mut Function, stack_slot_usage } } - println!("stack_addr/stack_load users: {:?}", stack_addr_load_insts_users); - for inst in stack_addr_load_insts_users.keys() { let mut is_recorded_stack_addr_or_stack_load = false; for stack_slot_users in stack_slot_usage_map.values() { @@ -220,7 +239,6 @@ fn remove_unused_stack_addr_and_stack_load(func: &mut Function, stack_slot_usage // FIXME remove clone for &inst in stack_slot_users.stack_addr.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - println!("Removing unused stack_addr {}", inst); func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); stack_slot_users.stack_addr.remove(&inst); @@ -229,7 +247,6 @@ fn remove_unused_stack_addr_and_stack_load(func: &mut Function, stack_slot_usage for &inst in stack_slot_users.stack_load.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - println!("Removing unused stack_addr {}", inst); func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); stack_slot_users.stack_load.remove(&inst); From 0f3eab589e5ee7e7b2a9f473f9879d30a410d669 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 18:07:51 +0100 Subject: [PATCH 1050/1566] Add OptimizeContext --- src/optimize/stack2reg.rs | 136 +++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 59 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index cbf95eae61865..2fc43aec97c07 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -31,56 +31,72 @@ struct StackSlotUsage { stack_store: HashSet, } +struct OptimizeContext<'a> { + ctx: &'a mut Context, + stack_slot_usage_map: BTreeMap, +} + +impl<'a> OptimizeContext<'a> { + fn for_context(ctx: &'a mut Context) -> Self { + ctx.flowgraph(); // Compute cfg and domtree. + + // Record all stack_addr, stack_load and stack_store instructions. + let mut stack_slot_usage_map = BTreeMap::::new(); + + let mut cursor = FuncCursor::new(&mut ctx.func); + while let Some(_ebb) = cursor.next_ebb() { + while let Some(inst) = cursor.next_inst() { + match cursor.func.dfg[inst] { + InstructionData::StackLoad { + opcode: Opcode::StackAddr, + stack_slot, + offset: _, + } => { + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_addr.insert(inst); + } + InstructionData::StackLoad { + opcode: Opcode::StackLoad, + stack_slot, + offset: _, + } => { + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_load.insert(inst); + } + InstructionData::StackStore { + opcode: Opcode::StackStore, + arg: _, + stack_slot, + offset: _, + } => { + stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_store.insert(inst); + } + _ => {} + } + } + } + + OptimizeContext { + ctx, + stack_slot_usage_map, + } + } +} + pub(super) fn optimize_function( ctx: &mut Context, clif_comments: &mut crate::pretty_clif::CommentWriter, name: String, // FIXME remove ) { - ctx.flowgraph(); // Compute cfg and domtree. - combine_stack_addr_with_load_store(&mut ctx.func); - // Record all stack_addr, stack_load and stack_store instructions. - let mut stack_slot_usage_map = BTreeMap::::new(); - - let mut cursor = FuncCursor::new(&mut ctx.func); - while let Some(_ebb) = cursor.next_ebb() { - while let Some(inst) = cursor.next_inst() { - match cursor.func.dfg[inst] { - InstructionData::StackLoad { - opcode: Opcode::StackAddr, - stack_slot, - offset: _, - } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_addr.insert(inst); - } - InstructionData::StackLoad { - opcode: Opcode::StackLoad, - stack_slot, - offset: _, - } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_load.insert(inst); - } - InstructionData::StackStore { - opcode: Opcode::StackStore, - arg: _, - stack_slot, - offset: _, - } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_store.insert(inst); - } - _ => {} - } - } - } + let mut opt_ctx = OptimizeContext::for_context(ctx); // FIXME Repeat following instructions until fixpoint. - remove_unused_stack_addr_and_stack_load(&mut ctx.func, &mut stack_slot_usage_map); + remove_unused_stack_addr_and_stack_load(&mut opt_ctx.ctx.func, &mut opt_ctx.stack_slot_usage_map); - println!("stack slot usage: {:?}", stack_slot_usage_map); + println!("stack slot usage: {:?}", opt_ctx.stack_slot_usage_map); - for (stack_slot, users) in stack_slot_usage_map.iter_mut() { + for (stack_slot, users) in opt_ctx.stack_slot_usage_map.iter_mut() { if users.stack_addr.is_empty().not() { // Stack addr leaked; there may be unknown loads and stores. // FIXME use stacked borrows to optimize @@ -88,17 +104,18 @@ pub(super) fn optimize_function( } for load in users.stack_load.clone().drain() { - let load_ebb = ctx.func.layout.inst_ebb(load).unwrap(); - let loaded_value = ctx.func.dfg.inst_results(load)[0]; - let loaded_type = ctx.func.dfg.value_type(loaded_value); + let load_ebb = opt_ctx.ctx.func.layout.inst_ebb(load).unwrap(); + let loaded_value = opt_ctx.ctx.func.dfg.inst_results(load)[0]; + let loaded_type = opt_ctx.ctx.func.dfg.value_type(loaded_value); + let ctx = &*opt_ctx.ctx; let potential_stores = users.stack_store.iter().cloned().filter(|&store| { match spatial_overlap(&ctx.func, load, store) { SpatialOverlap::No => false, // Can never be the source of the loaded value. SpatialOverlap::Partial | SpatialOverlap::Full => true, } }).filter(|&store| { - match temporal_order(&*ctx, load, store) { + match temporal_order(ctx, load, store) { TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, } @@ -107,25 +124,25 @@ pub(super) fn optimize_function( for &store in &potential_stores { println!( "Potential store -> load forwarding {} -> {} ({:?}, {:?})", - ctx.func.dfg.display_inst(store, None), - ctx.func.dfg.display_inst(load, None), - spatial_overlap(&ctx.func, store, load), - temporal_order(&*ctx, store, load), + opt_ctx.ctx.func.dfg.display_inst(store, None), + opt_ctx.ctx.func.dfg.display_inst(load, None), + spatial_overlap(&opt_ctx.ctx.func, store, load), + temporal_order(&*opt_ctx.ctx, store, load), ); } match *potential_stores { [] => println!("[{}] [BUG?] Reading uninitialized memory", name), - [store] if spatial_overlap(&ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&ctx, store, load) == TemporalOrder::DefinitivelyBefore => { + [store] if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&opt_ctx.ctx, store, load) == TemporalOrder::DefinitivelyBefore => { // Only one store could have been the origin of the value. - let store_ebb = ctx.func.layout.inst_ebb(store).unwrap(); - let stored_value = ctx.func.dfg.inst_args(store)[0]; - let stored_type = ctx.func.dfg.value_type(stored_value); + let store_ebb = opt_ctx.ctx.func.layout.inst_ebb(store).unwrap(); + let stored_value = opt_ctx.ctx.func.dfg.inst_args(store)[0]; + let stored_type = opt_ctx.ctx.func.dfg.value_type(stored_value); if stored_type == loaded_type && store_ebb == load_ebb { println!("Store to load forward {} -> {}", store, load); - ctx.func.dfg.detach_results(load); - ctx.func.dfg.replace(load).nop(); - ctx.func.dfg.change_to_alias(loaded_value, stored_value); + opt_ctx.ctx.func.dfg.detach_results(load); + opt_ctx.ctx.func.dfg.replace(load).nop(); + opt_ctx.ctx.func.dfg.change_to_alias(loaded_value, stored_value); users.stack_load.remove(&load); } } @@ -134,13 +151,14 @@ pub(super) fn optimize_function( } for store in users.stack_store.clone().drain() { + let ctx = &*opt_ctx.ctx; let potential_loads = users.stack_load.iter().cloned().filter(|&load| { match spatial_overlap(&ctx.func, store, load) { SpatialOverlap::No => false, // Can never be the source of the loaded value. SpatialOverlap::Partial | SpatialOverlap::Full => true, } }).filter(|&load| { - match temporal_order(&*ctx, store, load) { + match temporal_order(ctx, store, load) { TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, } @@ -149,18 +167,18 @@ pub(super) fn optimize_function( for &load in &potential_loads { println!( "Potential load from store {} <- {} ({:?}, {:?})", - ctx.func.dfg.display_inst(load, None), - ctx.func.dfg.display_inst(store, None), + opt_ctx.ctx.func.dfg.display_inst(load, None), + opt_ctx.ctx.func.dfg.display_inst(store, None), spatial_overlap(&ctx.func, store, load), - temporal_order(&*ctx, store, load), + temporal_order(&*opt_ctx.ctx, store, load), ); } if potential_loads.is_empty() { // Never loaded; can safely remove all stores and the stack slot. // FIXME also remove stores when there is always a next store before a load. - println!("[{}] Remove dead stack store {} of {}", name, ctx.func.dfg.display_inst(store, None), stack_slot.0); - ctx.func.dfg.replace(store).nop(); + println!("[{}] Remove dead stack store {} of {}", name, opt_ctx.ctx.func.dfg.display_inst(store, None), stack_slot.0); + opt_ctx.ctx.func.dfg.replace(store).nop(); users.stack_store.remove(&store); } } From af5a2a8509d1e4208bf626037a9c190ff371f12d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Dec 2019 18:16:43 +0100 Subject: [PATCH 1051/1566] Let remove_unused_stack_addr_and_stack_load take OptimizeContext --- src/optimize/stack2reg.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 2fc43aec97c07..5cc3e8506b438 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -92,7 +92,7 @@ pub(super) fn optimize_function( // FIXME Repeat following instructions until fixpoint. - remove_unused_stack_addr_and_stack_load(&mut opt_ctx.ctx.func, &mut opt_ctx.stack_slot_usage_map); + remove_unused_stack_addr_and_stack_load(&mut opt_ctx); println!("stack slot usage: {:?}", opt_ctx.stack_slot_usage_map); @@ -224,11 +224,11 @@ fn combine_stack_addr_with_load_store(func: &mut Function) { } } -fn remove_unused_stack_addr_and_stack_load(func: &mut Function, stack_slot_usage_map: &mut BTreeMap) { +fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext) { // FIXME incrementally rebuild on each call? let mut stack_addr_load_insts_users = HashMap::>::new(); - let mut cursor = FuncCursor::new(func); + let mut cursor = FuncCursor::new(&mut opt_ctx.ctx.func); while let Some(_ebb) = cursor.next_ebb() { while let Some(inst) = cursor.next_inst() { for &arg in cursor.func.dfg.inst_args(inst) { @@ -246,27 +246,27 @@ fn remove_unused_stack_addr_and_stack_load(func: &mut Function, stack_slot_usage for inst in stack_addr_load_insts_users.keys() { let mut is_recorded_stack_addr_or_stack_load = false; - for stack_slot_users in stack_slot_usage_map.values() { + for stack_slot_users in opt_ctx.stack_slot_usage_map.values() { is_recorded_stack_addr_or_stack_load |= stack_slot_users.stack_addr.contains(inst) || stack_slot_users.stack_load.contains(inst); } assert!(is_recorded_stack_addr_or_stack_load); } // Replace all unused stack_addr and stack_load instructions with nop. - for stack_slot_users in stack_slot_usage_map.values_mut() { + for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { // FIXME remove clone for &inst in stack_slot_users.stack_addr.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - func.dfg.detach_results(inst); - func.dfg.replace(inst).nop(); + opt_ctx.ctx.func.dfg.detach_results(inst); + opt_ctx.ctx.func.dfg.replace(inst).nop(); stack_slot_users.stack_addr.remove(&inst); } } for &inst in stack_slot_users.stack_load.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - func.dfg.detach_results(inst); - func.dfg.replace(inst).nop(); + opt_ctx.ctx.func.dfg.detach_results(inst); + opt_ctx.ctx.func.dfg.replace(inst).nop(); stack_slot_users.stack_load.remove(&inst); } } From 79148a3c1e962e030105a88b5ed694b593ad100d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Dec 2019 20:02:32 +0100 Subject: [PATCH 1052/1566] Extract potential_stores_for_load and potential_loads_of_store functions --- src/optimize/stack2reg.rs | 66 ++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 5cc3e8506b438..cf4da032ff689 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -31,6 +31,36 @@ struct StackSlotUsage { stack_store: HashSet, } +impl StackSlotUsage { + fn potential_stores_for_load(&self, ctx: &Context, load: Inst) -> Vec { + self.stack_store.iter().cloned().filter(|&store| { + match spatial_overlap(&ctx.func, load, store) { + SpatialOverlap::No => false, // Can never be the source of the loaded value. + SpatialOverlap::Partial | SpatialOverlap::Full => true, + } + }).filter(|&store| { + match temporal_order(ctx, load, store) { + TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. + TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, + } + }).collect::>() + } + + fn potential_loads_of_store(&self, ctx: &Context, store: Inst) -> Vec { + self.stack_load.iter().cloned().filter(|&load| { + match spatial_overlap(&ctx.func, store, load) { + SpatialOverlap::No => false, // Can never be the source of the loaded value. + SpatialOverlap::Partial | SpatialOverlap::Full => true, + } + }).filter(|&load| { + match temporal_order(ctx, store, load) { + TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. + TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, + } + }).collect::>() + } +} + struct OptimizeContext<'a> { ctx: &'a mut Context, stack_slot_usage_map: BTreeMap, @@ -103,23 +133,12 @@ pub(super) fn optimize_function( continue; } - for load in users.stack_load.clone().drain() { + for load in users.stack_load.clone().into_iter() { let load_ebb = opt_ctx.ctx.func.layout.inst_ebb(load).unwrap(); let loaded_value = opt_ctx.ctx.func.dfg.inst_results(load)[0]; let loaded_type = opt_ctx.ctx.func.dfg.value_type(loaded_value); - let ctx = &*opt_ctx.ctx; - let potential_stores = users.stack_store.iter().cloned().filter(|&store| { - match spatial_overlap(&ctx.func, load, store) { - SpatialOverlap::No => false, // Can never be the source of the loaded value. - SpatialOverlap::Partial | SpatialOverlap::Full => true, - } - }).filter(|&store| { - match temporal_order(ctx, load, store) { - TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. - TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, - } - }).collect::>(); + let potential_stores = users.potential_stores_for_load(&opt_ctx.ctx, load); for &store in &potential_stores { println!( @@ -127,7 +146,7 @@ pub(super) fn optimize_function( opt_ctx.ctx.func.dfg.display_inst(store, None), opt_ctx.ctx.func.dfg.display_inst(load, None), spatial_overlap(&opt_ctx.ctx.func, store, load), - temporal_order(&*opt_ctx.ctx, store, load), + temporal_order(&opt_ctx.ctx, store, load), ); } @@ -150,27 +169,16 @@ pub(super) fn optimize_function( } } - for store in users.stack_store.clone().drain() { - let ctx = &*opt_ctx.ctx; - let potential_loads = users.stack_load.iter().cloned().filter(|&load| { - match spatial_overlap(&ctx.func, store, load) { - SpatialOverlap::No => false, // Can never be the source of the loaded value. - SpatialOverlap::Partial | SpatialOverlap::Full => true, - } - }).filter(|&load| { - match temporal_order(ctx, store, load) { - TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. - TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, - } - }).collect::>(); + for store in users.stack_store.clone().into_iter() { + let potential_loads = users.potential_loads_of_store(&opt_ctx.ctx, store); for &load in &potential_loads { println!( "Potential load from store {} <- {} ({:?}, {:?})", opt_ctx.ctx.func.dfg.display_inst(load, None), opt_ctx.ctx.func.dfg.display_inst(store, None), - spatial_overlap(&ctx.func, store, load), - temporal_order(&*opt_ctx.ctx, store, load), + spatial_overlap(&opt_ctx.ctx.func, store, load), + temporal_order(&opt_ctx.ctx, store, load), ); } From 7c4debdb7c606890006c68278b7d4ea6146834e2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Dec 2019 20:25:34 +0100 Subject: [PATCH 1053/1566] Add functions to remove loads stores etc --- src/optimize/stack2reg.rs | 41 +++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index cf4da032ff689..340f16b587d95 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -59,6 +59,31 @@ impl StackSlotUsage { } }).collect::>() } + + fn remove_unused_stack_addr(&mut self, func: &mut Function, inst: Inst) { + func.dfg.detach_results(inst); + func.dfg.replace(inst).nop(); + self.stack_addr.remove(&inst); + } + + fn remove_unused_load(&mut self, func: &mut Function, load: Inst) { + func.dfg.detach_results(load); + func.dfg.replace(load).nop(); + self.stack_load.remove(&load); + } + + fn remove_dead_store(&mut self, func: &mut Function, store: Inst) { + func.dfg.replace(store).nop(); + self.stack_store.remove(&store); + } + + fn change_load_to_alias(&mut self, func: &mut Function, load: Inst, value: Value) { + let loaded_value = func.dfg.inst_results(load)[0]; + func.dfg.detach_results(load); + func.dfg.replace(load).nop(); + func.dfg.change_to_alias(loaded_value, value); + self.stack_load.remove(&load); + } } struct OptimizeContext<'a> { @@ -159,10 +184,7 @@ pub(super) fn optimize_function( let stored_type = opt_ctx.ctx.func.dfg.value_type(stored_value); if stored_type == loaded_type && store_ebb == load_ebb { println!("Store to load forward {} -> {}", store, load); - opt_ctx.ctx.func.dfg.detach_results(load); - opt_ctx.ctx.func.dfg.replace(load).nop(); - opt_ctx.ctx.func.dfg.change_to_alias(loaded_value, stored_value); - users.stack_load.remove(&load); + users.change_load_to_alias(&mut opt_ctx.ctx.func, load, stored_value); } } _ => {} // FIXME implement this @@ -186,8 +208,7 @@ pub(super) fn optimize_function( // Never loaded; can safely remove all stores and the stack slot. // FIXME also remove stores when there is always a next store before a load. println!("[{}] Remove dead stack store {} of {}", name, opt_ctx.ctx.func.dfg.display_inst(store, None), stack_slot.0); - opt_ctx.ctx.func.dfg.replace(store).nop(); - users.stack_store.remove(&store); + users.remove_dead_store(&mut opt_ctx.ctx.func, store); } } @@ -265,17 +286,13 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext) { // FIXME remove clone for &inst in stack_slot_users.stack_addr.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - opt_ctx.ctx.func.dfg.detach_results(inst); - opt_ctx.ctx.func.dfg.replace(inst).nop(); - stack_slot_users.stack_addr.remove(&inst); + stack_slot_users.remove_unused_stack_addr(&mut opt_ctx.ctx.func, inst); } } for &inst in stack_slot_users.stack_load.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - opt_ctx.ctx.func.dfg.detach_results(inst); - opt_ctx.ctx.func.dfg.replace(inst).nop(); - stack_slot_users.stack_load.remove(&inst); + stack_slot_users.remove_unused_load(&mut opt_ctx.ctx.func, inst); } } } From d6c2db2aea720b8f93d9840bfe929b1837951168 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Dec 2019 20:52:57 +0100 Subject: [PATCH 1054/1566] Return use domtree.dominates in temporal_order --- src/optimize/stack2reg.rs | 49 ++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 340f16b587d95..2b48d823225d2 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -182,7 +182,7 @@ pub(super) fn optimize_function( let store_ebb = opt_ctx.ctx.func.layout.inst_ebb(store).unwrap(); let stored_value = opt_ctx.ctx.func.dfg.inst_args(store)[0]; let stored_type = opt_ctx.ctx.func.dfg.value_type(stored_value); - if stored_type == loaded_type && store_ebb == load_ebb { + if stored_type == loaded_type { println!("Store to load forward {} -> {}", store, load); users.change_load_to_alias(&mut opt_ctx.ctx.func, load, stored_value); } @@ -379,34 +379,31 @@ enum TemporalOrder { fn temporal_order(ctx: &Context, src: Inst, dest: Inst) -> TemporalOrder { debug_assert_ne!(src, dest); + if ctx.domtree.dominates(src, dest, &ctx.func.layout) { + return TemporalOrder::DefinitivelyBefore; + } else if ctx.domtree.dominates(src, dest, &ctx.func.layout) { + return TemporalOrder::NeverBefore; + } + let src_ebb = ctx.func.layout.inst_ebb(src).unwrap(); let dest_ebb = ctx.func.layout.inst_ebb(dest).unwrap(); - if src_ebb == dest_ebb { - use std::cmp::Ordering::*; - match ctx.func.layout.cmp(src, dest) { - Less => TemporalOrder::DefinitivelyBefore, - Equal => unreachable!(), - Greater => TemporalOrder::MaybeBefore, // FIXME use dominator to check for loops + + // FIXME O(stack_load count * ebb count) + // FIXME reuse memory allocations + let mut visited = EntitySet::new(); + let mut todo = EntitySet::new(); + todo.insert(dest_ebb); + while let Some(ebb) = todo.pop() { + if visited.contains(ebb) { + continue; } - } else { - // FIXME O(stack_load count * ebb count) - // FIXME reuse memory allocations - // FIXME return DefinitivelyBefore is src dominates dest - let mut visited = EntitySet::new(); - let mut todo = EntitySet::new(); - todo.insert(dest_ebb); - while let Some(ebb) = todo.pop() { - if visited.contains(ebb) { - continue; - } - visited.insert(ebb); - if ebb == src_ebb { - return TemporalOrder::MaybeBefore; - } - for bb in ctx.cfg.pred_iter(ebb) { - todo.insert(bb.ebb); - } + visited.insert(ebb); + if ebb == src_ebb { + return TemporalOrder::MaybeBefore; + } + for bb in ctx.cfg.pred_iter(ebb) { + todo.insert(bb.ebb); } - TemporalOrder::NeverBefore } + TemporalOrder::NeverBefore } From fd5efa0921d59db36c87361bf90e19997358968e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Dec 2019 21:20:17 +0100 Subject: [PATCH 1055/1566] Fix potential_stores_for_load --- src/optimize/stack2reg.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 2b48d823225d2..4153892a673be 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -34,12 +34,12 @@ struct StackSlotUsage { impl StackSlotUsage { fn potential_stores_for_load(&self, ctx: &Context, load: Inst) -> Vec { self.stack_store.iter().cloned().filter(|&store| { - match spatial_overlap(&ctx.func, load, store) { + match spatial_overlap(&ctx.func, store, load) { SpatialOverlap::No => false, // Can never be the source of the loaded value. SpatialOverlap::Partial | SpatialOverlap::Full => true, } }).filter(|&store| { - match temporal_order(ctx, load, store) { + match temporal_order(ctx, store, load) { TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, } From 790132523f051bd1396db9e9c46a18e8c3dcd19b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Dec 2019 21:26:49 +0100 Subject: [PATCH 1056/1566] Support store to load forwarding for different types of the same size --- src/optimize/stack2reg.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 4153892a673be..eeedb7542fdd0 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -79,9 +79,16 @@ impl StackSlotUsage { fn change_load_to_alias(&mut self, func: &mut Function, load: Inst, value: Value) { let loaded_value = func.dfg.inst_results(load)[0]; - func.dfg.detach_results(load); - func.dfg.replace(load).nop(); - func.dfg.change_to_alias(loaded_value, value); + let loaded_type = func.dfg.value_type(loaded_value); + + if func.dfg.value_type(value) == loaded_type { + func.dfg.detach_results(load); + func.dfg.replace(load).nop(); + func.dfg.change_to_alias(loaded_value, value); + } else { + func.dfg.replace(load).bitcast(loaded_type, value); + } + self.stack_load.remove(&load); } } @@ -159,7 +166,6 @@ pub(super) fn optimize_function( } for load in users.stack_load.clone().into_iter() { - let load_ebb = opt_ctx.ctx.func.layout.inst_ebb(load).unwrap(); let loaded_value = opt_ctx.ctx.func.dfg.inst_results(load)[0]; let loaded_type = opt_ctx.ctx.func.dfg.value_type(loaded_value); @@ -179,13 +185,9 @@ pub(super) fn optimize_function( [] => println!("[{}] [BUG?] Reading uninitialized memory", name), [store] if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&opt_ctx.ctx, store, load) == TemporalOrder::DefinitivelyBefore => { // Only one store could have been the origin of the value. - let store_ebb = opt_ctx.ctx.func.layout.inst_ebb(store).unwrap(); let stored_value = opt_ctx.ctx.func.dfg.inst_args(store)[0]; - let stored_type = opt_ctx.ctx.func.dfg.value_type(stored_value); - if stored_type == loaded_type { - println!("Store to load forward {} -> {}", store, load); - users.change_load_to_alias(&mut opt_ctx.ctx.func, load, stored_value); - } + println!("Store to load forward {} -> {}", store, load); + users.change_load_to_alias(&mut opt_ctx.ctx.func, load, stored_value); } _ => {} // FIXME implement this } From b47c89de0ec4377e2cf8d0c48cb9d1952440ca65 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 12:25:23 +0100 Subject: [PATCH 1057/1566] Remove unnecessary check from temporal_order --- src/optimize/stack2reg.rs | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index eeedb7542fdd0..ef0f99bf6b258 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -382,30 +382,10 @@ fn temporal_order(ctx: &Context, src: Inst, dest: Inst) -> TemporalOrder { debug_assert_ne!(src, dest); if ctx.domtree.dominates(src, dest, &ctx.func.layout) { - return TemporalOrder::DefinitivelyBefore; + TemporalOrder::DefinitivelyBefore } else if ctx.domtree.dominates(src, dest, &ctx.func.layout) { - return TemporalOrder::NeverBefore; + TemporalOrder::NeverBefore + } else { + TemporalOrder::MaybeBefore } - - let src_ebb = ctx.func.layout.inst_ebb(src).unwrap(); - let dest_ebb = ctx.func.layout.inst_ebb(dest).unwrap(); - - // FIXME O(stack_load count * ebb count) - // FIXME reuse memory allocations - let mut visited = EntitySet::new(); - let mut todo = EntitySet::new(); - todo.insert(dest_ebb); - while let Some(ebb) = todo.pop() { - if visited.contains(ebb) { - continue; - } - visited.insert(ebb); - if ebb == src_ebb { - return TemporalOrder::MaybeBefore; - } - for bb in ctx.cfg.pred_iter(ebb) { - todo.insert(bb.ebb); - } - } - TemporalOrder::NeverBefore } From 0cb2b6055979c28a7326c7a80c4cf3d51bfad487 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 15:26:58 +0100 Subject: [PATCH 1058/1566] Don't print debug messages in release mode --- src/optimize/mod.rs | 2 +- src/optimize/stack2reg.rs | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 64400e8886a0f..34f6852613686 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -8,7 +8,7 @@ pub fn optimize_function<'tcx>( ctx: &mut Context, clif_comments: &mut crate::pretty_clif::CommentWriter, ) { - self::stack2reg::optimize_function(ctx, clif_comments, format!("{:?}", instance)); + self::stack2reg::optimize_function(ctx, clif_comments, instance); #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None); crate::base::verify_func(tcx, &*clif_comments, &ctx.func); diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index ef0f99bf6b258..210a8c5ec1684 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -143,10 +143,10 @@ impl<'a> OptimizeContext<'a> { } } -pub(super) fn optimize_function( +pub(super) fn optimize_function( ctx: &mut Context, clif_comments: &mut crate::pretty_clif::CommentWriter, - name: String, // FIXME remove + name: T, ) { combine_stack_addr_with_load_store(&mut ctx.func); @@ -156,7 +156,9 @@ pub(super) fn optimize_function( remove_unused_stack_addr_and_stack_load(&mut opt_ctx); - println!("stack slot usage: {:?}", opt_ctx.stack_slot_usage_map); + #[cfg(debug_assertions)] { + println!("stack slot usage: {:?}", opt_ctx.stack_slot_usage_map); + } for (stack_slot, users) in opt_ctx.stack_slot_usage_map.iter_mut() { if users.stack_addr.is_empty().not() { @@ -171,6 +173,7 @@ pub(super) fn optimize_function( let potential_stores = users.potential_stores_for_load(&opt_ctx.ctx, load); + #[cfg(debug_assertions)] for &store in &potential_stores { println!( "Potential store -> load forwarding {} -> {} ({:?}, {:?})", @@ -182,11 +185,19 @@ pub(super) fn optimize_function( } match *potential_stores { - [] => println!("[{}] [BUG?] Reading uninitialized memory", name), + [] => { + #[cfg(debug_assertions)] { + println!("[{:?}] [BUG?] Reading uninitialized memory", name); + } + } [store] if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&opt_ctx.ctx, store, load) == TemporalOrder::DefinitivelyBefore => { // Only one store could have been the origin of the value. let stored_value = opt_ctx.ctx.func.dfg.inst_args(store)[0]; - println!("Store to load forward {} -> {}", store, load); + + #[cfg(debug_assertions)] { + println!("Store to load forward {} -> {}", store, load); + } + users.change_load_to_alias(&mut opt_ctx.ctx.func, load, stored_value); } _ => {} // FIXME implement this @@ -196,6 +207,7 @@ pub(super) fn optimize_function( for store in users.stack_store.clone().into_iter() { let potential_loads = users.potential_loads_of_store(&opt_ctx.ctx, store); + #[cfg(debug_assertions)] for &load in &potential_loads { println!( "Potential load from store {} <- {} ({:?}, {:?})", @@ -209,7 +221,10 @@ pub(super) fn optimize_function( if potential_loads.is_empty() { // Never loaded; can safely remove all stores and the stack slot. // FIXME also remove stores when there is always a next store before a load. - println!("[{}] Remove dead stack store {} of {}", name, opt_ctx.ctx.func.dfg.display_inst(store, None), stack_slot.0); + + #[cfg(debug_assertions)] { + println!("[{:?}] Remove dead stack store {} of {}", name, opt_ctx.ctx.func.dfg.display_inst(store, None), stack_slot.0); + } users.remove_dead_store(&mut opt_ctx.ctx.func, store); } } @@ -219,7 +234,9 @@ pub(super) fn optimize_function( } } - println!(); + #[cfg(debug_assertions)] { + println!(); + } } fn combine_stack_addr_with_load_store(func: &mut Function) { @@ -275,6 +292,7 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext) { } } + #[cfg(debug_assertions)] for inst in stack_addr_load_insts_users.keys() { let mut is_recorded_stack_addr_or_stack_load = false; for stack_slot_users in opt_ctx.stack_slot_usage_map.values() { From dbb118a5bccc4a1fd71503abb777f684c3ccce68 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 15:36:29 +0100 Subject: [PATCH 1059/1566] Fix some warnings --- src/optimize/stack2reg.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 210a8c5ec1684..2abf865cf3eec 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -3,7 +3,7 @@ use std::ops::Not; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::entity::EntitySet; -use cranelift_codegen::ir::{InstructionData, Opcode, ProgramOrder, ValueDef}; +use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; use crate::prelude::*; @@ -168,9 +168,6 @@ pub(super) fn optimize_function( } for load in users.stack_load.clone().into_iter() { - let loaded_value = opt_ctx.ctx.func.dfg.inst_results(load)[0]; - let loaded_type = opt_ctx.ctx.func.dfg.value_type(loaded_value); - let potential_stores = users.potential_stores_for_load(&opt_ctx.ctx, load); #[cfg(debug_assertions)] From 4c7abd504ce2c534e3f2eedfeecf466f83c693da Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 15:59:49 +0100 Subject: [PATCH 1060/1566] Revert some changes --- example/mini_core.rs | 4 ---- src/base.rs | 2 +- src/value_and_place.rs | 13 +++++++++++++ test.sh | 15 ++++++--------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index f649c945c0590..1912cc50a218e 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -394,10 +394,6 @@ pub trait FnMut: FnOnce { #[lang = "panic"] pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! { - panic_inner(&_msg); -} - -pub fn panic_inner(_msg: &&str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort(); diff --git a/src/base.rs b/src/base.rs index 0adca5bee8b11..81ca47fe64580 100644 --- a/src/base.rs +++ b/src/base.rs @@ -269,7 +269,7 @@ fn trans_stmt<'tcx>( fx.set_debug_loc(stmt.source_info); - #[cfg(false_debug_assertions)] + #[cfg(debug_assertions)] match &stmt.kind { StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful _ => { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 6f0c615c9502a..39eb7d2470744 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -362,6 +362,19 @@ impl<'tcx> CPlace<'tcx> { } pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { + #[cfg(debug_assertions)] + { + use cranelift_codegen::cursor::{Cursor, CursorPosition}; + let cur_ebb = match fx.bcx.cursor().position() { + CursorPosition::After(ebb) => ebb, + _ => unreachable!(), + }; + fx.add_comment( + fx.bcx.func.layout.last_inst(cur_ebb).unwrap(), + format!("write_cvalue: {:?} <- {:?}",self, from), + ); + } + let from_ty = from.layout().ty; let to_ty = self.layout().ty; diff --git a/test.sh b/test.sh index 98171bc0f6a3e..e502a20db5bef 100755 --- a/test.sh +++ b/test.sh @@ -4,10 +4,10 @@ set -e if [[ "$1" == "--release" ]]; then export CHANNEL='release' - cargo rustc --release $CG_CLIF_COMPILE_FLAGS -- -Clink-args=-fuse-ld=lld + cargo build --release $CG_CLIF_COMPILE_FLAGS else export CHANNEL='debug' - cargo rustc $CG_CLIF_COMPILE_FLAGS -- -Clink-args=-fuse-ld=lld + cargo build $CG_CLIF_COMPILE_FLAGS fi source config.sh @@ -28,8 +28,6 @@ mkdir -p target/out/clif echo "[BUILD] mini_core" $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib -#exit 1 - echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib @@ -71,16 +69,15 @@ $RUSTC example/mod_bench.rs --crate-type bin pushd simple-raytracer echo "[BENCH COMPILE] ebobby/simple-raytracer" -rm -r target/x86_64*/ -../cargo.sh build +hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \ + "RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \ + "../cargo.sh build" echo "[BENCH RUN] ebobby/simple-raytracer" cp ./target/*/debug/main ./raytracer_cg_clif -hyperfine --runs ${RUN_RUNS:-10} ./raytracer_* +hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif popd -exit 1 - pushd build_sysroot/sysroot_src/src/libcore/tests rm -r ./target || true ../../../../../cargo.sh test From 196008bee3048dc330de1591e554b129c0bf5a56 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Dec 2019 16:43:24 +0100 Subject: [PATCH 1061/1566] Disable stack2reg opt when optimizations are disabled --- src/lib.rs | 1 + src/optimize/mod.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 02cfe160370e8..cbe07643a40df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ extern crate rustc_fs_util; extern crate rustc_incremental; extern crate rustc_index; extern crate rustc_mir; +extern crate rustc_session; extern crate rustc_target; extern crate syntax; diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 34f6852613686..59e4d2dd47d1e 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -8,6 +8,9 @@ pub fn optimize_function<'tcx>( ctx: &mut Context, clif_comments: &mut crate::pretty_clif::CommentWriter, ) { + if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No { + return; // FIXME classify optimizations over opt levels + } self::stack2reg::optimize_function(ctx, clif_comments, instance); #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None); From e9a8d8bf67ca0aab07f7796126f56ad8ee8fc5b2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jan 2020 21:30:56 +0100 Subject: [PATCH 1062/1566] Enable incr comp in release mode --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index e502a20db5bef..1b28075f0f097 100755 --- a/test.sh +++ b/test.sh @@ -4,7 +4,7 @@ set -e if [[ "$1" == "--release" ]]; then export CHANNEL='release' - cargo build --release $CG_CLIF_COMPILE_FLAGS + CARGO_INCREMENTAL=1 cargo build --release $CG_CLIF_COMPILE_FLAGS else export CHANNEL='debug' cargo build $CG_CLIF_COMPILE_FLAGS From 87d6953719c5b9c3e7fe4c5a97d2e845dcb52d57 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 11:31:56 +0100 Subject: [PATCH 1063/1566] Add documentation about the UB of the stack2reg optimization --- src/optimize/stack2reg.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 2abf865cf3eec..4762b40db8dd9 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -1,3 +1,14 @@ +//! This optimization replaces stack accesses with SSA variables and removes dead stores when possible. +//! +//! # Undefined behaviour +//! +//! This optimization is based on the assumption that stack slots which don't have their address +//! leaked through `stack_addr` are only accessed using `stack_load` and `stack_store` in the +//! function which has the stack slots. This optimization also assumes that stack slot accesses +//! are never out of bounds. If these assumptions are not correct, then this optimization may remove +//! `stack_store` instruction incorrectly, or incorrectly use a previously stored value as the value +//! being loaded by a `stack_load`. + use std::collections::{BTreeMap, HashSet}; use std::ops::Not; From c9034e54e57d03570fd6f3c228b00cf5560abf7d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 12:33:39 +0100 Subject: [PATCH 1064/1566] Add two FIXME's --- src/intrinsics/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index e17c38a8ef794..a8dfb404bf498 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -424,8 +424,10 @@ pub fn codegen_intrinsic_call<'tcx>( let byte_amount = fx.bcx.ins().imul(count, elem_size); if intrinsic.ends_with("_nonoverlapping") { + // FIXME emit_small_memcpy fx.bcx.call_memcpy(fx.module.target_config(), dst, src, byte_amount); } else { + // FIXME emit_small_memmove fx.bcx.call_memmove(fx.module.target_config(), dst, src, byte_amount); } }; From ff1c62365e0be3e96fb5d8d3938283cbf101d84b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 12:57:38 +0100 Subject: [PATCH 1065/1566] Remove faerie machO alignment workaround Fixes #738 --- src/constant.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 8621209765fb9..d53a5dcad35b2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -303,11 +303,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let mut data_ctx = DataContext::new(); - let mut bytes = alloc.inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); - // The machO backend of faerie doesn't align data objects correctly unless we do this. - while bytes.len() as u64 % 16 != 0 { - bytes.push(0xde); - } + let bytes = alloc.inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); data_ctx.define(bytes.into_boxed_slice()); for &(offset, (_tag, reloc)) in alloc.relocations().iter() { From ca92695a2c1fd7cfc58d7d769d3bc3bece2a01fa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 13:23:42 +0100 Subject: [PATCH 1066/1566] Use IndexVec for ebb_map cc #745 --- src/abi/mod.rs | 2 +- src/base.rs | 6 ++---- src/common.rs | 5 +++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index cde362e183473..b8bf2cf831a11 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -398,7 +398,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: fx.bcx .ins() - .jump(*fx.ebb_map.get(&START_BLOCK).unwrap(), &[]); + .jump(*fx.ebb_map.get(START_BLOCK).unwrap(), &[]); } pub fn codegen_terminator_call<'tcx>( diff --git a/src/base.rs b/src/base.rs index 81ca47fe64580..ac18ff6228a5a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,4 +1,5 @@ use rustc::ty::adjustment::PointerCast; +use rustc_index::vec::IndexVec; use crate::prelude::*; @@ -27,10 +28,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Predefine ebb's let start_ebb = bcx.create_ebb(); - let mut ebb_map: HashMap = HashMap::new(); - for (bb, _bb_data) in mir.basic_blocks().iter_enumerated() { - ebb_map.insert(bb, bcx.create_ebb()); - } + let ebb_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_ebb()).collect(); // Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); diff --git a/src/common.rs b/src/common.rs index b14e8af79a8d8..e5b932947ccc5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,5 +1,6 @@ use rustc::ty::layout::{Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; +use rustc_index::vec::IndexVec; use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; @@ -263,7 +264,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub mir: &'tcx Body<'tcx>, pub bcx: FunctionBuilder<'clif>, - pub ebb_map: HashMap, + pub ebb_map: IndexVec, pub local_map: HashMap>, pub clif_comments: crate::pretty_clif::CommentWriter, @@ -341,7 +342,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { - *self.ebb_map.get(&bb).unwrap() + *self.ebb_map.get(bb).unwrap() } pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { From c5a7fca527961f1992afed245f02dc9c27e5049d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 17:49:00 +0100 Subject: [PATCH 1067/1566] Use DUMMY_SP in less places Fixes #845 --- src/base.rs | 2 +- src/constant.rs | 2 ++ src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index ac18ff6228a5a..b0b92a72cf87f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -501,7 +501,7 @@ fn trans_stmt<'tcx>( assert!(lval .layout() .ty - .is_sized(fx.tcx.at(DUMMY_SP), ParamEnv::reveal_all())); + .is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size.into()); lval.write_cvalue(fx, val); diff --git a/src/constant.rs b/src/constant.rs index d53a5dcad35b2..1dfe4122a36a2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,5 +1,7 @@ use std::borrow::Cow; +use syntax::source_map::DUMMY_SP; + use rustc::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, }; diff --git a/src/lib.rs b/src/lib.rs index cbe07643a40df..c0a2433ceeb4b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,7 +64,7 @@ mod prelude { pub use std::convert::{TryFrom, TryInto}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; - pub use syntax::source_map::{Pos, Span, DUMMY_SP}; + pub use syntax::source_map::{Pos, Span}; pub use rustc::bug; pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; From 1bb848d4ac211ff0e81ee5ae4d92bb42b7faac8a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 17:58:38 +0100 Subject: [PATCH 1068/1566] Re-use cranelift_codegen::ir::Function for every function Fixes #844 --- src/base.rs | 18 +++++++++--------- src/common.rs | 2 +- src/lib.rs | 22 +++++----------------- src/vtable.rs | 4 ++-- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/base.rs b/src/base.rs index b0b92a72cf87f..0d71438cee92a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -21,10 +21,13 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( .map(|debug_context| FunctionDebugContext::new(debug_context, instance, func_id, &name)); // Make FunctionBuilder - let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); - func.collect_debug_info(); + let context = &mut cx.cached_context; + context.clear(); + context.func.name = ExternalName::user(0, func_id.as_u32()); + context.func.signature = sig; + context.func.collect_debug_info(); let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); + let mut bcx = FunctionBuilder::new(&mut context.func, &mut func_ctx); // Predefine ebb's let start_ebb = bcx.create_ebb(); @@ -48,7 +51,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( clif_comments, constants_cx: &mut cx.constants_cx, - caches: &mut cx.caches, + vtables: &mut cx.vtables, source_info_set: indexmap::IndexSet::new(), }; @@ -69,13 +72,10 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let local_map = fx.local_map; #[cfg(debug_assertions)] - crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &func, &clif_comments, None); + crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &context.func, &clif_comments, None); // Verify function - verify_func(tcx, &clif_comments, &func); - - let context = &mut cx.caches.context; - context.func = func; + verify_func(tcx, &clif_comments, &context.func); // Perform rust specific optimizations crate::optimize::optimize_function(cx.tcx, instance, context, &mut clif_comments); diff --git a/src/common.rs b/src/common.rs index e5b932947ccc5..3543df9cb865e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -269,7 +269,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub clif_comments: crate::pretty_clif::CommentWriter, pub constants_cx: &'clif mut crate::constant::ConstantCx, - pub caches: &'clif mut Caches<'tcx>, + pub vtables: &'clif mut HashMap<(Ty<'tcx>, Option>), DataId>, pub source_info_set: indexmap::IndexSet, } diff --git a/src/lib.rs b/src/lib.rs index c0a2433ceeb4b..c318b868ff504 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -114,7 +114,7 @@ mod prelude { pub use crate::trap::*; pub use crate::unimpl::unimpl; pub use crate::value_and_place::{CPlace, CPlaceInner, CValue}; - pub use crate::{Caches, CodegenCx}; + pub use crate::CodegenCx; pub struct PrintOnPanic String>(pub F); impl String> Drop for PrintOnPanic { @@ -126,25 +126,12 @@ mod prelude { } } -pub struct Caches<'tcx> { - pub context: Context, - pub vtables: HashMap<(Ty<'tcx>, Option>), DataId>, -} - -impl Default for Caches<'_> { - fn default() -> Self { - Caches { - context: Context::new(), - vtables: HashMap::new(), - } - } -} - pub struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { tcx: TyCtxt<'tcx>, module: &'clif mut Module, constants_cx: ConstantCx, - caches: Caches<'tcx>, + cached_context: Context, + vtables: HashMap<(Ty<'tcx>, Option>), DataId>, debug_context: Option<&'clif mut DebugContext<'tcx>>, } @@ -158,7 +145,8 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { tcx, module, constants_cx: ConstantCx::default(), - caches: Caches::default(), + cached_context: Context::new(), + vtables: HashMap::new(), debug_context, } } diff --git a/src/vtable.rs b/src/vtable.rs index c12dff3cdc6b3..913bb712da3cb 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -63,11 +63,11 @@ pub fn get_vtable<'tcx>( ty: Ty<'tcx>, trait_ref: Option>, ) -> Value { - let data_id = if let Some(data_id) = fx.caches.vtables.get(&(ty, trait_ref)) { + let data_id = if let Some(data_id) = fx.vtables.get(&(ty, trait_ref)) { *data_id } else { let data_id = build_vtable(fx, ty, trait_ref); - fx.caches.vtables.insert((ty, trait_ref), data_id); + fx.vtables.insert((ty, trait_ref), data_id); data_id }; From b4802b80540408a97d43e0810f2b4bea60d18612 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 18:20:00 +0100 Subject: [PATCH 1069/1566] Fix codegen of unimpl in simd_extract and unimpl simd_insert --- src/intrinsics/simd.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 17b6f230c88ad..cd163aa7ed372 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -104,6 +104,32 @@ pub fn codegen_simd_intrinsic_call<'tcx>( } }; + simd_insert, (c base, o idx, v val) { + let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { + idx_const + } else { + fx.tcx.sess.span_warn( + fx.mir.span, + "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", + ); + crate::trap::trap_unimplemented(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); + return; + }; + + let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); + let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, base.layout()); + if idx >= lane_count.into() { + fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); + } + + // FIXME implement this + fx.tcx.sess.span_warn( + fx.mir.span, + "`simd_insert` is not yet implemented. Calling this function will panic.", + ); + crate::trap::trap_unimplemented(fx, "`simd_insert` is not yet implemented"); + }; + simd_extract, (c v, o idx) { let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const @@ -112,7 +138,7 @@ pub fn codegen_simd_intrinsic_call<'tcx>( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); - crate::trap::trap_panic(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); + crate::trap::trap_unimplemented(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); return; }; From a3b8619c1e1a7c2e0e8ce5cb37482a206782c737 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Jan 2020 18:27:00 +0100 Subject: [PATCH 1070/1566] Revert "Use simd instructions for int and float simd intrinsics" This reverts commit 5e984a32d9b8a381d0b7f192f4a915aac59f18db. It was causing issues with vectors bigger than 128bit --- src/intrinsics/mod.rs | 72 +++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index a8dfb404bf498..0aab46b3bf009 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -267,16 +267,20 @@ macro simd_int_binop { simd_int_binop!($fx, $op|$op($x, $y) -> $ret); }, ($fx:expr, $op_u:ident|$op_s:ident($x:ident, $y:ident) -> $ret:ident) => { - let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); - let x_val = $x.load_scalar($fx); - let y_val = $y.load_scalar($fx); - - let res = match lane_layout.ty.kind { - ty::Uint(_) => $fx.bcx.ins().$op_u(x_val, y_val), - ty::Int(_) => $fx.bcx.ins().$op_s(x_val, y_val), - _ => unreachable!("{:?}", lane_layout.ty), - }; - $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); + simd_pair_for_each_lane( + $fx, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.kind { + ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); }, } @@ -285,30 +289,38 @@ macro simd_int_flt_binop { simd_int_flt_binop!($fx, $op|$op|$op_f($x, $y) -> $ret); }, ($fx:expr, $op_u:ident|$op_s:ident|$op_f:ident($x:ident, $y:ident) -> $ret:ident) => { - let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); - let x_val = $x.load_scalar($fx); - let y_val = $y.load_scalar($fx); - - let res = match lane_layout.ty.kind { - ty::Uint(_) => $fx.bcx.ins().$op_u(x_val, y_val), - ty::Int(_) => $fx.bcx.ins().$op_s(x_val, y_val), - ty::Float(_) => $fx.bcx.ins().$op_f(x_val, y_val), - _ => unreachable!("{:?}", lane_layout.ty), - }; - $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); + simd_pair_for_each_lane( + $fx, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.kind { + ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), + ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); }, } macro simd_flt_binop($fx:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { - let (lane_layout, lane_count) = lane_type_and_count($fx.tcx, $x.layout()); - let x_val = $x.load_scalar($fx); - let y_val = $y.load_scalar($fx); - - let res = match lane_layout.ty.kind { - ty::Float(_) => $fx.bcx.ins().$op(x_val, y_val), - _ => unreachable!("{:?}", lane_layout.ty), - }; - $ret.write_cvalue($fx, CValue::by_val(res, $ret.layout())); + simd_pair_for_each_lane( + $fx, + $x, + $y, + $ret, + |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.kind { + ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + CValue::by_val(res_lane, ret_lane_layout) + }, + ); } pub fn codegen_intrinsic_call<'tcx>( From 6652f466efc93a8706c07cda0502fd487ce8219d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 6 Jan 2020 20:11:03 +0100 Subject: [PATCH 1071/1566] Rustup to rustc 1.42.0-nightly (bc1571cc3 2020-01-05) --- src/common.rs | 2 +- src/constant.rs | 3 ++- src/debuginfo/line_info.rs | 2 +- src/driver.rs | 2 +- src/lib.rs | 5 +++-- src/target_features_whitelist.rs | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/common.rs b/src/common.rs index 3543df9cb865e..ab6ab7a0aa398 100644 --- a/src/common.rs +++ b/src/common.rs @@ -358,7 +358,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo()); let const_loc = self.tcx.const_caller_location(( - syntax::symbol::Symbol::intern(&caller.file.name.to_string()), + rustc_span::symbol::Symbol::intern(&caller.file.name.to_string()), caller.line as u32, caller.col_display as u32 + 1, )); diff --git a/src/constant.rs b/src/constant.rs index 1dfe4122a36a2..7f908851e4135 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use syntax::source_map::DUMMY_SP; +use rustc_span::DUMMY_SP; use rustc::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, @@ -391,6 +391,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn find_mir_or_eval_fn( _: &mut InterpCx<'mir, 'tcx, Self>, + _: Span, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: Option<(PlaceTy<'tcx>, BasicBlock)>, diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index e61bafaa6f10c..ef09bd406ce51 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -3,7 +3,7 @@ use std::path::{Component, Path}; use crate::prelude::*; -use syntax::source_map::FileName; +use rustc_span::FileName; use cranelift_codegen::binemit::CodeOffset; diff --git a/src/driver.rs b/src/driver.rs index 0a5916a552f5d..4d38e2e7d78b5 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -207,7 +207,7 @@ fn run_aot( let metadata_module = if need_metadata_module { let _timer = tcx.prof.generic_activity("codegen crate metadata"); - let (metadata_cgu_name, tmp_file) = rustc::util::common::time(tcx.sess, "write compressed metadata", || { + let (metadata_cgu_name, tmp_file) = tcx.sess.time("write compressed metadata", || { use rustc::mir::mono::CodegenUnitNameBuilder; let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); diff --git a/src/lib.rs b/src/lib.rs index c318b868ff504..24750e6938cc4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,7 @@ extern crate rustc_incremental; extern crate rustc_index; extern crate rustc_mir; extern crate rustc_session; +extern crate rustc_span; extern crate rustc_target; extern crate syntax; @@ -64,7 +65,7 @@ mod prelude { pub use std::convert::{TryFrom, TryInto}; pub use syntax::ast::{FloatTy, IntTy, UintTy}; - pub use syntax::source_map::{Pos, Span}; + pub use rustc_span::{Pos, Span}; pub use rustc::bug; pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -219,7 +220,7 @@ impl CodegenBackend for CraneliftCodegenBackend { let _timer = sess.prof.generic_activity("link_crate"); - rustc::util::common::time(sess, "linking", || { + sess.time("linking", || { let target_cpu = crate::target_triple(sess).to_string(); link_binary::>( sess, diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index 3626905db997e..20e31e1918994 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -1,4 +1,4 @@ -use syntax::symbol::{sym, Symbol}; +use rustc_span::symbol::{sym, Symbol}; use rustc::session::Session; From 33ad67c124336e6393815973fc8c0a9dfe333d11 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jan 2020 17:43:10 +0100 Subject: [PATCH 1072/1566] Rustup to rustc 1.42.0-nightly (caa231d99 2020-01-08) --- src/abi/mod.rs | 8 ++++---- src/base.rs | 2 +- src/common.rs | 2 +- src/constant.rs | 2 +- src/debuginfo/mod.rs | 2 +- src/lib.rs | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index b8bf2cf831a11..032d15162cf16 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -14,7 +14,7 @@ pub use self::returning::{can_return_to_ssa_var, codegen_return}; // Copied from https://github.com/rust-lang/rust/blob/c2f4c57296f0d929618baed0b0d6eb594abf01eb/src/librustc/ty/layout.rs#L2349 pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { - let ty = instance.ty(tcx); + let ty = instance.monomorphic_ty(tcx); match ty.kind { ty::FnDef(..) | // Shims currently have type FnPtr. Not sure this should remain. @@ -66,7 +66,7 @@ pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> t tcx.mk_fn_sig(std::iter::once(env_ty), ret_ty, false, - rustc::hir::Unsafety::Normal, + rustc_hir::Unsafety::Normal, rustc_target::spec::abi::Abi::Rust ) }) @@ -611,7 +611,7 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything } else { - let drop_fn_ty = drop_fn.ty(fx.tcx); + let drop_fn_ty = drop_fn.monomorphic_ty(fx.tcx); match ty.kind { ty::Dynamic(..) => { let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(fx); @@ -636,7 +636,7 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac &ty::RegionKind::ReErased, TypeAndMut { ty, - mutbl: crate::rustc::hir::Mutability::Mut, + mutbl: crate::rustc_hir::Mutability::Mut, }, ), ); diff --git a/src/base.rs b/src/base.rs index 0d71438cee92a..7df6bb1ed5e04 100644 --- a/src/base.rs +++ b/src/base.rs @@ -533,7 +533,7 @@ fn trans_stmt<'tcx>( outputs: _, inputs: _, } = &**asm; - let rustc::hir::InlineAsmInner { + let rustc_hir::InlineAsmInner { asm: asm_code, // Name outputs, // Vec inputs, // Vec diff --git a/src/common.rs b/src/common.rs index ab6ab7a0aa398..cca6e9911aa35 100644 --- a/src/common.rs +++ b/src/common.rs @@ -73,7 +73,7 @@ pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { - let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc::hir::Mutability::Not }); + let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not }); match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi { Abi::Scalar(_) => false, Abi::ScalarPair(_, _) => true, diff --git a/src/constant.rs b/src/constant.rs index 7f908851e4135..fe3d8e63d42d0 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -199,7 +199,7 @@ fn data_id_for_static( ) -> DataId { let instance = Instance::mono(tcx, def_id); let symbol_name = tcx.symbol_name(instance).name.as_str(); - let ty = instance.ty(tcx); + let ty = instance.monomorphic_ty(tcx); let is_mutable = if tcx.is_mutable_static(def_id) { true } else { diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 506cbc91c02af..4fa3570d2fd7a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -138,7 +138,7 @@ impl<'tcx> DebugContext<'tcx> { let type_entry = self.dwarf.unit.get_mut(type_id); - //type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc::hir::Mutability::Mut)); + //type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc_hir::Mutability::Mut)); type_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(pointee)); type_id diff --git a/src/lib.rs b/src/lib.rs index 24750e6938cc4..0c84f1d67045b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ extern crate rustc_codegen_utils; extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_fs_util; +extern crate rustc_hir; extern crate rustc_incremental; extern crate rustc_index; extern crate rustc_mir; @@ -68,7 +69,7 @@ mod prelude { pub use rustc_span::{Pos, Span}; pub use rustc::bug; - pub use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; + pub use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; pub use rustc::mir::{self, interpret::AllocId, mono::MonoItem, *}; pub use rustc::session::{ config::{CrateType, Lto}, From 66b2ce79874fb3597396ab12a029e2066f3599a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jan 2020 17:43:21 +0100 Subject: [PATCH 1073/1566] Update Cranelift --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a8432a186f382..159f37bc881ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -74,7 +74,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,17 +99,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" [[package]] name = "cranelift-entity" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" [[package]] name = "cranelift-faerie" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -144,7 +144,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -154,7 +154,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -165,7 +165,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#722a345ff6ee00ade5de87eef0a605711a88e8ec" +source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", From 3d5b54d959e1a65eba77550a5bef77efdc5d23b3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jan 2020 17:45:40 +0100 Subject: [PATCH 1074/1566] Update dependencies --- Cargo.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 159f37bc881ab..439f7708856a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ name = "backtrace-sys" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -55,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.48" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -115,7 +115,7 @@ dependencies = [ "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -210,7 +210,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -232,9 +232,9 @@ name = "failure_derive" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -273,7 +273,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -299,7 +299,7 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -339,7 +339,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -353,7 +353,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -364,7 +364,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -373,7 +373,7 @@ version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -435,9 +435,9 @@ name = "scroll_derive" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -478,10 +478,10 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -491,9 +491,9 @@ name = "synstructure" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -515,9 +515,9 @@ name = "thiserror-impl" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -558,7 +558,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" +"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" @@ -581,7 +581,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" -"checksum goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88a79ef1f0dad46fd78075b6f80f92d97710eddf87b3e18a15a66761e8942672" +"checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" @@ -591,7 +591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3c61759aa254402e53c79a68dc519cda1ceee2ff2b6d70b3e58bf64ac2f03e3" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" +"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" @@ -605,7 +605,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" -"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" +"checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" "checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" From 72729e22116652f8e6d34736f4d8502558e0fbb1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jan 2020 17:59:59 +0100 Subject: [PATCH 1075/1566] Disable read feature of gimli --- Cargo.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index efe56bffdca72..0b2b8652fa001 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,15 +25,18 @@ faerie = "0.12.0" ar = "0.8.0" byteorder = "1.2.7" libc = "0.2.53" -gimli = "0.19.0" indexmap = "1.0.2" -libloading = "0.5.1" [dependencies.object] version = "0.16.0" default-features = false features = ["compression", "read", "std"] # We don't need WASM support +[dependencies.gimli] +version = "0.19.0" +default-features = false +features = ["write"] # We don't need read support + # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/cranelift/"] #cranelift-codegen = { path = "../cranelift/cranelift-codegen", default-features = false, features = ["std"] } @@ -48,6 +51,7 @@ features = ["compression", "read", "std"] # We don't need WASM support [target.'cfg(not(target_arch = "wasm32"))'.dependencies] cranelift-simplejit = { git = "https://github.com/bytecodealliance/cranelift/" } +libloading = "0.5.1" [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. From 5424d7d55f88d293accc3f1a81f072b2c0b3df0e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Jan 2020 12:14:28 +0100 Subject: [PATCH 1076/1566] Prepare for basic blocks --- src/base.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 7df6bb1ed5e04..9a3a7870b0dfa 100644 --- a/src/base.rs +++ b/src/base.rs @@ -182,11 +182,17 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } let cond = trans_operand(fx, cond).load_scalar(fx); let target = fx.get_ebb(*target); + let failure = fx.bcx.create_ebb(); if *expected { - fx.bcx.ins().brnz(cond, target, &[]); + fx.bcx.ins().brz(cond, failure, &[]); } else { - fx.bcx.ins().brz(cond, target, &[]); + fx.bcx.ins().brnz(cond, failure, &[]); }; + fx.bcx.ins().jump(target, &[]); + + // FIXME insert bb after all other bb's to reduce the amount of jumps in the common + // case and improve code locality. + fx.bcx.switch_to_block(failure); trap_panic( fx, format!( From 2bd7dcd2c01c17ed73005725b38fc8c4ad802dad Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Jan 2020 13:12:49 +0100 Subject: [PATCH 1077/1566] Update Cranelift --- Cargo.lock | 133 +++++++++++++++---------------------------------- Cargo.toml | 9 ++-- src/backend.rs | 5 +- 3 files changed, 45 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 439f7708856a5..e3225dba1e101 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,6 +5,11 @@ name = "adler32" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "anyhow" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ar" version = "0.8.0" @@ -23,26 +28,6 @@ name = "autocfg" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "backtrace" -version = "0.3.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bitflags" version = "1.2.1" @@ -66,7 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -74,7 +59,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -83,14 +68,14 @@ dependencies = [ "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-codegen-meta" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,41 +84,41 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" [[package]] name = "cranelift-entity" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" [[package]] name = "cranelift-faerie" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ + "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-frontend" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-module" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -144,28 +129,28 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#8033363cc6065e33dc58f63b28b34d89518b5553" +source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" dependencies = [ "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -173,7 +158,7 @@ dependencies = [ "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -206,36 +191,17 @@ dependencies = [ [[package]] name = "faerie" -version = "0.12.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "failure_derive" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -334,7 +300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "object" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -342,7 +308,7 @@ dependencies = [ "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -388,11 +354,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "rustc_codegen_cranelift" version = "0.1.0" @@ -405,13 +366,13 @@ dependencies = [ "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "faerie 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -486,20 +447,9 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "synstructure" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "target-lexicon" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -551,11 +501,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" +"checksum anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" -"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" -"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" @@ -574,9 +523,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01fed63609767c70e34203201032c249d60a24578a67ef0ce7cc13ff010e9cf2" -"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" -"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" +"checksum faerie 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74b9ed6159e4a6212c61d9c6a86bee01876b192a64accecf58d5b5ae3b667b52" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" @@ -589,13 +536,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -"checksum object 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3c61759aa254402e53c79a68dc519cda1ceee2ff2b6d70b3e58bf64ac2f03e3" +"checksum object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" -"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" @@ -606,8 +552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" -"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" -"checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" +"checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" "checksum thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" diff --git a/Cargo.toml b/Cargo.toml index 0b2b8652fa001..6f08b705394b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,8 @@ cranelift-frontend = { git = "https://github.com/bytecodealliance/cranelift/", d cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-faerie = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/", optional = true } -target-lexicon = "0.9.0" -faerie = "0.12.0" +target-lexicon = "0.10.0" +faerie = "0.14.0" #goblin = "0.0.17" ar = "0.8.0" @@ -28,7 +28,7 @@ libc = "0.2.53" indexmap = "1.0.2" [dependencies.object] -version = "0.16.0" +version = "0.17.0" default-features = false features = ["compression", "read", "std"] # We don't need WASM support @@ -75,6 +75,3 @@ debug = false opt-level = 0 debug = false -[profile.dev.package.synstructure] -opt-level = 0 -debug = false diff --git a/src/backend.rs b/src/backend.rs index 305248182b5c4..9ec132185f605 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -7,7 +7,7 @@ use cranelift_module::{FuncId, Module}; use faerie::*; #[cfg(feature = "backend_object")] -use object::{SectionKind, RelocationKind, RelocationEncoding}; +use object::{SectionKind, SymbolFlags, RelocationKind, RelocationEncoding}; #[cfg(feature = "backend_object")] use object::write::*; use cranelift_faerie::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection}; @@ -61,7 +61,8 @@ impl WriteMetadata for object::write::Object { kind: object::SymbolKind::Data, scope: object::SymbolScope::Dynamic, weak: false, - section: Some(section_id), + section: SymbolSection::Section(section_id), + flags: SymbolFlags::None, }); } } From d65ba25ba740396f4cb748ab6320737e5797699a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Jan 2020 13:30:21 +0100 Subject: [PATCH 1078/1566] Remove faerie support --- .travis.yml | 3 -- Cargo.lock | 53 --------------------------- Cargo.toml | 11 ++---- src/backend.rs | 98 -------------------------------------------------- test.sh | 4 +-- 5 files changed, 4 insertions(+), 165 deletions(-) diff --git a/.travis.yml b/.travis.yml index 765739785568e..e73e9933976f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,3 @@ env: - RUST_BACKTRACE=1 # Reduce amount of benchmark runs as they are slow. - COMPILE_RUNS=2 RUN_RUNS=2 - jobs: - - "CG_CLIF_COMPILE_FLAGS=" - - "CG_CLIF_COMPILE_FLAGS='--features backend_object'" diff --git a/Cargo.lock b/Cargo.lock index e3225dba1e101..0f844bb5e4eb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,11 +5,6 @@ name = "adler32" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "anyhow" -version = "1.0.26" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "ar" version = "0.8.0" @@ -91,19 +86,6 @@ name = "cranelift-entity" version = "0.52.0" source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" -[[package]] -name = "cranelift-faerie" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" -dependencies = [ - "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "faerie 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cranelift-frontend" version = "0.52.0" @@ -189,21 +171,6 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "faerie" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -361,12 +328,10 @@ dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "faerie 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -414,11 +379,6 @@ name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "serde" -version = "1.0.104" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "smallvec" version = "1.1.0" @@ -429,14 +389,6 @@ name = "stable_deref_trait" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "string-interner" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "syn" version = "1.0.13" @@ -501,7 +453,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" -"checksum anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" @@ -514,7 +465,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-faerie 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" @@ -523,7 +473,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum faerie 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74b9ed6159e4a6212c61d9c6a86bee01876b192a64accecf58d5b5ae3b667b52" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" @@ -547,10 +496,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" diff --git a/Cargo.toml b/Cargo.toml index 6f08b705394b2..dddf84c17b031 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,19 +7,13 @@ edition = "2018" [lib] crate-type = ["dylib"] -[features] -default = ["backend_object"] -backend_object = ["object/write", "cranelift-object"] - [dependencies] # These have to be in sync with each other cranelift-codegen = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } cranelift-frontend = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } -cranelift-faerie = { git = "https://github.com/bytecodealliance/cranelift/" } -cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/", optional = true } +cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/" } target-lexicon = "0.10.0" -faerie = "0.14.0" #goblin = "0.0.17" ar = "0.8.0" @@ -30,7 +24,7 @@ indexmap = "1.0.2" [dependencies.object] version = "0.17.0" default-features = false -features = ["compression", "read", "std"] # We don't need WASM support +features = ["compression", "read", "std", "write"] # We don't need WASM support [dependencies.gimli] version = "0.19.0" @@ -43,7 +37,6 @@ features = ["write"] # We don't need read support #cranelift-frontend = { path = "../cranelift/cranelift-frontend", default-features = false, features = ["std"] } #cranelift-module = { path = "../cranelift/cranelift-module" } #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } -#cranelift-faerie = { path = "../cranelift/cranelift-faerie" } #cranelift-object = { path = "../cranelift/cranelift-object" } #[patch.crates-io] diff --git a/src/backend.rs b/src/backend.rs index 9ec132185f605..ae6888316f40b 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -5,14 +5,9 @@ use rustc::session::Session; use cranelift_module::{FuncId, Module}; -use faerie::*; -#[cfg(feature = "backend_object")] use object::{SectionKind, SymbolFlags, RelocationKind, RelocationEncoding}; -#[cfg(feature = "backend_object")] use object::write::*; -use cranelift_faerie::{FaerieBackend, FaerieBuilder, FaerieProduct, FaerieTrapCollection}; -#[cfg(feature = "backend_object")] use cranelift_object::*; use gimli::SectionId; @@ -23,30 +18,6 @@ pub trait WriteMetadata { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool); } -impl WriteMetadata for faerie::Artifact { - fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool) { - self - .declare(".rustc", faerie::Decl::section(faerie::SectionKind::Data)) - .unwrap(); - self - .define_with_symbols(".rustc", data, { - let mut map = std::collections::BTreeMap::new(); - // FIXME implement faerie elf backend section custom symbols - // For MachO this is necessary to prevent the linker from throwing away the .rustc section, - // but for ELF it isn't. - if is_like_osx { - map.insert( - symbol_name, - 0, - ); - } - map - }) - .unwrap(); - } -} - -#[cfg(feature = "backend_object")] impl WriteMetadata for object::write::Object { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, _is_like_osx: bool) { let segment = self.segment_name(object::write::StandardSegment::Data).to_vec(); @@ -80,42 +51,6 @@ pub trait WriteDebugInfo { ); } -impl WriteDebugInfo for FaerieProduct { - type SectionId = SectionId; - - fn add_debug_section(&mut self, id: SectionId, data: Vec) -> SectionId { - self.artifact.declare_with(id.name(), Decl::section(faerie::SectionKind::Debug), data).unwrap(); - id - } - - fn add_debug_reloc( - &mut self, - _section_map: &HashMap, - symbol_map: &indexmap::IndexMap, - from: &Self::SectionId, - reloc: &DebugReloc, - ) { - self - .artifact - .link_with( - faerie::Link { - from: from.name(), - to: match reloc.name { - DebugRelocName::Section(id) => id.name(), - DebugRelocName::Symbol(index) => &symbol_map.get_index(index).unwrap().1, - }, - at: u64::from(reloc.offset), - }, - faerie::Reloc::Debug { - size: reloc.size, - addend: reloc.addend as i32, - }, - ) - .expect("faerie relocation error"); - } -} - -#[cfg(feature = "backend_object")] impl WriteDebugInfo for ObjectProduct { type SectionId = (object::write::SectionId, object::write::SymbolId); @@ -168,30 +103,12 @@ pub trait Emit { fn emit(self) -> Vec; } -impl Emit for FaerieProduct { - fn emit(self) -> Vec { - self.artifact.emit().unwrap() - } -} - -#[cfg(feature = "backend_object")] impl Emit for ObjectProduct { fn emit(self) -> Vec { self.object.write().unwrap() } } -#[cfg(not(feature = "backend_object"))] -pub fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Artifact)) -> Vec { - let mut metadata_artifact = faerie::Artifact::new( - crate::build_isa(sess, true).triple().clone(), - name.to_string(), - ); - f(&mut metadata_artifact); - metadata_artifact.emit().unwrap() -} - -#[cfg(feature = "backend_object")] pub fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec { let triple = crate::build_isa(sess, true).triple().clone(); let mut metadata_object = @@ -203,21 +120,6 @@ pub fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> V pub type Backend = impl cranelift_module::Backend; -#[cfg(not(feature = "backend_object"))] -pub fn make_module(sess: &Session, name: String) -> Module { - let module: Module = Module::new( - FaerieBuilder::new( - crate::build_isa(sess, true), - name + ".o", - FaerieTrapCollection::Disabled, - cranelift_module::default_libcall_names(), - ) - .unwrap(), - ); - module -} - -#[cfg(feature = "backend_object")] pub fn make_module(sess: &Session, name: String) -> Module { let module: Module = Module::new( ObjectBuilder::new( diff --git a/test.sh b/test.sh index 1b28075f0f097..2990a9c03ebf4 100755 --- a/test.sh +++ b/test.sh @@ -4,10 +4,10 @@ set -e if [[ "$1" == "--release" ]]; then export CHANNEL='release' - CARGO_INCREMENTAL=1 cargo build --release $CG_CLIF_COMPILE_FLAGS + CARGO_INCREMENTAL=1 cargo build --release else export CHANNEL='debug' - cargo build $CG_CLIF_COMPILE_FLAGS + cargo build fi source config.sh From 70c9b3b35ba702a0f0d0e774fa0d2b2fec4b915f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Jan 2020 14:15:14 +0100 Subject: [PATCH 1079/1566] Better self profiling integration --- .gitignore | 2 ++ src/base.rs | 55 ++++++++++++++++++++++++++++++--------------------- src/driver.rs | 30 +++++++++++++++------------- 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index d00d779cb28ae..c301db32b72ad 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ target *.o perf.data perf.data.old +*.events +*.string* /build_sysroot/sysroot /build_sysroot/sysroot_src /build_sysroot/Cargo.lock diff --git a/src/base.rs b/src/base.rs index 9a3a7870b0dfa..4d1d5df8a89b0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -61,8 +61,10 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( fx.bcx.switch_to_block(entry_block); crate::trap::trap_unreachable(&mut fx, "function has uninhabited argument"); } else { - crate::abi::codegen_fn_prelude(&mut fx, start_ebb); - codegen_fn_content(&mut fx); + tcx.sess.time("codegen clif ir", || { + tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_ebb)); + codegen_fn_content(&mut fx); + }); } // Recover all necessary data from fx, before accessing func will prevent future access to it. @@ -78,10 +80,13 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( verify_func(tcx, &clif_comments, &context.func); // Perform rust specific optimizations - crate::optimize::optimize_function(cx.tcx, instance, context, &mut clif_comments); + tcx.sess.time("optimize clif ir", || { + crate::optimize::optimize_function(tcx, instance, context, &mut clif_comments); + }); // Define function - cx.module.define_function(func_id, context).unwrap(); + let module = &mut cx.module; + tcx.sess.time("define function", || module.define_function(func_id, context).unwrap()); // Write optimized function to file for debugging #[cfg(debug_assertions)] @@ -102,30 +107,34 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Define debuginfo for function let isa = cx.module.isa(); - debug_context - .as_mut() - .map(|x| x.define(context, isa, &source_info_set, local_map)); + tcx.sess.time("generate debug info", || { + debug_context + .as_mut() + .map(|x| x.define(context, isa, &source_info_set, local_map)); + }); // Clear context to make it usable for the next function context.clear(); } pub fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { - let flags = settings::Flags::new(settings::builder()); - match ::cranelift_codegen::verify_function(&func, &flags) { - Ok(_) => {} - Err(err) => { - tcx.sess.err(&format!("{:?}", err)); - let pretty_error = ::cranelift_codegen::print_errors::pretty_verifier_error( - &func, - None, - Some(Box::new(writer)), - err, - ); - tcx.sess - .fatal(&format!("cranelift verify error:\n{}", pretty_error)); + tcx.sess.time("verify clif ir", || { + let flags = settings::Flags::new(settings::builder()); + match ::cranelift_codegen::verify_function(&func, &flags) { + Ok(_) => {} + Err(err) => { + tcx.sess.err(&format!("{:?}", err)); + let pretty_error = ::cranelift_codegen::print_errors::pretty_verifier_error( + &func, + None, + Some(Box::new(writer)), + err, + ); + tcx.sess + .fatal(&format!("cranelift verify error:\n{}", pretty_error)); + } } - } + }); } fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { @@ -225,13 +234,13 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, from_hir_call: _, } => { - crate::abi::codegen_terminator_call( + fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, func, args, destination, bb_data.terminator().source_info.span, - ); + )); } TerminatorKind::Resume | TerminatorKind::Abort => { trap_unreachable(fx, "[corruption] Unwinding bb reached."); diff --git a/src/driver.rs b/src/driver.rs index 4d38e2e7d78b5..8a1edc12a8e00 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -294,18 +294,20 @@ fn codegen_mono_items<'tcx>( ) { let mut cx = CodegenCx::new(tcx, module, debug_context); - time("codegen mono items", move || { - for (&mono_item, &(linkage, visibility)) in &mono_items { - match mono_item { - MonoItem::Fn(instance) => { - let (name, sig) = - get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); - let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - cx.module.declare_function(&name, linkage, &sig).unwrap(); + time(tcx.sess, "codegen mono items", move || { + tcx.sess.time("predefine functions", || { + for (&mono_item, &(linkage, visibility)) in &mono_items { + match mono_item { + MonoItem::Fn(instance) => { + let (name, sig) = + get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + cx.module.declare_function(&name, linkage, &sig).unwrap(); + } + MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} } - MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} } - } + }); for (mono_item, (linkage, visibility)) in mono_items { crate::unimpl::try_unimpl(tcx, || { @@ -314,7 +316,7 @@ fn codegen_mono_items<'tcx>( }); } - cx.finalize(); + tcx.sess.time("finalize CodegenCx", || cx.finalize()); }); } @@ -350,7 +352,7 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( } }); - crate::base::trans_fn(cx, inst, linkage); + cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); @@ -361,10 +363,10 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( } } -fn time(name: &str, f: impl FnOnce() -> R) -> R { +fn time(sess: &Session, name: &str, f: impl FnOnce() -> R) -> R { println!("[{}] start", name); let before = std::time::Instant::now(); - let res = f(); + let res = sess.time(name, f); let after = std::time::Instant::now(); println!("[{}] end time: {:?}", name, after - before); res From 9dad9cf88d2db6385e8af031d4c964dad4389f6b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Jan 2020 14:21:45 +0100 Subject: [PATCH 1080/1566] Improve build time for build scripts in release mode --- Cargo.toml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index dddf84c17b031..fff1331666cb5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,11 +60,22 @@ opt-level = 0 opt-level = 0 debug = false +[profile.release.build-override] +opt-level = 0 +debug = false + [profile.dev.package.cranelift-codegen-meta] opt-level = 0 debug = false +[profile.release.package.cranelift-codegen-meta] +opt-level = 0 +debug = false + [profile.dev.package.syn] opt-level = 0 debug = false +[profile.release.package.syn] +opt-level = 0 +debug = false From 0080f55df2fb00a8934f064a3d9f4db3b0cc48db Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Jan 2020 14:27:26 +0100 Subject: [PATCH 1081/1566] Fix build --- src/driver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver.rs b/src/driver.rs index 8a1edc12a8e00..26188808d5ab7 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -363,7 +363,7 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( } } -fn time(sess: &Session, name: &str, f: impl FnOnce() -> R) -> R { +fn time(sess: &Session, name: &'static str, f: impl FnOnce() -> R) -> R { println!("[{}] start", name); let before = std::time::Instant::now(); let res = sess.time(name, f); From 2a082209a68703915ffe10c913d30f274bf76fa7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Jan 2020 14:15:24 +0100 Subject: [PATCH 1082/1566] Fix PlaceElem::Subslice length computation --- example/subslice-patterns-const-eval.rs | 99 +++++++++++++++++++++++++ src/base.rs | 2 +- test.sh | 4 + 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 example/subslice-patterns-const-eval.rs diff --git a/example/subslice-patterns-const-eval.rs b/example/subslice-patterns-const-eval.rs new file mode 100644 index 0000000000000..ec3614bb34ad0 --- /dev/null +++ b/example/subslice-patterns-const-eval.rs @@ -0,0 +1,99 @@ +// Based on https://github.com/rust-lang/rust/blob/c5840f9d252c2f5cc16698dbf385a29c5de3ca07/src/test/ui/array-slice-vec/subslice-patterns-const-eval-match.rs + +// Test that array subslice patterns are correctly handled in const evaluation. + +// run-pass + +#![feature(slice_patterns)] + +#[derive(PartialEq, Debug, Clone)] +struct N(u8); + +#[derive(PartialEq, Debug, Clone)] +struct Z; + +macro_rules! n { + ($($e:expr),* $(,)?) => { + [$(N($e)),*] + } +} + +// This macro has an unused variable so that it can be repeated base on the +// number of times a repeated variable (`$e` in `z`) occurs. +macro_rules! zed { + ($e:expr) => { Z } +} + +macro_rules! z { + ($($e:expr),* $(,)?) => { + [$(zed!($e)),*] + } +} + +// Compare constant evaluation and runtime evaluation of a given expression. +macro_rules! compare_evaluation { + ($e:expr, $t:ty $(,)?) => {{ + const CONST_EVAL: $t = $e; + const fn const_eval() -> $t { $e } + static CONST_EVAL2: $t = const_eval(); + let runtime_eval = $e; + assert_eq!(CONST_EVAL, runtime_eval); + assert_eq!(CONST_EVAL2, runtime_eval); + }} +} + +// Repeat `$test`, substituting the given macro variables with the given +// identifiers. +// +// For example: +// +// repeat! { +// ($name); X; Y: +// struct $name; +// } +// +// Expands to: +// +// struct X; struct Y; +// +// This is used to repeat the tests using both the `N` and `Z` +// types. +macro_rules! repeat { + (($($dollar:tt $placeholder:ident)*); $($($values:ident),+);*: $($test:tt)*) => { + macro_rules! single { + ($($dollar $placeholder:ident),*) => { $($test)* } + } + $(single!($($values),+);)* + } +} + +fn main() { + repeat! { + ($arr $Ty); n, N; z, Z: + compare_evaluation!({ let [_, x @ .., _] = $arr!(1, 2, 3, 4); x }, [$Ty; 2]); + compare_evaluation!({ let [_, ref x @ .., _] = $arr!(1, 2, 3, 4); x }, &'static [$Ty; 2]); + compare_evaluation!({ let [_, x @ .., _] = &$arr!(1, 2, 3, 4); x }, &'static [$Ty; 2]); + + compare_evaluation!({ let [_, _, x @ .., _, _] = $arr!(1, 2, 3, 4); x }, [$Ty; 0]); + compare_evaluation!( + { let [_, _, ref x @ .., _, _] = $arr!(1, 2, 3, 4); x }, + &'static [$Ty; 0], + ); + compare_evaluation!( + { let [_, _, x @ .., _, _] = &$arr!(1, 2, 3, 4); x }, + &'static [$Ty; 0], + ); + + compare_evaluation!({ let [_, .., x] = $arr!(1, 2, 3, 4); x }, $Ty); + compare_evaluation!({ let [_, .., ref x] = $arr!(1, 2, 3, 4); x }, &'static $Ty); + compare_evaluation!({ let [_, _y @ .., x] = &$arr!(1, 2, 3, 4); x }, &'static $Ty); + } + + compare_evaluation!({ let [_, .., N(x)] = n!(1, 2, 3, 4); x }, u8); + compare_evaluation!({ let [_, .., N(ref x)] = n!(1, 2, 3, 4); x }, &'static u8); + compare_evaluation!({ let [_, .., N(x)] = &n!(1, 2, 3, 4); x }, &'static u8); + + compare_evaluation!({ let [N(x), .., _] = n!(1, 2, 3, 4); x }, u8); + compare_evaluation!({ let [N(ref x), .., _] = n!(1, 2, 3, 4); x }, &'static u8); + compare_evaluation!({ let [N(x), .., _] = &n!(1, 2, 3, 4); x }, &'static u8); +} diff --git a/src/base.rs b/src/base.rs index 4d1d5df8a89b0..663e312a4249b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -688,7 +688,7 @@ pub fn trans_place<'tcx>( .eval_usize(fx.tcx, ParamEnv::reveal_all()); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), - fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)), + fx.layout_of(fx.tcx.mk_array(elem_ty, to as u64 - from as u64)), ); } ty::Slice(elem_ty) => { diff --git a/test.sh b/test.sh index 2990a9c03ebf4..d73badad95765 100755 --- a/test.sh +++ b/test.sh @@ -60,6 +60,10 @@ echo "[AOT] std_example" $RUSTC example/std_example.rs --crate-type bin ./target/out/std_example +echo "[AOT] subslice-patterns-const-eval" +$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort +./target/out/subslice-patterns-const-eval + echo "[BUILD] mod_bench" $RUSTC example/mod_bench.rs --crate-type bin From fed3b265635997dc84e8a01311c79726ad1e2ebf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Jan 2020 14:20:55 +0100 Subject: [PATCH 1083/1566] Don't panic on reported const eval errors --- src/constant.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index fe3d8e63d42d0..686147aa594bb 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -85,7 +85,10 @@ pub fn force_eval_const<'tcx>( match const_.val { ConstKind::Unevaluated(def_id, ref substs) => { let substs = fx.monomorphize(substs); - fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def_id, substs, None).unwrap() + fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def_id, substs, None).unwrap_or_else(|_| { + fx.tcx.sess.abort_if_errors(); + unreachable!(); + }) } _ => fx.monomorphize(&const_), } From 38797f8badc27da40bc25cc506f24c88f06b28e4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Jan 2020 16:49:42 +0100 Subject: [PATCH 1084/1566] Implement `#[track_caller]` Fixes #848 --- example/track-caller-attribute.rs | 42 +++++++++++++++++++++++ src/abi/comments.rs | 11 ++++-- src/abi/mod.rs | 56 +++++++++++++++++++++++++------ src/abi/pass_mode.rs | 2 +- src/abi/returning.rs | 2 +- src/base.rs | 7 ++-- src/common.rs | 8 +++++ test.sh | 4 +++ 8 files changed, 114 insertions(+), 18 deletions(-) create mode 100644 example/track-caller-attribute.rs diff --git a/example/track-caller-attribute.rs b/example/track-caller-attribute.rs new file mode 100644 index 0000000000000..40bf369a6fee3 --- /dev/null +++ b/example/track-caller-attribute.rs @@ -0,0 +1,42 @@ +// Based on https://github.com/anp/rust/blob/175631311716d7dfeceec40d2587cde7142ffa8c/src/test/ui/rfc-2091-track-caller/track-caller-attribute.rs + +// run-pass + +#![feature(track_caller)] + +use std::panic::Location; + +#[track_caller] +fn tracked() -> &'static Location<'static> { + Location::caller() +} + +fn nested_intrinsic() -> &'static Location<'static> { + Location::caller() +} + +fn nested_tracked() -> &'static Location<'static> { + tracked() +} + +fn main() { + let location = Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), 23); + assert_eq!(location.column(), 20); + + let tracked = tracked(); + assert_eq!(tracked.file(), file!()); + assert_eq!(tracked.line(), 28); + assert_eq!(tracked.column(), 19); + + let nested = nested_intrinsic(); + assert_eq!(nested.file(), file!()); + assert_eq!(nested.line(), 15); + assert_eq!(nested.column(), 5); + + let contained = nested_tracked(); + assert_eq!(contained.file(), file!()); + assert_eq!(contained.line(), 19); + assert_eq!(contained.column(), 5); +} diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 41c74ef4a3340..2201c6482563b 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -14,27 +14,34 @@ pub fn add_args_header_comment(fx: &mut FunctionCx) { pub fn add_arg_comment<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, kind: &str, - local: mir::Local, + local: Option, local_field: Option, params: EmptySinglePair, pass_mode: PassMode, ty: Ty<'tcx>, ) { + let local = if let Some(local) = local { + Cow::Owned(format!("{:?}", local)) + } else { + Cow::Borrowed("???") + }; let local_field = if let Some(local_field) = local_field { Cow::Owned(format!(".{}", local_field)) } else { Cow::Borrowed("") }; + let params = match params { Empty => Cow::Borrowed("-"), Single(param) => Cow::Owned(format!("= {:?}", param)), Pair(param_a, param_b) => Cow::Owned(format!("= {:?}, {:?}", param_a, param_b)), }; + let pass_mode = format!("{:?}", pass_mode); fx.add_global_comment(format!( "{kind:5}{local:>3}{local_field:<5} {params:10} {pass_mode:36} {ty:?}", kind = kind, - local = format!("{:?}", local), + local = local, local_field = local_field, params = params, pass_mode = pass_mode, diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 032d15162cf16..e9c9a751c26d2 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -80,6 +80,7 @@ fn clif_sig_from_fn_sig<'tcx>( triple: &target_lexicon::Triple, sig: FnSig<'tcx>, is_vtable_fn: bool, + requires_caller_location: bool, ) -> Signature { let abi = match sig.abi { Abi::System => { @@ -125,7 +126,7 @@ fn clif_sig_from_fn_sig<'tcx>( }) .flatten(); - let (params, returns) = match get_pass_mode( + let (mut params, returns): (Vec<_>, Vec<_>) = match get_pass_mode( tcx, tcx.layout_of(ParamEnv::reveal_all().and(output)).unwrap(), ) { @@ -150,6 +151,10 @@ fn clif_sig_from_fn_sig<'tcx>( } }; + if requires_caller_location { + params.push(AbiParam::new(pointer_ty(tcx))); + } + Signature { params, returns, @@ -169,7 +174,7 @@ pub fn get_function_name_and_sig<'tcx>( if fn_sig.c_variadic && !support_vararg { unimpl!("Variadic function definitions are not yet supported"); } - let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, false); + let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, false, inst.def.requires_caller_location(tcx)); (tcx.symbol_name(inst).name.as_str().to_string(), sig) } @@ -316,18 +321,24 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: let mut params = Vec::new(); for (i, arg_ty) in tupled_arg_tys.types().enumerate() { - let param = cvalue_for_param(fx, start_ebb, local, Some(i), arg_ty); + let param = cvalue_for_param(fx, start_ebb, Some(local), Some(i), arg_ty); params.push(param); } (local, ArgKind::Spread(params), arg_ty) } else { - let param = cvalue_for_param(fx, start_ebb, local, None, arg_ty); + let param = cvalue_for_param(fx, start_ebb, Some(local), None, arg_ty); (local, ArgKind::Normal(param), arg_ty) } }) .collect::>(); + assert!(fx.caller_location.is_none()); + if fx.instance.def.requires_caller_location(fx.tcx) { + // Store caller location for `#[track_caller]`. + fx.caller_location = Some(cvalue_for_param(fx, start_ebb, None, None, fx.tcx.caller_location_ty()).unwrap()); + } + fx.bcx.switch_to_block(start_ebb); fx.bcx.ins().nop(); @@ -403,10 +414,10 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: pub fn codegen_terminator_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + span: Span, func: &Operand<'tcx>, args: &[Operand<'tcx>], destination: &Option<(Place<'tcx>, BasicBlock)>, - span: Span, ) { let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); let sig = fx @@ -472,6 +483,7 @@ pub fn codegen_terminator_call<'tcx>( codegen_call_inner( fx, + span, Some(func), fn_ty, args, @@ -488,6 +500,7 @@ pub fn codegen_terminator_call<'tcx>( fn codegen_call_inner<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + span: Span, func: Option<&Operand<'tcx>>, fn_ty: Ty<'tcx>, args: Vec>, @@ -558,7 +571,7 @@ fn codegen_call_inner<'tcx>( let (call_inst, call_args) = self::returning::codegen_with_call_return_arg(fx, fn_sig, ret_place, |fx, return_ptr| { - let call_args: Vec = return_ptr + let mut call_args: Vec = return_ptr .into_iter() .chain(first_arg.into_iter()) .chain( @@ -569,9 +582,20 @@ fn codegen_call_inner<'tcx>( ) .collect::>(); + if instance.map(|inst| inst.def.requires_caller_location(fx.tcx)).unwrap_or(false) { + // Pass the caller location for `#[track_caller]`. + let caller_location = fx.get_caller_location(span); + call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); + } + let call_inst = if let Some(func_ref) = func_ref { - let sig = - clif_sig_from_fn_sig(fx.tcx, fx.triple(), fn_sig, is_virtual_call); + let sig = clif_sig_from_fn_sig( + fx.tcx, + fx.triple(), + fn_sig, + is_virtual_call, + false, // calls through function pointers never pass the caller location + ); let sig = fx.bcx.import_signature(sig); fx.bcx.ins().call_indirect(sig, func_ref, &call_args) } else { @@ -604,7 +628,11 @@ fn codegen_call_inner<'tcx>( } } -pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_place: CPlace<'tcx>) { +pub fn codegen_drop<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + span: Span, + drop_place: CPlace<'tcx>, +) { let ty = drop_place.layout().ty; let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty); @@ -625,7 +653,13 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); - let sig = clif_sig_from_fn_sig(fx.tcx, fx.triple(), fn_sig, true); + let sig = clif_sig_from_fn_sig( + fx.tcx, + fx.triple(), + fn_sig, + true, + false, // `drop_in_place` is never `#[track_caller]` + ); let sig = fx.bcx.import_signature(sig); fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); } @@ -642,7 +676,7 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac ); drop_place.write_place_ref(fx, arg_place); let arg_value = arg_place.to_cvalue(fx); - codegen_call_inner(fx, None, drop_fn_ty, vec![arg_value], None); + codegen_call_inner(fx, span, None, drop_fn_ty, vec![arg_value], None); } } } diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index d37f05cd98652..b2df277798764 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -126,7 +126,7 @@ pub fn adjust_arg_for_abi<'tcx>( pub fn cvalue_for_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_ebb: Ebb, - local: mir::Local, + local: Option, local_field: Option, arg_ty: Ty<'tcx>, ) -> Option> { diff --git a/src/abi/returning.rs b/src/abi/returning.rs index a503c6d795a07..f0a36e193b245 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -46,7 +46,7 @@ pub fn codegen_return_param( crate::abi::comments::add_arg_comment( fx, "ret", - RETURN_PLACE, + Some(RETURN_PLACE), None, ret_param, ret_pass_mode, diff --git a/src/base.rs b/src/base.rs index 663e312a4249b..6dc9f92775f10 100644 --- a/src/base.rs +++ b/src/base.rs @@ -48,6 +48,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( bcx, ebb_map, local_map: HashMap::new(), + caller_location: None, // set by `codegen_fn_prelude` clif_comments, constants_cx: &mut cx.constants_cx, @@ -236,10 +237,10 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } => { fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, + bb_data.terminator().source_info.span, func, args, destination, - bb_data.terminator().source_info.span, )); } TerminatorKind::Resume | TerminatorKind::Abort => { @@ -261,7 +262,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { unwind: _, } => { let drop_place = trans_place(fx, location); - crate::abi::codegen_drop(fx, drop_place); + crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); let target_ebb = fx.get_ebb(*target); fx.bcx.ins().jump(target_ebb, &[]); @@ -370,7 +371,7 @@ fn trans_stmt<'tcx>( match from_ty.kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( - Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs) + Instance::resolve_for_fn_ptr(fx.tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap(), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); diff --git a/src/common.rs b/src/common.rs index cca6e9911aa35..66e690d31222c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -267,6 +267,9 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub ebb_map: IndexVec, pub local_map: HashMap>, + /// When `#[track_caller]` is used, the implicit caller location is stored in this variable. + pub caller_location: Option>, + pub clif_comments: crate::pretty_clif::CommentWriter, pub constants_cx: &'clif mut crate::constant::ConstantCx, pub vtables: &'clif mut HashMap<(Ty<'tcx>, Option>), DataId>, @@ -355,6 +358,11 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub fn get_caller_location(&mut self, span: Span) -> CValue<'tcx> { + if let Some(loc) = self.caller_location { + // `#[track_caller]` is used; return caller location instead of current location. + return loc; + } + let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo()); let const_loc = self.tcx.const_caller_location(( diff --git a/test.sh b/test.sh index d73badad95765..72934e689584f 100755 --- a/test.sh +++ b/test.sh @@ -64,6 +64,10 @@ echo "[AOT] subslice-patterns-const-eval" $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort ./target/out/subslice-patterns-const-eval +echo "[AOT] track-caller-attribute" +$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort +./target/out/track-caller-attribute + echo "[BUILD] mod_bench" $RUSTC example/mod_bench.rs --crate-type bin From c74b3060372cb1057f5623a2d09d8b1599c133f8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Jan 2020 17:57:18 +0100 Subject: [PATCH 1085/1566] Move all cold code to the end of the function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #836 Benchmark #1: simple-raytracer/raytracer_cg_clif Time (mean ± σ): 9.250 s ± 0.056 s [User: 9.213 s, System: 0.015 s] Range (min … max): 9.151 s … 9.348 s 20 runs Benchmark #2: simple-raytracer/raytracer_cg_clif_cold_separated Time (mean ± σ): 9.179 s ± 0.101 s [User: 9.141 s, System: 0.016 s] Range (min … max): 9.070 s … 9.473 s 20 runs Summary 'simple-raytracer/raytracer_cg_clif_cold_separated' ran 1.01 ± 0.01 times faster than 'simple-raytracer/raytracer_cg_clif' --- src/abi/mod.rs | 1 + src/base.rs | 15 ++++++++++++--- src/common.rs | 3 +++ src/lib.rs | 1 + src/optimize/code_layout.rs | 34 ++++++++++++++++++++++++++++++++++ src/optimize/mod.rs | 5 +++++ src/optimize/stack2reg.rs | 1 - 7 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 src/optimize/code_layout.rs diff --git a/src/abi/mod.rs b/src/abi/mod.rs index e9c9a751c26d2..c983daabdc101 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -506,6 +506,7 @@ fn codegen_call_inner<'tcx>( args: Vec>, ret_place: Option>, ) { + // FIXME mark the current ebb as cold when calling a `#[cold]` function. let fn_sig = fx .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); diff --git a/src/base.rs b/src/base.rs index 6dc9f92775f10..db10443df1e33 100644 --- a/src/base.rs +++ b/src/base.rs @@ -32,6 +32,12 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Predefine ebb's let start_ebb = bcx.create_ebb(); let ebb_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_ebb()).collect(); + let mut cold_ebbs = EntitySet::new(); + for (bb, &ebb) in ebb_map.iter_enumerated() { + if mir.basic_blocks()[bb].is_cleanup { + cold_ebbs.insert(ebb); + } + } // Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); @@ -49,6 +55,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( ebb_map, local_map: HashMap::new(), caller_location: None, // set by `codegen_fn_prelude` + cold_ebbs, clif_comments, constants_cx: &mut cx.constants_cx, @@ -73,6 +80,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut clif_comments = fx.clif_comments; let source_info_set = fx.source_info_set; let local_map = fx.local_map; + let cold_ebbs = fx.cold_ebbs; #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &context.func, &clif_comments, None); @@ -82,7 +90,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Perform rust specific optimizations tcx.sess.time("optimize clif ir", || { - crate::optimize::optimize_function(tcx, instance, context, &mut clif_comments); + crate::optimize::optimize_function(tcx, instance, context, &cold_ebbs, &mut clif_comments); }); // Define function @@ -191,8 +199,11 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } } let cond = trans_operand(fx, cond).load_scalar(fx); + let target = fx.get_ebb(*target); let failure = fx.bcx.create_ebb(); + fx.cold_ebbs.insert(failure); + if *expected { fx.bcx.ins().brz(cond, failure, &[]); } else { @@ -200,8 +211,6 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { }; fx.bcx.ins().jump(target, &[]); - // FIXME insert bb after all other bb's to reduce the amount of jumps in the common - // case and improve code locality. fx.bcx.switch_to_block(failure); trap_panic( fx, diff --git a/src/common.rs b/src/common.rs index 66e690d31222c..201467c62a009 100644 --- a/src/common.rs +++ b/src/common.rs @@ -270,6 +270,9 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { /// When `#[track_caller]` is used, the implicit caller location is stored in this variable. pub caller_location: Option>, + /// See [crate::optimize::code_layout] for more information. + pub cold_ebbs: EntitySet, + pub clif_comments: crate::pretty_clif::CommentWriter, pub constants_cx: &'clif mut crate::constant::ConstantCx, pub vtables: &'clif mut HashMap<(Ty<'tcx>, Option>), DataId>, diff --git a/src/lib.rs b/src/lib.rs index 0c84f1d67045b..e4eb4147ce3e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,6 +95,7 @@ mod prelude { pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; pub use cranelift_codegen::Context; + pub use cranelift_codegen::entity::EntitySet; pub use cranelift_codegen::ir::{AbiParam, Ebb, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; pub use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; pub use cranelift_codegen::ir::function::Function; diff --git a/src/optimize/code_layout.rs b/src/optimize/code_layout.rs new file mode 100644 index 0000000000000..947b61d42e0b9 --- /dev/null +++ b/src/optimize/code_layout.rs @@ -0,0 +1,34 @@ +//! This optimization moves cold code to the end of the function. +//! +//! Some code is executed much less often than other code. For example panicking or the +//! landingpads for unwinding. By moving this cold code to the end of the function the average +//! amount of jumps is reduced and the code locality is improved. +//! +//! # Undefined behaviour +//! +//! This optimization doesn't assume anything that isn't already assumed by Cranelift itself. + +use crate::prelude::*; + +pub fn optimize_function(ctx: &mut Context, cold_ebbs: &EntitySet) { + // FIXME Move the ebb in place instead of remove and append once + // bytecodealliance/cranelift#1339 is implemented. + + let mut ebb_insts = HashMap::new(); + for ebb in cold_ebbs.keys().filter(|&ebb| cold_ebbs.contains(ebb)) { + let insts = ctx.func.layout.ebb_insts(ebb).collect::>(); + for &inst in &insts { + ctx.func.layout.remove_inst(inst); + } + ebb_insts.insert(ebb, insts); + ctx.func.layout.remove_ebb(ebb); + } + + // And then append them at the back again. + for ebb in cold_ebbs.keys().filter(|&ebb| cold_ebbs.contains(ebb)) { + ctx.func.layout.append_ebb(ebb); + for inst in ebb_insts.remove(&ebb).unwrap() { + ctx.func.layout.append_inst(inst, ebb); + } + } +} diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 59e4d2dd47d1e..ba9839e84be12 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -1,13 +1,18 @@ use crate::prelude::*; +mod code_layout; mod stack2reg; pub fn optimize_function<'tcx>( tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, ctx: &mut Context, + cold_ebbs: &EntitySet, clif_comments: &mut crate::pretty_clif::CommentWriter, ) { + // The code_layout optimization is very cheap. + self::code_layout::optimize_function(ctx, cold_ebbs); + if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No { return; // FIXME classify optimizations over opt levels } diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 4762b40db8dd9..b1afa9ab8bb15 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -13,7 +13,6 @@ use std::collections::{BTreeMap, HashSet}; use std::ops::Not; use cranelift_codegen::cursor::{Cursor, FuncCursor}; -use cranelift_codegen::entity::EntitySet; use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; From b44d6311caae19a3486d1edcbd6d83022e6fc2b2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Jan 2020 21:38:46 +0100 Subject: [PATCH 1086/1566] Rustup to rustc 1.42.0-nightly (3ebcfa145 2020-01-12) --- src/analyze.rs | 11 +-- src/base.rs | 17 +---- src/constant.rs | 176 ++++++++++++++++++++++++++----------------- src/debuginfo/mod.rs | 8 +- src/trap.rs | 12 --- 5 files changed, 113 insertions(+), 111 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index 3bebf0ed77724..c5541b1525732 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -23,7 +23,7 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec match &place_and_rval.1 { Rvalue::Ref(_, _, place) => { - analyze_non_ssa_place(&mut flag_map, place); + not_ssa(&mut flag_map, place.local) } _ => {} }, @@ -36,7 +36,7 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec) -> IndexVec, place: &Place) { - match place.base { - PlaceBase::Local(local) => not_ssa(flag_map, local), - _ => {} - } -} - fn not_ssa(flag_map: &mut IndexVec, local: Local) { flag_map[local] = SsaKind::NotSsa; } diff --git a/src/base.rs b/src/base.rs index db10443df1e33..0c0f43d076e3d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -292,7 +292,7 @@ fn trans_stmt<'tcx>( fx.set_debug_loc(stmt.source_info); - #[cfg(debug_assertions)] + #[cfg(false_debug_assertions)] match &stmt.kind { StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful _ => { @@ -646,20 +646,7 @@ pub fn trans_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: &Place<'tcx>, ) -> CPlace<'tcx> { - let mut cplace = match &place.base { - PlaceBase::Local(local) => fx.get_local_place(*local), - PlaceBase::Static(static_) => match static_.kind { - StaticKind::Static => { - // Statics can't be generic, so `static_.ty` doesn't need to be monomorphized. - crate::constant::codegen_static_ref(fx, static_.def_id, static_.ty) - } - StaticKind::Promoted(promoted, substs) => { - let instance = Instance::new(static_.def_id, fx.monomorphize(&substs)); - let ty = fx.monomorphize(&static_.ty); - crate::constant::trans_promoted(fx, instance, promoted, ty) - } - }, - }; + let mut cplace = fx.get_local_place(place.local); for elem in &*place.projection { match *elem { diff --git a/src/constant.rs b/src/constant.rs index 686147aa594bb..92ccaa1b1646c 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -40,7 +40,7 @@ pub fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { constants_cx.todo.insert(TodoItem::Static(def_id)); } -pub fn codegen_static_ref<'tcx>( +fn codegen_static_ref<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, def_id: DefId, ty: Ty<'tcx>, @@ -50,31 +50,37 @@ pub fn codegen_static_ref<'tcx>( cplace_for_dataid(fx, ty, data_id) } -pub fn trans_promoted<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - instance: Instance<'tcx>, - promoted: Promoted, - dest_ty: Ty<'tcx>, -) -> CPlace<'tcx> { - match fx.tcx.const_eval_promoted(instance, promoted) { - Ok(const_) => { - let cplace = trans_const_place(fx, const_); - debug_assert_eq!(cplace.layout(), fx.layout_of(dest_ty)); - cplace - } - Err(_) => crate::trap::trap_unreachable_ret_place( - fx, - fx.layout_of(dest_ty), - "[panic] Tried to get value of promoted value with errored during const eval.", - ), - } -} - pub fn trans_constant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { - let const_ = force_eval_const(fx, &constant.literal); + let const_ = match constant.literal.val { + ConstKind::Unevaluated(def_id, ref substs, promoted) if fx.tcx.is_static(def_id) => { + assert!(substs.is_empty()); + assert!(promoted.is_none()); + + return codegen_static_ref( + fx, + def_id, + fx.monomorphize(&constant.literal.ty), + ).to_cvalue(fx); + } + ConstKind::Unevaluated(def_id, ref substs, promoted) => { + let substs = fx.monomorphize(substs); + fx.tcx.const_eval_resolve( + ParamEnv::reveal_all(), + def_id, + substs, + promoted, + None, // FIXME use correct span + ).unwrap_or_else(|_| { + fx.tcx.sess.abort_if_errors(); + unreachable!(); + }) + } + _ => fx.monomorphize(&constant.literal), + }; + trans_const_value(fx, const_) } @@ -83,9 +89,15 @@ pub fn force_eval_const<'tcx>( const_: &'tcx Const, ) -> &'tcx Const<'tcx> { match const_.val { - ConstKind::Unevaluated(def_id, ref substs) => { + ConstKind::Unevaluated(def_id, ref substs, promoted) => { let substs = fx.monomorphize(substs); - fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def_id, substs, None).unwrap_or_else(|_| { + fx.tcx.const_eval_resolve( + ParamEnv::reveal_all(), + def_id, + substs, + promoted, + None, // FIXME pass correct span + ).unwrap_or_else(|_| { fx.tcx.sess.abort_if_errors(); unreachable!(); }) @@ -100,38 +112,78 @@ pub fn trans_const_value<'tcx>( ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); - match ty.kind { - ty::Bool | ty::Uint(_) => { - let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val(fx, ty, bits) + + if layout.is_zst() { + return CValue::by_ref( + crate::Pointer::const_addr(fx, i64::try_from(layout.align.pref.bytes()).unwrap()), + layout, + ); + } + + let const_val = match const_.val { + ConstKind::Value(const_val) => const_val, + _ => unreachable!("Const {:?} should have been evaluated", const_), + }; + + match const_val { + ConstValue::Scalar(x) => { + let scalar = match layout.abi { + layout::Abi::Scalar(ref x) => x, + _ => bug!("from_const: invalid ByVal layout: {:#?}", layout), + }; + + match ty.kind { + ty::Bool | ty::Uint(_) => { + let bits = const_.val.try_to_bits(layout.size).unwrap_or_else(|| { + panic!("{:?}\n{:?}", const_, layout); + }); + CValue::const_val(fx, ty, bits) + } + ty::Int(_) => { + let bits = const_.val.try_to_bits(layout.size).unwrap(); + CValue::const_val( + fx, + ty, + rustc::mir::interpret::sign_extend(bits, layout.size), + ) + } + ty::Float(fty) => { + let bits = const_.val.try_to_bits(layout.size).unwrap(); + let val = match fty { + FloatTy::F32 => fx + .bcx + .ins() + .f32const(Ieee32::with_bits(u32::try_from(bits).unwrap())), + FloatTy::F64 => fx + .bcx + .ins() + .f64const(Ieee64::with_bits(u64::try_from(bits).unwrap())), + }; + CValue::by_val(val, layout) + } + ty::FnDef(_def_id, _substs) => CValue::by_ref( + crate::pointer::Pointer::const_addr(fx, fx.pointer_type.bytes() as i64), + layout, + ), + _ => trans_const_place(fx, const_).to_cvalue(fx), + } } - ty::Int(_) => { - let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val( - fx, - ty, - rustc::mir::interpret::sign_extend(bits, layout.size), + ConstValue::ByRef { alloc, offset } => { + let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); + fx.constants_cx.todo.insert(TodoItem::Alloc(alloc_id)); + let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); + assert!(!layout.is_unsized(), "unsized ConstValue::ByRef not supported"); + CValue::by_ref( + crate::pointer::Pointer::new(global_ptr) + .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), + layout, ) } - ty::Float(fty) => { - let bits = const_.val.try_to_bits(layout.size).unwrap(); - let val = match fty { - FloatTy::F32 => fx - .bcx - .ins() - .f32const(Ieee32::with_bits(u32::try_from(bits).unwrap())), - FloatTy::F64 => fx - .bcx - .ins() - .f64const(Ieee64::with_bits(u64::try_from(bits).unwrap())), - }; - CValue::by_val(val, layout) + ConstValue::Slice { data: _, start: _, end: _ } => { + trans_const_place(fx, const_).to_cvalue(fx) } - ty::FnDef(_def_id, _substs) => CValue::by_ref( - crate::pointer::Pointer::const_addr(fx, fx.pointer_type.bytes() as i64), - layout, - ), - _ => trans_const_place(fx, const_).to_cvalue(fx), } } @@ -480,22 +532,8 @@ pub fn mir_operand_get_const_val<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, operand: &Operand<'tcx>, ) -> Option<&'tcx Const<'tcx>> { - let place = match operand { - Operand::Copy(place) | Operand::Move(place) => place, + match operand { + Operand::Copy(_) | Operand::Move(_) => return None, Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)), - }; - - assert!(place.projection.is_empty()); - let static_ = match &place.base { - PlaceBase::Static(static_) => static_, - PlaceBase::Local(_) => return None, - }; - - Some(match &static_.kind { - StaticKind::Static => unimplemented!(), - StaticKind::Promoted(promoted, substs) => { - let instance = Instance::new(static_.def_id, fx.monomorphize(substs)); - fx.tcx.const_eval_promoted(instance, *promoted).unwrap() - } - }) + } } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 4fa3570d2fd7a..d4be26885a042 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -283,7 +283,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { &local_map, &value_labels_ranges, Place { - base: PlaceBase::Local(local), + local, projection: ty::List::empty(), }, ); @@ -305,12 +305,8 @@ fn place_location<'a, 'tcx>( place: Place<'tcx>, ) -> AttributeValue { assert!(place.projection.is_empty()); // FIXME implement them - let cplace = match place.base { - PlaceBase::Local(local) => local_map[&local], - PlaceBase::Static(_) => bug!("Unenforced invariant that the place is based on a Local violated: {:?}", place), - }; - match cplace.inner() { + match local_map[&place.local].inner() { CPlaceInner::Var(local) => { let value_label = cranelift_codegen::ir::ValueLabel::from_u32(local.as_u32()); if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { diff --git a/src/trap.rs b/src/trap.rs index e297b27debb3d..316a26781dab4 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -93,15 +93,3 @@ pub fn trap_unreachable_ret_value<'tcx>( trap_unimplemented(fx, msg); CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout) } - -/// Like `trap_unreachable` but returns a fake place for the specified type. -/// -/// Trap code: user65535 -pub fn trap_unreachable_ret_place<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, - dest_layout: TyLayout<'tcx>, - msg: impl AsRef, -) -> CPlace<'tcx> { - trap_unimplemented(fx, msg); - CPlace::for_ptr(Pointer::const_addr(fx, 0), dest_layout) -} From b22b184969668e555a3c7bdd9e53868461eb3f41 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Jan 2020 13:55:08 +0100 Subject: [PATCH 1087/1566] Update Cranelift --- Cargo.lock | 102 ++++++++++++++++++++++++++--------------------------- src/lib.rs | 2 +- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f844bb5e4eb2..85128edd95c1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,22 +45,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ - "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-bforest 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-meta 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -69,29 +69,29 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ - "cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" [[package]] name = "cranelift-entity" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" [[package]] name = "cranelift-frontend" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -99,44 +99,44 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.52.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f4684ccdefd5841dc02a8d3db377de60231a0126" +version = "0.54.0" +source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" dependencies = [ - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -327,11 +327,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", @@ -460,16 +460,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift-bforest 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.52.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" diff --git a/src/lib.rs b/src/lib.rs index e4eb4147ce3e7..cc7c0bb5a63f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -248,7 +248,7 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box Date: Tue, 14 Jan 2020 14:16:06 +0100 Subject: [PATCH 1088/1566] Remove some depencencies --- Cargo.lock | 29 ----------------------------- Cargo.toml | 4 +--- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85128edd95c1e..94efff8eb4acf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,10 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "adler32" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "ar" version = "0.8.0" @@ -176,17 +171,6 @@ name = "fallible-iterator" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "flate2" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "gcc" version = "0.3.55" @@ -252,14 +236,6 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "miniz_oxide" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nodrop" version = "0.1.14" @@ -271,7 +247,6 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -334,7 +309,6 @@ dependencies = [ "cranelift-simplejit 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -452,7 +426,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" @@ -474,7 +447,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" @@ -483,7 +455,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" diff --git a/Cargo.toml b/Cargo.toml index fff1331666cb5..4161733b74d2a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,16 +15,14 @@ cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/" } target-lexicon = "0.10.0" -#goblin = "0.0.17" ar = "0.8.0" byteorder = "1.2.7" -libc = "0.2.53" indexmap = "1.0.2" [dependencies.object] version = "0.17.0" default-features = false -features = ["compression", "read", "std", "write"] # We don't need WASM support +features = ["read", "std", "write"] # We don't need WASM support [dependencies.gimli] version = "0.19.0" From 4fbb45c3f3673091075a0a7fc91bbf8abe777f36 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Jan 2020 14:19:43 +0100 Subject: [PATCH 1089/1566] Update gimli to 0.20.0 --- Cargo.lock | 36 +++--------------------------------- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 94efff8eb4acf..13b123636e3fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,14 +5,6 @@ name = "ar" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "autocfg" version = "0.1.7" @@ -166,11 +158,6 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "gcc" version = "0.3.55" @@ -178,14 +165,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -236,11 +220,6 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "object" version = "0.17.0" @@ -307,7 +286,7 @@ dependencies = [ "cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-object 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-simplejit 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -358,11 +337,6 @@ name = "smallvec" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "stable_deref_trait" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "syn" version = "1.0.13" @@ -427,7 +401,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" -"checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -446,16 +419,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" +"checksum gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" "checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" @@ -468,7 +439,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" -"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" diff --git a/Cargo.toml b/Cargo.toml index 4161733b74d2a..c4fca7f7c760b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ default-features = false features = ["read", "std", "write"] # We don't need WASM support [dependencies.gimli] -version = "0.19.0" +version = "0.20.0" default-features = false features = ["write"] # We don't need read support From 29fafb44b1de93c4f5000064ab06bd756b8499f9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Jan 2020 16:11:23 +0100 Subject: [PATCH 1090/1566] Optimize .debug_line generation This reduces the amount of time spent in .debug_line generation by about 50% Fixes #807 --- src/debuginfo/line_info.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index ef09bd406ce51..107ab6b763d10 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -122,19 +122,25 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase let line_strings = &mut self.debug_context.dwarf.line_strings; + let mut last_file = None; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); - let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); - /*println!( - "srcloc {:>04X} {}:{}:{}", - line_program.row().address_offset, - file.display(), - loc.line, - loc.col.to_u32() - );*/ + // line_program_add_file is very slow. + // Optimize for the common case of the current file not being changed. + let current_file_changed = if let Some(last_file) = &mut last_file { + // If the allocations are not equal, then the files may still be equal, but that + // is not a problem, as this is just an optimization. + !Lrc::ptr_eq(last_file, &loc.file) + } else { + true + }; + if current_file_changed { + let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); + line_program.row().file = file_id; + last_file = Some(loc.file.clone()); + } - line_program.row().file = file_id; line_program.row().line = loc.line as u64; line_program.row().column = loc.col.to_u32() as u64 + 1; line_program.generate_row(); From 09b44f5d25911b40e6c91fe160a89009ba6ddfe1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Jan 2020 17:11:06 +0100 Subject: [PATCH 1091/1566] Reduce visibility --- src/abi/pass_mode.rs | 22 +++++++++++----------- src/abi/returning.rs | 4 ++-- src/allocator.rs | 2 +- src/common.rs | 2 +- src/debuginfo/line_info.rs | 2 +- src/intrinsics/mod.rs | 2 +- src/intrinsics/simd.rs | 2 +- src/optimize/code_layout.rs | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index b2df277798764..58f6eaf25ce8d 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -1,5 +1,7 @@ use crate::prelude::*; +pub(super) use EmptySinglePair::*; + #[derive(Copy, Clone, Debug)] pub enum PassMode { NoPass, @@ -9,18 +11,18 @@ pub enum PassMode { } #[derive(Copy, Clone, Debug)] -pub enum EmptySinglePair { +pub(super) enum EmptySinglePair { Empty, Single(T), Pair(T, T), } impl EmptySinglePair { - pub fn into_iter(self) -> EmptySinglePairIter { + pub(super) fn into_iter(self) -> EmptySinglePairIter { EmptySinglePairIter(self) } - pub fn map(self, mut f: impl FnMut(T) -> U) -> EmptySinglePair { + pub(super) fn map(self, mut f: impl FnMut(T) -> U) -> EmptySinglePair { match self { Empty => Empty, Single(v) => Single(f(v)), @@ -29,7 +31,7 @@ impl EmptySinglePair { } } -pub struct EmptySinglePairIter(EmptySinglePair); +pub(super) struct EmptySinglePairIter(EmptySinglePair); impl Iterator for EmptySinglePairIter { type Item = T; @@ -47,14 +49,14 @@ impl Iterator for EmptySinglePairIter { } impl EmptySinglePair { - pub fn assert_single(self) -> T { + pub(super) fn assert_single(self) -> T { match self { Single(v) => v, _ => panic!("Called assert_single on {:?}", self), } } - pub fn assert_pair(self) -> (T, T) { + pub(super) fn assert_pair(self) -> (T, T) { match self { Pair(a, b) => (a, b), _ => panic!("Called assert_pair on {:?}", self), @@ -62,10 +64,8 @@ impl EmptySinglePair { } } -pub use EmptySinglePair::*; - impl PassMode { - pub fn get_param_ty(self, tcx: TyCtxt<'_>) -> EmptySinglePair { + pub(super) fn get_param_ty(self, tcx: TyCtxt<'_>) -> EmptySinglePair { match self { PassMode::NoPass => Empty, PassMode::ByVal(clif_type) => Single(clif_type), @@ -108,7 +108,7 @@ pub fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> PassMod } } -pub fn adjust_arg_for_abi<'tcx>( +pub(super) fn adjust_arg_for_abi<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, ) -> EmptySinglePair { @@ -123,7 +123,7 @@ pub fn adjust_arg_for_abi<'tcx>( } } -pub fn cvalue_for_param<'tcx>( +pub(super) fn cvalue_for_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_ebb: Ebb, local: Option, diff --git a/src/abi/returning.rs b/src/abi/returning.rs index f0a36e193b245..5228eb6031b30 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -13,7 +13,7 @@ pub fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyLayout<'tcx } } -pub fn codegen_return_param( +pub(super) fn codegen_return_param( fx: &mut FunctionCx, ssa_analyzed: &rustc_index::vec::IndexVec, start_ebb: Ebb, @@ -54,7 +54,7 @@ pub fn codegen_return_param( ); } -pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>( +pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( fx: &mut FunctionCx<'_, 'tcx, B>, fn_sig: FnSig<'tcx>, ret_place: Option>, diff --git a/src/allocator.rs b/src/allocator.rs index cfcb091afb5a2..df9e6aa196280 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -28,7 +28,7 @@ pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> } } -pub fn codegen_inner(module: &mut Module, kind: AllocatorKind) { +fn codegen_inner(module: &mut Module, kind: AllocatorKind) { let usize_ty = module.target_config().pointer_type(); for method in ALLOCATOR_METHODS { diff --git a/src/common.rs b/src/common.rs index 201467c62a009..dcf47f6657a50 100644 --- a/src/common.rs +++ b/src/common.rs @@ -34,7 +34,7 @@ pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { } } -pub fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { +fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { Some(match ty.kind { ty::Bool => types::I8, ty::Uint(size) => match size { diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 107ab6b763d10..3152e4812f758 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -101,7 +101,7 @@ impl<'tcx> DebugContext<'tcx> { } impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { - pub(crate) fn create_debug_lines( + pub(super) fn create_debug_lines( &mut self, context: &Context, isa: &dyn cranelift_codegen::isa::TargetIsa, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 0aab46b3bf009..70c9167c69e2b 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -127,7 +127,7 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ $ret.write_cvalue($fx, ret_val); } -pub fn lane_type_and_count<'tcx>( +fn lane_type_and_count<'tcx>( tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>, ) -> (TyLayout<'tcx>, u32) { diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index cd163aa7ed372..04e55d8018711 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use super::*; -pub fn codegen_simd_intrinsic_call<'tcx>( +pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, instance: Instance<'tcx>, args: &[mir::Operand<'tcx>], diff --git a/src/optimize/code_layout.rs b/src/optimize/code_layout.rs index 947b61d42e0b9..4d2301c6f6c56 100644 --- a/src/optimize/code_layout.rs +++ b/src/optimize/code_layout.rs @@ -10,7 +10,7 @@ use crate::prelude::*; -pub fn optimize_function(ctx: &mut Context, cold_ebbs: &EntitySet) { +pub(super) fn optimize_function(ctx: &mut Context, cold_ebbs: &EntitySet) { // FIXME Move the ebb in place instead of remove and append once // bytecodealliance/cranelift#1339 is implemented. From 0669a49b1068beaf839197f10e6bd4027b340639 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Jan 2020 11:53:24 +0100 Subject: [PATCH 1092/1566] Use release mode instead of debug mode in the readme cc #865 --- Readme.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index acd14b09254ba..bc1e20a736d62 100644 --- a/Readme.md +++ b/Readme.md @@ -8,7 +8,7 @@ $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift $ ./prepare.sh # download and patch sysroot src and install hyperfine for benchmarking -$ ./test.sh +$ ./test.sh --release ``` ## Usage @@ -18,13 +18,15 @@ $ ./test.sh ### Cargo ```bash -$ $cg_clif_dir/cargo.sh run +$ CHANNEL="release" $cg_clif_dir/cargo.sh run ``` +If you compiled cg_clif in debug mode you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. + ### Rustc ```bash -$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/debug/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs +$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs ``` From 217beab62aeb8a0dce19ae744a664c9041688f56 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Jan 2020 13:17:09 +0100 Subject: [PATCH 1093/1566] Reduce the amount of calls to layout_of --- src/abi/mod.rs | 6 +++--- src/abi/pass_mode.rs | 2 +- src/base.rs | 4 ++-- src/constant.rs | 15 +++++++-------- src/discriminant.rs | 6 +++--- src/intrinsics/mod.rs | 6 +++--- src/num.rs | 5 +++-- src/unsize.rs | 33 ++++++++++++++++----------------- src/value_and_place.rs | 17 ++++++++--------- src/vtable.rs | 17 ++++++++--------- 10 files changed, 54 insertions(+), 57 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index c983daabdc101..00e7ae48b798a 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -276,7 +276,7 @@ fn local_place<'tcx>( let place = if is_ssa { CPlace::new_var(fx, local, layout) } else { - CPlace::new_stack_slot(fx, layout.ty) + CPlace::new_stack_slot(fx, layout) }; #[cfg(debug_assertions)] @@ -667,13 +667,13 @@ pub fn codegen_drop<'tcx>( _ => { let arg_place = CPlace::new_stack_slot( fx, - fx.tcx.mk_ref( + fx.layout_of(fx.tcx.mk_ref( &ty::RegionKind::ReErased, TypeAndMut { ty, mutbl: crate::rustc_hir::Mutability::Mut, }, - ), + )), ); drop_place.write_place_ref(fx, arg_place); let arg_value = arg_place.to_cvalue(fx); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 58f6eaf25ce8d..231eb64de41b8 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -131,7 +131,7 @@ pub(super) fn cvalue_for_param<'tcx>( arg_ty: Ty<'tcx>, ) -> Option> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.tcx, fx.layout_of(arg_ty)); + let pass_mode = get_pass_mode(fx.tcx, layout); if let PassMode::NoPass = pass_mode { return None; diff --git a/src/base.rs b/src/base.rs index 0c0f43d076e3d..5eb0170a19dd5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -363,7 +363,7 @@ fn trans_stmt<'tcx>( } UnOp::Neg => match layout.ty.kind { ty::Int(_) => { - let zero = CValue::const_val(fx, layout.ty, 0); + let zero = CValue::const_val(fx, layout, 0); crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand) } ty::Float(_) => { @@ -528,7 +528,7 @@ fn trans_stmt<'tcx>( .ty .is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); - let val = CValue::const_val(fx, fx.tcx.types.usize, ty_size.into()); + let val = CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), ty_size.into()); lval.write_cvalue(fx, val); } Rvalue::Aggregate(kind, operands) => match **kind { diff --git a/src/constant.rs b/src/constant.rs index 92ccaa1b1646c..6d33f71072ae2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -43,11 +43,11 @@ pub fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { fn codegen_static_ref<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, def_id: DefId, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, ) -> CPlace<'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); - cplace_for_dataid(fx, ty, data_id) + cplace_for_dataid(fx, layout, data_id) } pub fn trans_constant<'tcx>( @@ -62,7 +62,7 @@ pub fn trans_constant<'tcx>( return codegen_static_ref( fx, def_id, - fx.monomorphize(&constant.literal.ty), + fx.layout_of(fx.monomorphize(&constant.literal.ty)), ).to_cvalue(fx); } ConstKind::Unevaluated(def_id, ref substs, promoted) => { @@ -137,13 +137,13 @@ pub fn trans_const_value<'tcx>( let bits = const_.val.try_to_bits(layout.size).unwrap_or_else(|| { panic!("{:?}\n{:?}", const_, layout); }); - CValue::const_val(fx, ty, bits) + CValue::const_val(fx, layout, bits) } ty::Int(_) => { let bits = const_.val.try_to_bits(layout.size).unwrap(); CValue::const_val( fx, - ty, + layout, rustc::mir::interpret::sign_extend(bits, layout.size), ) } @@ -228,7 +228,7 @@ fn trans_const_place<'tcx>( let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); fx.constants_cx.todo.insert(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); - cplace_for_dataid(fx, const_.ty, data_id) + cplace_for_dataid(fx, fx.layout_of(const_.ty), data_id) } fn data_id_for_alloc_id( @@ -304,12 +304,11 @@ fn data_id_for_static( fn cplace_for_dataid<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, data_id: DataId, ) -> CPlace<'tcx> { let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); - let layout = fx.layout_of(fx.monomorphize(&ty)); assert!(!layout.is_unsized(), "unsized statics aren't supported"); CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout) } diff --git a/src/discriminant.rs b/src/discriminant.rs index ccc474401b62f..6389bd6277cef 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -27,7 +27,7 @@ pub fn codegen_set_discriminant<'tcx>( .discriminant_for_variant(fx.tcx, variant_index) .unwrap() .val; - let discr = CValue::const_val(fx, ptr.layout().ty, to); + let discr = CValue::const_val(fx, ptr.layout(), to); ptr.write_cvalue(fx, discr); } layout::Variants::Multiple { @@ -45,7 +45,7 @@ pub fn codegen_set_discriminant<'tcx>( let niche = place.place_field(fx, mir::Field::new(discr_index)); let niche_value = variant_index.as_u32() - niche_variants.start().as_u32(); let niche_value = u128::from(niche_value).wrapping_add(niche_start); - let niche_llval = CValue::const_val(fx, niche.layout().ty, niche_value); + let niche_llval = CValue::const_val(fx, niche.layout(), niche_value); niche.write_cvalue(fx, niche_llval); } } @@ -73,7 +73,7 @@ pub fn codegen_get_discriminant<'tcx>( .ty .discriminant_for_variant(fx.tcx, *index) .map_or(u128::from(index.as_u32()), |discr| discr.val); - return CValue::const_val(fx, dest_layout.ty, discr_val); + return CValue::const_val(fx, dest_layout, discr_val); } layout::Variants::Multiple { discr, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 70c9167c69e2b..459c68baa6370 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -453,7 +453,7 @@ pub fn codegen_intrinsic_call<'tcx>( let layout = fx.layout_of(T); let size = if layout.is_unsized() { let (_ptr, info) = ptr.load_scalar_pair(fx); - let (size, _align) = crate::unsize::size_and_align_of_dst(fx, layout.ty, info); + let (size, _align) = crate::unsize::size_and_align_of_dst(fx, layout, info); size } else { fx @@ -467,7 +467,7 @@ pub fn codegen_intrinsic_call<'tcx>( let layout = fx.layout_of(T); let align = if layout.is_unsized() { let (_ptr, info) = ptr.load_scalar_pair(fx); - let (_size, align) = crate::unsize::size_and_align_of_dst(fx, layout.ty, info); + let (_size, align) = crate::unsize::size_and_align_of_dst(fx, layout, info); align } else { fx @@ -951,7 +951,7 @@ pub fn codegen_intrinsic_call<'tcx>( fx.bcx.ins().call_indirect(f_sig, f, &[data]); - let ret_val = CValue::const_val(fx, ret.layout().ty, 0); + let ret_val = CValue::const_val(fx, ret.layout(), 0); ret.write_cvalue(fx, ret_val); }; } diff --git a/src/num.rs b/src/num.rs index 5dee1d8c2abb4..e11143d6bd2c4 100644 --- a/src/num.rs +++ b/src/num.rs @@ -285,10 +285,11 @@ pub fn trans_checked_int_binop<'tcx>( }; let has_overflow = fx.bcx.ins().bint(types::I8, has_overflow); + + // FIXME directly write to result place instead let out_place = CPlace::new_stack_slot( fx, - fx.tcx - .mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter()), + fx.layout_of(fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter())), ); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); diff --git a/src/unsize.rs b/src/unsize.rs index 6d497b188669f..ab2b2f201a212 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -28,7 +28,9 @@ pub fn unsized_info<'tcx>( // change to the vtable. old_info.expect("unsized_info: missing old info for trait upcast") } - (_, &ty::Dynamic(ref data, ..)) => crate::vtable::get_vtable(fx, source, data.principal()), + (_, &ty::Dynamic(ref data, ..)) => { + crate::vtable::get_vtable(fx, fx.layout_of(source), data.principal()) + } _ => bug!( "unsized_info: invalid unsizing {:?} -> {:?}", source, @@ -38,13 +40,13 @@ pub fn unsized_info<'tcx>( } /// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer. -pub fn unsize_thin_ptr<'tcx>( +fn unsize_thin_ptr<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, src: Value, - src_ty: Ty<'tcx>, - dst_ty: Ty<'tcx>, + src_layout: TyLayout<'tcx>, + dst_layout: TyLayout<'tcx>, ) -> (Value, Value) { - match (&src_ty.kind, &dst_ty.kind) { + match (&src_layout.ty.kind, &dst_layout.ty.kind) { (&ty::Ref(_, a, _), &ty::Ref(_, b, _)) | (&ty::Ref(_, a, _), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { @@ -52,15 +54,13 @@ pub fn unsize_thin_ptr<'tcx>( (src, unsized_info(fx, a, b, None)) } (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => { - let (a, b) = (src_ty.boxed_ty(), dst_ty.boxed_ty()); + let (a, b) = (src_layout.ty.boxed_ty(), dst_layout.ty.boxed_ty()); assert!(!fx.layout_of(a).is_unsized()); (src, unsized_info(fx, a, b, None)) } (&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => { assert_eq!(def_a, def_b); - let src_layout = fx.layout_of(src_ty); - let dst_layout = fx.layout_of(dst_ty); let mut result = None; for i in 0..src_layout.fields.count() { let src_f = src_layout.field(fx, i); @@ -74,7 +74,7 @@ pub fn unsize_thin_ptr<'tcx>( let dst_f = dst_layout.field(fx, i); assert_ne!(src_f.ty, dst_f.ty); assert_eq!(result, None); - result = Some(unsize_thin_ptr(fx, src, src_f.ty, dst_f.ty)); + result = Some(unsize_thin_ptr(fx, src, src_f, dst_f)); } result.unwrap() } @@ -101,7 +101,7 @@ pub fn coerce_unsized_into<'tcx>( src.load_scalar_pair(fx) } else { let base = src.load_scalar(fx); - unsize_thin_ptr(fx, base, src_ty, dst_ty) + unsize_thin_ptr(fx, base, src.layout(), dst.layout()) }; dst.write_cvalue(fx, CValue::by_val_pair(base, info, dst.layout())); }; @@ -139,10 +139,9 @@ pub fn coerce_unsized_into<'tcx>( pub fn size_and_align_of_dst<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, info: Value, ) -> (Value, Value) { - let layout = fx.layout_of(ty); if !layout.is_unsized() { let size = fx .bcx @@ -154,7 +153,7 @@ pub fn size_and_align_of_dst<'tcx>( .iconst(fx.pointer_type, layout.align.abi.bytes() as i64); return (size, align); } - match ty.kind { + match layout.ty.kind { ty::Dynamic(..) => { // load size/align from vtable ( @@ -177,7 +176,7 @@ pub fn size_and_align_of_dst<'tcx>( // First get the size of all statically known fields. // Don't use size_of because it also rounds up to alignment, which we // want to avoid, as the unsized field's alignment could be smaller. - assert!(!ty.is_simd()); + assert!(!layout.ty.is_simd()); let i = layout.fields.count() - 1; let sized_size = layout.fields.offset(i).bytes(); @@ -186,8 +185,8 @@ pub fn size_and_align_of_dst<'tcx>( // Recurse to get the size of the dynamically sized field (must be // the last field). - let field_ty = layout.field(fx, i).ty; - let (unsized_size, mut unsized_align) = size_and_align_of_dst(fx, field_ty, info); + let field_layout = layout.field(fx, i); + let (unsized_size, mut unsized_align) = size_and_align_of_dst(fx, field_layout, info); // FIXME (#26403, #27023): We should be adding padding // to `sized_size` (to accommodate the `unsized_align` @@ -200,7 +199,7 @@ pub fn size_and_align_of_dst<'tcx>( let size = fx.bcx.ins().iadd_imm(unsized_size, sized_size as i64); // Packed types ignore the alignment of their fields. - if let ty::Adt(def, _) = ty.kind { + if let ty::Adt(def, _) = layout.ty.kind { if def.repr.packed() { unsized_align = sized_align; } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 39eb7d2470744..95913256f24ca 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -32,7 +32,7 @@ fn codegen_field<'tcx>( _ => { // We have to align the offset for DST's let unaligned_offset = field_offset.bytes(); - let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout.ty, extra); + let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout, extra); let one = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 1); let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); @@ -88,12 +88,13 @@ impl<'tcx> CValue<'tcx> { self.1 } + // FIXME remove pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { let layout = self.1; match self.0 { CValueInner::ByRef(ptr) => ptr, CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => { - let cplace = CPlace::new_stack_slot(fx, layout.ty); + let cplace = CPlace::new_stack_slot(fx, layout); cplace.write_cvalue(fx, self); cplace.to_ptr(fx) } @@ -196,13 +197,12 @@ impl<'tcx> CValue<'tcx> { /// If `ty` is signed, `const_val` must already be sign extended. pub fn const_val<'a>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, const_val: u128, ) -> CValue<'tcx> { - let clif_ty = fx.clif_type(ty).unwrap(); - let layout = fx.layout_of(ty); + let clif_ty = fx.clif_type(layout.ty).unwrap(); - let val = match ty.kind { + let val = match layout.ty.kind { ty::TyKind::Uint(UintTy::U128) | ty::TyKind::Int(IntTy::I128) => { let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64); let msb = fx @@ -226,7 +226,7 @@ impl<'tcx> CValue<'tcx> { ty::TyKind::Int(_) => fx.bcx.ins().iconst(clif_ty, const_val as i128 as i64), _ => panic!( "CValue::const_val for non bool/integer/pointer type {:?} is not allowed", - ty + layout.ty ), }; @@ -270,9 +270,8 @@ impl<'tcx> CPlace<'tcx> { pub fn new_stack_slot( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, ) -> CPlace<'tcx> { - let layout = fx.layout_of(ty); assert!(!layout.is_unsized()); if layout.size.bytes() == 0 { return CPlace { diff --git a/src/vtable.rs b/src/vtable.rs index 913bb712da3cb..7eaf8ffdada7c 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -60,14 +60,14 @@ pub fn get_ptr_and_method_ref<'tcx>( pub fn get_vtable<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, trait_ref: Option>, ) -> Value { - let data_id = if let Some(data_id) = fx.vtables.get(&(ty, trait_ref)) { + let data_id = if let Some(data_id) = fx.vtables.get(&(layout.ty, trait_ref)) { *data_id } else { - let data_id = build_vtable(fx, ty, trait_ref); - fx.vtables.insert((ty, trait_ref), data_id); + let data_id = build_vtable(fx, layout, trait_ref); + fx.vtables.insert((layout.ty, trait_ref), data_id); data_id }; @@ -77,20 +77,20 @@ pub fn get_vtable<'tcx>( fn build_vtable<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ty: Ty<'tcx>, + layout: TyLayout<'tcx>, trait_ref: Option>, ) -> DataId { let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, ty)); + import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, layout.ty)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; let methods_root; let methods = if let Some(trait_ref) = trait_ref { - methods_root = tcx.vtable_methods(trait_ref.with_self_ty(tcx, ty)); + methods_root = tcx.vtable_methods(trait_ref.with_self_ty(tcx, layout.ty)); methods_root.iter() } else { (&[]).iter() @@ -112,7 +112,6 @@ fn build_vtable<'tcx>( .collect::>() .into_boxed_slice(); - let layout = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); write_usize(fx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); write_usize(fx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); data_ctx.define(data); @@ -127,7 +126,7 @@ fn build_vtable<'tcx>( let data_id = fx .module .declare_data( - &format!("vtable.{:?}.for.{:?}", trait_ref, ty), + &format!("vtable.{:?}.for.{:?}", trait_ref, layout.ty), Linkage::Local, false, Some( From e798f98bb45f092ddb70fbfb476872809484de9e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Jan 2020 13:18:21 +0100 Subject: [PATCH 1094/1566] Fix debug build --- src/abi/comments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 2201c6482563b..c704da21b712b 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -11,7 +11,7 @@ pub fn add_args_header_comment(fx: &mut FunctionCx) { )); } -pub fn add_arg_comment<'tcx>( +pub(super) fn add_arg_comment<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, kind: &str, local: Option, From a288a5ea06bc601802e2f1537f883cb9019a2078 Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Wed, 15 Jan 2020 12:05:18 -0500 Subject: [PATCH 1095/1566] Store nightly snapshot in rust-toolchain file, and use it in cargo.sh The rust-toolchain file can also store an exact nightly snapshot (instead of just "nightly"), so we can store whatever snapshot that rustc_codegen_cranelift is known to work with. This also lets us add a new feature to `cargo.sh` to let it use the exact same nightly snapshot as cg_clif. If there's a nightly compiler mismatch, you get a confusing error message like: error: couldn't load codegen backend "librustc_codegen_cranelift.so": "librustc_driver-681e2b4f66c73d3e.so: cannot open shared object file: No such file or directory" So doing this automatically in cargo.sh is useful. --- cargo.sh | 6 +++++- rust-toolchain | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cargo.sh b/cargo.sh index 42c137030a5d8..5af2381215198 100755 --- a/cargo.sh +++ b/cargo.sh @@ -6,9 +6,13 @@ fi pushd $(dirname "$0") >/dev/null source config.sh + +# read nightly compiler from rust-toolchain file +TOOLCHAIN=$(cat rust-toolchain) + popd >/dev/null cmd=$1 shift -cargo $cmd --target $TARGET_TRIPLE $@ +cargo +${TOOLCHAIN} $cmd --target $TARGET_TRIPLE $@ diff --git a/rust-toolchain b/rust-toolchain index bf867e0ae5b6c..ae478dbcb74e1 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly +nightly-2020-01-13 From 99407a4057e5176df0e7441c07598f163bea809c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Jan 2020 18:40:24 +0100 Subject: [PATCH 1096/1566] Display warning when overriding default rustc version in cargo.sh --- cargo.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cargo.sh b/cargo.sh index 5af2381215198..9b83deaf7ab98 100755 --- a/cargo.sh +++ b/cargo.sh @@ -12,6 +12,11 @@ TOOLCHAIN=$(cat rust-toolchain) popd >/dev/null +if [[ $(rustc -V) != $(rustc +${TOOLCHAIN} -V) ]]; then + echo "rustc_codegen_cranelift is build for $(rustc +${TOOLCHAIN} -V) but the default rustc version is $(rustc -V)." + echo "Using $(rustc +${TOOLCHAIN} -V)." +fi + cmd=$1 shift From 31403cf50abb079d06a33cc9c3193a59e4d68d6b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Jan 2020 19:42:10 +0100 Subject: [PATCH 1097/1566] Add rustup script --- rustup.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 rustup.sh diff --git a/rustup.sh b/rustup.sh new file mode 100755 index 0000000000000..bd3158dd396c0 --- /dev/null +++ b/rustup.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e + +case $1 in + "prepare") + # FIXME Automatically detect latest nightly + read -p "Date of nightly to use (aka yesterday GMT): " TOOLCHAIN + + echo "=> Installing new nightly" + rustup toolchain install --profile minimal nightly-${TOOLCHAIN} # Sanity check to see if the nightly exists + echo nightly-${TOOLCHAIN} > rust-toolchain + + echo "=> Uninstalling all old nighlies" + for nightly in $(rustup toolchain list | grep nightly- | grep -v $TOOLCHAIN); do + rustup toolchain uninstall $nightly + done + + ./clean_all.sh + ./prepare.sh + ;; + "commit") + git commit -m "$(rustc -V)" + ;; + *) + echo "Unknown command '$1'" + echo "Usage: ./rustup.sh prepare|commit" + ;; +esac From 6a246dca93d95c19d4e39b923bed81308be01b3e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Jan 2020 20:04:33 +0100 Subject: [PATCH 1098/1566] rustc 1.42.0-nightly (31dd4f4ac 2020-01-13) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index ae478dbcb74e1..15374cf4ecdcf 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-01-13 +nightly-2020-01-14 From 160dcefab87e6b1feb64b43339657debcd8eee30 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 15 Jan 2020 20:20:30 +0100 Subject: [PATCH 1099/1566] Correct commit message in rustup.sh --- rustup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustup.sh b/rustup.sh index bd3158dd396c0..e1b1bdc399dcb 100755 --- a/rustup.sh +++ b/rustup.sh @@ -20,7 +20,7 @@ case $1 in ./prepare.sh ;; "commit") - git commit -m "$(rustc -V)" + git commit -m "Rustup to $(rustc -V)" ;; *) echo "Unknown command '$1'" From 98fc3b0c2776569851744b0cc302548e23d96602 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2020 05:11:56 +0000 Subject: [PATCH 1100/1566] Bump cranelift-codegen from `3268b0d` to `062e984` Bumps [cranelift-codegen](https://github.com/bytecodealliance/cranelift) from `3268b0d` to `062e984`. - [Release notes](https://github.com/bytecodealliance/cranelift/releases) - [Commits](https://github.com/bytecodealliance/cranelift/compare/3268b0d11f6646b95e250d9f5eba22756434bcef...062e984cddb39bfe41f3abcb4653e76670960a69) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 102 ++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13b123636e3fc..e93e5a6b114b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,22 +32,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ - "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-meta 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-shared 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-bforest 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-meta 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -56,29 +56,29 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ - "cranelift-codegen-shared 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" [[package]] name = "cranelift-entity" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" [[package]] name = "cranelift-frontend" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ - "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -86,44 +86,44 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ - "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ - "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ - "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.54.0" -source = "git+https://github.com/bytecodealliance/cranelift/#3268b0d11f6646b95e250d9f5eba22756434bcef" +version = "0.56.0" +source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" dependencies = [ - "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -281,11 +281,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -406,16 +406,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift-bforest 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.54.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" From 24fd604540316786e7f7780fa6da2dc53248b746 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Jan 2020 18:04:11 +0100 Subject: [PATCH 1101/1566] Update Cranelift As basic blocks now work, they are enabled. --- Cargo.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++--------- Cargo.toml | 8 +++---- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e93e5a6b114b0..a62148c4f0b53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,6 +5,14 @@ name = "ar" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "autocfg" version = "0.1.7" @@ -33,7 +41,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -41,13 +49,14 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-meta 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -57,7 +66,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -66,17 +75,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" [[package]] name = "cranelift-entity" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" [[package]] name = "cranelift-frontend" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -87,7 +96,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -98,7 +107,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -108,7 +117,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -119,7 +128,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#062e984cddb39bfe41f3abcb4653e76670960a69" +source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -158,11 +167,28 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "gimli" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gimli" version = "0.20.0" @@ -220,6 +246,11 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "object" version = "0.17.0" @@ -337,6 +368,11 @@ name = "smallvec" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "stable_deref_trait" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "syn" version = "1.0.13" @@ -401,6 +437,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" +"checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -419,7 +456,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" "checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" @@ -427,6 +466,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" +"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" @@ -439,6 +479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" +"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" diff --git a/Cargo.toml b/Cargo.toml index c4fca7f7c760b..8e4cff5c1eb67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,8 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } -cranelift-frontend = { git = "https://github.com/bytecodealliance/cranelift/", default-features = false, features = ["std"] } +cranelift-codegen = { git = "https://github.com/bytecodealliance/cranelift/" } +cranelift-frontend = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/" } target-lexicon = "0.10.0" @@ -31,8 +31,8 @@ features = ["write"] # We don't need read support # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/cranelift/"] -#cranelift-codegen = { path = "../cranelift/cranelift-codegen", default-features = false, features = ["std"] } -#cranelift-frontend = { path = "../cranelift/cranelift-frontend", default-features = false, features = ["std"] } +#cranelift-codegen = { path = "../cranelift/cranelift-codegen" } +#cranelift-frontend = { path = "../cranelift/cranelift-frontend" } #cranelift-module = { path = "../cranelift/cranelift-module" } #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } #cranelift-object = { path = "../cranelift/cranelift-object" } From 319797109522b85d061c97f0b63b0c7d4ab4152e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Jan 2020 18:09:00 +0100 Subject: [PATCH 1102/1566] Update dependencies --- Cargo.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a62148c4f0b53..df76a941bc840 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "autocfg" -version = "0.1.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -185,7 +185,7 @@ dependencies = [ "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -195,7 +195,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -210,10 +210,10 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -258,7 +258,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -271,7 +271,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -282,7 +282,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -318,7 +318,7 @@ dependencies = [ "cranelift-object 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-simplejit 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -345,9 +345,9 @@ name = "scroll_derive" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -375,10 +375,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -401,9 +401,9 @@ name = "thiserror-impl" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -438,7 +438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" @@ -461,7 +461,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" "checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" -"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" +"checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" @@ -469,7 +469,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" +"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" @@ -480,7 +480,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" -"checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" +"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" "checksum thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" From 83f6ef1558f35b206d000043943e8249c787827d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Jan 2020 19:14:03 +0100 Subject: [PATCH 1103/1566] Rustup to rustc 1.42.0-nightly (689fca01c 2020-01-17) --- patches/0017-Fix-libtest-compilation.patch | 4 ++-- rust-toolchain | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index 5592818474ebe..5299fb2b46505 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -39,8 +39,8 @@ index 8b76080..9e65de2 100644 let cfg = thread::Builder::new().name(name.as_slice().to_owned()); cfg.spawn(runtest).unwrap(); @@ -1531,17 +1531,8 @@ pub fn run_test( - (benchfn.clone())(harness) - }); + // Benchmarks aren't expected to panic, so we run them all in-process. + crate::bench::benchmark(desc, monitor_ch, opts.nocapture, benchfn); } - DynTestFn(f) => { - match strategy { diff --git a/rust-toolchain b/rust-toolchain index 15374cf4ecdcf..238b1af43953f 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-01-14 +nightly-2020-01-18 From c4acc78e4d9fd3f81361ea68e3b5fc5d09879c60 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 1 Dec 2019 17:35:40 +0100 Subject: [PATCH 1104/1566] Allow more types in CValue::const_val --- src/value_and_place.rs | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 95913256f24ca..f346ff8f05e0b 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -195,13 +195,20 @@ impl<'tcx> CValue<'tcx> { } /// If `ty` is signed, `const_val` must already be sign extended. - pub fn const_val<'a>( + pub fn const_val( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, const_val: u128, ) -> CValue<'tcx> { let clif_ty = fx.clif_type(layout.ty).unwrap(); + match layout.ty.kind { + ty::TyKind::Bool => { + assert!(const_val == 0 || const_val == 1, "Invalid bool 0x{:032X}", const_val); + } + _ => {} + } + let val = match layout.ty.kind { ty::TyKind::Uint(UintTy::U128) | ty::TyKind::Int(IntTy::I128) => { let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64); @@ -211,21 +218,25 @@ impl<'tcx> CValue<'tcx> { .iconst(types::I64, (const_val >> 64) as u64 as i64); fx.bcx.ins().iconcat(lsb, msb) } - ty::TyKind::Bool => { - assert!( - const_val == 0 || const_val == 1, - "Invalid bool 0x{:032X}", - const_val - ); - fx.bcx.ins().iconst(types::I8, const_val as i64) + ty::TyKind::Bool | ty::TyKind::Char | ty::TyKind::Uint(_) | ty::TyKind::Ref(..) + | ty::TyKind::RawPtr(..) => { + fx + .bcx + .ins() + .iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64) + } + ty::TyKind::Int(_) => { + let const_val = rustc::mir::interpret::sign_extend(const_val, layout.size); + fx.bcx.ins().iconst(clif_ty, i64::try_from(const_val as i128).unwrap()) + } + ty::TyKind::Float(FloatTy::F32) => { + fx.bcx.ins().f32const(Ieee32::with_bits(u32::try_from(const_val).unwrap())) + } + ty::TyKind::Float(FloatTy::F64) => { + fx.bcx.ins().f64const(Ieee64::with_bits(u64::try_from(const_val).unwrap())) } - ty::TyKind::Uint(_) | ty::TyKind::Ref(..) | ty::TyKind::RawPtr(..) => fx - .bcx - .ins() - .iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64), - ty::TyKind::Int(_) => fx.bcx.ins().iconst(clif_ty, const_val as i128 as i64), _ => panic!( - "CValue::const_val for non bool/integer/pointer type {:?} is not allowed", + "CValue::const_val for non bool/char/float/integer/pointer type {:?} is not allowed", layout.ty ), }; From 167c7f2201c388d5eafd7c3557a58b437a5b0db6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Jan 2020 14:01:51 +0100 Subject: [PATCH 1105/1566] Don't force static refs to const memory --- src/constant.rs | 85 ++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 6d33f71072ae2..b6b43526c7248 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -11,6 +11,7 @@ use rustc_mir::interpret::{ StackPopCleanup, StackPopInfo, }; +use cranelift_codegen::ir::GlobalValue; use cranelift_module::*; use crate::prelude::*; @@ -47,7 +48,10 @@ fn codegen_static_ref<'tcx>( ) -> CPlace<'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); - cplace_for_dataid(fx, layout, data_id) + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + #[cfg(debug_assertions)] + fx.add_entity_comment(local_data_id, format!("{:?}", def_id)); + cplace_for_dataid(fx, layout, local_data_id) } pub fn trans_constant<'tcx>( @@ -119,7 +123,6 @@ pub fn trans_const_value<'tcx>( layout, ); } - let const_val = match const_.val { ConstKind::Value(const_val) => const_val, _ => unreachable!("Const {:?} should have been evaluated", const_), @@ -127,45 +130,45 @@ pub fn trans_const_value<'tcx>( match const_val { ConstValue::Scalar(x) => { - let scalar = match layout.abi { - layout::Abi::Scalar(ref x) => x, - _ => bug!("from_const: invalid ByVal layout: {:#?}", layout), - }; + if fx.clif_type(layout.ty).is_none() { + return trans_const_place(fx, const_).to_cvalue(fx); + } - match ty.kind { - ty::Bool | ty::Uint(_) => { - let bits = const_.val.try_to_bits(layout.size).unwrap_or_else(|| { - panic!("{:?}\n{:?}", const_, layout); - }); - CValue::const_val(fx, layout, bits) + match x { + Scalar::Raw { data, size } => { + assert_eq!(u64::from(size), layout.size.bytes()); + return CValue::const_val(fx, layout, data); } - ty::Int(_) => { - let bits = const_.val.try_to_bits(layout.size).unwrap(); - CValue::const_val( - fx, - layout, - rustc::mir::interpret::sign_extend(bits, layout.size), - ) - } - ty::Float(fty) => { - let bits = const_.val.try_to_bits(layout.size).unwrap(); - let val = match fty { - FloatTy::F32 => fx - .bcx - .ins() - .f32const(Ieee32::with_bits(u32::try_from(bits).unwrap())), - FloatTy::F64 => fx - .bcx - .ins() - .f64const(Ieee64::with_bits(u64::try_from(bits).unwrap())), + Scalar::Ptr(ptr) => { + let alloc_kind = fx.tcx.alloc_map.lock().get(ptr.alloc_id); + let base_addr = match alloc_kind { + Some(GlobalAlloc::Memory(alloc)) => { + fx.constants_cx.todo.insert(TodoItem::Alloc(ptr.alloc_id)); + let data_id = data_id_for_alloc_id(fx.module, ptr.alloc_id, alloc.align); + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + #[cfg(debug_assertions)] + fx.add_entity_comment(local_data_id, format!("{:?}", ptr.alloc_id)); + fx.bcx.ins().global_value(fx.pointer_type, local_data_id) + } + Some(GlobalAlloc::Function(instance)) => { + let func_id = crate::abi::import_function(fx.tcx, fx.module, instance); + let local_func_id = fx.module.declare_func_in_func(func_id, &mut fx.bcx.func); + fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) + } + Some(GlobalAlloc::Static(def_id)) => { + assert!(fx.tcx.is_static(def_id)); + 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_entity_comment(local_data_id, format!("{:?}", def_id)); + fx.bcx.ins().global_value(fx.pointer_type, local_data_id) + } + None => bug!("missing allocation {:?}", ptr.alloc_id), }; - CValue::by_val(val, layout) + let val = fx.bcx.ins().iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap()); + return CValue::by_val(val, layout); } - ty::FnDef(_def_id, _substs) => CValue::by_ref( - crate::pointer::Pointer::const_addr(fx, fx.pointer_type.bytes() as i64), - layout, - ), - _ => trans_const_place(fx, const_).to_cvalue(fx), } } ConstValue::ByRef { alloc, offset } => { @@ -228,7 +231,10 @@ fn trans_const_place<'tcx>( let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); fx.constants_cx.todo.insert(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); - cplace_for_dataid(fx, fx.layout_of(const_.ty), data_id) + let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + #[cfg(debug_assertions)] + fx.add_entity_comment(local_data_id, format!("{:?}", alloc_id)); + cplace_for_dataid(fx, fx.layout_of(const_.ty), local_data_id) } fn data_id_for_alloc_id( @@ -305,9 +311,8 @@ fn data_id_for_static( fn cplace_for_dataid<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, - data_id: DataId, + local_data_id: GlobalValue, ) -> CPlace<'tcx> { - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); 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) From aa5c49cf2f5425344b7859de73b6d347b851f694 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Jan 2020 18:31:01 +0100 Subject: [PATCH 1106/1566] Make unused stack slots zero sized in stack2reg --- src/optimize/stack2reg.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index b1afa9ab8bb15..8fa5fb13c2eb4 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -237,7 +237,7 @@ pub(super) fn optimize_function( } if users.stack_store.is_empty() && users.stack_load.is_empty() { - // FIXME make stack_slot zero sized. + opt_ctx.ctx.func.stack_slots[stack_slot.0].size = 0; } } From a3f378754b63d222f1679b901f7d90d6d4c32aaa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Jan 2020 20:33:27 +0100 Subject: [PATCH 1107/1566] Warn when using LTO --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index cc7c0bb5a63f8..77ffd46f6f2ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,11 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { struct CraneliftCodegenBackend; impl CodegenBackend for CraneliftCodegenBackend { - fn init(&self, _sess: &Session) {} + fn init(&self, sess: &Session) { + if sess.lto() != rustc_session::config::Lto::No { + sess.warn("LTO is not supported. You may get a linker error."); + } + } fn metadata_loader(&self) -> Box { Box::new(crate::metadata::CraneliftMetadataLoader) From ddd3d95a7eb02ba491e6b1ac7ca9c60ee18e3c70 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Jan 2020 12:43:31 +0100 Subject: [PATCH 1108/1566] Make atomic instructions atomic using a global lock --- config.sh | 6 +++ src/atomic_shim.rs | 94 +++++++++++++++++++++++++++++++++++++++++++ src/driver.rs | 7 ++++ src/intrinsics/mod.rs | 38 ++++++++++++++++- src/lib.rs | 2 + src/main_shim.rs | 2 + 6 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 src/atomic_shim.rs diff --git a/config.sh b/config.sh index 4b7fe76d690b7..6a3cc715119cf 100644 --- a/config.sh +++ b/config.sh @@ -13,6 +13,12 @@ fi TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' + +# FIXME remove once the atomic shim is gone +if [[ `uname` == 'Darwin' ]]; then + export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" +fi + RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs new file mode 100644 index 0000000000000..300177e764563 --- /dev/null +++ b/src/atomic_shim.rs @@ -0,0 +1,94 @@ +//! Atomic intrinsics are implemented using a global lock for now, as Cranelift doesn't support +//! atomic operations yet. + +// FIXME implement atomic instructions in Cranelift. + +use crate::prelude::*; + +#[no_mangle] +pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; + +pub fn init_global_lock(module: &mut Module, bcx: &mut FunctionBuilder<'_>) { + if std::env::var("SHOULD_RUN").is_ok () { + // When using JIT, dylibs won't find the __cg_clif_global_atomic_mutex data object defined here, + // so instead define it in the cg_clif dylib. + + return; + } + + let mut data_ctx = DataContext::new(); + data_ctx.define_zeroinit(1024); // 1024 bytes should be big enough on all platforms. + let atomic_mutex = module.declare_data( + "__cg_clif_global_atomic_mutex", + Linkage::Export, + true, + Some(16), + ).unwrap(); + module.define_data(atomic_mutex, &data_ctx).unwrap(); + + let pthread_mutex_init = module.declare_function("pthread_mutex_init", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: module.target_config().default_call_conv, + params: vec![ + AbiParam::new(module.target_config().pointer_type() /* *mut pthread_mutex_t */), + AbiParam::new(module.target_config().pointer_type() /* *const pthread_mutex_attr_t */), + ], + returns: vec![AbiParam::new(types::I32 /* c_int */)], + }).unwrap(); + + let pthread_mutex_init = module.declare_func_in_func(pthread_mutex_init, bcx.func); + + let atomic_mutex = module.declare_data_in_func(atomic_mutex, bcx.func); + let atomic_mutex = bcx.ins().global_value(module.target_config().pointer_type(), atomic_mutex); + + let nullptr = bcx.ins().iconst(module.target_config().pointer_type(), 0); + + bcx.ins().call(pthread_mutex_init, &[atomic_mutex, nullptr]); +} + +pub fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { + let atomic_mutex = fx.module.declare_data( + "__cg_clif_global_atomic_mutex", + Linkage::Import, + true, + None, + ).unwrap(); + + let pthread_mutex_lock = fx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fx.module.target_config().default_call_conv, + params: vec![ + AbiParam::new(fx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + ], + returns: vec![AbiParam::new(types::I32 /* c_int */)], + }).unwrap(); + + let pthread_mutex_lock = fx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); + + let atomic_mutex = fx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fx.module.target_config().pointer_type(), atomic_mutex); + + fx.bcx.ins().call(pthread_mutex_lock, &[atomic_mutex]); +} + +pub fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { + let atomic_mutex = fx.module.declare_data( + "__cg_clif_global_atomic_mutex", + Linkage::Import, + true, + None, + ).unwrap(); + + let pthread_mutex_unlock = fx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fx.module.target_config().default_call_conv, + params: vec![ + AbiParam::new(fx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + ], + returns: vec![AbiParam::new(types::I32 /* c_int */)], + }).unwrap(); + + let pthread_mutex_unlock = fx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); + + let atomic_mutex = fx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fx.module.target_config().pointer_type(), atomic_mutex); + + fx.bcx.ins().call(pthread_mutex_unlock, &[atomic_mutex]); +} diff --git a/src/driver.rs b/src/driver.rs index 26188808d5ab7..9eb9df0eb54fa 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -36,6 +36,13 @@ pub fn codegen_crate( fn run_jit(tcx: TyCtxt<'_>) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; + // Rustc opens us without the RTLD_GLOBAL flag, so __cg_clif_global_atomic_mutex will not be + // exported. We fix this by opening ourself again as global. + // FIXME remove once atomic_shim is gone + let cg_dylib = std::ffi::OsString::from(&tcx.sess.opts.debugging_opts.codegen_backend.as_ref().unwrap()); + std::mem::forget(libloading::os::unix::Library::open(Some(cg_dylib), libc::RTLD_NOW | libc::RTLD_GLOBAL).unwrap()); + + let imported_symbols = load_imported_symbols_for_jit(tcx); let mut jit_builder = SimpleJITBuilder::with_isa( diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 459c68baa6370..cdb7164f88c9d 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -104,14 +104,20 @@ macro call_intrinsic_match { } macro atomic_binop_return_old($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) { + crate::atomic_shim::lock_global_lock($fx); + let clif_ty = $fx.clif_type($T).unwrap(); let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); let new = $fx.bcx.ins().$op(old, $src); $fx.bcx.ins().store(MemFlags::new(), new, $ptr, 0); $ret.write_cvalue($fx, CValue::by_val(old, $fx.layout_of($T))); + + crate::atomic_shim::unlock_global_lock($fx); } macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ret:ident) { + crate::atomic_shim::lock_global_lock($fx); + // Read old let clif_ty = $fx.clif_type($T).unwrap(); let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); @@ -125,6 +131,8 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ let ret_val = CValue::by_val(old, $ret.layout()); $ret.write_cvalue($fx, ret_val); + + crate::atomic_shim::unlock_global_lock($fx); } fn lane_type_and_count<'tcx>( @@ -845,19 +853,35 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, caller_location); }; - _ if intrinsic.starts_with("atomic_fence"), () {}; - _ if intrinsic.starts_with("atomic_singlethreadfence"), () {}; + _ if intrinsic.starts_with("atomic_fence"), () { + crate::atomic_shim::lock_global_lock(fx); + crate::atomic_shim::unlock_global_lock(fx); + }; + _ if intrinsic.starts_with("atomic_singlethreadfence"), () { + crate::atomic_shim::lock_global_lock(fx); + crate::atomic_shim::unlock_global_lock(fx); + }; _ if intrinsic.starts_with("atomic_load"), (c ptr) { + crate::atomic_shim::lock_global_lock(fx); + let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); let val = CValue::by_ref(Pointer::new(ptr.load_scalar(fx)), inner_layout); ret.write_cvalue(fx, val); + + crate::atomic_shim::unlock_global_lock(fx); }; _ if intrinsic.starts_with("atomic_store"), (v ptr, c val) { + crate::atomic_shim::lock_global_lock(fx); + let dest = CPlace::for_ptr(Pointer::new(ptr), val.layout()); dest.write_cvalue(fx, val); + + crate::atomic_shim::unlock_global_lock(fx); }; _ if intrinsic.starts_with("atomic_xchg"), (v ptr, c src) { + crate::atomic_shim::lock_global_lock(fx); + // Read old let clif_ty = fx.clif_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); @@ -866,8 +890,12 @@ pub fn codegen_intrinsic_call<'tcx>( // Write new let dest = CPlace::for_ptr(Pointer::new(ptr), src.layout()); dest.write_cvalue(fx, src); + + crate::atomic_shim::unlock_global_lock(fx); }; _ if intrinsic.starts_with("atomic_cxchg"), (v ptr, v test_old, v new) { // both atomic_cxchg_* and atomic_cxchgweak_* + crate::atomic_shim::lock_global_lock(fx); + // Read old let clif_ty = fx.clif_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); @@ -881,6 +909,8 @@ pub fn codegen_intrinsic_call<'tcx>( let ret_val = CValue::by_val_pair(old, fx.bcx.ins().bint(types::I8, is_eq), ret.layout()); ret.write_cvalue(fx, ret_val); + + crate::atomic_shim::unlock_global_lock(fx); }; _ if intrinsic.starts_with("atomic_xadd"), (v ptr, v amount) { @@ -893,12 +923,16 @@ pub fn codegen_intrinsic_call<'tcx>( atomic_binop_return_old! (fx, band(ptr, src) -> ret); }; _ if intrinsic.starts_with("atomic_nand"), (v ptr, v src) { + crate::atomic_shim::lock_global_lock(fx); + let clif_ty = fx.clif_type(T).unwrap(); let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); let and = fx.bcx.ins().band(old, src); let new = fx.bcx.ins().bnot(and); fx.bcx.ins().store(MemFlags::new(), new, ptr, 0); ret.write_cvalue(fx, CValue::by_val(old, fx.layout_of(T))); + + crate::atomic_shim::unlock_global_lock(fx); }; _ if intrinsic.starts_with("atomic_or"), (v ptr, v src) { atomic_binop_return_old! (fx, bor(ptr, src) -> ret); diff --git a/src/lib.rs b/src/lib.rs index 77ffd46f6f2ea..94c47d0d39578 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ #![allow(intra_doc_link_resolution_failure)] extern crate flate2; +extern crate libc; extern crate tempfile; extern crate rustc; extern crate rustc_codegen_ssa; @@ -36,6 +37,7 @@ mod abi; mod allocator; mod analyze; mod archive; +mod atomic_shim; mod base; mod backend; mod cast; diff --git a/src/main_shim.rs b/src/main_shim.rs index 8577845037dbc..b7c1425a1af5e 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -67,6 +67,8 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module Date: Sat, 18 Jan 2020 10:23:51 +0100 Subject: [PATCH 1109/1566] Improve PlaceElem::Subslice handling --- src/base.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/base.rs b/src/base.rs index 5eb0170a19dd5..e1ca09fa7804e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -678,11 +678,10 @@ pub fn trans_place<'tcx>( // slice[from:-to] in Python terms. match cplace.layout().ty.kind { - ty::Array(elem_ty, len) => { + ty::Array(elem_ty, _len) => { + assert!(!from_end, "array subslices are never `from_end`"); let elem_layout = fx.layout_of(elem_ty); let ptr = cplace.to_ptr(fx); - let len = crate::constant::force_eval_const(fx, len) - .eval_usize(fx.tcx, ParamEnv::reveal_all()); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), fx.layout_of(fx.tcx.mk_array(elem_ty, to as u64 - from as u64)), From 1db38c0dfc66c54cabce16e56fa16a8eb38366aa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Jan 2020 20:24:17 +0100 Subject: [PATCH 1110/1566] Re-introduce FnBox --- .../0015-Remove-usage-of-unsized-locals.patch | 47 +---- patches/0018-Add-FnBox-back.patch | 173 ++++++++++++++++++ 2 files changed, 178 insertions(+), 42 deletions(-) create mode 100644 patches/0018-Add-FnBox-back.patch diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch index 02ecaa7a99451..9c60ac55a9f31 100644 --- a/patches/0015-Remove-usage-of-unsized-locals.patch +++ b/patches/0015-Remove-usage-of-unsized-locals.patch @@ -44,53 +44,16 @@ index f6dee7c..0c6a8c0 100644 #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Box {} -diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs -index 1181b86..20f9251 100644 ---- a/src/libstd/sys_common/at_exit_imp.rs -+++ b/src/libstd/sys_common/at_exit_imp.rs -@@ -38,6 +38,7 @@ unsafe fn init() -> bool { - true - } - -+/* - pub fn cleanup() { - for i in 1..=ITERS { - unsafe { -@@ -60,6 +61,7 @@ pub fn cleanup() { - } - } - } -+*/ - - pub fn push(f: Box) -> bool { - unsafe { -diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs -index 6260c3b..611ed7e 100644 ---- a/src/libstd/sys_common/mod.rs -+++ b/src/libstd/sys_common/mod.rs -@@ -127,7 +127,6 @@ pub fn cleanup() { - CLEANUP.call_once(|| unsafe { - sys::args::cleanup(); - sys::stack_overflow::cleanup(); -- at_exit_imp::cleanup(); - }); - } - diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs index b2142e7..718bb1c 100644 --- a/src/libstd/sys_common/thread.rs +++ b/src/libstd/sys_common/thread.rs -@@ -6,12 +6,7 @@ use crate::sys::thread as imp; +@@ -6,7 +6,7 @@ pub unsafe fn start_thread(main: *mut u8) { + let _handler = stack_overflow::Handler::new(); - #[allow(dead_code)] - pub unsafe fn start_thread(main: *mut u8) { -- // Next, set up our stack overflow handler which may get triggered if we run -- // out of stack. -- let _handler = stack_overflow::Handler::new(); -- -- // Finally, let's run some code. + // Finally, let's run some code. - Box::from_raw(main as *mut Box)() -+ panic!("Threads are not yet supported, because cranelift doesn't support atomics."); ++ Box::from_raw(main as *mut Box)() } pub fn min_stack() -> usize { @@ -101,7 +64,7 @@ index f4a1783..362b537 100644 @@ -40,5 +40,7 @@ impl Thread { // unsafe: see thread::Builder::spawn_unchecked for safety requirements pub unsafe fn new(stack: usize, p: Box) -> io::Result { -+ panic!("Threads are not yet supported, because cranelift doesn't support atomics."); ++ panic!("Warning: Threads are not yet fully supported, because cranelift doesn't support atomics."); + let p = box p; let mut native: libc::pthread_t = mem::zeroed(); diff --git a/patches/0018-Add-FnBox-back.patch b/patches/0018-Add-FnBox-back.patch new file mode 100644 index 0000000000000..e5616aa5a8b1d --- /dev/null +++ b/patches/0018-Add-FnBox-back.patch @@ -0,0 +1,173 @@ +From 8617310c3c9e192080df6a0c7b4835d3f02e27b9 Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Fri, 1 Nov 2019 20:58:30 +0100 +Subject: [PATCH] Add FnBox back + +--- + src/liballoc/boxed.rs | 13 +++++++++++++ + src/libstd/prelude/v1.rs | 2 +- + src/libstd/sys/cloudabi/thread.rs | 2 +- + src/libstd/sys/hermit/thread.rs | 4 ++-- + src/libstd/sys/unix/thread.rs | 4 ++-- + src/libstd/sys_common/at_exit_imp.rs | 6 +++--- + src/libstd/sys_common/mod.rs | 2 +- + src/libstd/sys_common/thread.rs | 2 +- + src/libstd/thread/mod.rs | 2 +- + 9 files changed, 25 insertions(+), 12 deletions(-) + +diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs +index ef9b648..e32b870 100644 +--- a/src/liballoc/boxed.rs ++++ b/src/liballoc/boxed.rs +@@ -1079,3 +1079,16 @@ impl Future for Box { + F::poll(Pin::new(&mut *self), cx) + } + } ++ ++#[stable(feature = "rust1", since = "1.0.0")] ++pub trait FnBox: FnOnce { ++ #[stable(feature = "rust1", since = "1.0.0")] ++ extern "rust-call" fn call_box(self: Box, args: A) -> Self::Output; ++} ++ ++#[stable(feature = "rust1", since = "1.0.0")] ++impl> FnBox for F { ++ extern "rust-call" fn call_box(self: Box, args: A) -> Self::Output { ++ >::call_once(*self, args) ++ } ++} +diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs +index 3e4cf91..1f50eb3 100644 +--- a/src/libstd/prelude/v1.rs ++++ b/src/libstd/prelude/v1.rs +@@ -94,6 +94,6 @@ pub use core::prelude::v1::{ + #[stable(feature = "rust1", since = "1.0.0")] + #[doc(no_inline)] +-pub use crate::boxed::Box; ++pub use crate::boxed::{Box, FnBox}; + #[stable(feature = "rust1", since = "1.0.0")] + #[doc(no_inline)] + pub use crate::string::{String, ToString}; +diff --git a/src/libstd/sys/cloudabi/thread.rs b/src/libstd/sys/cloudabi/thread.rs +index 240b6ea..6f71c6b 100644 +--- a/src/libstd/sys/cloudabi/thread.rs ++++ b/src/libstd/sys/cloudabi/thread.rs +@@ -21,7 +21,7 @@ unsafe impl Sync for Thread {} + + impl Thread { + // unsafe: see thread::Builder::spawn_unchecked for safety requirements +- pub unsafe fn new(stack: usize, p: Box) -> io::Result { ++ pub unsafe fn new(stack: usize, p: Box) -> io::Result { + let p = box p; + let mut native: libc::pthread_t = mem::zeroed(); + let mut attr: libc::pthread_attr_t = mem::zeroed(); +diff --git a/src/libstd/sys/hermit/thread.rs b/src/libstd/sys/hermit/thread.rs +index 99a9c83..b8bc392 100644 +--- a/src/libstd/sys/hermit/thread.rs ++++ b/src/libstd/sys/hermit/thread.rs +@@ -44,9 +44,9 @@ unsafe impl Sync for Thread {} + pub const DEFAULT_MIN_STACK_SIZE: usize = 262144; + + impl Thread { + pub unsafe fn new_with_coreid( + _stack: usize, +- p: Box, ++ p: Box, + core_id: isize, + ) -> io::Result { + let p = box p; +@@ -67,7 +67,7 @@ impl Thread { + } + } + +- pub unsafe fn new(stack: usize, p: Box) -> io::Result { ++ pub unsafe fn new(stack: usize, p: Box) -> io::Result { + Thread::new_with_coreid(stack, p, -1 /* = no specific core */) + } + +diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs +index 143cf2f..a6e8faf 100644 +--- a/src/libstd/sys/unix/thread.rs ++++ b/src/libstd/sys/unix/thread.rs +@@ -38,8 +38,8 @@ unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t, + + impl Thread { + // unsafe: see thread::Builder::spawn_unchecked for safety requirements +- pub unsafe fn new(stack: usize, p: Box) -> io::Result { ++ pub unsafe fn new(stack: usize, p: Box) -> io::Result { + panic!("Warning: Threads are not yet fully supported, because cranelift doesn't support atomics."); + + let p = box p; + let mut native: libc::pthread_t = mem::zeroed(); +diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs +index cdb72ee..e523333 100644 +--- a/src/libstd/sys_common/at_exit_imp.rs ++++ b/src/libstd/sys_common/at_exit_imp.rs +@@ -6,7 +6,7 @@ use crate::mem; + use crate::ptr; + use crate::sys_common::mutex::Mutex; + +-type Queue = Vec>; ++type Queue = Vec>; + + // NB these are specifically not types from `std::sync` as they currently rely + // on poisoning and this module needs to operate at a lower level than requiring +@@ -53,14 +53,14 @@ pub fn cleanup() { + let queue: Box = Box::from_raw(queue); + for to_run in *queue { + // We are not holding any lock, so reentrancy is fine. +- to_run(); ++ to_run.call_box(()); + } + } + } + } + } + +-pub fn push(f: Box) -> bool { ++pub fn push(f: Box) -> bool { + unsafe { + let _guard = LOCK.lock(); + if init() { +diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs +index 7a0bcd0..668bef2 100644 +--- a/src/libstd/sys_common/mod.rs ++++ b/src/libstd/sys_common/mod.rs +@@ -113,7 +113,7 @@ pub trait FromInner { + /// closure will be run once the main thread exits. Returns `Err` to indicate + /// that the closure could not be registered, meaning that it is not scheduled + /// to be run. +-pub fn at_exit(f: F) -> Result<(), ()> { ++pub fn at_exit(f: F) -> Result<(), ()> { + if at_exit_imp::push(Box::new(f)) { Ok(()) } else { Err(()) } + } + +diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs +index c638be9..5c18a18 100644 +--- a/src/libstd/sys_common/thread.rs ++++ b/src/libstd/sys_common/thread.rs +@@ -10,7 +10,7 @@ pub unsafe fn start_thread(main: *mut u8) { + let _handler = stack_overflow::Handler::new(); + + // Finally, let's run some code. +- Box::from_raw(main as *mut Box)() ++ Box::from_raw(main as *mut Box).call_box(()) + } + + pub fn min_stack() -> usize { +diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs +index 0ffa6ac..4a3e3d6 100644 +--- a/src/libstd/thread/mod.rs ++++ b/src/libstd/thread/mod.rs +@@ -485,7 +485,7 @@ impl Builder { + // returning. + native: Some(imp::Thread::new( + stack_size, +- mem::transmute::, Box>(Box::new( ++ mem::transmute::, Box>(Box::new( + main, + )), + )?), +-- +2.20.1 + From eec023eb8529fac3f1b91d45d82609526ef3452f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 12:01:35 +0100 Subject: [PATCH 1111/1566] Rustup to rustc 1.42.0-nightly (c2d141df5 2020-01-24) --- rust-toolchain | 2 +- rustup.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 238b1af43953f..f8a3455b49b24 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-01-18 +nightly-2020-01-25 diff --git a/rustup.sh b/rustup.sh index e1b1bdc399dcb..afa7888cc0c25 100755 --- a/rustup.sh +++ b/rustup.sh @@ -5,14 +5,14 @@ set -e case $1 in "prepare") # FIXME Automatically detect latest nightly - read -p "Date of nightly to use (aka yesterday GMT): " TOOLCHAIN + read -p "Date of nightly to use: " TOOLCHAIN echo "=> Installing new nightly" rustup toolchain install --profile minimal nightly-${TOOLCHAIN} # Sanity check to see if the nightly exists echo nightly-${TOOLCHAIN} > rust-toolchain echo "=> Uninstalling all old nighlies" - for nightly in $(rustup toolchain list | grep nightly- | grep -v $TOOLCHAIN); do + for nightly in $(rustup toolchain list | grep nightly | grep -v $TOOLCHAIN | grep -v nightly-x86_64); do rustup toolchain uninstall $nightly done From bcb469e147dcaf2f9eb53e6f3c33a128522b51ba Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 12:28:22 +0100 Subject: [PATCH 1112/1566] Remove outdated troubleshooting section The nightly version is pinned since recently --- Readme.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Readme.md b/Readme.md index bc1e20a736d62..ef30baac390f5 100644 --- a/Readme.md +++ b/Readme.md @@ -36,9 +36,3 @@ $ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_cod * Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) * Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444), not coming soon) * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171), some basic things work) - -## Troubleshooting - -### Can't compile - -Try updating your nightly compiler. You can try to use an nightly a day or two older if updating rustc doesn't fix it. If you still can't compile it, please fill an issue. From 9cfb9470c5296215ac696065446f9d44492c5b37 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 16:23:54 +0100 Subject: [PATCH 1113/1566] Allow unsized types as function parameters --- src/abi/comments.rs | 22 ++++++++++++++-------- src/abi/mod.rs | 13 ++++++++++--- src/abi/pass_mode.rs | 26 +++++++++++++++++--------- src/abi/returning.rs | 14 +++++++++----- src/value_and_place.rs | 32 ++++++++++++++++++++------------ 5 files changed, 70 insertions(+), 37 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index c704da21b712b..71df9dba61b65 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -77,15 +77,21 @@ pub fn add_local_place_comments<'tcx>( ("ssa", std::borrow::Cow::Borrowed("")) } CPlaceInner::NoPlace => ("zst", "".into()), - CPlaceInner::Addr(ptr, None) => match ptr.base_and_offset() { - (crate::pointer::PointerBase::Addr(addr), offset) => { - ("reuse", format!("storage={}{}", addr, offset).into()) + CPlaceInner::Addr(ptr, meta) => { + let meta = if let Some(meta) = meta { + Cow::Owned(format!(",meta={}", meta)) + } else { + Cow::Borrowed("") + }; + match ptr.base_and_offset() { + (crate::pointer::PointerBase::Addr(addr), offset) => { + ("reuse", format!("storage={}{}{}", addr, offset, meta).into()) + } + (crate::pointer::PointerBase::Stack(stack_slot), offset) => { + ("stack", format!("storage={}{}{}", stack_slot, offset, meta).into()) + } } - (crate::pointer::PointerBase::Stack(stack_slot), offset) => { - ("stack", format!("storage={}{}", stack_slot, offset).into()) - } - }, - CPlaceInner::Addr(_, Some(_)) => unreachable!(), + } }; fx.add_global_comment(format!( diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 00e7ae48b798a..813a436ddf2c1 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -139,7 +139,7 @@ fn clif_sig_from_fn_sig<'tcx>( inputs.map(AbiParam::new).collect(), vec![AbiParam::new(ret_ty_a), AbiParam::new(ret_ty_b)], ), - PassMode::ByRef => { + PassMode::ByRef { sized: true } => { ( Some(pointer_ty(tcx)) // First param is place to put return val .into_iter() @@ -149,6 +149,7 @@ fn clif_sig_from_fn_sig<'tcx>( vec![], ) } + PassMode::ByRef { sized: false } => todo!(), }; if requires_caller_location { @@ -350,9 +351,11 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; + // While this is normally an optimization to prevent an unnecessary copy when an argument is + // not mutated by the current function, this is necessary to support unsized arguments. match arg_kind { ArgKind::Normal(Some(val)) => { - if let Some(addr) = val.try_to_addr() { + if let Some((addr, meta)) = val.try_to_addr() { let local_decl = &fx.mir.local_decls[local]; // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( @@ -364,7 +367,11 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: // We wont mutate this argument, so it is fine to borrow the backing storage // of this argument, to prevent a copy. - let place = CPlace::for_ptr(Pointer::new(addr), val.layout()); + let place = if let Some(meta) = meta { + CPlace::for_ptr_with_extra(Pointer::new(addr), meta, val.layout()) + } else { + CPlace::for_ptr(Pointer::new(addr), val.layout()) + }; #[cfg(debug_assertions)] self::comments::add_local_place_comments(fx, place, local); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 231eb64de41b8..bbb231ed8b747 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -7,7 +7,7 @@ pub enum PassMode { NoPass, ByVal(Type), ByValPair(Type, Type), - ByRef, + ByRef { sized: bool }, } #[derive(Copy, Clone, Debug)] @@ -70,14 +70,13 @@ impl PassMode { PassMode::NoPass => Empty, PassMode::ByVal(clif_type) => Single(clif_type), PassMode::ByValPair(a, b) => Pair(a, b), - PassMode::ByRef => Single(pointer_ty(tcx)), + PassMode::ByRef { sized: true } => Single(pointer_ty(tcx)), + PassMode::ByRef { sized: false } => Pair(pointer_ty(tcx), pointer_ty(tcx)), } } } pub fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> PassMode { - assert!(!layout.is_unsized()); - if layout.is_zst() { // WARNING zst arguments must never be passed, as that will break CastKind::ClosureFnPointer PassMode::NoPass @@ -94,16 +93,16 @@ pub fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> PassMod // Returning (i128, i128) by-val-pair would take 4 regs, while only 3 are // available on x86_64. Cranelift gets confused when too many return params // are used. - PassMode::ByRef + PassMode::ByRef { sized: true } } else { PassMode::ByValPair(a, b) } } // FIXME implement Vector Abi in a cg_llvm compatible way - layout::Abi::Vector { .. } => PassMode::ByRef, + layout::Abi::Vector { .. } => PassMode::ByRef { sized: true }, - layout::Abi::Aggregate { .. } => PassMode::ByRef, + &layout::Abi::Aggregate { sized } => PassMode::ByRef { sized }, } } } @@ -119,7 +118,12 @@ pub(super) fn adjust_arg_for_abi<'tcx>( let (a, b) = arg.load_scalar_pair(fx); Pair(a, b) } - PassMode::ByRef => Single(arg.force_stack(fx).get_addr(fx)), + PassMode::ByRef { sized: _ } => { + match arg.force_stack(fx) { + (ptr, None) => Single(ptr.get_addr(fx)), + (ptr, Some(meta)) => Pair(ptr.get_addr(fx), meta), + } + } } } @@ -158,6 +162,10 @@ pub(super) fn cvalue_for_param<'tcx>( let (a, b) = ebb_params.assert_pair(); Some(CValue::by_val_pair(a, b, layout)) } - PassMode::ByRef => Some(CValue::by_ref(Pointer::new(ebb_params.assert_single()), layout)), + PassMode::ByRef { sized: true } => Some(CValue::by_ref(Pointer::new(ebb_params.assert_single()), layout)), + PassMode::ByRef { sized: false } => { + let (ptr, meta) = ebb_params.assert_pair(); + Some(CValue::by_ref_unsized(Pointer::new(ptr), meta, layout)) + } } } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 5228eb6031b30..d76711173f111 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -9,7 +9,7 @@ pub fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyLayout<'tcx match get_pass_mode(tcx, dest_layout) { PassMode::NoPass | PassMode::ByVal(_) => true, // FIXME Make it possible to return ByValPair and ByRef to an ssa var. - PassMode::ByValPair(_, _) | PassMode::ByRef => false + PassMode::ByValPair(_, _) | PassMode::ByRef { sized: _ } => false } } @@ -33,13 +33,14 @@ pub(super) fn codegen_return_param( Empty } - PassMode::ByRef => { + PassMode::ByRef { sized: true } => { let ret_param = fx.bcx.append_ebb_param(start_ebb, fx.pointer_type); fx.local_map .insert(RETURN_PLACE, CPlace::for_ptr(Pointer::new(ret_param), ret_layout)); Single(ret_param) } + PassMode::ByRef { sized: false } => todo!(), }; #[cfg(debug_assertions)] @@ -65,10 +66,11 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( let output_pass_mode = get_pass_mode(fx.tcx, ret_layout); let return_ptr = match output_pass_mode { PassMode::NoPass => None, - PassMode::ByRef => match ret_place { + PassMode::ByRef { sized: true } => match ret_place { Some(ret_place) => Some(ret_place.to_ptr(fx).get_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), }, + PassMode::ByRef { sized: false } => todo!(), PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, }; @@ -89,7 +91,8 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( ret_place.write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_layout)); } } - PassMode::ByRef => {} + PassMode::ByRef { sized: true } => {} + PassMode::ByRef { sized: false } => todo!(), } (call_inst, meta) @@ -97,9 +100,10 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( pub fn codegen_return(fx: &mut FunctionCx) { match get_pass_mode(fx.tcx, return_layout(fx)) { - PassMode::NoPass | PassMode::ByRef => { + PassMode::NoPass | PassMode::ByRef { sized: true } => { fx.bcx.ins().return_(&[]); } + PassMode::ByRef { sized: false } => todo!(), PassMode::ByVal(_) => { let place = fx.get_local_place(RETURN_PLACE); let ret_val = place.to_cvalue(fx).load_scalar(fx); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index f346ff8f05e0b..882eb82f5aaa8 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -66,14 +66,18 @@ pub struct CValue<'tcx>(CValueInner, TyLayout<'tcx>); #[derive(Debug, Copy, Clone)] enum CValueInner { - ByRef(Pointer), + ByRef(Pointer, Option), ByVal(Value), ByValPair(Value, Value), } impl<'tcx> CValue<'tcx> { pub fn by_ref(ptr: Pointer, layout: TyLayout<'tcx>) -> CValue<'tcx> { - CValue(CValueInner::ByRef(ptr), layout) + CValue(CValueInner::ByRef(ptr, None), layout) + } + + pub fn by_ref_unsized(ptr: Pointer, meta: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + CValue(CValueInner::ByRef(ptr, Some(meta)), layout) } pub fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { @@ -89,24 +93,24 @@ impl<'tcx> CValue<'tcx> { } // FIXME remove - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { + pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option) { let layout = self.1; match self.0 { - CValueInner::ByRef(ptr) => ptr, + CValueInner::ByRef(ptr, meta) => (ptr, meta), CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => { let cplace = CPlace::new_stack_slot(fx, layout); cplace.write_cvalue(fx, self); - cplace.to_ptr(fx) + (cplace.to_ptr(fx), None) } } } - pub fn try_to_addr(self) -> Option { + pub fn try_to_addr(self) -> Option<(Value, Option)> { match self.0 { - CValueInner::ByRef(ptr) => { + CValueInner::ByRef(ptr, meta) => { if let Some((base_addr, offset)) = ptr.try_get_addr_and_offset() { if offset == Offset32::new(0) { - Some(base_addr) + Some((base_addr, meta)) } else { None } @@ -122,7 +126,7 @@ impl<'tcx> CValue<'tcx> { pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; match self.0 { - CValueInner::ByRef(ptr) => { + CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.abi { layout::Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), layout::Abi::Vector { ref element, count } => { @@ -134,6 +138,7 @@ impl<'tcx> CValue<'tcx> { ptr.load(fx, clif_ty, MemFlags::new()) } CValueInner::ByVal(value) => value, + CValueInner::ByRef(_, Some(_)) => bug!("load_scalar for unsized value not allowed"), CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"), } } @@ -145,7 +150,7 @@ impl<'tcx> CValue<'tcx> { ) -> (Value, Value) { let layout = self.1; match self.0 { - CValueInner::ByRef(ptr) => { + CValueInner::ByRef(ptr, None) => { let (a_scalar, b_scalar) = match &layout.abi { layout::Abi::ScalarPair(a, b) => (a, b), _ => unreachable!("load_scalar_pair({:?})", self), @@ -157,6 +162,7 @@ impl<'tcx> CValue<'tcx> { let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); (val1, val2) } + CValueInner::ByRef(_, Some(_)) => bug!("load_scalar_pair for unsized value not allowed"), CValueInner::ByVal(_) => bug!("Please use load_scalar for ByVal"), CValueInner::ByValPair(val1, val2) => (val1, val2), } @@ -182,10 +188,11 @@ impl<'tcx> CValue<'tcx> { _ => unreachable!("value_field for ByVal with abi {:?}", layout.abi), } } - CValueInner::ByRef(ptr) => { + CValueInner::ByRef(ptr, None) => { let (field_ptr, field_layout) = codegen_field(fx, ptr, None, layout, field); CValue::by_ref(field_ptr, field_layout) } + CValueInner::ByRef(_, Some(_)) => todo!(), _ => bug!("place_field for {:?}", self), } } @@ -495,7 +502,7 @@ impl<'tcx> CPlace<'tcx> { dst_layout.abi ); } - CValueInner::ByRef(from_ptr) => { + CValueInner::ByRef(from_ptr, None) => { let from_addr = from_ptr.get_addr(fx); let to_addr = to_ptr.get_addr(fx); let src_layout = from.1; @@ -511,6 +518,7 @@ impl<'tcx> CPlace<'tcx> { src_align, ); } + CValueInner::ByRef(_, Some(_)) => todo!(), } } From 242f2e3c7588574eb5f399dc4cde8f75d7e3e294 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 16:24:15 +0100 Subject: [PATCH 1114/1566] Fix correctness of optimization --- src/abi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 813a436ddf2c1..6d254abb2bf94 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -363,7 +363,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: ParamEnv::reveal_all(), local_decl.source_info.span, ); - if local_decl.mutability == mir::Mutability::Not && internally_mutable { + if local_decl.mutability == mir::Mutability::Not && !internally_mutable { // We wont mutate this argument, so it is fine to borrow the backing storage // of this argument, to prevent a copy. From 74c7a7b7c530beb70b08fe8fe7acfdc1d7226dc5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 16:24:48 +0100 Subject: [PATCH 1115/1566] Replace unimplemented! with unreachable! when it will never be supported --- src/base.rs | 4 ++-- src/intrinsics/mod.rs | 13 +++++++------ src/num.rs | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/base.rs b/src/base.rs index e1ca09fa7804e..6af9ddd8894dc 100644 --- a/src/base.rs +++ b/src/base.rs @@ -358,7 +358,7 @@ fn trans_stmt<'tcx>( ty::Uint(_) | ty::Int(_) => { CValue::by_val(fx.bcx.ins().bnot(val), layout) } - _ => unimplemented!("un op Not for {:?}", layout.ty), + _ => unreachable!("un op Not for {:?}", layout.ty), } } UnOp::Neg => match layout.ty.kind { @@ -369,7 +369,7 @@ fn trans_stmt<'tcx>( ty::Float(_) => { CValue::by_val(fx.bcx.ins().fneg(val), layout) } - _ => unimplemented!("un op Neg for {:?}", layout.ty), + _ => unreachable!("un op Neg for {:?}", layout.ty), }, }; lval.write_cvalue(fx, res); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index cdb7164f88c9d..7470b55366c2d 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -494,7 +494,7 @@ pub fn codegen_intrinsic_call<'tcx>( "unchecked_rem" => BinOp::Rem, "unchecked_shl" => BinOp::Shl, "unchecked_shr" => BinOp::Shr, - _ => unimplemented!("intrinsic {}", intrinsic), + _ => unreachable!("intrinsic {}", intrinsic), }; let res = crate::num::trans_int_binop(fx, bin_op, x, y); ret.write_cvalue(fx, res); @@ -505,7 +505,7 @@ pub fn codegen_intrinsic_call<'tcx>( "add_with_overflow" => BinOp::Add, "sub_with_overflow" => BinOp::Sub, "mul_with_overflow" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), + _ => unreachable!("intrinsic {}", intrinsic), }; let res = crate::num::trans_checked_int_binop( @@ -522,7 +522,7 @@ pub fn codegen_intrinsic_call<'tcx>( "wrapping_add" => BinOp::Add, "wrapping_sub" => BinOp::Sub, "wrapping_mul" => BinOp::Mul, - _ => unimplemented!("intrinsic {}", intrinsic), + _ => unreachable!("intrinsic {}", intrinsic), }; let res = crate::num::trans_int_binop( fx, @@ -537,7 +537,7 @@ pub fn codegen_intrinsic_call<'tcx>( let bin_op = match intrinsic { "saturating_add" => BinOp::Add, "saturating_sub" => BinOp::Sub, - _ => unimplemented!("intrinsic {}", intrinsic), + _ => unreachable!("intrinsic {}", intrinsic), }; let signed = type_sign(T); @@ -605,7 +605,8 @@ pub fn codegen_intrinsic_call<'tcx>( transmute, (c from) { assert_eq!(from.layout().ty, src_ty); - let addr = from.force_stack(fx); + let (addr, meta) = from.force_stack(fx); + assert!(meta.is_none()); let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) }; @@ -805,7 +806,7 @@ pub fn codegen_intrinsic_call<'tcx>( let hi = swap(bcx, hi); bcx.ins().iconcat(hi, lo) } - ty => unimplemented!("bswap {}", ty), + ty => unreachable!("bswap {}", ty), } }; let res = CValue::by_val(swap(&mut fx.bcx, arg), fx.layout_of(T)); diff --git a/src/num.rs b/src/num.rs index e11143d6bd2c4..103c15eca4136 100644 --- a/src/num.rs +++ b/src/num.rs @@ -91,7 +91,7 @@ pub fn codegen_binop<'tcx>( ty::Uint(_) | ty::Int(_) => crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs), ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs), ty::RawPtr(..) | ty::FnPtr(..) => crate::num::trans_ptr_binop(fx, bin_op, in_lhs, in_rhs), - _ => unimplemented!( + _ => unreachable!( "{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, From 8de317dd8f3006531ee68992f8ea78c7248188c2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 17:24:45 +0100 Subject: [PATCH 1116/1566] Update compiler_builtins --- build_sysroot/Cargo.toml | 2 +- src/driver.rs | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 2935a8bd3d334..f28a46245e8cf 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -5,7 +5,7 @@ version = "0.0.0" [dependencies] core = { path = "./sysroot_src/src/libcore" } -compiler_builtins = "=0.1.20" # FIXME use "0.1" once libstd has updated for the latest version +compiler_builtins = "0.1" alloc = { path = "./sysroot_src/src/liballoc" } std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind", "backtrace"] } test = { path = "./sysroot_src/src/libtest" } diff --git a/src/driver.rs b/src/driver.rs index 9eb9df0eb54fa..cf3ad422171df 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -364,9 +364,21 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); } - MonoItem::GlobalAsm(node_id) => tcx - .sess - .fatal(&format!("Unimplemented global asm mono item {:?}", node_id)), + MonoItem::GlobalAsm(hir_id) => { + let item = tcx.hir().expect_item(hir_id); + if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind { + // FIXME implement global asm using an external assembler + if asm.as_str().contains("__rust_probestack") { + return; + } else { + tcx + .sess + .fatal(&format!("Unimplemented global asm mono item \"{}\"", asm)); + } + } else { + bug!("Expected GlobalAsm found {:?}", item); + } + } } } From 92d435613050a13a898bd6b611443efe4c01cc5a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 17:54:49 +0100 Subject: [PATCH 1117/1566] Add #[cfg(debug_assertions)] to write_clif_file This silences a warning in release mode --- src/pretty_clif.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 5f3ebfc4bef9e..06be1636f8026 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -201,6 +201,7 @@ impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } } +#[cfg(debug_assertions)] pub fn write_clif_file<'tcx>( tcx: TyCtxt<'tcx>, postfix: &str, From d821f154c5c6f46f5e461a28a7fd1ea7a2351620 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jan 2020 17:55:48 +0100 Subject: [PATCH 1118/1566] Disable the code_layout optimization When compiling libcore, it causes ebb params to be dropped for a certain function --- src/optimize/code_layout.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/optimize/code_layout.rs b/src/optimize/code_layout.rs index 4d2301c6f6c56..9ceca814150c4 100644 --- a/src/optimize/code_layout.rs +++ b/src/optimize/code_layout.rs @@ -11,6 +11,8 @@ use crate::prelude::*; pub(super) fn optimize_function(ctx: &mut Context, cold_ebbs: &EntitySet) { + return; // FIXME add ebb arguments back + // FIXME Move the ebb in place instead of remove and append once // bytecodealliance/cranelift#1339 is implemented. From 09c97475fb123ed191e3dc14629f84cfed19d555 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2020 05:09:35 +0000 Subject: [PATCH 1119/1566] Bump cranelift-codegen from `93e3bc1` to `9a578c1` Bumps [cranelift-codegen](https://github.com/bytecodealliance/cranelift) from `93e3bc1` to `9a578c1`. - [Release notes](https://github.com/bytecodealliance/cranelift/releases) - [Commits](https://github.com/bytecodealliance/cranelift/compare/93e3bc19985d0be2d0bfb7bcf990139c4a95358d...9a578c10924ce485a7b7e22dd5577ebc96538bb0) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 62 ++++++++++-------------------------------------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df76a941bc840..f98e02e1a1587 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,14 +5,6 @@ name = "ar" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "arrayvec" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "autocfg" version = "1.0.0" @@ -41,7 +33,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -49,14 +41,14 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-meta 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", + "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -66,7 +58,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -75,17 +67,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" [[package]] name = "cranelift-entity" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" [[package]] name = "cranelift-frontend" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -96,7 +88,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -107,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -117,7 +109,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -128,7 +120,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#93e3bc19985d0be2d0bfb7bcf990139c4a95358d" +source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -167,28 +159,11 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "gimli" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "gimli" version = "0.20.0" @@ -246,11 +221,6 @@ dependencies = [ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "object" version = "0.17.0" @@ -368,11 +338,6 @@ name = "smallvec" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "stable_deref_trait" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "syn" version = "1.0.14" @@ -437,7 +402,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" -"checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -456,9 +420,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" "checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" "checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" @@ -466,7 +428,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" "checksum object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" "checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" "checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" @@ -479,7 +440,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" -"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" From 9cdea312cf8373900ecb8d2f59b5e7348eab6ed8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 29 Jan 2020 11:21:29 +0100 Subject: [PATCH 1120/1566] Rustup to rustc 1.42.0-nightly (3761dcd34 2020-01-28) --- patches/0022-core-Disable-not-compiling-tests.patch | 4 ++-- rust-toolchain | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch index e001ba766fcdb..cd450a9af95cb 100644 --- a/patches/0022-core-Disable-not-compiling-tests.patch +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -44,7 +44,7 @@ index 0475aeb..9558198 100644 --- a/src/libcore/tests/num/int_macros.rs +++ b/src/libcore/tests/num/int_macros.rs @@ -88,6 +88,7 @@ mod tests { - assert_eq!(C.count_zeros(), bits as u32 - 5); + assert_eq!(x.trailing_ones(), 0); } + /* @@ -64,7 +64,7 @@ index 04ed14f..a6e372e 100644 --- a/src/libcore/tests/num/uint_macros.rs +++ b/src/libcore/tests/num/uint_macros.rs @@ -52,6 +52,7 @@ mod tests { - assert!(C.count_zeros() == bits as u32 - 5); + assert_eq!(x.trailing_ones(), 0); } + /* diff --git a/rust-toolchain b/rust-toolchain index f8a3455b49b24..96b2165067550 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-01-25 +nightly-2020-01-29 From 7ec6bb21b6000b26b226759fbcb92fecd0c767b4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 29 Jan 2020 11:31:17 +0100 Subject: [PATCH 1121/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f98e02e1a1587..c31f768ac5ab8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -58,7 +58,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -67,17 +67,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" [[package]] name = "cranelift-entity" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" [[package]] name = "cranelift-frontend" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#9a578c10924ce485a7b7e22dd5577ebc96538bb0" +source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", From f12c0d8ac75497b44c70220232668980a4b8c149 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 29 Jan 2020 11:32:59 +0100 Subject: [PATCH 1122/1566] Update thiserror --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c31f768ac5ab8..ed348f19f0d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,7 +52,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -93,7 +93,7 @@ dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -355,15 +355,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "thiserror" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror-impl" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -442,8 +442,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" "checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" -"checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" -"checksum thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" +"checksum thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "205684fd018ca14432b12cce6ea3d46763311a571c3d294e71ba3f01adcf1aad" +"checksum thiserror-impl 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "57e4d2e50ca050ed44fb58309bdce3efa79948f84f9993ad1978de5eebdce5a7" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" From 8150f737c046f0bcc8501ad26f192b8c376580cb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 1 Feb 2020 12:35:03 +0100 Subject: [PATCH 1123/1566] Rustup to rustc 1.42.0-nightly (cd1ef390e 2020-01-31) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 96b2165067550..e2f2cd69e6333 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-01-29 +nightly-2020-02-01 From 52d183ead624d43c293d12708a9eb3574e8cd17f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 1 Feb 2020 12:35:45 +0100 Subject: [PATCH 1124/1566] Update smallvec to 1.2.0 --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ed348f19f0d12..9a940e3d04300 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,7 +50,7 @@ dependencies = [ "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -81,7 +81,7 @@ source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f dependencies = [ "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -335,7 +335,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "smallvec" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -439,7 +439,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" +"checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" "checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "205684fd018ca14432b12cce6ea3d46763311a571c3d294e71ba3f01adcf1aad" From 33e73091f8d4299e7f281a7d5da5184bf055c895 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 1 Feb 2020 16:47:35 +0100 Subject: [PATCH 1125/1566] Don't mark unwind ebbs as cold This fixes the code_layout optimization, as it would previously try to move non-existing ebbs. Fixes #877 --- src/base.rs | 18 ++++++++---------- src/optimize/code_layout.rs | 2 -- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/base.rs b/src/base.rs index 6af9ddd8894dc..5860e3121b47a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -32,12 +32,6 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Predefine ebb's let start_ebb = bcx.create_ebb(); let ebb_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_ebb()).collect(); - let mut cold_ebbs = EntitySet::new(); - for (bb, &ebb) in ebb_map.iter_enumerated() { - if mir.basic_blocks()[bb].is_cleanup { - cold_ebbs.insert(ebb); - } - } // Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); @@ -55,7 +49,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( ebb_map, local_map: HashMap::new(), caller_location: None, // set by `codegen_fn_prelude` - cold_ebbs, + cold_ebbs: EntitySet::new(), clif_comments, constants_cx: &mut cx.constants_cx, @@ -148,13 +142,17 @@ pub fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { + let ebb = fx.get_ebb(bb); + fx.bcx.switch_to_block(ebb); + if bb_data.is_cleanup { // Unwinding after panicking is not supported continue; - } - let ebb = fx.get_ebb(bb); - fx.bcx.switch_to_block(ebb); + // FIXME once unwinding is supported uncomment next lines + // // Unwinding is unlikely to happen, so mark cleanup ebb's as cold. + // fx.cold_ebbs.insert(ebb); + } fx.bcx.ins().nop(); for stmt in &bb_data.statements { diff --git a/src/optimize/code_layout.rs b/src/optimize/code_layout.rs index 9ceca814150c4..4d2301c6f6c56 100644 --- a/src/optimize/code_layout.rs +++ b/src/optimize/code_layout.rs @@ -11,8 +11,6 @@ use crate::prelude::*; pub(super) fn optimize_function(ctx: &mut Context, cold_ebbs: &EntitySet) { - return; // FIXME add ebb arguments back - // FIXME Move the ebb in place instead of remove and append once // bytecodealliance/cranelift#1339 is implemented. From eb4fc45310c70513d73d893616cd6735465680ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 3 Feb 2020 21:05:18 +0100 Subject: [PATCH 1126/1566] Use CachingSourceMapView::byte_pos_to_line_and_col instead of SourceMap::lookup_char_pos The former calculates byte offsets instead of char offsets. It is faster to calculate byte offsets than char offsets. Also most DWARF producers and consumers use byte offsets instead of char offsets. --- src/debuginfo/line_info.rs | 23 ++++++++++++----------- src/debuginfo/mod.rs | 6 ++++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 3152e4812f758..66a12091ecda9 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -3,7 +3,7 @@ use std::path::{Component, Path}; use crate::prelude::*; -use rustc_span::FileName; +use rustc_span::{CachingSourceMapView, FileName}; use cranelift_codegen::binemit::CodeOffset; @@ -74,12 +74,12 @@ fn line_program_add_file( impl<'tcx> DebugContext<'tcx> { pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { - let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo()); + let (file, line, col) = self.source_map.byte_pos_to_line_and_col(span.lo()).unwrap(); let file_id = line_program_add_file( &mut self.dwarf.unit.line_program, &mut self.dwarf.line_strings, - &loc.file.name, + &file.name, ); let entry = self.dwarf.unit.get_mut(entry_id); @@ -90,12 +90,12 @@ impl<'tcx> DebugContext<'tcx> { ); entry.set( gimli::DW_AT_decl_line, - AttributeValue::Udata(loc.line as u64), + AttributeValue::Udata(line as u64), ); // FIXME: probably omit this entry.set( gimli::DW_AT_decl_column, - AttributeValue::Udata(loc.col.to_usize() as u64), + AttributeValue::Udata(col.to_usize() as u64), ); } } @@ -108,6 +108,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, ) -> CodeOffset { let tcx = self.debug_context.tcx; + let mut source_map = CachingSourceMapView::new(tcx.sess.source_map()); let line_program = &mut self.debug_context.dwarf.unit.line_program; @@ -124,25 +125,25 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let line_strings = &mut self.debug_context.dwarf.line_strings; let mut last_file = None; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { - let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + let (file, line, col) = source_map.byte_pos_to_line_and_col(span.lo()).unwrap(); // line_program_add_file is very slow. // Optimize for the common case of the current file not being changed. let current_file_changed = if let Some(last_file) = &mut last_file { // If the allocations are not equal, then the files may still be equal, but that // is not a problem, as this is just an optimization. - !Lrc::ptr_eq(last_file, &loc.file) + !Lrc::ptr_eq(last_file, &file) } else { true }; if current_file_changed { - let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); + let file_id = line_program_add_file(line_program, line_strings, &file.name); line_program.row().file = file_id; - last_file = Some(loc.file.clone()); + last_file = Some(file.clone()); } - line_program.row().line = loc.line as u64; - line_program.row().column = loc.col.to_u32() as u64 + 1; + line_program.row().line = line as u64; + line_program.row().column = col.to_u32() as u64 + 1; line_program.generate_row(); }; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index d4be26885a042..f007cb1265dea 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -3,6 +3,8 @@ mod line_info; use crate::prelude::*; +use rustc_span::CachingSourceMapView; + use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift_codegen::isa::RegUnit; use cranelift_codegen::ValueLocRange; @@ -34,6 +36,8 @@ pub struct DebugContext<'tcx> { unit_range_list: RangeList, types: HashMap, UnitEntryId>, + + source_map: CachingSourceMapView<'tcx>, } impl<'tcx> DebugContext<'tcx> { @@ -98,6 +102,8 @@ impl<'tcx> DebugContext<'tcx> { unit_range_list: RangeList(Vec::new()), types: HashMap::new(), + + source_map: CachingSourceMapView::new(tcx.sess.source_map()), } } From fbe36ad68a226f389bf64f67ea60449b8d41efbf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 3 Feb 2020 21:36:36 +0100 Subject: [PATCH 1127/1566] Revert "Use CachingSourceMapView::byte_pos_to_line_and_col instead of SourceMap::lookup_char_pos" This reverts commit eb4fc45310c70513d73d893616cd6735465680ca. It caused a panic while compiling simple-raytracer --- src/debuginfo/line_info.rs | 23 +++++++++++------------ src/debuginfo/mod.rs | 6 ------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 66a12091ecda9..3152e4812f758 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -3,7 +3,7 @@ use std::path::{Component, Path}; use crate::prelude::*; -use rustc_span::{CachingSourceMapView, FileName}; +use rustc_span::FileName; use cranelift_codegen::binemit::CodeOffset; @@ -74,12 +74,12 @@ fn line_program_add_file( impl<'tcx> DebugContext<'tcx> { pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { - let (file, line, col) = self.source_map.byte_pos_to_line_and_col(span.lo()).unwrap(); + let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file( &mut self.dwarf.unit.line_program, &mut self.dwarf.line_strings, - &file.name, + &loc.file.name, ); let entry = self.dwarf.unit.get_mut(entry_id); @@ -90,12 +90,12 @@ impl<'tcx> DebugContext<'tcx> { ); entry.set( gimli::DW_AT_decl_line, - AttributeValue::Udata(line as u64), + AttributeValue::Udata(loc.line as u64), ); // FIXME: probably omit this entry.set( gimli::DW_AT_decl_column, - AttributeValue::Udata(col.to_usize() as u64), + AttributeValue::Udata(loc.col.to_usize() as u64), ); } } @@ -108,7 +108,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, ) -> CodeOffset { let tcx = self.debug_context.tcx; - let mut source_map = CachingSourceMapView::new(tcx.sess.source_map()); let line_program = &mut self.debug_context.dwarf.unit.line_program; @@ -125,25 +124,25 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let line_strings = &mut self.debug_context.dwarf.line_strings; let mut last_file = None; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { - let (file, line, col) = source_map.byte_pos_to_line_and_col(span.lo()).unwrap(); + let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); // line_program_add_file is very slow. // Optimize for the common case of the current file not being changed. let current_file_changed = if let Some(last_file) = &mut last_file { // If the allocations are not equal, then the files may still be equal, but that // is not a problem, as this is just an optimization. - !Lrc::ptr_eq(last_file, &file) + !Lrc::ptr_eq(last_file, &loc.file) } else { true }; if current_file_changed { - let file_id = line_program_add_file(line_program, line_strings, &file.name); + let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); line_program.row().file = file_id; - last_file = Some(file.clone()); + last_file = Some(loc.file.clone()); } - line_program.row().line = line as u64; - line_program.row().column = col.to_u32() as u64 + 1; + line_program.row().line = loc.line as u64; + line_program.row().column = loc.col.to_u32() as u64 + 1; line_program.generate_row(); }; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index f007cb1265dea..d4be26885a042 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -3,8 +3,6 @@ mod line_info; use crate::prelude::*; -use rustc_span::CachingSourceMapView; - use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift_codegen::isa::RegUnit; use cranelift_codegen::ValueLocRange; @@ -36,8 +34,6 @@ pub struct DebugContext<'tcx> { unit_range_list: RangeList, types: HashMap, UnitEntryId>, - - source_map: CachingSourceMapView<'tcx>, } impl<'tcx> DebugContext<'tcx> { @@ -102,8 +98,6 @@ impl<'tcx> DebugContext<'tcx> { unit_range_list: RangeList(Vec::new()), types: HashMap::new(), - - source_map: CachingSourceMapView::new(tcx.sess.source_map()), } } From 01f6f40ac24c32d61d2746d0f031279cf86ddd2f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 7 Feb 2020 13:49:48 +0100 Subject: [PATCH 1128/1566] Rustup to rustc 1.43.0-nightly (442ae7f04 2020-02-06) --- build_sysroot/alloc_system/lib.rs | 4 ++-- rust-toolchain | 2 +- src/common.rs | 1 + src/lib.rs | 14 +++++++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index a942fa8d95e49..c9815853de1a3 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -41,7 +41,7 @@ const MIN_ALIGN: usize = 8; target_arch = "sparc64")))] #[allow(dead_code)] const MIN_ALIGN: usize = 16; -use core::alloc::{Alloc, GlobalAlloc, AllocErr, Layout}; +use core::alloc::{AllocRef, GlobalAlloc, AllocErr, Layout}; use core::ptr::NonNull; /// The default memory allocator provided by the operating system. /// @@ -70,7 +70,7 @@ use core::ptr::NonNull; #[stable(feature = "alloc_system_type", since = "1.28.0")] pub struct System; #[unstable(feature = "allocator_api", issue = "32838")] -unsafe impl Alloc for System { +unsafe impl AllocRef for System { #[inline] unsafe fn alloc(&mut self, layout: Layout) -> Result, AllocErr> { NonNull::new(GlobalAlloc::alloc(self, layout)).ok_or(AllocErr) diff --git a/rust-toolchain b/rust-toolchain index e2f2cd69e6333..2580eba6f2668 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-02-01 +nightly-2020-02-07 diff --git a/src/common.rs b/src/common.rs index dcf47f6657a50..07a1c91d38532 100644 --- a/src/common.rs +++ b/src/common.rs @@ -329,6 +329,7 @@ impl<'tcx, B: Backend> BackendTypes for FunctionCx<'_, 'tcx, B> { type Type = Type; type Funclet = !; type DIScope = !; + type DIVariable = !; } impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { diff --git a/src/lib.rs b/src/lib.rs index 94c47d0d39578..ad2ad82f0f20c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -213,11 +213,19 @@ impl CodegenBackend for CraneliftCodegenBackend { res } - fn join_codegen_and_link( + fn join_codegen( &self, - res: Box, - sess: &Session, + ongoing_codegen: Box, + _sess: &Session, _dep_graph: &DepGraph, + ) -> Result, ErrorReported> { + Ok(ongoing_codegen) + } + + fn link( + &self, + sess: &Session, + res: Box, outputs: &OutputFilenames, ) -> Result<(), ErrorReported> { use rustc_codegen_ssa::back::link::link_binary; From 5204a9839888c025d22656f7e9465c3eff2f7acd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 7 Feb 2020 13:55:02 +0100 Subject: [PATCH 1129/1566] Remove the sudo key from .travis.yml It has been deprecated and doesn't have any effect anymore --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e73e9933976f6..a56566d89b5c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -sudo: false language: rust cache: directories: From bae0d9bb726b3524aee8ca4df1329b1233794a42 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 7 Feb 2020 20:27:37 +0100 Subject: [PATCH 1130/1566] [OPT] Don't call monomorphize from clif_type --- src/analyze.rs | 2 +- src/common.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analyze.rs b/src/analyze.rs index c5541b1525732..965e363d2ba14 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -11,7 +11,7 @@ pub enum SsaKind { pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { let mut flag_map = fx.mir.local_decls.iter().map(|local_decl| { - if fx.clif_type(local_decl.ty).is_some() { + if fx.clif_type(fx.monomorphize(&local_decl.ty)).is_some() { SsaKind::Ssa } else { SsaKind::NotSsa diff --git a/src/common.rs b/src/common.rs index 07a1c91d38532..a1d0203828e10 100644 --- a/src/common.rs +++ b/src/common.rs @@ -345,7 +345,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub fn clif_type(&self, ty: Ty<'tcx>) -> Option { - clif_type_from_ty(self.tcx, self.monomorphize(&ty)) + clif_type_from_ty(self.tcx, ty) } pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { From e95a300630ce9f44b363ecc18e78a6f5df410b79 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 7 Feb 2020 21:38:30 +0100 Subject: [PATCH 1131/1566] Use TrapCode::UnreachableCodeReached in trap_unreachable --- src/trap.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trap.rs b/src/trap.rs index 316a26781dab4..f5e9d8c47e2bd 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -65,7 +65,7 @@ pub fn trap_unreachable( msg: impl AsRef, ) { codegen_print(fx, msg.as_ref()); - fx.bcx.ins().trap(TrapCode::User(!0)); + fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); } /// Use this when something is unimplemented, but `libcore` or `libstd` requires it to codegen. From b5b2ffab6ae4026f8d9a8b552e075fdc81002ec7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Feb 2020 18:20:34 +0100 Subject: [PATCH 1132/1566] Rustup to rustc 1.43.0-nightly (5d04ce67f 2020-02-13) --- patches/0017-Fix-libtest-compilation.patch | 4 ++-- rust-toolchain | 2 +- src/base.rs | 2 +- src/constant.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index 5299fb2b46505..12dac18f3fa33 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -17,9 +17,9 @@ index 8b76080..9e65de2 100644 io::prelude::Write, - panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}, + panic::{self, PanicInfo}, - process, - process::{Command, Termination}, + process::{self, Command, Termination}, sync::mpsc::{channel, Sender}, + sync::{Arc, Mutex}, @@ -1493,7 +1493,7 @@ pub fn run_test( fn run_test_inner( desc: TestDesc, diff --git a/rust-toolchain b/rust-toolchain index 2580eba6f2668..b17bee1216ceb 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-02-07 +nightly-2020-02-14 diff --git a/src/base.rs b/src/base.rs index 5860e3121b47a..a0add9b202f19 100644 --- a/src/base.rs +++ b/src/base.rs @@ -190,7 +190,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, } => { if !fx.tcx.sess.overflow_checks() { - if let mir::interpret::PanicInfo::OverflowNeg = *msg { + if let mir::AssertKind::OverflowNeg = *msg { let target = fx.get_ebb(*target); fx.bcx.ins().jump(target, &[]); continue; diff --git a/src/constant.rs b/src/constant.rs index b6b43526c7248..c0e2770361c7a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -7,7 +7,7 @@ use rustc::mir::interpret::{ }; use rustc::ty::{layout::Align, Const, ConstKind}; use rustc_mir::interpret::{ - ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PanicInfo, PlaceTy, Pointer, + ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, StackPopInfo, }; @@ -525,7 +525,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn assert_panic( _: &mut InterpCx<'mir, 'tcx, Self>, _: Span, - _: &PanicInfo>, + _: &mir::AssertKind>, _: Option, ) -> InterpResult<'tcx> { unreachable!() From 430f738392dae75954bfa0059025dd18dadeff7d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Feb 2020 18:23:29 +0100 Subject: [PATCH 1133/1566] Update Cranelift for basic blocks --- Cargo.lock | 102 ++++++++++++++++++------------------ src/abi/mod.rs | 24 ++++----- src/abi/pass_mode.rs | 14 ++--- src/abi/returning.rs | 4 +- src/allocator.rs | 6 +-- src/base.rs | 60 ++++++++++----------- src/common.rs | 10 ++-- src/debuginfo/line_info.rs | 8 +-- src/intrinsics/llvm.rs | 4 +- src/intrinsics/mod.rs | 12 ++--- src/lib.rs | 2 +- src/main_shim.rs | 8 +-- src/optimize/code_layout.rs | 22 ++++---- src/optimize/mod.rs | 4 +- src/optimize/stack2reg.rs | 6 +-- src/pretty_clif.rs | 16 +++--- src/value_and_place.rs | 6 +-- 17 files changed, 154 insertions(+), 154 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a940e3d04300..efe7f3792d34e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,22 +32,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-meta 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-meta 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -57,29 +57,29 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", ] [[package]] name = "cranelift-codegen-shared" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" [[package]] name = "cranelift-entity" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" [[package]] name = "cranelift-frontend" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -87,44 +87,44 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-object" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.56.0" -source = "git+https://github.com/bytecodealliance/cranelift/#c73c3e8441efcb6324f18a22679e43e4bbd174cc" +version = "0.58.0" +source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-native 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -282,11 +282,11 @@ version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-frontend 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-object 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-simplejit 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -407,16 +407,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift-bforest 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.56.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-meta 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-frontend 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-native 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-object 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" +"checksum cranelift-simplejit 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 6d254abb2bf94..568165bc61d85 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -288,13 +288,13 @@ fn local_place<'tcx>( fx.local_map[&local] } -pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: Ebb) { +pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block: Block) { let ssa_analyzed = crate::analyze::analyze(fx); #[cfg(debug_assertions)] self::comments::add_args_header_comment(fx); - self::returning::codegen_return_param(fx, &ssa_analyzed, start_ebb); + self::returning::codegen_return_param(fx, &ssa_analyzed, start_block); // None means pass_mode == NoPass enum ArgKind<'tcx> { @@ -322,13 +322,13 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: let mut params = Vec::new(); for (i, arg_ty) in tupled_arg_tys.types().enumerate() { - let param = cvalue_for_param(fx, start_ebb, Some(local), Some(i), arg_ty); + let param = cvalue_for_param(fx, start_block, Some(local), Some(i), arg_ty); params.push(param); } (local, ArgKind::Spread(params), arg_ty) } else { - let param = cvalue_for_param(fx, start_ebb, Some(local), None, arg_ty); + let param = cvalue_for_param(fx, start_block, Some(local), None, arg_ty); (local, ArgKind::Normal(param), arg_ty) } }) @@ -337,10 +337,10 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: assert!(fx.caller_location.is_none()); if fx.instance.def.requires_caller_location(fx.tcx) { // Store caller location for `#[track_caller]`. - fx.caller_location = Some(cvalue_for_param(fx, start_ebb, None, None, fx.tcx.caller_location_ty()).unwrap()); + fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.tcx.caller_location_ty()).unwrap()); } - fx.bcx.switch_to_block(start_ebb); + fx.bcx.switch_to_block(start_block); fx.bcx.ins().nop(); #[cfg(debug_assertions)] @@ -416,7 +416,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_ebb: fx.bcx .ins() - .jump(*fx.ebb_map.get(START_BLOCK).unwrap(), &[]); + .jump(*fx.block_map.get(START_BLOCK).unwrap(), &[]); } pub fn codegen_terminator_call<'tcx>( @@ -458,8 +458,8 @@ pub fn codegen_terminator_call<'tcx>( InstanceDef::DropGlue(_, None) => { // empty drop glue - a nop. let (_, dest) = destination.expect("Non terminating drop_in_place_real???"); - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); + let ret_block = fx.get_block(dest); + fx.bcx.ins().jump(ret_block, &[]); return; } _ => {} @@ -498,8 +498,8 @@ pub fn codegen_terminator_call<'tcx>( ); if let Some((_, dest)) = destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); + let ret_block = fx.get_block(dest); + fx.bcx.ins().jump(ret_block, &[]); } else { trap_unreachable(fx, "[corruption] Diverging function returned"); } @@ -513,7 +513,7 @@ fn codegen_call_inner<'tcx>( args: Vec>, ret_place: Option>, ) { - // FIXME mark the current ebb as cold when calling a `#[cold]` function. + // FIXME mark the current block as cold when calling a `#[cold]` function. let fn_sig = fx .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index bbb231ed8b747..3c19787ef9252 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -129,7 +129,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( pub(super) fn cvalue_for_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - start_ebb: Ebb, + start_block: Block, local: Option, local_field: Option, arg_ty: Ty<'tcx>, @@ -142,7 +142,7 @@ pub(super) fn cvalue_for_param<'tcx>( } let clif_types = pass_mode.get_param_ty(fx.tcx); - let ebb_params = clif_types.map(|t| fx.bcx.append_ebb_param(start_ebb, t)); + let block_params = clif_types.map(|t| fx.bcx.append_block_param(start_block, t)); #[cfg(debug_assertions)] crate::abi::comments::add_arg_comment( @@ -150,21 +150,21 @@ pub(super) fn cvalue_for_param<'tcx>( "arg", local, local_field, - ebb_params, + block_params, pass_mode, arg_ty, ); match pass_mode { PassMode::NoPass => unreachable!(), - PassMode::ByVal(_) => Some(CValue::by_val(ebb_params.assert_single(), layout)), + PassMode::ByVal(_) => Some(CValue::by_val(block_params.assert_single(), layout)), PassMode::ByValPair(_, _) => { - let (a, b) = ebb_params.assert_pair(); + let (a, b) = block_params.assert_pair(); Some(CValue::by_val_pair(a, b, layout)) } - PassMode::ByRef { sized: true } => Some(CValue::by_ref(Pointer::new(ebb_params.assert_single()), layout)), + PassMode::ByRef { sized: true } => Some(CValue::by_ref(Pointer::new(block_params.assert_single()), layout)), PassMode::ByRef { sized: false } => { - let (ptr, meta) = ebb_params.assert_pair(); + let (ptr, meta) = block_params.assert_pair(); Some(CValue::by_ref_unsized(Pointer::new(ptr), meta, layout)) } } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index d76711173f111..b4dd04002cf8f 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -16,7 +16,7 @@ pub fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyLayout<'tcx pub(super) fn codegen_return_param( fx: &mut FunctionCx, ssa_analyzed: &rustc_index::vec::IndexVec, - start_ebb: Ebb, + start_block: Block, ) { let ret_layout = return_layout(fx); let ret_pass_mode = get_pass_mode(fx.tcx, ret_layout); @@ -34,7 +34,7 @@ pub(super) fn codegen_return_param( Empty } PassMode::ByRef { sized: true } => { - let ret_param = fx.bcx.append_ebb_param(start_ebb, fx.pointer_type); + let ret_param = fx.bcx.append_block_param(start_block, fx.pointer_type); fx.local_map .insert(RETURN_PLACE, CPlace::for_ptr(Pointer::new(ret_param), ret_layout)); diff --git a/src/allocator.rs b/src/allocator.rs index df9e6aa196280..8405096f32b42 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -78,11 +78,11 @@ fn codegen_inner(module: &mut Module, kind: AllocatorKin let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); - let ebb = bcx.create_ebb(); - bcx.switch_to_block(ebb); + let block = bcx.create_block(); + bcx.switch_to_block(block); let args = arg_tys .into_iter() - .map(|ty| bcx.append_ebb_param(ebb, ty)) + .map(|ty| bcx.append_block_param(block, ty)) .collect::>(); let callee_func_ref = module.declare_func_in_func(callee_func_id, &mut bcx.func); diff --git a/src/base.rs b/src/base.rs index a0add9b202f19..644a66bb31a99 100644 --- a/src/base.rs +++ b/src/base.rs @@ -29,9 +29,9 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut context.func, &mut func_ctx); - // Predefine ebb's - let start_ebb = bcx.create_ebb(); - let ebb_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_ebb()).collect(); + // Predefine block's + let start_block = bcx.create_block(); + let block_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_block()).collect(); // Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); @@ -46,10 +46,10 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( mir, bcx, - ebb_map, + block_map, local_map: HashMap::new(), caller_location: None, // set by `codegen_fn_prelude` - cold_ebbs: EntitySet::new(), + cold_blocks: EntitySet::new(), clif_comments, constants_cx: &mut cx.constants_cx, @@ -58,13 +58,13 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( }; if fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()) { - let entry_block = fx.bcx.create_ebb(); - fx.bcx.append_ebb_params_for_function_params(entry_block); + let entry_block = fx.bcx.create_block(); + fx.bcx.append_block_params_for_function_params(entry_block); fx.bcx.switch_to_block(entry_block); crate::trap::trap_unreachable(&mut fx, "function has uninhabited argument"); } else { tcx.sess.time("codegen clif ir", || { - tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_ebb)); + tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block)); codegen_fn_content(&mut fx); }); } @@ -74,7 +74,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut clif_comments = fx.clif_comments; let source_info_set = fx.source_info_set; let local_map = fx.local_map; - let cold_ebbs = fx.cold_ebbs; + let cold_blocks = fx.cold_blocks; #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &context.func, &clif_comments, None); @@ -84,7 +84,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Perform rust specific optimizations tcx.sess.time("optimize clif ir", || { - crate::optimize::optimize_function(tcx, instance, context, &cold_ebbs, &mut clif_comments); + crate::optimize::optimize_function(tcx, instance, context, &cold_blocks, &mut clif_comments); }); // Define function @@ -142,22 +142,22 @@ pub fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { - let ebb = fx.get_ebb(bb); - fx.bcx.switch_to_block(ebb); + let block = fx.get_block(bb); + fx.bcx.switch_to_block(block); if bb_data.is_cleanup { // Unwinding after panicking is not supported continue; // FIXME once unwinding is supported uncomment next lines - // // Unwinding is unlikely to happen, so mark cleanup ebb's as cold. - // fx.cold_ebbs.insert(ebb); + // // Unwinding is unlikely to happen, so mark cleanup block's as cold. + // fx.cold_blocks.insert(block); } fx.bcx.ins().nop(); for stmt in &bb_data.statements { fx.set_debug_loc(stmt.source_info); - trans_stmt(fx, ebb, stmt); + trans_stmt(fx, block, stmt); } #[cfg(debug_assertions)] @@ -168,7 +168,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { .kind .fmt_head(&mut terminator_head) .unwrap(); - let inst = fx.bcx.func.layout.last_inst(ebb).unwrap(); + let inst = fx.bcx.func.layout.last_inst(block).unwrap(); fx.add_comment(inst, terminator_head); } @@ -176,8 +176,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { match &bb_data.terminator().kind { TerminatorKind::Goto { target } => { - let ebb = fx.get_ebb(*target); - fx.bcx.ins().jump(ebb, &[]); + let block = fx.get_block(*target); + fx.bcx.ins().jump(block, &[]); } TerminatorKind::Return => { crate::abi::codegen_return(fx); @@ -191,16 +191,16 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } => { if !fx.tcx.sess.overflow_checks() { if let mir::AssertKind::OverflowNeg = *msg { - let target = fx.get_ebb(*target); + let target = fx.get_block(*target); fx.bcx.ins().jump(target, &[]); continue; } } let cond = trans_operand(fx, cond).load_scalar(fx); - let target = fx.get_ebb(*target); - let failure = fx.bcx.create_ebb(); - fx.cold_ebbs.insert(failure); + let target = fx.get_block(*target); + let failure = fx.bcx.create_block(); + fx.cold_blocks.insert(failure); if *expected { fx.bcx.ins().brz(cond, failure, &[]); @@ -229,11 +229,11 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { let discr = trans_operand(fx, discr).load_scalar(fx); let mut switch = ::cranelift_frontend::Switch::new(); for (i, value) in values.iter().enumerate() { - let ebb = fx.get_ebb(targets[i]); - switch.set_entry(*value as u64, ebb); + let block = fx.get_block(targets[i]); + switch.set_entry(*value as u64, block); } - let otherwise_ebb = fx.get_ebb(targets[targets.len() - 1]); - switch.emit(&mut fx.bcx, discr, otherwise_ebb); + let otherwise_block = fx.get_block(targets[targets.len() - 1]); + switch.emit(&mut fx.bcx, discr, otherwise_block); } TerminatorKind::Call { func, @@ -271,8 +271,8 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { let drop_place = trans_place(fx, location); crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); - let target_ebb = fx.get_ebb(*target); - fx.bcx.ins().jump(target_ebb, &[]); + let target_block = fx.get_block(*target); + fx.bcx.ins().jump(target_block, &[]); } }; } @@ -283,7 +283,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fn trans_stmt<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - cur_ebb: Ebb, + cur_block: Block, stmt: &Statement<'tcx>, ) { let _print_guard = PrintOnPanic(|| format!("stmt {:?}", stmt)); @@ -294,7 +294,7 @@ fn trans_stmt<'tcx>( match &stmt.kind { StatementKind::StorageLive(..) | StatementKind::StorageDead(..) => {} // Those are not very useful _ => { - let inst = fx.bcx.func.layout.last_inst(cur_ebb).unwrap(); + let inst = fx.bcx.func.layout.last_inst(cur_block).unwrap(); fx.add_comment(inst, format!("{:?}", stmt)); } } diff --git a/src/common.rs b/src/common.rs index a1d0203828e10..374ad0acee53e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -264,14 +264,14 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub mir: &'tcx Body<'tcx>, pub bcx: FunctionBuilder<'clif>, - pub ebb_map: IndexVec, + pub block_map: IndexVec, pub local_map: HashMap>, /// When `#[track_caller]` is used, the implicit caller location is stored in this variable. pub caller_location: Option>, /// See [crate::optimize::code_layout] for more information. - pub cold_ebbs: EntitySet, + pub cold_blocks: EntitySet, pub clif_comments: crate::pretty_clif::CommentWriter, pub constants_cx: &'clif mut crate::constant::ConstantCx, @@ -325,7 +325,7 @@ impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend> BackendTypes for FunctionCx<'_, 'tcx, B> { type Value = Value; type Function = Value; - type BasicBlock = Ebb; + type BasicBlock = Block; type Type = Type; type Funclet = !; type DIScope = !; @@ -348,8 +348,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { clif_type_from_ty(self.tcx, ty) } - pub fn get_ebb(&self, bb: BasicBlock) -> Ebb { - *self.ebb_map.get(bb).unwrap() + pub fn get_block(&self, bb: BasicBlock) -> Block { + *self.block_map.get(bb).unwrap() } pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 3152e4812f758..7a3ac0991c412 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -118,8 +118,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let encinfo = isa.encoding_info(); let func = &context.func; - let mut ebbs = func.layout.ebbs().collect::>(); - ebbs.sort_by_key(|ebb| func.offsets[*ebb]); // Ensure inst offsets always increase + let mut blocks = func.layout.blocks().collect::>(); + blocks.sort_by_key(|block| func.offsets[*block]); // Ensure inst offsets always increase let line_strings = &mut self.debug_context.dwarf.line_strings; let mut last_file = None; @@ -147,8 +147,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { }; let mut end = 0; - for ebb in ebbs { - for (offset, inst, size) in func.inst_offsets(ebb, &encinfo) { + for block in blocks { + for (offset, inst, size) in func.inst_offsets(block, &encinfo) { let srcloc = func.srclocs[inst]; line_program.row().address_offset = offset as u64; if !srcloc.is_default() { diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index 5b3deb52baade..b30f3b8f8dbd4 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -97,8 +97,8 @@ pub fn codegen_llvm_intrinsic_call<'tcx>( } if let Some((_, dest)) = destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); + let ret_block = fx.get_block(dest); + fx.bcx.ins().jump(ret_block, &[]); } else { trap_unreachable(fx, "[corruption] Diverging intrinsic returned."); } diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 7470b55366c2d..d23d28dccd2bf 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -87,8 +87,8 @@ macro call_intrinsic_match { $ret.write_cvalue($fx, res); if let Some((_, dest)) = $destination { - let ret_ebb = $fx.get_ebb(dest); - $fx.bcx.ins().jump(ret_ebb, &[]); + let ret_block = $fx.get_block(dest); + $fx.bcx.ins().jump(ret_block, &[]); return; } else { unreachable!(); @@ -369,8 +369,8 @@ pub fn codegen_intrinsic_call<'tcx>( if intrinsic.starts_with("simd_") { self::simd::codegen_simd_intrinsic_call(fx, instance, args, ret, span); - let ret_ebb = fx.get_ebb(destination.expect("SIMD intrinsics don't diverge").1); - fx.bcx.ins().jump(ret_ebb, &[]); + let ret_block = fx.get_block(destination.expect("SIMD intrinsics don't diverge").1); + fx.bcx.ins().jump(ret_block, &[]); return; } @@ -992,8 +992,8 @@ pub fn codegen_intrinsic_call<'tcx>( } if let Some((_, dest)) = destination { - let ret_ebb = fx.get_ebb(dest); - fx.bcx.ins().jump(ret_ebb, &[]); + let ret_block = fx.get_block(dest); + fx.bcx.ins().jump(ret_block, &[]); } else { trap_unreachable(fx, "[corruption] Diverging intrinsic returned."); } diff --git a/src/lib.rs b/src/lib.rs index ad2ad82f0f20c..21fca3c89f69a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,7 +98,7 @@ mod prelude { pub use cranelift_codegen::Context; pub use cranelift_codegen::entity::EntitySet; - pub use cranelift_codegen::ir::{AbiParam, Ebb, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; + pub use cranelift_codegen::ir::{AbiParam, Block, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; pub use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; pub use cranelift_codegen::ir::function::Function; pub use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; diff --git a/src/main_shim.rs b/src/main_shim.rs index b7c1425a1af5e..fc3f9734874e6 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -62,10 +62,10 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { - // FIXME Move the ebb in place instead of remove and append once +pub(super) fn optimize_function(ctx: &mut Context, cold_blocks: &EntitySet) { + // FIXME Move the block in place instead of remove and append once // bytecodealliance/cranelift#1339 is implemented. - let mut ebb_insts = HashMap::new(); - for ebb in cold_ebbs.keys().filter(|&ebb| cold_ebbs.contains(ebb)) { - let insts = ctx.func.layout.ebb_insts(ebb).collect::>(); + let mut block_insts = HashMap::new(); + for block in cold_blocks.keys().filter(|&block| cold_blocks.contains(block)) { + let insts = ctx.func.layout.block_insts(block).collect::>(); for &inst in &insts { ctx.func.layout.remove_inst(inst); } - ebb_insts.insert(ebb, insts); - ctx.func.layout.remove_ebb(ebb); + block_insts.insert(block, insts); + ctx.func.layout.remove_block(block); } // And then append them at the back again. - for ebb in cold_ebbs.keys().filter(|&ebb| cold_ebbs.contains(ebb)) { - ctx.func.layout.append_ebb(ebb); - for inst in ebb_insts.remove(&ebb).unwrap() { - ctx.func.layout.append_inst(inst, ebb); + for block in cold_blocks.keys().filter(|&block| cold_blocks.contains(block)) { + ctx.func.layout.append_block(block); + for inst in block_insts.remove(&block).unwrap() { + ctx.func.layout.append_inst(inst, block); } } } diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index ba9839e84be12..23c14a57c56ad 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -7,11 +7,11 @@ pub fn optimize_function<'tcx>( tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, ctx: &mut Context, - cold_ebbs: &EntitySet, + cold_blocks: &EntitySet, clif_comments: &mut crate::pretty_clif::CommentWriter, ) { // The code_layout optimization is very cheap. - self::code_layout::optimize_function(ctx, cold_ebbs); + self::code_layout::optimize_function(ctx, cold_blocks); if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No { return; // FIXME classify optimizations over opt levels diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 8fa5fb13c2eb4..acce3a6465b77 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -116,7 +116,7 @@ impl<'a> OptimizeContext<'a> { let mut stack_slot_usage_map = BTreeMap::::new(); let mut cursor = FuncCursor::new(&mut ctx.func); - while let Some(_ebb) = cursor.next_ebb() { + while let Some(_block) = cursor.next_block() { while let Some(inst) = cursor.next_inst() { match cursor.func.dfg[inst] { InstructionData::StackLoad { @@ -249,7 +249,7 @@ pub(super) fn optimize_function( fn combine_stack_addr_with_load_store(func: &mut Function) { // Turn load and store into stack_load and stack_store when possible. let mut cursor = FuncCursor::new(func); - while let Some(_ebb) = cursor.next_ebb() { + while let Some(_block) = cursor.next_block() { while let Some(inst) = cursor.next_inst() { match cursor.func.dfg[inst] { InstructionData::Load { opcode: Opcode::Load, arg: addr, flags: _, offset } => { @@ -284,7 +284,7 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext) { let mut stack_addr_load_insts_users = HashMap::>::new(); let mut cursor = FuncCursor::new(&mut opt_ctx.ctx.func); - while let Some(_ebb) = cursor.next_ebb() { + while let Some(_block) = cursor.next_block() { while let Some(inst) = cursor.next_inst() { for &arg in cursor.func.dfg.inst_args(inst) { if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 06be1636f8026..e619be41cb18d 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -38,14 +38,14 @@ use crate::prelude::*; /// sig1 = (i64, i64, i64) system_v /// fn0 = colocated u0:6 sig1 ; Instance { def: Item(DefId(0/0:31 ~ example[8787]::{{impl}}[1]::call_mut[0])), substs: [ReErased, ReErased] } /// -/// ebb0(v0: i64, v1: i64, v2: i64): +/// block0(v0: i64, v1: i64, v2: i64): /// v3 = stack_addr.i64 ss0 /// v4 = stack_addr.i64 ss1 /// store v2, v4 /// v5 = stack_addr.i64 ss2 -/// jump ebb1 +/// jump block1 /// -/// ebb1: +/// block1: /// nop /// ; _3 = &mut _1 /// ; _4 = _2 @@ -55,9 +55,9 @@ use crate::prelude::*; /// ; _0 = const mini_core::FnMut::call_mut(move _3, move _4) /// v7 = load.i64 v5 /// call fn0(v0, v3, v7) -/// jump ebb2 +/// jump block2 /// -/// ebb2: +/// block2: /// nop /// ; /// ; return @@ -136,15 +136,15 @@ impl FuncWriter for &'_ CommentWriter { } } - fn write_ebb_header( + fn write_block_header( &mut self, w: &mut dyn fmt::Write, func: &Function, isa: Option<&dyn isa::TargetIsa>, - ebb: Ebb, + block: Block, indent: usize, ) -> fmt::Result { - PlainWriter.write_ebb_header(w, func, isa, ebb, indent) + PlainWriter.write_block_header(w, func, isa, block, indent) } fn write_instruction( diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 882eb82f5aaa8..cc194e1c91eac 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -382,12 +382,12 @@ impl<'tcx> CPlace<'tcx> { #[cfg(debug_assertions)] { use cranelift_codegen::cursor::{Cursor, CursorPosition}; - let cur_ebb = match fx.bcx.cursor().position() { - CursorPosition::After(ebb) => ebb, + let cur_block = match fx.bcx.cursor().position() { + CursorPosition::After(block) => block, _ => unreachable!(), }; fx.add_comment( - fx.bcx.func.layout.last_inst(cur_ebb).unwrap(), + fx.bcx.func.layout.last_inst(cur_block).unwrap(), format!("write_cvalue: {:?} <- {:?}",self, from), ); } From 6b2545402850eb57a7cbf54736042ad016ccfd0b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Feb 2020 18:37:28 +0100 Subject: [PATCH 1134/1566] Update dependencies --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efe7f3792d34e..c9389c0d11197 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,7 +17,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.3.2" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -43,7 +43,7 @@ name = "cranelift-codegen" version = "0.58.0" source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-meta 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -169,8 +169,8 @@ name = "gimli" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -185,7 +185,7 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -228,7 +228,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -281,14 +281,14 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-frontend 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-object 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-simplejit 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -404,7 +404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" @@ -423,7 +423,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" "checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" -"checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" +"checksum indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" "checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" From a3f27a442838bf823b2071381cf6a26b566cfa3f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 14 Feb 2020 19:12:43 +0100 Subject: [PATCH 1135/1566] Use archive_format for determining if gnu style archives should be emitted Fixes #893 --- src/archive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/archive.rs b/src/archive.rs index 5363c97675c3b..803a1ef0dabee 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -41,7 +41,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { lib_search_paths: archive_search_paths(sess), use_native_ar: false, // FIXME test for linux and System V derivatives instead - use_gnu_style_archive: !sess.target.target.options.is_like_osx, + use_gnu_style_archive: sess.target.target.options.archive_format == "gnu", }; let (src_archives, entries) = if let Some(input) = input { From 6156f48ffe43da77d98c1127acd393109619f471 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Feb 2020 11:59:38 +0100 Subject: [PATCH 1136/1566] Update Cranelift and use the new ineg instruction --- Cargo.lock | 20 ++++++++++---------- src/base.rs | 6 +++++- src/unsize.rs | 3 +-- src/value_and_place.rs | 3 ++- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c9389c0d11197..31030e6148878 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -58,7 +58,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -67,17 +67,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" [[package]] name = "cranelift-entity" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" [[package]] name = "cranelift-frontend" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#280fd1e13b5cdad9d9d308b78bb94b0476f2d9f0" +source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", diff --git a/src/base.rs b/src/base.rs index 644a66bb31a99..1eab45bf3c6f5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -360,10 +360,14 @@ fn trans_stmt<'tcx>( } } UnOp::Neg => match layout.ty.kind { - ty::Int(_) => { + ty::Int(IntTy::I128) => { + // FIXME remove this case once ineg.i128 works let zero = CValue::const_val(fx, layout, 0); crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand) } + ty::Int(_) => { + CValue::by_val(fx.bcx.ins().ineg(val), layout) + } ty::Float(_) => { CValue::by_val(fx.bcx.ins().fneg(val), layout) } diff --git a/src/unsize.rs b/src/unsize.rs index ab2b2f201a212..9d2e73714fcaa 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -225,8 +225,7 @@ pub fn size_and_align_of_dst<'tcx>( // `(size + (align-1)) & -align` let addend = fx.bcx.ins().iadd_imm(align, -1); let add = fx.bcx.ins().iadd(size, addend); - let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); - let neg = fx.bcx.ins().isub(zero, align); + let neg = fx.bcx.ins().ineg(align); let size = fx.bcx.ins().band(add, neg); (size, align) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index cc194e1c91eac..c075fe4554499 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -509,13 +509,14 @@ impl<'tcx> CPlace<'tcx> { let size = dst_layout.size.bytes(); let src_align = src_layout.align.abi.bytes() as u8; let dst_align = dst_layout.align.abi.bytes() as u8; - fx.bcx.emit_small_memcpy( + fx.bcx.emit_small_memory_copy( fx.module.target_config(), to_addr, from_addr, size, dst_align, src_align, + true, ); } CValueInner::ByRef(_, Some(_)) => todo!(), From 487e4ff86e83c072eb4c9f26fe2abdf784f558f0 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2020 05:10:16 +0000 Subject: [PATCH 1137/1566] Bump cranelift-codegen from `f1aa072` to `cd3d84e` Bumps [cranelift-codegen](https://github.com/bytecodealliance/cranelift) from `f1aa072` to `cd3d84e`. - [Release notes](https://github.com/bytecodealliance/cranelift/releases) - [Commits](https://github.com/bytecodealliance/cranelift/compare/f1aa07265b3b25c1859f7184e92fd600316b4b25...cd3d84e580cc69876a93ea87ef12d45ee2942b2d) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31030e6148878..6025fe9ccde1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -58,7 +58,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -67,17 +67,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" [[package]] name = "cranelift-entity" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" [[package]] name = "cranelift-frontend" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#f1aa07265b3b25c1859f7184e92fd600316b4b25" +source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", From 2714068b9709e3e1d13a55f6c442afaecbc08d90 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2020 17:54:27 +0100 Subject: [PATCH 1138/1566] Bump thiserror from 1.0.10 to 1.0.11 (#894) Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.10 to 1.0.11. - [Release notes](https://github.com/dtolnay/thiserror/releases) - [Commits](https://github.com/dtolnay/thiserror/compare/1.0.10...1.0.11) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6025fe9ccde1e..78f201d93b760 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,7 +52,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -93,7 +93,7 @@ dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -355,15 +355,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "thiserror" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thiserror-impl 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror-impl" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -442,8 +442,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" "checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" -"checksum thiserror 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "205684fd018ca14432b12cce6ea3d46763311a571c3d294e71ba3f01adcf1aad" -"checksum thiserror-impl 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "57e4d2e50ca050ed44fb58309bdce3efa79948f84f9993ad1978de5eebdce5a7" +"checksum thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ee14bf8e6767ab4c687c9e8bc003879e042a96fd67a3ba5934eadb6536bef4db" +"checksum thiserror-impl 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "a7b51e1fbc44b5a0840be594fbc0f960be09050f2617e61e6aa43bef97cd3ef4" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" From c1bf153049cd7897b32ba0969f1e9fc5ccdd2b42 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Feb 2020 14:20:37 +0100 Subject: [PATCH 1139/1566] Rustup to rustc 1.43.0-nightly (8aa9d2014 2020-02-21) --- rust-toolchain | 2 +- src/base.rs | 3 ++- src/common.rs | 5 ++++- src/constant.rs | 47 +++++++------------------------------------ src/intrinsics/mod.rs | 5 ++++- 5 files changed, 18 insertions(+), 44 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index b17bee1216ceb..292e9dbf723bd 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-02-14 +nightly-2020-02-22 diff --git a/src/base.rs b/src/base.rs index 1eab45bf3c6f5..c741d02b8d752 100644 --- a/src/base.rs +++ b/src/base.rs @@ -632,7 +632,8 @@ fn codegen_array_len<'tcx>( ) -> Value { match place.layout().ty.kind { ty::Array(_elem_ty, len) => { - let len = crate::constant::force_eval_const(fx, len) + let len = fx.monomorphize(&len) + .eval(fx.tcx, ParamEnv::reveal_all()) .eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } diff --git a/src/common.rs b/src/common.rs index 374ad0acee53e..d9659f42d6fcd 100644 --- a/src/common.rs +++ b/src/common.rs @@ -374,7 +374,10 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { caller.line as u32, caller.col_display as u32 + 1, )); - crate::constant::trans_const_value(self, const_loc) + crate::constant::trans_const_value( + self, + ty::Const::from_value(self.tcx, const_loc, self.tcx.caller_location_ty()), + ) } pub fn triple(&self) -> &target_lexicon::Triple { diff --git a/src/constant.rs b/src/constant.rs index c0e2770361c7a..47e949021dfd1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -69,47 +69,12 @@ pub fn trans_constant<'tcx>( fx.layout_of(fx.monomorphize(&constant.literal.ty)), ).to_cvalue(fx); } - ConstKind::Unevaluated(def_id, ref substs, promoted) => { - let substs = fx.monomorphize(substs); - fx.tcx.const_eval_resolve( - ParamEnv::reveal_all(), - def_id, - substs, - promoted, - None, // FIXME use correct span - ).unwrap_or_else(|_| { - fx.tcx.sess.abort_if_errors(); - unreachable!(); - }) - } - _ => fx.monomorphize(&constant.literal), + _ => fx.monomorphize(&constant.literal).eval(fx.tcx, ParamEnv::reveal_all()), }; trans_const_value(fx, const_) } -pub fn force_eval_const<'tcx>( - fx: &FunctionCx<'_, 'tcx, impl Backend>, - const_: &'tcx Const, -) -> &'tcx Const<'tcx> { - match const_.val { - ConstKind::Unevaluated(def_id, ref substs, promoted) => { - let substs = fx.monomorphize(substs); - fx.tcx.const_eval_resolve( - ParamEnv::reveal_all(), - def_id, - substs, - promoted, - None, // FIXME pass correct span - ).unwrap_or_else(|_| { - fx.tcx.sess.abort_if_errors(); - unreachable!(); - }) - } - _ => fx.monomorphize(&const_), - } -} - pub fn trans_const_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, @@ -338,8 +303,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let const_ = tcx.const_eval_poly(def_id).unwrap(); - let alloc = match const_.val { - ConstKind::Value(ConstValue::ByRef { alloc, offset }) if offset.bytes() == 0 => alloc, + let alloc = match const_ { + ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc, _ => bug!("static const eval returned {:#?}", const_), }; @@ -537,7 +502,9 @@ pub fn mir_operand_get_const_val<'tcx>( operand: &Operand<'tcx>, ) -> Option<&'tcx Const<'tcx>> { match operand { - Operand::Copy(_) | Operand::Move(_) => return None, - Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)), + Operand::Copy(_) | Operand::Move(_) => None, + Operand::Constant(const_) => { + Some(fx.monomorphize(&const_.literal).eval(fx.tcx, ParamEnv::reveal_all())) + } } } diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index d23d28dccd2bf..c8f23555952b8 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -835,7 +835,10 @@ pub fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () { let const_val = fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); - let val = crate::constant::trans_const_value(fx, const_val); + let val = crate::constant::trans_const_value( + fx, + ty::Const::from_value(fx.tcx, const_val, ret.layout().ty), + ); ret.write_cvalue(fx, val); }; From ad7e8ad2cc58fed130beb3255524349426d2b13e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Feb 2020 14:25:22 +0100 Subject: [PATCH 1140/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- src/backend.rs | 3 +-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78f201d93b760..a6948fda0f76b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -58,7 +58,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -67,17 +67,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" [[package]] name = "cranelift-entity" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" [[package]] name = "cranelift-frontend" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#cd3d84e580cc69876a93ea87ef12d45ee2942b2d" +source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", diff --git a/src/backend.rs b/src/backend.rs index ae6888316f40b..2113fca86dd06 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -127,8 +127,7 @@ pub fn make_module(sess: &Session, name: String) -> Module { name + ".o", ObjectTrapCollection::Disabled, cranelift_module::default_libcall_names(), - ) - .unwrap(), + ), ); module } From 43e23af7002f7e43a4ebe2d891367cab36cf0706 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Feb 2020 14:29:34 +0100 Subject: [PATCH 1141/1566] Update dependencies --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6948fda0f76b..408427bb14a21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,7 +126,7 @@ dependencies = [ "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-native 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -146,7 +146,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -156,7 +156,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -193,7 +193,7 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.66" +version = "0.2.67" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -218,7 +218,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -271,7 +271,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -317,7 +317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -340,7 +340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -368,7 +368,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -424,7 +424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" "checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" "checksum indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" -"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" +"checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" @@ -440,7 +440,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" -"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5" +"checksum syn 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a0294dc449adc58bb6592fff1a23d3e5e6e235afc6a0ffca2657d19e7bbffe5" "checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" "checksum thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ee14bf8e6767ab4c687c9e8bc003879e042a96fd67a3ba5934eadb6536bef4db" "checksum thiserror-impl 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "a7b51e1fbc44b5a0840be594fbc0f960be09050f2617e61e6aa43bef97cd3ef4" From cc30c202938e79126c4e94fc6719fc018f834cfb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Feb 2020 15:17:30 +0100 Subject: [PATCH 1142/1566] Silence some warnings --- src/base.rs | 1 + src/debuginfo/mod.rs | 4 ++-- src/intrinsics/mod.rs | 1 + src/intrinsics/simd.rs | 4 ++-- src/optimize/stack2reg.rs | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/base.rs b/src/base.rs index c741d02b8d752..963354e421864 100644 --- a/src/base.rs +++ b/src/base.rs @@ -283,6 +283,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fn trans_stmt<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + #[allow(unused_variables)] cur_block: Block, stmt: &Statement<'tcx>, ) { diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index d4be26885a042..f9048ad401050 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -124,10 +124,10 @@ impl<'tcx> DebugContext<'tcx> { ty::Uint(_) => primitive(&mut self.dwarf, gimli::DW_ATE_unsigned), ty::Int(_) => primitive(&mut self.dwarf, gimli::DW_ATE_signed), ty::Float(_) => primitive(&mut self.dwarf, gimli::DW_ATE_float), - ty::Ref(_, pointee_ty, mutbl) + ty::Ref(_, pointee_ty, _mutbl) | ty::RawPtr(ty::TypeAndMut { ty: pointee_ty, - mutbl, + mutbl: _mutbl, }) => { let type_id = new_entry(&mut self.dwarf, gimli::DW_TAG_pointer_type); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index c8f23555952b8..53c699ef8c628 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -44,6 +44,7 @@ macro intrinsic_match { $( $($($name:tt).*)|+ $(if $cond:expr)?, $(<$($subst:ident),*>)? ($($a:ident $arg:ident),*) $content:block; )*) => { + let _ = $substs; // Silence warning when substs is unused. match $intrinsic { $( $(intrinsic_pat!($($name).*))|* $(if $cond)? => { diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 04e55d8018711..4d7bec0f06ee6 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -17,7 +17,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.tcx.sess.fatal(&format!("Unknown SIMD intrinsic {}", intrinsic)); + fx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); }; simd_cast, (c a) { @@ -104,7 +104,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( } }; - simd_insert, (c base, o idx, v val) { + simd_insert, (c base, o idx, v _val) { let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index acce3a6465b77..4e9cff7636558 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -155,7 +155,7 @@ impl<'a> OptimizeContext<'a> { pub(super) fn optimize_function( ctx: &mut Context, - clif_comments: &mut crate::pretty_clif::CommentWriter, + _clif_comments: &mut crate::pretty_clif::CommentWriter, name: T, ) { combine_stack_addr_with_load_store(&mut ctx.func); From 53ef00e68cc0620fa84ffa4e74305ec4f6df2f23 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 22 Feb 2020 15:57:53 +0100 Subject: [PATCH 1143/1566] Fix JIT on macOS Fixes #671 --- src/driver.rs | 9 ++++++++- test.sh | 16 ++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index cf3ad422171df..056fc57989f69 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -136,8 +136,15 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { return None; } + let dlsym_name = if cfg!(target_os = "macos") { + // On macOS `dlsym` expects the name without leading `_`. + assert!(name.starts_with("_"), "{:?}", name); + &name[1..] + } else { + &name + }; let symbol: libloading::Symbol<*const u8> = - unsafe { lib.get(name.as_bytes()) }.unwrap(); + unsafe { lib.get(dlsym_name.as_bytes()) }.unwrap(); Some((name, *symbol)) })); std::mem::forget(lib) diff --git a/test.sh b/test.sh index 72934e689584f..e1cb1333649c3 100755 --- a/test.sh +++ b/test.sh @@ -12,16 +12,6 @@ fi source config.sh -jit() { - if [[ `uname` == 'Darwin' ]]; then - # FIXME(#671) `dlsym` returns "symbol not found" for existing symbols on macOS. - echo "[JIT] $1 (Ignored on macOS)" - else - echo "[JIT] $1" - SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic $2 - fi -} - rm -r target/out || true mkdir -p target/out/clif @@ -31,7 +21,8 @@ $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib -#JIT_ARGS="abc bcd" jit mini_core_hello_world example/mini_core_hello_world.rs +echo "[JIT] mini_core_hello_world" +JIT_ARGS="abc bcd" SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g @@ -49,7 +40,8 @@ echo "[AOT] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin ./target/out/alloc_example -jit std_example example/std_example.rs +echo "[JIT] std_example" +SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs echo "[AOT] dst_field_align" # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. From 101f8d4ecf3437c17022e78cdb8afe9dfe104dd2 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2020 05:09:52 +0000 Subject: [PATCH 1144/1566] Bump cranelift-codegen from `0c7da4a` to `5ad5505` Bumps [cranelift-codegen](https://github.com/bytecodealliance/cranelift) from `0c7da4a` to `5ad5505`. - [Release notes](https://github.com/bytecodealliance/cranelift/releases) - [Commits](https://github.com/bytecodealliance/cranelift/compare/0c7da4a66325b82423111927b0d701e9a09269a6...5ad55057f18652ad0a4f270cd9b2876eb051c7d0) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 408427bb14a21..3bfc11c5165ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,7 +33,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift-bforest" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", ] @@ -41,7 +41,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -58,7 +58,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -67,17 +67,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" [[package]] name = "cranelift-entity" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" [[package]] name = "cranelift-frontend" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -88,7 +88,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -109,7 +109,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", @@ -120,7 +120,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#0c7da4a66325b82423111927b0d701e9a09269a6" +source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" dependencies = [ "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", From 0e0afb4f1fe47638aa59e41ce0b9a775bb4c15f6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 26 Feb 2020 14:30:11 +0100 Subject: [PATCH 1145/1566] Rustup to rustc 1.43.0-nightly (6fd8798f4 2020-02-25) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 292e9dbf723bd..ad067e2ebe6d3 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-02-22 +nightly-2020-02-26 From c8de552c0134896c8c804c7ca74555bd300ee937 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 27 Oct 2019 16:55:35 +0100 Subject: [PATCH 1146/1566] Tls support --- Cargo.lock | 317 ++++++++++++++---------------- crate_patches/regex.patch | 34 ---- example/mini_core.rs | 11 +- example/mini_core_hello_world.rs | 79 +++++++- example/std_example.rs | 4 + patches/0018-Add-FnBox-back.patch | 5 +- prepare.sh | 1 - src/atomic_shim.rs | 3 + src/constant.rs | 4 + src/lib.rs | 13 +- src/trap.rs | 1 + src/vtable.rs | 1 + test.sh | 4 +- 13 files changed, 270 insertions(+), 207 deletions(-) delete mode 100644 crate_patches/regex.patch diff --git a/Cargo.lock b/Cargo.lock index 3bfc11c5165ec..881b953884b29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,448 +4,437 @@ name = "ar" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" [[package]] name = "autocfg" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" [[package]] name = "cfg-if" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-meta 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "gimli", + "log", + "smallvec", + "target-lexicon", + "thiserror", ] [[package]] name = "cranelift-codegen-meta" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", + "cranelift-codegen-shared", + "cranelift-entity", ] [[package]] name = "cranelift-codegen-shared" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" [[package]] name = "cranelift-entity" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" [[package]] name = "cranelift-frontend" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", ] [[package]] name = "cranelift-module" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen", + "cranelift-entity", + "log", + "thiserror", ] [[package]] name = "cranelift-native" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen", + "raw-cpuid", + "target-lexicon", ] [[package]] name = "cranelift-object" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen", + "cranelift-module", + "goblin", + "object", + "target-lexicon", ] [[package]] name = "cranelift-simplejit" -version = "0.58.0" -source = "git+https://github.com/bytecodealliance/cranelift/#5ad55057f18652ad0a4f270cd9b2876eb051c7d0" +version = "0.59.0" +source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" dependencies = [ - "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-native 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-codegen", + "cranelift-module", + "cranelift-native", + "errno", + "libc", + "region", + "target-lexicon", + "winapi", ] [[package]] name = "crc32fast" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "errno" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" dependencies = [ - "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "errno-dragonfly", + "libc", + "winapi", ] [[package]] name = "errno-dragonfly" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" dependencies = [ - "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc", + "libc", ] [[package]] name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "gimli" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" dependencies = [ - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder", + "indexmap", ] [[package]] name = "goblin" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log", + "plain", + "scroll", ] [[package]] name = "indexmap" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" dependencies = [ - "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "libc" version = "0.2.67" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" [[package]] name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" dependencies = [ - "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "winapi", ] [[package]] name = "log" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" dependencies = [ - "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" dependencies = [ - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "object" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" dependencies = [ - "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast", + "goblin", + "indexmap", + "scroll", + "target-lexicon", + "uuid", ] [[package]] name = "plain" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] name = "proc-macro2" version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "raw-cpuid" version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cc", + "rustc_version", ] [[package]] name = "region" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)", - "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "libc", + "mach", + "winapi", ] [[package]] name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ - "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-frontend 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-object 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "cranelift-simplejit 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)", - "gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", - "target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ar", + "byteorder", + "cranelift-codegen", + "cranelift-frontend", + "cranelift-module", + "cranelift-object", + "cranelift-simplejit", + "gimli", + "indexmap", + "libloading", + "object", + "target-lexicon", ] [[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver", ] [[package]] name = "scroll" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" dependencies = [ - "scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll_derive", ] [[package]] name = "scroll_derive" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser", ] [[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "smallvec" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" [[package]] name = "syn" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a0294dc449adc58bb6592fff1a23d3e5e6e235afc6a0ffca2657d19e7bbffe5" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "target-lexicon" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "thiserror" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee14bf8e6767ab4c687c9e8bc003879e042a96fd67a3ba5934eadb6536bef4db" dependencies = [ - "thiserror-impl 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7b51e1fbc44b5a0840be594fbc0f960be09050f2617e61e6aa43bef97cd3ef4" dependencies = [ - "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "unicode-xid" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "uuid" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" [[package]] name = "winapi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" -"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" -"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum cranelift-bforest 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-meta 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-codegen-shared 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-entity 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-frontend 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-module 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-native 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-object 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum cranelift-simplejit 0.58.0 (git+https://github.com/bytecodealliance/cranelift/)" = "" -"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" -"checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" -"checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" -"checksum goblin 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" -"checksum indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" -"checksum libc 0.2.67 (registry+https://github.com/rust-lang/crates.io-index)" = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" -"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" -"checksum object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" -"checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" -"checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" -"checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" -"checksum syn 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a0294dc449adc58bb6592fff1a23d3e5e6e235afc6a0ffca2657d19e7bbffe5" -"checksum target-lexicon 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" -"checksum thiserror 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ee14bf8e6767ab4c687c9e8bc003879e042a96fd67a3ba5934eadb6536bef4db" -"checksum thiserror-impl 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "a7b51e1fbc44b5a0840be594fbc0f960be09050f2617e61e6aa43bef97cd3ef4" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/crate_patches/regex.patch b/crate_patches/regex.patch deleted file mode 100644 index 4209ccfbdd2a9..0000000000000 --- a/crate_patches/regex.patch +++ /dev/null @@ -1,34 +0,0 @@ -From febff2a8c639efb5de1e1b4758cdb473847d80ce Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Tue, 30 Jul 2019 12:12:37 +0200 -Subject: [PATCH] Disable threads in shootout-regex-dna example - ---- - examples/shootout-regex-dna.rs | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/examples/shootout-regex-dna.rs b/examples/shootout-regex-dna.rs -index 2171bb3..37382f8 100644 ---- a/examples/shootout-regex-dna.rs -+++ b/examples/shootout-regex-dna.rs -@@ -37,7 +37,7 @@ fn main() { - for variant in variants { - let seq = seq_arc.clone(); - let restr = variant.to_string(); -- let future = thread::spawn(move || variant.find_iter(&seq).count()); -+ let future = variant.find_iter(&seq).count(); - counts.push((restr, future)); - } - -@@ -60,7 +60,7 @@ fn main() { - } - - for (variant, count) in counts { -- println!("{} {}", variant, count.join().unwrap()); -+ println!("{} {}", variant, count); - } - println!("\n{}\n{}\n{}", ilen, clen, seq.len()); - } --- -2.11.0 - diff --git a/example/mini_core.rs b/example/mini_core.rs index 1912cc50a218e..2e14424d8de86 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,6 +1,7 @@ #![feature( no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, - untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_traits + untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_traits, + thread_local, )] #![no_core] #![allow(dead_code)] @@ -551,3 +552,11 @@ struct PanicLocation { line: u32, column: u32, } + +#[no_mangle] +pub fn get_tls() -> u8 { + #[thread_local] + static A: u8 = 42; + + A +} diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index fdc71af443748..489ceea83ea19 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -1,8 +1,11 @@ // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs -#![feature(no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns, never_type, linkage, extern_types)] +#![feature( + no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns, never_type, linkage, + extern_types, thread_local +)] #![no_core] -#![allow(dead_code)] +#![allow(dead_code, non_camel_case_types)] extern crate mini_core; @@ -276,6 +279,78 @@ fn main() { extern_nullptr as *const (); let slice_ptr = &[] as *const [u8]; slice_ptr as *const u8; + + #[cfg(not(jit))] + test_tls(); +} + +#[repr(C)] +enum c_void { + _1, + _2, +} + +type c_int = i32; +type c_ulong = u64; + +type pthread_t = c_ulong; + +#[repr(C)] +struct pthread_attr_t { + __size: [u64; 7], +} + +#[link(name = "pthread")] +extern "C" { + fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + + fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(_: *mut c_void) -> *mut c_void, + value: *mut c_void + ) -> c_int; + + fn pthread_join( + native: pthread_t, + value: *mut *mut c_void + ) -> c_int; +} + +#[thread_local] +#[cfg(not(jit))] +static mut TLS: u8 = 42; + +#[cfg(not(jit))] +extern "C" fn mutate_tls(_: *mut c_void) -> *mut c_void { + unsafe { TLS = 0; } + 0 as *mut c_void +} + +#[cfg(not(jit))] +fn test_tls() { + unsafe { + let mut attr: pthread_attr_t = intrinsics::init(); + let mut thread: pthread_t = 0; + + assert_eq!(TLS, 42); + + if pthread_attr_init(&mut attr) != 0 { + assert!(false); + } + + if pthread_create(&mut thread, &attr, mutate_tls, 0 as *mut c_void) != 0 { + assert!(false); + } + + let mut res = 0 as *mut c_void; + pthread_join(thread, &mut res); + + // TLS of main thread must not have been changed by the other thread. + assert_eq!(TLS, 42); + + puts("TLS works!\n\0" as *const str as *const u8); + } } // Copied ui/issues/issue-61696.rs diff --git a/example/std_example.rs b/example/std_example.rs index eccffc621406f..3332c025e173f 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -12,6 +12,10 @@ fn main() { let stderr = ::std::io::stderr(); let mut stderr = stderr.lock(); + std::thread::spawn(move || { + println!("Hello from another thread!"); + }); + writeln!(stderr, "some {} text", "").unwrap(); let _ = std::process::Command::new("true").env("c", "d").spawn(); diff --git a/patches/0018-Add-FnBox-back.patch b/patches/0018-Add-FnBox-back.patch index e5616aa5a8b1d..12a4fbf4425e1 100644 --- a/patches/0018-Add-FnBox-back.patch +++ b/patches/0018-Add-FnBox-back.patch @@ -95,8 +95,9 @@ index 143cf2f..a6e8faf 100644 // unsafe: see thread::Builder::spawn_unchecked for safety requirements - pub unsafe fn new(stack: usize, p: Box) -> io::Result { + pub unsafe fn new(stack: usize, p: Box) -> io::Result { - panic!("Warning: Threads are not yet fully supported, because cranelift doesn't support atomics."); - +- panic!("Warning: Threads are not yet fully supported, because cranelift doesn't support atomics."); ++ println!("Spawned thread"); + let p = box p; let mut native: libc::pthread_t = mem::zeroed(); diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs diff --git a/prepare.sh b/prepare.sh index 2d9d1d9f908bd..c0ff44eaf5d02 100755 --- a/prepare.sh +++ b/prepare.sh @@ -9,7 +9,6 @@ git clone https://github.com/rust-lang/regex.git || echo "rust-lang/regex has al pushd regex git checkout -- . git checkout 341f207c1071f7290e3f228c710817c280c8dca1 -git apply ../crate_patches/regex.patch popd git clone https://github.com/ebobby/simple-raytracer || echo "ebobby/simple-raytracer has already been cloned" diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 300177e764563..17922e7bbcded 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -22,6 +22,7 @@ pub fn init_global_lock(module: &mut Module, bcx: &mut FunctionBui "__cg_clif_global_atomic_mutex", Linkage::Export, true, + false, Some(16), ).unwrap(); module.define_data(atomic_mutex, &data_ctx).unwrap(); @@ -50,6 +51,7 @@ pub fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { "__cg_clif_global_atomic_mutex", Linkage::Import, true, + false, None, ).unwrap(); @@ -74,6 +76,7 @@ pub fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { "__cg_clif_global_atomic_mutex", Linkage::Import, true, + false, None, ).unwrap(); diff --git a/src/constant.rs b/src/constant.rs index 47e949021dfd1..3da096655f593 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -212,6 +212,7 @@ fn data_id_for_alloc_id( &format!("__alloc_{}", alloc_id.0), Linkage::Local, false, + false, Some(align.bytes() as u8), ) .unwrap() @@ -238,11 +239,14 @@ fn data_id_for_static( .pref .bytes(); + let attrs = tcx.codegen_fn_attrs(def_id); + let data_id = module .declare_data( &*symbol_name, linkage, is_mutable, + attrs.flags.contains(rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags::THREAD_LOCAL), Some(align.try_into().unwrap()), ) .unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 21fca3c89f69a..1d27e99e32f61 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -256,6 +256,10 @@ fn target_triple(sess: &Session) -> target_lexicon::Triple { } fn build_isa(sess: &Session, enable_pic: bool) -> Box { + use target_lexicon::BinaryFormat; + + let target_triple = crate::target_triple(sess); + let mut flags_builder = settings::builder(); if enable_pic { flags_builder.enable("is_pic").unwrap(); @@ -274,6 +278,14 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box "elf_gd", + BinaryFormat::Macho => "macho", + BinaryFormat::Coff => "coff", + _ => "none", + }; + flags_builder.set("tls_model", tls_model).unwrap(); + // FIXME(CraneStation/cranelift#732) fix LICM in presence of jump tables /* use rustc::session::config::OptLevel; @@ -290,7 +302,6 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box, ms &(symbol_name.name.as_str().to_string() + msg), Linkage::Local, false, + false, None, ) .unwrap(); diff --git a/src/vtable.rs b/src/vtable.rs index 7eaf8ffdada7c..5ce975d3124f3 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -129,6 +129,7 @@ fn build_vtable<'tcx>( &format!("vtable.{:?}.for.{:?}", trait_ref, layout.ty), Linkage::Local, false, + false, Some( fx.tcx .data_layout diff --git a/test.sh b/test.sh index e1cb1333649c3..b650653b74036 100755 --- a/test.sh +++ b/test.sh @@ -22,7 +22,7 @@ echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib echo "[JIT] mini_core_hello_world" -JIT_ARGS="abc bcd" SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs +JIT_ARGS="abc bcd" SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g @@ -88,7 +88,7 @@ echo "[TEST] rust-lang/regex example shootout-regex-dna" ../cargo.sh clean # Make sure `[codegen mono items] start` doesn't poison the diff ../cargo.sh build --example shootout-regex-dna -cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna > res.txt +cat examples/regexdna-input.txt | ../cargo.sh run --example shootout-regex-dna | grep -v "Spawned thread" > res.txt diff -u res.txt examples/regexdna-output.txt echo "[TEST] rust-lang/regex tests" From 900c04a42338604d7dbea655950527ea76601533 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 26 Feb 2020 16:35:13 +0100 Subject: [PATCH 1147/1566] Implement simd_fma --- src/intrinsics/simd.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 4d7bec0f06ee6..99149d7d89bf7 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -180,6 +180,28 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( simd_int_binop!(fx, bxor(x, y) -> ret); }; + simd_fma, (c a, c b, c c) { + assert_eq!(a.layout(), b.layout()); + assert_eq!(a.layout(), c.layout()); + let layout = a.layout(); + + let (_lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); + assert_eq!(lane_count, ret_lane_count); + + for lane in 0..lane_count { + let lane = mir::Field::new(lane.try_into().unwrap()); + let a_lane = a.value_field(fx, lane).load_scalar(fx); + let b_lane = b.value_field(fx, lane).load_scalar(fx); + let c_lane = c.value_field(fx, lane).load_scalar(fx); + + let mul_lane = fx.bcx.ins().fmul(a_lane, b_lane); + let res_lane = CValue::by_val(fx.bcx.ins().fadd(mul_lane, c_lane), ret_lane_layout); + + ret.place_field(fx, lane).write_cvalue(fx, res_lane); + } + }; + simd_fmin, (c x, c y) { simd_flt_binop!(fx, fmin(x, y) -> ret); }; From d07767b5c1535991749e7b1680114331f4a0b325 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Feb 2020 14:19:16 +0100 Subject: [PATCH 1148/1566] Rustup to rustc 1.43.0-nightly (0eb878d2a 2020-02-28) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index ad067e2ebe6d3..e2e4b45c0d319 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-02-26 +nightly-2020-02-29 From dc1165300d7d63040904012d09a2556222c8aedd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 29 Feb 2020 14:24:29 +0100 Subject: [PATCH 1149/1566] Update for the merge of Cranelift into Wasmtime --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 881b953884b29..647ad6bb34613 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "cranelift-entity", ] @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "byteorder", "cranelift-bforest", @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -73,17 +73,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" [[package]] name = "cranelift-entity" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" [[package]] name = "cranelift-frontend" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "cranelift-codegen", "log", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -105,7 +105,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/cranelift/#1d144eeacffb1997cc567b7d518f195932ee3d92" +source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" dependencies = [ "cranelift-codegen", "cranelift-module", diff --git a/Cargo.toml b/Cargo.toml index 8e4cff5c1eb67..0f89f03432aa6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,10 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { git = "https://github.com/bytecodealliance/cranelift/" } -cranelift-frontend = { git = "https://github.com/bytecodealliance/cranelift/" } -cranelift-module = { git = "https://github.com/bytecodealliance/cranelift/" } -cranelift-object = { git = "https://github.com/bytecodealliance/cranelift/" } +cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/" } +cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/" } +cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/" } +cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/" } target-lexicon = "0.10.0" ar = "0.8.0" @@ -30,18 +30,18 @@ default-features = false features = ["write"] # We don't need read support # Uncomment to use local checkout of cranelift -#[patch."https://github.com/bytecodealliance/cranelift/"] -#cranelift-codegen = { path = "../cranelift/cranelift-codegen" } -#cranelift-frontend = { path = "../cranelift/cranelift-frontend" } -#cranelift-module = { path = "../cranelift/cranelift-module" } -#cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } -#cranelift-object = { path = "../cranelift/cranelift-object" } +#[patch."https://github.com/bytecodealliance/wasmtime/"] +#cranelift-codegen = { path = "../wasmtime/cranelift/cranelift-codegen" } +#cranelift-frontend = { path = "../wasmtime/cranelift/cranelift-frontend" } +#cranelift-module = { path = "../wasmtime/cranelift/cranelift-module" } +#cranelift-simplejit = { path = "../wasmtime/cranelift/cranelift-simplejit" } +#cranelift-object = { path = "../wasmtime/cranelift/cranelift-object" } #[patch.crates-io] #gimli = { path = "../" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -cranelift-simplejit = { git = "https://github.com/bytecodealliance/cranelift/" } +cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/" } libloading = "0.5.1" [profile.dev] From 9ab2af56aa4a8b6f11a4275671fd7947c0251a0b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 4 Mar 2020 15:04:28 +0100 Subject: [PATCH 1150/1566] Rustup to rustc 1.43.0-nightly (4ad624882 2020-03-03) --- build_sysroot/alloc_system/lib.rs | 16 ++++++++++------ example/mini_core_hello_world.rs | 2 +- example/std_example.rs | 2 +- example/subslice-patterns-const-eval.rs | 2 -- rust-toolchain | 2 +- src/allocator.rs | 2 +- src/archive.rs | 2 +- src/base.rs | 4 ++-- src/constant.rs | 4 ---- src/lib.rs | 4 ++-- 10 files changed, 19 insertions(+), 21 deletions(-) diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index c9815853de1a3..abfcf301a5347 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -72,12 +72,14 @@ pub struct System; #[unstable(feature = "allocator_api", issue = "32838")] unsafe impl AllocRef for System { #[inline] - unsafe fn alloc(&mut self, layout: Layout) -> Result, AllocErr> { - NonNull::new(GlobalAlloc::alloc(self, layout)).ok_or(AllocErr) + unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { + NonNull::new(GlobalAlloc::alloc(self, layout)).ok_or(AllocErr).map(|p| (p, layout.size())) } #[inline] - unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result, AllocErr> { - NonNull::new(GlobalAlloc::alloc_zeroed(self, layout)).ok_or(AllocErr) + unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { + NonNull::new(GlobalAlloc::alloc_zeroed(self, layout)) + .ok_or(AllocErr) + .map(|p| (p, layout.size())) } #[inline] unsafe fn dealloc(&mut self, ptr: NonNull, layout: Layout) { @@ -87,8 +89,10 @@ unsafe impl AllocRef for System { unsafe fn realloc(&mut self, ptr: NonNull, layout: Layout, - new_size: usize) -> Result, AllocErr> { - NonNull::new(GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size)).ok_or(AllocErr) + new_size: usize) -> Result<(NonNull, usize), AllocErr> { + NonNull::new(GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size)) + .ok_or(AllocErr) + .map(|p| (p, layout.size())) } } #[cfg(any(windows, unix, target_os = "cloudabi", target_os = "redox"))] diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 489ceea83ea19..382ba99538d80 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -1,7 +1,7 @@ // Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs #![feature( - no_core, unboxed_closures, start, lang_items, box_syntax, slice_patterns, never_type, linkage, + no_core, unboxed_closures, start, lang_items, box_syntax, never_type, linkage, extern_types, thread_local )] #![no_core] diff --git a/example/std_example.rs b/example/std_example.rs index 3332c025e173f..baf9a9c526eb5 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -84,7 +84,7 @@ fn main() { let empty: [i32; 0] = []; assert!(empty.is_sorted()); - println!("{:?}", unsafe { std::intrinsics::caller_location() }); + println!("{:?}", std::intrinsics::caller_location()); unsafe { test_simd(); diff --git a/example/subslice-patterns-const-eval.rs b/example/subslice-patterns-const-eval.rs index ec3614bb34ad0..2cb84786f56d0 100644 --- a/example/subslice-patterns-const-eval.rs +++ b/example/subslice-patterns-const-eval.rs @@ -4,8 +4,6 @@ // run-pass -#![feature(slice_patterns)] - #[derive(PartialEq, Debug, Clone)] struct N(u8); diff --git a/rust-toolchain b/rust-toolchain index e2e4b45c0d319..5b13884152fa5 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-02-29 +nightly-2020-03-04 diff --git a/src/allocator.rs b/src/allocator.rs index 8405096f32b42..eeead3050d8b0 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -10,7 +10,7 @@ use crate::prelude::*; -use syntax::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; +use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { diff --git a/src/archive.rs b/src/archive.rs index 803a1ef0dabee..19ca3ea770306 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -94,7 +94,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { )); } - fn add_native_library(&mut self, name: syntax::ast::Name) { + fn add_native_library(&mut self, name: rustc_ast::ast::Name) { let location = find_library(name, &self.config.lib_search_paths, self.config.sess); self.add_archive(location.clone(), |_| false) .unwrap_or_else(|e| { diff --git a/src/base.rs b/src/base.rs index 963354e421864..ddd3c3cef0788 100644 --- a/src/base.rs +++ b/src/base.rs @@ -555,7 +555,7 @@ fn trans_stmt<'tcx>( | StatementKind::AscribeUserType(..) => {} StatementKind::InlineAsm(asm) => { - use syntax::ast::Name; + use rustc_ast::ast::Name; let InlineAsm { asm, outputs: _, @@ -568,7 +568,7 @@ fn trans_stmt<'tcx>( clobbers, // Vec volatile, // bool alignstack, // bool - dialect: _, // syntax::ast::AsmDialect + dialect: _, // rustc_ast::ast::AsmDialect asm_str_style: _, } = asm; match &*asm_code.as_str() { diff --git a/src/constant.rs b/src/constant.rs index 3da096655f593..e82ddaaf74925 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -439,10 +439,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { panic!(); } - fn find_foreign_static(_: TyCtxt<'tcx>, _: DefId) -> InterpResult<'tcx, Cow<'tcx, Allocation>> { - panic!(); - } - fn binary_ptr_op( _: &InterpCx<'mir, 'tcx, Self>, _: mir::BinOp, diff --git a/src/lib.rs b/src/lib.rs index 1d27e99e32f61..85e0fb047e4da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ extern crate rustc_mir; extern crate rustc_session; extern crate rustc_span; extern crate rustc_target; -extern crate syntax; +extern crate rustc_ast; use std::any::Any; @@ -67,7 +67,7 @@ mod prelude { pub use std::collections::{HashMap, HashSet}; pub use std::convert::{TryFrom, TryInto}; - pub use syntax::ast::{FloatTy, IntTy, UintTy}; + pub use rustc_ast::ast::{FloatTy, IntTy, UintTy}; pub use rustc_span::{Pos, Span}; pub use rustc::bug; From b00927b9562ab6b467a96e19aee594605e191d07 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 10:39:57 +0100 Subject: [PATCH 1151/1566] Rustup to rustc 1.43.0-nightly (2890b37b8 2020-03-06) --- rust-toolchain | 2 +- rustup.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 5b13884152fa5..076504e39377e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-04 +nightly-2020-03-07 diff --git a/rustup.sh b/rustup.sh index afa7888cc0c25..aeb60c50c0939 100755 --- a/rustup.sh +++ b/rustup.sh @@ -4,8 +4,7 @@ set -e case $1 in "prepare") - # FIXME Automatically detect latest nightly - read -p "Date of nightly to use: " TOOLCHAIN + TOOLCHAIN=$(date +%Y-%m-%d) echo "=> Installing new nightly" rustup toolchain install --profile minimal nightly-${TOOLCHAIN} # Sanity check to see if the nightly exists From 576aa7644570efef98b8453429cf1cd1dcf58fe2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 11:06:24 +0100 Subject: [PATCH 1152/1566] Don't run dsymutil on librustc_codegen_cranelift on macOS This halves clean incremental compilation time --- test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index b650653b74036..78407ffbe50b3 100755 --- a/test.sh +++ b/test.sh @@ -4,10 +4,10 @@ set -e if [[ "$1" == "--release" ]]; then export CHANNEL='release' - CARGO_INCREMENTAL=1 cargo build --release + CARGO_INCREMENTAL=1 cargo rustc --release -- -Zrun_dsymutil=no else export CHANNEL='debug' - cargo build + cargo rustc -- -Zrun_dsymutil=no fi source config.sh From 5d2a1daf8380585697b026ce2583c74454e9eef0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 11:10:33 +0100 Subject: [PATCH 1153/1566] Remove unused inline asm whitelist --- src/base.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/base.rs b/src/base.rs index ddd3c3cef0788..4f369723dc43a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -618,9 +618,6 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } - _ if fx.tcx.symbol_name(fx.instance).name.as_str() == "__rust_probestack" => { - crate::trap::trap_unimplemented(fx, "__rust_probestack is not supported"); - } _ => unimpl!("Inline assembly is not supported"), } } From a29730e288895a032118ff5f4df89c17ad834030 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 11:11:42 +0100 Subject: [PATCH 1154/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 647ad6bb34613..2a7209831fcb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "cranelift-entity", ] @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "byteorder", "cranelift-bforest", @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -73,17 +73,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" [[package]] name = "cranelift-entity" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" [[package]] name = "cranelift-frontend" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "cranelift-codegen", "log", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -105,7 +105,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2c5be49af0a2dca6e116010e57720eacddb14e0f" +source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" dependencies = [ "cranelift-codegen", "cranelift-module", From 152bde63fecfd2bc3b2296b36cf9140b977ff035 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 11:27:49 +0100 Subject: [PATCH 1155/1566] Misc changes --- src/constant.rs | 6 +----- src/debuginfo/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index e82ddaaf74925..b67637ff21402 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -261,11 +261,7 @@ fn data_id_for_static( } let mut data_ctx = DataContext::new(); - let zero_bytes = std::iter::repeat(0) - .take(pointer_ty(tcx).bytes() as usize) - .collect::>() - .into_boxed_slice(); - data_ctx.define(zero_bytes); + data_ctx.define_zeroinit(pointer_ty(tcx).bytes() as usize); match module.define_data(data_id, &data_ctx) { // Everytime a weak static is referenced, there will be a zero pointer definition, // so duplicate definitions are expected and allowed. diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index f9048ad401050..c90f5fa6aedf8 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -67,8 +67,8 @@ impl<'tcx> DebugContext<'tcx> { dwarf.unit.line_program = line_program; { - let name = dwarf.strings.add(&*name); - let comp_dir = dwarf.strings.add(&*comp_dir); + let name = dwarf.strings.add(name); + let comp_dir = dwarf.strings.add(comp_dir); let root = dwarf.unit.root(); let root = dwarf.unit.get_mut(root); From 2ecffb6fc42fb5f2fce0ac0620176c5924d69dd6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 11:54:35 +0100 Subject: [PATCH 1156/1566] Inline codegen_cgus --- src/driver.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 056fc57989f69..9d68fb067753b 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -67,8 +67,17 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { .declare_function("main", Linkage::Import, &sig) .unwrap(); - codegen_cgus(tcx, &mut jit_module, &mut None); + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) + .flatten() + .collect::>(); + + codegen_mono_items(tcx, &mut jit_module, None, mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); crate::allocator::codegen(tcx, &mut jit_module); + jit_module.finalize_definitions(); tcx.sess.abort_if_errors(); @@ -196,6 +205,13 @@ fn run_aot( } }; + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) + .flatten() + .collect::>(); + let mut module = new_module("some_file".to_string()); let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { @@ -208,7 +224,8 @@ fn run_aot( None }; - codegen_cgus(tcx, &mut module, &mut debug); + codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); tcx.sess.abort_if_errors(); @@ -283,23 +300,6 @@ fn run_aot( }) } -fn codegen_cgus<'tcx>( - tcx: TyCtxt<'tcx>, - module: &mut Module, - debug: &mut Option>, -) { - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let mono_items = cgus - .iter() - .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) - .flatten() - .collect::>(); - - codegen_mono_items(tcx, module, debug.as_mut(), mono_items); - - crate::main_shim::maybe_create_entry_wrapper(tcx, module); -} - fn codegen_mono_items<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, From 575836ebe3caa9963b61355561d16acb57e11aa3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 12:13:54 +0100 Subject: [PATCH 1157/1566] Check for main in current module before codegen of entry wrapper --- src/main_shim.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main_shim.rs b/src/main_shim.rs index fc3f9734874e6..74ee0d8fee81b 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -17,6 +17,11 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module return, }; + let instance = Instance::mono(tcx, main_def_id); + if module.get_name(&*tcx.symbol_name(instance).name.as_str()).is_none() { + return; + } + create_entry_fn(tcx, module, main_def_id, use_start_lang_item); fn create_entry_fn( From 97db112295dbf18595e1ad3006422621fa643b30 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 12:16:32 +0100 Subject: [PATCH 1158/1566] Move time "codegen mono items" out of codegen_mono_items --- src/driver.rs | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 9d68fb067753b..e67c2a50bc8aa 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -74,7 +74,9 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { .flatten() .collect::>(); - codegen_mono_items(tcx, &mut jit_module, None, mono_items); + time(tcx.sess, "codegen mono items", || { + codegen_mono_items(tcx, &mut jit_module, None, mono_items); + }); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); crate::allocator::codegen(tcx, &mut jit_module); @@ -224,7 +226,9 @@ fn run_aot( None }; - codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + time(tcx.sess, "codegen mono items", || { + codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + }); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); tcx.sess.abort_if_errors(); @@ -308,30 +312,28 @@ fn codegen_mono_items<'tcx>( ) { let mut cx = CodegenCx::new(tcx, module, debug_context); - time(tcx.sess, "codegen mono items", move || { - tcx.sess.time("predefine functions", || { - for (&mono_item, &(linkage, visibility)) in &mono_items { - match mono_item { - MonoItem::Fn(instance) => { - let (name, sig) = - get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); - let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - cx.module.declare_function(&name, linkage, &sig).unwrap(); - } - MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} + tcx.sess.time("predefine functions", || { + for (&mono_item, &(linkage, visibility)) in &mono_items { + match mono_item { + MonoItem::Fn(instance) => { + let (name, sig) = + get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + cx.module.declare_function(&name, linkage, &sig).unwrap(); } + MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} } - }); - - for (mono_item, (linkage, visibility)) in mono_items { - crate::unimpl::try_unimpl(tcx, || { - let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - trans_mono_item(&mut cx, mono_item, linkage); - }); } - - tcx.sess.time("finalize CodegenCx", || cx.finalize()); }); + + for (mono_item, (linkage, visibility)) in mono_items { + crate::unimpl::try_unimpl(tcx, || { + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + trans_mono_item(&mut cx, mono_item, linkage); + }); + } + + tcx.sess.time("finalize CodegenCx", || cx.finalize()); } fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( From 36ea72c2bd8488aa007919dbfb97fde9e13f9020 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 12:45:05 +0100 Subject: [PATCH 1159/1566] Move emit_module call --- src/driver.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index e67c2a50bc8aa..b6cc3a98257f0 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -231,6 +231,14 @@ fn run_aot( }); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + let modules = vec![emit_module( + tcx, + "some_file".to_string(), + ModuleKind::Regular, + module, + debug, + )]; + tcx.sess.abort_if_errors(); let mut allocator_module = new_module("allocator_shim".to_string()); @@ -277,13 +285,7 @@ fn run_aot( Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), - modules: vec![emit_module( - tcx, - "some_file".to_string(), - ModuleKind::Regular, - module, - debug, - )], + modules, allocator_module: if created_alloc_shim { Some(emit_module( tcx, From 03acf67a0e3a2780d2a1443f4e4596b69d9a2b09 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 7 Mar 2020 12:45:55 +0100 Subject: [PATCH 1160/1566] Use multiple codegen units --- src/driver.rs | 59 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index b6cc3a98257f0..29e498db75006 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -72,7 +72,9 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { .iter() .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) .flatten() - .collect::>(); + .collect::>() + .into_iter() + .collect::>(); time(tcx.sess, "codegen mono items", || { codegen_mono_items(tcx, &mut jit_module, None, mono_items); @@ -208,36 +210,35 @@ fn run_aot( }; let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let mono_items = cgus - .iter() - .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) - .flatten() - .collect::>(); - let mut module = new_module("some_file".to_string()); + let modules = time(tcx.sess, "codegen mono items", move || { + cgus.iter().map(|cgu| { + let mono_items = cgu.items_in_deterministic_order(tcx); - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { - let debug = DebugContext::new( - tcx, - module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) - } else { - None - }; + let mut module = new_module(cgu.name().as_str().to_string()); - time(tcx.sess, "codegen mono items", || { - codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); - }); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let debug = DebugContext::new( + tcx, + module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) + } else { + None + }; - let modules = vec![emit_module( - tcx, - "some_file".to_string(), - ModuleKind::Regular, - module, - debug, - )]; + codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + + emit_module( + tcx, + cgu.name().as_str().to_string(), + ModuleKind::Regular, + module, + debug, + ) + }).collect::>() + }); tcx.sess.abort_if_errors(); @@ -310,12 +311,12 @@ fn codegen_mono_items<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, debug_context: Option<&mut DebugContext<'tcx>>, - mono_items: FxHashMap, (RLinkage, Visibility)>, + mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { let mut cx = CodegenCx::new(tcx, module, debug_context); tcx.sess.time("predefine functions", || { - for (&mono_item, &(linkage, visibility)) in &mono_items { + for &(mono_item, (linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = From 63f22397ae2a3eb7a4ab43488a1ae1fc77f33d45 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 8 Mar 2020 12:25:11 +0100 Subject: [PATCH 1161/1566] Fix Cranelift patch paths --- Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0f89f03432aa6..dbd9eef4937a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,11 +31,11 @@ features = ["write"] # We don't need read support # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/wasmtime/"] -#cranelift-codegen = { path = "../wasmtime/cranelift/cranelift-codegen" } -#cranelift-frontend = { path = "../wasmtime/cranelift/cranelift-frontend" } -#cranelift-module = { path = "../wasmtime/cranelift/cranelift-module" } -#cranelift-simplejit = { path = "../wasmtime/cranelift/cranelift-simplejit" } -#cranelift-object = { path = "../wasmtime/cranelift/cranelift-object" } +#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" } +#cranelift-frontend = { path = "../wasmtime/cranelift/frontend" } +#cranelift-module = { path = "../wasmtime/cranelift/module" } +#cranelift-simplejit = { path = "../wasmtime/cranelift/simplejit" } +#cranelift-object = { path = "../wasmtime/cranelift/object" } #[patch.crates-io] #gimli = { path = "../" } From 6a90b6844f0876de7c22d7ae000b2d923b3efb2c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 8 Mar 2020 13:27:43 +0100 Subject: [PATCH 1162/1566] Revert "Use multiple codegen units" This reverts commit 03acf67a0e3a2780d2a1443f4e4596b69d9a2b09. --- src/driver.rs | 59 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 29e498db75006..b6cc3a98257f0 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -72,9 +72,7 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { .iter() .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) .flatten() - .collect::>() - .into_iter() - .collect::>(); + .collect::>(); time(tcx.sess, "codegen mono items", || { codegen_mono_items(tcx, &mut jit_module, None, mono_items); @@ -210,35 +208,36 @@ fn run_aot( }; let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) + .flatten() + .collect::>(); - let modules = time(tcx.sess, "codegen mono items", move || { - cgus.iter().map(|cgu| { - let mono_items = cgu.items_in_deterministic_order(tcx); - - let mut module = new_module(cgu.name().as_str().to_string()); - - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { - let debug = DebugContext::new( - tcx, - module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) - } else { - None - }; + let mut module = new_module("some_file".to_string()); - codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let debug = DebugContext::new( + tcx, + module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) + } else { + None + }; - emit_module( - tcx, - cgu.name().as_str().to_string(), - ModuleKind::Regular, - module, - debug, - ) - }).collect::>() + time(tcx.sess, "codegen mono items", || { + codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); }); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + + let modules = vec![emit_module( + tcx, + "some_file".to_string(), + ModuleKind::Regular, + module, + debug, + )]; tcx.sess.abort_if_errors(); @@ -311,12 +310,12 @@ fn codegen_mono_items<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, debug_context: Option<&mut DebugContext<'tcx>>, - mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, + mono_items: FxHashMap, (RLinkage, Visibility)>, ) { let mut cx = CodegenCx::new(tcx, module, debug_context); tcx.sess.time("predefine functions", || { - for &(mono_item, (linkage, visibility)) in &mono_items { + for (&mono_item, &(linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = From 12d324ce68d04656a7dc95d63b5716003dc077b7 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 9 Mar 2020 05:17:39 +0000 Subject: [PATCH 1163/1566] Bump cranelift-codegen from `4284491` to `fbe29da` Bumps [cranelift-codegen](https://github.com/bytecodealliance/wasmtime) from `4284491` to `fbe29da`. - [Release notes](https://github.com/bytecodealliance/wasmtime/releases) - [Commits](https://github.com/bytecodealliance/wasmtime/compare/428449133943213f2edc58ec161efcbb23d0eebd...fbe29da5cc1c0847af176f151f114a6a535534ff) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2a7209831fcb3..5223abb47930e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "cranelift-entity", ] @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "byteorder", "cranelift-bforest", @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -73,17 +73,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" [[package]] name = "cranelift-entity" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" [[package]] name = "cranelift-frontend" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "cranelift-codegen", "log", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -105,7 +105,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#428449133943213f2edc58ec161efcbb23d0eebd" +source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" dependencies = [ "cranelift-codegen", "cranelift-module", From 11b1c8b5c68111455900b42af47cd648066232ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 9 Mar 2020 11:21:40 +0100 Subject: [PATCH 1164/1566] Use multiple codegen units Fixes #909 --- src/constant.rs | 2 +- src/driver.rs | 59 +++++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index b67637ff21402..79183d560930a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -315,7 +315,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu if tcx.is_reachable_non_generic(def_id) { Linkage::Export } else { - Linkage::Local + Linkage::Export // FIXME Set hidden visibility }, ); (data_id, alloc) diff --git a/src/driver.rs b/src/driver.rs index b6cc3a98257f0..29e498db75006 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -72,7 +72,9 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { .iter() .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) .flatten() - .collect::>(); + .collect::>() + .into_iter() + .collect::>(); time(tcx.sess, "codegen mono items", || { codegen_mono_items(tcx, &mut jit_module, None, mono_items); @@ -208,36 +210,35 @@ fn run_aot( }; let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let mono_items = cgus - .iter() - .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) - .flatten() - .collect::>(); - let mut module = new_module("some_file".to_string()); + let modules = time(tcx.sess, "codegen mono items", move || { + cgus.iter().map(|cgu| { + let mono_items = cgu.items_in_deterministic_order(tcx); - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { - let debug = DebugContext::new( - tcx, - module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) - } else { - None - }; + let mut module = new_module(cgu.name().as_str().to_string()); - time(tcx.sess, "codegen mono items", || { - codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); - }); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let debug = DebugContext::new( + tcx, + module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) + } else { + None + }; - let modules = vec![emit_module( - tcx, - "some_file".to_string(), - ModuleKind::Regular, - module, - debug, - )]; + codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + + emit_module( + tcx, + cgu.name().as_str().to_string(), + ModuleKind::Regular, + module, + debug, + ) + }).collect::>() + }); tcx.sess.abort_if_errors(); @@ -310,12 +311,12 @@ fn codegen_mono_items<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, debug_context: Option<&mut DebugContext<'tcx>>, - mono_items: FxHashMap, (RLinkage, Visibility)>, + mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { let mut cx = CodegenCx::new(tcx, module, debug_context); tcx.sess.time("predefine functions", || { - for (&mono_item, &(linkage, visibility)) in &mono_items { + for &(mono_item, (linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = From c84949129b02dac8f6aa53d9d3134bb8e2c7ec95 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2020 10:39:45 +0100 Subject: [PATCH 1165/1566] Bump quote from 1.0.2 to 1.0.3 (#912) Bumps [quote](https://github.com/dtolnay/quote) from 1.0.2 to 1.0.3. - [Release notes](https://github.com/dtolnay/quote/releases) - [Commits](https://github.com/dtolnay/quote/compare/1.0.2...1.0.3) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5223abb47930e..273c367ef565d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" dependencies = [ "proc-macro2", ] From 32bcee563e49d8e60889a943c21111d9dd05bfaf Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2020 10:40:04 +0100 Subject: [PATCH 1166/1566] Bump syn from 1.0.15 to 1.0.16 (#907) Bumps [syn](https://github.com/dtolnay/syn) from 1.0.15 to 1.0.16. - [Release notes](https://github.com/dtolnay/syn/releases) - [Commits](https://github.com/dtolnay/syn/compare/1.0.15...1.0.16) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 273c367ef565d..e92b7befd295c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,9 +370,9 @@ checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" [[package]] name = "syn" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a0294dc449adc58bb6592fff1a23d3e5e6e235afc6a0ffca2657d19e7bbffe5" +checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" dependencies = [ "proc-macro2", "quote", From c53297f5ebe46f4d3ef0627c985a03871bd23780 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2020 10:40:23 +0100 Subject: [PATCH 1167/1566] Bump proc-macro2 from 1.0.8 to 1.0.9 (#908) Bumps [proc-macro2](https://github.com/alexcrichton/proc-macro2) from 1.0.8 to 1.0.9. - [Release notes](https://github.com/alexcrichton/proc-macro2/releases) - [Commits](https://github.com/alexcrichton/proc-macro2/compare/1.0.8...1.0.9) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e92b7befd295c..823364ee70f62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,9 +261,9 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] name = "proc-macro2" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548" +checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" dependencies = [ "unicode-xid", ] From 240d56c33c1a0b7097e7b7da475f61fa1d57400f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 10 Mar 2020 20:41:31 +0100 Subject: [PATCH 1168/1566] Support virtual calls with unsized self argument --- src/abi/mod.rs | 6 +++--- src/common.rs | 4 +++- src/pointer.rs | 7 ------- src/value_and_place.rs | 21 +++++++-------------- src/vtable.rs | 11 ++++++++++- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 568165bc61d85..230cba3a93430 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -355,7 +355,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block // not mutated by the current function, this is necessary to support unsized arguments. match arg_kind { ArgKind::Normal(Some(val)) => { - if let Some((addr, meta)) = val.try_to_addr() { + if let Some((addr, meta)) = val.try_to_ptr() { let local_decl = &fx.mir.local_decls[local]; // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( @@ -368,9 +368,9 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block // of this argument, to prevent a copy. let place = if let Some(meta) = meta { - CPlace::for_ptr_with_extra(Pointer::new(addr), meta, val.layout()) + CPlace::for_ptr_with_extra(addr, meta, val.layout()) } else { - CPlace::for_ptr(Pointer::new(addr), val.layout()) + CPlace::for_ptr(addr, val.layout()) }; #[cfg(debug_assertions)] diff --git a/src/common.rs b/src/common.rs index d9659f42d6fcd..5d99b385779ff 100644 --- a/src/common.rs +++ b/src/common.rs @@ -353,7 +353,9 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { - *self.local_map.get(&local).unwrap() + *self.local_map.get(&local).unwrap_or_else(|| { + panic!("Local {:?} doesn't exist", local); + }) } pub fn set_debug_loc(&mut self, source_info: mir::SourceInfo) { diff --git a/src/pointer.rs b/src/pointer.rs index 8ba9582f55468..0ecb0e1274e40 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -55,13 +55,6 @@ impl Pointer { } } - pub fn try_get_addr_and_offset(self) -> Option<(Value, Offset32)> { - match self.base { - PointerBase::Addr(addr) => Some((addr, self.offset)), - PointerBase::Stack(_) => None, - } - } - pub fn offset<'a, 'tcx>( self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, diff --git a/src/value_and_place.rs b/src/value_and_place.rs index c075fe4554499..9024d59ecb4f9 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -105,19 +105,9 @@ impl<'tcx> CValue<'tcx> { } } - pub fn try_to_addr(self) -> Option<(Value, Option)> { + pub fn try_to_ptr(self) -> Option<(Pointer, Option)> { match self.0 { - CValueInner::ByRef(ptr, meta) => { - if let Some((base_addr, offset)) = ptr.try_get_addr_and_offset() { - if offset == Offset32::new(0) { - Some((base_addr, meta)) - } else { - None - } - } else { - None - } - } + CValueInner::ByRef(ptr, meta) => Some((ptr, meta)), CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => None, } } @@ -345,8 +335,11 @@ impl<'tcx> CPlace<'tcx> { CValue::by_val(val, layout) } CPlaceInner::Addr(ptr, extra) => { - assert!(extra.is_none(), "unsized values are not yet supported"); - CValue::by_ref(ptr, layout) + if let Some(extra) = extra { + CValue::by_ref_unsized(ptr, extra, layout) + } else { + CValue::by_ref(ptr, layout) + } } CPlaceInner::NoPlace => CValue::by_ref( Pointer::const_addr(fx, i64::try_from(self.layout.align.pref.bytes()).unwrap()), diff --git a/src/vtable.rs b/src/vtable.rs index 5ce975d3124f3..e4b3a9942cf0c 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -47,7 +47,16 @@ pub fn get_ptr_and_method_ref<'tcx>( arg: CValue<'tcx>, idx: usize, ) -> (Value, Value) { - let (ptr, vtable) = arg.load_scalar_pair(fx); + let (ptr, vtable) = if let Abi::ScalarPair(_, _) = arg.layout().abi { + arg.load_scalar_pair(fx) + } else { + let (ptr, vtable) = arg.try_to_ptr().unwrap(); + ( + ptr.get_addr(fx), + vtable.unwrap() + ) + }; + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( pointer_ty(fx.tcx), From dcc86d306c28dc1b35e0d9b1370751da7689023a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 10 Mar 2020 20:48:58 +0100 Subject: [PATCH 1169/1566] Emulate ` as FnOnce>::call_once` without `alloca` Fixes #884 cc #15 --- .../0015-Remove-usage-of-unsized-locals.patch | 73 -------- patches/0017-Fix-libtest-compilation.patch | 68 ------- patches/0018-Add-FnBox-back.patch | 174 ------------------ src/abi/mod.rs | 16 +- src/base.rs | 92 ++++++++- 5 files changed, 97 insertions(+), 326 deletions(-) delete mode 100644 patches/0015-Remove-usage-of-unsized-locals.patch delete mode 100644 patches/0018-Add-FnBox-back.patch diff --git a/patches/0015-Remove-usage-of-unsized-locals.patch b/patches/0015-Remove-usage-of-unsized-locals.patch deleted file mode 100644 index 9c60ac55a9f31..0000000000000 --- a/patches/0015-Remove-usage-of-unsized-locals.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 7403e2998345ef0650fd50628d7098d4d1e88e5c Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 6 Apr 2019 12:16:21 +0200 -Subject: [PATCH] Remove usage of unsized locals - ---- - src/liballoc/boxed.rs | 23 ----------------------- - src/libstd/sys_common/at_exit_imp.rs | 2 ++ - src/libstd/sys_common/mod.rs | 1 - - src/libstd/sys_common/thread.rs | 7 +------ - 4 files changed, 3 insertions(+), 30 deletions(-) - -diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs -index f6dee7c..0c6a8c0 100644 ---- a/src/liballoc/boxed.rs -+++ b/src/liballoc/boxed.rs -@@ -694,29 +694,6 @@ impl ExactSizeIterator for Box { - #[stable(feature = "fused", since = "1.26.0")] - impl FusedIterator for Box {} - --#[stable(feature = "boxed_closure_impls", since = "1.35.0")] --impl + ?Sized> FnOnce for Box { -- type Output = >::Output; -- -- extern "rust-call" fn call_once(self, args: A) -> Self::Output { -- >::call_once(*self, args) -- } --} -- --#[stable(feature = "boxed_closure_impls", since = "1.35.0")] --impl + ?Sized> FnMut for Box { -- extern "rust-call" fn call_mut(&mut self, args: A) -> Self::Output { -- >::call_mut(self, args) -- } --} -- --#[stable(feature = "boxed_closure_impls", since = "1.35.0")] --impl + ?Sized> Fn for Box { -- extern "rust-call" fn call(&self, args: A) -> Self::Output { -- >::call(self, args) -- } --} -- - #[unstable(feature = "coerce_unsized", issue = "27732")] - impl, U: ?Sized> CoerceUnsized> for Box {} - -diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs -index b2142e7..718bb1c 100644 ---- a/src/libstd/sys_common/thread.rs -+++ b/src/libstd/sys_common/thread.rs -@@ -6,7 +6,7 @@ pub unsafe fn start_thread(main: *mut u8) { - let _handler = stack_overflow::Handler::new(); - - // Finally, let's run some code. -- Box::from_raw(main as *mut Box)() -+ Box::from_raw(main as *mut Box)() - } - - pub fn min_stack() -> usize { -diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs -index f4a1783..362b537 100644 ---- a/src/libstd/sys/unix/thread.rs -+++ b/src/libstd/sys/unix/thread.rs -@@ -40,5 +40,7 @@ impl Thread { - // unsafe: see thread::Builder::spawn_unchecked for safety requirements - pub unsafe fn new(stack: usize, p: Box) -> io::Result { -+ panic!("Warning: Threads are not yet fully supported, because cranelift doesn't support atomics."); -+ - let p = box p; - let mut native: libc::pthread_t = mem::zeroed(); - let mut attr: libc::pthread_attr_t = mem::zeroed(); --- -2.20.1 (Apple Git-117) diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch index 12dac18f3fa33..5998c26a4902f 100644 --- a/patches/0017-Fix-libtest-compilation.patch +++ b/patches/0017-Fix-libtest-compilation.patch @@ -11,24 +11,6 @@ diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 8b76080..9e65de2 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs -@@ -52,7 +52,7 @@ use std::fmt; - use std::{ - env, io, - io::prelude::Write, -- panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}, -+ panic::{self, PanicInfo}, - process::{self, Command, Termination}, - sync::mpsc::{channel, Sender}, - sync::{Arc, Mutex}, -@@ -1493,7 +1493,7 @@ pub fn run_test( - fn run_test_inner( - desc: TestDesc, - monitor_ch: Sender, -- testfn: Box, -+ testfn: Box, - opts: TestRunOpts, - ) { - let concurrency = opts.concurrency; @@ -1509,7 +1509,7 @@ pub fn run_test( // If the platform is single-threaded we're just going to run // the test synchronously, regardless of the concurrency @@ -38,55 +20,5 @@ index 8b76080..9e65de2 100644 if concurrency == Concurrent::Yes && supports_threads { let cfg = thread::Builder::new().name(name.as_slice().to_owned()); cfg.spawn(runtest).unwrap(); -@@ -1531,17 +1531,8 @@ pub fn run_test( - // Benchmarks aren't expected to panic, so we run them all in-process. - crate::bench::benchmark(desc, monitor_ch, opts.nocapture, benchfn); - } -- DynTestFn(f) => { -- match strategy { -- RunStrategy::InProcess => (), -- _ => panic!("Cannot run dynamic test fn out-of-process"), -- }; -- run_test_inner( -- desc, -- monitor_ch, -- Box::new(move || __rust_begin_short_backtrace(f)), -- test_run_opts, -- ); -+ DynTestFn(_f) => { -+ unimplemented!(); - } - StaticTestFn(f) => run_test_inner( - desc, -@@ -1604,10 +1592,10 @@ fn get_result_from_exit_code(desc: &TestDesc, code: i32) -> TestResult { - fn run_test_in_process( - desc: TestDesc, - nocapture: bool, - report_time: bool, -- testfn: Box, -+ testfn: Box, - monitor_ch: Sender, - time_opts: Option, - ) { - // Buffer for capturing standard I/O - let data = Arc::new(Mutex::new(Vec::new())); -@@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc, - }; - - let start = report_time.then(Instant::now); -- let result = catch_unwind(AssertUnwindSafe(testfn)); -+ let result = Ok::<(), Box>(testfn()); - let exec_time = start.map(|start| { - let duration = start.elapsed(); - TestExecTime(duration) -@@ -1688,7 +1676,7 @@ fn spawn_test_subprocess(desc: TestDesc, report_time: bool, monitor_ch: Sender) -> ! { -+fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box) -> ! { - let builtin_panic_hook = panic::take_hook(); - let record_result = Arc::new(move |panic_info: Option<&'_ PanicInfo<'_>>| { - let test_result = match panic_info { -- 2.20.1 diff --git a/patches/0018-Add-FnBox-back.patch b/patches/0018-Add-FnBox-back.patch deleted file mode 100644 index 12a4fbf4425e1..0000000000000 --- a/patches/0018-Add-FnBox-back.patch +++ /dev/null @@ -1,174 +0,0 @@ -From 8617310c3c9e192080df6a0c7b4835d3f02e27b9 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Fri, 1 Nov 2019 20:58:30 +0100 -Subject: [PATCH] Add FnBox back - ---- - src/liballoc/boxed.rs | 13 +++++++++++++ - src/libstd/prelude/v1.rs | 2 +- - src/libstd/sys/cloudabi/thread.rs | 2 +- - src/libstd/sys/hermit/thread.rs | 4 ++-- - src/libstd/sys/unix/thread.rs | 4 ++-- - src/libstd/sys_common/at_exit_imp.rs | 6 +++--- - src/libstd/sys_common/mod.rs | 2 +- - src/libstd/sys_common/thread.rs | 2 +- - src/libstd/thread/mod.rs | 2 +- - 9 files changed, 25 insertions(+), 12 deletions(-) - -diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs -index ef9b648..e32b870 100644 ---- a/src/liballoc/boxed.rs -+++ b/src/liballoc/boxed.rs -@@ -1079,3 +1079,16 @@ impl Future for Box { - F::poll(Pin::new(&mut *self), cx) - } - } -+ -+#[stable(feature = "rust1", since = "1.0.0")] -+pub trait FnBox: FnOnce { -+ #[stable(feature = "rust1", since = "1.0.0")] -+ extern "rust-call" fn call_box(self: Box, args: A) -> Self::Output; -+} -+ -+#[stable(feature = "rust1", since = "1.0.0")] -+impl> FnBox for F { -+ extern "rust-call" fn call_box(self: Box, args: A) -> Self::Output { -+ >::call_once(*self, args) -+ } -+} -diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs -index 3e4cf91..1f50eb3 100644 ---- a/src/libstd/prelude/v1.rs -+++ b/src/libstd/prelude/v1.rs -@@ -94,6 +94,6 @@ pub use core::prelude::v1::{ - #[stable(feature = "rust1", since = "1.0.0")] - #[doc(no_inline)] --pub use crate::boxed::Box; -+pub use crate::boxed::{Box, FnBox}; - #[stable(feature = "rust1", since = "1.0.0")] - #[doc(no_inline)] - pub use crate::string::{String, ToString}; -diff --git a/src/libstd/sys/cloudabi/thread.rs b/src/libstd/sys/cloudabi/thread.rs -index 240b6ea..6f71c6b 100644 ---- a/src/libstd/sys/cloudabi/thread.rs -+++ b/src/libstd/sys/cloudabi/thread.rs -@@ -21,7 +21,7 @@ unsafe impl Sync for Thread {} - - impl Thread { - // unsafe: see thread::Builder::spawn_unchecked for safety requirements -- pub unsafe fn new(stack: usize, p: Box) -> io::Result { -+ pub unsafe fn new(stack: usize, p: Box) -> io::Result { - let p = box p; - let mut native: libc::pthread_t = mem::zeroed(); - let mut attr: libc::pthread_attr_t = mem::zeroed(); -diff --git a/src/libstd/sys/hermit/thread.rs b/src/libstd/sys/hermit/thread.rs -index 99a9c83..b8bc392 100644 ---- a/src/libstd/sys/hermit/thread.rs -+++ b/src/libstd/sys/hermit/thread.rs -@@ -44,9 +44,9 @@ unsafe impl Sync for Thread {} - pub const DEFAULT_MIN_STACK_SIZE: usize = 262144; - - impl Thread { - pub unsafe fn new_with_coreid( - _stack: usize, -- p: Box, -+ p: Box, - core_id: isize, - ) -> io::Result { - let p = box p; -@@ -67,7 +67,7 @@ impl Thread { - } - } - -- pub unsafe fn new(stack: usize, p: Box) -> io::Result { -+ pub unsafe fn new(stack: usize, p: Box) -> io::Result { - Thread::new_with_coreid(stack, p, -1 /* = no specific core */) - } - -diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs -index 143cf2f..a6e8faf 100644 ---- a/src/libstd/sys/unix/thread.rs -+++ b/src/libstd/sys/unix/thread.rs -@@ -38,8 +38,8 @@ unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t, - - impl Thread { - // unsafe: see thread::Builder::spawn_unchecked for safety requirements -- pub unsafe fn new(stack: usize, p: Box) -> io::Result { -+ pub unsafe fn new(stack: usize, p: Box) -> io::Result { -- panic!("Warning: Threads are not yet fully supported, because cranelift doesn't support atomics."); -+ println!("Spawned thread"); - - let p = box p; - let mut native: libc::pthread_t = mem::zeroed(); -diff --git a/src/libstd/sys_common/at_exit_imp.rs b/src/libstd/sys_common/at_exit_imp.rs -index cdb72ee..e523333 100644 ---- a/src/libstd/sys_common/at_exit_imp.rs -+++ b/src/libstd/sys_common/at_exit_imp.rs -@@ -6,7 +6,7 @@ use crate::mem; - use crate::ptr; - use crate::sys_common::mutex::Mutex; - --type Queue = Vec>; -+type Queue = Vec>; - - // NB these are specifically not types from `std::sync` as they currently rely - // on poisoning and this module needs to operate at a lower level than requiring -@@ -53,14 +53,14 @@ pub fn cleanup() { - let queue: Box = Box::from_raw(queue); - for to_run in *queue { - // We are not holding any lock, so reentrancy is fine. -- to_run(); -+ to_run.call_box(()); - } - } - } - } - } - --pub fn push(f: Box) -> bool { -+pub fn push(f: Box) -> bool { - unsafe { - let _guard = LOCK.lock(); - if init() { -diff --git a/src/libstd/sys_common/mod.rs b/src/libstd/sys_common/mod.rs -index 7a0bcd0..668bef2 100644 ---- a/src/libstd/sys_common/mod.rs -+++ b/src/libstd/sys_common/mod.rs -@@ -113,7 +113,7 @@ pub trait FromInner { - /// closure will be run once the main thread exits. Returns `Err` to indicate - /// that the closure could not be registered, meaning that it is not scheduled - /// to be run. --pub fn at_exit(f: F) -> Result<(), ()> { -+pub fn at_exit(f: F) -> Result<(), ()> { - if at_exit_imp::push(Box::new(f)) { Ok(()) } else { Err(()) } - } - -diff --git a/src/libstd/sys_common/thread.rs b/src/libstd/sys_common/thread.rs -index c638be9..5c18a18 100644 ---- a/src/libstd/sys_common/thread.rs -+++ b/src/libstd/sys_common/thread.rs -@@ -10,7 +10,7 @@ pub unsafe fn start_thread(main: *mut u8) { - let _handler = stack_overflow::Handler::new(); - - // Finally, let's run some code. -- Box::from_raw(main as *mut Box)() -+ Box::from_raw(main as *mut Box).call_box(()) - } - - pub fn min_stack() -> usize { -diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs -index 0ffa6ac..4a3e3d6 100644 ---- a/src/libstd/thread/mod.rs -+++ b/src/libstd/thread/mod.rs -@@ -485,7 +485,7 @@ impl Builder { - // returning. - native: Some(imp::Thread::new( - stack_size, -- mem::transmute::, Box>(Box::new( -+ mem::transmute::, Box>(Box::new( - main, - )), - )?), --- -2.20.1 - diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 230cba3a93430..0f62efea632de 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -288,7 +288,7 @@ fn local_place<'tcx>( fx.local_map[&local] } -pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block: Block) { +pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block: Block, should_codegen_locals: bool) { let ssa_analyzed = crate::analyze::analyze(fx); #[cfg(debug_assertions)] @@ -405,13 +405,17 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block } } - for local in fx.mir.vars_and_temps_iter() { - let ty = fx.monomorphize(&fx.mir.local_decls[local].ty); - let layout = fx.layout_of(ty); + // HACK should_codegen_locals required for the ``implement ` as FnOnce>::call_once` + // without `alloca``` hack in `base::trans_fn`. + if should_codegen_locals { + for local in fx.mir.vars_and_temps_iter() { + let ty = fx.monomorphize(&fx.mir.local_decls[local].ty); + let layout = fx.layout_of(ty); - let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; + let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; - local_place(fx, local, layout, is_ssa); + local_place(fx, local, layout, is_ssa); + } } fx.bcx diff --git a/src/base.rs b/src/base.rs index 4f369723dc43a..1d73c69dc001d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -57,14 +57,96 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( source_info_set: indexmap::IndexSet::new(), }; - if fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()) { - let entry_block = fx.bcx.create_block(); - fx.bcx.append_block_params_for_function_params(entry_block); - fx.bcx.switch_to_block(entry_block); + let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()); + let is_call_once_for_box = name.starts_with("_ZN83_$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$9call_once"); + + 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"); + } else if is_call_once_for_box { + // HACK implement ` as FnOnce>::call_once` without `alloca`. + tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block, false)); + fx.bcx.switch_to_block(fx.block_map[START_BLOCK]); + let bb_data = &fx.mir.basic_blocks()[START_BLOCK]; + let destination = match &bb_data.terminator().kind { + TerminatorKind::Call { + func, + args, + destination, + cleanup: _, + from_hir_call: _, + } => { + assert_eq!(args.len(), 2); + + let closure_arg = Local::new(1); + let closure_local = args[0].place().unwrap().as_local().unwrap(); + assert_eq!(fx.mir.local_decls[closure_local].ty, fx.mir.local_decls[closure_arg].ty.builtin_deref(true).unwrap().ty); + let closure_deref = fx.local_map[&closure_arg].place_deref(&mut fx); + fx.local_map.insert(closure_local, closure_deref); + + let args_arg = Local::new(2); + let args_local = args[1].place().unwrap().as_local().unwrap(); + assert_eq!(fx.mir.local_decls[args_local].ty, fx.mir.local_decls[args_arg].ty); + fx.local_map.insert(args_local, fx.local_map[&args_arg]); + + fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( + &mut fx, + bb_data.terminator().source_info.span, + func, + args, + destination, + )); + destination.map(|(_ret_place, ret_block)| ret_block) + } + _ => unreachable!(), + }; + + let destination = if let Some(destination) = destination { + fx.bcx.switch_to_block(fx.block_map[destination]); + let bb_data = &fx.mir.basic_blocks()[destination]; + match &bb_data.terminator().kind { + TerminatorKind::Call { + func, + args, + destination, + cleanup: _, + from_hir_call: _, + } => { + match destination { + Some((ret_place, _ret_block)) => { + fx.local_map.insert(ret_place.as_local().unwrap(), CPlace::no_place(fx.layout_of(fx.tcx.mk_unit()))); + } + None => {} + } + + assert_eq!(args.len(), 1); + fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( + &mut fx, + bb_data.terminator().source_info.span, + func, + args, + destination, + )); + destination.map(|(_ret_place, ret_block)| ret_block) + } + _ => unreachable!(), + } + } else { + None + }; + + if let Some(destination) = destination { + fx.bcx.switch_to_block(fx.block_map[destination]); + let bb_data = &fx.mir.basic_blocks()[destination]; + match &bb_data.terminator().kind { + TerminatorKind::Return => crate::abi::codegen_return(&mut fx), + _ => unreachable!(), + } + } } else { tcx.sess.time("codegen clif ir", || { - tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block)); + tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block, true)); codegen_fn_content(&mut fx); }); } From 8878d0079402d2cc0a0db731da71f18cd4d1880a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 10 Mar 2020 20:51:38 +0100 Subject: [PATCH 1170/1566] Rustup to rustc 1.43.0-nightly (3dbade652 2020-03-09) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 076504e39377e..c1c2521f63d00 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-07 +nightly-2020-03-10 From c5b5b2b702f9d2847e088d0e9e73fea1914793c5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 10 Mar 2020 20:53:05 +0100 Subject: [PATCH 1171/1566] Don't disable multithreading in libtest --- patches/0017-Fix-libtest-compilation.patch | 24 ---------------------- 1 file changed, 24 deletions(-) delete mode 100644 patches/0017-Fix-libtest-compilation.patch diff --git a/patches/0017-Fix-libtest-compilation.patch b/patches/0017-Fix-libtest-compilation.patch deleted file mode 100644 index 5998c26a4902f..0000000000000 --- a/patches/0017-Fix-libtest-compilation.patch +++ /dev/null @@ -1,24 +0,0 @@ -From e06143d3373293d0490df482261cd4a842f1a5c5 Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Thu, 3 Oct 2019 16:51:34 +0200 -Subject: [PATCH] Fix libtest compilation - ---- - src/libtest/lib.rs | 28 ++++++++-------------------- - 1 file changed, 8 insertions(+), 20 deletions(-) - -diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs -index 8b76080..9e65de2 100644 ---- a/src/libtest/lib.rs -+++ b/src/libtest/lib.rs -@@ -1509,7 +1509,7 @@ pub fn run_test( - // If the platform is single-threaded we're just going to run - // the test synchronously, regardless of the concurrency - // level. -- let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32"); -+ let supports_threads = false; - if concurrency == Concurrent::Yes && supports_threads { - let cfg = thread::Builder::new().name(name.as_slice().to_owned()); - cfg.spawn(runtest).unwrap(); --- -2.20.1 From 1e074106e60e6b3108c7757a70c1e72be385d3ba Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 11 Mar 2020 14:08:54 +0100 Subject: [PATCH 1172/1566] Don't disable inline asm in hint::spin_loop --- ...3-Disable-inline-assembly-in-libcore.patch | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 patches/0003-Disable-inline-assembly-in-libcore.patch diff --git a/patches/0003-Disable-inline-assembly-in-libcore.patch b/patches/0003-Disable-inline-assembly-in-libcore.patch deleted file mode 100644 index 5174e4d08e950..0000000000000 --- a/patches/0003-Disable-inline-assembly-in-libcore.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 50ce3e454d5721cb534a9e9bb73c82246b930bab Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 19 Jan 2019 11:46:43 +0100 -Subject: [PATCH] Disable inline assembly in libcore - ---- - src/libcore/hint.rs | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs -index ad5a207..04712b8 100644 ---- a/src/libcore/hint.rs -+++ b/src/libcore/hint.rs -@@ -62,6 +62,7 @@ pub unsafe fn unreachable_unchecked() -> ! { - #[inline] - #[unstable(feature = "renamed_spin_loop", issue = "55002")] - pub fn spin_loop() { -+ /* - #[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse2"))] - { - #[cfg(target_arch = "x86")] -@@ -71,4 +72,5 @@ pub fn spin_loop() { - unsafe { crate::arch::arm::__yield() }; - } - } -+ */ - } --- -2.17.2 (Apple Git-113) From e4f1f3db27a052dac6f9e767a773f3ed94ee5bb0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 11 Mar 2020 15:18:01 +0100 Subject: [PATCH 1173/1566] Implement incremental caching of object files --- src/driver.rs | 221 +++++++++++++++++++++++++++++++++++++++----------- src/lib.rs | 16 +++- 2 files changed, 187 insertions(+), 50 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 29e498db75006..1ce2e1ce7733c 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -2,9 +2,11 @@ use std::any::Any; use std::ffi::CString; use std::os::raw::{c_char, c_int}; +use rustc::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; use rustc::middle::cstore::EncodedMetadata; -use rustc::mir::mono::{Linkage as RLinkage, Visibility}; +use rustc::mir::mono::{CodegenUnit, Linkage as RLinkage, Visibility}; use rustc::session::config::{DebugInfo, OutputType}; +use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; @@ -172,20 +174,32 @@ fn run_aot( tcx: TyCtxt<'_>, metadata: EncodedMetadata, need_metadata_module: bool, -) -> Box { - let new_module = |name: String| { +) -> Box<(CodegenResults, FxHashMap)> { + let mut work_products = FxHashMap::default(); + + fn new_module(tcx: TyCtxt<'_>, name: String) -> Module { let module = crate::backend::make_module(tcx.sess, name); assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); module }; + struct ModuleCodegenResult(CompiledModule, Option<(WorkProductId, WorkProduct)>); + + use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; + + impl HashStable for ModuleCodegenResult { + fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { + // do nothing + } + } + fn emit_module( tcx: TyCtxt<'_>, name: String, kind: ModuleKind, mut module: Module, debug: Option, - ) -> CompiledModule + ) -> ModuleCodegenResult where B::Product: Emit + WriteDebugInfo, { module.finalize_definitions(); @@ -200,54 +214,146 @@ fn run_aot( .temp_path(OutputType::Object, Some(&name)); let obj = product.emit(); std::fs::write(&tmp_file, obj).unwrap(); - CompiledModule { - name, - kind, - object: Some(tmp_file), - bytecode: None, - bytecode_compressed: None, - } + + let work_product = if std::env::var("CG_CLIF_INCR_CACHE").is_ok() { + rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( + tcx.sess, + &name, + &[(WorkProductFileKind::Object, tmp_file.clone())], + ) + } else { + None + }; + + ModuleCodegenResult( + CompiledModule { + name, + kind, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + }, + work_product, + ) }; let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let modules = time(tcx.sess, "codegen mono items", move || { + if tcx.dep_graph.is_fully_enabled() { + for cgu in &*cgus { + tcx.codegen_unit(cgu.name()); + } + } + + let modules = time(tcx.sess, "codegen mono items", || { cgus.iter().map(|cgu| { - let mono_items = cgu.items_in_deterministic_order(tcx); + let cgu_reuse = determine_cgu_reuse(tcx, cgu); + tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse); + + match cgu_reuse { + CguReuse::No => {} + CguReuse::PreLto => { + let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); + let mut object = None; + let work_product = cgu.work_product(tcx); + for (kind, saved_file) in &work_product.saved_files { + let obj_out = match kind { + WorkProductFileKind::Object => { + let path = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); + object = Some(path.clone()); + path + } + WorkProductFileKind::Bytecode | WorkProductFileKind::BytecodeCompressed => { + panic!("cg_clif doesn't use bytecode"); + } + }; + let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); + if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { + tcx.sess.err(&format!( + "unable to copy {} to {}: {}", + source_file.display(), + obj_out.display(), + err + )); + } + } + + work_products.insert(cgu.work_product_id(), work_product); - let mut module = new_module(cgu.name().as_str().to_string()); + return CompiledModule { + name: cgu.name().to_string(), + kind: ModuleKind::Regular, + object, + bytecode: None, + bytecode_compressed: None, + }; + } + CguReuse::PostLto => unreachable!(), + } + + let dep_node = cgu.codegen_dep_node(tcx); + let (ModuleCodegenResult(module, work_product), _) = + tcx.dep_graph.with_task(dep_node, tcx, cgu.name(), module_codegen, rustc::dep_graph::hash_result); - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { - let debug = DebugContext::new( + fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodegenResult { + let cgu = tcx.codegen_unit(cgu_name); + let mono_items = cgu.items_in_deterministic_order(tcx); + + let mut module = new_module(tcx, cgu_name.as_str().to_string()); + + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let debug = DebugContext::new( + tcx, + module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) + } else { + None + }; + + codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + + emit_module( tcx, - module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) - } else { - None - }; + cgu.name().as_str().to_string(), + ModuleKind::Regular, + module, + debug, + ) + } - codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + if let Some((id, product)) = work_product { + work_products.insert(id, product); + } - emit_module( - tcx, - cgu.name().as_str().to_string(), - ModuleKind::Regular, - module, - debug, - ) + module }).collect::>() }); tcx.sess.abort_if_errors(); - let mut allocator_module = new_module("allocator_shim".to_string()); + let mut allocator_module = new_module(tcx, "allocator_shim".to_string()); let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module); + let allocator_module = if created_alloc_shim { + let ModuleCodegenResult(module, work_product) = emit_module( + tcx, + "allocator_shim".to_string(), + ModuleKind::Allocator, + allocator_module, + None, + ); + if let Some((id, product)) = work_product { + work_products.insert(id, product); + } + Some(module) + } else { + None + }; + rustc_incremental::assert_dep_graph(tcx); rustc_incremental::save_dep_graph(tcx); - rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); let metadata_module = if need_metadata_module { let _timer = tcx.prof.generic_activity("codegen crate metadata"); @@ -284,27 +390,17 @@ fn run_aot( None }; - Box::new(CodegenResults { + Box::new((CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules, - allocator_module: if created_alloc_shim { - Some(emit_module( - tcx, - "allocator_shim".to_string(), - ModuleKind::Allocator, - allocator_module, - None, - )) - } else { - None - }, + allocator_module, metadata_module, crate_hash: tcx.crate_hash(LOCAL_CRATE), metadata, windows_subsystem: None, // Windows is not yet supported linker_info: LinkerInfo::new(tcx), crate_info: CrateInfo::new(tcx), - }) + }, work_products)) } fn codegen_mono_items<'tcx>( @@ -402,3 +498,36 @@ fn time(sess: &Session, name: &'static str, f: impl FnOnce() -> R) -> R { println!("[{}] end time: {:?}", name, after - before); res } + +// Adapted from https://github.com/rust-lang/rust/blob/303d8aff6092709edd4dbd35b1c88e9aa40bf6d8/src/librustc_codegen_ssa/base.rs#L922-L953 +fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse { + if !tcx.dep_graph.is_fully_enabled() { + return CguReuse::No; + } + + let work_product_id = &cgu.work_product_id(); + if tcx.dep_graph.previous_work_product(work_product_id).is_none() { + // We don't have anything cached for this CGU. This can happen + // if the CGU did not exist in the previous session. + return CguReuse::No; + } + + // Try to mark the CGU as green. If it we can do so, it means that nothing + // affecting the LLVM module has changed and we can re-use a cached version. + // If we compile with any kind of LTO, this means we can re-use the bitcode + // of the Pre-LTO stage (possibly also the Post-LTO version but we'll only + // know that later). If we are not doing LTO, there is only one optimized + // version of each module, so we re-use that. + let dep_node = cgu.codegen_dep_node(tcx); + assert!( + !tcx.dep_graph.dep_node_exists(&dep_node), + "CompileCodegenUnit dep-node for CGU `{}` already exists before marking.", + cgu.name() + ); + + if tcx.dep_graph.try_mark_green(tcx, &dep_node).is_some() { + CguReuse::PreLto + } else { + CguReuse::No + } +} diff --git a/src/lib.rs b/src/lib.rs index 85e0fb047e4da..81111b776d676 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ extern crate rustc_ast; use std::any::Any; -use rustc::dep_graph::DepGraph; +use rustc::dep_graph::{DepGraph, WorkProduct, WorkProductId}; use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc::session::config::OutputFilenames; use rustc::ty::query::Providers; @@ -216,10 +216,16 @@ impl CodegenBackend for CraneliftCodegenBackend { fn join_codegen( &self, ongoing_codegen: Box, - _sess: &Session, - _dep_graph: &DepGraph, + sess: &Session, + dep_graph: &DepGraph, ) -> Result, ErrorReported> { - Ok(ongoing_codegen) + let (codegen_results, work_products) = *ongoing_codegen.downcast::<(CodegenResults, FxHashMap)>().unwrap(); + + sess.time("serialize_work_products", move || { + rustc_incremental::save_work_product_index(sess, &dep_graph, work_products) + }); + + Ok(Box::new(codegen_results)) } fn link( @@ -247,6 +253,8 @@ impl CodegenBackend for CraneliftCodegenBackend { ); }); + rustc_incremental::finalize_session_directory(sess, codegen_results.crate_hash); + Ok(()) } } From 92ff6c2930a1e2a2d348b2bf08d1286b79cf416a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 11 Mar 2020 19:54:18 +0100 Subject: [PATCH 1174/1566] Mention CG_CLIF_INCR_CACHE in the readme --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index ef30baac390f5..305a7ac991bbb 100644 --- a/Readme.md +++ b/Readme.md @@ -18,6 +18,7 @@ $ ./test.sh --release ### Cargo ```bash +$ export CG_CLIF_INCR_CACHE=1 # Enable caching of object files in the incremental cache $ CHANNEL="release" $cg_clif_dir/cargo.sh run ``` @@ -26,6 +27,7 @@ If you compiled cg_clif in debug mode you should use `CHANNEL="debug"` instead o ### Rustc ```bash +$ export CG_CLIF_INCR_CACHE=1 # Enable caching of object files in the incremental cache $ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs ``` From 198037119520d8cccafdc1fd511164c63d741aed Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:17:19 +0100 Subject: [PATCH 1175/1566] Better use of env vars --- Readme.md | 16 ++++++++++++++-- config.sh | 3 +++ src/atomic_shim.rs | 2 +- src/driver.rs | 29 +++++++++++++++++------------ test.sh | 4 ++-- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Readme.md b/Readme.md index 305a7ac991bbb..27adb7d3e4825 100644 --- a/Readme.md +++ b/Readme.md @@ -18,7 +18,6 @@ $ ./test.sh --release ### Cargo ```bash -$ export CG_CLIF_INCR_CACHE=1 # Enable caching of object files in the incremental cache $ CHANNEL="release" $cg_clif_dir/cargo.sh run ``` @@ -27,10 +26,23 @@ If you compiled cg_clif in debug mode you should use `CHANNEL="debug"` instead o ### Rustc ```bash -$ export CG_CLIF_INCR_CACHE=1 # Enable caching of object files in the incremental cache $ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs ``` +## Env vars + +
+
CG_CLIF_JIT
+
Enable JIT mode to immediately run a program instead of writing an executable file.
+
CG_CLIF_JIT_ARGS
+
When JIT mode is enable pass these arguments to the program.
+
CG_CLIF_INCR_CACHE_DISABLE
+
Don't cache object files in the incremental cache. Useful during development of cg_clif + to make it possible to use incremental mode for all analyses performed by rustc without caching + object files when their content should have been changed by a change to cg_clif.
+
CG_CLIF_DISPLAY_CG_TIME
+
Display the time it took to perform codegen for a crate
+
## Not yet supported diff --git a/config.sh b/config.sh index 6a3cc715119cf..e2534da89e152 100644 --- a/config.sh +++ b/config.sh @@ -24,3 +24,6 @@ export RUSTC_LOG=warn # display metadata load errors export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib" export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH + +export CG_CLIF_DISPLAY_CG_TIME=1 +export CG_CLIF_INCR_CACHE_DISABLED=1 diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 17922e7bbcded..83c1b164fc122 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -9,7 +9,7 @@ use crate::prelude::*; pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; pub fn init_global_lock(module: &mut Module, bcx: &mut FunctionBuilder<'_>) { - if std::env::var("SHOULD_RUN").is_ok () { + if std::env::var("CG_CLIF_JIT").is_ok () { // When using JIT, dylibs won't find the __cg_clif_global_atomic_mutex data object defined here, // so instead define it in the cg_clif dylib. diff --git a/src/driver.rs b/src/driver.rs index 1ce2e1ce7733c..2fcd5e2932ca2 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -21,7 +21,7 @@ pub fn codegen_crate( ) -> Box { tcx.sess.abort_if_errors(); - if std::env::var("SHOULD_RUN").is_ok() + if std::env::var("CG_CLIF_JIT").is_ok() && tcx.sess.crate_types.get().contains(&CrateType::Executable) { #[cfg(not(target_arch = "wasm32"))] @@ -90,12 +90,12 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); - println!("Rustc codegen cranelift will JIT run the executable, because the SHOULD_RUN env var is set"); + println!("Rustc codegen cranelift will JIT run the executable, because the CG_CLIF_JIT env var is set"); let f: extern "C" fn(c_int, *const *const c_char) -> c_int = unsafe { ::std::mem::transmute(finalized_main) }; - let args = ::std::env::var("JIT_ARGS").unwrap_or_else(|_| String::new()); + let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new()); let args = args .split(" ") .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) @@ -215,14 +215,14 @@ fn run_aot( let obj = product.emit(); std::fs::write(&tmp_file, obj).unwrap(); - let work_product = if std::env::var("CG_CLIF_INCR_CACHE").is_ok() { + let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { + None + } else { rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( tcx.sess, &name, &[(WorkProductFileKind::Object, tmp_file.clone())], ) - } else { - None }; ModuleCodegenResult( @@ -251,6 +251,7 @@ fn run_aot( tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse); match cgu_reuse { + _ if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() => {} CguReuse::No => {} CguReuse::PreLto => { let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); @@ -491,12 +492,16 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( } fn time(sess: &Session, name: &'static str, f: impl FnOnce() -> R) -> R { - println!("[{}] start", name); - let before = std::time::Instant::now(); - let res = sess.time(name, f); - let after = std::time::Instant::now(); - println!("[{}] end time: {:?}", name, after - before); - res + if std::env::var("CG_CLIF_DISPLAY_CG_TIME").is_ok() { + println!("[{}] start", name); + let before = std::time::Instant::now(); + let res = sess.time(name, f); + let after = std::time::Instant::now(); + println!("[{}] end time: {:?}", name, after - before); + res + } else { + sess.time(name, f) + } } // Adapted from https://github.com/rust-lang/rust/blob/303d8aff6092709edd4dbd35b1c88e9aa40bf6d8/src/librustc_codegen_ssa/base.rs#L922-L953 diff --git a/test.sh b/test.sh index 78407ffbe50b3..bc4c807cbf286 100755 --- a/test.sh +++ b/test.sh @@ -22,7 +22,7 @@ echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib echo "[JIT] mini_core_hello_world" -JIT_ARGS="abc bcd" SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit +CG_CLIF_JIT=1 CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit echo "[AOT] mini_core_hello_world" $RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g @@ -41,7 +41,7 @@ $RUSTC example/alloc_example.rs --crate-type bin ./target/out/alloc_example echo "[JIT] std_example" -SHOULD_RUN=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs +CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs echo "[AOT] dst_field_align" # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. From 7c16ea63f6e2e230ca7f3893ead23ad1bb46b82a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:20:36 +0100 Subject: [PATCH 1176/1566] [README] Threads are supported --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 27adb7d3e4825..f5ce2fff9ce1f 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # WIP Cranelift codegen backend for rust -> ⚠⚠⚠ Threads and certain kinds of FFI don't work yet. ⚠⚠⚠ +> ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠ ## Building From f7666e9c2bf733c4f8f3271a3ab2a6e184396972 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:25:35 +0100 Subject: [PATCH 1177/1566] Fix typo found by @lqd --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index f5ce2fff9ce1f..0f916e0463314 100644 --- a/Readme.md +++ b/Readme.md @@ -36,7 +36,7 @@ $ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_cod
Enable JIT mode to immediately run a program instead of writing an executable file.
CG_CLIF_JIT_ARGS
When JIT mode is enable pass these arguments to the program.
-
CG_CLIF_INCR_CACHE_DISABLE
+
CG_CLIF_INCR_CACHE_DISABLED
Don't cache object files in the incremental cache. Useful during development of cg_clif to make it possible to use incremental mode for all analyses performed by rustc without caching object files when their content should have been changed by a change to cg_clif.
From dfd365e060b610dd996de570fce3d91bf3f57a26 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:40:42 +0100 Subject: [PATCH 1178/1566] Display crate name in the "codegen mono items" time message --- src/driver.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 2fcd5e2932ca2..e56794bc4a946 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -78,7 +78,7 @@ fn run_jit(tcx: TyCtxt<'_>) -> ! { .into_iter() .collect::>(); - time(tcx.sess, "codegen mono items", || { + time(tcx, "codegen mono items", || { codegen_mono_items(tcx, &mut jit_module, None, mono_items); }); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); @@ -245,7 +245,7 @@ fn run_aot( } } - let modules = time(tcx.sess, "codegen mono items", || { + let modules = time(tcx, "codegen mono items", || { cgus.iter().map(|cgu| { let cgu_reuse = determine_cgu_reuse(tcx, cgu); tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse); @@ -491,16 +491,16 @@ fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( } } -fn time(sess: &Session, name: &'static str, f: impl FnOnce() -> R) -> R { +fn time(tcx: TyCtxt<'_>, name: &'static str, f: impl FnOnce() -> R) -> R { if std::env::var("CG_CLIF_DISPLAY_CG_TIME").is_ok() { - println!("[{}] start", name); + println!("[{:<30}: {}] start", tcx.crate_name(LOCAL_CRATE), name); let before = std::time::Instant::now(); - let res = sess.time(name, f); + let res = tcx.sess.time(name, f); let after = std::time::Instant::now(); - println!("[{}] end time: {:?}", name, after - before); + println!("[{:<30}: {}] end time: {:?}", tcx.crate_name(LOCAL_CRATE), name, after - before); res } else { - sess.time(name, f) + tcx.sess.time(name, f) } } From 1a0d1ed9df4ae0f8f54d7bd222ced683a84bdd34 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:42:01 +0100 Subject: [PATCH 1179/1566] Move driver.rs --- src/{driver.rs => driver/mod.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{driver.rs => driver/mod.rs} (100%) diff --git a/src/driver.rs b/src/driver/mod.rs similarity index 100% rename from src/driver.rs rename to src/driver/mod.rs From 03240d89ccab3327a348a2abcbcebf61edbd5293 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:44:27 +0100 Subject: [PATCH 1180/1566] Move jit code to driver/jit.rs --- src/driver/jit.rs | 141 +++++++++++++++++++++++++++++++++++++++++++++ src/driver/mod.rs | 143 ++-------------------------------------------- 2 files changed, 145 insertions(+), 139 deletions(-) create mode 100644 src/driver/jit.rs diff --git a/src/driver/jit.rs b/src/driver/jit.rs new file mode 100644 index 0000000000000..00bc00428412a --- /dev/null +++ b/src/driver/jit.rs @@ -0,0 +1,141 @@ +use std::ffi::CString; +use std::os::raw::{c_char, c_int}; + +use rustc_codegen_ssa::CrateInfo; + +use crate::prelude::*; + +pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { + use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; + + // Rustc opens us without the RTLD_GLOBAL flag, so __cg_clif_global_atomic_mutex will not be + // exported. We fix this by opening ourself again as global. + // FIXME remove once atomic_shim is gone + let cg_dylib = std::ffi::OsString::from(&tcx.sess.opts.debugging_opts.codegen_backend.as_ref().unwrap()); + std::mem::forget(libloading::os::unix::Library::open(Some(cg_dylib), libc::RTLD_NOW | libc::RTLD_GLOBAL).unwrap()); + + + let imported_symbols = load_imported_symbols_for_jit(tcx); + + let mut jit_builder = SimpleJITBuilder::with_isa( + crate::build_isa(tcx.sess, false), + cranelift_module::default_libcall_names(), + ); + jit_builder.symbols(imported_symbols); + let mut jit_module: Module = Module::new(jit_builder); + assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); + + let sig = Signature { + params: vec![ + AbiParam::new(jit_module.target_config().pointer_type()), + AbiParam::new(jit_module.target_config().pointer_type()), + ], + returns: vec![AbiParam::new( + jit_module.target_config().pointer_type(), /*isize*/ + )], + call_conv: CallConv::triple_default(&crate::target_triple(tcx.sess)), + }; + let main_func_id = jit_module + .declare_function("main", Linkage::Import, &sig) + .unwrap(); + + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let mono_items = cgus + .iter() + .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) + .flatten() + .collect::>() + .into_iter() + .collect::>(); + + super::time(tcx, "codegen mono items", || { + super::codegen_mono_items(tcx, &mut jit_module, None, mono_items); + }); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); + crate::allocator::codegen(tcx, &mut jit_module); + + jit_module.finalize_definitions(); + + tcx.sess.abort_if_errors(); + + let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); + + println!("Rustc codegen cranelift will JIT run the executable, because the CG_CLIF_JIT env var is set"); + + let f: extern "C" fn(c_int, *const *const c_char) -> c_int = + unsafe { ::std::mem::transmute(finalized_main) }; + + let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new()); + let args = args + .split(" ") + .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) + .map(|arg| CString::new(arg).unwrap()) + .collect::>(); + let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); + // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end + + let ret = f(args.len() as c_int, argv.as_ptr()); + + jit_module.finish(); + std::process::exit(ret); +} + +fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { + use rustc::middle::dependency_format::Linkage; + + let mut dylib_paths = Vec::new(); + + let crate_info = CrateInfo::new(tcx); + let formats = tcx.dependency_formats(LOCAL_CRATE); + let data = &formats + .iter() + .find(|(crate_type, _data)| *crate_type == CrateType::Executable) + .unwrap() + .1; + for &(cnum, _) in &crate_info.used_crates_dynamic { + let src = &crate_info.used_crate_source[&cnum]; + match data[cnum.as_usize() - 1] { + Linkage::NotLinked | Linkage::IncludedFromDylib => {} + Linkage::Static => { + let name = tcx.crate_name(cnum); + let mut err = tcx + .sess + .struct_err(&format!("Can't load static lib {}", name.as_str())); + err.note("rustc_codegen_cranelift can only load dylibs in JIT mode."); + err.emit(); + } + Linkage::Dynamic => { + dylib_paths.push(src.dylib.as_ref().unwrap().0.clone()); + } + } + } + + let mut imported_symbols = Vec::new(); + for path in dylib_paths { + use object::Object; + let lib = libloading::Library::new(&path).unwrap(); + let obj = std::fs::read(path).unwrap(); + let obj = object::File::parse(&obj).unwrap(); + imported_symbols.extend(obj.dynamic_symbols().filter_map(|(_idx, symbol)| { + let name = symbol.name().unwrap().to_string(); + if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { + return None; + } + let dlsym_name = if cfg!(target_os = "macos") { + // On macOS `dlsym` expects the name without leading `_`. + assert!(name.starts_with("_"), "{:?}", name); + &name[1..] + } else { + &name + }; + let symbol: libloading::Symbol<*const u8> = + unsafe { lib.get(dlsym_name.as_bytes()) }.unwrap(); + Some((name, *symbol)) + })); + std::mem::forget(lib) + } + + tcx.sess.abort_if_errors(); + + imported_symbols +} diff --git a/src/driver/mod.rs b/src/driver/mod.rs index e56794bc4a946..8e7d0742dc5a1 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,6 +1,4 @@ use std::any::Any; -use std::ffi::CString; -use std::os::raw::{c_char, c_int}; use rustc::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; use rustc::middle::cstore::EncodedMetadata; @@ -14,6 +12,9 @@ use crate::prelude::*; use crate::backend::{Emit, WriteDebugInfo}; +#[cfg(not(target_arch = "wasm32"))] +mod jit; + pub fn codegen_crate( tcx: TyCtxt<'_>, metadata: EncodedMetadata, @@ -25,7 +26,7 @@ pub fn codegen_crate( && tcx.sess.crate_types.get().contains(&CrateType::Executable) { #[cfg(not(target_arch = "wasm32"))] - let _: ! = run_jit(tcx); + let _: ! = jit::run_jit(tcx); #[cfg(target_arch = "wasm32")] panic!("jit not supported on wasm"); @@ -34,142 +35,6 @@ pub fn codegen_crate( run_aot(tcx, metadata, need_metadata_module) } -#[cfg(not(target_arch = "wasm32"))] -fn run_jit(tcx: TyCtxt<'_>) -> ! { - use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; - - // Rustc opens us without the RTLD_GLOBAL flag, so __cg_clif_global_atomic_mutex will not be - // exported. We fix this by opening ourself again as global. - // FIXME remove once atomic_shim is gone - let cg_dylib = std::ffi::OsString::from(&tcx.sess.opts.debugging_opts.codegen_backend.as_ref().unwrap()); - std::mem::forget(libloading::os::unix::Library::open(Some(cg_dylib), libc::RTLD_NOW | libc::RTLD_GLOBAL).unwrap()); - - - let imported_symbols = load_imported_symbols_for_jit(tcx); - - let mut jit_builder = SimpleJITBuilder::with_isa( - crate::build_isa(tcx.sess, false), - cranelift_module::default_libcall_names(), - ); - jit_builder.symbols(imported_symbols); - let mut jit_module: Module = Module::new(jit_builder); - assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); - - let sig = Signature { - params: vec![ - AbiParam::new(jit_module.target_config().pointer_type()), - AbiParam::new(jit_module.target_config().pointer_type()), - ], - returns: vec![AbiParam::new( - jit_module.target_config().pointer_type(), /*isize*/ - )], - call_conv: CallConv::triple_default(&crate::target_triple(tcx.sess)), - }; - let main_func_id = jit_module - .declare_function("main", Linkage::Import, &sig) - .unwrap(); - - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - let mono_items = cgus - .iter() - .map(|cgu| cgu.items_in_deterministic_order(tcx).into_iter()) - .flatten() - .collect::>() - .into_iter() - .collect::>(); - - time(tcx, "codegen mono items", || { - codegen_mono_items(tcx, &mut jit_module, None, mono_items); - }); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); - crate::allocator::codegen(tcx, &mut jit_module); - - jit_module.finalize_definitions(); - - tcx.sess.abort_if_errors(); - - let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); - - println!("Rustc codegen cranelift will JIT run the executable, because the CG_CLIF_JIT env var is set"); - - let f: extern "C" fn(c_int, *const *const c_char) -> c_int = - unsafe { ::std::mem::transmute(finalized_main) }; - - let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new()); - let args = args - .split(" ") - .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) - .map(|arg| CString::new(arg).unwrap()) - .collect::>(); - let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); - // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end - - let ret = f(args.len() as c_int, argv.as_ptr()); - - jit_module.finish(); - std::process::exit(ret); -} - -fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { - use rustc::middle::dependency_format::Linkage; - - let mut dylib_paths = Vec::new(); - - let crate_info = CrateInfo::new(tcx); - let formats = tcx.dependency_formats(LOCAL_CRATE); - let data = &formats - .iter() - .find(|(crate_type, _data)| *crate_type == CrateType::Executable) - .unwrap() - .1; - for &(cnum, _) in &crate_info.used_crates_dynamic { - let src = &crate_info.used_crate_source[&cnum]; - match data[cnum.as_usize() - 1] { - Linkage::NotLinked | Linkage::IncludedFromDylib => {} - Linkage::Static => { - let name = tcx.crate_name(cnum); - let mut err = tcx - .sess - .struct_err(&format!("Can't load static lib {}", name.as_str())); - err.note("rustc_codegen_cranelift can only load dylibs in JIT mode."); - err.emit(); - } - Linkage::Dynamic => { - dylib_paths.push(src.dylib.as_ref().unwrap().0.clone()); - } - } - } - - let mut imported_symbols = Vec::new(); - for path in dylib_paths { - use object::Object; - let lib = libloading::Library::new(&path).unwrap(); - let obj = std::fs::read(path).unwrap(); - let obj = object::File::parse(&obj).unwrap(); - imported_symbols.extend(obj.dynamic_symbols().filter_map(|(_idx, symbol)| { - let name = symbol.name().unwrap().to_string(); - if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { - return None; - } - let dlsym_name = if cfg!(target_os = "macos") { - // On macOS `dlsym` expects the name without leading `_`. - assert!(name.starts_with("_"), "{:?}", name); - &name[1..] - } else { - &name - }; - let symbol: libloading::Symbol<*const u8> = - unsafe { lib.get(dlsym_name.as_bytes()) }.unwrap(); - Some((name, *symbol)) - })); - std::mem::forget(lib) - } - - tcx.sess.abort_if_errors(); - - imported_symbols -} - fn run_aot( tcx: TyCtxt<'_>, metadata: EncodedMetadata, From 933ef94f6330e77127e8756e7db82bd67d424201 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:48:17 +0100 Subject: [PATCH 1181/1566] Move aot code to driver/aot.rs --- src/driver/aot.rs | 278 +++++++++++++++++++++++++++++++++++++++++++++ src/driver/mod.rs | 279 +--------------------------------------------- 2 files changed, 281 insertions(+), 276 deletions(-) create mode 100644 src/driver/aot.rs diff --git a/src/driver/aot.rs b/src/driver/aot.rs new file mode 100644 index 0000000000000..d87ab9d85ce0f --- /dev/null +++ b/src/driver/aot.rs @@ -0,0 +1,278 @@ +use rustc::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; +use rustc::middle::cstore::EncodedMetadata; +use rustc::mir::mono::CodegenUnit; +use rustc::session::config::{DebugInfo, OutputType}; +use rustc_session::cgu_reuse_tracker::CguReuse; +use rustc_codegen_ssa::back::linker::LinkerInfo; +use rustc_codegen_ssa::CrateInfo; + +use crate::prelude::*; + +use crate::backend::{Emit, WriteDebugInfo}; + +pub(super) fn run_aot( + tcx: TyCtxt<'_>, + metadata: EncodedMetadata, + need_metadata_module: bool, +) -> Box<(CodegenResults, FxHashMap)> { + let mut work_products = FxHashMap::default(); + + fn new_module(tcx: TyCtxt<'_>, name: String) -> Module { + let module = crate::backend::make_module(tcx.sess, name); + assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); + module + }; + + struct ModuleCodegenResult(CompiledModule, Option<(WorkProductId, WorkProduct)>); + + use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; + + impl HashStable for ModuleCodegenResult { + fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { + // do nothing + } + } + + fn emit_module( + tcx: TyCtxt<'_>, + name: String, + kind: ModuleKind, + mut module: Module, + debug: Option, + ) -> ModuleCodegenResult + where B::Product: Emit + WriteDebugInfo, + { + module.finalize_definitions(); + let mut product = module.finish(); + + if let Some(mut debug) = debug { + debug.emit(&mut product); + } + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(&name)); + let obj = product.emit(); + std::fs::write(&tmp_file, obj).unwrap(); + + let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { + None + } else { + rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( + tcx.sess, + &name, + &[(WorkProductFileKind::Object, tmp_file.clone())], + ) + }; + + ModuleCodegenResult( + CompiledModule { + name, + kind, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + }, + work_product, + ) + }; + + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + + if tcx.dep_graph.is_fully_enabled() { + for cgu in &*cgus { + tcx.codegen_unit(cgu.name()); + } + } + + let modules = super::time(tcx, "codegen mono items", || { + cgus.iter().map(|cgu| { + let cgu_reuse = determine_cgu_reuse(tcx, cgu); + tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse); + + match cgu_reuse { + _ if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() => {} + CguReuse::No => {} + CguReuse::PreLto => { + let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); + let mut object = None; + let work_product = cgu.work_product(tcx); + for (kind, saved_file) in &work_product.saved_files { + let obj_out = match kind { + WorkProductFileKind::Object => { + let path = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); + object = Some(path.clone()); + path + } + WorkProductFileKind::Bytecode | WorkProductFileKind::BytecodeCompressed => { + panic!("cg_clif doesn't use bytecode"); + } + }; + let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); + if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { + tcx.sess.err(&format!( + "unable to copy {} to {}: {}", + source_file.display(), + obj_out.display(), + err + )); + } + } + + work_products.insert(cgu.work_product_id(), work_product); + + return CompiledModule { + name: cgu.name().to_string(), + kind: ModuleKind::Regular, + object, + bytecode: None, + bytecode_compressed: None, + }; + } + CguReuse::PostLto => unreachable!(), + } + + let dep_node = cgu.codegen_dep_node(tcx); + let (ModuleCodegenResult(module, work_product), _) = + tcx.dep_graph.with_task(dep_node, tcx, cgu.name(), module_codegen, rustc::dep_graph::hash_result); + + fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodegenResult { + let cgu = tcx.codegen_unit(cgu_name); + let mono_items = cgu.items_in_deterministic_order(tcx); + + let mut module = new_module(tcx, cgu_name.as_str().to_string()); + + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let debug = DebugContext::new( + tcx, + module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) + } else { + None + }; + + super::codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + + emit_module( + tcx, + cgu.name().as_str().to_string(), + ModuleKind::Regular, + module, + debug, + ) + } + + if let Some((id, product)) = work_product { + work_products.insert(id, product); + } + + module + }).collect::>() + }); + + tcx.sess.abort_if_errors(); + + let mut allocator_module = new_module(tcx, "allocator_shim".to_string()); + let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module); + + let allocator_module = if created_alloc_shim { + let ModuleCodegenResult(module, work_product) = emit_module( + tcx, + "allocator_shim".to_string(), + ModuleKind::Allocator, + allocator_module, + None, + ); + if let Some((id, product)) = work_product { + work_products.insert(id, product); + } + Some(module) + } else { + None + }; + + rustc_incremental::assert_dep_graph(tcx); + rustc_incremental::save_dep_graph(tcx); + + let metadata_module = if need_metadata_module { + let _timer = tcx.prof.generic_activity("codegen crate metadata"); + let (metadata_cgu_name, tmp_file) = tcx.sess.time("write compressed metadata", || { + use rustc::mir::mono::CodegenUnitNameBuilder; + + let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); + let metadata_cgu_name = cgu_name_builder + .build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")) + .as_str() + .to_string(); + + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Metadata, Some(&metadata_cgu_name)); + + let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| { + crate::metadata::write_metadata(tcx, object); + }); + + std::fs::write(&tmp_file, obj).unwrap(); + + (metadata_cgu_name, tmp_file) + }); + + Some(CompiledModule { + name: metadata_cgu_name, + kind: ModuleKind::Metadata, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + }) + } else { + None + }; + + Box::new((CodegenResults { + crate_name: tcx.crate_name(LOCAL_CRATE), + modules, + allocator_module, + metadata_module, + crate_hash: tcx.crate_hash(LOCAL_CRATE), + metadata, + windows_subsystem: None, // Windows is not yet supported + linker_info: LinkerInfo::new(tcx), + crate_info: CrateInfo::new(tcx), + }, work_products)) +} + +// Adapted from https://github.com/rust-lang/rust/blob/303d8aff6092709edd4dbd35b1c88e9aa40bf6d8/src/librustc_codegen_ssa/base.rs#L922-L953 +fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse { + if !tcx.dep_graph.is_fully_enabled() { + return CguReuse::No; + } + + let work_product_id = &cgu.work_product_id(); + if tcx.dep_graph.previous_work_product(work_product_id).is_none() { + // We don't have anything cached for this CGU. This can happen + // if the CGU did not exist in the previous session. + return CguReuse::No; + } + + // Try to mark the CGU as green. If it we can do so, it means that nothing + // affecting the LLVM module has changed and we can re-use a cached version. + // If we compile with any kind of LTO, this means we can re-use the bitcode + // of the Pre-LTO stage (possibly also the Post-LTO version but we'll only + // know that later). If we are not doing LTO, there is only one optimized + // version of each module, so we re-use that. + let dep_node = cgu.codegen_dep_node(tcx); + assert!( + !tcx.dep_graph.dep_node_exists(&dep_node), + "CompileCodegenUnit dep-node for CGU `{}` already exists before marking.", + cgu.name() + ); + + if tcx.dep_graph.try_mark_green(tcx, &dep_node).is_some() { + CguReuse::PreLto + } else { + CguReuse::No + } +} diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 8e7d0742dc5a1..c676006aecec7 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,17 +1,11 @@ use std::any::Any; -use rustc::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; use rustc::middle::cstore::EncodedMetadata; -use rustc::mir::mono::{CodegenUnit, Linkage as RLinkage, Visibility}; -use rustc::session::config::{DebugInfo, OutputType}; -use rustc_session::cgu_reuse_tracker::CguReuse; -use rustc_codegen_ssa::back::linker::LinkerInfo; -use rustc_codegen_ssa::CrateInfo; +use rustc::mir::mono::{Linkage as RLinkage, Visibility}; use crate::prelude::*; -use crate::backend::{Emit, WriteDebugInfo}; - +mod aot; #[cfg(not(target_arch = "wasm32"))] mod jit; @@ -32,241 +26,7 @@ pub fn codegen_crate( panic!("jit not supported on wasm"); } - run_aot(tcx, metadata, need_metadata_module) -} - -fn run_aot( - tcx: TyCtxt<'_>, - metadata: EncodedMetadata, - need_metadata_module: bool, -) -> Box<(CodegenResults, FxHashMap)> { - let mut work_products = FxHashMap::default(); - - fn new_module(tcx: TyCtxt<'_>, name: String) -> Module { - let module = crate::backend::make_module(tcx.sess, name); - assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); - module - }; - - struct ModuleCodegenResult(CompiledModule, Option<(WorkProductId, WorkProduct)>); - - use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; - - impl HashStable for ModuleCodegenResult { - fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { - // do nothing - } - } - - fn emit_module( - tcx: TyCtxt<'_>, - name: String, - kind: ModuleKind, - mut module: Module, - debug: Option, - ) -> ModuleCodegenResult - where B::Product: Emit + WriteDebugInfo, - { - module.finalize_definitions(); - let mut product = module.finish(); - - if let Some(mut debug) = debug { - debug.emit(&mut product); - } - - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, Some(&name)); - let obj = product.emit(); - std::fs::write(&tmp_file, obj).unwrap(); - - let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { - None - } else { - rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( - tcx.sess, - &name, - &[(WorkProductFileKind::Object, tmp_file.clone())], - ) - }; - - ModuleCodegenResult( - CompiledModule { - name, - kind, - object: Some(tmp_file), - bytecode: None, - bytecode_compressed: None, - }, - work_product, - ) - }; - - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); - - if tcx.dep_graph.is_fully_enabled() { - for cgu in &*cgus { - tcx.codegen_unit(cgu.name()); - } - } - - let modules = time(tcx, "codegen mono items", || { - cgus.iter().map(|cgu| { - let cgu_reuse = determine_cgu_reuse(tcx, cgu); - tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse); - - match cgu_reuse { - _ if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() => {} - CguReuse::No => {} - CguReuse::PreLto => { - let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); - let mut object = None; - let work_product = cgu.work_product(tcx); - for (kind, saved_file) in &work_product.saved_files { - let obj_out = match kind { - WorkProductFileKind::Object => { - let path = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); - object = Some(path.clone()); - path - } - WorkProductFileKind::Bytecode | WorkProductFileKind::BytecodeCompressed => { - panic!("cg_clif doesn't use bytecode"); - } - }; - let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); - if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { - tcx.sess.err(&format!( - "unable to copy {} to {}: {}", - source_file.display(), - obj_out.display(), - err - )); - } - } - - work_products.insert(cgu.work_product_id(), work_product); - - return CompiledModule { - name: cgu.name().to_string(), - kind: ModuleKind::Regular, - object, - bytecode: None, - bytecode_compressed: None, - }; - } - CguReuse::PostLto => unreachable!(), - } - - let dep_node = cgu.codegen_dep_node(tcx); - let (ModuleCodegenResult(module, work_product), _) = - tcx.dep_graph.with_task(dep_node, tcx, cgu.name(), module_codegen, rustc::dep_graph::hash_result); - - fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodegenResult { - let cgu = tcx.codegen_unit(cgu_name); - let mono_items = cgu.items_in_deterministic_order(tcx); - - let mut module = new_module(tcx, cgu_name.as_str().to_string()); - - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { - let debug = DebugContext::new( - tcx, - module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) - } else { - None - }; - - codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); - - emit_module( - tcx, - cgu.name().as_str().to_string(), - ModuleKind::Regular, - module, - debug, - ) - } - - if let Some((id, product)) = work_product { - work_products.insert(id, product); - } - - module - }).collect::>() - }); - - tcx.sess.abort_if_errors(); - - let mut allocator_module = new_module(tcx, "allocator_shim".to_string()); - let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module); - - let allocator_module = if created_alloc_shim { - let ModuleCodegenResult(module, work_product) = emit_module( - tcx, - "allocator_shim".to_string(), - ModuleKind::Allocator, - allocator_module, - None, - ); - if let Some((id, product)) = work_product { - work_products.insert(id, product); - } - Some(module) - } else { - None - }; - - rustc_incremental::assert_dep_graph(tcx); - rustc_incremental::save_dep_graph(tcx); - - let metadata_module = if need_metadata_module { - let _timer = tcx.prof.generic_activity("codegen crate metadata"); - let (metadata_cgu_name, tmp_file) = tcx.sess.time("write compressed metadata", || { - use rustc::mir::mono::CodegenUnitNameBuilder; - - let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); - let metadata_cgu_name = cgu_name_builder - .build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")) - .as_str() - .to_string(); - - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Metadata, Some(&metadata_cgu_name)); - - let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| { - crate::metadata::write_metadata(tcx, object); - }); - - std::fs::write(&tmp_file, obj).unwrap(); - - (metadata_cgu_name, tmp_file) - }); - - Some(CompiledModule { - name: metadata_cgu_name, - kind: ModuleKind::Metadata, - object: Some(tmp_file), - bytecode: None, - bytecode_compressed: None, - }) - } else { - None - }; - - Box::new((CodegenResults { - crate_name: tcx.crate_name(LOCAL_CRATE), - modules, - allocator_module, - metadata_module, - crate_hash: tcx.crate_hash(LOCAL_CRATE), - metadata, - windows_subsystem: None, // Windows is not yet supported - linker_info: LinkerInfo::new(tcx), - crate_info: CrateInfo::new(tcx), - }, work_products)) + aot::run_aot(tcx, metadata, need_metadata_module) } fn codegen_mono_items<'tcx>( @@ -368,36 +128,3 @@ fn time(tcx: TyCtxt<'_>, name: &'static str, f: impl FnOnce() -> R) -> R { tcx.sess.time(name, f) } } - -// Adapted from https://github.com/rust-lang/rust/blob/303d8aff6092709edd4dbd35b1c88e9aa40bf6d8/src/librustc_codegen_ssa/base.rs#L922-L953 -fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse { - if !tcx.dep_graph.is_fully_enabled() { - return CguReuse::No; - } - - let work_product_id = &cgu.work_product_id(); - if tcx.dep_graph.previous_work_product(work_product_id).is_none() { - // We don't have anything cached for this CGU. This can happen - // if the CGU did not exist in the previous session. - return CguReuse::No; - } - - // Try to mark the CGU as green. If it we can do so, it means that nothing - // affecting the LLVM module has changed and we can re-use a cached version. - // If we compile with any kind of LTO, this means we can re-use the bitcode - // of the Pre-LTO stage (possibly also the Post-LTO version but we'll only - // know that later). If we are not doing LTO, there is only one optimized - // version of each module, so we re-use that. - let dep_node = cgu.codegen_dep_node(tcx); - assert!( - !tcx.dep_graph.dep_node_exists(&dep_node), - "CompileCodegenUnit dep-node for CGU `{}` already exists before marking.", - cgu.name() - ); - - if tcx.dep_graph.try_mark_green(tcx, &dep_node).is_some() { - CguReuse::PreLto - } else { - CguReuse::No - } -} From b469bf3b08a1c7def04ed256342a68739d8dd6a7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 11:58:59 +0100 Subject: [PATCH 1182/1566] Refactor driver/aot.rs Fixes #917 --- src/driver/aot.rs | 244 ++++++++++++++++++++++++---------------------- 1 file changed, 126 insertions(+), 118 deletions(-) diff --git a/src/driver/aot.rs b/src/driver/aot.rs index d87ab9d85ce0f..3473b0ae40c65 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -5,77 +5,146 @@ use rustc::session::config::{DebugInfo, OutputType}; use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use crate::prelude::*; use crate::backend::{Emit, WriteDebugInfo}; -pub(super) fn run_aot( +fn new_module(tcx: TyCtxt<'_>, name: String) -> Module { + let module = crate::backend::make_module(tcx.sess, name); + assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); + module +} + +struct ModuleCodegenResult(CompiledModule, Option<(WorkProductId, WorkProduct)>); + + +impl HashStable for ModuleCodegenResult { + fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { + // do nothing + } +} + +fn emit_module( tcx: TyCtxt<'_>, - metadata: EncodedMetadata, - need_metadata_module: bool, -) -> Box<(CodegenResults, FxHashMap)> { - let mut work_products = FxHashMap::default(); + name: String, + kind: ModuleKind, + mut module: Module, + debug: Option, +) -> ModuleCodegenResult + where B::Product: Emit + WriteDebugInfo, +{ + module.finalize_definitions(); + let mut product = module.finish(); + + if let Some(mut debug) = debug { + debug.emit(&mut product); + } - fn new_module(tcx: TyCtxt<'_>, name: String) -> Module { - let module = crate::backend::make_module(tcx.sess, name); - assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); - module - }; + let tmp_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(&name)); + let obj = product.emit(); + std::fs::write(&tmp_file, obj).unwrap(); - struct ModuleCodegenResult(CompiledModule, Option<(WorkProductId, WorkProduct)>); + let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { + None + } else { + rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( + tcx.sess, + &name, + &[(WorkProductFileKind::Object, tmp_file.clone())], + ) + }; - use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; + ModuleCodegenResult( + CompiledModule { + name, + kind, + object: Some(tmp_file), + bytecode: None, + bytecode_compressed: None, + }, + work_product, + ) +} - impl HashStable for ModuleCodegenResult { - fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { - // do nothing +fn reuse_workproduct_for_cgu( + tcx: TyCtxt<'_>, + cgu: &CodegenUnit, + work_products: &mut FxHashMap, +) -> CompiledModule { + let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); + let mut object = None; + let work_product = cgu.work_product(tcx); + for (kind, saved_file) in &work_product.saved_files { + let obj_out = match kind { + WorkProductFileKind::Object => { + let path = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); + object = Some(path.clone()); + path + } + WorkProductFileKind::Bytecode | WorkProductFileKind::BytecodeCompressed => { + panic!("cg_clif doesn't use bytecode"); + } + }; + let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); + if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { + tcx.sess.err(&format!( + "unable to copy {} to {}: {}", + source_file.display(), + obj_out.display(), + err + )); } } - fn emit_module( - tcx: TyCtxt<'_>, - name: String, - kind: ModuleKind, - mut module: Module, - debug: Option, - ) -> ModuleCodegenResult - where B::Product: Emit + WriteDebugInfo, - { - module.finalize_definitions(); - let mut product = module.finish(); - - if let Some(mut debug) = debug { - debug.emit(&mut product); - } + work_products.insert(cgu.work_product_id(), work_product); - let tmp_file = tcx - .output_filenames(LOCAL_CRATE) - .temp_path(OutputType::Object, Some(&name)); - let obj = product.emit(); - std::fs::write(&tmp_file, obj).unwrap(); + CompiledModule { + name: cgu.name().to_string(), + kind: ModuleKind::Regular, + object, + bytecode: None, + bytecode_compressed: None, + } +} - let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { - None - } else { - rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( - tcx.sess, - &name, - &[(WorkProductFileKind::Object, tmp_file.clone())], - ) - }; - - ModuleCodegenResult( - CompiledModule { - name, - kind, - object: Some(tmp_file), - bytecode: None, - bytecode_compressed: None, - }, - work_product, - ) - }; +fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodegenResult { + let cgu = tcx.codegen_unit(cgu_name); + let mono_items = cgu.items_in_deterministic_order(tcx); + + let mut module = new_module(tcx, cgu_name.as_str().to_string()); + + let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { + let debug = DebugContext::new( + tcx, + module.target_config().pointer_type().bytes() as u8, + ); + Some(debug) + } else { + None + }; + + super::codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + + emit_module( + tcx, + cgu.name().as_str().to_string(), + ModuleKind::Regular, + module, + debug, + ) +} + +pub(super) fn run_aot( + tcx: TyCtxt<'_>, + metadata: EncodedMetadata, + need_metadata_module: bool, +) -> Box<(CodegenResults, FxHashMap)> { + let mut work_products = FxHashMap::default(); let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); @@ -94,40 +163,7 @@ pub(super) fn run_aot( _ if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() => {} CguReuse::No => {} CguReuse::PreLto => { - let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); - let mut object = None; - let work_product = cgu.work_product(tcx); - for (kind, saved_file) in &work_product.saved_files { - let obj_out = match kind { - WorkProductFileKind::Object => { - let path = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); - object = Some(path.clone()); - path - } - WorkProductFileKind::Bytecode | WorkProductFileKind::BytecodeCompressed => { - panic!("cg_clif doesn't use bytecode"); - } - }; - let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); - if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { - tcx.sess.err(&format!( - "unable to copy {} to {}: {}", - source_file.display(), - obj_out.display(), - err - )); - } - } - - work_products.insert(cgu.work_product_id(), work_product); - - return CompiledModule { - name: cgu.name().to_string(), - kind: ModuleKind::Regular, - object, - bytecode: None, - bytecode_compressed: None, - }; + return reuse_workproduct_for_cgu(tcx, &*cgu, &mut work_products); } CguReuse::PostLto => unreachable!(), } @@ -136,34 +172,6 @@ pub(super) fn run_aot( let (ModuleCodegenResult(module, work_product), _) = tcx.dep_graph.with_task(dep_node, tcx, cgu.name(), module_codegen, rustc::dep_graph::hash_result); - fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodegenResult { - let cgu = tcx.codegen_unit(cgu_name); - let mono_items = cgu.items_in_deterministic_order(tcx); - - let mut module = new_module(tcx, cgu_name.as_str().to_string()); - - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { - let debug = DebugContext::new( - tcx, - module.target_config().pointer_type().bytes() as u8, - ); - Some(debug) - } else { - None - }; - - super::codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); - - emit_module( - tcx, - cgu.name().as_str().to_string(), - ModuleKind::Regular, - module, - debug, - ) - } - if let Some((id, product)) = work_product { work_products.insert(id, product); } From 1c02e6c368337bea10a57eb345bd36edbff75f87 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 12 Mar 2020 21:04:00 +0100 Subject: [PATCH 1183/1566] Rustup to rustc 1.43.0-nightly (c20d7eecb 2020-03-11) --- build_sysroot/alloc_system/lib.rs | 14 ++++++++------ rust-toolchain | 2 +- src/constant.rs | 1 - src/intrinsics/mod.rs | 17 ++++++++++++++--- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index abfcf301a5347..8ad0a076d3d30 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -72,14 +72,16 @@ pub struct System; #[unstable(feature = "allocator_api", issue = "32838")] unsafe impl AllocRef for System { #[inline] - unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { - NonNull::new(GlobalAlloc::alloc(self, layout)).ok_or(AllocErr).map(|p| (p, layout.size())) + fn alloc(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { + NonNull::new(unsafe { GlobalAlloc::alloc(self, layout) }) + .ok_or(AllocErr) + .map(|p| (p, layout.size())) } #[inline] - unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { - NonNull::new(GlobalAlloc::alloc_zeroed(self, layout)) - .ok_or(AllocErr) - .map(|p| (p, layout.size())) + fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { + NonNull::new(unsafe { GlobalAlloc::alloc_zeroed(self, layout) }) + .ok_or(AllocErr) + .map(|p| (p, layout.size())) } #[inline] unsafe fn dealloc(&mut self, ptr: NonNull, layout: Layout) { diff --git a/rust-toolchain b/rust-toolchain index c1c2521f63d00..7b70b3322191a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-10 +nightly-2020-03-12 diff --git a/src/constant.rs b/src/constant.rs index 79183d560930a..e6093704c112e 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -485,7 +485,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn assert_panic( _: &mut InterpCx<'mir, 'tcx, Self>, - _: Span, _: &mir::AssertKind>, _: Option, ) -> InterpResult<'tcx> { diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 53c699ef8c628..61a96ac0fe85d 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -813,9 +813,20 @@ pub fn codegen_intrinsic_call<'tcx>( let res = CValue::by_val(swap(&mut fx.bcx, arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - panic_if_uninhabited, () { - if fx.layout_of(T).abi.is_uninhabited() { - crate::trap::trap_panic(fx, "[panic] Called intrinsic::panic_if_uninhabited for uninhabited type."); + panic_if_uninhabited | panic_if_zero_invalid | panic_if_any_invalid, () { + let layout = fx.layout_of(T); + if layout.abi.is_uninhabited() { + crate::trap::trap_panic(fx, &format!("attempted to instantiate uninhabited type `{}`", T)); + return; + } + + if intrinsic == "panic_if_zero_invalid" && !layout.might_permit_raw_init(fx, /*zero:*/ true).unwrap() { + crate::trap::trap_panic(fx, &format!("attempted to zero-initialize type `{}`, which is invalid", T)); + return; + } + + if intrinsic == "panic_if_any_invalid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { + crate::trap::trap_panic(fx, &format!("attempted to leave type `{}` uninitialized, which is invalid", T)); return; } }; From 4d226e8f17d2b0eb424486b965f95e42a89389b9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 11:01:39 +0100 Subject: [PATCH 1184/1566] Hash trap message symbol nameThis saves ~7% of disk space --- src/trap.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/trap.rs b/src/trap.rs index 6ce5be0009fcb..5d3064906834a 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -1,3 +1,6 @@ +use std::collections::hash_map::DefaultHasher; +use std::hash::{Hash, Hasher}; + use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { @@ -21,12 +24,15 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let symbol_name = fx.tcx.symbol_name(fx.instance); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); + let mut hasher = DefaultHasher::new(); + real_msg.hash(&mut hasher); + let msg_hash = hasher.finish(); let mut data_ctx = DataContext::new(); data_ctx.define(real_msg.as_bytes().to_vec().into_boxed_slice()); let msg_id = fx .module .declare_data( - &(symbol_name.name.as_str().to_string() + msg), + &format!("__trap_{:08x}", msg_hash), Linkage::Local, false, false, From 98a073cf262f6fb2a3213d009dd1ee15d3cb7e44 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 11:19:31 +0100 Subject: [PATCH 1185/1566] Shrink vtable symbol names a bit --- src/vtable.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vtable.rs b/src/vtable.rs index e4b3a9942cf0c..28688fee049b6 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -135,7 +135,14 @@ fn build_vtable<'tcx>( let data_id = fx .module .declare_data( - &format!("vtable.{:?}.for.{:?}", trait_ref, layout.ty), + &format!( + "__vtable.{}.for.{:?}", + trait_ref + .as_ref() + .map(|trait_ref| format!("{:?}", trait_ref.skip_binder()).into()) + .unwrap_or(std::borrow::Cow::Borrowed("???")), + layout.ty + ), Linkage::Local, false, false, From ec9b3e15afec04a046d982a9dfe361c614104307 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 18:25:18 +0100 Subject: [PATCH 1186/1566] Setup github actions --- .github/workflows/main.yml | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000000..bedc765cc837f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,47 @@ +name: CI + +on: + - push + - pull_request + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + + - name: Cache cargo installed crates + uses: actions/cache@v1.1.2 + with: + path: $HOME/.cargo/bin + key: cargo-installed-crates + + - name: Prepare dependencies + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + ./prepare.sh + + # Compile is a separate step, as the actions-rs/cargo action supports error annotations + - name: Compile + uses: actions-rs/cargo@v1.0.1 + with: + command: build + args: --release + + - name: Test + run: | + # Enable backtraces for easier debugging + export RUST_BACKTRACE=1 + + # Reduce amount of benchmark runs as they are slow + export COMPILE_RUNS=2 + export RUN_RUNS=2 + + ./test.sh --release From 512b33f001cd17bcd38f7f9cfd8ceee4b41a9862 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 18:54:20 +0100 Subject: [PATCH 1187/1566] [gh actions] Fix caching of cargo installed crates --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bedc765cc837f..c99974013e076 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,8 +19,8 @@ jobs: - name: Cache cargo installed crates uses: actions/cache@v1.1.2 with: - path: $HOME/.cargo/bin - key: cargo-installed-crates + path: ~/.cargo/bin + key: cargo-installed-crates-${{ matrix.os }} - name: Prepare dependencies run: | From 133b05b3a43457b7918c4fb2be3d2ab0e8fa4e2b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 19:24:17 +0100 Subject: [PATCH 1188/1566] [gh actions] Cache target dir for specific rustc version --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c99974013e076..884a8e466f682 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,6 +22,12 @@ jobs: path: ~/.cargo/bin key: cargo-installed-crates-${{ matrix.os }} + - name: Cache target dir + uses: actions/cache@v1.1.2 + with: + path: target + key: target-dir-${{ matrix.os }}-${{ hashFiles('rust-toolchain') }} + - name: Prepare dependencies run: | git config --global user.email "user@example.com" From 2e5661dae628ec20ad3a58d5bc1642cce0c0cf71 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 19:34:35 +0100 Subject: [PATCH 1189/1566] [gh actions] Fix caching of ~/.cargo/bin --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 884a8e466f682..6bf1ca2cf6af9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,10 @@ jobs: steps: - uses: actions/checkout@v2 + # https://github.com/actions/cache/issues/133 + - name: Fixup owner of ~/.cargo/bin + run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/bin + - name: Cache cargo installed crates uses: actions/cache@v1.1.2 with: From 014438c61413cb67308eb2691ce69b3d254cee18 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 19:44:50 +0100 Subject: [PATCH 1190/1566] [gh actions] Cache cargo registry and index --- .github/workflows/main.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6bf1ca2cf6af9..379e3492f2eb9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,11 +26,23 @@ jobs: path: ~/.cargo/bin key: cargo-installed-crates-${{ matrix.os }} - - name: Cache target dir + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + + - name: Cache cargo target dir uses: actions/cache@v1.1.2 with: path: target - key: target-dir-${{ matrix.os }}-${{ hashFiles('rust-toolchain') }} + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain') }} - name: Prepare dependencies run: | From 50c1d8a028c1610f3187e9e0c24ba6ce40b5c6f6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 13 Mar 2020 20:24:52 +0100 Subject: [PATCH 1191/1566] [gh actions] Really fix permission problems with caching --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 379e3492f2eb9..34f543164dacb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: # https://github.com/actions/cache/issues/133 - name: Fixup owner of ~/.cargo/bin - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/bin + run: sudo chown -R $(whoami):$(id -ng) ~/.cargo - name: Cache cargo installed crates uses: actions/cache@v1.1.2 From bed829389efe5ca8a6edc8861436f353d0b36ea6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 12:47:18 +0100 Subject: [PATCH 1192/1566] [gh actions] invalidate cargo-installed-crates cache --- .github/workflows/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 34f543164dacb..020582e542d27 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,16 +15,16 @@ jobs: steps: - uses: actions/checkout@v2 - + # https://github.com/actions/cache/issues/133 - name: Fixup owner of ~/.cargo/bin run: sudo chown -R $(whoami):$(id -ng) ~/.cargo - + - name: Cache cargo installed crates uses: actions/cache@v1.1.2 with: path: ~/.cargo/bin - key: cargo-installed-crates-${{ matrix.os }} + key: cargo-installed-crates2-${{ matrix.os }} - name: Cache cargo registry uses: actions/cache@v1 @@ -49,21 +49,21 @@ jobs: git config --global user.email "user@example.com" git config --global user.name "User" ./prepare.sh - + # Compile is a separate step, as the actions-rs/cargo action supports error annotations - name: Compile uses: actions-rs/cargo@v1.0.1 with: command: build args: --release - + - name: Test run: | # Enable backtraces for easier debugging export RUST_BACKTRACE=1 - + # Reduce amount of benchmark runs as they are slow export COMPILE_RUNS=2 export RUN_RUNS=2 - + ./test.sh --release From 9fd8b84a4b8df7c4b0fe4bcb17585e5a147fd5bc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 12:49:52 +0100 Subject: [PATCH 1193/1566] [gh actions] Invalidate cargo-registry cache --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 020582e542d27..43001a5caff5f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: uses: actions/cache@v1 with: path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-cargo-registry2-${{ hashFiles('**/Cargo.lock') }} - name: Cache cargo index uses: actions/cache@v1 From 10ee80c288cc8a2c506f6147f4b33fbec05536b0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 14:34:07 +0100 Subject: [PATCH 1194/1566] Write dummy return value on unimplemented simd_{insert,extract} Fixes #919 --- src/intrinsics/simd.rs | 6 ++++-- src/trap.rs | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 99149d7d89bf7..e42309663d05c 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -127,7 +127,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.mir.span, "`simd_insert` is not yet implemented. Calling this function will panic.", ); - crate::trap::trap_unimplemented(fx, "`simd_insert` is not yet implemented"); + let val = crate::trap::trap_unimplemented_ret_value(fx, ret.layout(), "`simd_insert` is not yet implemented"); + ret.write_cvalue(fx, val); }; simd_extract, (c v, o idx) { @@ -138,7 +139,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); - crate::trap::trap_unimplemented(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); + let val = crate::trap::trap_unimplemented_ret_value(fx, ret.layout(), "`#[rustc_arg_required_const(..)]` is not yet supported."); + ret.write_cvalue(fx, val); return; }; diff --git a/src/trap.rs b/src/trap.rs index 5d3064906834a..a223e6397da6d 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -75,6 +75,18 @@ pub fn trap_unreachable( fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); } +/// Like `trap_unreachable` but returns a fake value of the specified type. +/// +/// Trap code: user65535 +pub fn trap_unreachable_ret_value<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, + dest_layout: TyLayout<'tcx>, + msg: impl AsRef, +) -> CValue<'tcx> { + trap_unreachable(fx, msg); + CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout) +} + /// Use this when something is unimplemented, but `libcore` or `libstd` requires it to codegen. /// Unlike `trap_unreachable` this will not fill the current block, so you **must** add instructions /// to it afterwards. @@ -89,10 +101,10 @@ pub fn trap_unimplemented( fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); } -/// Like `trap_unreachable` but returns a fake value of the specified type. +/// Like `trap_unimplemented` but returns a fake value of the specified type. /// /// Trap code: user65535 -pub fn trap_unreachable_ret_value<'tcx>( +pub fn trap_unimplemented_ret_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef, From ce4c514001f33d26396669e000923c4d7991b809 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 14:39:29 +0100 Subject: [PATCH 1195/1566] Error on allocation containing reference to TLS value Fixes #868 --- src/constant.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index e6093704c112e..d862a9412a6e1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use rustc_span::DUMMY_SP; +use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, }; @@ -246,7 +247,7 @@ fn data_id_for_static( &*symbol_name, linkage, is_mutable, - attrs.flags.contains(rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags::THREAD_LOCAL), + attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL), Some(align.try_into().unwrap()), ) .unwrap(); @@ -359,6 +360,10 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu data_id_for_alloc_id(module, reloc, alloc.align) } GlobalAlloc::Static(def_id) => { + if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { + tcx.sess.fatal(&format!("Allocation {:?} contains reference to TLS value {:?}", alloc, def_id)); + } + // Don't push a `TodoItem::Static` here, as it will cause statics used by // multiple crates to be duplicated between them. It isn't necessary anyway, // as it will get pushed by `codegen_static` when necessary. From 092cae12f9f5bb077f189a62ef03ef634a91edf4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 14:48:04 +0100 Subject: [PATCH 1196/1566] Dont single step into macros Fixes #782 --- src/debuginfo/line_info.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 7a3ac0991c412..7997ae33d0ecd 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -122,8 +122,23 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { blocks.sort_by_key(|block| func.offsets[*block]); // Ensure inst offsets always increase let line_strings = &mut self.debug_context.dwarf.line_strings; + let function_span = self.mir.span; let mut last_file = None; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { + // Based on https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L116-L131 + // In order to have a good line stepping behavior in debugger, we overwrite debug + // locations of macro expansions with that of the outermost expansion site + // (unless the crate is being compiled with `-Z debug-macros`). + let span = if !span.from_expansion() || + tcx.sess.opts.debugging_opts.debug_macros { + span + } else { + // Walk up the macro expansion chain until we reach a non-expanded span. + // We also stop at the function body level because no line stepping can occur + // at the level above that. + rustc_span::hygiene::walk_chain(span, function_span.ctxt()) + }; + let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); // line_program_add_file is very slow. From 660b5c33e7d6bc843e73c45c5d2270005330088b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 15:10:22 +0100 Subject: [PATCH 1197/1566] Use byte offsets instead of char offsets in debuginfo cc #807 --- src/debuginfo/line_info.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 7997ae33d0ecd..47e1d54c3815d 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -3,7 +3,7 @@ use std::path::{Component, Path}; use crate::prelude::*; -use rustc_span::FileName; +use rustc_span::{FileName, SourceFileAndLine}; use cranelift_codegen::binemit::CodeOffset; @@ -139,25 +139,32 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { rustc_span::hygiene::walk_chain(span, function_span.ctxt()) }; - let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); + let (file, line, col) = match tcx.sess.source_map().lookup_line(span.lo()) { + Ok(SourceFileAndLine { sf: file, line }) => { + let line_pos = file.line_begin_pos(span.lo()); + + (file, u64::try_from(line).unwrap() + 1, u64::from((span.lo() - line_pos).to_u32()) + 1) + } + Err(file) => (file, 0, 0) + }; // line_program_add_file is very slow. // Optimize for the common case of the current file not being changed. let current_file_changed = if let Some(last_file) = &mut last_file { // If the allocations are not equal, then the files may still be equal, but that // is not a problem, as this is just an optimization. - !Lrc::ptr_eq(last_file, &loc.file) + !Lrc::ptr_eq(last_file, &file) } else { true }; if current_file_changed { - let file_id = line_program_add_file(line_program, line_strings, &loc.file.name); + let file_id = line_program_add_file(line_program, line_strings, &file.name); line_program.row().file = file_id; - last_file = Some(loc.file.clone()); + last_file = Some(file.clone()); } - line_program.row().line = loc.line as u64; - line_program.row().column = loc.col.to_u32() as u64 + 1; + line_program.row().line = line; + line_program.row().column = col; line_program.generate_row(); }; From efe3d84ce417e99d3f663f40cda328bde876a8eb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 15:18:04 +0100 Subject: [PATCH 1198/1566] Don't lookup span position when the span hasn't changed This improves performance of FunctionDebugContext::define by ~60% Fixes #807 --- src/debuginfo/line_info.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 47e1d54c3815d..fda861c5519f1 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -123,8 +123,17 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let line_strings = &mut self.debug_context.dwarf.line_strings; let function_span = self.mir.span; + let mut last_span = None; let mut last_file = None; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { + if let Some(last_span) = last_span { + if span == last_span { + line_program.generate_row(); + return; + } + } + last_span = Some(span); + // Based on https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L116-L131 // In order to have a good line stepping behavior in debugger, we overwrite debug // locations of macro expansions with that of the outermost expansion site @@ -150,7 +159,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { // line_program_add_file is very slow. // Optimize for the common case of the current file not being changed. - let current_file_changed = if let Some(last_file) = &mut last_file { + let current_file_changed = if let Some(last_file) = &last_file { // If the allocations are not equal, then the files may still be equal, but that // is not a problem, as this is just an optimization. !Lrc::ptr_eq(last_file, &file) From 5d516f9e118d6527947ca5deb3d76bbc4fa0f8a1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 16:36:55 +0100 Subject: [PATCH 1199/1566] Use Vec instead of HashSet for ccx.todo This reduces runtime of ConstantCx::finalize for the coercions rustc bench by ~65% cc #878 --- src/constant.rs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index d862a9412a6e1..5771c64fb7604 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -7,6 +7,7 @@ use rustc::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, }; use rustc::ty::{layout::Align, Const, ConstKind}; +use rustc_data_structures::fx::FxHashSet; use rustc_mir::interpret::{ ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup, StackPopInfo, @@ -19,11 +20,11 @@ use crate::prelude::*; #[derive(Default)] pub struct ConstantCx { - todo: HashSet, - done: HashSet, + todo: Vec, + done: FxHashSet, } -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Debug)] enum TodoItem { Alloc(AllocId), Static(DefId), @@ -39,7 +40,7 @@ impl ConstantCx { } pub fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { - constants_cx.todo.insert(TodoItem::Static(def_id)); + constants_cx.todo.push(TodoItem::Static(def_id)); } fn codegen_static_ref<'tcx>( @@ -109,7 +110,7 @@ pub fn trans_const_value<'tcx>( let alloc_kind = fx.tcx.alloc_map.lock().get(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { - fx.constants_cx.todo.insert(TodoItem::Alloc(ptr.alloc_id)); + fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); let data_id = data_id_for_alloc_id(fx.module, ptr.alloc_id, alloc.align); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] @@ -139,7 +140,7 @@ pub fn trans_const_value<'tcx>( } ConstValue::ByRef { alloc, offset } => { let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); - fx.constants_cx.todo.insert(TodoItem::Alloc(alloc_id)); + fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); @@ -195,7 +196,7 @@ fn trans_const_place<'tcx>( //println!("const value: {:?} allocation: {:?}", value, alloc); let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); - fx.constants_cx.todo.insert(TodoItem::Alloc(alloc_id)); + fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] @@ -287,7 +288,7 @@ fn cplace_for_dataid<'tcx>( fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mut ConstantCx) { let memory = Memory::::new(tcx.at(DUMMY_SP), ()); - while let Some(todo_item) = pop_set(&mut cx.todo) { + while let Some(todo_item) = cx.todo.pop() { let (data_id, alloc) = match todo_item { TodoItem::Alloc(alloc_id) => { //println!("alloc_id {}", alloc_id); @@ -356,7 +357,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu continue; } GlobalAlloc::Memory(_) => { - cx.todo.insert(TodoItem::Alloc(reloc)); + cx.todo.push(TodoItem::Alloc(reloc)); data_id_for_alloc_id(module, reloc, alloc.align) } GlobalAlloc::Static(def_id) => { @@ -387,15 +388,6 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu assert!(cx.todo.is_empty(), "{:?}", cx.todo); } -fn pop_set(set: &mut HashSet) -> Option { - if let Some(elem) = set.iter().next().map(|elem| *elem) { - set.remove(&elem); - Some(elem) - } else { - None - } -} - struct TransPlaceInterpreter; impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { From fe0e2ae66dac3da90e5f2f51b2c1430f5c82e434 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 18:17:13 +0100 Subject: [PATCH 1200/1566] [gh actions] Really fix caching this time --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43001a5caff5f..f7dce42e50236 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,8 +17,9 @@ jobs: - uses: actions/checkout@v2 # https://github.com/actions/cache/issues/133 - - name: Fixup owner of ~/.cargo/bin - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo + - name: Fixup owner of ~/.cargo/ + # Don't remove the trailing /. It is necessary to follow the symlink. + run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ - name: Cache cargo installed crates uses: actions/cache@v1.1.2 From 0c1dcb0bbfb91b98a929c888109aaeb1c1639d42 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 19:01:47 +0100 Subject: [PATCH 1201/1566] Pre-allocate vec for rlib metadata reading Reduces the time spent during the copy from ~9% to ~1% for helloworld cc #878 --- src/metadata.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/metadata.rs b/src/metadata.rs index f15e1682d13d3..c1f2534111ead 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,3 +1,4 @@ +use std::convert::TryFrom; use std::fs::File; use std::path::Path; @@ -24,7 +25,10 @@ impl MetadataLoader for CraneliftMetadataLoader { while let Some(entry_result) = archive.next_entry() { let mut entry = entry_result.map_err(|e| format!("{:?}", e))?; if entry.header().identifier() == METADATA_FILENAME.as_bytes() { - let mut buf = Vec::new(); + let mut buf = Vec::with_capacity( + usize::try_from(entry.header().size()) + .expect("Rlib metadata file too big to load into memory.") + ); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); return Ok(rustc_erase_owner!(buf.map_owner_box())); From d445a6f73d15470117d4cca982a7fcc3809c25ee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 20:52:20 +0100 Subject: [PATCH 1202/1566] Update links for the merge of the Cranelift and Wasmtime repos --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 0f916e0463314..4ff92d705a8d8 100644 --- a/Readme.md +++ b/Readme.md @@ -47,6 +47,6 @@ $ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_cod ## Not yet supported * Good non-rust abi support ([several problems](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) -* Checked binops ([some missing instructions in cranelift](https://github.com/CraneStation/cranelift/issues/460)) -* Inline assembly ([no cranelift support](https://github.com/CraneStation/cranelift/issues/444), not coming soon) +* Checked binops ([some missing instructions in cranelift](https://github.com/bytecodealliance/wasmtime/issues/1044)) +* Inline assembly ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1041), not coming soon) * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171), some basic things work) From 643f0a1455d720fdaa46bf57a07ea665c4d8a8ee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 15 Mar 2020 19:52:41 +0100 Subject: [PATCH 1203/1566] Remove unused import --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 81111b776d676..15ea15a7410a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,8 +90,6 @@ mod prelude { pub use rustc_index::vec::Idx; - pub use rustc_mir::monomorphize::collector; - pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; pub use rustc_codegen_ssa::traits::*; pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; From 16d3fd31d7e1da7193e960e83e69bf52a0654899 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2020 05:11:04 +0000 Subject: [PATCH 1204/1566] Bump cranelift-codegen from `fbe29da` to `e2f6c08` Bumps [cranelift-codegen](https://github.com/bytecodealliance/wasmtime) from `fbe29da` to `e2f6c08`. - [Release notes](https://github.com/bytecodealliance/wasmtime/releases) - [Commits](https://github.com/bytecodealliance/wasmtime/compare/fbe29da5cc1c0847af176f151f114a6a535534ff...e2f6c0805231daa0524d7c770d11ced6dfe961a2) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 823364ee70f62..ebb67ea023cde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,7 +39,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "cranelift-entity", ] @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "byteorder", "cranelift-bforest", @@ -64,7 +64,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -73,17 +73,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" [[package]] name = "cranelift-entity" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" [[package]] name = "cranelift-frontend" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "cranelift-codegen", "log", @@ -94,7 +94,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -105,7 +105,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -115,7 +115,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -127,7 +127,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#fbe29da5cc1c0847af176f151f114a6a535534ff" +source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" dependencies = [ "cranelift-codegen", "cranelift-module", From ebf13f1cce75de55a5174141761fc68d9322a739 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Mar 2020 14:52:06 +0100 Subject: [PATCH 1205/1566] Rustup to rustc 1.43.0-nightly (dd6718796 2020-03-16) --- rust-toolchain | 2 +- src/constant.rs | 6 +++--- src/intrinsics/mod.rs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 7b70b3322191a..9d825f30c98e9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-12 +nightly-2020-03-17 diff --git a/src/constant.rs b/src/constant.rs index 5771c64fb7604..2f702a53e0795 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -10,7 +10,7 @@ use rustc::ty::{layout::Align, Const, ConstKind}; use rustc_data_structures::fx::FxHashSet; use rustc_mir::interpret::{ ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, - StackPopCleanup, StackPopInfo, + StackPopCleanup, StackPopJump, }; use cranelift_codegen::ir::GlobalValue; @@ -476,8 +476,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { Ok(()) } - fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: (), _: bool) -> InterpResult<'tcx, StackPopInfo> { - Ok(StackPopInfo::Normal) + fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: (), _: bool) -> InterpResult<'tcx, StackPopJump> { + Ok(StackPopJump::Normal) } fn assert_panic( diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 61a96ac0fe85d..a95b54a05e121 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -359,7 +359,7 @@ pub fn codegen_intrinsic_call<'tcx>( "transmute" => { trap_unreachable( fx, - "[corruption] Called intrinsic::transmute with uninhabited argument.", + "[corruption] Transmuting to uninhabited type.", ); } _ => unimplemented!("unsupported instrinsic {}", intrinsic), @@ -813,19 +813,19 @@ pub fn codegen_intrinsic_call<'tcx>( let res = CValue::by_val(swap(&mut fx.bcx, arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - panic_if_uninhabited | panic_if_zero_invalid | panic_if_any_invalid, () { + assert_inhabited | assert_zero_valid | assert_any_valid, () { let layout = fx.layout_of(T); if layout.abi.is_uninhabited() { crate::trap::trap_panic(fx, &format!("attempted to instantiate uninhabited type `{}`", T)); return; } - if intrinsic == "panic_if_zero_invalid" && !layout.might_permit_raw_init(fx, /*zero:*/ true).unwrap() { + if intrinsic == "assert_zero_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ true).unwrap() { crate::trap::trap_panic(fx, &format!("attempted to zero-initialize type `{}`, which is invalid", T)); return; } - if intrinsic == "panic_if_any_invalid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { + if intrinsic == "assert_any_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { crate::trap::trap_panic(fx, &format!("attempted to leave type `{}` uninitialized, which is invalid", T)); return; } From d07c404bf47dff3418ddf9219a05dbd594884bb6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Mar 2020 14:53:32 +0100 Subject: [PATCH 1206/1566] Rename try intrinsic argument to match upstream --- src/intrinsics/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index a95b54a05e121..09e119f4abab8 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -991,7 +991,7 @@ pub fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, val); }; - try, (v f, v data, v _local_ptr) { + try, (v f, v data, v _catch_fn) { // FIXME once unwinding is supported, change this to actually catch panics let f_sig = fx.bcx.func.import_signature(Signature { call_conv: CallConv::triple_default(fx.triple()), From 6e9ee812719ad9d3fb0144458b6460f00a2b25bd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Mar 2020 15:07:55 +0100 Subject: [PATCH 1207/1566] [gh actions] Run the compile step with the same arguments as test.sh --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f7dce42e50236..5cb1af9d9b2f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,8 +55,8 @@ jobs: - name: Compile uses: actions-rs/cargo@v1.0.1 with: - command: build - args: --release + command: rustc + args: --release -- -Zrun_dsymutil=no - name: Test run: | From c7b2ffaebdaf76ebf0084e5ed2fc6253787b0467 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Mar 2020 15:12:15 +0100 Subject: [PATCH 1208/1566] Fix intrinsic name --- src/intrinsics/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 09e119f4abab8..5043c5ec0d86e 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -813,7 +813,7 @@ pub fn codegen_intrinsic_call<'tcx>( let res = CValue::by_val(swap(&mut fx.bcx, arg), fx.layout_of(T)); ret.write_cvalue(fx, res); }; - assert_inhabited | assert_zero_valid | assert_any_valid, () { + assert_inhabited | assert_zero_valid | assert_uninit_valid, () { let layout = fx.layout_of(T); if layout.abi.is_uninhabited() { crate::trap::trap_panic(fx, &format!("attempted to instantiate uninhabited type `{}`", T)); @@ -825,7 +825,7 @@ pub fn codegen_intrinsic_call<'tcx>( return; } - if intrinsic == "assert_any_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { + if intrinsic == "assert_uninit_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { crate::trap::trap_panic(fx, &format!("attempted to leave type `{}` uninitialized, which is invalid", T)); return; } From b475199d1c30c36dc473ef1b6d4fd4046d236451 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Mar 2020 15:30:32 +0100 Subject: [PATCH 1209/1566] [debuginfo] Fix map_reg --- src/debuginfo/mod.rs | 111 +++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index c90f5fa6aedf8..c1fb6c92c316a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -4,7 +4,7 @@ mod line_info; use crate::prelude::*; use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; -use cranelift_codegen::isa::RegUnit; +use cranelift_codegen::isa::{RegUnit, TargetIsa}; use cranelift_codegen::ValueLocRange; use gimli::write::{ @@ -253,7 +253,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub fn define( &mut self, context: &Context, - isa: &dyn cranelift_codegen::isa::TargetIsa, + isa: &dyn TargetIsa, source_info_set: &indexmap::IndexSet, local_map: HashMap>, ) { @@ -279,6 +279,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let location = place_location( self, + isa, context, &local_map, &value_labels_ranges, @@ -299,6 +300,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { fn place_location<'a, 'tcx>( func_debug_ctx: &mut FunctionDebugContext<'a, 'tcx>, + isa: &dyn TargetIsa, context: &Context, local_map: &HashMap>, value_labels_ranges: &HashMap>, @@ -323,7 +325,7 @@ fn place_location<'a, 'tcx>( addend: i64::from(value_loc_range.end), }, data: Expression( - translate_loc(value_loc_range.loc, &context.func.stack_slots).unwrap(), + translate_loc(isa, value_loc_range.loc, &context.func.stack_slots).unwrap(), ), }) .collect(), @@ -353,62 +355,67 @@ fn place_location<'a, 'tcx>( -// Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137 - -fn map_reg(reg: RegUnit) -> Register { - static mut REG_X86_MAP: Option> = None; - // FIXME lazy initialization? - unsafe { - if REG_X86_MAP.is_none() { - REG_X86_MAP = Some(HashMap::new()); +// Adapted from https://github.com/bytecodealliance/wasmtime/blob/50496efb6bac32aaf469c6d9186b322de83549bf/crates/debug/src/transform/map_reg.rs +pub(crate) fn map_reg(isa: &dyn TargetIsa, reg: RegUnit) -> Register { + // TODO avoid duplication with fde.rs + assert!(isa.name() == "x86" && isa.pointer_bits() == 64); + // Mapping from https://github.com/bytecodealliance/cranelift/pull/902 by @iximeow + const X86_GP_REG_MAP: [Register; 16] = [ + X86_64::RAX, + X86_64::RCX, + X86_64::RDX, + X86_64::RBX, + X86_64::RSP, + X86_64::RBP, + X86_64::RSI, + X86_64::RDI, + X86_64::R8, + X86_64::R9, + X86_64::R10, + X86_64::R11, + X86_64::R12, + X86_64::R13, + X86_64::R14, + X86_64::R15, + ]; + const X86_XMM_REG_MAP: [Register; 16] = [ + X86_64::XMM0, + X86_64::XMM1, + X86_64::XMM2, + X86_64::XMM3, + X86_64::XMM4, + X86_64::XMM5, + X86_64::XMM6, + X86_64::XMM7, + X86_64::XMM8, + X86_64::XMM9, + X86_64::XMM10, + X86_64::XMM11, + X86_64::XMM12, + X86_64::XMM13, + X86_64::XMM14, + X86_64::XMM15, + ]; + let reg_info = isa.register_info(); + let bank = reg_info.bank_containing_regunit(reg).unwrap(); + match bank.name { + "IntRegs" => { + // x86 GP registers have a weird mapping to DWARF registers, so we use a + // lookup table. + X86_GP_REG_MAP[(reg - bank.first_unit) as usize] } - if let Some(val) = REG_X86_MAP.as_mut().unwrap().get(®) { - return *val; + "FloatRegs" => X86_XMM_REG_MAP[(reg - bank.first_unit) as usize], + bank_name => { + panic!("unsupported register bank: {}", bank_name); } - let result = match reg { - 0 => X86_64::RAX, - 1 => X86_64::RCX, - 2 => X86_64::RDX, - 3 => X86_64::RBX, - 4 => X86_64::RSP, - 5 => X86_64::RBP, - 6 => X86_64::RSI, - 7 => X86_64::RDI, - 8 => X86_64::R8, - 9 => X86_64::R9, - 10 => X86_64::R10, - 11 => X86_64::R11, - 12 => X86_64::R12, - 13 => X86_64::R13, - 14 => X86_64::R14, - 15 => X86_64::R15, - 16 => X86_64::XMM0, - 17 => X86_64::XMM1, - 18 => X86_64::XMM2, - 19 => X86_64::XMM3, - 20 => X86_64::XMM4, - 21 => X86_64::XMM5, - 22 => X86_64::XMM6, - 23 => X86_64::XMM7, - 24 => X86_64::XMM8, - 25 => X86_64::XMM9, - 26 => X86_64::XMM10, - 27 => X86_64::XMM11, - 28 => X86_64::XMM12, - 29 => X86_64::XMM13, - 30 => X86_64::XMM14, - 31 => X86_64::XMM15, - _ => panic!("unknown x86_64 register {}", reg), - }; - REG_X86_MAP.as_mut().unwrap().insert(reg, result); - result } } -fn translate_loc(loc: ValueLoc, stack_slots: &StackSlots) -> Option> { +// Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137 +fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option> { match loc { ValueLoc::Reg(reg) => { - let machine_reg = map_reg(reg).0 as u8; + let machine_reg = map_reg(isa, reg).0 as u8; assert!(machine_reg <= 32); // FIXME Some(vec![gimli::constants::DW_OP_reg0.0 + machine_reg]) } From 992fae08c497d4f7af35cfa3b94a2036df3cc868 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 17 Mar 2020 16:26:56 +0100 Subject: [PATCH 1210/1566] Simplify handling of unimplemented stuff --- src/abi/mod.rs | 6 +++--- src/base.rs | 2 +- src/driver/mod.rs | 6 ++---- src/intrinsics/mod.rs | 2 +- src/lib.rs | 6 ++++-- src/unimpl.rs | 28 ---------------------------- 6 files changed, 11 insertions(+), 39 deletions(-) delete mode 100644 src/unimpl.rs diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 0f62efea632de..e7a649ad207ca 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -173,7 +173,7 @@ pub fn get_function_name_and_sig<'tcx>( let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_sig_for_fn_abi(tcx, inst)); if fn_sig.c_variadic && !support_vararg { - unimpl!("Variadic function definitions are not yet supported"); + unimpl_fatal!(tcx, tcx.def_span(inst.def_id()), "Variadic function definitions are not yet supported"); } let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, false, inst.def.requires_caller_location(tcx)); (tcx.symbol_name(inst).name.as_str().to_string(), sig) @@ -622,7 +622,7 @@ fn codegen_call_inner<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { if fn_sig.abi != Abi::C { - unimpl!("Variadic call for non-C abi {:?}", fn_sig.abi); + unimpl_fatal!(fx.tcx, span, "Variadic call for non-C abi {:?}", fn_sig.abi); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); let abi_params = call_args @@ -631,7 +631,7 @@ fn codegen_call_inner<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - unimpl!("Non int ty {:?} for variadic call", ty); + unimpl_fatal!(fx.tcx, span, "Non int ty {:?} for variadic call", ty); } AbiParam::new(ty) }) diff --git a/src/base.rs b/src/base.rs index 1d73c69dc001d..0161a42a104a6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -700,7 +700,7 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } - _ => unimpl!("Inline assembly is not supported"), + _ => unimpl_fatal!(fx.tcx, stmt.source_info.span, "Inline assembly is not supported"), } } } diff --git a/src/driver/mod.rs b/src/driver/mod.rs index c676006aecec7..d68cb5bb7eedc 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -52,10 +52,8 @@ fn codegen_mono_items<'tcx>( }); for (mono_item, (linkage, visibility)) in mono_items { - crate::unimpl::try_unimpl(tcx, || { - let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - trans_mono_item(&mut cx, mono_item, linkage); - }); + let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); + trans_mono_item(&mut cx, mono_item, linkage); } tcx.sess.time("finalize CodegenCx", || cx.finalize()); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 5043c5ec0d86e..376eed50b00e1 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -425,7 +425,7 @@ pub fn codegen_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - unimpl!("unsupported intrinsic {}", intrinsic) + unimpl_fatal!(fx.tcx, span, "unsupported intrinsic {}", intrinsic); }; assume, (c _a) {}; diff --git a/src/lib.rs b/src/lib.rs index 15ea15a7410a2..a3fbb99eb65f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,7 +57,6 @@ mod pointer; mod pretty_clif; mod target_features_whitelist; mod trap; -mod unimpl; mod unsize; mod value_and_place; mod vtable; @@ -115,7 +114,6 @@ mod prelude { pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; pub use crate::pointer::Pointer; pub use crate::trap::*; - pub use crate::unimpl::unimpl; pub use crate::value_and_place::{CPlace, CPlaceInner, CValue}; pub use crate::CodegenCx; @@ -127,6 +125,10 @@ mod prelude { } } } + + pub macro unimpl_fatal($tcx:expr, $span:expr, $($tt:tt)*) { + $tcx.sess.span_fatal($span, &format!($($tt)*)); + } } pub struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { diff --git a/src/unimpl.rs b/src/unimpl.rs deleted file mode 100644 index b668235e75e82..0000000000000 --- a/src/unimpl.rs +++ /dev/null @@ -1,28 +0,0 @@ -//! The unimpl! macro is defined here. It is used to generate -//! a non-fatal error on not yet implemented things. - -use rustc::ty::TyCtxt; - -// Just public, because of the unimpl macro -#[doc(hidden)] -pub struct NonFatal(pub String); - -/// Use when something in the current function is unimplemented. -/// -/// This will emit an error and continue codegen at a different function. -pub macro unimpl($($tt:tt)*) { - panic!(NonFatal(format!($($tt)*))); -} - -pub fn try_unimpl(tcx: TyCtxt, f: impl FnOnce()) { - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); - - if let Err(err) = res { - match err.downcast::() { - Ok(non_fatal) => { - tcx.sess.err(&non_fatal.0); - } - Err(err) => ::std::panic::resume_unwind(err), - } - } -} From d464169beb132f44be20a8c1c78c8a69aa11fc1d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Mar 2020 20:05:57 +0100 Subject: [PATCH 1211/1566] Rustup to rustc 1.44.0-nightly (7ceebd98c 2020-03-17) --- example/mini_core.rs | 1 - rust-toolchain | 2 +- src/intrinsics/mod.rs | 72 ------------------------------------------- 3 files changed, 1 insertion(+), 74 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 2e14424d8de86..8abb72dc78696 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -477,7 +477,6 @@ pub mod intrinsics { pub fn min_align_of_val(val: &T) -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; - pub fn init() -> T; pub fn ctlz_nonzero(x: T) -> T; pub fn needs_drop() -> bool; pub fn bitreverse(x: T) -> T; diff --git a/rust-toolchain b/rust-toolchain index 9d825f30c98e9..fb96c33ad2edc 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-17 +nightly-2020-03-18 diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 376eed50b00e1..de96c4e6edec8 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -611,78 +611,6 @@ pub fn codegen_intrinsic_call<'tcx>( let dst_layout = fx.layout_of(dst_ty); ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) }; - init, () { - let layout = ret.layout(); - if layout.abi == Abi::Uninhabited { - crate::trap::trap_panic(fx, "[panic] Called intrinsic::init for uninhabited type."); - return; - } - - match *ret.inner() { - CPlaceInner::NoPlace => {} - CPlaceInner::Var(var) => { - let clif_ty = fx.clif_type(layout.ty).unwrap(); - let val = match clif_ty { - types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 0), - types::I128 => { - let zero = fx.bcx.ins().iconst(types::I64, 0); - fx.bcx.ins().iconcat(zero, zero) - } - types::F32 => { - let zero = fx.bcx.ins().iconst(types::I32, 0); - fx.bcx.ins().bitcast(types::F32, zero) - } - types::F64 => { - let zero = fx.bcx.ins().iconst(types::I64, 0); - fx.bcx.ins().bitcast(types::F64, zero) - } - _ => panic!("clif_type returned {}", clif_ty), - }; - fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); - fx.bcx.def_var(mir_var(var), val); - } - _ => { - let addr = ret.to_ptr(fx).get_addr(fx); - let layout = ret.layout(); - fx.bcx.emit_small_memset(fx.module.target_config(), addr, 0, layout.size.bytes(), 1); - } - } - }; - uninit, () { - let layout = ret.layout(); - if layout.abi == Abi::Uninhabited { - crate::trap::trap_panic(fx, "[panic] Called intrinsic::uninit for uninhabited type."); - return; - } - match *ret.inner() { - CPlaceInner::NoPlace => {}, - CPlaceInner::Var(var) => { - let clif_ty = fx.clif_type(layout.ty).unwrap(); - let val = match clif_ty { - types::I8 | types::I16 | types::I32 | types::I64 => fx.bcx.ins().iconst(clif_ty, 42), - types::I128 => { - let zero = fx.bcx.ins().iconst(types::I64, 0); - let fourty_two = fx.bcx.ins().iconst(types::I64, 42); - fx.bcx.ins().iconcat(fourty_two, zero) - } - types::F32 => { - let zero = fx.bcx.ins().iconst(types::I32, 0xdeadbeef); - fx.bcx.ins().bitcast(types::F32, zero) - } - types::F64 => { - let zero = fx.bcx.ins().iconst(types::I64, 0xcafebabedeadbeefu64 as i64); - fx.bcx.ins().bitcast(types::F64, zero) - } - _ => panic!("clif_type returned {}", clif_ty), - }; - fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); - fx.bcx.def_var(mir_var(var), val); - } - CPlaceInner::Addr(_, _) => { - // Don't write to `ret`, as the destination memory is already uninitialized. - } - } - }; write_bytes, (c dst, v val, v count) { let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty; let pointee_size = fx.layout_of(pointee_ty).size.bytes(); From d74c151b69b1b225be0bba290740e67145826620 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 18 Mar 2020 20:33:29 +0100 Subject: [PATCH 1212/1566] Fix it --- example/mini_core.rs | 1 + example/mini_core_hello_world.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 8abb72dc78696..9160540d1d552 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -481,6 +481,7 @@ pub mod intrinsics { pub fn needs_drop() -> bool; pub fn bitreverse(x: T) -> T; pub fn bswap(x: T) -> T; + pub fn write_bytes(dst: *mut T, val: u8, count: usize); } } diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 382ba99538d80..1a7534849e912 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -117,6 +117,12 @@ struct Unique { impl CoerceUnsized> for Unique where T: Unsize {} +unsafe fn zeroed() -> T { + let mut uninit = MaybeUninit { uninit: () }; + intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0, 1); + uninit.value.value +} + fn take_f32(_f: f32) {} fn take_unique(_u: Unique<()>) {} @@ -194,10 +200,6 @@ fn main() { y: !, } - unsafe fn zeroed() -> T { - intrinsics::init::() - } - unsafe fn uninitialized() -> T { MaybeUninit { uninit: () }.value.value } @@ -330,7 +332,7 @@ extern "C" fn mutate_tls(_: *mut c_void) -> *mut c_void { #[cfg(not(jit))] fn test_tls() { unsafe { - let mut attr: pthread_attr_t = intrinsics::init(); + let mut attr: pthread_attr_t = zeroed(); let mut thread: pthread_t = 0; assert_eq!(TLS, 42); From 52f90c6308fbad7212a461686287a50152d50780 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Mar 2020 12:09:21 +0100 Subject: [PATCH 1213/1566] Update Cranelift --- Cargo.lock | 47 +++++++++++++++++++++++++++-------------------- src/linkage.rs | 4 +--- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ebb67ea023cde..d808c05b3b8a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,11 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "anyhow" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "013a6e0a2cbe3d20f9c60b65458f7a7f7a5e636c5d0f45a5a6aee5d4b1f01785" + [[package]] name = "ar" version = "0.8.0" @@ -38,16 +44,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ "byteorder", "cranelift-bforest", @@ -63,8 +69,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -72,18 +78,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" [[package]] name = "cranelift-entity" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" [[package]] name = "cranelift-frontend" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ "cranelift-codegen", "log", @@ -93,9 +99,10 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ + "anyhow", "cranelift-codegen", "cranelift-entity", "log", @@ -104,8 +111,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -114,8 +121,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -126,8 +133,8 @@ dependencies = [ [[package]] name = "cranelift-simplejit" -version = "0.59.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#e2f6c0805231daa0524d7c770d11ced6dfe961a2" +version = "0.60.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" dependencies = [ "cranelift-codegen", "cranelift-module", diff --git a/src/linkage.rs b/src/linkage.rs index 08604e87c33ec..bf5c295622268 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -6,9 +6,7 @@ pub fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibility: Visi match (linkage, visibility) { (RLinkage::External, Visibility::Default) => Linkage::Export, (RLinkage::Internal, Visibility::Default) => Linkage::Local, - // FIXME this should get external linkage, but hidden visibility, - // not internal linkage and default visibility - (RLinkage::External, Visibility::Hidden) => Linkage::Export, + (RLinkage::External, Visibility::Hidden) => Linkage::Hidden, _ => panic!("{:?} = {:?} {:?}", mono_item, linkage, visibility), } } From 02d85dd59091076e3a973ea9f6533ab1fa0a68f2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 19 Mar 2020 13:54:38 +0100 Subject: [PATCH 1214/1566] Update dependencies --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d808c05b3b8a0..493e617d1c1f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -214,9 +214,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.67" +version = "0.2.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" +checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" [[package]] name = "libloading" From a59479bd37583b93941aa3dda2576a833cd83917 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Mar 2020 12:18:40 +0100 Subject: [PATCH 1215/1566] Add clif ir comments for stack2reg opt --- src/abi/mod.rs | 2 +- src/constant.rs | 8 +++--- src/optimize/mod.rs | 2 +- src/optimize/stack2reg.rs | 46 +++++++++++++++++--------------- src/pretty_clif.rs | 56 +++++++++++++++++++-------------------- src/trap.rs | 4 +-- src/value_and_place.rs | 2 +- 7 files changed, 61 insertions(+), 59 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index e7a649ad207ca..5f7939a1ca76e 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -200,7 +200,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { .declare_func_in_func(func_id, &mut self.bcx.func); #[cfg(debug_assertions)] - self.add_entity_comment(func_ref, format!("{:?}", inst)); + self.add_comment(func_ref, format!("{:?}", inst)); func_ref } diff --git a/src/constant.rs b/src/constant.rs index 2f702a53e0795..e6953b97a5d2b 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -52,7 +52,7 @@ fn codegen_static_ref<'tcx>( 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_entity_comment(local_data_id, format!("{:?}", def_id)); + fx.add_comment(local_data_id, format!("{:?}", def_id)); cplace_for_dataid(fx, layout, local_data_id) } @@ -114,7 +114,7 @@ pub fn trans_const_value<'tcx>( let data_id = data_id_for_alloc_id(fx.module, ptr.alloc_id, alloc.align); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] - fx.add_entity_comment(local_data_id, format!("{:?}", ptr.alloc_id)); + fx.add_comment(local_data_id, format!("{:?}", ptr.alloc_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { @@ -128,7 +128,7 @@ pub fn trans_const_value<'tcx>( 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_entity_comment(local_data_id, format!("{:?}", def_id)); + fx.add_comment(local_data_id, format!("{:?}", def_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } None => bug!("missing allocation {:?}", ptr.alloc_id), @@ -200,7 +200,7 @@ fn trans_const_place<'tcx>( let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] - fx.add_entity_comment(local_data_id, format!("{:?}", alloc_id)); + fx.add_comment(local_data_id, format!("{:?}", alloc_id)); cplace_for_dataid(fx, fx.layout_of(const_.ty), local_data_id) } diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 23c14a57c56ad..f6d02e999e1b2 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -16,7 +16,7 @@ pub fn optimize_function<'tcx>( if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No { return; // FIXME classify optimizations over opt levels } - self::stack2reg::optimize_function(ctx, clif_comments, instance); + self::stack2reg::optimize_function(ctx, clif_comments); #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None); crate::base::verify_func(tcx, &*clif_comments, &ctx.func); diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 4e9cff7636558..757e608d73390 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -10,6 +10,7 @@ //! being loaded by a `stack_load`. use std::collections::{BTreeMap, HashSet}; +use std::fmt; use std::ops::Not; use cranelift_codegen::cursor::{Cursor, FuncCursor}; @@ -19,9 +20,15 @@ use cranelift_codegen::ir::immediates::Offset32; use crate::prelude::*; /// Workaround for `StackSlot` not implementing `Ord`. -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq)] struct OrdStackSlot(StackSlot); +impl fmt::Debug for OrdStackSlot { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}", self.0) + } +} + impl PartialOrd for OrdStackSlot { fn partial_cmp(&self, rhs: &Self) -> Option { self.0.as_u32().partial_cmp(&rhs.0.as_u32()) @@ -153,10 +160,9 @@ impl<'a> OptimizeContext<'a> { } } -pub(super) fn optimize_function( +pub(super) fn optimize_function( ctx: &mut Context, - _clif_comments: &mut crate::pretty_clif::CommentWriter, - name: T, + clif_comments: &mut crate::pretty_clif::CommentWriter, ) { combine_stack_addr_with_load_store(&mut ctx.func); @@ -167,7 +173,9 @@ pub(super) fn optimize_function( remove_unused_stack_addr_and_stack_load(&mut opt_ctx); #[cfg(debug_assertions)] { - println!("stack slot usage: {:?}", opt_ctx.stack_slot_usage_map); + for (&OrdStackSlot(stack_slot), usage) in &opt_ctx.stack_slot_usage_map { + clif_comments.add_comment(stack_slot, format!("used by: {:?}", usage)); + } } for (stack_slot, users) in opt_ctx.stack_slot_usage_map.iter_mut() { @@ -182,28 +190,26 @@ pub(super) fn optimize_function( #[cfg(debug_assertions)] for &store in &potential_stores { - println!( + clif_comments.add_comment(load, format!( "Potential store -> load forwarding {} -> {} ({:?}, {:?})", opt_ctx.ctx.func.dfg.display_inst(store, None), opt_ctx.ctx.func.dfg.display_inst(load, None), spatial_overlap(&opt_ctx.ctx.func, store, load), temporal_order(&opt_ctx.ctx, store, load), - ); + )); } match *potential_stores { [] => { - #[cfg(debug_assertions)] { - println!("[{:?}] [BUG?] Reading uninitialized memory", name); - } + #[cfg(debug_assertions)] + clif_comments.add_comment(load, format!("[BUG?] Reading uninitialized memory")); } [store] if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&opt_ctx.ctx, store, load) == TemporalOrder::DefinitivelyBefore => { // Only one store could have been the origin of the value. let stored_value = opt_ctx.ctx.func.dfg.inst_args(store)[0]; - #[cfg(debug_assertions)] { - println!("Store to load forward {} -> {}", store, load); - } + #[cfg(debug_assertions)] + clif_comments.add_comment(load, format!("Store to load forward {} -> {}", store, load)); users.change_load_to_alias(&mut opt_ctx.ctx.func, load, stored_value); } @@ -216,22 +222,22 @@ pub(super) fn optimize_function( #[cfg(debug_assertions)] for &load in &potential_loads { - println!( + clif_comments.add_comment(store, format!( "Potential load from store {} <- {} ({:?}, {:?})", opt_ctx.ctx.func.dfg.display_inst(load, None), opt_ctx.ctx.func.dfg.display_inst(store, None), spatial_overlap(&opt_ctx.ctx.func, store, load), temporal_order(&opt_ctx.ctx, store, load), - ); + )); } if potential_loads.is_empty() { // Never loaded; can safely remove all stores and the stack slot. // FIXME also remove stores when there is always a next store before a load. - #[cfg(debug_assertions)] { - println!("[{:?}] Remove dead stack store {} of {}", name, opt_ctx.ctx.func.dfg.display_inst(store, None), stack_slot.0); - } + #[cfg(debug_assertions)] + clif_comments.add_comment(store, format!("Remove dead stack store {} of {}", opt_ctx.ctx.func.dfg.display_inst(store, None), stack_slot.0)); + users.remove_dead_store(&mut opt_ctx.ctx.func, store); } } @@ -240,10 +246,6 @@ pub(super) fn optimize_function( opt_ctx.ctx.func.stack_slots[stack_slot.0].size = 0; } } - - #[cfg(debug_assertions)] { - println!(); - } } fn combine_stack_addr_with_load_store(func: &mut Function) { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index e619be41cb18d..a2872af53f99c 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -69,7 +69,6 @@ use crate::prelude::*; pub struct CommentWriter { global_comments: Vec, entity_comments: HashMap, - inst_comments: HashMap, } impl CommentWriter { @@ -94,7 +93,30 @@ impl CommentWriter { CommentWriter { global_comments, entity_comments: HashMap::new(), - inst_comments: HashMap::new(), + } + } +} + +#[cfg(debug_assertions)] +impl CommentWriter { + pub fn add_global_comment>(&mut self, comment: S) { + self.global_comments.push(comment.into()); + } + + pub fn add_comment<'s, S: Into>, E: Into>( + &mut self, + entity: E, + comment: S, + ) { + use std::collections::hash_map::Entry; + match self.entity_comments.entry(entity.into()) { + Entry::Occupied(mut occ) => { + occ.get_mut().push('\n'); + occ.get_mut().push_str(comment.into().as_ref()); + } + Entry::Vacant(vac) => { + vac.insert(comment.into().into_owned()); + } } } } @@ -157,7 +179,7 @@ impl FuncWriter for &'_ CommentWriter { indent: usize, ) -> fmt::Result { PlainWriter.write_instruction(w, func, aliases, isa, inst, indent)?; - if let Some(comment) = self.inst_comments.get(&inst) { + if let Some(comment) = self.entity_comments.get(&inst.into()) { writeln!(w, "; {}", comment.replace('\n', "\n; "))?; } Ok(()) @@ -167,37 +189,15 @@ impl FuncWriter for &'_ CommentWriter { #[cfg(debug_assertions)] impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub fn add_global_comment>(&mut self, comment: S) { - self.clif_comments.global_comments.push(comment.into()); + self.clif_comments.add_global_comment(comment); } - pub fn add_entity_comment<'s, S: Into>, E: Into>( + pub fn add_comment<'s, S: Into>, E: Into>( &mut self, entity: E, comment: S, ) { - use std::collections::hash_map::Entry; - match self.clif_comments.entity_comments.entry(entity.into()) { - Entry::Occupied(mut occ) => { - occ.get_mut().push('\n'); - occ.get_mut().push_str(comment.into().as_ref()); - } - Entry::Vacant(vac) => { - vac.insert(comment.into().into_owned()); - } - } - } - - pub fn add_comment<'s, S: Into>>(&mut self, inst: Inst, comment: S) { - use std::collections::hash_map::Entry; - match self.clif_comments.inst_comments.entry(inst) { - Entry::Occupied(mut occ) => { - occ.get_mut().push('\n'); - occ.get_mut().push_str(comment.into().as_ref()); - } - Entry::Vacant(vac) => { - vac.insert(comment.into().into_owned()); - } - } + self.clif_comments.add_comment(entity, comment); } } diff --git a/src/trap.rs b/src/trap.rs index a223e6397da6d..c13260424ff7b 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -19,7 +19,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let puts = fx.module.declare_func_in_func(puts, &mut fx.bcx.func); #[cfg(debug_assertions)] { - fx.add_entity_comment(puts, "puts"); + fx.add_comment(puts, "puts"); } let symbol_name = fx.tcx.symbol_name(fx.instance); @@ -46,7 +46,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); #[cfg(debug_assertions)] { - fx.add_entity_comment(local_msg_id, msg); + fx.add_comment(local_msg_id, msg); } let msg_ptr = fx.bcx.ins().global_value(pointer_ty(fx.tcx), local_msg_id); fx.bcx.ins().call(puts, &[msg_ptr]); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 9024d59ecb4f9..64d585e8a993e 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -381,7 +381,7 @@ impl<'tcx> CPlace<'tcx> { }; fx.add_comment( fx.bcx.func.layout.last_inst(cur_block).unwrap(), - format!("write_cvalue: {:?} <- {:?}",self, from), + format!("write_cvalue: {:?}: {:?} <- {:?}: {:?}", self.inner(), self.layout().ty, from.0, from.layout().ty), ); } From e9db3e781760a5fafd125259a21b63bcf734af07 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 20 Mar 2020 16:29:05 +0100 Subject: [PATCH 1216/1566] Avoid u/i*::{min.max}_value() They will be deprecated in the future --- src/codegen_i128.rs | 2 +- src/common.rs | 24 ++++++++++++------------ src/discriminant.rs | 2 +- src/intrinsics/mod.rs | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index be0ed1668f859..f1bdb49b74ad6 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -108,7 +108,7 @@ pub fn maybe_codegen<'tcx>( } (BinOp::Shr, true) => { let sign = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, lhs_msb, 0); - let all_ones = fx.bcx.ins().iconst(types::I64, u64::max_value() as i64); + let all_ones = fx.bcx.ins().iconst(types::I64, u64::MAX as i64); let all_sign_bits = fx.bcx.ins().select(sign, all_zeros, all_ones); let val = fx.bcx.ins().iconcat(lhs_msb, all_sign_bits); diff --git a/src/common.rs b/src/common.rs index 5d99b385779ff..f0cc8dd4db7f6 100644 --- a/src/common.rs +++ b/src/common.rs @@ -221,23 +221,23 @@ pub fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { (types::I8, false) | (types::I16, false) | (types::I32, false) | (types::I64, false) => { 0i64 } - (types::I8, true) => i8::min_value() as i64, - (types::I16, true) => i16::min_value() as i64, - (types::I32, true) => i32::min_value() as i64, - (types::I64, true) => i64::min_value(), + (types::I8, true) => i8::MIN as i64, + (types::I16, true) => i16::MIN as i64, + (types::I32, true) => i32::MIN as i64, + (types::I64, true) => i64::MIN, (types::I128, _) => unimplemented!(), _ => unreachable!(), }; let max = match (ty, signed) { - (types::I8, false) => u8::max_value() as i64, - (types::I16, false) => u16::max_value() as i64, - (types::I32, false) => u32::max_value() as i64, - (types::I64, false) => u64::max_value() as i64, - (types::I8, true) => i8::max_value() as i64, - (types::I16, true) => i16::max_value() as i64, - (types::I32, true) => i32::max_value() as i64, - (types::I64, true) => i64::max_value(), + (types::I8, false) => u8::MAX as i64, + (types::I16, false) => u16::MAX as i64, + (types::I32, false) => u32::MAX as i64, + (types::I64, false) => u64::MAX as i64, + (types::I8, true) => i8::MAX as i64, + (types::I16, true) => i16::MAX as i64, + (types::I32, true) => i32::MAX as i64, + (types::I64, true) => i64::MAX, (types::I128, _) => unimplemented!(), _ => unreachable!(), }; diff --git a/src/discriminant.rs b/src/discriminant.rs index 6389bd6277cef..82d2d9fd8b36b 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -119,7 +119,7 @@ pub fn codegen_get_discriminant<'tcx>( let relative_discr = if niche_start == 0 { encoded_discr } else { - // FIXME handle niche_start > i64::max_value() + // FIXME handle niche_start > i64::MAX fx.bcx .ins() .iadd_imm(encoded_discr, -i64::try_from(niche_start).unwrap()) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index de96c4e6edec8..24dd7b07d222e 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -227,7 +227,7 @@ fn bool_to_zero_or_max_uint<'tcx>( let max = fx .bcx .ins() - .iconst(int_ty, (u64::max_value() >> (64 - int_ty.bits())) as i64); + .iconst(int_ty, (u64::MAX >> (64 - int_ty.bits())) as i64); let mut res = fx.bcx.ins().select(val, max, zero); if ty.is_float() { From 6b30d508f7c624140b34ccd677bd66e5830bac6c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Mar 2020 16:52:02 +0100 Subject: [PATCH 1217/1566] Fix some FIXME's and add some new FIXME's --- src/archive.rs | 10 +--------- src/base.rs | 1 - src/debuginfo/mod.rs | 2 +- src/intrinsics/mod.rs | 2 ++ 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 19ca3ea770306..49bbc1da606a4 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -184,15 +184,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let (ref src_archive_path, ref mut src_archive) = self.src_archives[archive_index]; let entry = src_archive.jump_to_entry(entry_index).unwrap(); - let orig_header = entry.header(); - - // FIXME implement clone for `ar::Archive`. - let mut header = - ar::Header::new(orig_header.identifier().to_vec(), orig_header.size()); - header.set_mtime(orig_header.mtime()); - header.set_uid(orig_header.uid()); - header.set_gid(orig_header.gid()); - header.set_mode(orig_header.mode()); + let header = entry.header().clone(); match builder { BuilderKind::Bsd(ref mut builder) => { diff --git a/src/base.rs b/src/base.rs index 0161a42a104a6..4a865fdb73142 100644 --- a/src/base.rs +++ b/src/base.rs @@ -432,7 +432,6 @@ fn trans_stmt<'tcx>( UnOp::Not => { match layout.ty.kind { ty::Bool => { - let val = fx.bcx.ins().uextend(types::I32, val); // WORKAROUND for CraneStation/cranelift#466 let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout) } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index c1fb6c92c316a..363abb8cd772b 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -50,7 +50,7 @@ impl<'tcx> DebugContext<'tcx> { // FIXME: how to get version when building out of tree? // Normally this would use option_env!("CFG_VERSION"). - let producer = format!("cranelift fn (rustc version {})", "unknown version"); + let producer = format!("cg_clif (rustc {})", "unknown version"); let comp_dir = tcx.sess.working_dir.0.to_string_lossy().into_owned(); let name = match tcx.sess.local_crate_source_file { Some(ref path) => path.to_string_lossy().into_owned(), diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 24dd7b07d222e..2df8948054fcc 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -761,6 +761,7 @@ pub fn codegen_intrinsic_call<'tcx>( volatile_load, (c ptr) { // Cranelift treats loads as volatile by default + // FIXME ignore during stack2reg optimization let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); let val = CValue::by_ref(Pointer::new(ptr.load_scalar(fx)), inner_layout); @@ -768,6 +769,7 @@ pub fn codegen_intrinsic_call<'tcx>( }; volatile_store, (v ptr, c val) { // Cranelift treats stores as volatile by default + // FIXME ignore during stack2reg optimization let dest = CPlace::for_ptr(Pointer::new(ptr), val.layout()); dest.write_cvalue(fx, val); }; From 9d014d77813fd28b29d4c3fd166d429274fc94a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 21 Mar 2020 16:54:48 +0100 Subject: [PATCH 1218/1566] [ci] Remove Travis CI This completes the switch to github actions --- .travis.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a56566d89b5c4..0000000000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: rust -cache: - directories: - - $HOME/.cargo - -os: - - linux - - osx - -rust: - - nightly - -script: - - ./prepare.sh - - ./test.sh --release - -env: - global: - # Enable backtraces for easier debugging. - - RUST_BACKTRACE=1 - # Reduce amount of benchmark runs as they are slow. - - COMPILE_RUNS=2 RUN_RUNS=2 From eb3d35834665a3c0459e24a4e42934fb4bd7eba5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2020 05:22:45 +0000 Subject: [PATCH 1219/1566] Bump cranelift-codegen from `1c55eb1` to `c202a8e` Bumps [cranelift-codegen](https://github.com/bytecodealliance/wasmtime) from `1c55eb1` to `c202a8e`. - [Release notes](https://github.com/bytecodealliance/wasmtime/releases) - [Commits](https://github.com/bytecodealliance/wasmtime/compare/1c55eb1a8bba9e59df604a0df2b6552dd54e76a7...c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 493e617d1c1f1..e1ba6a28fbaf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" [[package]] name = "cranelift-entity" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" [[package]] name = "cranelift-frontend" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1c55eb1a8bba9e59df604a0df2b6552dd54e76a7" +source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" dependencies = [ "cranelift-codegen", "cranelift-module", From 3c9ebdb19401965913b2b1dd81de1381058c87ad Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Mar 2020 13:09:44 +0100 Subject: [PATCH 1220/1566] Rustup to rustc 1.44.0-nightly (1edd389cc 2020-03-23) --- example/mini_core.rs | 4 ++-- rust-toolchain | 2 +- rustup.sh | 1 + src/abi/mod.rs | 6 +++--- src/backend.rs | 2 +- src/driver/aot.rs | 2 +- src/lib.rs | 14 ++++++-------- src/main_shim.rs | 2 +- src/metadata.rs | 2 +- src/target_features_whitelist.rs | 2 +- 10 files changed, 18 insertions(+), 19 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 9160540d1d552..5311d84e72ac9 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -472,9 +472,9 @@ pub mod intrinsics { extern "rust-intrinsic" { pub fn abort() -> !; pub fn size_of() -> usize; - pub fn size_of_val(val: &T) -> usize; + pub fn size_of_val(val: *const T) -> usize; pub fn min_align_of() -> usize; - pub fn min_align_of_val(val: &T) -> usize; + pub fn min_align_of_val(val: *const T) -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; pub fn ctlz_nonzero(x: T) -> T; diff --git a/rust-toolchain b/rust-toolchain index fb96c33ad2edc..295c041848b61 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-18 +nightly-2020-03-24 diff --git a/rustup.sh b/rustup.sh index aeb60c50c0939..01ce5bb78be0f 100755 --- a/rustup.sh +++ b/rustup.sh @@ -19,6 +19,7 @@ case $1 in ./prepare.sh ;; "commit") + git add rust-toolchain git commit -m "Rustup to $(rustc -V)" ;; *) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 5f7939a1ca76e..5d6a0772ce8fc 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -32,7 +32,7 @@ pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> t sig } ty::Closure(def_id, substs) => { - let sig = substs.as_closure().sig(def_id, tcx); + let sig = substs.as_closure().sig(); let env_ty = tcx.closure_env_ty(def_id, substs).unwrap(); sig.map_bound(|sig| tcx.mk_fn_sig( @@ -43,8 +43,8 @@ pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> t sig.abi )) } - ty::Generator(def_id, substs, _) => { - let sig = substs.as_generator().poly_sig(def_id, tcx); + ty::Generator(_def_id, substs, _) => { + let sig = substs.as_generator().poly_sig(); let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty); diff --git a/src/backend.rs b/src/backend.rs index 2113fca86dd06..5c57e16125c68 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use std::convert::TryFrom; -use rustc::session::Session; +use rustc_session::Session; use cranelift_module::{FuncId, Module}; diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 3473b0ae40c65..71876816f39fd 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -1,7 +1,7 @@ use rustc::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; use rustc::middle::cstore::EncodedMetadata; use rustc::mir::mono::CodegenUnit; -use rustc::session::config::{DebugInfo, OutputType}; +use rustc_session::config::{DebugInfo, OutputType}; use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_codegen_ssa::back::linker::LinkerInfo; use rustc_codegen_ssa::CrateInfo; diff --git a/src/lib.rs b/src/lib.rs index a3fbb99eb65f0..061f78c8a929d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,6 @@ extern crate libc; extern crate tempfile; extern crate rustc; extern crate rustc_codegen_ssa; -extern crate rustc_codegen_utils; extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_fs_util; @@ -16,6 +15,7 @@ extern crate rustc_index; extern crate rustc_mir; extern crate rustc_session; extern crate rustc_span; +extern crate rustc_symbol_mangling; extern crate rustc_target; extern crate rustc_ast; @@ -23,10 +23,10 @@ use std::any::Any; use rustc::dep_graph::{DepGraph, WorkProduct, WorkProductId}; use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; -use rustc::session::config::OutputFilenames; +use rustc_session::config::OutputFilenames; use rustc::ty::query::Providers; use rustc::util::common::ErrorReported; -use rustc_codegen_utils::codegen_backend::CodegenBackend; +use rustc_codegen_ssa::traits::CodegenBackend; use cranelift_codegen::settings; @@ -72,7 +72,7 @@ mod prelude { pub use rustc::bug; pub use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; pub use rustc::mir::{self, interpret::AllocId, mono::MonoItem, *}; - pub use rustc::session::{ + pub use rustc_session::{ config::{CrateType, Lto}, Session, }; @@ -203,12 +203,10 @@ impl CodegenBackend for CraneliftCodegenBackend { metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box { - rustc_codegen_utils::check_for_rustc_errors_attr(tcx); - let res = driver::codegen_crate(tcx, metadata, need_metadata_module); rustc_incremental::assert_module_sources::assert_module_sources(tcx); - rustc_codegen_utils::symbol_names_test::report_symbol_names(tcx); + rustc_symbol_mangling::test::report_symbol_names(tcx); res } @@ -296,7 +294,7 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box { flags_builder.set("opt_level", "fastest").unwrap(); diff --git a/src/main_shim.rs b/src/main_shim.rs index 74ee0d8fee81b..145dd704badc2 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -4,7 +4,7 @@ use crate::prelude::*; /// users main function. pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { use rustc::middle::lang_items::StartFnLangItem; - use rustc::session::config::EntryFnType; + use rustc_session::config::EntryFnType; let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) { Some((def_id, entry_ty)) => ( diff --git a/src/metadata.rs b/src/metadata.rs index c1f2534111ead..cedbff914bfd5 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -3,7 +3,7 @@ use std::fs::File; use std::path::Path; use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; -use rustc::session::config; +use rustc_session::config; use rustc::ty::TyCtxt; use rustc_codegen_ssa::METADATA_FILENAME; use rustc_data_structures::owning_ref::{self, OwningRef}; diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index 20e31e1918994..cbc88fc6b5180 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -1,6 +1,6 @@ use rustc_span::symbol::{sym, Symbol}; -use rustc::session::Session; +use rustc_session::Session; // Copied from https://github.com/rust-lang/rust/blob/f69b07144a151f46aaee1b6230ba4160e9394562/src/librustc_codegen_llvm/llvm_util.rs#L93-L264 From 5c9b9305b754065f6573d01fc27d1631b01a7abd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Mar 2020 13:17:03 +0100 Subject: [PATCH 1221/1566] Update Cranelift and object --- Cargo.lock | 72 +++++++++++-------------------------------------- Cargo.toml | 2 +- src/metadata.rs | 8 +++--- 3 files changed, 22 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1ba6a28fbaf3..041b76ff5f301 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" [[package]] name = "cranelift-entity" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" [[package]] name = "cranelift-frontend" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,11 +122,10 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "cranelift-codegen", "cranelift-module", - "goblin", "object", "target-lexicon", ] @@ -134,7 +133,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c202a8eeaf8f72a5e87d50ac2f0d58c9170b3488" +source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -192,17 +191,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "goblin" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" -dependencies = [ - "log", - "plain", - "scroll", -] - [[package]] name = "indexmap" version = "1.3.2" @@ -248,24 +236,16 @@ dependencies = [ [[package]] name = "object" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae" +checksum = "e5666bbb90bc4d1e5bdcb26c0afda1822d25928341e9384ab187a9b37ab69e36" dependencies = [ "crc32fast", - "goblin", "indexmap", - "scroll", "target-lexicon", - "uuid", + "wasmparser", ] -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - [[package]] name = "proc-macro2" version = "1.0.9" @@ -334,26 +314,6 @@ dependencies = [ "semver", ] -[[package]] -name = "scroll" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" -dependencies = [ - "scroll_derive", -] - -[[package]] -name = "scroll_derive" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "semver" version = "0.9.0" @@ -419,10 +379,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] -name = "uuid" -version = "0.8.1" +name = "wasmparser" +version = "0.51.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" [[package]] name = "winapi" diff --git a/Cargo.toml b/Cargo.toml index dbd9eef4937a4..ab8410c49fd08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ byteorder = "1.2.7" indexmap = "1.0.2" [dependencies.object] -version = "0.17.0" +version = "0.18.0" default-features = false features = ["read", "std", "write"] # We don't need WASM support diff --git a/src/metadata.rs b/src/metadata.rs index cedbff914bfd5..3c3a7c5014910 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -44,13 +44,15 @@ impl MetadataLoader for CraneliftMetadataLoader { _target: &Target, path: &Path, ) -> Result, String> { - use object::Object; + use object::{Object, ObjectSection}; let file = std::fs::read(path).map_err(|e| format!("read:{:?}", e))?; let file = object::File::parse(&file).map_err(|e| format!("parse: {:?}", e))?; let buf = file - .section_data_by_name(".rustc") + .section_by_name(".rustc") .ok_or("no .rustc section")? - .into_owned(); + .data() + .map_err(|e| format!("failed to read .rustc section: {:?}", e))? + .to_owned(); let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); Ok(rustc_erase_owner!(buf.map_owner_box())) } From dc76cd0551d140f1455cb0969de070cc2cd3fdcc Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Mar 2020 13:20:26 +0100 Subject: [PATCH 1222/1566] Update dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 041b76ff5f301..dace6acc72de4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -337,9 +337,9 @@ checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" [[package]] name = "syn" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" +checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" dependencies = [ "proc-macro2", "quote", @@ -354,18 +354,18 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "thiserror" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee14bf8e6767ab4c687c9e8bc003879e042a96fd67a3ba5934eadb6536bef4db" +checksum = "e3711fd1c4e75b3eff12ba5c40dba762b6b65c5476e8174c1a664772060c49bf" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7b51e1fbc44b5a0840be594fbc0f960be09050f2617e61e6aa43bef97cd3ef4" +checksum = "ae2b85ba4c9aa32dd3343bd80eb8d22e9b54b7688c17ea3907f236885353b233" dependencies = [ "proc-macro2", "quote", From b113e88ddb399f92f0d044caa35e668d2499bdd9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 24 Mar 2020 13:41:19 +0100 Subject: [PATCH 1223/1566] Fix warnings --- src/abi/pass_mode.rs | 2 ++ src/abi/returning.rs | 3 +++ src/optimize/mod.rs | 1 + src/optimize/stack2reg.rs | 1 + src/pointer.rs | 1 + src/pretty_clif.rs | 16 +++++++--------- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 3c19787ef9252..dc6908fc72dcf 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -130,7 +130,9 @@ pub(super) fn adjust_arg_for_abi<'tcx>( pub(super) fn cvalue_for_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_block: Block, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] local: Option, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] local_field: Option, arg_ty: Ty<'tcx>, ) -> Option> { diff --git a/src/abi/returning.rs b/src/abi/returning.rs index b4dd04002cf8f..0262728bb67c3 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -43,6 +43,9 @@ pub(super) fn codegen_return_param( PassMode::ByRef { sized: false } => todo!(), }; + #[cfg(not(debug_assertions))] + let _ = ret_param; + #[cfg(debug_assertions)] crate::abi::comments::add_arg_comment( fx, diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index f6d02e999e1b2..29ad5321d5772 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -5,6 +5,7 @@ mod stack2reg; pub fn optimize_function<'tcx>( tcx: TyCtxt<'tcx>, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] instance: Instance<'tcx>, ctx: &mut Context, cold_blocks: &EntitySet, diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 757e608d73390..b21f838111c26 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -162,6 +162,7 @@ impl<'a> OptimizeContext<'a> { pub(super) fn optimize_function( ctx: &mut Context, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] clif_comments: &mut crate::pretty_clif::CommentWriter, ) { combine_stack_addr_with_load_store(&mut ctx.func); diff --git a/src/pointer.rs b/src/pointer.rs index 0ecb0e1274e40..b9183aeedc9e2 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -37,6 +37,7 @@ impl Pointer { } } + #[cfg(debug_assertions)] pub fn base_and_offset(self) -> (PointerBase, Offset32) { (self.base, self.offset) } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index a2872af53f99c..725df448161ad 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -1,12 +1,10 @@ -use std::borrow::Cow; use std::collections::HashMap; use std::fmt; use cranelift_codegen::{ entity::SecondaryMap, - ir::{self, entities::AnyEntity, function::DisplayFunctionAnnotations}, + ir::{entities::AnyEntity, function::DisplayFunctionAnnotations}, write::{FuncWriter, PlainWriter}, - ValueLabelsRanges, }; use crate::prelude::*; @@ -103,7 +101,7 @@ impl CommentWriter { self.global_comments.push(comment.into()); } - pub fn add_comment<'s, S: Into>, E: Into>( + pub fn add_comment + AsRef, E: Into>( &mut self, entity: E, comment: S, @@ -112,10 +110,10 @@ impl CommentWriter { match self.entity_comments.entry(entity.into()) { Entry::Occupied(mut occ) => { occ.get_mut().push('\n'); - occ.get_mut().push_str(comment.into().as_ref()); + occ.get_mut().push_str(comment.as_ref()); } Entry::Vacant(vac) => { - vac.insert(comment.into().into_owned()); + vac.insert(comment.into()); } } } @@ -192,7 +190,7 @@ impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { self.clif_comments.add_global_comment(comment); } - pub fn add_comment<'s, S: Into>, E: Into>( + pub fn add_comment + AsRef, E: Into>( &mut self, entity: E, comment: S, @@ -206,9 +204,9 @@ pub fn write_clif_file<'tcx>( tcx: TyCtxt<'tcx>, postfix: &str, instance: Instance<'tcx>, - func: &ir::Function, + func: &cranelift_codegen::ir::Function, mut clif_comments: &CommentWriter, - value_ranges: Option<&ValueLabelsRanges>, + value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>, ) { use std::io::Write; From f288959c00f8f78df21a706c6e6188d4bfb909b4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Mar 2020 12:14:45 +0100 Subject: [PATCH 1224/1566] Limit publicness to crate where possible and remove unused imports --- src/abi/comments.rs | 6 +- src/abi/mod.rs | 20 +++---- src/abi/pass_mode.rs | 4 +- src/abi/returning.rs | 4 +- src/allocator.rs | 2 +- src/analyze.rs | 4 +- src/archive.rs | 2 +- src/atomic_shim.rs | 6 +- src/backend.rs | 12 ++-- src/base.rs | 8 +-- src/cast.rs | 4 +- src/codegen_i128.rs | 2 +- src/common.rs | 62 ++++++++++----------- src/constant.rs | 12 ++-- src/debuginfo/emit.rs | 14 ++--- src/debuginfo/line_info.rs | 4 +- src/debuginfo/mod.rs | 12 ++-- src/discriminant.rs | 4 +- src/driver/jit.rs | 2 +- src/driver/mod.rs | 6 +- src/intrinsics/llvm.rs | 2 +- src/intrinsics/mod.rs | 6 +- src/lib.rs | 96 ++++++++++++++------------------ src/linkage.rs | 4 +- src/main_shim.rs | 2 +- src/metadata.rs | 4 +- src/num.rs | 14 ++--- src/optimize/mod.rs | 2 +- src/pointer.rs | 24 ++++---- src/pretty_clif.rs | 14 ++--- src/target_features_whitelist.rs | 4 +- src/trap.rs | 10 ++-- src/unsize.rs | 6 +- src/value_and_place.rs | 68 +++++++++++----------- src/vtable.rs | 10 ++-- 35 files changed, 225 insertions(+), 231 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 71df9dba61b65..0ac3bec74c7b7 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -5,7 +5,7 @@ use rustc::mir; use crate::abi::pass_mode::*; use crate::prelude::*; -pub fn add_args_header_comment(fx: &mut FunctionCx) { +pub(super) fn add_args_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(format!( "kind loc.idx param pass mode ty" )); @@ -49,14 +49,14 @@ pub(super) fn add_arg_comment<'tcx>( )); } -pub fn add_locals_header_comment(fx: &mut FunctionCx) { +pub(super) fn add_locals_header_comment(fx: &mut FunctionCx) { fx.add_global_comment(String::new()); fx.add_global_comment(format!( "kind local ty size align (abi,pref)" )); } -pub fn add_local_place_comments<'tcx>( +pub(super) fn add_local_place_comments<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: CPlace<'tcx>, local: Local, diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 5d6a0772ce8fc..2e7a73a484d34 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -10,10 +10,10 @@ use cranelift_codegen::ir::AbiParam; use self::pass_mode::*; use crate::prelude::*; -pub use self::returning::{can_return_to_ssa_var, codegen_return}; +pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return}; // Copied from https://github.com/rust-lang/rust/blob/c2f4c57296f0d929618baed0b0d6eb594abf01eb/src/librustc/ty/layout.rs#L2349 -pub fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { +pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { let ty = instance.monomorphic_ty(tcx); match ty.kind { ty::FnDef(..) | @@ -163,7 +163,7 @@ fn clif_sig_from_fn_sig<'tcx>( } } -pub fn get_function_name_and_sig<'tcx>( +pub(crate) fn get_function_name_and_sig<'tcx>( tcx: TyCtxt<'tcx>, triple: &target_lexicon::Triple, inst: Instance<'tcx>, @@ -180,7 +180,7 @@ pub fn get_function_name_and_sig<'tcx>( } /// Instance must be monomorphized -pub fn import_function<'tcx>( +pub(crate) fn import_function<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, inst: Instance<'tcx>, @@ -193,7 +193,7 @@ pub fn import_function<'tcx>( impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized - pub fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { + pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { let func_id = import_function(self.tcx, self.module, inst); let func_ref = self .module @@ -234,7 +234,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { results } - pub fn easy_call( + pub(crate) fn easy_call( &mut self, name: &str, args: &[CValue<'tcx>], @@ -288,7 +288,7 @@ fn local_place<'tcx>( fx.local_map[&local] } -pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block: Block, should_codegen_locals: bool) { +pub(crate) fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block: Block, should_codegen_locals: bool) { let ssa_analyzed = crate::analyze::analyze(fx); #[cfg(debug_assertions)] @@ -423,7 +423,7 @@ pub fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block .jump(*fx.block_map.get(START_BLOCK).unwrap(), &[]); } -pub fn codegen_terminator_call<'tcx>( +pub(crate) fn codegen_terminator_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, span: Span, func: &Operand<'tcx>, @@ -444,7 +444,7 @@ pub fn codegen_terminator_call<'tcx>( ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs).unwrap(); if fx.tcx.symbol_name(instance).name.as_str().starts_with("llvm.") { - crate::intrinsics::llvm::codegen_llvm_intrinsic_call( + crate::intrinsics::codegen_llvm_intrinsic_call( fx, &fx.tcx.symbol_name(instance).name.as_str(), substs, @@ -640,7 +640,7 @@ fn codegen_call_inner<'tcx>( } } -pub fn codegen_drop<'tcx>( +pub(crate) fn codegen_drop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, span: Span, drop_place: CPlace<'tcx>, diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index dc6908fc72dcf..bed4574717e6d 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -3,7 +3,7 @@ use crate::prelude::*; pub(super) use EmptySinglePair::*; #[derive(Copy, Clone, Debug)] -pub enum PassMode { +pub(super) enum PassMode { NoPass, ByVal(Type), ByValPair(Type, Type), @@ -76,7 +76,7 @@ impl PassMode { } } -pub fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> PassMode { +pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> PassMode { if layout.is_zst() { // WARNING zst arguments must never be passed, as that will break CastKind::ClosureFnPointer PassMode::NoPass diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 0262728bb67c3..59836f881b649 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -5,7 +5,7 @@ fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyLay fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty)) } -pub fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyLayout<'tcx>) -> bool { +pub(crate) fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyLayout<'tcx>) -> bool { match get_pass_mode(tcx, dest_layout) { PassMode::NoPass | PassMode::ByVal(_) => true, // FIXME Make it possible to return ByValPair and ByRef to an ssa var. @@ -101,7 +101,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( (call_inst, meta) } -pub fn codegen_return(fx: &mut FunctionCx) { +pub(crate) fn codegen_return(fx: &mut FunctionCx) { match get_pass_mode(fx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { sized: true } => { fx.bcx.ins().return_(&[]); diff --git a/src/allocator.rs b/src/allocator.rs index eeead3050d8b0..b8240f4a822bc 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -13,7 +13,7 @@ use crate::prelude::*; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created -pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { +pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| { use rustc::middle::dependency_format::Linkage; list.iter().any(|&linkage| linkage == Linkage::Dynamic) diff --git a/src/analyze.rs b/src/analyze.rs index 965e363d2ba14..b82e16217ef61 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -4,12 +4,12 @@ use rustc::mir::StatementKind::*; use rustc_index::vec::IndexVec; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub enum SsaKind { +pub(crate) enum SsaKind { NotSsa, Ssa, } -pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { +pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { let mut flag_map = fx.mir.local_decls.iter().map(|local_decl| { if fx.clif_type(fx.monomorphize(&local_decl.ty)).is_some() { SsaKind::Ssa diff --git a/src/archive.rs b/src/archive.rs index 49bbc1da606a4..6ebb713b26761 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -23,7 +23,7 @@ enum ArchiveEntry { File(PathBuf), } -pub struct ArArchiveBuilder<'a> { +pub(crate) struct ArArchiveBuilder<'a> { config: ArchiveConfig<'a>, src_archives: Vec<(PathBuf, ar::Archive)>, // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 83c1b164fc122..d277b33e1b624 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -8,7 +8,7 @@ use crate::prelude::*; #[no_mangle] pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; -pub fn init_global_lock(module: &mut Module, bcx: &mut FunctionBuilder<'_>) { +pub(crate) fn init_global_lock(module: &mut Module, bcx: &mut FunctionBuilder<'_>) { if std::env::var("CG_CLIF_JIT").is_ok () { // When using JIT, dylibs won't find the __cg_clif_global_atomic_mutex data object defined here, // so instead define it in the cg_clif dylib. @@ -46,7 +46,7 @@ pub fn init_global_lock(module: &mut Module, bcx: &mut FunctionBui bcx.ins().call(pthread_mutex_init, &[atomic_mutex, nullptr]); } -pub fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { let atomic_mutex = fx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, @@ -71,7 +71,7 @@ pub fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.bcx.ins().call(pthread_mutex_lock, &[atomic_mutex]); } -pub fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { let atomic_mutex = fx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, diff --git a/src/backend.rs b/src/backend.rs index 5c57e16125c68..723f1bca55a18 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -14,7 +14,7 @@ use gimli::SectionId; use crate::debuginfo::{DebugReloc, DebugRelocName}; -pub trait WriteMetadata { +pub(crate) trait WriteMetadata { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, is_like_osx: bool); } @@ -38,7 +38,7 @@ impl WriteMetadata for object::write::Object { } } -pub trait WriteDebugInfo { +pub(crate) trait WriteDebugInfo { type SectionId; fn add_debug_section(&mut self, name: SectionId, data: Vec) -> Self::SectionId; @@ -99,7 +99,7 @@ impl WriteDebugInfo for ObjectProduct { } } -pub trait Emit { +pub(crate) trait Emit { fn emit(self) -> Vec; } @@ -109,7 +109,7 @@ impl Emit for ObjectProduct { } } -pub fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec { +pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec { let triple = crate::build_isa(sess, true).triple().clone(); let mut metadata_object = object::write::Object::new(triple.binary_format, triple.architecture); @@ -118,9 +118,9 @@ pub fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> V metadata_object.write().unwrap() } -pub type Backend = impl cranelift_module::Backend; +pub(crate) type Backend = impl cranelift_module::Backend; -pub fn make_module(sess: &Session, name: String) -> Module { +pub(crate) fn make_module(sess: &Session, name: String) -> Module { let module: Module = Module::new( ObjectBuilder::new( crate::build_isa(sess, true), diff --git a/src/base.rs b/src/base.rs index 4a865fdb73142..a901258163847 100644 --- a/src/base.rs +++ b/src/base.rs @@ -3,7 +3,7 @@ use rustc_index::vec::IndexVec; use crate::prelude::*; -pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( +pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( cx: &mut crate::CodegenCx<'clif, 'tcx, B>, instance: Instance<'tcx>, linkage: Linkage, @@ -202,7 +202,7 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( context.clear(); } -pub fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { +pub(crate) fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { tcx.sess.time("verify clif ir", || { let flags = settings::Flags::new(settings::builder()); match ::cranelift_codegen::verify_function(&func, &flags) { @@ -724,7 +724,7 @@ fn codegen_array_len<'tcx>( } } -pub fn trans_place<'tcx>( +pub(crate) fn trans_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: &Place<'tcx>, ) -> CPlace<'tcx> { @@ -792,7 +792,7 @@ pub fn trans_place<'tcx>( cplace } -pub fn trans_operand<'tcx>( +pub(crate) fn trans_operand<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, operand: &Operand<'tcx>, ) -> CValue<'tcx> { diff --git a/src/cast.rs b/src/cast.rs index d945ad7d054bf..08dc68b08d7ef 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -pub fn clif_intcast( +pub(crate) fn clif_intcast( fx: &mut FunctionCx<'_, '_, impl Backend>, val: Value, to: Type, @@ -48,7 +48,7 @@ pub fn clif_intcast( } } -pub fn clif_int_or_float_cast( +pub(crate) fn clif_int_or_float_cast( fx: &mut FunctionCx<'_, '_, impl Backend>, from: Value, from_signed: bool, diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index f1bdb49b74ad6..e2bb5b17ba2d3 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -2,7 +2,7 @@ use crate::prelude::*; -pub fn maybe_codegen<'tcx>( +pub(crate) fn maybe_codegen<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, checked: bool, diff --git a/src/common.rs b/src/common.rs index f0cc8dd4db7f6..09133d94db237 100644 --- a/src/common.rs +++ b/src/common.rs @@ -6,11 +6,11 @@ use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use crate::prelude::*; -pub fn mir_var(loc: Local) -> Variable { +pub(crate) fn mir_var(loc: Local) -> Variable { Variable::with_u32(loc.index() as u32) } -pub fn pointer_ty(tcx: TyCtxt) -> types::Type { +pub(crate) fn pointer_ty(tcx: TyCtxt) -> types::Type { match tcx.data_layout.pointer_size.bits() { 16 => types::I16, 32 => types::I32, @@ -19,7 +19,7 @@ pub fn pointer_ty(tcx: TyCtxt) -> types::Type { } } -pub fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { +pub(crate) fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { match scalar.value { Primitive::Int(int, _sign) => match int { Integer::I8 => types::I8, @@ -72,7 +72,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { +pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not }); match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi { Abi::Scalar(_) => false, @@ -81,7 +81,7 @@ pub fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { } } -pub fn codegen_icmp( +pub(crate) fn codegen_icmp( fx: &mut FunctionCx<'_, '_, impl Backend>, intcc: IntCC, lhs: Value, @@ -126,7 +126,7 @@ pub fn codegen_icmp( } } -pub fn codegen_icmp_imm( +pub(crate) fn codegen_icmp_imm( fx: &mut FunctionCx<'_, '_, impl Backend>, intcc: IntCC, lhs: Value, @@ -207,7 +207,7 @@ fn resolve_128bit_value_imm(func: &Function, val: Value) -> Option { Some(msb << 64 | lsb) } -pub fn resolve_value_imm(func: &Function, val: Value) -> Option { +pub(crate) fn resolve_value_imm(func: &Function, val: Value) -> Option { if func.dfg.value_type(val) == types::I128 { resolve_128bit_value_imm(func, val) } else { @@ -215,7 +215,7 @@ pub fn resolve_value_imm(func: &Function, val: Value) -> Option { } } -pub fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { +pub(crate) fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { assert!(ty.is_int()); let min = match (ty, signed) { (types::I8, false) | (types::I16, false) | (types::I32, false) | (types::I64, false) => { @@ -245,7 +245,7 @@ pub fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { (min, max) } -pub fn type_sign(ty: Ty<'_>) -> bool { +pub(crate) fn type_sign(ty: Ty<'_>) -> bool { match ty.kind { ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) | ty::Char | ty::Uint(..) | ty::Bool => false, ty::Int(..) => true, @@ -254,30 +254,30 @@ pub fn type_sign(ty: Ty<'_>) -> bool { } } -pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { +pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` - pub tcx: TyCtxt<'tcx>, - pub module: &'clif mut Module, - pub pointer_type: Type, // Cached from module + pub(crate) tcx: TyCtxt<'tcx>, + pub(crate) module: &'clif mut Module, + pub(crate) pointer_type: Type, // Cached from module - pub instance: Instance<'tcx>, - pub mir: &'tcx Body<'tcx>, + pub(crate) instance: Instance<'tcx>, + pub(crate) mir: &'tcx Body<'tcx>, - pub bcx: FunctionBuilder<'clif>, - pub block_map: IndexVec, - pub local_map: HashMap>, + pub(crate) bcx: FunctionBuilder<'clif>, + pub(crate) block_map: IndexVec, + pub(crate) local_map: HashMap>, /// When `#[track_caller]` is used, the implicit caller location is stored in this variable. - pub caller_location: Option>, + pub(crate) caller_location: Option>, /// See [crate::optimize::code_layout] for more information. - pub cold_blocks: EntitySet, + pub(crate) cold_blocks: EntitySet, - pub clif_comments: crate::pretty_clif::CommentWriter, - pub constants_cx: &'clif mut crate::constant::ConstantCx, - pub vtables: &'clif mut HashMap<(Ty<'tcx>, Option>), DataId>, + pub(crate) clif_comments: crate::pretty_clif::CommentWriter, + pub(crate) constants_cx: &'clif mut crate::constant::ConstantCx, + pub(crate) vtables: &'clif mut HashMap<(Ty<'tcx>, Option>), DataId>, - pub source_info_set: indexmap::IndexSet, + pub(crate) source_info_set: indexmap::IndexSet, } impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { @@ -333,7 +333,7 @@ impl<'tcx, B: Backend> BackendTypes for FunctionCx<'_, 'tcx, B> { } impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { - pub fn monomorphize(&self, value: &T) -> T + pub(crate) fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx>, { @@ -344,26 +344,26 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { ) } - pub fn clif_type(&self, ty: Ty<'tcx>) -> Option { + pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option { clif_type_from_ty(self.tcx, ty) } - pub fn get_block(&self, bb: BasicBlock) -> Block { + pub(crate) fn get_block(&self, bb: BasicBlock) -> Block { *self.block_map.get(bb).unwrap() } - pub fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { + pub(crate) fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { *self.local_map.get(&local).unwrap_or_else(|| { panic!("Local {:?} doesn't exist", local); }) } - pub fn set_debug_loc(&mut self, source_info: mir::SourceInfo) { + pub(crate) fn set_debug_loc(&mut self, source_info: mir::SourceInfo) { let (index, _) = self.source_info_set.insert_full(source_info); self.bcx.set_srcloc(SourceLoc::new(index as u32)); } - pub fn get_caller_location(&mut self, span: Span) -> CValue<'tcx> { + pub(crate) fn get_caller_location(&mut self, span: Span) -> CValue<'tcx> { if let Some(loc) = self.caller_location { // `#[track_caller]` is used; return caller location instead of current location. return loc; @@ -382,7 +382,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { ) } - pub fn triple(&self) -> &target_lexicon::Triple { + pub(crate) fn triple(&self) -> &target_lexicon::Triple { self.module.isa().triple() } } diff --git a/src/constant.rs b/src/constant.rs index e6953b97a5d2b..98a69c11cdd29 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -19,7 +19,7 @@ use cranelift_module::*; use crate::prelude::*; #[derive(Default)] -pub struct ConstantCx { +pub(crate) struct ConstantCx { todo: Vec, done: FxHashSet, } @@ -31,7 +31,7 @@ enum TodoItem { } impl ConstantCx { - pub fn finalize(mut self, tcx: TyCtxt<'_>, module: &mut Module) { + pub(crate) fn finalize(mut self, tcx: TyCtxt<'_>, module: &mut Module) { //println!("todo {:?}", self.todo); define_all_allocs(tcx, module, &mut self); //println!("done {:?}", self.done); @@ -39,7 +39,7 @@ impl ConstantCx { } } -pub fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { +pub(crate) fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { constants_cx.todo.push(TodoItem::Static(def_id)); } @@ -56,7 +56,7 @@ fn codegen_static_ref<'tcx>( cplace_for_dataid(fx, layout, local_data_id) } -pub fn trans_constant<'tcx>( +pub(crate) fn trans_constant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { @@ -77,7 +77,7 @@ pub fn trans_constant<'tcx>( trans_const_value(fx, const_) } -pub fn trans_const_value<'tcx>( +pub(crate) fn trans_const_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, const_: &'tcx Const<'tcx>, ) -> CValue<'tcx> { @@ -489,7 +489,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { } } -pub fn mir_operand_get_const_val<'tcx>( +pub(crate) fn mir_operand_get_const_val<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, operand: &Operand<'tcx>, ) -> Option<&'tcx Const<'tcx>> { diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 2b6dc9f669f30..16527353fbc4c 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -8,7 +8,7 @@ use crate::backend::WriteDebugInfo; use super::DebugContext; impl DebugContext<'_> { - pub fn emit(&mut self, product: &mut P) { + pub(crate) fn emit(&mut self, product: &mut P) { let unit_range_list_id = self.dwarf.unit.ranges.add(self.unit_range_list.clone()); let root = self.dwarf.unit.root(); let root = self.dwarf.unit.get_mut(root); @@ -41,15 +41,15 @@ impl DebugContext<'_> { } #[derive(Clone)] -pub struct DebugReloc { - pub offset: u32, - pub size: u8, - pub name: DebugRelocName, - pub addend: i64, +pub(crate) struct DebugReloc { + pub(crate) offset: u32, + pub(crate) size: u8, + pub(crate) name: DebugRelocName, + pub(crate) addend: i64, } #[derive(Clone)] -pub enum DebugRelocName { +pub(crate) enum DebugRelocName { Section(SectionId), Symbol(usize), } diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index fda861c5519f1..0870f89e3d83d 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -3,7 +3,7 @@ use std::path::{Component, Path}; use crate::prelude::*; -use rustc_span::{FileName, SourceFileAndLine}; +use rustc_span::{FileName, SourceFileAndLine, Pos}; use cranelift_codegen::binemit::CodeOffset; @@ -162,7 +162,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let current_file_changed = if let Some(last_file) = &last_file { // If the allocations are not equal, then the files may still be equal, but that // is not a problem, as this is just an optimization. - !Lrc::ptr_eq(last_file, &file) + !rustc_data_structures::sync::Lrc::ptr_eq(last_file, &file) } else { true }; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 363abb8cd772b..95fde120a9c13 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -13,7 +13,7 @@ use gimli::write::{ }; use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, X86_64}; -pub use emit::{DebugReloc, DebugRelocName}; +pub(crate) use emit::{DebugReloc, DebugRelocName}; fn target_endian(tcx: TyCtxt) -> RunTimeEndian { use rustc::ty::layout::Endian; @@ -24,7 +24,7 @@ fn target_endian(tcx: TyCtxt) -> RunTimeEndian { } } -pub struct DebugContext<'tcx> { +pub(crate) struct DebugContext<'tcx> { tcx: TyCtxt<'tcx>, endian: RunTimeEndian, @@ -37,7 +37,7 @@ pub struct DebugContext<'tcx> { } impl<'tcx> DebugContext<'tcx> { - pub fn new(tcx: TyCtxt<'tcx>, address_size: u8) -> Self { + pub(crate) fn new(tcx: TyCtxt<'tcx>, address_size: u8) -> Self { let encoding = Encoding { format: Format::Dwarf32, // TODO: this should be configurable @@ -187,7 +187,7 @@ impl<'tcx> DebugContext<'tcx> { } } -pub struct FunctionDebugContext<'a, 'tcx> { +pub(crate) struct FunctionDebugContext<'a, 'tcx> { debug_context: &'a mut DebugContext<'tcx>, entry_id: UnitEntryId, symbol: usize, @@ -196,7 +196,7 @@ pub struct FunctionDebugContext<'a, 'tcx> { } impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { - pub fn new( + pub(crate) fn new( debug_context: &'a mut DebugContext<'tcx>, instance: Instance<'tcx>, func_id: FuncId, @@ -250,7 +250,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { var_id } - pub fn define( + pub(crate) fn define( &mut self, context: &Context, isa: &dyn TargetIsa, diff --git a/src/discriminant.rs b/src/discriminant.rs index 82d2d9fd8b36b..a6d6d814fc96f 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -2,7 +2,7 @@ use crate::prelude::*; -pub fn codegen_set_discriminant<'tcx>( +pub(crate) fn codegen_set_discriminant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: CPlace<'tcx>, variant_index: VariantIdx, @@ -52,7 +52,7 @@ pub fn codegen_set_discriminant<'tcx>( } } -pub fn codegen_get_discriminant<'tcx>( +pub(crate) fn codegen_get_discriminant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, value: CValue<'tcx>, dest_layout: TyLayout<'tcx>, diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 00bc00428412a..d4582e6f1ff95 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -89,7 +89,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { let formats = tcx.dependency_formats(LOCAL_CRATE); let data = &formats .iter() - .find(|(crate_type, _data)| *crate_type == CrateType::Executable) + .find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable) .unwrap() .1; for &(cnum, _) in &crate_info.used_crates_dynamic { diff --git a/src/driver/mod.rs b/src/driver/mod.rs index d68cb5bb7eedc..7f46150252e24 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,7 +1,7 @@ use std::any::Any; use rustc::middle::cstore::EncodedMetadata; -use rustc::mir::mono::{Linkage as RLinkage, Visibility}; +use rustc::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; use crate::prelude::*; @@ -9,7 +9,7 @@ mod aot; #[cfg(not(target_arch = "wasm32"))] mod jit; -pub fn codegen_crate( +pub(crate) fn codegen_crate( tcx: TyCtxt<'_>, metadata: EncodedMetadata, need_metadata_module: bool, @@ -17,7 +17,7 @@ pub fn codegen_crate( tcx.sess.abort_if_errors(); if std::env::var("CG_CLIF_JIT").is_ok() - && tcx.sess.crate_types.get().contains(&CrateType::Executable) + && tcx.sess.crate_types.get().contains(&rustc_session::config::CrateType::Executable) { #[cfg(not(target_arch = "wasm32"))] let _: ! = jit::run_jit(tcx); diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index b30f3b8f8dbd4..e1a0066fc48e3 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -3,7 +3,7 @@ use crate::prelude::*; use rustc::ty::subst::SubstsRef; -pub fn codegen_llvm_intrinsic_call<'tcx>( +pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, intrinsic: &str, substs: SubstsRef<'tcx>, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 2df8948054fcc..c6db8504a80ee 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -1,6 +1,8 @@ -pub mod llvm; +mod llvm; mod simd; +pub(crate) use llvm::codegen_llvm_intrinsic_call; + use crate::prelude::*; macro intrinsic_pat { @@ -332,7 +334,7 @@ macro simd_flt_binop($fx:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { ); } -pub fn codegen_intrinsic_call<'tcx>( +pub(crate) fn codegen_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, instance: Instance<'tcx>, args: &[mir::Operand<'tcx>], diff --git a/src/lib.rs b/src/lib.rs index 061f78c8a929d..303ef3f7f9489 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,62 +62,52 @@ mod value_and_place; mod vtable; mod prelude { - pub use std::any::Any; - pub use std::collections::{HashMap, HashSet}; - pub use std::convert::{TryFrom, TryInto}; - - pub use rustc_ast::ast::{FloatTy, IntTy, UintTy}; - pub use rustc_span::{Pos, Span}; - - pub use rustc::bug; - pub use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; - pub use rustc::mir::{self, interpret::AllocId, mono::MonoItem, *}; - pub use rustc_session::{ - config::{CrateType, Lto}, - Session, - }; - pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout, VariantIdx}; - pub use rustc::ty::{ - self, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, - TypeFoldable, + pub(crate) use std::collections::HashMap; + pub(crate) use std::convert::{TryFrom, TryInto}; + + pub(crate) use rustc_ast::ast::{FloatTy, IntTy, UintTy}; + pub(crate) use rustc_span::Span; + + pub(crate) use rustc::bug; + pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE}; + pub(crate) use rustc::mir::{self, *}; + pub(crate) use rustc_session::Session; + pub(crate) use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout, VariantIdx}; + pub(crate) use rustc::ty::{ + self, FnSig, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; - pub use rustc_data_structures::{ - fx::{FxHashMap, FxHashSet}, - sync::Lrc, - }; + pub(crate) use rustc_data_structures::fx::FxHashMap; + + pub(crate) use rustc_index::vec::Idx; + + pub(crate) use rustc_codegen_ssa::traits::*; + pub(crate) use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; - pub use rustc_index::vec::Idx; - - pub use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; - pub use rustc_codegen_ssa::traits::*; - pub use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; - - pub use cranelift_codegen::Context; - pub use cranelift_codegen::entity::EntitySet; - pub use cranelift_codegen::ir::{AbiParam, Block, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; - pub use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; - pub use cranelift_codegen::ir::function::Function; - pub use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; - pub use cranelift_codegen::ir::types; - pub use cranelift_codegen::isa::{self, CallConv}; - pub use cranelift_codegen::settings::{self, Configurable}; - pub use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; - pub use cranelift_module::{ - self, Backend, DataContext, DataId, FuncId, FuncOrDataId, Linkage, Module, + pub(crate) use cranelift_codegen::Context; + pub(crate) use cranelift_codegen::entity::EntitySet; + pub(crate) use cranelift_codegen::ir::{AbiParam, Block, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; + pub(crate) use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; + pub(crate) use cranelift_codegen::ir::function::Function; + pub(crate) use cranelift_codegen::ir::types; + pub(crate) use cranelift_codegen::isa::{self, CallConv}; + pub(crate) use cranelift_codegen::settings::{self, Configurable}; + pub(crate) use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; + pub(crate) use cranelift_module::{ + self, Backend, DataContext, DataId, FuncId, Linkage, Module, }; - pub use crate::abi::*; - pub use crate::base::{trans_operand, trans_place}; - pub use crate::cast::*; - pub use crate::common::*; - pub use crate::debuginfo::{DebugContext, FunctionDebugContext}; - pub use crate::pointer::Pointer; - pub use crate::trap::*; - pub use crate::value_and_place::{CPlace, CPlaceInner, CValue}; - pub use crate::CodegenCx; - - pub struct PrintOnPanic String>(pub F); + pub(crate) use crate::abi::*; + pub(crate) use crate::base::{trans_operand, trans_place}; + pub(crate) use crate::cast::*; + pub(crate) use crate::common::*; + pub(crate) use crate::debuginfo::{DebugContext, FunctionDebugContext}; + pub(crate) use crate::pointer::Pointer; + pub(crate) use crate::trap::*; + pub(crate) use crate::value_and_place::{CPlace, CPlaceInner, CValue}; + pub(crate) use crate::CodegenCx; + + pub(crate) struct PrintOnPanic String>(pub F); impl String> Drop for PrintOnPanic { fn drop(&mut self) { if ::std::thread::panicking() { @@ -126,12 +116,12 @@ mod prelude { } } - pub macro unimpl_fatal($tcx:expr, $span:expr, $($tt:tt)*) { + pub(crate) macro unimpl_fatal($tcx:expr, $span:expr, $($tt:tt)*) { $tcx.sess.span_fatal($span, &format!($($tt)*)); } } -pub struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { +pub(crate) struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { tcx: TyCtxt<'tcx>, module: &'clif mut Module, constants_cx: ConstantCx, diff --git a/src/linkage.rs b/src/linkage.rs index bf5c295622268..6b4c4353964ba 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -2,7 +2,7 @@ use rustc::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; use crate::prelude::*; -pub fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibility: Visibility) -> Linkage { +pub(crate) fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibility: Visibility) -> Linkage { match (linkage, visibility) { (RLinkage::External, Visibility::Default) => Linkage::Export, (RLinkage::Internal, Visibility::Default) => Linkage::Local, @@ -11,7 +11,7 @@ pub fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibility: Visi } } -pub fn get_static_ref_linkage(tcx: TyCtxt, def_id: DefId) -> Linkage { +pub(crate) fn get_static_ref_linkage(tcx: TyCtxt, def_id: DefId) -> Linkage { let fn_attrs = tcx.codegen_fn_attrs(def_id); if let Some(linkage) = fn_attrs.linkage { diff --git a/src/main_shim.rs b/src/main_shim.rs index 145dd704badc2..81f9e0ebad987 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -2,7 +2,7 @@ use crate::prelude::*; /// Create the `main` function which will initialize the rust runtime and call /// users main function. -pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { +pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { use rustc::middle::lang_items::StartFnLangItem; use rustc_session::config::EntryFnType; diff --git a/src/metadata.rs b/src/metadata.rs index 3c3a7c5014910..748d4075a702e 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -12,7 +12,7 @@ use rustc_target::spec::Target; use crate::backend::WriteMetadata; -pub struct CraneliftMetadataLoader; +pub(crate) struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { fn get_rlib_metadata( @@ -59,7 +59,7 @@ impl MetadataLoader for CraneliftMetadataLoader { } // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 -pub fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) -> EncodedMetadata { +pub(crate) fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) -> EncodedMetadata { use flate2::write::DeflateEncoder; use flate2::Compression; use std::io::Write; diff --git a/src/num.rs b/src/num.rs index 103c15eca4136..b0d04f1227989 100644 --- a/src/num.rs +++ b/src/num.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -pub fn bin_op_to_intcc(bin_op: BinOp, signed: bool) -> Option { +pub(crate) fn bin_op_to_intcc(bin_op: BinOp, signed: bool) -> Option { use BinOp::*; use IntCC::*; Some(match bin_op { @@ -51,7 +51,7 @@ fn codegen_compare_bin_op<'tcx>( CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)) } -pub fn codegen_binop<'tcx>( +pub(crate) fn codegen_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -100,7 +100,7 @@ pub fn codegen_binop<'tcx>( } } -pub fn trans_bool_binop<'tcx>( +pub(crate) fn trans_bool_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -121,7 +121,7 @@ pub fn trans_bool_binop<'tcx>( CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) } -pub fn trans_int_binop<'tcx>( +pub(crate) fn trans_int_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -192,7 +192,7 @@ pub fn trans_int_binop<'tcx>( CValue::by_val(val, in_lhs.layout()) } -pub fn trans_checked_int_binop<'tcx>( +pub(crate) fn trans_checked_int_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -297,7 +297,7 @@ pub fn trans_checked_int_binop<'tcx>( out_place.to_cvalue(fx) } -pub fn trans_float_binop<'tcx>( +pub(crate) fn trans_float_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, @@ -342,7 +342,7 @@ pub fn trans_float_binop<'tcx>( CValue::by_val(res, in_lhs.layout()) } -pub fn trans_ptr_binop<'tcx>( +pub(crate) fn trans_ptr_binop<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, bin_op: BinOp, in_lhs: CValue<'tcx>, diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 29ad5321d5772..d59df98e7500c 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -3,7 +3,7 @@ use crate::prelude::*; mod code_layout; mod stack2reg; -pub fn optimize_function<'tcx>( +pub(crate) fn optimize_function<'tcx>( tcx: TyCtxt<'tcx>, #[cfg_attr(not(debug_assertions), allow(unused_variables))] instance: Instance<'tcx>, diff --git a/src/pointer.rs b/src/pointer.rs index b9183aeedc9e2..854a7cd44018f 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -3,33 +3,33 @@ use crate::prelude::*; use cranelift_codegen::ir::immediates::Offset32; #[derive(Copy, Clone, Debug)] -pub struct Pointer { +pub(crate) struct Pointer { base: PointerBase, offset: Offset32, } #[derive(Copy, Clone, Debug)] -pub enum PointerBase { +pub(crate) enum PointerBase { Addr(Value), Stack(StackSlot), } impl Pointer { - pub fn new(addr: Value) -> Self { + pub(crate) fn new(addr: Value) -> Self { Pointer { base: PointerBase::Addr(addr), offset: Offset32::new(0), } } - pub fn stack_slot(stack_slot: StackSlot) -> Self { + pub(crate) fn stack_slot(stack_slot: StackSlot) -> Self { Pointer { base: PointerBase::Stack(stack_slot), offset: Offset32::new(0), } } - pub fn const_addr<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, addr: i64) -> Self { + pub(crate) fn const_addr<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, addr: i64) -> Self { let addr = fx.bcx.ins().iconst(fx.pointer_type, addr); Pointer { base: PointerBase::Addr(addr), @@ -38,11 +38,11 @@ impl Pointer { } #[cfg(debug_assertions)] - pub fn base_and_offset(self) -> (PointerBase, Offset32) { + pub(crate) fn base_and_offset(self) -> (PointerBase, Offset32) { (self.base, self.offset) } - pub fn get_addr<'a, 'tcx>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { + pub(crate) fn get_addr<'a, 'tcx>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { match self.base { PointerBase::Addr(base_addr) => { let offset: i64 = self.offset.into(); @@ -56,7 +56,7 @@ impl Pointer { } } - pub fn offset<'a, 'tcx>( + pub(crate) fn offset<'a, 'tcx>( self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, extra_offset: Offset32, @@ -64,7 +64,7 @@ impl Pointer { self.offset_i64(fx, extra_offset.into()) } - pub fn offset_i64<'a, 'tcx>( + pub(crate) fn offset_i64<'a, 'tcx>( self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, extra_offset: i64, @@ -92,7 +92,7 @@ impl Pointer { } } - pub fn offset_value<'a, 'tcx>( + pub(crate) fn offset_value<'a, 'tcx>( self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, extra_offset: Value, @@ -112,7 +112,7 @@ impl Pointer { } } - pub fn load<'a, 'tcx>( + pub(crate) fn load<'a, 'tcx>( self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, ty: Type, @@ -130,7 +130,7 @@ impl Pointer { } } - pub fn store<'a, 'tcx>( + pub(crate) fn store<'a, 'tcx>( self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value: Value, diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 725df448161ad..911b215bf1378 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -64,13 +64,13 @@ use crate::prelude::*; /// ``` #[derive(Debug)] -pub struct CommentWriter { +pub(crate) struct CommentWriter { global_comments: Vec, entity_comments: HashMap, } impl CommentWriter { - pub fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self { + pub(crate) fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self { let global_comments = if cfg!(debug_assertions) { vec![ format!("symbol {}", tcx.symbol_name(instance).name.as_str()), @@ -97,11 +97,11 @@ impl CommentWriter { #[cfg(debug_assertions)] impl CommentWriter { - pub fn add_global_comment>(&mut self, comment: S) { + pub(crate) fn add_global_comment>(&mut self, comment: S) { self.global_comments.push(comment.into()); } - pub fn add_comment + AsRef, E: Into>( + pub(crate) fn add_comment + AsRef, E: Into>( &mut self, entity: E, comment: S, @@ -186,11 +186,11 @@ impl FuncWriter for &'_ CommentWriter { #[cfg(debug_assertions)] impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { - pub fn add_global_comment>(&mut self, comment: S) { + pub(crate) fn add_global_comment>(&mut self, comment: S) { self.clif_comments.add_global_comment(comment); } - pub fn add_comment + AsRef, E: Into>( + pub(crate) fn add_comment + AsRef, E: Into>( &mut self, entity: E, comment: S, @@ -200,7 +200,7 @@ impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } #[cfg(debug_assertions)] -pub fn write_clif_file<'tcx>( +pub(crate) fn write_clif_file<'tcx>( tcx: TyCtxt<'tcx>, postfix: &str, instance: Instance<'tcx>, diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index cbc88fc6b5180..de433cca514a6 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -115,7 +115,7 @@ const WASM_WHITELIST: &[(&str, Option)] = &[ /// /// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this /// iterator! -pub fn all_known_features() -> impl Iterator)> { +pub(crate) fn all_known_features() -> impl Iterator)> { ARM_WHITELIST .iter() .cloned() @@ -127,7 +127,7 @@ pub fn all_known_features() -> impl Iterator &'static [(&'static str, Option)] { +pub(crate) fn target_feature_whitelist(sess: &Session) -> &'static [(&'static str, Option)] { match &*sess.target.target.arch { "arm" => ARM_WHITELIST, "aarch64" => AARCH64_WHITELIST, diff --git a/src/trap.rs b/src/trap.rs index c13260424ff7b..d63e86db29d98 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -55,7 +55,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms /// Use this when `rustc_codegen_llvm` would insert a call to the panic handler. /// /// Trap code: user0 -pub fn trap_panic( +pub(crate) fn trap_panic( fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef, ) { @@ -67,7 +67,7 @@ pub fn trap_panic( /// so you can **not** add instructions to it afterwards. /// /// Trap code: user65535 -pub fn trap_unreachable( +pub(crate) fn trap_unreachable( fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef, ) { @@ -78,7 +78,7 @@ pub fn trap_unreachable( /// Like `trap_unreachable` but returns a fake value of the specified type. /// /// Trap code: user65535 -pub fn trap_unreachable_ret_value<'tcx>( +pub(crate) fn trap_unreachable_ret_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef, @@ -92,7 +92,7 @@ pub fn trap_unreachable_ret_value<'tcx>( /// to it afterwards. /// /// Trap code: user65535 -pub fn trap_unimplemented( +pub(crate) fn trap_unimplemented( fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef, ) { @@ -104,7 +104,7 @@ pub fn trap_unimplemented( /// Like `trap_unimplemented` but returns a fake value of the specified type. /// /// Trap code: user65535 -pub fn trap_unimplemented_ret_value<'tcx>( +pub(crate) fn trap_unimplemented_ret_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef, diff --git a/src/unsize.rs b/src/unsize.rs index 9d2e73714fcaa..d6a85deda7807 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -8,7 +8,7 @@ use crate::prelude::*; /// The `old_info` argument is a bit funny. It is intended for use /// in an upcast, where the new vtable for an object will be derived /// from the old one. -pub fn unsized_info<'tcx>( +pub(crate) fn unsized_info<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, source: Ty<'tcx>, target: Ty<'tcx>, @@ -84,7 +84,7 @@ fn unsize_thin_ptr<'tcx>( /// Coerce `src`, which is a reference to a value of type `src_ty`, /// to a value of type `dst_ty` and store the result in `dst` -pub fn coerce_unsized_into<'tcx>( +pub(crate) fn coerce_unsized_into<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, src: CValue<'tcx>, dst: CPlace<'tcx>, @@ -137,7 +137,7 @@ pub fn coerce_unsized_into<'tcx>( // Adapted from https://github.com/rust-lang/rust/blob/2a663555ddf36f6b041445894a8c175cd1bc718c/src/librustc_codegen_ssa/glue.rs -pub fn size_and_align_of_dst<'tcx>( +pub(crate) fn size_and_align_of_dst<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, info: Value, diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 64d585e8a993e..41fe85795c299 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -62,7 +62,7 @@ fn scalar_pair_calculate_b_offset(tcx: TyCtxt<'_>, a_scalar: &Scalar, b_scalar: /// A read-only value #[derive(Debug, Copy, Clone)] -pub struct CValue<'tcx>(CValueInner, TyLayout<'tcx>); +pub(crate) struct CValue<'tcx>(CValueInner, TyLayout<'tcx>); #[derive(Debug, Copy, Clone)] enum CValueInner { @@ -72,28 +72,28 @@ enum CValueInner { } impl<'tcx> CValue<'tcx> { - pub fn by_ref(ptr: Pointer, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_ref(ptr: Pointer, layout: TyLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByRef(ptr, None), layout) } - pub fn by_ref_unsized(ptr: Pointer, meta: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_ref_unsized(ptr: Pointer, meta: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByRef(ptr, Some(meta)), layout) } - pub fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByVal(value), layout) } - pub fn by_val_pair(value: Value, extra: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_val_pair(value: Value, extra: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByValPair(value, extra), layout) } - pub fn layout(&self) -> TyLayout<'tcx> { + pub(crate) fn layout(&self) -> TyLayout<'tcx> { self.1 } // FIXME remove - pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option) { + pub(crate) fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option) { let layout = self.1; match self.0 { CValueInner::ByRef(ptr, meta) => (ptr, meta), @@ -105,7 +105,7 @@ impl<'tcx> CValue<'tcx> { } } - pub fn try_to_ptr(self) -> Option<(Pointer, Option)> { + pub(crate) fn try_to_ptr(self) -> Option<(Pointer, Option)> { match self.0 { CValueInner::ByRef(ptr, meta) => Some((ptr, meta)), CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => None, @@ -113,7 +113,7 @@ impl<'tcx> CValue<'tcx> { } /// Load a value with layout.abi of scalar - pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + pub(crate) fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; match self.0 { CValueInner::ByRef(ptr, None) => { @@ -134,7 +134,7 @@ impl<'tcx> CValue<'tcx> { } /// Load a value pair with layout.abi of scalar pair - pub fn load_scalar_pair<'a>( + pub(crate) fn load_scalar_pair<'a>( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ) -> (Value, Value) { @@ -158,7 +158,7 @@ impl<'tcx> CValue<'tcx> { } } - pub fn value_field<'a>( + pub(crate) fn value_field<'a>( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, @@ -187,16 +187,18 @@ impl<'tcx> CValue<'tcx> { } } - pub fn unsize_value<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + pub(crate) fn unsize_value<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { crate::unsize::coerce_unsized_into(fx, self, dest); } /// If `ty` is signed, `const_val` must already be sign extended. - pub fn const_val( + pub(crate) fn const_val( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, const_val: u128, ) -> CValue<'tcx> { + use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; + let clif_ty = fx.clif_type(layout.ty).unwrap(); match layout.ty.kind { @@ -241,42 +243,42 @@ impl<'tcx> CValue<'tcx> { CValue::by_val(val, layout) } - pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + pub(crate) fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { CValue(self.0, layout) } } /// A place where you can write a value to or read a value from #[derive(Debug, Copy, Clone)] -pub struct CPlace<'tcx> { +pub(crate) struct CPlace<'tcx> { inner: CPlaceInner, layout: TyLayout<'tcx>, } #[derive(Debug, Copy, Clone)] -pub enum CPlaceInner { +pub(crate) enum CPlaceInner { Var(Local), Addr(Pointer, Option), NoPlace, } impl<'tcx> CPlace<'tcx> { - pub fn layout(&self) -> TyLayout<'tcx> { + pub(crate) fn layout(&self) -> TyLayout<'tcx> { self.layout } - pub fn inner(&self) -> &CPlaceInner { + pub(crate) fn inner(&self) -> &CPlaceInner { &self.inner } - pub fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub(crate) fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::NoPlace, layout, } } - pub fn new_stack_slot( + pub(crate) fn new_stack_slot( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, ) -> CPlace<'tcx> { @@ -299,7 +301,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn new_var( + pub(crate) fn new_var( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, layout: TyLayout<'tcx>, @@ -312,21 +314,21 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn for_ptr(ptr: Pointer, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub(crate) fn for_ptr(ptr: Pointer, layout: TyLayout<'tcx>) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::Addr(ptr, None), layout, } } - pub fn for_ptr_with_extra(ptr: Pointer, extra: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub(crate) fn for_ptr_with_extra(ptr: Pointer, extra: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::Addr(ptr, Some(extra)), layout, } } - pub fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> { + pub(crate) fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> { let layout = self.layout(); match self.inner { CPlaceInner::Var(var) => { @@ -348,14 +350,14 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn to_ptr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { + pub(crate) fn to_ptr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { match self.to_ptr_maybe_unsized(fx) { (ptr, None) => ptr, (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), } } - pub fn to_ptr_maybe_unsized( + pub(crate) fn to_ptr_maybe_unsized( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ) -> (Pointer, Option) { @@ -371,7 +373,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { + pub(crate) fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { #[cfg(debug_assertions)] { use cranelift_codegen::cursor::{Cursor, CursorPosition}; @@ -516,7 +518,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn place_field( + pub(crate) fn place_field( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, @@ -532,7 +534,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn place_index( + pub(crate) fn place_index( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, index: Value, @@ -551,7 +553,7 @@ impl<'tcx> CPlace<'tcx> { CPlace::for_ptr(ptr.offset_value(fx, offset), elem_layout) } - pub fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { + pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); if has_ptr_meta(fx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); @@ -561,7 +563,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if has_ptr_meta(fx.tcx, self.layout().ty) { let (ptr, extra) = self.to_ptr_maybe_unsized(fx); let ptr = CValue::by_val_pair( @@ -576,7 +578,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + pub(crate) fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { assert!(!self.layout().is_unsized()); match self.inner { CPlaceInner::NoPlace => { @@ -590,7 +592,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub fn downcast_variant( + pub(crate) fn downcast_variant( self, fx: &FunctionCx<'_, 'tcx, impl Backend>, variant: VariantIdx, diff --git a/src/vtable.rs b/src/vtable.rs index 28688fee049b6..127e4ce79a63e 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -12,7 +12,7 @@ fn vtable_memflags() -> MemFlags { flags } -pub fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { +pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -22,7 +22,7 @@ pub fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) ) } -pub fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { +pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -32,7 +32,7 @@ pub fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> ) } -pub fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { +pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -42,7 +42,7 @@ pub fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value ) } -pub fn get_ptr_and_method_ref<'tcx>( +pub(crate) fn get_ptr_and_method_ref<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, idx: usize, @@ -67,7 +67,7 @@ pub fn get_ptr_and_method_ref<'tcx>( (ptr, func_ref) } -pub fn get_vtable<'tcx>( +pub(crate) fn get_vtable<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, layout: TyLayout<'tcx>, trait_ref: Option>, From 3f33fcbd30d6cf5151ed8185a566c6495e456bbd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Mar 2020 16:04:34 +0100 Subject: [PATCH 1225/1566] Avoid using select in bool_to_zero_or_max_uint It legalizes to a branch --- src/intrinsics/mod.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index c6db8504a80ee..6f6511ec14dd0 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -225,12 +225,8 @@ fn bool_to_zero_or_max_uint<'tcx>( ty => ty, }; - let zero = fx.bcx.ins().iconst(int_ty, 0); - let max = fx - .bcx - .ins() - .iconst(int_ty, (u64::MAX >> (64 - int_ty.bits())) as i64); - let mut res = fx.bcx.ins().select(val, max, zero); + let val = fx.bcx.ins().bint(int_ty, val); + let mut res = fx.bcx.ins().ineg(val); if ty.is_float() { res = fx.bcx.ins().bitcast(ty, res); From d2c5b4be68850b86621e66b80c244cbeb425953d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Mar 2020 16:41:05 +0100 Subject: [PATCH 1226/1566] Use vector icmp in simd_cmp! when possible --- src/intrinsics/mod.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 6f6511ec14dd0..1e6a795783572 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -154,6 +154,21 @@ fn lane_type_and_count<'tcx>( (lane_layout, lane_count) } +fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> Option { + let (element, count) = match &layout.abi { + Abi::Vector { element, count } => (element.clone(), *count), + _ => unreachable!(), + }; + + match scalar_to_clif_type(tcx, element).by(u16::try_from(count).unwrap()) { + // Cranelift currently only implements icmp for 128bit vectors. While 64bit lanes are + // supported, this needs either the `use_sse41_simd` or `use_sse42_simd` target flag + // to be enabled. + Some(vector_ty) if vector_ty.bits() == 128 && vector_ty.lane_type() != types::I64 => Some(vector_ty), + _ => None, + } +} + fn simd_for_each_lane<'tcx, B: Backend>( fx: &mut FunctionCx<'_, 'tcx, B>, val: CValue<'tcx>, @@ -237,6 +252,18 @@ fn bool_to_zero_or_max_uint<'tcx>( macro simd_cmp { ($fx:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { + let vector_ty = clif_vector_type($fx.tcx, $x.layout()); + + if let Some(vector_ty) = vector_ty { + let x = $x.load_scalar($fx); + let y = $y.load_scalar($fx); + let val = codegen_icmp($fx, IntCC::$cc, x, y); + + // HACK This depends on the fact that icmp for vectors represents bools as 0 and !0, not 0 and 1. + let val = $fx.bcx.ins().raw_bitcast(vector_ty, val); + + $ret.write_cvalue($fx, CValue::by_val(val, $ret.layout())); + } else { simd_pair_for_each_lane( $fx, $x, @@ -250,8 +277,10 @@ macro simd_cmp { bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) }, ); + } }, ($fx:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { + // FIXME use vector icmp when possible simd_pair_for_each_lane( $fx, $x, From 33fd4c47aaf5193c67366cc82a5c678ebeba8964 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Mar 2020 16:42:28 +0100 Subject: [PATCH 1227/1566] Use 16bit simd indices --- src/intrinsics/mod.rs | 30 +++++++++++++++--------------- src/intrinsics/simd.rs | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 1e6a795783572..2034d95cdacaa 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -141,10 +141,10 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ fn lane_type_and_count<'tcx>( tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>, -) -> (TyLayout<'tcx>, u32) { +) -> (TyLayout<'tcx>, u16) { assert!(layout.ty.is_simd()); let lane_count = match layout.fields { - layout::FieldPlacement::Array { stride: _, count } => u32::try_from(count).unwrap(), + layout::FieldPlacement::Array { stride: _, count } => u16::try_from(count).unwrap(), _ => unreachable!("lane_type_and_count({:?})", layout), }; let lane_layout = layout.field(&ty::layout::LayoutCx { @@ -264,19 +264,19 @@ macro simd_cmp { $ret.write_cvalue($fx, CValue::by_val(val, $ret.layout())); } else { - simd_pair_for_each_lane( - $fx, - $x, - $y, - $ret, - |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { - ty::Uint(_) | ty::Int(_) => codegen_icmp(fx, IntCC::$cc, x_lane, y_lane), - _ => unreachable!("{:?}", lane_layout.ty), - }; - bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) - }, - ); + simd_pair_for_each_lane( + $fx, + $x, + $y, + $ret, + |fx, lane_layout, res_lane_layout, x_lane, y_lane| { + let res_lane = match lane_layout.ty.kind { + ty::Uint(_) | ty::Int(_) => codegen_icmp(fx, IntCC::$cc, x_lane, y_lane), + _ => unreachable!("{:?}", lane_layout.ty), + }; + bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) + }, + ); } }, ($fx:expr, $cc_u:ident|$cc_s:ident($x:ident, $y:ident) -> $ret:ident) => { diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index e42309663d05c..d5c618a604ddb 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -53,7 +53,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( // simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U _ if intrinsic.starts_with("simd_shuffle"), (c x, c y, o idx) { - let n: u32 = intrinsic["simd_shuffle".len()..].parse().unwrap(); + let n: u16 = intrinsic["simd_shuffle".len()..].parse().unwrap(); assert_eq!(x.layout(), y.layout()); let layout = x.layout(); @@ -85,8 +85,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.tcx.data_layout.endian, &idx_bytes[4*i.. 4*i + 4], ).expect("read_target_uint"); - u32::try_from(idx).expect("try_from u32") - }).collect::>() + u16::try_from(idx).expect("try_from u32") + }).collect::>() }; for &idx in &indexes { From f6d12440aab0d3566a8519205f40f0392739ce41 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Mar 2020 14:01:48 +0100 Subject: [PATCH 1228/1566] Update Cranelift --- Cargo.lock | 40 ++++++++++++++++++++-------------------- src/allocator.rs | 6 +++++- src/backend.rs | 1 - src/base.rs | 9 ++++++++- src/main_shim.rs | 6 +++++- 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dace6acc72de4..f9f5e13d225a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,16 +44,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "byteorder", "cranelift-bforest", @@ -69,8 +69,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -78,18 +78,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" [[package]] name = "cranelift-entity" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" [[package]] name = "cranelift-frontend" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "cranelift-codegen", "log", @@ -99,8 +99,8 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "anyhow", "cranelift-codegen", @@ -111,8 +111,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -121,8 +121,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -132,8 +132,8 @@ dependencies = [ [[package]] name = "cranelift-simplejit" -version = "0.60.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#0d4bde4ab30f202c888888db7a8eb2d905c0119f" +version = "0.61.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" dependencies = [ "cranelift-codegen", "cranelift-module", diff --git a/src/allocator.rs b/src/allocator.rs index b8240f4a822bc..0b40af9de54cb 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -94,6 +94,10 @@ fn codegen_inner(module: &mut Module, kind: AllocatorKin bcx.seal_all_blocks(); bcx.finalize(); } - module.define_function(func_id, &mut ctx).unwrap(); + module.define_function( + func_id, + &mut ctx, + &mut cranelift_codegen::binemit::NullTrapSink {}, + ).unwrap(); } } diff --git a/src/backend.rs b/src/backend.rs index 723f1bca55a18..3612ec63340e4 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -125,7 +125,6 @@ pub(crate) fn make_module(sess: &Session, name: String) -> Module { ObjectBuilder::new( crate::build_isa(sess, true), name + ".o", - ObjectTrapCollection::Disabled, cranelift_module::default_libcall_names(), ), ); diff --git a/src/base.rs b/src/base.rs index a901258163847..9709dce697f5c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -171,7 +171,14 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Define function let module = &mut cx.module; - tcx.sess.time("define function", || module.define_function(func_id, context).unwrap()); + tcx.sess.time( + "define function", + || module.define_function( + func_id, + context, + &mut cranelift_codegen::binemit::NullTrapSink {}, + ).unwrap(), + ); // Write optimized function to file for debugging #[cfg(debug_assertions)] diff --git a/src/main_shim.rs b/src/main_shim.rs index 81f9e0ebad987..ab264f2e85aae 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -103,6 +103,10 @@ pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module Date: Sat, 28 Mar 2020 14:20:24 +0100 Subject: [PATCH 1229/1566] Rustup to rustc 1.44.0-nightly (75208942f 2020-03-27) --- rust-toolchain | 2 +- src/abi/comments.rs | 6 +++--- src/base.rs | 14 ++++++++++---- src/constant.rs | 6 +++--- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 295c041848b61..839a020ec18c5 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-24 +nightly-2020-03-28 diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 0ac3bec74c7b7..4f5fb0f2e44ed 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -61,15 +61,15 @@ pub(super) fn add_local_place_comments<'tcx>( place: CPlace<'tcx>, local: Local, ) { - let TyLayout { ty, details } = place.layout(); - let ty::layout::LayoutDetails { + let TyLayout { ty, layout } = place.layout(); + let ty::layout::Layout { size, align, abi: _, variants: _, fields: _, largest_niche: _, - } = details; + } = layout; let (kind, extra) = match *place.inner() { CPlaceInner::Var(var) => { diff --git a/src/base.rs b/src/base.rs index 9709dce697f5c..d2841b25f5ea9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -573,7 +573,13 @@ fn trans_stmt<'tcx>( } Rvalue::Repeat(operand, times) => { let operand = trans_operand(fx, operand); - for i in 0..*times { + let times = fx + .monomorphize(times) + .eval(fx.tcx, ParamEnv::reveal_all()) + .val + .try_to_bits(fx.tcx.data_layout.pointer_size) + .unwrap(); + for i in 0..times { let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); @@ -642,14 +648,14 @@ fn trans_stmt<'tcx>( | StatementKind::Retag { .. } | StatementKind::AscribeUserType(..) => {} - StatementKind::InlineAsm(asm) => { + StatementKind::LlvmInlineAsm(asm) => { use rustc_ast::ast::Name; - let InlineAsm { + let LlvmInlineAsm { asm, outputs: _, inputs: _, } = &**asm; - let rustc_hir::InlineAsmInner { + let rustc_hir::LlvmInlineAsmInner { asm: asm_code, // Name outputs, // Vec inputs, // Vec diff --git a/src/constant.rs b/src/constant.rs index 98a69c11cdd29..7bd2f47619329 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -391,7 +391,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu struct TransPlaceInterpreter; impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { - type MemoryKinds = !; + type MemoryKind = !; type ExtraFnVal = !; type PointerTag = (); type AllocExtra = (); @@ -400,7 +400,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { type MemoryMap = FxHashMap, Allocation<()>)>; const CHECK_ALIGN: bool = true; - const STATIC_KIND: Option = None; + const GLOBAL_KIND: Option = None; fn enforce_validity(_: &InterpCx<'mir, 'tcx, Self>) -> bool { false @@ -458,7 +458,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { (alloc, ()) } - fn tag_static_base_pointer(_: &(), _: AllocId) -> Self::PointerTag { + fn tag_global_base_pointer(_: &(), _: AllocId) -> Self::PointerTag { () } From 203b0b6b11842a2ff9281c797c1412011463aaf5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Mar 2020 14:20:53 +0100 Subject: [PATCH 1230/1566] Update errno --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9f5e13d225a7..a00846355b44a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" +checksum = "b480f641ccf0faf324e20c1d3e53d81b7484c698b42ea677f6907ae4db195371" dependencies = [ "errno-dragonfly", "libc", From 13fe779e1088f93dd97cff8a335d5829276926a5 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Mar 2020 16:50:32 +0000 Subject: [PATCH 1231/1566] Bump cranelift-codegen from `08e5484` to `cd900d7` Bumps [cranelift-codegen](https://github.com/bytecodealliance/wasmtime) from `08e5484` to `cd900d7`. - [Release notes](https://github.com/bytecodealliance/wasmtime/releases) - [Commits](https://github.com/bytecodealliance/wasmtime/compare/08e5484cdb158b7795587ff7ad0cb04beef6dcd3...cd900d72db7b0ab3e16cf41e63d13828e4c48712) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a00846355b44a..3afec9bb73e34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" [[package]] name = "cranelift-entity" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" [[package]] name = "cranelift-frontend" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#08e5484cdb158b7795587ff7ad0cb04beef6dcd3" +source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" dependencies = [ "cranelift-codegen", "cranelift-module", From 017a9b7641d291c7b23ffdcb0d8f305d6e9cad23 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Mar 2020 19:00:24 +0200 Subject: [PATCH 1232/1566] Rustup to rustc 1.44.0-nightly (699f83f52 2020-03-29) --- rust-toolchain | 2 +- src/abi/comments.rs | 2 +- src/abi/mod.rs | 2 +- src/abi/pass_mode.rs | 2 +- src/abi/returning.rs | 4 ++-- src/common.rs | 4 ++-- src/constant.rs | 4 ++-- src/discriminant.rs | 2 +- src/intrinsics/mod.rs | 16 ++++++++-------- src/lib.rs | 2 +- src/trap.rs | 4 ++-- src/unsize.rs | 6 +++--- src/value_and_place.rs | 36 ++++++++++++++++++------------------ src/vtable.rs | 4 ++-- 14 files changed, 45 insertions(+), 45 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 839a020ec18c5..8746986fb4f5d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-28 +nightly-2020-03-30 diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 4f5fb0f2e44ed..773b49f8e4458 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -61,7 +61,7 @@ pub(super) fn add_local_place_comments<'tcx>( place: CPlace<'tcx>, local: Local, ) { - let TyLayout { ty, layout } = place.layout(); + let TyAndLayout { ty, layout } = place.layout(); let ty::layout::Layout { size, align, diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 2e7a73a484d34..eb03552bf0ef1 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -271,7 +271,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { fn local_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, is_ssa: bool, ) -> CPlace<'tcx> { let place = if is_ssa { diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index bed4574717e6d..8ebc981d9b055 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -76,7 +76,7 @@ impl PassMode { } } -pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> PassMode { +pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> PassMode { if layout.is_zst() { // WARNING zst arguments must never be passed, as that will break CastKind::ClosureFnPointer PassMode::NoPass diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 59836f881b649..d53abe32147d1 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -1,11 +1,11 @@ use crate::abi::pass_mode::*; use crate::prelude::*; -fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyLayout<'tcx> { +fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyAndLayout<'tcx> { fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty)) } -pub(crate) fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyLayout<'tcx>) -> bool { +pub(crate) fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyAndLayout<'tcx>) -> bool { match get_pass_mode(tcx, dest_layout) { PassMode::NoPass | PassMode::ByVal(_) => true, // FIXME Make it possible to return ByValPair and ByRef to an ssa var. diff --git a/src/common.rs b/src/common.rs index 09133d94db237..1d3fdfc75bf3f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -282,9 +282,9 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { type Ty = Ty<'tcx>; - type TyLayout = TyLayout<'tcx>; + type TyAndLayout = TyAndLayout<'tcx>; - fn layout_of(&self, ty: Ty<'tcx>) -> TyLayout<'tcx> { + fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { assert!(!ty.needs_subst()); self.tcx .layout_of(ParamEnv::reveal_all().and(&ty)) diff --git a/src/constant.rs b/src/constant.rs index 7bd2f47619329..306f61aa074b7 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -46,7 +46,7 @@ pub(crate) fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { fn codegen_static_ref<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, def_id: DefId, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, ) -> CPlace<'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); @@ -277,7 +277,7 @@ fn data_id_for_static( fn cplace_for_dataid<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, local_data_id: GlobalValue, ) -> CPlace<'tcx> { let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); diff --git a/src/discriminant.rs b/src/discriminant.rs index a6d6d814fc96f..2d0b36a5480f2 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -55,7 +55,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( pub(crate) fn codegen_get_discriminant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, value: CValue<'tcx>, - dest_layout: TyLayout<'tcx>, + dest_layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { let layout = value.layout(); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 2034d95cdacaa..feacb3e6e9e33 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -140,8 +140,8 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ fn lane_type_and_count<'tcx>( tcx: TyCtxt<'tcx>, - layout: TyLayout<'tcx>, -) -> (TyLayout<'tcx>, u16) { + layout: TyAndLayout<'tcx>, +) -> (TyAndLayout<'tcx>, u16) { assert!(layout.ty.is_simd()); let lane_count = match layout.fields { layout::FieldPlacement::Array { stride: _, count } => u16::try_from(count).unwrap(), @@ -154,7 +154,7 @@ fn lane_type_and_count<'tcx>( (lane_layout, lane_count) } -fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyLayout<'tcx>) -> Option { +fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Option { let (element, count) = match &layout.abi { Abi::Vector { element, count } => (element.clone(), *count), _ => unreachable!(), @@ -175,8 +175,8 @@ fn simd_for_each_lane<'tcx, B: Backend>( ret: CPlace<'tcx>, f: impl Fn( &mut FunctionCx<'_, 'tcx, B>, - TyLayout<'tcx>, - TyLayout<'tcx>, + TyAndLayout<'tcx>, + TyAndLayout<'tcx>, Value, ) -> CValue<'tcx>, ) { @@ -203,8 +203,8 @@ fn simd_pair_for_each_lane<'tcx, B: Backend>( ret: CPlace<'tcx>, f: impl Fn( &mut FunctionCx<'_, 'tcx, B>, - TyLayout<'tcx>, - TyLayout<'tcx>, + TyAndLayout<'tcx>, + TyAndLayout<'tcx>, Value, Value, ) -> CValue<'tcx>, @@ -229,7 +229,7 @@ fn simd_pair_for_each_lane<'tcx, B: Backend>( fn bool_to_zero_or_max_uint<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, val: Value, ) -> CValue<'tcx> { let ty = fx.clif_type(layout.ty).unwrap(); diff --git a/src/lib.rs b/src/lib.rs index 303ef3f7f9489..fb06207133929 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,7 +72,7 @@ mod prelude { pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE}; pub(crate) use rustc::mir::{self, *}; pub(crate) use rustc_session::Session; - pub(crate) use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout, VariantIdx}; + pub(crate) use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyAndLayout, VariantIdx}; pub(crate) use rustc::ty::{ self, FnSig, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; diff --git a/src/trap.rs b/src/trap.rs index d63e86db29d98..86af1ee538119 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -80,7 +80,7 @@ pub(crate) fn trap_unreachable( /// Trap code: user65535 pub(crate) fn trap_unreachable_ret_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, - dest_layout: TyLayout<'tcx>, + dest_layout: TyAndLayout<'tcx>, msg: impl AsRef, ) -> CValue<'tcx> { trap_unreachable(fx, msg); @@ -106,7 +106,7 @@ pub(crate) fn trap_unimplemented( /// Trap code: user65535 pub(crate) fn trap_unimplemented_ret_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, - dest_layout: TyLayout<'tcx>, + dest_layout: TyAndLayout<'tcx>, msg: impl AsRef, ) -> CValue<'tcx> { trap_unimplemented(fx, msg); diff --git a/src/unsize.rs b/src/unsize.rs index d6a85deda7807..affb36d7d3712 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -43,8 +43,8 @@ pub(crate) fn unsized_info<'tcx>( fn unsize_thin_ptr<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, src: Value, - src_layout: TyLayout<'tcx>, - dst_layout: TyLayout<'tcx>, + src_layout: TyAndLayout<'tcx>, + dst_layout: TyAndLayout<'tcx>, ) -> (Value, Value) { match (&src_layout.ty.kind, &dst_layout.ty.kind) { (&ty::Ref(_, a, _), &ty::Ref(_, b, _)) @@ -139,7 +139,7 @@ pub(crate) fn coerce_unsized_into<'tcx>( pub(crate) fn size_and_align_of_dst<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, info: Value, ) -> (Value, Value) { if !layout.is_unsized() { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 41fe85795c299..226c78ed01cfc 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -6,9 +6,9 @@ fn codegen_field<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, base: Pointer, extra: Option, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, field: mir::Field, -) -> (Pointer, TyLayout<'tcx>) { +) -> (Pointer, TyAndLayout<'tcx>) { let field_offset = layout.fields.offset(field.index()); let field_layout = layout.field(&*fx, field.index()); @@ -62,7 +62,7 @@ fn scalar_pair_calculate_b_offset(tcx: TyCtxt<'_>, a_scalar: &Scalar, b_scalar: /// A read-only value #[derive(Debug, Copy, Clone)] -pub(crate) struct CValue<'tcx>(CValueInner, TyLayout<'tcx>); +pub(crate) struct CValue<'tcx>(CValueInner, TyAndLayout<'tcx>); #[derive(Debug, Copy, Clone)] enum CValueInner { @@ -72,23 +72,23 @@ enum CValueInner { } impl<'tcx> CValue<'tcx> { - pub(crate) fn by_ref(ptr: Pointer, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_ref(ptr: Pointer, layout: TyAndLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByRef(ptr, None), layout) } - pub(crate) fn by_ref_unsized(ptr: Pointer, meta: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_ref_unsized(ptr: Pointer, meta: Value, layout: TyAndLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByRef(ptr, Some(meta)), layout) } - pub(crate) fn by_val(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_val(value: Value, layout: TyAndLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByVal(value), layout) } - pub(crate) fn by_val_pair(value: Value, extra: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_val_pair(value: Value, extra: Value, layout: TyAndLayout<'tcx>) -> CValue<'tcx> { CValue(CValueInner::ByValPair(value, extra), layout) } - pub(crate) fn layout(&self) -> TyLayout<'tcx> { + pub(crate) fn layout(&self) -> TyAndLayout<'tcx> { self.1 } @@ -194,7 +194,7 @@ impl<'tcx> CValue<'tcx> { /// If `ty` is signed, `const_val` must already be sign extended. pub(crate) fn const_val( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, const_val: u128, ) -> CValue<'tcx> { use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; @@ -243,7 +243,7 @@ impl<'tcx> CValue<'tcx> { CValue::by_val(val, layout) } - pub(crate) fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + pub(crate) fn unchecked_cast_to(self, layout: TyAndLayout<'tcx>) -> Self { CValue(self.0, layout) } } @@ -252,7 +252,7 @@ impl<'tcx> CValue<'tcx> { #[derive(Debug, Copy, Clone)] pub(crate) struct CPlace<'tcx> { inner: CPlaceInner, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, } #[derive(Debug, Copy, Clone)] @@ -263,7 +263,7 @@ pub(crate) enum CPlaceInner { } impl<'tcx> CPlace<'tcx> { - pub(crate) fn layout(&self) -> TyLayout<'tcx> { + pub(crate) fn layout(&self) -> TyAndLayout<'tcx> { self.layout } @@ -271,7 +271,7 @@ impl<'tcx> CPlace<'tcx> { &self.inner } - pub(crate) fn no_place(layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub(crate) fn no_place(layout: TyAndLayout<'tcx>) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::NoPlace, layout, @@ -280,7 +280,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn new_stack_slot( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { assert!(!layout.is_unsized()); if layout.size.bytes() == 0 { @@ -304,7 +304,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn new_var( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { fx.bcx .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); @@ -314,14 +314,14 @@ impl<'tcx> CPlace<'tcx> { } } - pub(crate) fn for_ptr(ptr: Pointer, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub(crate) fn for_ptr(ptr: Pointer, layout: TyAndLayout<'tcx>) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::Addr(ptr, None), layout, } } - pub(crate) fn for_ptr_with_extra(ptr: Pointer, extra: Value, layout: TyLayout<'tcx>) -> CPlace<'tcx> { + pub(crate) fn for_ptr_with_extra(ptr: Pointer, extra: Value, layout: TyAndLayout<'tcx>) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::Addr(ptr, Some(extra)), layout, @@ -578,7 +578,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub(crate) fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { + pub(crate) fn unchecked_cast_to(self, layout: TyAndLayout<'tcx>) -> Self { assert!(!self.layout().is_unsized()); match self.inner { CPlaceInner::NoPlace => { diff --git a/src/vtable.rs b/src/vtable.rs index 127e4ce79a63e..436073d26ce5c 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -69,7 +69,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( pub(crate) fn get_vtable<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> Value { let data_id = if let Some(data_id) = fx.vtables.get(&(layout.ty, trait_ref)) { @@ -86,7 +86,7 @@ pub(crate) fn get_vtable<'tcx>( fn build_vtable<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - layout: TyLayout<'tcx>, + layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> DataId { let tcx = fx.tcx; From 13e3a3c8b0001999e40efa58abd14ee61e6d53d8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Mar 2020 13:20:19 +0200 Subject: [PATCH 1233/1566] Rustup to rustc 1.44.0-nightly (211365947 2020-03-30) --- rust-toolchain | 2 +- src/abi/comments.rs | 2 +- src/allocator.rs | 2 +- src/analyze.rs | 2 +- src/base.rs | 4 ++-- src/common.rs | 2 +- src/constant.rs | 6 +++--- src/debuginfo/mod.rs | 2 +- src/driver/aot.rs | 10 +++++----- src/driver/jit.rs | 2 +- src/driver/mod.rs | 4 ++-- src/intrinsics/llvm.rs | 2 +- src/intrinsics/simd.rs | 4 ++-- src/lib.rs | 18 +++++++++--------- src/linkage.rs | 2 +- src/main_shim.rs | 2 +- src/metadata.rs | 6 +++--- src/value_and_place.rs | 2 +- 18 files changed, 37 insertions(+), 37 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 8746986fb4f5d..cd37a8d267e64 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-30 +nightly-2020-03-31 diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 773b49f8e4458..fb95a25606f36 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use rustc::mir; +use rustc_middle::mir; use crate::abi::pass_mode::*; use crate::prelude::*; diff --git a/src/allocator.rs b/src/allocator.rs index 0b40af9de54cb..2ea4a1659f8bf 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -15,7 +15,7 @@ use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS /// Returns whether an allocator shim was created pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| { - use rustc::middle::dependency_format::Linkage; + use rustc_middle::middle::dependency_format::Linkage; list.iter().any(|&linkage| linkage == Linkage::Dynamic) }); if any_dynamic_crate { diff --git a/src/analyze.rs b/src/analyze.rs index b82e16217ef61..afb8ac409fe64 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use rustc::mir::StatementKind::*; +use rustc_middle::mir::StatementKind::*; use rustc_index::vec::IndexVec; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] diff --git a/src/base.rs b/src/base.rs index d2841b25f5ea9..cc7692a6795bd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,4 +1,4 @@ -use rustc::ty::adjustment::PointerCast; +use rustc_middle::ty::adjustment::PointerCast; use rustc_index::vec::IndexVec; use crate::prelude::*; @@ -592,7 +592,7 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { - use rustc::middle::lang_items::ExchangeMallocFnLangItem; + use rustc_middle::middle::lang_items::ExchangeMallocFnLangItem; let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); let content_ty = fx.monomorphize(content_ty); diff --git a/src/common.rs b/src/common.rs index 1d3fdfc75bf3f..4c0e314d3ff42 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,4 +1,4 @@ -use rustc::ty::layout::{Integer, Primitive}; +use rustc_middle::ty::layout::{Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; use rustc_index::vec::IndexVec; diff --git a/src/constant.rs b/src/constant.rs index 306f61aa074b7..1d98404c75fbd 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -2,11 +2,11 @@ use std::borrow::Cow; use rustc_span::DUMMY_SP; -use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags; -use rustc::mir::interpret::{ +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; +use rustc_middle::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, }; -use rustc::ty::{layout::Align, Const, ConstKind}; +use rustc_middle::ty::{layout::Align, Const, ConstKind}; use rustc_data_structures::fx::FxHashSet; use rustc_mir::interpret::{ ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 95fde120a9c13..226d67fe04423 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -16,7 +16,7 @@ use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, X86_64}; pub(crate) use emit::{DebugReloc, DebugRelocName}; fn target_endian(tcx: TyCtxt) -> RunTimeEndian { - use rustc::ty::layout::Endian; + use rustc_middle::ty::layout::Endian; match tcx.data_layout.endian { Endian::Big => RunTimeEndian::Big, diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 71876816f39fd..b4f0a03bbd52d 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -1,6 +1,6 @@ -use rustc::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; -use rustc::middle::cstore::EncodedMetadata; -use rustc::mir::mono::CodegenUnit; +use rustc_middle::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; +use rustc_middle::middle::cstore::EncodedMetadata; +use rustc_middle::mir::mono::CodegenUnit; use rustc_session::config::{DebugInfo, OutputType}; use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_codegen_ssa::back::linker::LinkerInfo; @@ -170,7 +170,7 @@ pub(super) fn run_aot( let dep_node = cgu.codegen_dep_node(tcx); let (ModuleCodegenResult(module, work_product), _) = - tcx.dep_graph.with_task(dep_node, tcx, cgu.name(), module_codegen, rustc::dep_graph::hash_result); + tcx.dep_graph.with_task(dep_node, tcx, cgu.name(), module_codegen, rustc_middle::dep_graph::hash_result); if let Some((id, product)) = work_product { work_products.insert(id, product); @@ -207,7 +207,7 @@ pub(super) fn run_aot( let metadata_module = if need_metadata_module { let _timer = tcx.prof.generic_activity("codegen crate metadata"); let (metadata_cgu_name, tmp_file) = tcx.sess.time("write compressed metadata", || { - use rustc::mir::mono::CodegenUnitNameBuilder; + use rustc_middle::mir::mono::CodegenUnitNameBuilder; let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); let metadata_cgu_name = cgu_name_builder diff --git a/src/driver/jit.rs b/src/driver/jit.rs index d4582e6f1ff95..b4d16011cad7f 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -81,7 +81,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { } fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { - use rustc::middle::dependency_format::Linkage; + use rustc_middle::middle::dependency_format::Linkage; let mut dylib_paths = Vec::new(); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 7f46150252e24..6aa736d18ce6e 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,7 +1,7 @@ use std::any::Any; -use rustc::middle::cstore::EncodedMetadata; -use rustc::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; +use rustc_middle::middle::cstore::EncodedMetadata; +use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; use crate::prelude::*; diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index e1a0066fc48e3..b99a3dffa11c2 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -1,7 +1,7 @@ use crate::intrinsics::*; use crate::prelude::*; -use rustc::ty::subst::SubstsRef; +use rustc_middle::ty::subst::SubstsRef; pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index d5c618a604ddb..cf7decb046492 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -67,7 +67,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let total_len = lane_count * 2; let indexes = { - use rustc::mir::interpret::*; + use rustc_middle::mir::interpret::*; let idx_const = crate::constant::mir_operand_get_const_val(fx, idx).expect("simd_shuffle* idx not const"); let idx_bytes = match idx_const.val { @@ -81,7 +81,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( (0..ret_lane_count).map(|i| { let i = usize::try_from(i).unwrap(); - let idx = rustc::mir::interpret::read_target_uint( + let idx = rustc_middle::mir::interpret::read_target_uint( fx.tcx.data_layout.endian, &idx_bytes[4*i.. 4*i + 4], ).expect("read_target_uint"); diff --git a/src/lib.rs b/src/lib.rs index fb06207133929..b23e74cd5bfe4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ extern crate flate2; extern crate libc; extern crate tempfile; -extern crate rustc; +extern crate rustc_middle; extern crate rustc_codegen_ssa; extern crate rustc_data_structures; extern crate rustc_driver; @@ -21,11 +21,11 @@ extern crate rustc_ast; use std::any::Any; -use rustc::dep_graph::{DepGraph, WorkProduct, WorkProductId}; -use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; +use rustc_middle::dep_graph::{DepGraph, WorkProduct, WorkProductId}; +use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc_session::config::OutputFilenames; -use rustc::ty::query::Providers; -use rustc::util::common::ErrorReported; +use rustc_middle::ty::query::Providers; +use rustc_middle::util::common::ErrorReported; use rustc_codegen_ssa::traits::CodegenBackend; use cranelift_codegen::settings; @@ -68,12 +68,12 @@ mod prelude { pub(crate) use rustc_ast::ast::{FloatTy, IntTy, UintTy}; pub(crate) use rustc_span::Span; - pub(crate) use rustc::bug; + pub(crate) use rustc_middle::bug; pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE}; - pub(crate) use rustc::mir::{self, *}; + pub(crate) use rustc_middle::mir::{self, *}; pub(crate) use rustc_session::Session; - pub(crate) use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyAndLayout, VariantIdx}; - pub(crate) use rustc::ty::{ + pub(crate) use rustc_middle::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyAndLayout, VariantIdx}; + pub(crate) use rustc_middle::ty::{ self, FnSig, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; diff --git a/src/linkage.rs b/src/linkage.rs index 6b4c4353964ba..893ec851f1034 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -1,4 +1,4 @@ -use rustc::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; +use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; use crate::prelude::*; diff --git a/src/main_shim.rs b/src/main_shim.rs index ab264f2e85aae..193d1cde163a0 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -3,7 +3,7 @@ use crate::prelude::*; /// Create the `main` function which will initialize the rust runtime and call /// users main function. pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { - use rustc::middle::lang_items::StartFnLangItem; + use rustc_middle::middle::lang_items::StartFnLangItem; use rustc_session::config::EntryFnType; let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) { diff --git a/src/metadata.rs b/src/metadata.rs index 748d4075a702e..daf2127a37654 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -2,9 +2,9 @@ use std::convert::TryFrom; use std::fs::File; use std::path::Path; -use rustc::middle::cstore::{EncodedMetadata, MetadataLoader}; +use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc_session::config; -use rustc::ty::TyCtxt; +use rustc_middle::ty::TyCtxt; use rustc_codegen_ssa::METADATA_FILENAME; use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::rustc_erase_owner; @@ -104,7 +104,7 @@ pub(crate) fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) .unwrap(); product.add_rustc_section( - rustc::middle::exported_symbols::metadata_symbol_name(tcx), + rustc_middle::middle::exported_symbols::metadata_symbol_name(tcx), compressed, tcx.sess.target.target.options.is_like_osx, ); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 226c78ed01cfc..4f196d6f056ed 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -225,7 +225,7 @@ impl<'tcx> CValue<'tcx> { .iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64) } ty::TyKind::Int(_) => { - let const_val = rustc::mir::interpret::sign_extend(const_val, layout.size); + let const_val = rustc_middle::mir::interpret::sign_extend(const_val, layout.size); fx.bcx.ins().iconst(clif_ty, i64::try_from(const_val as i128).unwrap()) } ty::TyKind::Float(FloatTy::F32) => { From ab4328db4302f441538c5439e683cb10ab8cd855 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Mar 2020 14:13:03 +0200 Subject: [PATCH 1234/1566] Fix opt level names --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b23e74cd5bfe4..335112b4764b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -287,11 +287,11 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box { - flags_builder.set("opt_level", "fastest").unwrap(); + flags_builder.set("opt_level", "none").unwrap(); } OptLevel::Less | OptLevel::Default => {} OptLevel::Aggressive => { - flags_builder.set("opt_level", "best").unwrap(); + flags_builder.set("opt_level", "speed_and_size").unwrap(); } OptLevel::Size | OptLevel::SizeMin => { sess.warn("Optimizing for size is not supported. Just ignoring the request"); From c2e35604474aa25479dcca231fbc393a941234da Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Mar 2020 14:13:38 +0200 Subject: [PATCH 1235/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3afec9bb73e34..8708c68cb0294 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" [[package]] name = "cranelift-entity" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" [[package]] name = "cranelift-frontend" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#cd900d72db7b0ab3e16cf41e63d13828e4c48712" +source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" dependencies = [ "cranelift-codegen", "cranelift-module", From a0eab7d91330de1d18caecdde558369c77f642f7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 31 Mar 2020 21:11:16 +0200 Subject: [PATCH 1236/1566] Update actions-rs/cargo --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5cb1af9d9b2f0..91e4c9ced3443 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,7 +53,7 @@ jobs: # Compile is a separate step, as the actions-rs/cargo action supports error annotations - name: Compile - uses: actions-rs/cargo@v1.0.1 + uses: actions-rs/cargo@v1.0.3 with: command: rustc args: --release -- -Zrun_dsymutil=no From e3396901c407da7caba2d28743259d62fac189a8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 1 Apr 2020 14:12:46 +0200 Subject: [PATCH 1237/1566] Update Cranelift --- Cargo.lock | 20 +++++++------- src/debuginfo/mod.rs | 66 ++------------------------------------------ 2 files changed, 13 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8708c68cb0294..8c68bdcd282ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" [[package]] name = "cranelift-entity" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" [[package]] name = "cranelift-frontend" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ac7cd4c46abdc9d4f3ef3230386afd52177e5f7c" +source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" dependencies = [ "cranelift-codegen", "cranelift-module", diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 226d67fe04423..6509e8ef5a1bc 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -4,14 +4,14 @@ mod line_info; use crate::prelude::*; use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; -use cranelift_codegen::isa::{RegUnit, TargetIsa}; +use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; use gimli::write::{ self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, LocationList, Range, RangeList, UnitEntryId, Writer, }; -use gimli::{Encoding, Format, LineEncoding, Register, RunTimeEndian, X86_64}; +use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; pub(crate) use emit::{DebugReloc, DebugRelocName}; @@ -351,71 +351,11 @@ fn place_location<'a, 'tcx>( } } - - - - -// Adapted from https://github.com/bytecodealliance/wasmtime/blob/50496efb6bac32aaf469c6d9186b322de83549bf/crates/debug/src/transform/map_reg.rs -pub(crate) fn map_reg(isa: &dyn TargetIsa, reg: RegUnit) -> Register { - // TODO avoid duplication with fde.rs - assert!(isa.name() == "x86" && isa.pointer_bits() == 64); - // Mapping from https://github.com/bytecodealliance/cranelift/pull/902 by @iximeow - const X86_GP_REG_MAP: [Register; 16] = [ - X86_64::RAX, - X86_64::RCX, - X86_64::RDX, - X86_64::RBX, - X86_64::RSP, - X86_64::RBP, - X86_64::RSI, - X86_64::RDI, - X86_64::R8, - X86_64::R9, - X86_64::R10, - X86_64::R11, - X86_64::R12, - X86_64::R13, - X86_64::R14, - X86_64::R15, - ]; - const X86_XMM_REG_MAP: [Register; 16] = [ - X86_64::XMM0, - X86_64::XMM1, - X86_64::XMM2, - X86_64::XMM3, - X86_64::XMM4, - X86_64::XMM5, - X86_64::XMM6, - X86_64::XMM7, - X86_64::XMM8, - X86_64::XMM9, - X86_64::XMM10, - X86_64::XMM11, - X86_64::XMM12, - X86_64::XMM13, - X86_64::XMM14, - X86_64::XMM15, - ]; - let reg_info = isa.register_info(); - let bank = reg_info.bank_containing_regunit(reg).unwrap(); - match bank.name { - "IntRegs" => { - // x86 GP registers have a weird mapping to DWARF registers, so we use a - // lookup table. - X86_GP_REG_MAP[(reg - bank.first_unit) as usize] - } - "FloatRegs" => X86_XMM_REG_MAP[(reg - bank.first_unit) as usize], - bank_name => { - panic!("unsupported register bank: {}", bank_name); - } - } -} - // Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137 fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option> { match loc { ValueLoc::Reg(reg) => { - let machine_reg = map_reg(isa, reg).0 as u8; + let machine_reg = cranelift_codegen::isa::fde::map_reg(isa, reg).unwrap().0 as u8; assert!(machine_reg <= 32); // FIXME Some(vec![gimli::constants::DW_OP_reg0.0 + machine_reg]) } From 5958355ef1f8a1787acee664128e18b0db2d2d23 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 1 Apr 2020 14:14:34 +0200 Subject: [PATCH 1238/1566] Update dependencies --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c68bdcd282ad..ec29f3288537a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "anyhow" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "013a6e0a2cbe3d20f9c60b65458f7a7f7a5e636c5d0f45a5a6aee5d4b1f01785" +checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff" [[package]] name = "ar" @@ -248,9 +248,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" +checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" dependencies = [ "unicode-xid", ] @@ -354,18 +354,18 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "thiserror" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3711fd1c4e75b3eff12ba5c40dba762b6b65c5476e8174c1a664772060c49bf" +checksum = "f0570dc61221295909abdb95c739f2e74325e14293b2026b0a7e195091ec54ae" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae2b85ba4c9aa32dd3343bd80eb8d22e9b54b7688c17ea3907f236885353b233" +checksum = "227362df41d566be41a28f64401e07a043157c21c14b9785a0d8e256f940a8fd" dependencies = [ "proc-macro2", "quote", From 786c7d8d8ce3a21a394404c41a01a666c26071f3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 2 Apr 2020 14:27:51 +0200 Subject: [PATCH 1239/1566] Rustup to rustc 1.44.0-nightly (76b11980a 2020-04-01) --- rust-toolchain | 2 +- src/constant.rs | 3 --- src/intrinsics/mod.rs | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index cd37a8d267e64..876125317a9a2 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-03-31 +nightly-2020-04-02 diff --git a/src/constant.rs b/src/constant.rs index 1d98404c75fbd..f94ccae8185d3 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -171,7 +171,6 @@ fn trans_const_place<'tcx>( ); ecx.push_stack_frame( fx.instance, - DUMMY_SP, fx.mir, None, StackPopCleanup::None { cleanup: false }, @@ -412,7 +411,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn find_mir_or_eval_fn( _: &mut InterpCx<'mir, 'tcx, Self>, - _: Span, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: Option<(PlaceTy<'tcx>, BasicBlock)>, @@ -423,7 +421,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { fn call_intrinsic( _: &mut InterpCx<'mir, 'tcx, Self>, - _: Span, _: Instance<'tcx>, _: &[OpTy<'tcx>], _: Option<(PlaceTy<'tcx>, BasicBlock)>, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index feacb3e6e9e33..e5a1e21882556 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -144,7 +144,7 @@ fn lane_type_and_count<'tcx>( ) -> (TyAndLayout<'tcx>, u16) { assert!(layout.ty.is_simd()); let lane_count = match layout.fields { - layout::FieldPlacement::Array { stride: _, count } => u16::try_from(count).unwrap(), + layout::FieldsShape::Array { stride: _, count } => u16::try_from(count).unwrap(), _ => unreachable!("lane_type_and_count({:?})", layout), }; let lane_layout = layout.field(&ty::layout::LayoutCx { From 17f99b4a964a4ade86da447088c0a3fc2de43270 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 2 Apr 2020 17:23:15 +0200 Subject: [PATCH 1240/1566] Take Place by value instead of by reference --- src/abi/mod.rs | 5 ++--- src/base.rs | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index eb03552bf0ef1..aa89a3d4e29ed 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -428,7 +428,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( span: Span, func: &Operand<'tcx>, args: &[Operand<'tcx>], - destination: &Option<(Place<'tcx>, BasicBlock)>, + destination: Option<(Place<'tcx>, BasicBlock)>, ) { let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); let sig = fx @@ -436,8 +436,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); let destination = destination - .as_ref() - .map(|&(ref place, bb)| (trans_place(fx, place), bb)); + .map(|(place, bb)| (trans_place(fx, place), bb)); if let ty::FnDef(def_id, substs) = fn_ty.kind { let instance = diff --git a/src/base.rs b/src/base.rs index cc7692a6795bd..0970b0d169522 100644 --- a/src/base.rs +++ b/src/base.rs @@ -95,7 +95,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( bb_data.terminator().source_info.span, func, args, - destination, + *destination, )); destination.map(|(_ret_place, ret_block)| ret_block) } @@ -126,7 +126,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( bb_data.terminator().source_info.span, func, args, - destination, + *destination, )); destination.map(|(_ret_place, ret_block)| ret_block) } @@ -336,7 +336,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { bb_data.terminator().source_info.span, func, args, - destination, + *destination, )); } TerminatorKind::Resume | TerminatorKind::Abort => { @@ -357,7 +357,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { target, unwind: _, } => { - let drop_place = trans_place(fx, location); + let drop_place = trans_place(fx, *location); crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); let target_block = fx.get_block(*target); @@ -394,11 +394,11 @@ fn trans_stmt<'tcx>( place, variant_index, } => { - let place = trans_place(fx, place); + let place = trans_place(fx, **place); crate::discriminant::codegen_set_discriminant(fx, place, *variant_index); } StatementKind::Assign(to_place_and_rval) => { - let lval = trans_place(fx, &to_place_and_rval.0); + let lval = trans_place(fx, to_place_and_rval.0); let dest_layout = lval.layout(); match &to_place_and_rval.1 { Rvalue::Use(operand) => { @@ -406,7 +406,7 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, val); } Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { - let place = trans_place(fx, place); + let place = trans_place(fx, *place); place.write_place_ref(fx, lval); } Rvalue::BinaryOp(bin_op, lhs, rhs) => { @@ -565,7 +565,7 @@ fn trans_stmt<'tcx>( operand.unsize_value(fx, lval); } Rvalue::Discriminant(place) => { - let place = trans_place(fx, place); + let place = trans_place(fx, *place); let value = place.to_cvalue(fx); let discr = crate::discriminant::codegen_get_discriminant(fx, value, dest_layout); @@ -586,7 +586,7 @@ fn trans_stmt<'tcx>( } } Rvalue::Len(place) => { - let place = trans_place(fx, place); + let place = trans_place(fx, *place); let usize_layout = fx.layout_of(fx.tcx.types.usize); let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); @@ -739,11 +739,11 @@ fn codegen_array_len<'tcx>( pub(crate) fn trans_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - place: &Place<'tcx>, + place: Place<'tcx>, ) -> CPlace<'tcx> { let mut cplace = fx.get_local_place(place.local); - for elem in &*place.projection { + for elem in place.projection { match *elem { PlaceElem::Deref => { cplace = cplace.place_deref(fx); @@ -811,7 +811,7 @@ pub(crate) fn trans_operand<'tcx>( ) -> CValue<'tcx> { match operand { Operand::Move(place) | Operand::Copy(place) => { - let cplace = trans_place(fx, place); + let cplace = trans_place(fx, *place); cplace.to_cvalue(fx) } Operand::Constant(const_) => crate::constant::trans_constant(fx, const_), From ac1c5d69544450d30785d001224f7233da48cbda Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Apr 2020 11:54:18 +0200 Subject: [PATCH 1241/1566] Rustup to rustc 1.44.0-nightly (537ccdf3a 2020-04-02) --- build_sysroot/alloc_system/lib.rs | 107 +++++++++++++++++++++++++----- rust-toolchain | 2 +- src/abi/comments.rs | 2 +- src/abi/pass_mode.rs | 10 +-- src/base.rs | 2 +- src/common.rs | 6 +- src/constant.rs | 3 +- src/debuginfo/mod.rs | 2 +- src/discriminant.rs | 24 ++++--- src/intrinsics/mod.rs | 2 +- src/lib.rs | 6 +- src/main_shim.rs | 2 +- src/value_and_place.rs | 8 +-- src/vtable.rs | 4 +- 14 files changed, 128 insertions(+), 52 deletions(-) diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index 8ad0a076d3d30..bb0ceb229f46f 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -18,6 +18,7 @@ #![feature(nll)] #![feature(staged_api)] #![feature(rustc_attrs)] +#![feature(alloc_layout_extra)] #![cfg_attr( all(target_arch = "wasm32", not(target_os = "emscripten")), feature(integer_atomics, stdsimd) @@ -41,8 +42,10 @@ const MIN_ALIGN: usize = 8; target_arch = "sparc64")))] #[allow(dead_code)] const MIN_ALIGN: usize = 16; -use core::alloc::{AllocRef, GlobalAlloc, AllocErr, Layout}; +use core::alloc::*; use core::ptr::NonNull; +use core::intrinsics; + /// The default memory allocator provided by the operating system. /// /// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows, @@ -72,29 +75,97 @@ pub struct System; #[unstable(feature = "allocator_api", issue = "32838")] unsafe impl AllocRef for System { #[inline] - fn alloc(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { - NonNull::new(unsafe { GlobalAlloc::alloc(self, layout) }) - .ok_or(AllocErr) - .map(|p| (p, layout.size())) + fn alloc(&mut self, layout: Layout, init: AllocInit) -> Result { + unsafe { + let size = layout.size(); + if size == 0 { + Ok(MemoryBlock { ptr: layout.dangling(), size: 0 }) + } else { + let raw_ptr = match init { + AllocInit::Uninitialized => GlobalAlloc::alloc(self, layout), + AllocInit::Zeroed => GlobalAlloc::alloc_zeroed(self, layout), + }; + let ptr = NonNull::new(raw_ptr).ok_or(AllocErr)?; + Ok(MemoryBlock { ptr, size }) + } + } } + #[inline] - fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull, usize), AllocErr> { - NonNull::new(unsafe { GlobalAlloc::alloc_zeroed(self, layout) }) - .ok_or(AllocErr) - .map(|p| (p, layout.size())) + unsafe fn dealloc(&mut self, ptr: NonNull, layout: Layout) { + if layout.size() != 0 { + GlobalAlloc::dealloc(self, ptr.as_ptr(), layout) + } } + #[inline] - unsafe fn dealloc(&mut self, ptr: NonNull, layout: Layout) { - GlobalAlloc::dealloc(self, ptr.as_ptr(), layout) + unsafe fn grow( + &mut self, + ptr: NonNull, + layout: Layout, + new_size: usize, + placement: ReallocPlacement, + init: AllocInit, + ) -> Result { + let size = layout.size(); + debug_assert!( + new_size >= size, + "`new_size` must be greater than or equal to `memory.size()`" + ); + + if size == new_size { + return Ok(MemoryBlock { ptr, size }); + } + + match placement { + ReallocPlacement::InPlace => Err(AllocErr), + ReallocPlacement::MayMove if layout.size() == 0 => { + let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); + self.alloc(new_layout, init) + } + ReallocPlacement::MayMove => { + // `realloc` probably checks for `new_size > size` or something similar. + intrinsics::assume(new_size > size); + let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); + let memory = + MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }; + init.init_offset(memory, size); + Ok(memory) + } + } } + #[inline] - unsafe fn realloc(&mut self, - ptr: NonNull, - layout: Layout, - new_size: usize) -> Result<(NonNull, usize), AllocErr> { - NonNull::new(GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size)) - .ok_or(AllocErr) - .map(|p| (p, layout.size())) + unsafe fn shrink( + &mut self, + ptr: NonNull, + layout: Layout, + new_size: usize, + placement: ReallocPlacement, + ) -> Result { + let size = layout.size(); + debug_assert!( + new_size <= size, + "`new_size` must be smaller than or equal to `memory.size()`" + ); + + if size == new_size { + return Ok(MemoryBlock { ptr, size }); + } + + match placement { + ReallocPlacement::InPlace => Err(AllocErr), + ReallocPlacement::MayMove if new_size == 0 => { + self.dealloc(ptr, layout); + Ok(MemoryBlock { ptr: layout.dangling(), size: 0 }) + } + ReallocPlacement::MayMove => { + // `realloc` probably checks for `new_size < size` or something similar. + intrinsics::assume(new_size < size); + let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); + Ok(MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }) + } + } } } #[cfg(any(windows, unix, target_os = "cloudabi", target_os = "redox"))] diff --git a/rust-toolchain b/rust-toolchain index 876125317a9a2..6eacfad019a0a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-02 +nightly-2020-04-03 diff --git a/src/abi/comments.rs b/src/abi/comments.rs index fb95a25606f36..eae9ede3305c8 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -62,7 +62,7 @@ pub(super) fn add_local_place_comments<'tcx>( local: Local, ) { let TyAndLayout { ty, layout } = place.layout(); - let ty::layout::Layout { + let rustc_target::abi::Layout { size, align, abi: _, diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 8ebc981d9b055..68af0e6ca0fa8 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -82,11 +82,11 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) PassMode::NoPass } else { match &layout.abi { - layout::Abi::Uninhabited => PassMode::NoPass, - layout::Abi::Scalar(scalar) => { + Abi::Uninhabited => PassMode::NoPass, + Abi::Scalar(scalar) => { PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) } - layout::Abi::ScalarPair(a, b) => { + Abi::ScalarPair(a, b) => { let a = scalar_to_clif_type(tcx, a.clone()); let b = scalar_to_clif_type(tcx, b.clone()); if a == types::I128 && b == types::I128 { @@ -100,9 +100,9 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) } // FIXME implement Vector Abi in a cg_llvm compatible way - layout::Abi::Vector { .. } => PassMode::ByRef { sized: true }, + Abi::Vector { .. } => PassMode::ByRef { sized: true }, - &layout::Abi::Aggregate { sized } => PassMode::ByRef { sized }, + &Abi::Aggregate { sized } => PassMode::ByRef { sized }, } } } diff --git a/src/base.rs b/src/base.rs index 0970b0d169522..b5f67c7ea01cd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -592,7 +592,7 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { - use rustc_middle::middle::lang_items::ExchangeMallocFnLangItem; + use rustc_hir::lang_items::ExchangeMallocFnLangItem; let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); let content_ty = fx.monomorphize(content_ty); diff --git a/src/common.rs b/src/common.rs index 4c0e314d3ff42..a3e636dddfb9f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,4 +1,4 @@ -use rustc_middle::ty::layout::{Integer, Primitive}; +use rustc_target::abi::{Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; use rustc_index::vec::IndexVec; @@ -304,8 +304,8 @@ impl<'tcx, B: Backend + 'static> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx } } -impl<'tcx, B: Backend + 'static> layout::HasDataLayout for FunctionCx<'_, 'tcx, B> { - fn data_layout(&self) -> &layout::TargetDataLayout { +impl<'tcx, B: Backend + 'static> rustc_target::abi::HasDataLayout for FunctionCx<'_, 'tcx, B> { + fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { &self.tcx.data_layout } } diff --git a/src/constant.rs b/src/constant.rs index f94ccae8185d3..2882ecd078649 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -6,7 +6,8 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, }; -use rustc_middle::ty::{layout::Align, Const, ConstKind}; +use rustc_middle::ty::{Const, ConstKind}; +use rustc_target::abi::Align; use rustc_data_structures::fx::FxHashSet; use rustc_mir::interpret::{ ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 6509e8ef5a1bc..3c6c8469be8d1 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -16,7 +16,7 @@ use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; pub(crate) use emit::{DebugReloc, DebugRelocName}; fn target_endian(tcx: TyCtxt) -> RunTimeEndian { - use rustc_middle::ty::layout::Endian; + use rustc_target::abi::Endian; match tcx.data_layout.endian { Endian::Big => RunTimeEndian::Big, diff --git a/src/discriminant.rs b/src/discriminant.rs index 2d0b36a5480f2..b51851f0dc9df 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -1,5 +1,7 @@ //! Adapted from https://github.com/rust-lang/rust/blob/d760df5aea483aae041c9a241e7acacf48f75035/src/librustc_codegen_ssa/mir/place.rs +use rustc_target::abi::{DiscriminantKind, Int, Variants}; + use crate::prelude::*; pub(crate) fn codegen_set_discriminant<'tcx>( @@ -12,13 +14,13 @@ pub(crate) fn codegen_set_discriminant<'tcx>( return; } match layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { assert_eq!(index, variant_index); } - layout::Variants::Multiple { + Variants::Multiple { discr: _, discr_index, - discr_kind: layout::DiscriminantKind::Tag, + discr_kind: DiscriminantKind::Tag, variants: _, } => { let ptr = place.place_field(fx, mir::Field::new(discr_index)); @@ -30,11 +32,11 @@ pub(crate) fn codegen_set_discriminant<'tcx>( let discr = CValue::const_val(fx, ptr.layout(), to); ptr.write_cvalue(fx, discr); } - layout::Variants::Multiple { + Variants::Multiple { discr: _, discr_index, discr_kind: - layout::DiscriminantKind::Niche { + DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start, @@ -59,7 +61,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>( ) -> CValue<'tcx> { let layout = value.layout(); - if layout.abi == layout::Abi::Uninhabited { + if layout.abi == Abi::Uninhabited { return trap_unreachable_ret_value( fx, dest_layout, @@ -68,14 +70,14 @@ pub(crate) fn codegen_get_discriminant<'tcx>( } let (discr_scalar, discr_index, discr_kind) = match &layout.variants { - layout::Variants::Single { index } => { + Variants::Single { index } => { let discr_val = layout .ty .discriminant_for_variant(fx.tcx, *index) .map_or(u128::from(index.as_u32()), |discr| discr.val); return CValue::const_val(fx, dest_layout, discr_val); } - layout::Variants::Multiple { + Variants::Multiple { discr, discr_index, discr_kind, @@ -91,15 +93,15 @@ pub(crate) fn codegen_get_discriminant<'tcx>( // Decode the discriminant (specifically if it's niche-encoded). match *discr_kind { - layout::DiscriminantKind::Tag => { + DiscriminantKind::Tag => { let signed = match discr_scalar.value { - layout::Int(_, signed) => signed, + Int(_, signed) => signed, _ => false, }; let val = clif_intcast(fx, encoded_discr, cast_to, signed); return CValue::by_val(val, dest_layout); } - layout::DiscriminantKind::Niche { + DiscriminantKind::Niche { dataful_variant, ref niche_variants, niche_start, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index e5a1e21882556..8c8e9aae5d043 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -144,7 +144,7 @@ fn lane_type_and_count<'tcx>( ) -> (TyAndLayout<'tcx>, u16) { assert!(layout.ty.is_simd()); let lane_count = match layout.fields { - layout::FieldsShape::Array { stride: _, count } => u16::try_from(count).unwrap(), + rustc_target::abi::FieldsShape::Array { stride: _, count } => u16::try_from(count).unwrap(), _ => unreachable!("lane_type_and_count({:?})", layout), }; let lane_layout = layout.field(&ty::layout::LayoutCx { diff --git a/src/lib.rs b/src/lib.rs index 335112b4764b9..6a1839c3b1f39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ extern crate rustc_middle; extern crate rustc_codegen_ssa; extern crate rustc_data_structures; extern crate rustc_driver; +extern crate rustc_errors; extern crate rustc_fs_util; extern crate rustc_hir; extern crate rustc_incremental; @@ -21,11 +22,11 @@ extern crate rustc_ast; use std::any::Any; +use rustc_errors::ErrorReported; use rustc_middle::dep_graph::{DepGraph, WorkProduct, WorkProductId}; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc_session::config::OutputFilenames; use rustc_middle::ty::query::Providers; -use rustc_middle::util::common::ErrorReported; use rustc_codegen_ssa::traits::CodegenBackend; use cranelift_codegen::settings; @@ -72,7 +73,8 @@ mod prelude { pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE}; pub(crate) use rustc_middle::mir::{self, *}; pub(crate) use rustc_session::Session; - pub(crate) use rustc_middle::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyAndLayout, VariantIdx}; + pub(crate) use rustc_middle::ty::layout::{self, TyAndLayout}; + pub(crate) use rustc_target::abi::{Abi, LayoutOf, Scalar, Size, VariantIdx}; pub(crate) use rustc_middle::ty::{ self, FnSig, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; diff --git a/src/main_shim.rs b/src/main_shim.rs index 193d1cde163a0..f575d68cff2ad 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -3,7 +3,7 @@ use crate::prelude::*; /// Create the `main` function which will initialize the rust runtime and call /// users main function. pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { - use rustc_middle::middle::lang_items::StartFnLangItem; + use rustc_hir::lang_items::StartFnLangItem; use rustc_session::config::EntryFnType; let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 4f196d6f056ed..63ce64ab57dce 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -118,8 +118,8 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.abi { - layout::Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), - layout::Abi::Vector { ref element, count } => { + Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), + Abi::Vector { ref element, count } => { scalar_to_clif_type(fx.tcx, element.clone()) .by(u16::try_from(count).unwrap()).unwrap() } @@ -142,7 +142,7 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByRef(ptr, None) => { let (a_scalar, b_scalar) = match &layout.abi { - layout::Abi::ScalarPair(a, b) => (a, b), + Abi::ScalarPair(a, b) => (a, b), _ => unreachable!("load_scalar_pair({:?})", self), }; let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); @@ -167,7 +167,7 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByVal(val) => { match layout.abi { - layout::Abi::Vector { element: _, count } => { + Abi::Vector { element: _, count } => { let count = u8::try_from(count).expect("SIMD type with more than 255 lanes???"); let field = u8::try_from(field.index()).unwrap(); assert!(field < count); diff --git a/src/vtable.rs b/src/vtable.rs index 436073d26ce5c..d67cc6e865eed 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -177,8 +177,8 @@ fn write_usize(tcx: TyCtxt, buf: &mut [u8], idx: usize, num: u64) { let mut target = &mut buf[idx * usize_size..(idx + 1) * usize_size]; match tcx.data_layout.endian { - layout::Endian::Little => target.write_uint::(num, usize_size), - layout::Endian::Big => target.write_uint::(num, usize_size), + rustc_target::abi::Endian::Little => target.write_uint::(num, usize_size), + rustc_target::abi::Endian::Big => target.write_uint::(num, usize_size), } .unwrap() } From 7d28ab8ba2c9af56aa3f75524978c0863848ac0b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 Apr 2020 19:06:07 +0200 Subject: [PATCH 1242/1566] Remove the trans_const_place and TransPlaceInterpreter hack --- src/constant.rs | 184 ++++++++---------------------------------------- 1 file changed, 28 insertions(+), 156 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 2882ecd078649..eea2e3c1f00e1 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,18 +1,12 @@ -use std::borrow::Cow; - use rustc_span::DUMMY_SP; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::{ - read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, InterpResult, Scalar, + read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, Pointer, Scalar, }; use rustc_middle::ty::{Const, ConstKind}; use rustc_target::abi::Align; use rustc_data_structures::fx::FxHashSet; -use rustc_mir::interpret::{ - ImmTy, InterpCx, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, - StackPopCleanup, StackPopJump, -}; use cranelift_codegen::ir::GlobalValue; use cranelift_module::*; @@ -84,6 +78,7 @@ pub(crate) fn trans_const_value<'tcx>( ) -> CValue<'tcx> { let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); + assert!(!layout.is_unsized(), "sized const value"); if layout.is_zst() { return CValue::by_ref( @@ -99,7 +94,15 @@ pub(crate) fn trans_const_value<'tcx>( match const_val { ConstValue::Scalar(x) => { if fx.clif_type(layout.ty).is_none() { - return trans_const_place(fx, const_).to_cvalue(fx); + let (size, align) = (layout.size, layout.align.pref); + let mut alloc = Allocation::from_bytes( + std::iter::repeat(0).take(size.bytes_usize()).collect::>(), + align, + ); + let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used + alloc.write_scalar(fx, ptr, x.into(), size).unwrap(); + let alloc = fx.tcx.intern_const_alloc(alloc); + return CValue::by_ref(pointer_for_allocation(fx, alloc), layout); } match x { @@ -140,68 +143,35 @@ pub(crate) fn trans_const_value<'tcx>( } } ConstValue::ByRef { alloc, offset } => { - let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); - fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); - let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); - assert!(!layout.is_unsized(), "unsized ConstValue::ByRef not supported"); CValue::by_ref( - crate::pointer::Pointer::new(global_ptr) + pointer_for_allocation(fx, alloc) .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), layout, ) } - ConstValue::Slice { data: _, start: _, end: _ } => { - trans_const_place(fx, const_).to_cvalue(fx) + ConstValue::Slice { data, start, end } => { + let ptr = pointer_for_allocation(fx, data) + .offset_i64(fx, i64::try_from(start).unwrap()) + .get_addr(fx); + let len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(end.checked_sub(start).unwrap()).unwrap()); + CValue::by_val_pair(ptr, len, layout) } } } -fn trans_const_place<'tcx>( +fn pointer_for_allocation<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, -) -> CPlace<'tcx> { - // Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551 - let result = || -> InterpResult<'tcx, &'tcx Allocation> { - let mut ecx = InterpCx::new( - fx.tcx.at(DUMMY_SP), - ty::ParamEnv::reveal_all(), - TransPlaceInterpreter, - (), - ); - ecx.push_stack_frame( - fx.instance, - fx.mir, - None, - StackPopCleanup::None { cleanup: false }, - ) - .unwrap(); - let op = ecx.eval_operand( - &Operand::Constant(Box::new(Constant { - span: DUMMY_SP, - user_ty: None, - literal: const_, - })), - None, - )?; - let ptr = ecx.allocate(op.layout, MemoryKind::Stack); - ecx.copy_op(op, ptr.into())?; - let alloc = ecx - .memory - .get_raw(ptr.to_ref().to_scalar()?.assert_ptr().alloc_id)?; - Ok(fx.tcx.intern_const_alloc(alloc.clone())) - }; - let alloc = result().expect("unable to convert ConstKind to Allocation"); - - //println!("const value: {:?} allocation: {:?}", value, alloc); + alloc: &'tcx Allocation, +) -> crate::pointer::Pointer { let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); + 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!("{:?}", alloc_id)); - cplace_for_dataid(fx, fx.layout_of(const_.ty), local_data_id) + let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); + crate::pointer::Pointer::new(global_ptr) } fn data_id_for_alloc_id( @@ -286,13 +256,14 @@ fn cplace_for_dataid<'tcx>( } fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mut ConstantCx) { - let memory = Memory::::new(tcx.at(DUMMY_SP), ()); - while let Some(todo_item) = cx.todo.pop() { let (data_id, alloc) = match todo_item { TodoItem::Alloc(alloc_id) => { //println!("alloc_id {}", alloc_id); - let alloc = memory.get_raw(alloc_id).unwrap(); + let alloc = match tcx.alloc_map.lock().get(alloc_id).unwrap() { + GlobalAlloc::Memory(alloc) => alloc, + GlobalAlloc::Function(_) | GlobalAlloc::Static(_) => unreachable!(), + }; let data_id = data_id_for_alloc_id(module, alloc_id, alloc.align); (data_id, alloc) } @@ -388,105 +359,6 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu assert!(cx.todo.is_empty(), "{:?}", cx.todo); } -struct TransPlaceInterpreter; - -impl<'mir, 'tcx> Machine<'mir, 'tcx> for TransPlaceInterpreter { - type MemoryKind = !; - type ExtraFnVal = !; - type PointerTag = (); - type AllocExtra = (); - type MemoryExtra = (); - type FrameExtra = (); - type MemoryMap = FxHashMap, Allocation<()>)>; - - const CHECK_ALIGN: bool = true; - const GLOBAL_KIND: Option = None; - - fn enforce_validity(_: &InterpCx<'mir, 'tcx, Self>) -> bool { - false - } - - fn before_terminator(_: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { - panic!(); - } - - fn find_mir_or_eval_fn( - _: &mut InterpCx<'mir, 'tcx, Self>, - _: Instance<'tcx>, - _: &[OpTy<'tcx>], - _: Option<(PlaceTy<'tcx>, BasicBlock)>, - _: Option, - ) -> InterpResult<'tcx, Option<&'mir Body<'tcx>>> { - panic!(); - } - - fn call_intrinsic( - _: &mut InterpCx<'mir, 'tcx, Self>, - _: Instance<'tcx>, - _: &[OpTy<'tcx>], - _: Option<(PlaceTy<'tcx>, BasicBlock)>, - _: Option, - ) -> InterpResult<'tcx> { - panic!(); - } - - fn binary_ptr_op( - _: &InterpCx<'mir, 'tcx, Self>, - _: mir::BinOp, - _: ImmTy<'tcx>, - _: ImmTy<'tcx>, - ) -> InterpResult<'tcx, (Scalar, bool, Ty<'tcx>)> { - panic!(); - } - - fn ptr_to_int(_: &Memory<'mir, 'tcx, Self>, _: Pointer<()>) -> InterpResult<'tcx, u64> { - panic!(); - } - - fn box_alloc(_: &mut InterpCx<'mir, 'tcx, Self>, _: PlaceTy<'tcx>) -> InterpResult<'tcx> { - panic!(); - } - - fn init_allocation_extra<'b>( - _: &(), - _: AllocId, - alloc: Cow<'b, Allocation>, - _: Option>, - ) -> (Cow<'b, Allocation<(), ()>>, ()) { - (alloc, ()) - } - - fn tag_global_base_pointer(_: &(), _: AllocId) -> Self::PointerTag { - () - } - - fn call_extra_fn( - _: &mut InterpCx<'mir, 'tcx, Self>, - _: !, - _: &[OpTy<'tcx, ()>], - _: Option<(PlaceTy<'tcx, ()>, BasicBlock)>, - _: Option, - ) -> InterpResult<'tcx> { - unreachable!(); - } - - fn stack_push(_: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> { - Ok(()) - } - - fn stack_pop(_: &mut InterpCx<'mir, 'tcx, Self>, _: (), _: bool) -> InterpResult<'tcx, StackPopJump> { - Ok(StackPopJump::Normal) - } - - fn assert_panic( - _: &mut InterpCx<'mir, 'tcx, Self>, - _: &mir::AssertKind>, - _: Option, - ) -> InterpResult<'tcx> { - unreachable!() - } -} - pub(crate) fn mir_operand_get_const_val<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, operand: &Operand<'tcx>, From ca9a8a0441fd8391ec9ef703e023712769e517fe Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2020 05:28:25 +0000 Subject: [PATCH 1243/1566] Bump cranelift-codegen from `20e7185` to `9ca3bf5` Bumps [cranelift-codegen](https://github.com/bytecodealliance/wasmtime) from `20e7185` to `9ca3bf5`. - [Release notes](https://github.com/bytecodealliance/wasmtime/releases) - [Commits](https://github.com/bytecodealliance/wasmtime/compare/20e71858a1e5a71a4dbdc563c41e3367f06a04f6...9ca3bf532e2ee225b82ad81067e1cf80a8f212de) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec29f3288537a..904af1db63641 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,16 +44,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "byteorder", "cranelift-bforest", @@ -69,8 +69,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -78,18 +78,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" [[package]] name = "cranelift-entity" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" [[package]] name = "cranelift-frontend" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "cranelift-codegen", "log", @@ -99,8 +99,8 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "anyhow", "cranelift-codegen", @@ -111,8 +111,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -121,8 +121,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -132,8 +132,8 @@ dependencies = [ [[package]] name = "cranelift-simplejit" -version = "0.61.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#20e71858a1e5a71a4dbdc563c41e3367f06a04f6" +version = "0.62.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" dependencies = [ "cranelift-codegen", "cranelift-module", From 8de9fbb752022174bc7f4f4667dcc97014ea5687 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 6 Apr 2020 11:09:01 +0200 Subject: [PATCH 1244/1566] Bump libloading from 0.5.2 to 0.6.0 (#957) Bumps [libloading](https://github.com/nagisa/rust_libloading) from 0.5.2 to 0.6.0. - [Release notes](https://github.com/nagisa/rust_libloading/releases) - [Commits](https://github.com/nagisa/rust_libloading/compare/0.5.2...0.6.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> --- Cargo.lock | 5 ++--- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 904af1db63641..9d4099a293739 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,11 +208,10 @@ checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" [[package]] name = "libloading" -version = "0.5.2" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +checksum = "2c979a19ffb457f0273965c333053f3d586bf759bf7b683fbebc37f9a9ebedc4" dependencies = [ - "cc", "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index ab8410c49fd08..81c2a8d5c03aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ features = ["write"] # We don't need read support [target.'cfg(not(target_arch = "wasm32"))'.dependencies] cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/" } -libloading = "0.5.1" +libloading = "0.6.0" [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. From a3283962bc289326c2b908681f0a476c53f428b7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Apr 2020 12:32:00 +0200 Subject: [PATCH 1245/1566] Update the rustc usage section of the readme --- Readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 4ff92d705a8d8..5d86ae5e525b1 100644 --- a/Readme.md +++ b/Readme.md @@ -25,8 +25,10 @@ If you compiled cg_clif in debug mode you should use `CHANNEL="debug"` instead o ### Rustc +> You should prefer using the Cargo method. + ```bash -$ rustc -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs +$ rustc +$(cat $cg_clif_dir/rust-toolchain) -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs ``` ## Env vars From fd3be6d4920a2aef5db17f0e4abc90dcf1e14f2d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Apr 2020 12:44:10 +0200 Subject: [PATCH 1246/1566] Clarify debug mode vs release mode building in the readme --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 5d86ae5e525b1..ba56e57649868 100644 --- a/Readme.md +++ b/Readme.md @@ -21,7 +21,7 @@ $ ./test.sh --release $ CHANNEL="release" $cg_clif_dir/cargo.sh run ``` -If you compiled cg_clif in debug mode you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. +If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. ### Rustc From 291c75d10b734d7b118c7232157eefdc342c4144 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 5 Apr 2020 13:48:26 +0200 Subject: [PATCH 1247/1566] Enable the rust_2018_idioms and unused_lifetimes lints and fix all warnings They are set to deny by default in the rust-lang/rust repo --- src/abi/comments.rs | 4 ++-- src/abi/mod.rs | 12 ++++++++---- src/abi/returning.rs | 4 ++-- src/base.rs | 2 +- src/common.rs | 4 ++-- src/debuginfo/emit.rs | 2 +- src/debuginfo/mod.rs | 2 +- src/driver/aot.rs | 4 ++-- src/driver/jit.rs | 2 +- src/intrinsics/mod.rs | 2 +- src/lib.rs | 12 ++++++++---- src/linkage.rs | 4 ++-- src/main_shim.rs | 2 +- src/optimize/stack2reg.rs | 4 ++-- src/pretty_clif.rs | 6 +++--- src/value_and_place.rs | 12 ++++++------ src/vtable.rs | 2 +- 17 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index eae9ede3305c8..b030b5055b2da 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -5,7 +5,7 @@ use rustc_middle::mir; use crate::abi::pass_mode::*; use crate::prelude::*; -pub(super) fn add_args_header_comment(fx: &mut FunctionCx) { +pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.add_global_comment(format!( "kind loc.idx param pass mode ty" )); @@ -49,7 +49,7 @@ pub(super) fn add_arg_comment<'tcx>( )); } -pub(super) fn add_locals_header_comment(fx: &mut FunctionCx) { +pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.add_global_comment(String::new()); fx.add_global_comment(format!( "kind local ty size align (abi,pref)" diff --git a/src/abi/mod.rs b/src/abi/mod.rs index aa89a3d4e29ed..87a36113b8490 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -92,7 +92,7 @@ fn clif_sig_from_fn_sig<'tcx>( } abi => abi, }; - let (call_conv, inputs, output): (CallConv, Vec, Ty) = match abi { + let (call_conv, inputs, output): (CallConv, Vec>, Ty<'tcx>) = match abi { Abi::Rust => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), Abi::C => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), Abi::RustCall => { @@ -101,7 +101,7 @@ fn clif_sig_from_fn_sig<'tcx>( ty::Tuple(ref tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; - let mut inputs: Vec = vec![sig.inputs()[0]]; + let mut inputs: Vec> = vec![sig.inputs()[0]]; inputs.extend(extra_args.types()); (CallConv::triple_default(triple), inputs, sig.output()) } @@ -288,7 +288,11 @@ fn local_place<'tcx>( fx.local_map[&local] } -pub(crate) fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, start_block: Block, should_codegen_locals: bool) { +pub(crate) fn codegen_fn_prelude<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + start_block: Block, + should_codegen_locals: bool, +) { let ssa_analyzed = crate::analyze::analyze(fx); #[cfg(debug_assertions)] @@ -332,7 +336,7 @@ pub(crate) fn codegen_fn_prelude(fx: &mut FunctionCx<'_, '_, impl Backend>, star (local, ArgKind::Normal(param), arg_ty) } }) - .collect::>(); + .collect::, Ty<'tcx>)>>(); assert!(fx.caller_location.is_none()); if fx.instance.def.requires_caller_location(fx.tcx) { diff --git a/src/abi/returning.rs b/src/abi/returning.rs index d53abe32147d1..afe36d6890e66 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -14,7 +14,7 @@ pub(crate) fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyAndL } pub(super) fn codegen_return_param( - fx: &mut FunctionCx, + fx: &mut FunctionCx<'_, '_, impl Backend>, ssa_analyzed: &rustc_index::vec::IndexVec, start_block: Block, ) { @@ -101,7 +101,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( (call_inst, meta) } -pub(crate) fn codegen_return(fx: &mut FunctionCx) { +pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { match get_pass_mode(fx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { sized: true } => { fx.bcx.ins().return_(&[]); diff --git a/src/base.rs b/src/base.rs index b5f67c7ea01cd..fca20c0def74e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -209,7 +209,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( context.clear(); } -pub(crate) fn verify_func(tcx: TyCtxt, writer: &crate::pretty_clif::CommentWriter, func: &Function) { +pub(crate) fn verify_func(tcx: TyCtxt<'_>, writer: &crate::pretty_clif::CommentWriter, func: &Function) { tcx.sess.time("verify clif ir", || { let flags = settings::Flags::new(settings::builder()); match ::cranelift_codegen::verify_function(&func, &flags) { diff --git a/src/common.rs b/src/common.rs index a3e636dddfb9f..27e1b1cc3b032 100644 --- a/src/common.rs +++ b/src/common.rs @@ -10,7 +10,7 @@ pub(crate) fn mir_var(loc: Local) -> Variable { Variable::with_u32(loc.index() as u32) } -pub(crate) fn pointer_ty(tcx: TyCtxt) -> types::Type { +pub(crate) fn pointer_ty(tcx: TyCtxt<'_>) -> types::Type { match tcx.data_layout.pointer_size.bits() { 16 => types::I16, 32 => types::I32, @@ -19,7 +19,7 @@ pub(crate) fn pointer_ty(tcx: TyCtxt) -> types::Type { } } -pub(crate) fn scalar_to_clif_type(tcx: TyCtxt, scalar: Scalar) -> Type { +pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type { match scalar.value { Primitive::Int(int, _sign) => match int { Integer::I8 => types::I8, diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 16527353fbc4c..63b8557500393 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -61,7 +61,7 @@ struct WriterRelocate { } impl WriterRelocate { - fn new(ctx: &DebugContext) -> Self { + fn new(ctx: &DebugContext<'_>) -> Self { WriterRelocate { relocs: Vec::new(), writer: EndianVec::new(ctx.endian), diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 3c6c8469be8d1..cea9d3ed193a8 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -15,7 +15,7 @@ use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; pub(crate) use emit::{DebugReloc, DebugRelocName}; -fn target_endian(tcx: TyCtxt) -> RunTimeEndian { +fn target_endian(tcx: TyCtxt<'_>) -> RunTimeEndian { use rustc_target::abi::Endian; match tcx.data_layout.endian { diff --git a/src/driver/aot.rs b/src/driver/aot.rs index b4f0a03bbd52d..591e15803373c 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -31,7 +31,7 @@ fn emit_module( name: String, kind: ModuleKind, mut module: Module, - debug: Option, + debug: Option>, ) -> ModuleCodegenResult where B::Product: Emit + WriteDebugInfo, { @@ -72,7 +72,7 @@ fn emit_module( fn reuse_workproduct_for_cgu( tcx: TyCtxt<'_>, - cgu: &CodegenUnit, + cgu: &CodegenUnit<'_>, work_products: &mut FxHashMap, ) -> CompiledModule { let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index b4d16011cad7f..bf388a2769a05 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -128,7 +128,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> { } else { &name }; - let symbol: libloading::Symbol<*const u8> = + let symbol: libloading::Symbol<'_, *const u8> = unsafe { lib.get(dlsym_name.as_bytes()) }.unwrap(); Some((name, *symbol)) })); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 8c8e9aae5d043..43bed01feb756 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -691,7 +691,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; bswap, (v arg) { // FIXME(CraneStation/cranelift#794) add bswap instruction to cranelift - fn swap(bcx: &mut FunctionBuilder, v: Value) -> Value { + fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value { match bcx.func.dfg.value_type(v) { types::I8 => v, diff --git a/src/lib.rs b/src/lib.rs index 6a1839c3b1f39..bbd6842e262d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,13 +1,13 @@ #![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds, never_type)] #![allow(intra_doc_link_resolution_failure)] +#![warn(rust_2018_idioms)] +#![warn(unused_lifetimes)] extern crate flate2; extern crate libc; -extern crate tempfile; extern crate rustc_middle; extern crate rustc_codegen_ssa; extern crate rustc_data_structures; -extern crate rustc_driver; extern crate rustc_errors; extern crate rustc_fs_util; extern crate rustc_hir; @@ -20,6 +20,10 @@ extern crate rustc_symbol_mangling; extern crate rustc_target; extern crate rustc_ast; +// This prevents duplicating functions and statics that are already part of the host rustc process. +#[allow(unused_extern_crates)] +extern crate rustc_driver; + use std::any::Any; use rustc_errors::ErrorReported; @@ -166,7 +170,7 @@ impl CodegenBackend for CraneliftCodegenBackend { Box::new(crate::metadata::CraneliftMetadataLoader) } - fn provide(&self, providers: &mut Providers) { + fn provide(&self, providers: &mut Providers<'_>) { providers.target_features_whitelist = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); if tcx.sess.opts.actually_rustdoc { @@ -187,7 +191,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } }; } - fn provide_extern(&self, _providers: &mut Providers) {} + fn provide_extern(&self, _providers: &mut Providers<'_>) {} fn codegen_crate<'tcx>( &self, diff --git a/src/linkage.rs b/src/linkage.rs index 893ec851f1034..379c39ca63700 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -2,7 +2,7 @@ use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; use crate::prelude::*; -pub(crate) fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibility: Visibility) -> Linkage { +pub(crate) fn get_clif_linkage(mono_item: MonoItem<'_>, linkage: RLinkage, visibility: Visibility) -> Linkage { match (linkage, visibility) { (RLinkage::External, Visibility::Default) => Linkage::Export, (RLinkage::Internal, Visibility::Default) => Linkage::Local, @@ -11,7 +11,7 @@ pub(crate) fn get_clif_linkage(mono_item: MonoItem, linkage: RLinkage, visibilit } } -pub(crate) fn get_static_ref_linkage(tcx: TyCtxt, def_id: DefId) -> Linkage { +pub(crate) fn get_static_ref_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage { let fn_attrs = tcx.codegen_fn_attrs(def_id); if let Some(linkage) = fn_attrs.linkage { diff --git a/src/main_shim.rs b/src/main_shim.rs index f575d68cff2ad..ab2350e0a659f 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -65,7 +65,7 @@ pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.0) } } @@ -282,7 +282,7 @@ fn combine_stack_addr_with_load_store(func: &mut Function) { } } -fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext) { +fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // FIXME incrementally rebuild on each call? let mut stack_addr_load_insts_users = HashMap::>::new(); diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 911b215bf1378..4865950f6b05b 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -185,7 +185,7 @@ impl FuncWriter for &'_ CommentWriter { } #[cfg(debug_assertions)] -impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { +impl FunctionCx<'_, '_, B> { pub(crate) fn add_global_comment>(&mut self, comment: S) { self.clif_comments.add_global_comment(comment); } @@ -248,8 +248,8 @@ pub(crate) fn write_clif_file<'tcx>( } } -impl<'a, 'tcx, B: Backend + 'static> fmt::Debug for FunctionCx<'_, 'tcx, B> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl fmt::Debug for FunctionCx<'_, '_, B> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "{:?}", self.instance.substs)?; writeln!(f, "{:?}", self.local_map)?; diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 63ce64ab57dce..ca016e804b9b8 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -12,7 +12,7 @@ fn codegen_field<'tcx>( let field_offset = layout.fields.offset(field.index()); let field_layout = layout.field(&*fx, field.index()); - let simple = |fx: &mut FunctionCx<_>| { + let simple = |fx: &mut FunctionCx<'_, '_, _>| { ( base.offset_i64(fx, i64::try_from(field_offset.bytes()).unwrap()), field_layout, @@ -93,7 +93,7 @@ impl<'tcx> CValue<'tcx> { } // FIXME remove - pub(crate) fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option) { + pub(crate) fn force_stack(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option) { let layout = self.1; match self.0 { CValueInner::ByRef(ptr, meta) => (ptr, meta), @@ -113,7 +113,7 @@ impl<'tcx> CValue<'tcx> { } /// Load a value with layout.abi of scalar - pub(crate) fn load_scalar<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + pub(crate) fn load_scalar(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { let layout = self.1; match self.0 { CValueInner::ByRef(ptr, None) => { @@ -134,7 +134,7 @@ impl<'tcx> CValue<'tcx> { } /// Load a value pair with layout.abi of scalar pair - pub(crate) fn load_scalar_pair<'a>( + pub(crate) fn load_scalar_pair( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ) -> (Value, Value) { @@ -158,7 +158,7 @@ impl<'tcx> CValue<'tcx> { } } - pub(crate) fn value_field<'a>( + pub(crate) fn value_field( self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, @@ -187,7 +187,7 @@ impl<'tcx> CValue<'tcx> { } } - pub(crate) fn unsize_value<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + pub(crate) fn unsize_value(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { crate::unsize::coerce_unsized_into(fx, self, dest); } diff --git a/src/vtable.rs b/src/vtable.rs index d67cc6e865eed..8302047a44e12 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -166,7 +166,7 @@ fn build_vtable<'tcx>( data_id } -fn write_usize(tcx: TyCtxt, buf: &mut [u8], idx: usize, num: u64) { +fn write_usize(tcx: TyCtxt<'_>, buf: &mut [u8], idx: usize, num: u64) { use byteorder::{BigEndian, LittleEndian, WriteBytesExt}; let usize_size = tcx From 016673b0c3043d52900cedd4546e39e71c098205 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 5 Apr 2020 14:01:02 +0200 Subject: [PATCH 1248/1566] Fix rustc::internals lint warnings --- src/backend.rs | 6 +++--- src/base.rs | 2 +- src/common.rs | 4 ++-- src/debuginfo/emit.rs | 4 ++-- src/debuginfo/mod.rs | 11 ++++++----- src/lib.rs | 5 ++--- src/optimize/code_layout.rs | 2 +- src/optimize/stack2reg.rs | 14 ++++++++------ src/pretty_clif.rs | 5 ++--- src/value_and_place.rs | 14 +++++++------- 10 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index 3612ec63340e4..319183729d141 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,6 +1,6 @@ -use std::collections::HashMap; use std::convert::TryFrom; +use rustc_data_structures::fx::FxHashMap; use rustc_session::Session; use cranelift_module::{FuncId, Module}; @@ -44,7 +44,7 @@ pub(crate) trait WriteDebugInfo { fn add_debug_section(&mut self, name: SectionId, data: Vec) -> Self::SectionId; fn add_debug_reloc( &mut self, - section_map: &HashMap, + section_map: &FxHashMap, symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, @@ -74,7 +74,7 @@ impl WriteDebugInfo for ObjectProduct { fn add_debug_reloc( &mut self, - section_map: &HashMap, + section_map: &FxHashMap, symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, diff --git a/src/base.rs b/src/base.rs index fca20c0def74e..4b19895c45021 100644 --- a/src/base.rs +++ b/src/base.rs @@ -47,7 +47,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( bcx, block_map, - local_map: HashMap::new(), + local_map: FxHashMap::default(), caller_location: None, // set by `codegen_fn_prelude` cold_blocks: EntitySet::new(), diff --git a/src/common.rs b/src/common.rs index 27e1b1cc3b032..ed368bf96ecc4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -265,7 +265,7 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) bcx: FunctionBuilder<'clif>, pub(crate) block_map: IndexVec, - pub(crate) local_map: HashMap>, + pub(crate) local_map: FxHashMap>, /// When `#[track_caller]` is used, the implicit caller location is stored in this variable. pub(crate) caller_location: Option>, @@ -275,7 +275,7 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) clif_comments: crate::pretty_clif::CommentWriter, pub(crate) constants_cx: &'clif mut crate::constant::ConstantCx, - pub(crate) vtables: &'clif mut HashMap<(Ty<'tcx>, Option>), DataId>, + pub(crate) vtables: &'clif mut FxHashMap<(Ty<'tcx>, Option>), DataId>, pub(crate) source_info_set: indexmap::IndexSet, } diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 63b8557500393..0c24fe359df51 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use rustc_data_structures::fx::FxHashMap; use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer}; use gimli::{RunTimeEndian, SectionId}; @@ -20,7 +20,7 @@ impl DebugContext<'_> { let mut sections = Sections::new(WriterRelocate::new(self)); self.dwarf.write(&mut sections).unwrap(); - let mut section_map = HashMap::new(); + let mut section_map = FxHashMap::default(); let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { let section_id = product.add_debug_section(id, section.writer.take()); diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index cea9d3ed193a8..62898f075e2ba 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -33,7 +33,7 @@ pub(crate) struct DebugContext<'tcx> { dwarf: DwarfUnit, unit_range_list: RangeList, - types: HashMap, UnitEntryId>, + types: FxHashMap, UnitEntryId>, } impl<'tcx> DebugContext<'tcx> { @@ -97,7 +97,7 @@ impl<'tcx> DebugContext<'tcx> { dwarf, unit_range_list: RangeList(Vec::new()), - types: HashMap::new(), + types: FxHashMap::default(), } } @@ -255,7 +255,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { context: &Context, isa: &dyn TargetIsa, source_info_set: &indexmap::IndexSet, - local_map: HashMap>, + local_map: FxHashMap>, ) { let end = self.create_debug_lines(context, isa, source_info_set); @@ -302,8 +302,9 @@ fn place_location<'a, 'tcx>( func_debug_ctx: &mut FunctionDebugContext<'a, 'tcx>, isa: &dyn TargetIsa, context: &Context, - local_map: &HashMap>, - value_labels_ranges: &HashMap>, + local_map: &FxHashMap>, + #[allow(rustc::default_hash_types)] + value_labels_ranges: &std::collections::HashMap>, place: Place<'tcx>, ) -> AttributeValue { assert!(place.projection.is_empty()); // FIXME implement them diff --git a/src/lib.rs b/src/lib.rs index bbd6842e262d7..e7a637211d409 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,7 +67,6 @@ mod value_and_place; mod vtable; mod prelude { - pub(crate) use std::collections::HashMap; pub(crate) use std::convert::{TryFrom, TryInto}; pub(crate) use rustc_ast::ast::{FloatTy, IntTy, UintTy}; @@ -132,7 +131,7 @@ pub(crate) struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { module: &'clif mut Module, constants_cx: ConstantCx, cached_context: Context, - vtables: HashMap<(Ty<'tcx>, Option>), DataId>, + vtables: FxHashMap<(Ty<'tcx>, Option>), DataId>, debug_context: Option<&'clif mut DebugContext<'tcx>>, } @@ -147,7 +146,7 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { module, constants_cx: ConstantCx::default(), cached_context: Context::new(), - vtables: HashMap::new(), + vtables: FxHashMap::default(), debug_context, } } diff --git a/src/optimize/code_layout.rs b/src/optimize/code_layout.rs index 7e910fe08beb2..ca9ff15ec10ff 100644 --- a/src/optimize/code_layout.rs +++ b/src/optimize/code_layout.rs @@ -14,7 +14,7 @@ pub(super) fn optimize_function(ctx: &mut Context, cold_blocks: &EntitySet>(); for &inst in &insts { diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 7673c085cee3e..d6a9d6228c42a 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -9,10 +9,12 @@ //! `stack_store` instruction incorrectly, or incorrectly use a previously stored value as the value //! being loaded by a `stack_load`. -use std::collections::{BTreeMap, HashSet}; +use std::collections::BTreeMap; use std::fmt; use std::ops::Not; +use rustc_data_structures::fx::FxHashSet; + use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; @@ -43,9 +45,9 @@ impl Ord for OrdStackSlot { #[derive(Debug, Default)] struct StackSlotUsage { - stack_addr: HashSet, - stack_load: HashSet, - stack_store: HashSet, + stack_addr: FxHashSet, + stack_load: FxHashSet, + stack_store: FxHashSet, } impl StackSlotUsage { @@ -284,7 +286,7 @@ fn combine_stack_addr_with_load_store(func: &mut Function) { fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // FIXME incrementally rebuild on each call? - let mut stack_addr_load_insts_users = HashMap::>::new(); + let mut stack_addr_load_insts_users = FxHashMap::>::default(); let mut cursor = FuncCursor::new(&mut opt_ctx.ctx.func); while let Some(_block) = cursor.next_block() { @@ -293,7 +295,7 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { match cursor.func.dfg[arg_origin].opcode() { Opcode::StackAddr | Opcode::StackLoad => { - stack_addr_load_insts_users.entry(arg_origin).or_insert_with(HashSet::new).insert(inst); + stack_addr_load_insts_users.entry(arg_origin).or_insert_with(FxHashSet::default).insert(inst); } _ => {} } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 4865950f6b05b..c3b8bee956c05 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::fmt; use cranelift_codegen::{ @@ -66,7 +65,7 @@ use crate::prelude::*; #[derive(Debug)] pub(crate) struct CommentWriter { global_comments: Vec, - entity_comments: HashMap, + entity_comments: FxHashMap, } impl CommentWriter { @@ -90,7 +89,7 @@ impl CommentWriter { CommentWriter { global_comments, - entity_comments: HashMap::new(), + entity_comments: FxHashMap::default(), } } } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index ca016e804b9b8..272c38b7b9747 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -202,14 +202,14 @@ impl<'tcx> CValue<'tcx> { let clif_ty = fx.clif_type(layout.ty).unwrap(); match layout.ty.kind { - ty::TyKind::Bool => { + ty::Bool => { assert!(const_val == 0 || const_val == 1, "Invalid bool 0x{:032X}", const_val); } _ => {} } let val = match layout.ty.kind { - ty::TyKind::Uint(UintTy::U128) | ty::TyKind::Int(IntTy::I128) => { + ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => { let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64); let msb = fx .bcx @@ -217,21 +217,21 @@ impl<'tcx> CValue<'tcx> { .iconst(types::I64, (const_val >> 64) as u64 as i64); fx.bcx.ins().iconcat(lsb, msb) } - ty::TyKind::Bool | ty::TyKind::Char | ty::TyKind::Uint(_) | ty::TyKind::Ref(..) - | ty::TyKind::RawPtr(..) => { + ty::Bool | ty::Char | ty::Uint(_) | ty::Ref(..) + | ty::RawPtr(..) => { fx .bcx .ins() .iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64) } - ty::TyKind::Int(_) => { + ty::Int(_) => { let const_val = rustc_middle::mir::interpret::sign_extend(const_val, layout.size); fx.bcx.ins().iconst(clif_ty, i64::try_from(const_val as i128).unwrap()) } - ty::TyKind::Float(FloatTy::F32) => { + ty::Float(FloatTy::F32) => { fx.bcx.ins().f32const(Ieee32::with_bits(u32::try_from(const_val).unwrap())) } - ty::TyKind::Float(FloatTy::F64) => { + ty::Float(FloatTy::F64) => { fx.bcx.ins().f64const(Ieee64::with_bits(u64::try_from(const_val).unwrap())) } _ => panic!( From 9cf1bcea5c9bcb697a2988dcd2d575be68a8062f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Apr 2020 13:22:40 +0200 Subject: [PATCH 1249/1566] Rustup to rustc 1.44.0-nightly (485c5fb6e 2020-04-08) --- patches/0023-core-Ignore-failing-tests.patch | 4 ++-- rust-toolchain | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index f5473834f0b45..b6b1e93bb6bf3 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -28,16 +28,16 @@ index c9096b7..be37fcd 100644 #[test] +#[ignore] fn test_range_size_hint() { - use core::usize::MAX as UMAX; assert_eq!((0..0usize).size_hint(), (0, Some(0))); + assert_eq!((0..100usize).size_hint(), (100, Some(100))); @@ -2210,6 +2212,7 @@ fn test_range_size_hint() { } #[test] +#[ignore] fn test_range_inclusive_size_hint() { - use core::usize::MAX as UMAX; assert_eq!((1..=0usize).size_hint(), (0, Some(0))); + assert_eq!((0..=0usize).size_hint(), (1, Some(1))); @@ -2305,6 +2308,7 @@ fn test_repeat_with_take_collect() { } diff --git a/rust-toolchain b/rust-toolchain index 6eacfad019a0a..64862e81715aa 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-03 +nightly-2020-04-09 From dfb5d16fb33948746d5d0c83eecb3acb5c49a49b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 29 Mar 2020 12:03:30 +0200 Subject: [PATCH 1250/1566] Use bitcast to transmute where possible --- src/intrinsics/mod.rs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 43bed01feb756..d5315ac3b8add 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -631,12 +631,29 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, CValue::by_val(res, base.layout())); }; - transmute, (c from) { - assert_eq!(from.layout().ty, src_ty); - let (addr, meta) = from.force_stack(fx); - assert!(meta.is_none()); - let dst_layout = fx.layout_of(dst_ty); - ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout)) + transmute, (c from) { + assert_eq!(from.layout().size, ret.layout().size); + if from.layout().ty.kind == ret.layout().ty.kind { + ret.write_cvalue(fx, from); + } else if let (Some(src_ty), Some(dst_ty)) = (fx.clif_type(from.layout().ty), fx.clif_type(ret.layout().ty)) { + let from = from.load_scalar(fx); + let val = match (src_ty, dst_ty) { + (_, _) if src_ty == dst_ty => from, + (types::I32, types::F32) | (types::F32, types::I32) + | (types::I64, types::F64) | (types::F64, types::I64) => { + fx.bcx.ins().bitcast(dst_ty, from) + } + (_, _) if src_ty.is_vector() && dst_ty.is_vector() => { + fx.bcx.ins().raw_bitcast(dst_ty, from) + } + _ => unreachable!("{:?} -> {:?}", src_ty, dst_ty), + }; + ret.write_cvalue(fx, CValue::by_val(val, ret.layout())); + } else { + let (addr, meta) = from.force_stack(fx); + assert!(meta.is_none()); + ret.write_cvalue(fx, CValue::by_ref(addr, ret.layout())); + } }; write_bytes, (c dst, v val, v count) { let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty; From 53307fd2e1fbf184aa3af44194a0f3b1bffea9a5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Mar 2020 17:42:23 +0100 Subject: [PATCH 1251/1566] Introduce PointerBase::Dangling --- src/abi/comments.rs | 3 +++ src/pointer.rs | 23 +++++++++++++++++++++++ src/value_and_place.rs | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index b030b5055b2da..d949bf7f57db0 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -90,6 +90,9 @@ pub(super) fn add_local_place_comments<'tcx>( (crate::pointer::PointerBase::Stack(stack_slot), offset) => { ("stack", format!("storage={}{}{}", stack_slot, offset, meta).into()) } + (crate::pointer::PointerBase::Dangling(align), offset) => { + ("zst", format!("align={},offset={}", align.bytes(), offset).into()) + } } } }; diff --git a/src/pointer.rs b/src/pointer.rs index 854a7cd44018f..a338e2b0197e8 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -1,5 +1,7 @@ use crate::prelude::*; +use rustc_target::abi::Align; + use cranelift_codegen::ir::immediates::Offset32; #[derive(Copy, Clone, Debug)] @@ -12,6 +14,7 @@ pub(crate) struct Pointer { pub(crate) enum PointerBase { Addr(Value), Stack(StackSlot), + Dangling(Align), } impl Pointer { @@ -37,6 +40,13 @@ impl Pointer { } } + pub(crate) fn dangling(align: Align) -> Self { + Pointer { + base: PointerBase::Dangling(align), + offset: Offset32::new(0), + } + } + #[cfg(debug_assertions)] pub(crate) fn base_and_offset(self) -> (PointerBase, Offset32) { (self.base, self.offset) @@ -53,6 +63,9 @@ impl Pointer { } } PointerBase::Stack(stack_slot) => fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, self.offset), + PointerBase::Dangling(align) => { + fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()) + } } } @@ -80,6 +93,7 @@ impl Pointer { let base_addr = match self.base { PointerBase::Addr(addr) => addr, PointerBase::Stack(stack_slot) => fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), + PointerBase::Dangling(align) => fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()), }; let addr = fx.bcx.ins().iadd_imm(base_addr, new_offset); Pointer { @@ -109,6 +123,13 @@ impl Pointer { offset: Offset32::new(0), } } + PointerBase::Dangling(align) => { + let addr = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()); + Pointer { + base: PointerBase::Addr(fx.bcx.ins().iadd(addr, extra_offset)), + offset: self.offset, + } + } } } @@ -127,6 +148,7 @@ impl Pointer { } else { fx.bcx.ins().stack_load(ty, stack_slot, self.offset) } + PointerBase::Dangling(_align) => unreachable!(), } } @@ -150,6 +172,7 @@ impl Pointer { fx.bcx.ins().stack_store(value, stack_slot, self.offset); } } + PointerBase::Dangling(_align) => unreachable!(), } } } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 272c38b7b9747..6d164e70f0e9f 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -344,7 +344,7 @@ impl<'tcx> CPlace<'tcx> { } } CPlaceInner::NoPlace => CValue::by_ref( - Pointer::const_addr(fx, i64::try_from(self.layout.align.pref.bytes()).unwrap()), + Pointer::dangling(self.layout.align.pref), layout, ), } From 3ef617014259d26502fa430ad96be4bd50625741 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 29 Mar 2020 11:51:43 +0200 Subject: [PATCH 1252/1566] Remove CPlace::NoPlace --- src/abi/comments.rs | 1 - src/abi/mod.rs | 2 +- src/abi/returning.rs | 2 +- src/base.rs | 6 ++--- src/debuginfo/mod.rs | 1 - src/value_and_place.rs | 56 ++++++++++++------------------------------ 6 files changed, 21 insertions(+), 47 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index d949bf7f57db0..4405f98addff6 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -76,7 +76,6 @@ pub(super) fn add_local_place_comments<'tcx>( assert_eq!(local, var); ("ssa", std::borrow::Cow::Borrowed("")) } - CPlaceInner::NoPlace => ("zst", "".into()), CPlaceInner::Addr(ptr, meta) => { let meta = if let Some(meta) = meta { Cow::Owned(format!(",meta={}", meta)) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 87a36113b8490..582021cb083d4 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -657,7 +657,7 @@ pub(crate) fn codegen_drop<'tcx>( let drop_fn_ty = drop_fn.monomorphic_ty(fx.tcx); match ty.kind { ty::Dynamic(..) => { - let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(fx); + let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(); let ptr = ptr.get_addr(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); diff --git a/src/abi/returning.rs b/src/abi/returning.rs index afe36d6890e66..449c77c3c09b5 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -70,7 +70,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef { sized: true } => match ret_place { - Some(ret_place) => Some(ret_place.to_ptr(fx).get_addr(fx)), + Some(ret_place) => Some(ret_place.to_ptr().get_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), }, PassMode::ByRef { sized: false } => todo!(), diff --git a/src/base.rs b/src/base.rs index 4b19895c45021..414f6c30ce5ca 100644 --- a/src/base.rs +++ b/src/base.rs @@ -730,7 +730,7 @@ fn codegen_array_len<'tcx>( fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place - .to_ptr_maybe_unsized(fx) + .to_ptr_maybe_unsized() .1 .expect("Length metadata for slice place"), _ => bug!("Rvalue::Len({:?})", place), @@ -776,7 +776,7 @@ pub(crate) fn trans_place<'tcx>( ty::Array(elem_ty, _len) => { assert!(!from_end, "array subslices are never `from_end`"); let elem_layout = fx.layout_of(elem_ty); - let ptr = cplace.to_ptr(fx); + let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), fx.layout_of(fx.tcx.mk_array(elem_ty, to as u64 - from as u64)), @@ -785,7 +785,7 @@ pub(crate) fn trans_place<'tcx>( ty::Slice(elem_ty) => { assert!(from_end, "slice subslices should be `from_end`"); let elem_layout = fx.layout_of(elem_ty); - let (ptr, len) = cplace.to_ptr_maybe_unsized(fx); + let (ptr, len) = cplace.to_ptr_maybe_unsized(); let len = len.unwrap(); cplace = CPlace::for_ptr_with_extra( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 62898f075e2ba..51da712b55d1c 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -348,7 +348,6 @@ fn place_location<'a, 'tcx>( // For PointerBase::Stack: //AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())) } - CPlaceInner::NoPlace => AttributeValue::Exprloc(Expression(vec![])), } } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 6d164e70f0e9f..619b7199b538d 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -100,7 +100,7 @@ impl<'tcx> CValue<'tcx> { CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => { let cplace = CPlace::new_stack_slot(fx, layout); cplace.write_cvalue(fx, self); - (cplace.to_ptr(fx), None) + (cplace.to_ptr(), None) } } } @@ -259,7 +259,6 @@ pub(crate) struct CPlace<'tcx> { pub(crate) enum CPlaceInner { Var(Local), Addr(Pointer, Option), - NoPlace, } impl<'tcx> CPlace<'tcx> { @@ -273,7 +272,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn no_place(layout: TyAndLayout<'tcx>) -> CPlace<'tcx> { CPlace { - inner: CPlaceInner::NoPlace, + inner: CPlaceInner::Addr(Pointer::dangling(layout.align.pref), None), layout, } } @@ -284,10 +283,7 @@ impl<'tcx> CPlace<'tcx> { ) -> CPlace<'tcx> { assert!(!layout.is_unsized()); if layout.size.bytes() == 0 { - return CPlace { - inner: CPlaceInner::NoPlace, - layout, - }; + return CPlace::no_place(layout); } let stack_slot = fx.bcx.create_stack_slot(StackSlotData { @@ -343,33 +339,20 @@ impl<'tcx> CPlace<'tcx> { CValue::by_ref(ptr, layout) } } - CPlaceInner::NoPlace => CValue::by_ref( - Pointer::dangling(self.layout.align.pref), - layout, - ), } } - pub(crate) fn to_ptr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer { - match self.to_ptr_maybe_unsized(fx) { + pub(crate) fn to_ptr(self) -> Pointer { + match self.to_ptr_maybe_unsized() { (ptr, None) => ptr, (_, Some(_)) => bug!("Expected sized cplace, found {:?}", self), } } - pub(crate) fn to_ptr_maybe_unsized( - self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - ) -> (Pointer, Option) { + pub(crate) fn to_ptr_maybe_unsized(self) -> (Pointer, Option) { match self.inner { CPlaceInner::Addr(ptr, extra) => (ptr, extra), - CPlaceInner::NoPlace => { - ( - Pointer::const_addr(fx, i64::try_from(self.layout.align.pref.bytes()).unwrap()), - None, - ) - } - CPlaceInner::Var(_) => bug!("Expected CPlace::Addr, found CPlace::Var"), + CPlaceInner::Var(_) => bug!("Expected CPlace::Addr, found {:?}", self), } } @@ -460,12 +443,11 @@ impl<'tcx> CPlace<'tcx> { fx.bcx.def_var(mir_var(var), data); return; } - CPlaceInner::Addr(ptr, None) => ptr, - CPlaceInner::NoPlace => { - if dst_layout.abi != Abi::Uninhabited { - assert_eq!(dst_layout.size.bytes(), 0, "{:?}", dst_layout); + CPlaceInner::Addr(ptr, None) => { + if dst_layout.size == Size::ZERO || dst_layout.abi == Abi::Uninhabited { + return; } - return; + ptr } CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self), }; @@ -524,7 +506,7 @@ impl<'tcx> CPlace<'tcx> { field: mir::Field, ) -> CPlace<'tcx> { let layout = self.layout(); - let (base, extra) = self.to_ptr_maybe_unsized(fx); + let (base, extra) = self.to_ptr_maybe_unsized(); let (field_ptr, field_layout) = codegen_field(fx, base, extra, layout, field); if field_layout.is_unsized() { @@ -540,8 +522,8 @@ impl<'tcx> CPlace<'tcx> { index: Value, ) -> CPlace<'tcx> { let (elem_layout, ptr) = match self.layout().ty.kind { - ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_ptr(fx)), - ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_ptr_maybe_unsized(fx).0), + ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_ptr()), + ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_ptr_maybe_unsized().0), _ => bug!("place_index({:?})", self.layout().ty), }; @@ -565,7 +547,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { if has_ptr_meta(fx.tcx, self.layout().ty) { - let (ptr, extra) = self.to_ptr_maybe_unsized(fx); + let (ptr, extra) = self.to_ptr_maybe_unsized(); let ptr = CValue::by_val_pair( ptr.get_addr(fx), extra.expect("unsized type without metadata"), @@ -573,19 +555,13 @@ impl<'tcx> CPlace<'tcx> { ); dest.write_cvalue(fx, ptr); } else { - let ptr = CValue::by_val(self.to_ptr(fx).get_addr(fx), dest.layout()); + let ptr = CValue::by_val(self.to_ptr().get_addr(fx), dest.layout()); dest.write_cvalue(fx, ptr); } } pub(crate) fn unchecked_cast_to(self, layout: TyAndLayout<'tcx>) -> Self { assert!(!self.layout().is_unsized()); - match self.inner { - CPlaceInner::NoPlace => { - assert!(layout.size.bytes() == 0); - } - _ => {} - } CPlace { inner: self.inner, layout, From ea1a99900e3bbd1a4078634710a78fe4ad4da861 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 29 Mar 2020 11:52:30 +0200 Subject: [PATCH 1253/1566] Remove unchecked_cast_to --- src/base.rs | 4 ++-- src/value_and_place.rs | 19 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/base.rs b/src/base.rs index 414f6c30ce5ca..1d7605847891e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -485,7 +485,7 @@ fn trans_stmt<'tcx>( | Rvalue::Cast(CastKind::Pointer(PointerCast::ArrayToPointer), operand, to_ty) => { let to_layout = fx.layout_of(fx.monomorphize(to_ty)); let operand = trans_operand(fx, operand); - lval.write_cvalue(fx, operand.unchecked_cast_to(to_layout)); + lval.write_cvalue(fx, operand.cast_pointer_to(to_layout)); } Rvalue::Cast(CastKind::Misc, operand, to_ty) => { let operand = trans_operand(fx, operand); @@ -509,7 +509,7 @@ fn trans_stmt<'tcx>( if is_fat_ptr(fx, from_ty) { if is_fat_ptr(fx, to_ty) { // fat-ptr -> fat-ptr - lval.write_cvalue(fx, operand.unchecked_cast_to(dest_layout)); + lval.write_cvalue(fx, operand.cast_pointer_to(dest_layout)); } else { // fat-ptr -> thin-ptr let (ptr, _extra) = operand.load_scalar_pair(fx); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 619b7199b538d..ae89af880e557 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -243,7 +243,10 @@ impl<'tcx> CValue<'tcx> { CValue::by_val(val, layout) } - pub(crate) fn unchecked_cast_to(self, layout: TyAndLayout<'tcx>) -> Self { + pub(crate) fn cast_pointer_to(self, layout: TyAndLayout<'tcx>) -> Self { + assert!(matches!(self.layout().ty.kind, ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..))); + assert!(matches!(layout.ty.kind, ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..))); + assert_eq!(self.layout().abi, layout.abi); CValue(self.0, layout) } } @@ -560,20 +563,16 @@ impl<'tcx> CPlace<'tcx> { } } - pub(crate) fn unchecked_cast_to(self, layout: TyAndLayout<'tcx>) -> Self { - assert!(!self.layout().is_unsized()); - CPlace { - inner: self.inner, - layout, - } - } - pub(crate) fn downcast_variant( self, fx: &FunctionCx<'_, 'tcx, impl Backend>, variant: VariantIdx, ) -> Self { + assert!(!self.layout().is_unsized()); let layout = self.layout().for_variant(fx, variant); - self.unchecked_cast_to(layout) + CPlace { + inner: self.inner, + layout, + } } } From b6bbc0f751cf0a10612852b589f437ced458702d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 30 Mar 2020 18:44:14 +0200 Subject: [PATCH 1254/1566] Codegen goto return block as return terminator --- src/base.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/base.rs b/src/base.rs index 1d7605847891e..b76aedbb810ca 100644 --- a/src/base.rs +++ b/src/base.rs @@ -169,6 +169,12 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( crate::optimize::optimize_function(tcx, instance, context, &cold_blocks, &mut clif_comments); }); + // If the return block is not reachable, then the SSA builder may have inserted a `iconst.i128` + // instruction, which doesn't have an encoding. + context.compute_cfg(); + context.compute_domtree(); + context.eliminate_unreachable_code(cx.module.isa()).unwrap(); + // Define function let module = &mut cx.module; tcx.sess.time( @@ -265,6 +271,23 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { match &bb_data.terminator().kind { TerminatorKind::Goto { target } => { + if let TerminatorKind::Return = fx.mir[*target].terminator().kind { + let mut can_immediately_return = true; + for stmt in &fx.mir[*target].statements { + if let StatementKind::StorageDead(_) = stmt.kind { + } else { + // FIXME Can sometimes happen, see rust-lang/rust#70531 + can_immediately_return = false; + break; + } + } + + if can_immediately_return { + crate::abi::codegen_return(fx); + continue; + } + } + let block = fx.get_block(*target); fx.bcx.ins().jump(block, &[]); } From bbc0cd66b421a6196e90afbf7e386427ebf67fa2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 12:52:53 +0200 Subject: [PATCH 1255/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- src/debuginfo/mod.rs | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d4099a293739..7766088ee8f3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" [[package]] name = "cranelift-entity" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" [[package]] name = "cranelift-frontend" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,7 +133,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#9ca3bf532e2ee225b82ad81067e1cf80a8f212de" +source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" dependencies = [ "cranelift-codegen", "cranelift-module", diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 51da712b55d1c..b6eebbf482c2d 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -355,9 +355,9 @@ fn place_location<'a, 'tcx>( fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option> { match loc { ValueLoc::Reg(reg) => { - let machine_reg = cranelift_codegen::isa::fde::map_reg(isa, reg).unwrap().0 as u8; + let machine_reg = isa.map_dwarf_register(reg).unwrap(); assert!(machine_reg <= 32); // FIXME - Some(vec![gimli::constants::DW_OP_reg0.0 + machine_reg]) + Some(vec![gimli::constants::DW_OP_reg0.0 + machine_reg as u8]) } ValueLoc::Stack(ss) => { if let Some(ss_offset) = stack_slots[ss].offset { From 287e70f1b49cc2c22d997dcb4e892c001cfc50e5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 13:00:44 +0200 Subject: [PATCH 1256/1566] Update dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7766088ee8f3b..52a6c6912e657 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -330,9 +330,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "smallvec" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +checksum = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a" [[package]] name = "syn" @@ -353,18 +353,18 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "thiserror" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0570dc61221295909abdb95c739f2e74325e14293b2026b0a7e195091ec54ae" +checksum = "54b3d3d2ff68104100ab257bb6bb0cb26c901abe4bd4ba15961f3bf867924012" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227362df41d566be41a28f64401e07a043157c21c14b9785a0d8e256f940a8fd" +checksum = "ca972988113b7715266f91250ddb98070d033c62a011fa0fcc57434a649310dd" dependencies = [ "proc-macro2", "quote", From 8daca65e47e9b93e75511e30cab53249d680990e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 13:30:39 +0200 Subject: [PATCH 1257/1566] Rustup to rustc 1.44.0-nightly (3712e11a8 2020-04-12) --- rust-toolchain | 2 +- src/abi/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 64862e81715aa..ab0c7c21a139d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-09 +nightly-2020-04-13 diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 582021cb083d4..0f08203d8e6a2 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -169,7 +169,7 @@ pub(crate) fn get_function_name_and_sig<'tcx>( inst: Instance<'tcx>, support_vararg: bool, ) -> (String, Signature) { - assert!(!inst.substs.needs_infer() && !inst.substs.has_param_types()); + assert!(!inst.substs.needs_infer()); let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_sig_for_fn_abi(tcx, inst)); if fn_sig.c_variadic && !support_vararg { From 40cdcf0e5eb9cd09c26d26e51e3fb784c4bb7411 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 14:53:25 +0200 Subject: [PATCH 1258/1566] Remove one usage of force_stack --- src/intrinsics/mod.rs | 23 +-------------- src/value_and_place.rs | 66 +++++++++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 39 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index d5315ac3b8add..12edbfdbe3fcb 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -632,28 +632,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; transmute, (c from) { - assert_eq!(from.layout().size, ret.layout().size); - if from.layout().ty.kind == ret.layout().ty.kind { - ret.write_cvalue(fx, from); - } else if let (Some(src_ty), Some(dst_ty)) = (fx.clif_type(from.layout().ty), fx.clif_type(ret.layout().ty)) { - let from = from.load_scalar(fx); - let val = match (src_ty, dst_ty) { - (_, _) if src_ty == dst_ty => from, - (types::I32, types::F32) | (types::F32, types::I32) - | (types::I64, types::F64) | (types::F64, types::I64) => { - fx.bcx.ins().bitcast(dst_ty, from) - } - (_, _) if src_ty.is_vector() && dst_ty.is_vector() => { - fx.bcx.ins().raw_bitcast(dst_ty, from) - } - _ => unreachable!("{:?} -> {:?}", src_ty, dst_ty), - }; - ret.write_cvalue(fx, CValue::by_val(val, ret.layout())); - } else { - let (addr, meta) = from.force_stack(fx); - assert!(meta.is_none()); - ret.write_cvalue(fx, CValue::by_ref(addr, ret.layout())); - } + ret.write_cvalue_transmute(fx, from); }; write_bytes, (c dst, v val, v count) { let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty; diff --git a/src/value_and_place.rs b/src/value_and_place.rs index ae89af880e557..5a0e2ee268be9 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -360,22 +360,6 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { - #[cfg(debug_assertions)] - { - use cranelift_codegen::cursor::{Cursor, CursorPosition}; - let cur_block = match fx.bcx.cursor().position() { - CursorPosition::After(block) => block, - _ => unreachable!(), - }; - fx.add_comment( - fx.bcx.func.layout.last_inst(cur_block).unwrap(), - format!("write_cvalue: {:?}: {:?} <- {:?}: {:?}", self.inner(), self.layout().ty, from.0, from.layout().ty), - ); - } - - let from_ty = from.layout().ty; - let to_ty = self.layout().ty; - fn assert_assignable<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, from_ty: Ty<'tcx>, @@ -436,12 +420,60 @@ impl<'tcx> CPlace<'tcx> { } } - assert_assignable(fx, from_ty, to_ty); + assert_assignable(fx, from.layout().ty, self.layout().ty); + + self.write_cvalue_maybe_transmute(fx, from, "write_cvalue"); + } + + pub(crate) fn write_cvalue_transmute( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + from: CValue<'tcx>, + ) { + self.write_cvalue_maybe_transmute(fx, from, "write_cvalue_transmute"); + } + + fn write_cvalue_maybe_transmute( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + from: CValue<'tcx>, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] + method: &'static str, + ) { + assert_eq!(self.layout().size, from.layout().size); + + #[cfg(debug_assertions)] + { + use cranelift_codegen::cursor::{Cursor, CursorPosition}; + let cur_block = match fx.bcx.cursor().position() { + CursorPosition::After(block) => block, + _ => unreachable!(), + }; + fx.add_comment( + fx.bcx.func.layout.last_inst(cur_block).unwrap(), + format!("{}: {:?}: {:?} <- {:?}: {:?}", method, self.inner(), self.layout().ty, from.0, from.layout().ty), + ); + } let dst_layout = self.layout(); let to_ptr = match self.inner { CPlaceInner::Var(var) => { let data = from.load_scalar(fx); + let src_ty = fx.bcx.func.dfg.value_type(data); + let dst_ty = fx.clif_type(self.layout().ty).unwrap(); + let data = match (src_ty, dst_ty) { + (_, _) if src_ty == dst_ty => data, + + // This is a `write_cvalue_transmute`. + (types::I32, types::F32) | (types::F32, types::I32) + | (types::I64, types::F64) | (types::F64, types::I64) => { + fx.bcx.ins().bitcast(dst_ty, data) + } + _ if src_ty.is_vector() && dst_ty.is_vector() => { + fx.bcx.ins().raw_bitcast(dst_ty, data) + } + _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty), + }; fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); fx.bcx.def_var(mir_var(var), data); return; From 04af24d418da041c1e95dbd7c35f62d661353f3b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 17:31:35 +0200 Subject: [PATCH 1259/1566] Don't use codegen_call_inner in codegen_drop --- src/abi/mod.rs | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 0f08203d8e6a2..5b81b48a09cde 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -655,19 +655,18 @@ pub(crate) fn codegen_drop<'tcx>( // we don't actually need to drop anything } else { let drop_fn_ty = drop_fn.monomorphic_ty(fx.tcx); + let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &drop_fn_ty.fn_sig(fx.tcx), + ); + assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); + match ty.kind { ty::Dynamic(..) => { let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(); let ptr = ptr.get_addr(fx); let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); - let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( - ParamEnv::reveal_all(), - &drop_fn_ty.fn_sig(fx.tcx), - ); - - assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); - let sig = clif_sig_from_fn_sig( fx.tcx, fx.triple(), @@ -679,6 +678,15 @@ pub(crate) fn codegen_drop<'tcx>( fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); } _ => { + let instance = match drop_fn_ty.kind { + ty::FnDef(def_id, substs) => { + Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap() + } + _ => unreachable!("{:?}", drop_fn_ty), + }; + + assert!(!matches!(instance.def, InstanceDef::Virtual(_, _))); + let arg_place = CPlace::new_stack_slot( fx, fx.layout_of(fx.tcx.mk_ref( @@ -691,7 +699,18 @@ pub(crate) fn codegen_drop<'tcx>( ); drop_place.write_place_ref(fx, arg_place); let arg_value = arg_place.to_cvalue(fx); - codegen_call_inner(fx, span, None, drop_fn_ty, vec![arg_value], None); + let arg_value = adjust_arg_for_abi(fx, arg_value); + + let mut call_args: Vec = arg_value.into_iter().collect::>(); + + if instance.def.requires_caller_location(fx.tcx) { + // Pass the caller location for `#[track_caller]`. + let caller_location = fx.get_caller_location(span); + call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); + } + + let func_ref = fx.get_function_ref(instance); + fx.bcx.ins().call(func_ref, &call_args); } } } From 4bbae74458d42a475aa3ab728f67b576b6866a5a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 17:38:17 +0200 Subject: [PATCH 1260/1566] Merge codegen_call_inner into codegen_terminator_call --- src/abi/mod.rs | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 5b81b48a09cde..05ca51c452f24 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -495,31 +495,6 @@ pub(crate) fn codegen_terminator_call<'tcx>( .collect::>() }; - codegen_call_inner( - fx, - span, - Some(func), - fn_ty, - args, - destination.map(|(place, _)| place), - ); - - if let Some((_, dest)) = destination { - let ret_block = fx.get_block(dest); - fx.bcx.ins().jump(ret_block, &[]); - } else { - trap_unreachable(fx, "[corruption] Diverging function returned"); - } -} - -fn codegen_call_inner<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - span: Span, - func: Option<&Operand<'tcx>>, - fn_ty: Ty<'tcx>, - args: Vec>, - ret_place: Option>, -) { // FIXME mark the current block as cold when calling a `#[cold]` function. let fn_sig = fx .tcx @@ -572,7 +547,7 @@ fn codegen_call_inner<'tcx>( let nop_inst = fx.bcx.ins().nop(); fx.add_comment(nop_inst, "indirect call"); } - let func = trans_operand(fx, func.expect("indirect call without func Operand")) + let func = trans_operand(fx, func) .load_scalar(fx); ( Some(func), @@ -584,6 +559,7 @@ fn codegen_call_inner<'tcx>( } }; + let ret_place = destination.map(|(place, _)| place); let (call_inst, call_args) = self::returning::codegen_with_call_return_arg(fx, fn_sig, ret_place, |fx, return_ptr| { let mut call_args: Vec = return_ptr @@ -641,6 +617,13 @@ fn codegen_call_inner<'tcx>( .collect::>(); fx.bcx.func.dfg.signatures[sig_ref].params = abi_params; } + + if let Some((_, dest)) = destination { + let ret_block = fx.get_block(dest); + fx.bcx.ins().jump(ret_block, &[]); + } else { + trap_unreachable(fx, "[corruption] Diverging function returned"); + } } pub(crate) fn codegen_drop<'tcx>( From af016640b68dd091da81970efcba8a65661722d8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 19:12:44 +0200 Subject: [PATCH 1261/1566] Cleanup codegen_terminator_call a bit --- src/abi/mod.rs | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 05ca51c452f24..3867cd38d38dc 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -435,14 +435,16 @@ pub(crate) fn codegen_terminator_call<'tcx>( destination: Option<(Place<'tcx>, BasicBlock)>, ) { let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); - let sig = fx + let fn_sig = fx .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - let destination = destination - .map(|(place, bb)| (trans_place(fx, place), bb)); + // FIXME mark the current block as cold when calling a `#[cold]` function. + + let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); - if let ty::FnDef(def_id, substs) = fn_ty.kind { + // Handle special calls like instrinsics 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(); @@ -469,24 +471,29 @@ pub(crate) fn codegen_terminator_call<'tcx>( fx.bcx.ins().jump(ret_block, &[]); return; } - _ => {} + _ => Some(instance) } - } + } else { + None + }; // Unpack arguments tuple for closures - let args = if sig.abi == Abi::RustCall { + let args = if fn_sig.abi == Abi::RustCall { assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); let self_arg = trans_operand(fx, &args[0]); let pack_arg = trans_operand(fx, &args[1]); - let mut args = Vec::new(); - args.push(self_arg); - match pack_arg.layout().ty.kind { + + let tupled_arguments = match pack_arg.layout().ty.kind { ty::Tuple(ref tupled_arguments) => { - for (i, _) in tupled_arguments.iter().enumerate() { - args.push(pack_arg.value_field(fx, mir::Field::new(i))); - } + tupled_arguments } _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), + }; + + let mut args = Vec::with_capacity(1 + tupled_arguments.len()); + args.push(self_arg); + for i in 0..tupled_arguments.len() { + args.push(pack_arg.value_field(fx, mir::Field::new(i))); } args } else { @@ -495,18 +502,6 @@ pub(crate) fn codegen_terminator_call<'tcx>( .collect::>() }; - // FIXME mark the current block as cold when calling a `#[cold]` function. - let fn_sig = fx - .tcx - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - - let instance = match fn_ty.kind { - ty::FnDef(def_id, substs) => { - Some(Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap()) - } - _ => None, - }; - // | indirect call target // | | the first argument to be passed // v v v virtual calls are special cased below From 21aa9b29bc8fa460ddfc0a893859f5023a1c7b41 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Apr 2020 19:53:49 +0200 Subject: [PATCH 1262/1566] Pre-allocate local_map --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index b76aedbb810ca..16394fd50cf08 100644 --- a/src/base.rs +++ b/src/base.rs @@ -47,7 +47,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( bcx, block_map, - local_map: FxHashMap::default(), + local_map: FxHashMap::with_capacity_and_hasher(mir.local_decls.len(), Default::default()), caller_location: None, // set by `codegen_fn_prelude` cold_blocks: EntitySet::new(), From 78cdfc6c9214e6cff7e56750279581453cde21ef Mon Sep 17 00:00:00 2001 From: Venkata Jaswanth U Date: Tue, 14 Apr 2020 21:36:28 +0530 Subject: [PATCH 1263/1566] Fixes #958: Use session.fatal() instead of assert! --- src/archive.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 6ebb713b26761..f8ea9176fffbf 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -225,11 +225,10 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { .arg(self.config.dst) .status() .expect("Couldn't run ranlib"); - assert!( - status.success(), - "Ranlib exited with code {:?}", - status.code() - ); + + if !status.success() { + self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); + } } } From 9a378c3f3f8582d6478677069e4f2810198dda46 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 16 Apr 2020 14:27:07 +0200 Subject: [PATCH 1264/1566] Fix transmute of non-scalar to scalar Fixes #967 --- src/value_and_place.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 5a0e2ee268be9..5779009535b64 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -123,7 +123,7 @@ impl<'tcx> CValue<'tcx> { scalar_to_clif_type(fx.tcx, element.clone()) .by(u16::try_from(count).unwrap()).unwrap() } - _ => unreachable!(), + _ => unreachable!("{:?}", layout.ty), }; ptr.load(fx, clif_ty, MemFlags::new()) } @@ -458,7 +458,7 @@ impl<'tcx> CPlace<'tcx> { let dst_layout = self.layout(); let to_ptr = match self.inner { CPlaceInner::Var(var) => { - let data = from.load_scalar(fx); + let data = CValue(from.0, dst_layout).load_scalar(fx); let src_ty = fx.bcx.func.dfg.value_type(data); let dst_ty = fx.clif_type(self.layout().ty).unwrap(); let data = match (src_ty, dst_ty) { @@ -487,7 +487,7 @@ impl<'tcx> CPlace<'tcx> { CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self), }; - match self.layout().abi { + match from.layout().abi { // FIXME make Abi::Vector work too Abi::Scalar(_) => { let val = from.load_scalar(fx); From cd684e39e0d27513d21f15e7cc65273ec5883e1b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Apr 2020 14:14:18 +0200 Subject: [PATCH 1265/1566] Fix saturated_* intrinsics for 128bit ints Fixes #968 --- src/cast.rs | 8 +++++++- src/common.rs | 31 ++++++++++++++++++++++++++++--- src/intrinsics/mod.rs | 4 +--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/cast.rs b/src/cast.rs index 08dc68b08d7ef..395a270efd9dc 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -159,7 +159,13 @@ pub(crate) fn clif_int_or_float_cast( } else { fx.bcx.ins().fcvt_to_uint_sat(types::I32, from) }; - let (min, max) = type_min_max_value(to_ty, to_signed); + let (min, max) = match (to_ty, to_signed) { + (types::I8, false) => (0, u8::MAX as i64), + (types::I16, false) => (0, u16::MAX as i64), + (types::I8, true) => (i8::MIN as i64, i8::MAX as i64), + (types::I16, true) => (i16::MIN as i64, i16::MAX as i64), + _ => unreachable!(), + }; let min_val = fx.bcx.ins().iconst(types::I32, min); let max_val = fx.bcx.ins().iconst(types::I32, max); diff --git a/src/common.rs b/src/common.rs index ed368bf96ecc4..e24eb9f0553eb 100644 --- a/src/common.rs +++ b/src/common.rs @@ -215,8 +215,33 @@ pub(crate) fn resolve_value_imm(func: &Function, val: Value) -> Option { } } -pub(crate) fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { +pub(crate) fn type_min_max_value(bcx: &mut FunctionBuilder<'_>, ty: Type, signed: bool) -> (Value, Value) { assert!(ty.is_int()); + + if ty == types::I128 { + if signed { + let min = i128::MIN as u128; + let min_lsb = bcx.ins().iconst(types::I64, min as u64 as i64); + let min_msb = bcx.ins().iconst(types::I64, (min >> 64) as u64 as i64); + let min = bcx.ins().iconcat(min_lsb, min_msb); + + let max = i128::MIN as u128; + let max_lsb = bcx.ins().iconst(types::I64, max as u64 as i64); + let max_msb = bcx.ins().iconst(types::I64, (max >> 64) as u64 as i64); + let max = bcx.ins().iconcat(max_lsb, max_msb); + + return (min, max); + } else { + let min_half = bcx.ins().iconst(types::I64, 0); + let min = bcx.ins().iconcat(min_half, min_half); + + let max_half = bcx.ins().iconst(types::I64, u64::MAX as i64); + let max = bcx.ins().iconcat(max_half, max_half); + + return (min, max); + } + } + let min = match (ty, signed) { (types::I8, false) | (types::I16, false) | (types::I32, false) | (types::I64, false) => { 0i64 @@ -225,7 +250,6 @@ pub(crate) fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { (types::I16, true) => i16::MIN as i64, (types::I32, true) => i32::MIN as i64, (types::I64, true) => i64::MIN, - (types::I128, _) => unimplemented!(), _ => unreachable!(), }; @@ -238,10 +262,11 @@ pub(crate) fn type_min_max_value(ty: Type, signed: bool) -> (i64, i64) { (types::I16, true) => i16::MAX as i64, (types::I32, true) => i32::MAX as i64, (types::I64, true) => i64::MAX, - (types::I128, _) => unimplemented!(), _ => unreachable!(), }; + let (min, max) = (bcx.ins().iconst(ty, min), bcx.ins().iconst(ty, max)); + (min, max) } diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 12edbfdbe3fcb..8ae4848a7dff4 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -583,9 +583,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( // `select.i8` is not implemented by Cranelift. let has_overflow = fx.bcx.ins().uextend(types::I32, has_overflow); - let (min, max) = type_min_max_value(clif_ty, signed); - let min = fx.bcx.ins().iconst(clif_ty, min); - let max = fx.bcx.ins().iconst(clif_ty, max); + let (min, max) = type_min_max_value(&mut fx.bcx, clif_ty, signed); let val = match (intrinsic, signed) { ("saturating_add", false) => fx.bcx.ins().select(has_overflow, max, val), From 0c6b2dcafc1e3effbac3399fdcd0a702df3e313f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Apr 2020 14:26:39 +0200 Subject: [PATCH 1266/1566] Rustup to rustc 1.44.0-nightly (7f3df5772 2020-04-16) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index ab0c7c21a139d..0f09fccb5cd33 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-13 +nightly-2020-04-17 From 045ae10380b99e97bd29d18c3f3af5cac5a5d7a1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Apr 2020 14:32:01 +0200 Subject: [PATCH 1267/1566] Update Cranelift --- Cargo.lock | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52a6c6912e657..756c52921cf32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "byteorder", "cranelift-bforest", @@ -62,6 +62,7 @@ dependencies = [ "cranelift-entity", "gimli", "log", + "regalloc", "smallvec", "target-lexicon", "thiserror", @@ -70,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" [[package]] name = "cranelift-entity" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" [[package]] name = "cranelift-frontend" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#63c97e365e716e3dbe07f8cb5a2c1084b188baed" +source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -274,6 +275,16 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "regalloc" +version = "0.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89ce0cd835fa6e91bbf5d010beee19d0c2e97e4ad5e13c399a31122cfc83bdd6" +dependencies = [ + "log", + "rustc-hash", +] + [[package]] name = "region" version = "2.1.2" @@ -286,6 +297,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_codegen_cranelift" version = "0.1.0" From 9f602bf4dae1a86dde890552e3c0c7fa2ca9196f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Apr 2020 16:54:46 +0200 Subject: [PATCH 1268/1566] Use qemu to run tests for AArch64 when using a different host arch --- config.sh | 18 +++++++++++++-- test.sh | 68 ++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/config.sh b/config.sh index e2534da89e152..0f75e331a7e7e 100644 --- a/config.sh +++ b/config.sh @@ -10,9 +10,23 @@ else exit 1 fi -TARGET_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") +HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") +TARGET_TRIPLE=$HOST_TRIPLE +#TARGET_TRIPLE="aarch64-unknown-linux-gnu" -export RUSTFLAGS='-Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +linker='' +RUN_WRAPPER='' +if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then + if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then + # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. + linker='-Clinker=aarch64-linux-gnu-gcc' + RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu' + else + echo "Unknown non-native platform" + fi +fi + +export RUSTFLAGS=$linker' -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' # FIXME remove once the atomic shim is gone if [[ `uname` == 'Darwin' ]]; then diff --git a/test.sh b/test.sh index bc4c807cbf286..190fd7b291abb 100755 --- a/test.sh +++ b/test.sh @@ -16,69 +16,85 @@ rm -r target/out || true mkdir -p target/out/clif echo "[BUILD] mini_core" -$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib +$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE echo "[BUILD] example" -$RUSTC example/example.rs --crate-type lib +$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE -echo "[JIT] mini_core_hello_world" -CG_CLIF_JIT=1 CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit +if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then + echo "[JIT] mini_core_hello_world" + CG_CLIF_JIT=1 CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE +else + echo "[JIT] mini_core_hello_world (skipped)" +fi echo "[AOT] mini_core_hello_world" -$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g -./target/out/mini_core_hello_world abc bcd +$RUSTC example/mini_core_hello_world.rs --crate-name mini_core_hello_world --crate-type bin -g --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/mini_core_hello_world abc bcd # (echo "break set -n main"; echo "run"; sleep 1; echo "si -c 10"; sleep 1; echo "frame variable") | lldb -- ./target/out/mini_core_hello_world abc bcd echo "[AOT] arbitrary_self_types_pointers_and_wrappers" -$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin -./target/out/arbitrary_self_types_pointers_and_wrappers +$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers echo "[BUILD] sysroot" time ./build_sysroot/build_sysroot.sh echo "[AOT] alloc_example" -$RUSTC example/alloc_example.rs --crate-type bin -./target/out/alloc_example +$RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/alloc_example -echo "[JIT] std_example" -CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs +if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then + echo "[JIT] std_example" + CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs --target $HOST_TRIPLE +else + echo "[JIT] std_example (skipped)" +fi echo "[AOT] dst_field_align" # FIXME Re-add -Zmir-opt-level=2 once rust-lang/rust#67529 is fixed. -$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin -./target/out/dst_field_align +$RUSTC example/dst-field-align.rs --crate-name dst_field_align --crate-type bin --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false) echo "[AOT] std_example" -$RUSTC example/std_example.rs --crate-type bin -./target/out/std_example +$RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE echo "[AOT] subslice-patterns-const-eval" -$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort -./target/out/subslice-patterns-const-eval +$RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/subslice-patterns-const-eval echo "[AOT] track-caller-attribute" -$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort -./target/out/track-caller-attribute +$RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/track-caller-attribute echo "[BUILD] mod_bench" -$RUSTC example/mod_bench.rs --crate-type bin +$RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE # FIXME linker gives multiple definitions error on Linux #echo "[BUILD] sysroot in release mode" #./build_sysroot/build_sysroot.sh --release pushd simple-raytracer -echo "[BENCH COMPILE] ebobby/simple-raytracer" -hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \ +if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then + echo "[BENCH COMPILE] ebobby/simple-raytracer" + hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \ "RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \ "../cargo.sh build" -echo "[BENCH RUN] ebobby/simple-raytracer" -cp ./target/*/debug/main ./raytracer_cg_clif -hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif + echo "[BENCH RUN] ebobby/simple-raytracer" + cp ./target/*/debug/main ./raytracer_cg_clif + hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif +else + echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)" + echo "[COMPILE] ebobby/simple-raytracer" + ../cargo.sh build + echo "[BENCH RUN] ebobby/simple-raytracer (skipped)" +fi popd pushd build_sysroot/sysroot_src/src/libcore/tests +echo "[TEST] libcore" rm -r ./target || true ../../../../../cargo.sh test popd From 51d07790df51eb50a2b90a410eec50b667e571fb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Apr 2020 19:33:57 +0200 Subject: [PATCH 1269/1566] Use the correct return type for puts --- example/alloc_example.rs | 2 +- example/mini_core.rs | 2 +- src/trap.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/alloc_example.rs b/example/alloc_example.rs index 20a8642cbd175..f75103c76a524 100644 --- a/example/alloc_example.rs +++ b/example/alloc_example.rs @@ -13,7 +13,7 @@ static ALLOC: System = System; #[link(name = "c")] extern "C" { - fn puts(s: *const u8); + fn puts(s: *const u8) -> i32; } #[panic_handler] diff --git a/example/mini_core.rs b/example/mini_core.rs index 5311d84e72ac9..0c95ac6772a8d 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -488,7 +488,7 @@ pub mod intrinsics { pub mod libc { #[link(name = "c")] extern "C" { - pub fn puts(s: *const u8); + pub fn puts(s: *const u8) -> i32; pub fn printf(format: *const i8, ...) -> i32; pub fn malloc(size: usize) -> *mut u8; pub fn free(ptr: *mut u8); diff --git a/src/trap.rs b/src/trap.rs index 86af1ee538119..2b437a0f76966 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -12,7 +12,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms &Signature { call_conv: CallConv::triple_default(fx.triple()), params: vec![AbiParam::new(pointer_ty(fx.tcx))], - returns: vec![], + returns: vec![AbiParam::new(types::I32)], }, ) .unwrap(); From a802c7f2927cceb6bc87bf456bd9bee472218e27 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Apr 2020 21:03:43 +0200 Subject: [PATCH 1270/1566] Disable line debuginfo for the AArch64 backend --- src/debuginfo/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index b6eebbf482c2d..967b300c0c5db 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -257,6 +257,10 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, local_map: FxHashMap>, ) { + if isa.get_mach_backend().is_some() { + return; // The AArch64 backend doesn't support line debuginfo yet. + } + let end = self.create_debug_lines(context, isa, source_info_set); self.debug_context From 077209e56544ccb55a5e2864d388eccf32c888ee Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 18 Apr 2020 14:56:04 +0300 Subject: [PATCH 1271/1566] Support file hashes in .debug_line --- src/debuginfo/line_info.rs | 38 ++++++++++++++++++++++++-------- src/debuginfo/mod.rs | 44 ++++++++++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 16 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 0870f89e3d83d..a507821647e1b 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -1,14 +1,15 @@ use std::ffi::OsStr; +use std::time::SystemTime; use std::path::{Component, Path}; use crate::prelude::*; -use rustc_span::{FileName, SourceFileAndLine, Pos}; +use rustc_span::{FileName, SourceFile, SourceFileAndLine, Pos, SourceFileHash, SourceFileHashAlgorithm}; use cranelift_codegen::binemit::CodeOffset; use gimli::write::{ - Address, AttributeValue, FileId, LineProgram, LineString, LineStringTable, UnitEntryId, + Address, AttributeValue, FileId, LineProgram, LineString, FileInfo, LineStringTable, UnitEntryId, }; // OPTIMIZATION: It is cheaper to do this in one pass than using `.parent()` and `.file_name()`. @@ -38,9 +39,9 @@ fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] { fn line_program_add_file( line_program: &mut LineProgram, line_strings: &mut LineStringTable, - file: &FileName, + file: &SourceFile, ) -> FileId { - match file { + match &file.name { FileName::Real(path) => { let (dir_path, file_name) = split_path_dir_and_file(path); let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str()); @@ -57,13 +58,32 @@ fn line_program_add_file( line_program.encoding(), line_strings, ); - line_program.add_file(file_name, dir_id, None) + + let md5 = Some(file.src_hash) + .filter(|h| matches!(h, SourceFileHash { kind: SourceFileHashAlgorithm::Md5, .. })) + .map(|h| { + let mut buf = [0u8; super::MD5_LEN]; + buf.copy_from_slice(h.hash_bytes()); + buf + }); + + line_program.file_has_timestamp = true; + line_program.file_has_md5 = md5.is_some(); + + line_program.add_file(file_name, dir_id, Some(FileInfo { + timestamp: SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .map(|t| t.as_secs()) + .unwrap_or(0), + size: 0, + md5: md5.unwrap_or_default(), + })) } // FIXME give more appropriate file names - _ => { + filename => { let dir_id = line_program.default_directory(); let dummy_file_name = LineString::new( - file.to_string().into_bytes(), + filename.to_string().into_bytes(), line_program.encoding(), line_strings, ); @@ -79,7 +99,7 @@ impl<'tcx> DebugContext<'tcx> { let file_id = line_program_add_file( &mut self.dwarf.unit.line_program, &mut self.dwarf.line_strings, - &loc.file.name, + &loc.file, ); let entry = self.dwarf.unit.get_mut(entry_id); @@ -167,7 +187,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { true }; if current_file_changed { - let file_id = line_program_add_file(line_program, line_strings, &file.name); + let file_id = line_program_add_file(line_program, line_strings, &file); line_program.row().file = file_id; last_file = Some(file.clone()); } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index b6eebbf482c2d..d6225e8052ab8 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,15 +1,19 @@ mod emit; mod line_info; +use std::time::SystemTime; + use crate::prelude::*; +use rustc_span::{FileName, SourceFileHash, SourceFileHashAlgorithm}; + use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; use gimli::write::{ self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, - LocationList, Range, RangeList, UnitEntryId, Writer, + LocationList, Range, RangeList, UnitEntryId, Writer, FileInfo, }; use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; @@ -24,6 +28,8 @@ fn target_endian(tcx: TyCtxt<'_>) -> RunTimeEndian { } } +const MD5_LEN: usize = 16; + pub(crate) struct DebugContext<'tcx> { tcx: TyCtxt<'tcx>, @@ -42,7 +48,8 @@ impl<'tcx> DebugContext<'tcx> { format: Format::Dwarf32, // TODO: this should be configurable // macOS doesn't seem to support DWARF > 3 - version: 3, + // 5 version is required for md5 file hash + version: 5, address_size, }; @@ -52,18 +59,41 @@ impl<'tcx> DebugContext<'tcx> { // Normally this would use option_env!("CFG_VERSION"). let producer = format!("cg_clif (rustc {})", "unknown version"); let comp_dir = tcx.sess.working_dir.0.to_string_lossy().into_owned(); - let name = match tcx.sess.local_crate_source_file { - Some(ref path) => path.to_string_lossy().into_owned(), - None => tcx.crate_name(LOCAL_CRATE).to_string(), + let (name, md5) = match tcx.sess.local_crate_source_file.clone() { + Some(path) => { + let name = path.to_string_lossy().into_owned(); + let hash = tcx.sess + .source_map() + .get_source_file(&FileName::Real(path)) + .map(|f| f.src_hash) + .filter(|h| matches!(h, SourceFileHash { kind: SourceFileHashAlgorithm::Md5, .. })) + .map(|h| { + let mut buf = [0u8; MD5_LEN]; + buf.copy_from_slice(h.hash_bytes()); + buf + }); + (name, hash) + }, + None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), }; - let line_program = LineProgram::new( + let mut line_program = LineProgram::new( encoding, LineEncoding::default(), LineString::new(comp_dir.as_bytes(), encoding, &mut dwarf.line_strings), LineString::new(name.as_bytes(), encoding, &mut dwarf.line_strings), - None, + Some(FileInfo { + timestamp: SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .map(|t| t.as_secs()) + .unwrap_or(0), + size: 0, + md5: md5.unwrap_or_default(), + }), ); + line_program.file_has_timestamp = true; + line_program.file_has_md5 = md5.is_some(); + dwarf.unit.line_program = line_program; { From 5c0e34d7ab4f64fbb62825404c5075ef9bb4a710 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 18 Apr 2020 16:02:02 +0300 Subject: [PATCH 1272/1566] Don`t include timestamp as debug file info --- src/debuginfo/line_info.rs | 7 +------ src/debuginfo/mod.rs | 8 +------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index a507821647e1b..98257e89f1e4e 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -1,5 +1,4 @@ use std::ffi::OsStr; -use std::time::SystemTime; use std::path::{Component, Path}; use crate::prelude::*; @@ -67,14 +66,10 @@ fn line_program_add_file( buf }); - line_program.file_has_timestamp = true; line_program.file_has_md5 = md5.is_some(); line_program.add_file(file_name, dir_id, Some(FileInfo { - timestamp: SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .map(|t| t.as_secs()) - .unwrap_or(0), + timestamp: 0, size: 0, md5: md5.unwrap_or_default(), })) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index d6225e8052ab8..c308916a22dac 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,8 +1,6 @@ mod emit; mod line_info; -use std::time::SystemTime; - use crate::prelude::*; use rustc_span::{FileName, SourceFileHash, SourceFileHashAlgorithm}; @@ -83,15 +81,11 @@ impl<'tcx> DebugContext<'tcx> { LineString::new(comp_dir.as_bytes(), encoding, &mut dwarf.line_strings), LineString::new(name.as_bytes(), encoding, &mut dwarf.line_strings), Some(FileInfo { - timestamp: SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .map(|t| t.as_secs()) - .unwrap_or(0), + timestamp: 0, size: 0, md5: md5.unwrap_or_default(), }), ); - line_program.file_has_timestamp = true; line_program.file_has_md5 = md5.is_some(); dwarf.unit.line_program = line_program; From 1e472531c6bf3bd3b725924918e4dbb49056759f Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 18 Apr 2020 16:05:20 +0300 Subject: [PATCH 1273/1566] Use dwarf 3 for osx --- src/debuginfo/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index c308916a22dac..17bb53aa3476a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -47,7 +47,11 @@ impl<'tcx> DebugContext<'tcx> { // TODO: this should be configurable // macOS doesn't seem to support DWARF > 3 // 5 version is required for md5 file hash - version: 5, + version: if tcx.sess.target.target.options.is_like_osx { + 3 + } else { + 5 + }, address_size, }; From 710da05af7e4ee13c00b9019752b6076ae6b71b4 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 18 Apr 2020 16:16:17 +0300 Subject: [PATCH 1274/1566] Dedup file hashing logic with type --- src/debuginfo/line_info.rs | 41 ++++++++++++++++++++++++++++---------- src/debuginfo/mod.rs | 20 +++++++------------ 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 98257e89f1e4e..afef0b8ec2f63 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -1,4 +1,5 @@ use std::ffi::OsStr; +use std::convert::TryFrom; use std::path::{Component, Path}; use crate::prelude::*; @@ -35,6 +36,33 @@ fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] { } } +pub(crate) const MD5_LEN: usize = 16; + +#[derive(Default, Clone, Copy)] +pub struct FileHash([u8; MD5_LEN]); + +impl FileHash { + pub fn inner(self) -> [u8; MD5_LEN] { + self.0 + } +} + +pub struct UnsupportedHashType; + +impl TryFrom for FileHash { + type Error = UnsupportedHashType; + + fn try_from(hash: SourceFileHash) -> Result { + if hash.kind == SourceFileHashAlgorithm::Md5 { + let mut buf = [0u8; MD5_LEN]; + buf.copy_from_slice(hash.hash_bytes()); + Ok(Self(buf)) + } else { + Err(UnsupportedHashType) + } + } +} + fn line_program_add_file( line_program: &mut LineProgram, line_strings: &mut LineStringTable, @@ -58,20 +86,13 @@ fn line_program_add_file( line_strings, ); - let md5 = Some(file.src_hash) - .filter(|h| matches!(h, SourceFileHash { kind: SourceFileHashAlgorithm::Md5, .. })) - .map(|h| { - let mut buf = [0u8; super::MD5_LEN]; - buf.copy_from_slice(h.hash_bytes()); - buf - }); - - line_program.file_has_md5 = md5.is_some(); + let file_hash = FileHash::try_from(file.src_hash); + line_program.file_has_md5 = file_hash.is_ok(); line_program.add_file(file_name, dir_id, Some(FileInfo { timestamp: 0, size: 0, - md5: md5.unwrap_or_default(), + md5: file_hash.unwrap_or_default().inner(), })) } // FIXME give more appropriate file names diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 17bb53aa3476a..fbf5fa052362a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,9 +1,11 @@ mod emit; mod line_info; +use std::convert::TryFrom; + use crate::prelude::*; -use rustc_span::{FileName, SourceFileHash, SourceFileHashAlgorithm}; +use rustc_span::FileName; use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift_codegen::isa::TargetIsa; @@ -26,8 +28,6 @@ fn target_endian(tcx: TyCtxt<'_>) -> RunTimeEndian { } } -const MD5_LEN: usize = 16; - pub(crate) struct DebugContext<'tcx> { tcx: TyCtxt<'tcx>, @@ -61,19 +61,13 @@ impl<'tcx> DebugContext<'tcx> { // Normally this would use option_env!("CFG_VERSION"). let producer = format!("cg_clif (rustc {})", "unknown version"); let comp_dir = tcx.sess.working_dir.0.to_string_lossy().into_owned(); - let (name, md5) = match tcx.sess.local_crate_source_file.clone() { + let (name, file_hash) = match tcx.sess.local_crate_source_file.clone() { Some(path) => { let name = path.to_string_lossy().into_owned(); let hash = tcx.sess .source_map() .get_source_file(&FileName::Real(path)) - .map(|f| f.src_hash) - .filter(|h| matches!(h, SourceFileHash { kind: SourceFileHashAlgorithm::Md5, .. })) - .map(|h| { - let mut buf = [0u8; MD5_LEN]; - buf.copy_from_slice(h.hash_bytes()); - buf - }); + .and_then(|f| line_info::FileHash::try_from(f.src_hash).ok()); (name, hash) }, None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), @@ -87,10 +81,10 @@ impl<'tcx> DebugContext<'tcx> { Some(FileInfo { timestamp: 0, size: 0, - md5: md5.unwrap_or_default(), + md5: file_hash.unwrap_or_default().inner(), }), ); - line_program.file_has_md5 = md5.is_some(); + line_program.file_has_md5 = file_hash.is_some(); dwarf.unit.line_program = line_program; From 0e837e308254f3e56b95fcdafa706e40be084bb9 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 18 Apr 2020 16:33:01 +0300 Subject: [PATCH 1275/1566] Simplify FileHash ctor --- src/debuginfo/line_info.rs | 25 +++++++++---------------- src/debuginfo/mod.rs | 5 ++--- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index afef0b8ec2f63..ae3d39183ba0b 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -1,5 +1,4 @@ use std::ffi::OsStr; -use std::convert::TryFrom; use std::path::{Component, Path}; use crate::prelude::*; @@ -42,25 +41,19 @@ pub(crate) const MD5_LEN: usize = 16; pub struct FileHash([u8; MD5_LEN]); impl FileHash { - pub fn inner(self) -> [u8; MD5_LEN] { - self.0 - } -} - -pub struct UnsupportedHashType; - -impl TryFrom for FileHash { - type Error = UnsupportedHashType; - - fn try_from(hash: SourceFileHash) -> Result { + pub fn from_source_hash(hash: SourceFileHash) -> Option { if hash.kind == SourceFileHashAlgorithm::Md5 { let mut buf = [0u8; MD5_LEN]; buf.copy_from_slice(hash.hash_bytes()); - Ok(Self(buf)) + Some(Self(buf)) } else { - Err(UnsupportedHashType) + None } } + + pub fn inner(self) -> [u8; MD5_LEN] { + self.0 + } } fn line_program_add_file( @@ -86,9 +79,9 @@ fn line_program_add_file( line_strings, ); - let file_hash = FileHash::try_from(file.src_hash); + let file_hash = FileHash::from_source_hash(file.src_hash); - line_program.file_has_md5 = file_hash.is_ok(); + line_program.file_has_md5 = file_hash.is_some(); line_program.add_file(file_name, dir_id, Some(FileInfo { timestamp: 0, size: 0, diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index fbf5fa052362a..042beb4de1bb7 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,8 +1,6 @@ mod emit; mod line_info; -use std::convert::TryFrom; - use crate::prelude::*; use rustc_span::FileName; @@ -67,7 +65,8 @@ impl<'tcx> DebugContext<'tcx> { let hash = tcx.sess .source_map() .get_source_file(&FileName::Real(path)) - .and_then(|f| line_info::FileHash::try_from(f.src_hash).ok()); + .map(|f| f.src_hash) + .and_then(line_info::FileHash::from_source_hash); (name, hash) }, None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), From eab4c9063ec63bf484347cbd6b21117d336db4a5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Apr 2020 15:42:49 +0200 Subject: [PATCH 1276/1566] Sync fn_sig_for_fn_abi with upstream for generator resume args Fixes #970 --- example/std_example.rs | 8 ++++++-- src/abi/mod.rs | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index baf9a9c526eb5..d7e8cf73ea8f1 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,8 +1,8 @@ -#![feature(core_intrinsics)] -#![feature(is_sorted)] +#![feature(core_intrinsics, generators, generator_trait, is_sorted)] use std::arch::x86_64::*; use std::io::Write; +use std::ops::Generator; fn main() { let mutex = std::sync::Mutex::new(()); @@ -89,6 +89,10 @@ fn main() { unsafe { test_simd(); } + + Box::pin(move |mut _task_context| { + yield (); + }).as_mut().resume(0); } #[target_feature(enable = "sse2")] diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 3867cd38d38dc..dabb2b6e010c2 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -12,7 +12,7 @@ use crate::prelude::*; pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return}; -// Copied from https://github.com/rust-lang/rust/blob/c2f4c57296f0d929618baed0b0d6eb594abf01eb/src/librustc/ty/layout.rs#L2349 +// Copied from https://github.com/rust-lang/rust/blob/b2c1a606feb1fbdb0ac0acba76f881ef172ed474/src/librustc_middle/ty/layout.rs#L2287 pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { let ty = instance.monomorphic_ty(tcx); match ty.kind { @@ -43,7 +43,7 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx sig.abi )) } - ty::Generator(_def_id, substs, _) => { + ty::Generator(_, substs, _) => { let sig = substs.as_generator().poly_sig(); let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); @@ -63,8 +63,9 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx ]); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); - tcx.mk_fn_sig(std::iter::once(env_ty), - ret_ty, + tcx.mk_fn_sig( + [env_ty, sig.resume_ty].iter(), + &ret_ty, false, rustc_hir::Unsafety::Normal, rustc_target::spec::abi::Abi::Rust From 5b4a8091d5dfeebcd2925eecc7e887bc83f5a689 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Apr 2020 15:57:08 +0200 Subject: [PATCH 1277/1566] Add some documentation about the debuginfo support of cg_clif --- docs/dwarf.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docs/dwarf.md diff --git a/docs/dwarf.md b/docs/dwarf.md new file mode 100644 index 0000000000000..ac400bb8d0741 --- /dev/null +++ b/docs/dwarf.md @@ -0,0 +1,21 @@ +# Line number information + +Line number information maps between machine code instructions and the source level location. + +## Encoding + +The line number information is stored in the `.debug_line` section for ELF and `__debug_line` +section of the `__DWARF` segment for Mach-O object files. The line number information contains a +header followed by the line program. The line program is a program for a virtual machine with +instructions like set line number for the current machine code instruction and advance the current +machine code instruction. + +## Tips + +You need to set either `DW_AT_low_pc` and `DW_AT_high_pc` **or** `DW_AT_ranges` of a +`DW_TAG_compilation_unit` to the range of addresses in the compilation unit. After that you need +to set `DW_AT_stmt_list` to the `.debug_line` section offset of the line program. Otherwise a +debugger won't find the line number information. On macOS the debuginfo relocations **must** be +section relative and not symbol relative. +See [#303 (comment)](https://github.com/bjorn3/rustc_codegen_cranelift/issues/303#issuecomment-457825535) +for more information. From fb709ede02c1feca4c9196d7795992af9606f203 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Sat, 18 Apr 2020 17:43:00 +0300 Subject: [PATCH 1278/1566] Simplify with make_file_info --- src/debuginfo/line_info.rs | 37 ++++++++++++++----------------------- src/debuginfo/mod.rs | 18 +++++++----------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index ae3d39183ba0b..c001d4b082b49 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -37,22 +37,17 @@ fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] { pub(crate) const MD5_LEN: usize = 16; -#[derive(Default, Clone, Copy)] -pub struct FileHash([u8; MD5_LEN]); - -impl FileHash { - pub fn from_source_hash(hash: SourceFileHash) -> Option { - if hash.kind == SourceFileHashAlgorithm::Md5 { - let mut buf = [0u8; MD5_LEN]; - buf.copy_from_slice(hash.hash_bytes()); - Some(Self(buf)) - } else { - None - } - } - - pub fn inner(self) -> [u8; MD5_LEN] { - self.0 +pub fn make_file_info(hash: SourceFileHash) -> Option { + if hash.kind == SourceFileHashAlgorithm::Md5 { + let mut buf = [0u8; MD5_LEN]; + buf.copy_from_slice(hash.hash_bytes()); + Some(FileInfo { + timestamp: 0, + size: 0, + md5: buf, + }) + } else { + None } } @@ -79,14 +74,10 @@ fn line_program_add_file( line_strings, ); - let file_hash = FileHash::from_source_hash(file.src_hash); + let info = make_file_info(file.src_hash); - line_program.file_has_md5 = file_hash.is_some(); - line_program.add_file(file_name, dir_id, Some(FileInfo { - timestamp: 0, - size: 0, - md5: file_hash.unwrap_or_default().inner(), - })) + line_program.file_has_md5 = info.is_some(); + line_program.add_file(file_name, dir_id, info) } // FIXME give more appropriate file names filename => { diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 042beb4de1bb7..c1d96183ea4b6 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -11,7 +11,7 @@ use cranelift_codegen::ValueLocRange; use gimli::write::{ self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, - LocationList, Range, RangeList, UnitEntryId, Writer, FileInfo, + LocationList, Range, RangeList, UnitEntryId, Writer, }; use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; @@ -59,15 +59,15 @@ impl<'tcx> DebugContext<'tcx> { // Normally this would use option_env!("CFG_VERSION"). let producer = format!("cg_clif (rustc {})", "unknown version"); let comp_dir = tcx.sess.working_dir.0.to_string_lossy().into_owned(); - let (name, file_hash) = match tcx.sess.local_crate_source_file.clone() { + let (name, file_info) = match tcx.sess.local_crate_source_file.clone() { Some(path) => { let name = path.to_string_lossy().into_owned(); - let hash = tcx.sess + let info = tcx.sess .source_map() .get_source_file(&FileName::Real(path)) .map(|f| f.src_hash) - .and_then(line_info::FileHash::from_source_hash); - (name, hash) + .and_then(line_info::make_file_info); + (name, info) }, None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), }; @@ -77,13 +77,9 @@ impl<'tcx> DebugContext<'tcx> { LineEncoding::default(), LineString::new(comp_dir.as_bytes(), encoding, &mut dwarf.line_strings), LineString::new(name.as_bytes(), encoding, &mut dwarf.line_strings), - Some(FileInfo { - timestamp: 0, - size: 0, - md5: file_hash.unwrap_or_default().inner(), - }), + file_info, ); - line_program.file_has_md5 = file_hash.is_some(); + line_program.file_has_md5 = file_info.is_some(); dwarf.unit.line_program = line_program; From e64a7ebcb0c8633d30bc553023a6e7ed830b2709 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 18 Apr 2020 21:13:09 +0200 Subject: [PATCH 1279/1566] Implement check mode Fixes #973 --- src/driver/aot.rs | 12 +++++++++++- src/driver/jit.rs | 4 ++++ src/lib.rs | 1 - 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 591e15803373c..b74608974b7d5 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -146,7 +146,13 @@ pub(super) fn run_aot( ) -> Box<(CodegenResults, FxHashMap)> { let mut work_products = FxHashMap::default(); - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + let cgus = if tcx.sess.opts.output_types.should_codegen() { + tcx.collect_and_partition_mono_items(LOCAL_CRATE).1 + } else { + // If only `--emit metadata` is used, we shouldn't perform any codegen. + // Also `tcx.collect_and_partition_mono_items` may panic in that case. + &[] + }; if tcx.dep_graph.is_fully_enabled() { for cgu in &*cgus { @@ -239,6 +245,10 @@ pub(super) fn run_aot( None }; + if tcx.sess.opts.output_types.should_codegen() { + rustc_incremental::assert_module_sources::assert_module_sources(tcx); + } + Box::new((CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules, diff --git a/src/driver/jit.rs b/src/driver/jit.rs index bf388a2769a05..a5dca71c330fc 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -39,6 +39,10 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { .declare_function("main", Linkage::Import, &sig) .unwrap(); + if !tcx.sess.opts.output_types.should_codegen() { + tcx.sess.fatal("JIT mode doesn't work with `cargo check`."); + } + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); let mono_items = cgus .iter() diff --git a/src/lib.rs b/src/lib.rs index e7a637211d409..d679b4d7930c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -200,7 +200,6 @@ impl CodegenBackend for CraneliftCodegenBackend { ) -> Box { let res = driver::codegen_crate(tcx, metadata, need_metadata_module); - rustc_incremental::assert_module_sources::assert_module_sources(tcx); rustc_symbol_mangling::test::report_symbol_names(tcx); res From 080d17f4f595de836c0222d3a2695325defce93a Mon Sep 17 00:00:00 2001 From: Serentty Date: Sun, 19 Apr 2020 04:55:07 -0400 Subject: [PATCH 1280/1566] Fix spelling error in comment (#974) --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 16394fd50cf08..144199a5b4f54 100644 --- a/src/base.rs +++ b/src/base.rs @@ -29,7 +29,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut func_ctx = FunctionBuilderContext::new(); let mut bcx = FunctionBuilder::new(&mut context.func, &mut func_ctx); - // Predefine block's + // Predefine blocks let start_block = bcx.create_block(); let block_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_block()).collect(); From 385c656372debf8d538346d5b51e6955121f4b4f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 19 Apr 2020 11:10:00 +0200 Subject: [PATCH 1281/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 756c52921cf32..2c0a4adcd2154 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" [[package]] name = "cranelift-entity" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" [[package]] name = "cranelift-frontend" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#7d88384c0fe087cd80a3d8ae1bbc80950b2b7d91" +source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" dependencies = [ "cranelift-codegen", "cranelift-module", From 8c7a4577536c88632e3c1783b567ec2215aeda48 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Mon, 20 Apr 2020 23:27:54 +0300 Subject: [PATCH 1282/1566] Use md5 dwarf hash, only if all files has it Co-Authored-By: bjorn3 --- src/debuginfo/line_info.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index c001d4b082b49..3c44f8ebf4cc0 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -76,7 +76,7 @@ fn line_program_add_file( let info = make_file_info(file.src_hash); - line_program.file_has_md5 = info.is_some(); + line_program.file_has_md5 &= info.is_some(); line_program.add_file(file_name, dir_id, info) } // FIXME give more appropriate file names From c3c5c4b731588fa289fb3e4959b9b896b95149a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 21 Apr 2020 12:13:50 +0200 Subject: [PATCH 1283/1566] Use DWARF version 4 for now --- src/debuginfo/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index c1d96183ea4b6..f39bae2388cb5 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -48,7 +48,9 @@ impl<'tcx> DebugContext<'tcx> { version: if tcx.sess.target.target.options.is_like_osx { 3 } else { - 5 + // FIXME change to version 5 once the gdb and lldb shipping with the latest debian + // support it. + 4 }, address_size, }; From 27a46ff765c26eab7b1e1f7d419cec8f5051df00 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Apr 2020 17:54:21 +0200 Subject: [PATCH 1284/1566] Rustup to rustc 1.44.0-nightly (45d050cde 2020-04-21) Remove the ` as FnOnce>::call_once` hack now that rust-lang/rust#71170 is merged. --- rust-toolchain | 2 +- src/base.rs | 81 -------------------------------------------------- 2 files changed, 1 insertion(+), 82 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 0f09fccb5cd33..f3bb3d375853d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-17 +nightly-2020-04-22 diff --git a/src/base.rs b/src/base.rs index 144199a5b4f54..6f4e60f6693af 100644 --- a/src/base.rs +++ b/src/base.rs @@ -58,92 +58,11 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( }; let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()); - let is_call_once_for_box = name.starts_with("_ZN83_$LT$alloc..boxed..Box$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$A$GT$$GT$9call_once"); 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"); - } else if is_call_once_for_box { - // HACK implement ` as FnOnce>::call_once` without `alloca`. - tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block, false)); - fx.bcx.switch_to_block(fx.block_map[START_BLOCK]); - let bb_data = &fx.mir.basic_blocks()[START_BLOCK]; - let destination = match &bb_data.terminator().kind { - TerminatorKind::Call { - func, - args, - destination, - cleanup: _, - from_hir_call: _, - } => { - assert_eq!(args.len(), 2); - - let closure_arg = Local::new(1); - let closure_local = args[0].place().unwrap().as_local().unwrap(); - assert_eq!(fx.mir.local_decls[closure_local].ty, fx.mir.local_decls[closure_arg].ty.builtin_deref(true).unwrap().ty); - let closure_deref = fx.local_map[&closure_arg].place_deref(&mut fx); - fx.local_map.insert(closure_local, closure_deref); - - let args_arg = Local::new(2); - let args_local = args[1].place().unwrap().as_local().unwrap(); - assert_eq!(fx.mir.local_decls[args_local].ty, fx.mir.local_decls[args_arg].ty); - fx.local_map.insert(args_local, fx.local_map[&args_arg]); - - fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( - &mut fx, - bb_data.terminator().source_info.span, - func, - args, - *destination, - )); - destination.map(|(_ret_place, ret_block)| ret_block) - } - _ => unreachable!(), - }; - - let destination = if let Some(destination) = destination { - fx.bcx.switch_to_block(fx.block_map[destination]); - let bb_data = &fx.mir.basic_blocks()[destination]; - match &bb_data.terminator().kind { - TerminatorKind::Call { - func, - args, - destination, - cleanup: _, - from_hir_call: _, - } => { - match destination { - Some((ret_place, _ret_block)) => { - fx.local_map.insert(ret_place.as_local().unwrap(), CPlace::no_place(fx.layout_of(fx.tcx.mk_unit()))); - } - None => {} - } - - assert_eq!(args.len(), 1); - fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( - &mut fx, - bb_data.terminator().source_info.span, - func, - args, - *destination, - )); - destination.map(|(_ret_place, ret_block)| ret_block) - } - _ => unreachable!(), - } - } else { - None - }; - - if let Some(destination) = destination { - fx.bcx.switch_to_block(fx.block_map[destination]); - let bb_data = &fx.mir.basic_blocks()[destination]; - match &bb_data.terminator().kind { - TerminatorKind::Return => crate::abi::codegen_return(&mut fx), - _ => unreachable!(), - } - } } else { tcx.sess.time("codegen clif ir", || { tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block, true)); From 6f8bfb55990f69fbe1ab96a558bfe84a2866c9d1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Apr 2020 18:02:17 +0200 Subject: [PATCH 1285/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c0a4adcd2154..2c9168855cef8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" [[package]] name = "cranelift-entity" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" [[package]] name = "cranelift-frontend" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#1845a011324d2713c1bba033a5ea84b3519fa36b" +source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" dependencies = [ "cranelift-codegen", "cranelift-module", From 169140506366d5aa96967a71b6af98563a9c2988 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Apr 2020 18:02:50 +0200 Subject: [PATCH 1286/1566] Update dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c9168855cef8..9205c8ed4a6a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,9 +32,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" +checksum = "9c9384ca4b90c0ea47e19a5c996d6643a3e73dedf9b89c65efb67587e34da1bb" [[package]] name = "cfg-if" @@ -203,15 +203,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" [[package]] name = "libloading" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c979a19ffb457f0273965c333053f3d586bf759bf7b683fbebc37f9a9ebedc4" +checksum = "3c4f51b790f5bdb65acb4cc94bb81d7b2ee60348a5431ac1467d390b017600b0" dependencies = [ "winapi", ] From b69b72973ad267086b92cac9dfb1e1f16820ddb2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 22 Apr 2020 14:48:56 +0200 Subject: [PATCH 1287/1566] Generate simple debuginfo for arguments --- src/debuginfo/mod.rs | 74 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 4fdf2f1658c23..fe56367292654 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -35,6 +35,7 @@ pub(crate) struct DebugContext<'tcx> { dwarf: DwarfUnit, unit_range_list: RangeList, + clif_types: FxHashMap, types: FxHashMap, UnitEntryId>, } @@ -116,10 +117,45 @@ impl<'tcx> DebugContext<'tcx> { dwarf, unit_range_list: RangeList(Vec::new()), + clif_types: FxHashMap::default(), types: FxHashMap::default(), } } + fn dwarf_ty_for_clif_ty(&mut self, ty: Type) -> UnitEntryId { + if let Some(type_id) = self.clif_types.get(&ty) { + return *type_id; + } + + let new_entry = |dwarf: &mut DwarfUnit, tag| dwarf.unit.add(dwarf.unit.root(), tag); + + let primitive = |dwarf: &mut DwarfUnit, ate| { + let type_id = new_entry(dwarf, gimli::DW_TAG_base_type); + let type_entry = dwarf.unit.get_mut(type_id); + type_entry.set(gimli::DW_AT_encoding, AttributeValue::Encoding(ate)); + type_id + }; + + let type_id = if ty.is_bool() { + primitive(&mut self.dwarf, gimli::DW_ATE_boolean) + } else if ty.is_int() { + primitive(&mut self.dwarf, gimli::DW_ATE_address) + } else if ty.is_float() { + primitive(&mut self.dwarf, gimli::DW_ATE_float) + } else { + new_entry(&mut self.dwarf, gimli::DW_TAG_structure_type) + }; + + let type_entry = self.dwarf.unit.get_mut(type_id); + type_entry.set(gimli::DW_AT_name, AttributeValue::String(format!("{}", ty).replace('i', "u").into_bytes())); + type_entry.set( + gimli::DW_AT_byte_size, + AttributeValue::Udata(u64::from(ty.bytes())), + ); + + type_id + } + fn dwarf_ty(&mut self, ty: Ty<'tcx>) -> UnitEntryId { if let Some(type_id) = self.types.get(ty) { return *type_id; @@ -249,11 +285,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { } fn define_local(&mut self, name: String, ty: Ty<'tcx>) -> UnitEntryId { - let ty = self.debug_context.tcx.subst_and_normalize_erasing_regions( - self.instance.substs, - ty::ParamEnv::reveal_all(), - &ty, - ); let dw_ty = self.debug_context.dwarf_ty(ty); let var_id = self @@ -290,15 +321,44 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { symbol: self.symbol, addend: 0, }, - length: end as u64, + length: u64::from(end), }); + // FIXME Remove once actual debuginfo for locals works. + for (i, (param, &val)) in context.func.signature.params.iter().zip(context.func.dfg.block_params(context.func.layout.entry_block().unwrap())).enumerate() { + use cranelift_codegen::ir::ArgumentPurpose; + let base_name = match param.purpose { + ArgumentPurpose::Normal => "arg", + ArgumentPurpose::StructReturn => "sret", + ArgumentPurpose::Link | ArgumentPurpose::FramePointer | ArgumentPurpose::CalleeSaved => continue, + ArgumentPurpose::VMContext | ArgumentPurpose::SignatureId | ArgumentPurpose::StackLimit => unreachable!(), + }; + let name = format!("{}{}", base_name, i); + + let dw_ty = self.debug_context.dwarf_ty_for_clif_ty(param.value_type); + let loc = Expression( + translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap(), + ); + + let arg_id = self.debug_context.dwarf.unit.add(self.entry_id, gimli::DW_TAG_formal_parameter); + let var_entry = self.debug_context.dwarf.unit.get_mut(arg_id); + + var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); + var_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(dw_ty)); + var_entry.set(gimli::DW_AT_location, AttributeValue::Exprloc(loc)); + } + // FIXME make it more reliable and implement scopes before re-enabling this. if false { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); for (local, _local_decl) in self.mir.local_decls.iter_enumerated() { - let var_id = self.define_local(format!("{:?}", local), &self.mir.local_decls[local].ty); + let ty = self.debug_context.tcx.subst_and_normalize_erasing_regions( + self.instance.substs, + ty::ParamEnv::reveal_all(), + &self.mir.local_decls[local].ty, + ); + let var_id = self.define_local(format!("{:?}", local), ty); let location = place_location( self, From c3180f3bd724d11600b2bb8b3b98fb61d78aa46f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 23 Apr 2020 16:44:12 +0200 Subject: [PATCH 1288/1566] Fix function arguments for gdb --- docs/dwarf.md | 132 +++++++++++++++++++++++++++++++++++++++++++ src/debuginfo/mod.rs | 14 +++++ 2 files changed, 146 insertions(+) diff --git a/docs/dwarf.md b/docs/dwarf.md index ac400bb8d0741..502b1b0362310 100644 --- a/docs/dwarf.md +++ b/docs/dwarf.md @@ -19,3 +19,135 @@ debugger won't find the line number information. On macOS the debuginfo relocati section relative and not symbol relative. See [#303 (comment)](https://github.com/bjorn3/rustc_codegen_cranelift/issues/303#issuecomment-457825535) for more information. + +# Function debuginfo + +## Tips + +`DW_TAG_subprogram` requires `DW_AT_name`, `DW_AT_low_pc` and `DW_AT_high_pc` **or** `DW_AT_ranges`. +Otherwise gdb will silently skip it. When `DW_AT_high_pc` is a length instead of an address, the +DWARF version must be at least 4. + +
+IRC log of #gdb on irc.freenode.org at 2020-04-23 + +``` +(13:46:11) bjorn3: i am writing a backend for a compiler that uses DWARF for debuginfo. for some reason gdb seems to completely ignore all DW_TAG_subprogram, while lldb works fine. any idea what the problem could be? +(13:47:49) bjorn3: this is the output of llvm-dwarfdump: https://gist.github.com/bjorn3/8a34e333c80f13cb048381e94b4a3756 +(13:47:50) osa1: luispm: why is that problem not exists in 'commands'? (the target vs. host) +(13:52:16) luispm: osa1, commands is a bit more high level. It executes isolated commands. Breakpoint conditions need to be evaluated in the context of a valid expression. That expression may involve variables, symbols etc. +(13:52:36) luispm: osa1, Oh, i see your point now. Commands is only executed on the host. +(13:53:18) luispm: osa1, The commands are not tied to the execution context of the debugged program. The breakpoint conditions determine if execution must stop or continue etc. +(13:55:00) luispm: bjorn3, Likely something GDB thinks is wrong. Does enabling "set debug dwarf*" show anything? +(13:56:01) bjorn3: luispm: no +(13:56:12) bjorn3: for more context: https://github.com/bjorn3/rustc_codegen_cranelift/pull/978 +(13:58:16) osa1 verliet de ruimte (quit: Quit: osa1). +(13:58:28) bjorn3: luispm: wait, for b m it shows nothing, but when stepping into a new function it does +(13:58:45) bjorn3: it still doesn't show anything for `info args` though +(13:58:50) bjorn3: No symbol table info available. +(14:00:50) luispm: bjorn3, Is that expected given the nature of the binary? +(14:01:17) bjorn3: b main may show nothing as I only set DW_AT_linkage_name and not DW_AT_name +(14:01:24) bjorn3: info args should work though +(14:03:26) luispm: Sorry, I'm not sure what's up. There may be a genuine bug there. +(14:03:41) luispm: tromey (not currently in the channel, but maybe later today) may have more input. +(14:04:08) bjorn3: okay, thanks luispm! +(14:04:27) luispm: In the worst case, reporting a bug may prompt someone to look into that as well. +(14:04:48) luispm: Or send an e-mail to the gdb@sourceware.org mailing list. +(14:05:11) bjorn3: I don't know if it is a bug in gdb, or just me producing (slightly) wrong DWARF +(14:39:40) irker749: gdb: tom binutils-gdb.git:master * 740480b88af / gdb/ChangeLog gdb/darwin-nat.c gdb/inferior.c gdb/inferior.h: Remove iterate_over_inferiors +(15:22:45) irker749: gdb: tromey binutils-gdb.git:master * ecc6c6066b5 / gdb/ChangeLog gdb/dwarf2/read.c gdb/unittests/lookup_name_info-selftests.c: Fix Ada crash with .debug_names +(15:23:13) bjorn3: tromey: ping +(15:23:29) tromey: bjorn3: hey +(15:24:16) bjorn3: I am writing a backend for a compiler which uses DWARF for debuginfo. I unfortunately can't get gdb to show arguments. lldb works fine. +(15:25:13) bjorn3: it just says: No symbol table info available. +(15:25:21) bjorn3: any idea what it could be? +(15:25:34) bjorn3: dwarfdump output: https://gist.github.com/bjorn3/8a34e333c80f13cb048381e94b4a3756 +(15:26:48) bjorn3: more context: https://github.com/bjorn3/rustc_codegen_cranelift/pull/978 +(15:28:05) tromey: offhand I don't know, but if you can send me an executable I can look +(15:28:17) bjorn3: how should I send it? +(15:29:26) tromey: good question +(15:29:41) tromey: you could try emailing it to tromey at adacore.com +(15:29:47) tromey: dunno if that will work or not +(15:30:26) bjorn3: i will try +(15:37:27) bjorn3: tromey: i sent an email with the subject "gdb args not showing" +(15:38:29) tromey: will check now +(15:38:40) bjorn3: thanks! +(15:42:51) irker749: gdb: tdevries binutils-gdb.git:master * de82891ce5b / gdb/ChangeLog gdb/block.c gdb/block.h gdb/symtab.c gdb/testsuite/ChangeLog gdb/testsuite/gdb.base/decl-before-def-decl.c gdb/testsuite/gdb.base/decl-before-def-def.c gdb/testsuite/gdb.base/decl-before-def.exp: [gdb/symtab] Prefer def over decl (inter-CU case) +(15:42:52) irker749: gdb: tdevries binutils-gdb.git:master * 70bc38f5138 / gdb/ChangeLog gdb/symtab.c gdb/testsuite/ChangeLog gdb/testsuite/gdb.base/decl-before-def.exp: [gdb/symtab] Prefer def over decl (inter-CU case, with context) +(15:43:36) tromey: bjorn3: sorry, got distracted. I have the file now +(15:45:35) tromey: my first thing when investigating was to enable complaints +(15:45:37) tromey: so I did +(15:45:40) tromey: set complaints 1000 +(15:45:42) tromey: then +(15:45:51) tromey: file -readnow mini_core_hello_world +(15:46:00) tromey: gdb printed just one style of complaint +(15:46:07) tromey: During symbol reading: missing name for subprogram DIE at 0x3f7 +(15:46:18) tromey: (which is really pretty good, most compilers manage to generate a bunch) +(15:46:29) tromey: and then the gdb DWARF reader says +(15:46:34) tromey: /* Ignore functions with missing or empty names. These are actually +(15:46:34) tromey: illegal according to the DWARF standard. */ +(15:46:34) tromey: if (name == NULL) +(15:46:34) tromey: { +(15:46:37) tromey: complaint (_("missing name for subprogram DIE at %s"), +(15:46:40) tromey: sect_offset_str (die->sect_off)); +(15:46:47) tromey: I wonder if that comment is correct though +(15:47:34) tromey: I guess pedantically maybe it is, DWARF 5 3.3.1 says +(15:47:43) tromey: The subroutine or entry point entry has a DW_AT_name attribute whose value is +(15:47:43) tromey: a null-terminated string containing the subroutine or entry point name. +(15:48:14) bjorn3: i tried set complaints, but it returned complaints for system files. i didn't know about file -readnow. +(15:48:21) tromey: cool +(15:48:26) bjorn3: i will try adding DW_AT_name +(15:48:45) tromey: without readnow unfortunately you get less stuff, because for whatever reason gdb has 2 separate DWARF scanners +(15:49:02) tromey: sort of anyway +(15:49:43) tromey: this seems kind of pedantic of gdb, like if there's a linkage name but no DW_AT_name, then why bail? +(15:50:01) tromey: also what about anonymous functions +(15:50:17) tromey: but anyway this explains the current situation and if you don't mind adding DW_AT_name, then that's probably simplest +(15:51:47) bjorn3: i added DW_AT_name. +(15:51:54) bjorn3: now it says cannot get low and high bounds for subprogram DIE at ... +(15:52:01) tromey: ugh +(15:52:10) bjorn3: i will add DW_AT_low_pc and DW_AT_high_pc +(15:52:15) tromey: /* Ignore functions with missing or invalid low and high pc attributes. */ +(15:52:37) tromey: you can also use DW_AT_ranges +(15:52:55) tromey: if you'd prefer +(15:53:08) bjorn3: already using DW_AT_ranges for DW_TAG_compilation_unit +(15:53:19) bjorn3: for individual functions, there are no gaps +(15:57:07) bjorn3: still the same error with DW_AT_low_pc and DW_AT_high_pc +(15:57:24) bjorn3: tromey: ^ +(15:58:08) tromey: hmmm +(15:58:30) bjorn3: should i send the new executable? +(15:58:31) tromey: send me another executable & I will debug +(15:58:33) tromey: yep +(15:59:23) bjorn3: sent as repy of the previous mail +(16:03:23) tromey: the low PC has DW_FORM_addr, but the high PC has DW_FORM_udata, which seems weird +(16:03:50) mjw: no +(16:03:54) tromey: no? +(16:04:00) mjw: I suggested that for the DWARF standard... +(16:04:05) mjw: sorry +(16:04:58) mjw: The idea was that instead of two relocations and two address wide fields, you have one address and a constant offset. +(16:05:05) tromey: ahh, I see the code now +(16:05:07) tromey: I forgot about this +(16:05:18) tromey: if (cu->header.version >= 4 && attr_high->form_is_constant ()) +(16:05:18) tromey: high += low; +(16:05:36) mjw: that second offset doesn't need a relocation and can often be packed in something small, like an uleb128 +(16:05:51) mjw: using udata might not be ideal though, but is allowed +(16:05:51) tromey: bjorn3: the problem is that this CU claims to be DWARF 3 but is using a DWARF 4 feature +(16:05:58) mjw: aha +(16:05:59) bjorn3: which one? +(16:06:03) ryoshu: hi +(16:06:08) tromey: high_pc (udata) 107 (+0x00000000000011b0 <_ZN21mini_core_hello_world5start17hec55b7ca64fc434eE>) +(16:06:08) tromey: +(16:06:12) ryoshu: just soft ping, I have a queue of patches :) +(16:06:22) tromey: using this as a length requires DWARF 4 +(16:06:36) tromey: for gdb at least it's fine to always emit DWARF 4 +(16:06:44) bjorn3: trying dwarf 4 now +(16:06:48) tromey: I think there are some DWARF 5 features still in the works but DWARF 4 should be solid AFAIK +(16:07:03) tromey: fini +(16:07:08) tromey: lol wrong window +(16:07:56) mjw: Maybe you can accept it for DWARF < 4. But if I remember correctly it might be that people might have been using udata as if it was an address... +(16:08:13) tromey: yeah, I vaguely recall this as well, though I'd expect there to be a comment +(16:08:21) mjw: Cannot really remember why it needed version >= 4. Maybe there was no good reason? +(16:08:32) bjorn3: tromey: it works!!!! thanks for all the help! +(16:08:41) tromey: my pleasure bjorn3 +``` + +
diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index fe56367292654..21618d2ded828 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -270,6 +270,11 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { .add(scope, gimli::DW_TAG_subprogram); let entry = debug_context.dwarf.unit.get_mut(entry_id); let name_id = debug_context.dwarf.strings.add(name); + // Gdb requires DW_AT_name. Otherwise the DW_TAG_subprogram is skipped. + entry.set( + gimli::DW_AT_name, + AttributeValue::StringRef(name_id), + ); entry.set( gimli::DW_AT_linkage_name, AttributeValue::StringRef(name_id), @@ -324,6 +329,15 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { length: u64::from(end), }); + let func_entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); + // Gdb requires both DW_AT_low_pc and DW_AT_high_pc. Otherwise the DW_TAG_subprogram is skipped. + func_entry.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Symbol { + symbol: self.symbol, + addend: 0, + })); + // Using Udata for DW_AT_high_pc requires at least DWARF4 + func_entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(end))); + // FIXME Remove once actual debuginfo for locals works. for (i, (param, &val)) in context.func.signature.params.iter().zip(context.func.dfg.block_params(context.func.layout.entry_block().unwrap())).enumerate() { use cranelift_codegen::ir::ArgumentPurpose; From 6b8b4e54ba96b5292487273ae8808ba0eb43228a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Apr 2020 11:42:46 +0200 Subject: [PATCH 1289/1566] Rustup to rustc 1.44.0-nightly (3360cc3a0 2020-04-24) --- rust-toolchain | 2 +- src/abi/mod.rs | 9 ++++++--- src/base.rs | 2 +- src/debuginfo/mod.rs | 2 +- src/main_shim.rs | 1 + 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index f3bb3d375853d..4d9449951493f 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-22 +nightly-2020-04-25 diff --git a/src/abi/mod.rs b/src/abi/mod.rs index dabb2b6e010c2..501cbc25a365d 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -446,8 +446,9 @@ pub(crate) fn codegen_terminator_call<'tcx>( // Handle special calls like instrinsics 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(); + let instance = ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) + .unwrap() + .unwrap(); if fx.tcx.symbol_name(instance).name.as_str().starts_with("llvm.") { crate::intrinsics::codegen_llvm_intrinsic_call( @@ -659,7 +660,9 @@ pub(crate) fn codegen_drop<'tcx>( _ => { let instance = match drop_fn_ty.kind { ty::FnDef(def_id, substs) => { - Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs).unwrap() + Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs) + .unwrap() + .unwrap() } _ => unreachable!("{:?}", drop_fn_ty), }; diff --git a/src/base.rs b/src/base.rs index 6f4e60f6693af..98951e005dba5 100644 --- a/src/base.rs +++ b/src/base.rs @@ -10,7 +10,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( ) { let tcx = cx.tcx; - let mir = *tcx.instance_mir(instance.def); + let mir = tcx.instance_mir(instance.def); // Declare function let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 21618d2ded828..4927035035dc1 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -257,7 +257,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { func_id: FuncId, name: &str, ) -> Self { - let mir = *debug_context.tcx.instance_mir(instance.def); + let mir = debug_context.tcx.instance_mir(instance.def); let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string()); diff --git a/src/main_shim.rs b/src/main_shim.rs index ab2350e0a659f..f39e07f664d4c 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -84,6 +84,7 @@ pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module Date: Sat, 25 Apr 2020 11:46:04 +0200 Subject: [PATCH 1290/1566] Update Cranelift --- Cargo.lock | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9205c8ed4a6a5..20b983f3637e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" [[package]] name = "cranelift-entity" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" [[package]] name = "cranelift-frontend" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#25cbd8b5911a05d49af695d0962b4e0d383cc5b2" +source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -277,12 +277,13 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.17" +version = "0.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ce0cd835fa6e91bbf5d010beee19d0c2e97e4ad5e13c399a31122cfc83bdd6" +checksum = "c6d7df180ed313488abdbeec2e3398f16cbf5ea6ce20db968c8cd6fc410400a9" dependencies = [ "log", "rustc-hash", + "smallvec", ] [[package]] From 9d6f65ea1408b2151c0a92ff439aef48ac5c8882 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Apr 2020 14:17:09 +0200 Subject: [PATCH 1291/1566] Implement line debuginfo for AArch64 --- src/debuginfo/line_info.rs | 69 ++++++++++++++++++++++++++------------ src/debuginfo/mod.rs | 8 ++--- 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 3c44f8ebf4cc0..0c8c10c15e20d 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -6,6 +6,7 @@ use crate::prelude::*; use rustc_span::{FileName, SourceFile, SourceFileAndLine, Pos, SourceFileHash, SourceFileHashAlgorithm}; use cranelift_codegen::binemit::CodeOffset; +use cranelift_codegen::machinst::MachSrcLoc; use gimli::write::{ Address, AttributeValue, FileId, LineProgram, LineString, FileInfo, LineStringTable, UnitEntryId, @@ -128,18 +129,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, ) -> CodeOffset { let tcx = self.debug_context.tcx; - let line_program = &mut self.debug_context.dwarf.unit.line_program; - - line_program.begin_sequence(Some(Address::Symbol { - symbol: self.symbol, - addend: 0, - })); - - let encinfo = isa.encoding_info(); let func = &context.func; - let mut blocks = func.layout.blocks().collect::>(); - blocks.sort_by_key(|block| func.offsets[*block]); // Ensure inst offsets always increase let line_strings = &mut self.debug_context.dwarf.line_strings; let function_span = self.mir.span; @@ -197,22 +188,58 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { line_program.generate_row(); }; - let mut end = 0; - for block in blocks { - for (offset, inst, size) in func.inst_offsets(block, &encinfo) { - let srcloc = func.srclocs[inst]; - line_program.row().address_offset = offset as u64; - if !srcloc.is_default() { - let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); + line_program.begin_sequence(Some(Address::Symbol { + symbol: self.symbol, + addend: 0, + })); + + let mut func_end = 0; + + if let Some(ref mcr) = &context.mach_compile_result { + for &MachSrcLoc { start, end, loc } in mcr.sections.get_srclocs_sorted() { + // FIXME get_srclocs_sorted omits default srclocs + if func_end < start { + line_program.row().address_offset = func_end as u64; + create_row_for_span(line_program, self.mir.span); + } + line_program.row().address_offset = start as u64; + if !loc.is_default() { + let source_info = *source_info_set.get_index(loc.bits() as usize).unwrap(); create_row_for_span(line_program, source_info.span); } else { create_row_for_span(line_program, self.mir.span); } - end = offset + size; + func_end = end; + } + // FIXME get_srclocs_sorted omits default srclocs + if func_end < mcr.sections.total_size() { + line_program.row().address_offset = func_end as u64; + create_row_for_span(line_program, self.mir.span); + func_end = mcr.sections.total_size(); + } + } else { + let encinfo = isa.encoding_info(); + let mut blocks = func.layout.blocks().collect::>(); + blocks.sort_by_key(|block| func.offsets[*block]); // Ensure inst offsets always increase + + for block in blocks { + for (offset, inst, size) in func.inst_offsets(block, &encinfo) { + let srcloc = func.srclocs[inst]; + line_program.row().address_offset = offset as u64; + if !srcloc.is_default() { + let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); + create_row_for_span(line_program, source_info.span); + } else { + create_row_for_span(line_program, self.mir.span); + } + func_end = offset + size; + } } } - line_program.end_sequence(end as u64); + assert_ne!(func_end, 0); + + line_program.end_sequence(func_end as u64); let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); entry.set( @@ -222,11 +249,11 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { addend: 0, }), ); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(end as u64)); + entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(func_end as u64)); self.debug_context .emit_location(self.entry_id, self.mir.span); - end + func_end } } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 4927035035dc1..fb0a8b006c1b4 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -312,10 +312,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, local_map: FxHashMap>, ) { - if isa.get_mach_backend().is_some() { - return; // The AArch64 backend doesn't support line debuginfo yet. - } - let end = self.create_debug_lines(context, isa, source_info_set); self.debug_context @@ -329,6 +325,10 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { length: u64::from(end), }); + if isa.get_mach_backend().is_some() { + return; // Not yet implemented for the AArch64 backend. + } + let func_entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); // Gdb requires both DW_AT_low_pc and DW_AT_high_pc. Otherwise the DW_TAG_subprogram is skipped. func_entry.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Symbol { From e7661d49c34a45f9da9a9b6bf0e39ce376939a64 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Apr 2020 18:23:31 +0200 Subject: [PATCH 1292/1566] Implement .eh_frame writing --- Cargo.toml | 2 +- src/backend.rs | 2 +- src/debuginfo/emit.rs | 15 ++++++++++++++- src/debuginfo/mod.rs | 18 ++++++++++++++---- src/debuginfo/unwind.rs | 31 +++++++++++++++++++++++++++++++ src/driver/aot.rs | 2 +- 6 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 src/debuginfo/unwind.rs diff --git a/Cargo.toml b/Cargo.toml index 81c2a8d5c03aa..90f5429bb0e1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/" } +cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", features = ["unwind"] } cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/" } cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/" } cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/" } diff --git a/src/backend.rs b/src/backend.rs index 319183729d141..bfc9e2d436767 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -39,7 +39,7 @@ impl WriteMetadata for object::write::Object { } pub(crate) trait WriteDebugInfo { - type SectionId; + type SectionId: Copy; fn add_debug_section(&mut self, name: SectionId, data: Vec) -> Self::SectionId; fn add_debug_reloc( diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 0c24fe359df51..e49e13a5be5a8 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -1,6 +1,6 @@ use rustc_data_structures::fx::FxHashMap; -use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer}; +use gimli::write::{Address, AttributeValue, EhFrame, EndianVec, Result, Sections, Writer, Section}; use gimli::{RunTimeEndian, SectionId}; use crate::backend::WriteDebugInfo; @@ -20,6 +20,9 @@ impl DebugContext<'_> { let mut sections = Sections::new(WriterRelocate::new(self)); self.dwarf.write(&mut sections).unwrap(); + let mut eh_frame = EhFrame::from(WriterRelocate::new(self)); + self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); + let mut section_map = FxHashMap::default(); let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { @@ -37,6 +40,16 @@ impl DebugContext<'_> { } Ok(()) }); + + if !eh_frame.0.writer.slice().is_empty() { + let id = eh_frame.id(); + let section_id = product.add_debug_section(id, eh_frame.0.writer.into_vec()); + section_map.insert(id, section_id); + + for reloc in &eh_frame.0.relocs { + product.add_debug_reloc(§ion_map, &self.symbols, §ion_id, reloc); + } + } } } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index fb0a8b006c1b4..fdc6cc911c75a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,5 +1,6 @@ mod emit; mod line_info; +mod unwind; use crate::prelude::*; @@ -10,8 +11,8 @@ use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; use gimli::write::{ - self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, - LocationList, Range, RangeList, UnitEntryId, Writer, + self, Address, AttributeValue, CieId, DwarfUnit, Expression, FrameTable, LineProgram, + LineString, Location, LocationList, Range, RangeList, UnitEntryId, Writer, }; use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; @@ -34,13 +35,15 @@ pub(crate) struct DebugContext<'tcx> { dwarf: DwarfUnit, unit_range_list: RangeList, + frame_table: FrameTable, + cie: CieId, clif_types: FxHashMap, types: FxHashMap, UnitEntryId>, } impl<'tcx> DebugContext<'tcx> { - pub(crate) fn new(tcx: TyCtxt<'tcx>, address_size: u8) -> Self { + pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self { let encoding = Encoding { format: Format::Dwarf32, // TODO: this should be configurable @@ -53,7 +56,7 @@ impl<'tcx> DebugContext<'tcx> { // support it. 4 }, - address_size, + address_size: isa.frontend_config().pointer_bytes(), }; let mut dwarf = DwarfUnit::new(encoding); @@ -108,6 +111,9 @@ impl<'tcx> DebugContext<'tcx> { ); } + let mut frame_table = FrameTable::default(); + let cie = frame_table.add_cie(isa.create_systemv_cie().expect("SystemV unwind info CIE")); + DebugContext { tcx, @@ -116,7 +122,9 @@ impl<'tcx> DebugContext<'tcx> { dwarf, unit_range_list: RangeList(Vec::new()), + frame_table, + cie, clif_types: FxHashMap::default(), types: FxHashMap::default(), } @@ -312,6 +320,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, local_map: FxHashMap>, ) { + self.create_unwind_info(context, isa); + let end = self.create_debug_lines(context, isa, source_info_set); self.debug_context diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs new file mode 100644 index 0000000000000..c0d4eb5c0edeb --- /dev/null +++ b/src/debuginfo/unwind.rs @@ -0,0 +1,31 @@ +use crate::prelude::*; + +use cranelift_codegen::isa::unwind::UnwindInfo; + +use gimli::write::Address; + +impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { + pub(super) fn create_unwind_info( + &mut self, + context: &Context, + isa: &dyn cranelift_codegen::isa::TargetIsa, + ) { + let unwind_info = if let Some(unwind_info) = context.create_unwind_info(isa).unwrap() { + unwind_info + } else { + return; + }; + + match unwind_info { + UnwindInfo::SystemV(unwind_info) => { + self.debug_context.frame_table.add_fde(self.debug_context.cie, unwind_info.to_fde(Address::Symbol { + symbol: self.symbol, + addend: 0, + })); + }, + UnwindInfo::WindowsX64(_) => { + // FIXME implement this + } + } + } +} diff --git a/src/driver/aot.rs b/src/driver/aot.rs index b74608974b7d5..6ab5b40d3ce79 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -120,7 +120,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { let debug = DebugContext::new( tcx, - module.target_config().pointer_type().bytes() as u8, + module.isa(), ); Some(debug) } else { From 7031c96fb3dc829586676d55e4d451f2c8de88bd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Apr 2020 19:07:25 +0200 Subject: [PATCH 1293/1566] Call panic lang item on failed TerminatorKind::Assert Fixes #164 --- ...itrary_self_types_pointers_and_wrappers.rs | 2 +- example/mini_core.rs | 16 ++++++-- example/mini_core_hello_world.rs | 4 +- src/abi/mod.rs | 2 +- src/base.rs | 38 +++++++++++++++---- src/common.rs | 31 +++++++++++++++ src/trap.rs | 29 +------------- 7 files changed, 79 insertions(+), 43 deletions(-) diff --git a/example/arbitrary_self_types_pointers_and_wrappers.rs b/example/arbitrary_self_types_pointers_and_wrappers.rs index 10934cebcf1ab..0b0039a1370a4 100644 --- a/example/arbitrary_self_types_pointers_and_wrappers.rs +++ b/example/arbitrary_self_types_pointers_and_wrappers.rs @@ -13,7 +13,7 @@ use mini_core::*; macro_rules! assert_eq { ($l:expr, $r: expr) => { if $l != $r { - panic(&(stringify!($l != $r), file!(), line!(), 0)); + panic(stringify!($l != $r)); } } } diff --git a/example/mini_core.rs b/example/mini_core.rs index 0c95ac6772a8d..60085d35ae164 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,7 +1,7 @@ #![feature( no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_traits, - thread_local, + thread_local, track_caller )] #![no_core] #![allow(dead_code)] @@ -394,9 +394,19 @@ pub trait FnMut: FnOnce { } #[lang = "panic"] -pub fn panic(&(_msg, _file, _line, _col): &(&'static str, &'static str, u32, u32)) -> ! { +#[track_caller] +pub fn panic(msg: &str) -> ! { unsafe { - libc::puts("Panicking\0" as *const str as *const u8); + libc::puts("Panicking\n\0" as *const str as *const u8); + intrinsics::abort(); + } +} + +#[lang = "panic_bounds_check"] +#[track_caller] +fn panic_bounds_check(index: usize, len: usize) -> ! { + unsafe { + libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index); intrinsics::abort(); } } diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 1a7534849e912..93eda4be31a9b 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -97,7 +97,7 @@ static NUM_REF: &'static u8 = unsafe { &NUM }; macro_rules! assert { ($e:expr) => { if !$e { - panic(&(stringify!(! $e), file!(), line!(), 0)); + panic(stringify!(! $e)); } }; } @@ -105,7 +105,7 @@ macro_rules! assert { macro_rules! assert_eq { ($l:expr, $r: expr) => { if $l != $r { - panic(&(stringify!($l != $r), file!(), line!(), 0)); + panic(stringify!($l != $r)); } } } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 501cbc25a365d..f4a2fd566aca3 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -206,7 +206,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { func_ref } - fn lib_call( + pub(crate) fn lib_call( &mut self, name: &str, input_tys: Vec, diff --git a/src/base.rs b/src/base.rs index 98951e005dba5..b97279fb23563 100644 --- a/src/base.rs +++ b/src/base.rs @@ -241,14 +241,36 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.bcx.ins().jump(target, &[]); fx.bcx.switch_to_block(failure); - trap_panic( - fx, - format!( - "[panic] Assert {:?} at {:?} failed.", - msg, - bb_data.terminator().source_info.span - ), - ); + + let location = fx.get_caller_location(bb_data.terminator().source_info.span).load_scalar(fx); + + let args; + let lang_item = match msg { + AssertKind::BoundsCheck { ref len, ref index } => { + let len = trans_operand(fx, len).load_scalar(fx); + let index = trans_operand(fx, index).load_scalar(fx); + args = [index, len, location]; + rustc_hir::lang_items::PanicBoundsCheckFnLangItem + } + _ => { + let msg_str = msg.description(); + let msg_ptr = fx.anonymous_str("assert", msg_str); + let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap()); + args = [msg_ptr, msg_len, location]; + rustc_hir::lang_items::PanicFnLangItem + } + }; + + let def_id = fx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { + fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) + }); + + let instance = Instance::mono(fx.tcx, def_id); + let symbol_name = fx.tcx.symbol_name(instance).name.as_str(); + + fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); + + crate::trap::trap_unreachable(fx, "panic lang item returned"); } TerminatorKind::SwitchInt { diff --git a/src/common.rs b/src/common.rs index e24eb9f0553eb..0547e02b43972 100644 --- a/src/common.rs +++ b/src/common.rs @@ -410,4 +410,35 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub(crate) fn triple(&self) -> &target_lexicon::Triple { self.module.isa().triple() } + + pub(crate) fn anonymous_str(&mut self, prefix: &str, msg: &str) -> Value { + use std::collections::hash_map::DefaultHasher; + use std::hash::{Hash, Hasher}; + + let mut hasher = DefaultHasher::new(); + msg.hash(&mut hasher); + let msg_hash = hasher.finish(); + let mut data_ctx = DataContext::new(); + data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice()); + let msg_id = self + .module + .declare_data( + &format!("__{}_{:08x}", prefix, msg_hash), + Linkage::Local, + false, + false, + None, + ) + .unwrap(); + + // Ignore DuplicateDefinition error, as the data will be the same + let _ = self.module.define_data(msg_id, &data_ctx); + + let local_msg_id = self.module.declare_data_in_func(msg_id, self.bcx.func); + #[cfg(debug_assertions)] + { + self.add_comment(local_msg_id, msg); + } + self.bcx.ins().global_value(self.pointer_type, local_msg_id) + } } diff --git a/src/trap.rs b/src/trap.rs index 2b437a0f76966..bf644cd5f2f16 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -1,6 +1,3 @@ -use std::collections::hash_map::DefaultHasher; -use std::hash::{Hash, Hasher}; - use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { @@ -24,31 +21,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let symbol_name = fx.tcx.symbol_name(fx.instance); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); - let mut hasher = DefaultHasher::new(); - real_msg.hash(&mut hasher); - let msg_hash = hasher.finish(); - let mut data_ctx = DataContext::new(); - data_ctx.define(real_msg.as_bytes().to_vec().into_boxed_slice()); - let msg_id = fx - .module - .declare_data( - &format!("__trap_{:08x}", msg_hash), - Linkage::Local, - false, - false, - None, - ) - .unwrap(); - - // Ignore DuplicateDefinition error, as the data will be the same - let _ = fx.module.define_data(msg_id, &data_ctx); - - let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); - #[cfg(debug_assertions)] - { - fx.add_comment(local_msg_id, msg); - } - let msg_ptr = fx.bcx.ins().global_value(pointer_ty(fx.tcx), local_msg_id); + let msg_ptr = fx.anonymous_str("trap", &real_msg); fx.bcx.ins().call(puts, &[msg_ptr]); } From 11a16499fecda2163a8f68192bfd336d55a9a20b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 27 Apr 2020 11:54:17 +0200 Subject: [PATCH 1294/1566] Rustup to rustc 1.45.0-nightly (e83f75634 2020-04-26) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 4d9449951493f..55eac5861a16a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-25 +nightly-2020-04-27 From 68721d4bb46cc84623acc6056fbea6e13c33190e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 27 Apr 2020 11:57:09 +0200 Subject: [PATCH 1295/1566] Update dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20b983f3637e0..8b7ded36bb385 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,9 +32,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.51" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c9384ca4b90c0ea47e19a5c996d6643a3e73dedf9b89c65efb67587e34da1bb" +checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" [[package]] name = "cfg-if" @@ -348,15 +348,15 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "smallvec" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a" +checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "syn" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" +checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" dependencies = [ "proc-macro2", "quote", From 0792280120cbb582b780974a1b90df975350f2c5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 29 Apr 2020 13:49:38 +0200 Subject: [PATCH 1296/1566] Remove some unused files --- abc.cpp | 35 ---------------------- copy.clif | 80 --------------------------------------------------- flamegraph.sh | 12 -------- 3 files changed, 127 deletions(-) delete mode 100644 abc.cpp delete mode 100644 copy.clif delete mode 100755 flamegraph.sh diff --git a/abc.cpp b/abc.cpp deleted file mode 100644 index 7f131fdd8fd78..0000000000000 --- a/abc.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// compile using g++ -std=c++11 -g -c abc.cpp -o abc.o - -struct Opaque; - -struct MyType { - unsigned int field_a; - int field_b; - void* field_c; - float field_d; - //double field_e; - //long long field_f; - bool field_g; - char field_h; - Opaque* field_i; -}; - -MyType bcd(int x, MyType a) { - MyType b = a; - MyType c = b; - MyType d = c; - MyType e = d; - MyType f = e; - MyType g = f; - MyType h = g; - MyType i = h; - MyType j = i; - MyType k = j; - MyType l = k; - MyType m = l; - return b; -} -int main() { - bcd(42, {}); - return 0; -} diff --git a/copy.clif b/copy.clif deleted file mode 100644 index e3c510d29f97f..0000000000000 --- a/copy.clif +++ /dev/null @@ -1,80 +0,0 @@ -target x86_64 - -; copy_nonoverlapping -function u0:0(i64, i64, i64) fast { - ss0 = explicit_slot 8 - ss1 = explicit_slot 8 - ss2 = explicit_slot 8 -ebb0(v0: i64, v1: i64, v2: i64): ; fn(src, dst, count) - v99 = iconst.i64 1 - jump ebb1(v0, v1, v2) - -ebb1(v10: i64, v11: i64, v12: i64): - ; if no more bytes to copy, return - brz v12, ebb2 - - ; copy one byte - v20 = uload8.i32 v10 - istore8.i32 v20, v11 - - ; increment src and dst and decrement remaining count - v30 = iadd_imm v10, 1 - v31 = iadd_imm v11, 1 - v32 = isub v12, v99 - - ; loop - jump ebb1(v30, v31, v32) - -ebb2: - return -} - -; copy -function u0:0(i64, i64, i64) fast { - ss0 = explicit_slot 8 - ss1 = explicit_slot 8 - ss2 = explicit_slot 8 -ebb0(v0: i64, v1: i64, v2: i64): ; fn(src, dst, count): - v98 = iconst.i64 8 - v99 = iconst.i64 1 - jump ebb1(v0, v1, v2) - -; copy eight bytes -ebb1(v10: i64, v11: i64, v12: i64): - ; if less than eight bytes to copy, goto ebb2 - v90 = icmp ult v12, v98 - brz v90, ebb2(v10, v11, v12) - - ; copy one byte - v80 = load.i64 v10 - store.i64 v80, v11 - - ; increment src and dst and decrement remaining count - v20 = iadd_imm v0, 1 - v21 = iadd_imm v1, 1 - v22 = isub v2, v98 - - ; loop - jump ebb1(v20, v21, v22) - -; copy one byte -ebb2(v30: i64, v31: i64, v32: i64): - ; if no more bytes to copy, return - brz v32, ebb3 - - ; copy one byte - v81 = uload8.i32 v30 - istore8.i32 v81, v31 - - ; increment src and dst and decrement remaining count - v40 = iadd_imm v30, 1 - v41 = iadd_imm v31, 1 - v42 = isub v32, v99 - - ; loop - jump ebb2(v40, v41, v42) - -; done -ebb3: - return -} \ No newline at end of file diff --git a/flamegraph.sh b/flamegraph.sh deleted file mode 100755 index ce095483ce93d..0000000000000 --- a/flamegraph.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source config.sh - -# These files grow really big (~1.4G) because of the sample frequency -rm perf.data* || true - -# Profile compiling libcore -perf record -F 9000 --call-graph dwarf \ - -- $RUSTC --crate-type lib build_sysroot/sysroot_src/src/libcore/lib.rs --crate-name core - -# Generate the flamegraph -perf script | ../FlameGraph/stackcollapse-perf.pl | grep cranelift | ../FlameGraph/flamegraph.pl > abc.svg From 12c92a32f63130c18ba06d7320d2b28a2bd76625 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Apr 2020 11:28:48 +0200 Subject: [PATCH 1297/1566] Rustup to rustc 1.45.0-nightly (fa51f810e 2020-04-29) --- example/mini_core.rs | 6 ++++++ rust-toolchain | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 60085d35ae164..8042ca8978974 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -85,6 +85,12 @@ unsafe impl Freeze for *mut T {} unsafe impl Freeze for &T {} unsafe impl Freeze for &mut T {} +#[lang = "structural_peq"] +pub trait StructuralPartialEq {} + +#[lang = "structural_teq"] +pub trait StructuralEq {} + #[lang = "not"] pub trait Not { type Output; diff --git a/rust-toolchain b/rust-toolchain index 55eac5861a16a..07c9621f2a8bd 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-27 +nightly-2020-04-30 From 9fb167e711f9470348cca422e9eacf096cac551a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Apr 2020 16:12:33 +0200 Subject: [PATCH 1298/1566] Commit missing change for rustup --- src/main_shim.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main_shim.rs b/src/main_shim.rs index f39e07f664d4c..c45b0eb8cd42e 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -8,7 +8,7 @@ pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module ( - def_id, + def_id.to_def_id(), match entry_ty { EntryFnType::Main => true, EntryFnType::Start => false, From 485e52e1539d7fb1916c201a73f3d467a18646bf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 17:51:51 +0200 Subject: [PATCH 1299/1566] Rustup to rustc 1.45.0-nightly (7ced01a73 2020-04-30) --- rust-toolchain | 2 +- src/archive.rs | 6 +++--- src/driver/aot.rs | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 07c9621f2a8bd..1bc2439682ea3 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-04-30 +nightly-2020-05-01 diff --git a/src/archive.rs b/src/archive.rs index f8ea9176fffbf..d3c24c556f361 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -4,7 +4,7 @@ use std::path::{Path, PathBuf}; use crate::prelude::*; use rustc_codegen_ssa::back::archive::{find_library, ArchiveBuilder}; -use rustc_codegen_ssa::{METADATA_FILENAME, RLIB_BYTECODE_EXTENSION}; +use rustc_codegen_ssa::METADATA_FILENAME; struct ArchiveConfig<'a> { sess: &'a Session, @@ -116,8 +116,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let obj_start = name.to_owned(); self.add_archive(rlib.to_owned(), move |fname: &str| { - // Ignore bytecode/metadata files, no matter the name. - if fname.ends_with(RLIB_BYTECODE_EXTENSION) || fname == METADATA_FILENAME { + // Ignore metadata files, no matter the name. + if fname == METADATA_FILENAME { return true; } diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 6ab5b40d3ce79..76bd614b16486 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -64,7 +64,6 @@ fn emit_module( kind, object: Some(tmp_file), bytecode: None, - bytecode_compressed: None, }, work_product, ) @@ -85,7 +84,7 @@ fn reuse_workproduct_for_cgu( object = Some(path.clone()); path } - WorkProductFileKind::Bytecode | WorkProductFileKind::BytecodeCompressed => { + WorkProductFileKind::Bytecode => { panic!("cg_clif doesn't use bytecode"); } }; @@ -107,7 +106,6 @@ fn reuse_workproduct_for_cgu( kind: ModuleKind::Regular, object, bytecode: None, - bytecode_compressed: None, } } @@ -239,7 +237,6 @@ pub(super) fn run_aot( kind: ModuleKind::Metadata, object: Some(tmp_file), bytecode: None, - bytecode_compressed: None, }) } else { None From 4da6488d95cec9709bf77a28913c8040cc0508ee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 19:21:29 +0200 Subject: [PATCH 1300/1566] Always emit .eh_frame section --- src/backend.rs | 6 ++--- src/base.rs | 2 ++ src/debuginfo/emit.rs | 29 ++++++--------------- src/debuginfo/mod.rs | 18 +++---------- src/debuginfo/unwind.rs | 56 +++++++++++++++++++++++++++++++++-------- src/driver/aot.rs | 12 ++++++++- src/driver/jit.rs | 5 +++- src/driver/mod.rs | 3 ++- src/lib.rs | 5 +++- 9 files changed, 82 insertions(+), 54 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index bfc9e2d436767..5077c77ec3379 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,4 +1,4 @@ -use std::convert::TryFrom; +use std::convert::{TryFrom, TryInto}; use rustc_data_structures::fx::FxHashMap; use rustc_session::Session; @@ -45,7 +45,6 @@ pub(crate) trait WriteDebugInfo { fn add_debug_reloc( &mut self, section_map: &FxHashMap, - symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ); @@ -75,7 +74,6 @@ impl WriteDebugInfo for ObjectProduct { fn add_debug_reloc( &mut self, section_map: &FxHashMap, - symbol_map: &indexmap::IndexMap, from: &Self::SectionId, reloc: &DebugReloc, ) { @@ -84,7 +82,7 @@ impl WriteDebugInfo for ObjectProduct { (section_map.get(&id).unwrap().1, 0) } DebugRelocName::Symbol(id) => { - let symbol_id = self.function_symbol(*symbol_map.get_index(id).unwrap().0); + let symbol_id = self.function_symbol(FuncId::from_u32(id.try_into().unwrap())); self.object.symbol_section_and_offset(symbol_id).expect("Debug reloc for undef sym???") } }; diff --git a/src/base.rs b/src/base.rs index b97279fb23563..cbef8d288c8e3 100644 --- a/src/base.rs +++ b/src/base.rs @@ -124,10 +124,12 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( // Define debuginfo for function let isa = cx.module.isa(); + let unwind_context = &mut cx.unwind_context; tcx.sess.time("generate debug info", || { debug_context .as_mut() .map(|x| x.define(context, isa, &source_info_set, local_map)); + unwind_context.add_function(func_id, &context, isa); }); // Clear context to make it usable for the next function diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index e49e13a5be5a8..af93620fa8a9f 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -1,6 +1,6 @@ use rustc_data_structures::fx::FxHashMap; -use gimli::write::{Address, AttributeValue, EhFrame, EndianVec, Result, Sections, Writer, Section}; +use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer}; use gimli::{RunTimeEndian, SectionId}; use crate::backend::WriteDebugInfo; @@ -17,12 +17,9 @@ impl DebugContext<'_> { AttributeValue::RangeListRef(unit_range_list_id), ); - let mut sections = Sections::new(WriterRelocate::new(self)); + let mut sections = Sections::new(WriterRelocate::new(self.endian)); self.dwarf.write(&mut sections).unwrap(); - let mut eh_frame = EhFrame::from(WriterRelocate::new(self)); - self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); - let mut section_map = FxHashMap::default(); let _: Result<()> = sections.for_each_mut(|id, section| { if !section.writer.slice().is_empty() { @@ -35,21 +32,11 @@ impl DebugContext<'_> { let _: Result<()> = sections.for_each(|id, section| { if let Some(section_id) = section_map.get(&id) { for reloc in §ion.relocs { - product.add_debug_reloc(§ion_map, &self.symbols, section_id, reloc); + product.add_debug_reloc(§ion_map, section_id, reloc); } } Ok(()) }); - - if !eh_frame.0.writer.slice().is_empty() { - let id = eh_frame.id(); - let section_id = product.add_debug_section(id, eh_frame.0.writer.into_vec()); - section_map.insert(id, section_id); - - for reloc in &eh_frame.0.relocs { - product.add_debug_reloc(§ion_map, &self.symbols, §ion_id, reloc); - } - } } } @@ -68,16 +55,16 @@ pub(crate) enum DebugRelocName { } #[derive(Clone)] -struct WriterRelocate { - relocs: Vec, - writer: EndianVec, +pub(super) struct WriterRelocate { + pub(super) relocs: Vec, + pub(super) writer: EndianVec, } impl WriterRelocate { - fn new(ctx: &DebugContext<'_>) -> Self { + pub(super) fn new(endian: RunTimeEndian) -> Self { WriterRelocate { relocs: Vec::new(), - writer: EndianVec::new(ctx.endian), + writer: EndianVec::new(endian), } } } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index fdc6cc911c75a..2a360dd00c282 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -11,12 +11,13 @@ use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; use gimli::write::{ - self, Address, AttributeValue, CieId, DwarfUnit, Expression, FrameTable, LineProgram, + self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, LocationList, Range, RangeList, UnitEntryId, Writer, }; use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; pub(crate) use emit::{DebugReloc, DebugRelocName}; +pub(crate) use unwind::UnwindContext; fn target_endian(tcx: TyCtxt<'_>) -> RunTimeEndian { use rustc_target::abi::Endian; @@ -31,13 +32,10 @@ pub(crate) struct DebugContext<'tcx> { tcx: TyCtxt<'tcx>, endian: RunTimeEndian, - symbols: indexmap::IndexMap, dwarf: DwarfUnit, unit_range_list: RangeList, - frame_table: FrameTable, - cie: CieId, clif_types: FxHashMap, types: FxHashMap, UnitEntryId>, } @@ -111,20 +109,14 @@ impl<'tcx> DebugContext<'tcx> { ); } - let mut frame_table = FrameTable::default(); - let cie = frame_table.add_cie(isa.create_systemv_cie().expect("SystemV unwind info CIE")); - DebugContext { tcx, endian: target_endian(tcx), - symbols: indexmap::IndexMap::new(), dwarf, unit_range_list: RangeList(Vec::new()), - frame_table, - cie, clif_types: FxHashMap::default(), types: FxHashMap::default(), } @@ -267,8 +259,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { ) -> Self { let mir = debug_context.tcx.instance_mir(instance.def); - let (symbol, _) = debug_context.symbols.insert_full(func_id, name.to_string()); - // FIXME: add to appropriate scope intead of root let scope = debug_context.dwarf.unit.root(); @@ -291,7 +281,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { FunctionDebugContext { debug_context, entry_id, - symbol, + symbol: func_id.as_u32() as usize, instance, mir, } @@ -320,8 +310,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { source_info_set: &indexmap::IndexSet, local_map: FxHashMap>, ) { - self.create_unwind_info(context, isa); - let end = self.create_debug_lines(context, isa, source_info_set); self.debug_context diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index c0d4eb5c0edeb..987c4d8f3e8ca 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -1,15 +1,35 @@ use crate::prelude::*; -use cranelift_codegen::isa::unwind::UnwindInfo; +use cranelift_codegen::isa::{TargetIsa, unwind::UnwindInfo}; -use gimli::write::Address; +use gimli::write::{Address, CieId, EhFrame, FrameTable, Section}; -impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { - pub(super) fn create_unwind_info( - &mut self, - context: &Context, - isa: &dyn cranelift_codegen::isa::TargetIsa, - ) { +use crate::backend::WriteDebugInfo; + +pub(crate) struct UnwindContext<'tcx> { + tcx: TyCtxt<'tcx>, + frame_table: FrameTable, + cie_id: CieId, +} + +impl<'tcx> UnwindContext<'tcx> { + pub(crate) fn new( + tcx: TyCtxt<'tcx>, + module: &mut Module, + ) -> Self { + let mut frame_table = FrameTable::default(); + let cie = module.isa().create_systemv_cie().expect("SystemV unwind info CIE"); + + let cie_id = frame_table.add_cie(cie); + + UnwindContext { + tcx, + frame_table, + cie_id, + } + } + + pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) { let unwind_info = if let Some(unwind_info) = context.create_unwind_info(isa).unwrap() { unwind_info } else { @@ -18,8 +38,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { match unwind_info { UnwindInfo::SystemV(unwind_info) => { - self.debug_context.frame_table.add_fde(self.debug_context.cie, unwind_info.to_fde(Address::Symbol { - symbol: self.symbol, + self.frame_table.add_fde(self.cie_id, unwind_info.to_fde(Address::Symbol { + symbol: func_id.as_u32() as usize, addend: 0, })); }, @@ -28,4 +48,20 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { } } } + + pub(crate) fn emit(self, product: &mut P) { + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); + self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); + + if !eh_frame.0.writer.slice().is_empty() { + let id = eh_frame.id(); + let section_id = product.add_debug_section(id, eh_frame.0.writer.into_vec()); + let mut section_map = FxHashMap::default(); + section_map.insert(id, section_id); + + for reloc in &eh_frame.0.relocs { + product.add_debug_reloc(§ion_map, §ion_id, reloc); + } + } + } } diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 76bd614b16486..9454f43f23ade 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -32,6 +32,7 @@ fn emit_module( kind: ModuleKind, mut module: Module, debug: Option>, + unwind_context: UnwindContext<'_>, ) -> ModuleCodegenResult where B::Product: Emit + WriteDebugInfo, { @@ -42,6 +43,8 @@ fn emit_module( debug.emit(&mut product); } + unwind_context.emit(&mut product); + let tmp_file = tcx .output_filenames(LOCAL_CRATE) .temp_path(OutputType::Object, Some(&name)); @@ -125,7 +128,9 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege None }; - super::codegen_mono_items(tcx, &mut module, debug.as_mut(), mono_items); + let mut unwind_context = UnwindContext::new(tcx, &mut module); + + super::codegen_mono_items(tcx, &mut module, debug.as_mut(), &mut unwind_context, mono_items); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); emit_module( @@ -134,6 +139,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege ModuleKind::Regular, module, debug, + unwind_context, ) } @@ -190,12 +196,16 @@ pub(super) fn run_aot( let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module); let allocator_module = if created_alloc_shim { + // FIXME create .eh_frame for allocator shim + let unwind_context = UnwindContext::new(tcx, &mut allocator_module); + let ModuleCodegenResult(module, work_product) = emit_module( tcx, "allocator_shim".to_string(), ModuleKind::Allocator, allocator_module, None, + unwind_context, ); if let Some((id, product)) = work_product { work_products.insert(id, product); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index a5dca71c330fc..4d7ca34d1ba39 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -52,8 +52,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { .into_iter() .collect::>(); + // FIXME register with unwind runtime + let mut unwind_context = UnwindContext::new(tcx, &mut jit_module); + super::time(tcx, "codegen mono items", || { - super::codegen_mono_items(tcx, &mut jit_module, None, mono_items); + super::codegen_mono_items(tcx, &mut jit_module, None, &mut unwind_context, mono_items); }); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); crate::allocator::codegen(tcx, &mut jit_module); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 6aa736d18ce6e..bf3241b8834cc 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -33,9 +33,10 @@ fn codegen_mono_items<'tcx>( tcx: TyCtxt<'tcx>, module: &mut Module, debug_context: Option<&mut DebugContext<'tcx>>, + unwind_context: &mut UnwindContext<'tcx>, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { - let mut cx = CodegenCx::new(tcx, module, debug_context); + let mut cx = CodegenCx::new(tcx, module, debug_context, unwind_context); tcx.sess.time("predefine functions", || { for &(mono_item, (linkage, visibility)) in &mono_items { diff --git a/src/lib.rs b/src/lib.rs index d679b4d7930c7..8af309a22bac7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,7 +106,7 @@ mod prelude { pub(crate) use crate::base::{trans_operand, trans_place}; pub(crate) use crate::cast::*; pub(crate) use crate::common::*; - pub(crate) use crate::debuginfo::{DebugContext, FunctionDebugContext}; + pub(crate) use crate::debuginfo::{DebugContext, FunctionDebugContext, UnwindContext}; pub(crate) use crate::pointer::Pointer; pub(crate) use crate::trap::*; pub(crate) use crate::value_and_place::{CPlace, CPlaceInner, CValue}; @@ -133,6 +133,7 @@ pub(crate) struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { cached_context: Context, vtables: FxHashMap<(Ty<'tcx>, Option>), DataId>, debug_context: Option<&'clif mut DebugContext<'tcx>>, + unwind_context: &'clif mut UnwindContext<'tcx>, } impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { @@ -140,6 +141,7 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { tcx: TyCtxt<'tcx>, module: &'clif mut Module, debug_context: Option<&'clif mut DebugContext<'tcx>>, + unwind_context: &'clif mut UnwindContext<'tcx>, ) -> Self { CodegenCx { tcx, @@ -148,6 +150,7 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { cached_context: Context::new(), vtables: FxHashMap::default(), debug_context, + unwind_context, } } From 020bcb31dbb1e6a96575806a560bdc082bfa2bb6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 20:57:51 +0200 Subject: [PATCH 1301/1566] Register frame table in JIT mode --- Cargo.lock | 1 + Cargo.toml | 1 + src/debuginfo/emit.rs | 21 ++++++++++ src/debuginfo/unwind.rs | 85 +++++++++++++++++++++++++++++++++++++++++ src/driver/jit.rs | 2 + 5 files changed, 110 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 8b7ded36bb385..66d4be9cfbffb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,6 +310,7 @@ version = "0.1.0" dependencies = [ "ar", "byteorder", + "cfg-if", "cranelift-codegen", "cranelift-frontend", "cranelift-module", diff --git a/Cargo.toml b/Cargo.toml index 90f5429bb0e1c..e9e6008f6cf38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ target-lexicon = "0.10.0" ar = "0.8.0" byteorder = "1.2.7" indexmap = "1.0.2" +cfg-if = "0.1.10" [dependencies.object] version = "0.18.0" diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index af93620fa8a9f..9cce630fed52f 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -1,3 +1,5 @@ +use std::convert::TryInto; + use rustc_data_structures::fx::FxHashMap; use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer}; @@ -67,6 +69,25 @@ impl WriterRelocate { writer: EndianVec::new(endian), } } + + pub(super) fn relocate_for_jit( + mut self, + jit_module: &mut cranelift_module::Module, + ) -> Vec { + for reloc in self.relocs.drain(..) { + match reloc.name { + super::DebugRelocName::Section(_) => unreachable!(), + super::DebugRelocName::Symbol(sym) => { + let addr = jit_module.get_finalized_function( + cranelift_module::FuncId::from_u32(sym.try_into().unwrap()), + ); + let val = (addr as u64 as i64 + reloc.addend) as u64; + self.writer.write_udata_at(reloc.offset as usize, val, reloc.size).unwrap(); + } + } + } + self.writer.into_vec() + } } impl Writer for WriterRelocate { diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 987c4d8f3e8ca..83795961377b0 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -64,4 +64,89 @@ impl<'tcx> UnwindContext<'tcx> { } } } + + pub(crate) unsafe fn register_jit( + self, + jit_module: &mut Module, + ) -> Option { + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); + self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); + + if eh_frame.0.writer.slice().is_empty() { + return None; + } + + let mut eh_frame = eh_frame.0.relocate_for_jit(jit_module); + + // GCC expects a terminating "empty" length, so write a 0 length at the end of the table. + eh_frame.extend(&[0, 0, 0, 0]); + + let mut registrations = Vec::new(); + + // ======================================================================= + // Everything after this line up to the end of the file is loosly based on + // https://github.com/bytecodealliance/wasmtime/blob/4471a82b0c540ff48960eca6757ccce5b1b5c3e4/crates/jit/src/unwind/systemv.rs + cfg_if::cfg_if! { + if #[cfg(target_os = "macos")] { + // On macOS, `__register_frame` takes a pointer to a single FDE + let start = eh_frame.as_ptr(); + let end = start.add(eh_frame.len()); + let mut current = start; + + // Walk all of the entries in the frame table and register them + while current < end { + let len = std::ptr::read::(current as *const u32) as usize; + + // Skip over the CIE + if current != start { + __register_frame(current); + registrations.push(current as usize); + } + + // Move to the next table entry (+4 because the length itself is not inclusive) + current = current.add(len + 4); + } + } else { + // On other platforms, `__register_frame` will walk the FDEs until an entry of length 0 + let ptr = eh_frame.as_ptr(); + __register_frame(ptr); + registrations.push(ptr as usize); + } + } + + Some(UnwindRegistry { + _frame_table: eh_frame, + registrations, + }) + } +} + +/// Represents a registry of function unwind information for System V ABI. +pub(crate) struct UnwindRegistry { + _frame_table: Vec, + registrations: Vec, +} + +extern "C" { + // libunwind import + fn __register_frame(fde: *const u8); + fn __deregister_frame(fde: *const u8); +} + +impl Drop for UnwindRegistry { + fn drop(&mut self) { + unsafe { + // libgcc stores the frame entries as a linked list in decreasing sort order + // based on the PC value of the registered entry. + // + // As we store the registrations in increasing order, it would be O(N^2) to + // deregister in that order. + // + // To ensure that we just pop off the first element in the list upon every + // deregistration, walk our list of registrations backwards. + for fde in self.registrations.iter().rev() { + __deregister_frame(*fde as *const _); + } + } + } } diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 4d7ca34d1ba39..08d21b5cc9f6b 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -63,6 +63,8 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { jit_module.finalize_definitions(); + let _unwind_register_guard = unsafe { unwind_context.register_jit(&mut jit_module) }; + tcx.sess.abort_if_errors(); let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); From 875b5f7b349cb5ebb44bda2ebdcfd0b53c1ec275 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 4 May 2020 05:27:24 +0000 Subject: [PATCH 1302/1566] Bump cranelift-codegen from `ebd13ce` to `c284ffe` Bumps [cranelift-codegen](https://github.com/bytecodealliance/wasmtime) from `ebd13ce` to `c284ffe`. - [Release notes](https://github.com/bytecodealliance/wasmtime/releases) - [Commits](https://github.com/bytecodealliance/wasmtime/compare/ebd13cee05192d36ad7f62740f2215e1845d9f8b...c284ffe6c036b8058228d576c46688968629b48c) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66d4be9cfbffb..6a5f33c087ac7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,16 +44,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,8 +70,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,18 +79,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" [[package]] name = "cranelift-entity" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" [[package]] name = "cranelift-frontend" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "cranelift-codegen", "log", @@ -100,8 +100,8 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,8 +112,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,8 +122,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,8 +133,8 @@ dependencies = [ [[package]] name = "cranelift-simplejit" -version = "0.62.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ebd13cee05192d36ad7f62740f2215e1845d9f8b" +version = "0.63.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -277,9 +277,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.18" +version = "0.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6d7df180ed313488abdbeec2e3398f16cbf5ea6ce20db968c8cd6fc410400a9" +checksum = "b27b256b41986ac5141b37b8bbba85d314fbf546c182eb255af6720e07e4f804" dependencies = [ "log", "rustc-hash", From 6f9a4fda3a50a376d64ab852df90e77a2fb081c1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 5 May 2020 12:03:27 +0200 Subject: [PATCH 1303/1566] Set RUSTDOCFLAGS Fixes #969 --- cargo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cargo.sh b/cargo.sh index 9b83deaf7ab98..3e756696d9c21 100755 --- a/cargo.sh +++ b/cargo.sh @@ -20,4 +20,4 @@ fi cmd=$1 shift -cargo +${TOOLCHAIN} $cmd --target $TARGET_TRIPLE $@ +RUSTDOCFLAGS=$RUSTFLAGS cargo +${TOOLCHAIN} $cmd --target $TARGET_TRIPLE $@ From f8add1960ab7867286e22711fdd3abf0dc0bdf1d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 5 May 2020 12:06:15 +0200 Subject: [PATCH 1304/1566] Document running rust code from the shell --- Readme.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index ba56e57649868..e850b320fe282 100644 --- a/Readme.md +++ b/Readme.md @@ -13,7 +13,7 @@ $ ./test.sh --release ## Usage -`$cg_clif_dir` is the directory you cloned this repo into in the following instruction. +`$cg_clif_dir` is the directory you cloned this repo into in the following instructions. ### Cargo @@ -31,6 +31,24 @@ If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./tes $ rustc +$(cat $cg_clif_dir/rust-toolchain) -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs ``` +### Shell + +These are a few functions that allow you to easily run rust code from the shell using cg_clif as jit. + +```bash +function jit_naked() { + echo "$@" | CG_CLIF_JIT=1 rustc -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot - -Cprefer-dynamic +} + +function jit() { + jit_naked "fn main() { $@ }" +} + +function jit_calc() { + jit 'println!("0x{:x}", ' $@ ');'; +} +``` + ## Env vars
From 27cc90effa886046754d15255303c6510b92df45 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 5 May 2020 12:16:28 +0200 Subject: [PATCH 1305/1566] Improvements for latest Cranelift --- src/debuginfo/line_info.rs | 18 +++++------------- src/debuginfo/unwind.rs | 12 ++++++++---- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 0c8c10c15e20d..92a9de1e17667 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -197,11 +197,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { if let Some(ref mcr) = &context.mach_compile_result { for &MachSrcLoc { start, end, loc } in mcr.sections.get_srclocs_sorted() { - // FIXME get_srclocs_sorted omits default srclocs - if func_end < start { - line_program.row().address_offset = func_end as u64; - create_row_for_span(line_program, self.mir.span); - } line_program.row().address_offset = start as u64; if !loc.is_default() { let source_info = *source_info_set.get_index(loc.bits() as usize).unwrap(); @@ -211,12 +206,10 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { } func_end = end; } - // FIXME get_srclocs_sorted omits default srclocs - if func_end < mcr.sections.total_size() { - line_program.row().address_offset = func_end as u64; - create_row_for_span(line_program, self.mir.span); - func_end = mcr.sections.total_size(); - } + + line_program.end_sequence(func_end as u64); + + func_end = mcr.sections.total_size(); } else { let encinfo = isa.encoding_info(); let mut blocks = func.layout.blocks().collect::>(); @@ -235,12 +228,11 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { func_end = offset + size; } } + line_program.end_sequence(func_end as u64); } assert_ne!(func_end, 0); - line_program.end_sequence(func_end as u64); - let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); entry.set( gimli::DW_AT_low_pc, diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 83795961377b0..a0f933d7c62b1 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -9,7 +9,7 @@ use crate::backend::WriteDebugInfo; pub(crate) struct UnwindContext<'tcx> { tcx: TyCtxt<'tcx>, frame_table: FrameTable, - cie_id: CieId, + cie_id: Option, } impl<'tcx> UnwindContext<'tcx> { @@ -18,9 +18,13 @@ impl<'tcx> UnwindContext<'tcx> { module: &mut Module, ) -> Self { let mut frame_table = FrameTable::default(); - let cie = module.isa().create_systemv_cie().expect("SystemV unwind info CIE"); - let cie_id = frame_table.add_cie(cie); + + let cie_id = if let Some(cie) = module.isa().create_systemv_cie() { + Some(frame_table.add_cie(cie)) + } else { + None + }; UnwindContext { tcx, @@ -38,7 +42,7 @@ impl<'tcx> UnwindContext<'tcx> { match unwind_info { UnwindInfo::SystemV(unwind_info) => { - self.frame_table.add_fde(self.cie_id, unwind_info.to_fde(Address::Symbol { + self.frame_table.add_fde(self.cie_id.unwrap(), unwind_info.to_fde(Address::Symbol { symbol: func_id.as_u32() as usize, addend: 0, })); From c7e0dde38a87638683561b50d1bc52832660726f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 9 May 2020 14:14:45 +0200 Subject: [PATCH 1306/1566] Rustup to rustc 1.45.0-nightly (7ebd87a7a 2020-05-08) --- rust-toolchain | 2 +- src/driver/aot.rs | 20 ++++++-------------- src/lib.rs | 18 +++++++----------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 1bc2439682ea3..e40c16e06f2c7 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-05-01 +nightly-2020-05-09 diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 9454f43f23ade..91b4b51e84b5f 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -1,4 +1,4 @@ -use rustc_middle::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId}; +use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::middle::cstore::EncodedMetadata; use rustc_middle::mir::mono::CodegenUnit; use rustc_session::config::{DebugInfo, OutputType}; @@ -57,7 +57,7 @@ fn emit_module( rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( tcx.sess, &name, - &[(WorkProductFileKind::Object, tmp_file.clone())], + &[tmp_file.clone()], ) }; @@ -80,17 +80,9 @@ fn reuse_workproduct_for_cgu( let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); let mut object = None; let work_product = cgu.work_product(tcx); - for (kind, saved_file) in &work_product.saved_files { - let obj_out = match kind { - WorkProductFileKind::Object => { - let path = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); - object = Some(path.clone()); - path - } - WorkProductFileKind::Bytecode => { - panic!("cg_clif doesn't use bytecode"); - } - }; + for saved_file in &work_product.saved_files { + let obj_out = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); + object = Some(obj_out.clone()); let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { tcx.sess.err(&format!( @@ -160,7 +152,7 @@ pub(super) fn run_aot( if tcx.dep_graph.is_fully_enabled() { for cgu in &*cgus { - tcx.codegen_unit(cgu.name()); + tcx.ensure().codegen_unit(cgu.name()); } } diff --git a/src/lib.rs b/src/lib.rs index 8af309a22bac7..4e3fbc3eaaa40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,18 +178,14 @@ impl CodegenBackend for CraneliftCodegenBackend { if tcx.sess.opts.actually_rustdoc { // rustdoc needs to be able to document functions that use all the features, so // whitelist them all - tcx.arena.alloc( - target_features_whitelist::all_known_features() - .map(|(a, b)| (a.to_string(), b)) - .collect(), - ) + target_features_whitelist::all_known_features() + .map(|(a, b)| (a.to_string(), b)) + .collect() } else { - tcx.arena.alloc( - target_features_whitelist::target_feature_whitelist(tcx.sess) - .iter() - .map(|&(a, b)| (a.to_string(), b)) - .collect(), - ) + target_features_whitelist::target_feature_whitelist(tcx.sess) + .iter() + .map(|&(a, b)| (a.to_string(), b)) + .collect() } }; } From fa57d9d0dbbf9e3b342cf324313cd019bcc5f4f1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 10 May 2020 15:18:26 +0200 Subject: [PATCH 1307/1566] Update Cranelift --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6a5f33c087ac7..21f02a017b162 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" [[package]] name = "cranelift-entity" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" [[package]] name = "cranelift-frontend" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c284ffe6c036b8058228d576c46688968629b48c" +source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -277,9 +277,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.21" +version = "0.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b27b256b41986ac5141b37b8bbba85d314fbf546c182eb255af6720e07e4f804" +checksum = "b36727ea09f6e363ddebb29b2d2620052267cc1fc6e0da7da63317938eb4104c" dependencies = [ "log", "rustc-hash", From ac14f8d4ded829c0ea80367f4cfdcecb7be9a5b5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 10 May 2020 15:35:32 +0200 Subject: [PATCH 1308/1566] Update dependencies --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21f02a017b162..6750f697c6d6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,9 +209,9 @@ checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" [[package]] name = "libloading" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c4f51b790f5bdb65acb4cc94bb81d7b2ee60348a5431ac1467d390b017600b0" +checksum = "2cadb8e769f070c45df05c78c7520eb4cd17061d4ab262e43cfc68b4d00ac71c" dependencies = [ "winapi", ] @@ -248,18 +248,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3" +checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f" +checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" dependencies = [ "proc-macro2", ] @@ -355,9 +355,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "syn" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" +checksum = "e8e5aa70697bb26ee62214ae3288465ecec0000f05182f039b477001f08f5ae7" dependencies = [ "proc-macro2", "quote", @@ -372,18 +372,18 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "thiserror" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b3d3d2ff68104100ab257bb6bb0cb26c901abe4bd4ba15961f3bf867924012" +checksum = "d12a1dae4add0f0d568eebc7bf142f145ba1aa2544cafb195c76f0f409091b60" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca972988113b7715266f91250ddb98070d033c62a011fa0fcc57434a649310dd" +checksum = "3f34e0c1caaa462fd840ec6b768946ea1e7842620d94fe29d5b847138f521269" dependencies = [ "proc-macro2", "quote", From 2e5282f9293b174cad733a14d7a9769ec9f89016 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 10 May 2020 17:36:13 +0200 Subject: [PATCH 1309/1566] [CI] Hash Cargo.lock in addition to toolchain for target dir cache --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91e4c9ced3443..29c848bdf9eff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,7 +43,7 @@ jobs: uses: actions/cache@v1.1.2 with: path: target - key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain') }} + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} - name: Prepare dependencies run: | From bcd357a0ae1fab1efabf9bed7435cf19e615948f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 18 May 2020 11:35:23 +0200 Subject: [PATCH 1310/1566] Rustup to rustc 1.45.0-nightly (46e85b432 2020-05-24) --- .gitignore | 2 - build_sysroot/Cargo.lock | 290 +++++++++++++++++++++++++++++++++ build_sysroot/Cargo.toml | 2 + build_sysroot/build_sysroot.sh | 1 - clean_all.sh | 2 +- prepare.sh | 2 +- rust-toolchain | 2 +- rustup.sh | 5 +- src/archive.rs | 2 +- src/base.rs | 51 +++--- src/constant.rs | 12 +- src/driver/aot.rs | 6 +- src/driver/mod.rs | 2 +- src/intrinsics/mod.rs | 1 + src/metadata.rs | 3 +- 15 files changed, 335 insertions(+), 48 deletions(-) create mode 100644 build_sysroot/Cargo.lock diff --git a/.gitignore b/.gitignore index c301db32b72ad..e98128dd09e13 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,5 @@ perf.data.old *.string* /build_sysroot/sysroot /build_sysroot/sysroot_src -/build_sysroot/Cargo.lock -/build_sysroot/test_target/Cargo.lock /rust /regex diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock new file mode 100644 index 0000000000000..1fee499763f23 --- /dev/null +++ b/build_sysroot/Cargo.lock @@ -0,0 +1,290 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "alloc" +version = "0.0.0" +dependencies = [ + "compiler_builtins", + "core", +] + +[[package]] +name = "alloc_system" +version = "0.0.0" +dependencies = [ + "compiler_builtins", + "core", + "libc", +] + +[[package]] +name = "autocfg" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" + +[[package]] +name = "backtrace" +version = "0.3.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130" +dependencies = [ + "backtrace-sys", + "cfg-if", + "compiler_builtins", + "libc", + "rustc-demangle", + "rustc-std-workspace-core", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" +dependencies = [ + "cc", + "compiler_builtins", + "libc", + "rustc-std-workspace-core", +] + +[[package]] +name = "cc" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + +[[package]] +name = "compiler_builtins" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439a6fab343b1dab347823537734a5cd4ae6ae2000b465ab886f64cdb723bd14" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "core" +version = "0.0.0" + +[[package]] +name = "dlmalloc" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35055b1021724f4eb5262eb49130eebff23fc59fc5a14160e05faad8eeb36673" +dependencies = [ + "compiler_builtins", + "libc", + "rustc-std-workspace-core", +] + +[[package]] +name = "fortanix-sgx-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56c422ef86062869b2d57ae87270608dc5929969dd130a6e248979cf4fb6ca6" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "rustc-std-workspace-core", + "rustc-std-workspace-std", + "unicode-width", +] + +[[package]] +name = "hashbrown" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" +dependencies = [ + "autocfg", + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "hermit-abi" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" +dependencies = [ + "compiler_builtins", + "libc", + "rustc-std-workspace-core", +] + +[[package]] +name = "libc" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "panic_abort" +version = "0.0.0" +dependencies = [ + "compiler_builtins", + "core", + "libc", +] + +[[package]] +name = "panic_unwind" +version = "0.0.0" +dependencies = [ + "alloc", + "cfg-if", + "compiler_builtins", + "core", + "libc", + "unwind", +] + +[[package]] +name = "proc_macro" +version = "0.0.0" +dependencies = [ + "std", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + +[[package]] +name = "rustc-std-workspace-alloc" +version = "1.99.0" +dependencies = [ + "alloc", +] + +[[package]] +name = "rustc-std-workspace-core" +version = "1.99.0" +dependencies = [ + "core", +] + +[[package]] +name = "rustc-std-workspace-std" +version = "1.99.0" +dependencies = [ + "std", +] + +[[package]] +name = "std" +version = "0.0.0" +dependencies = [ + "alloc", + "backtrace", + "cfg-if", + "compiler_builtins", + "core", + "dlmalloc", + "fortanix-sgx-abi", + "hashbrown", + "hermit-abi", + "libc", + "panic_abort", + "panic_unwind", + "unwind", + "wasi", +] + +[[package]] +name = "sysroot" +version = "0.0.0" +dependencies = [ + "alloc", + "alloc_system", + "compiler_builtins", + "core", + "libc", + "std", + "test", +] + +[[package]] +name = "term" +version = "0.0.0" +dependencies = [ + "core", + "std", +] + +[[package]] +name = "test" +version = "0.0.0" +dependencies = [ + "core", + "getopts", + "libc", + "panic_abort", + "panic_unwind", + "proc_macro", + "std", + "term", +] + +[[package]] +name = "unicode-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", + "rustc-std-workspace-std", +] + +[[package]] +name = "unwind" +version = "0.0.0" +dependencies = [ + "cc", + "cfg-if", + "compiler_builtins", + "core", + "libc", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index f28a46245e8cf..ef39a0d87f630 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -12,6 +12,8 @@ test = { path = "./sysroot_src/src/libtest" } alloc_system = { path = "./alloc_system" } +libc = { version = "=0.2.69", default-features = false } # FIXME rustc 1.45.0-nightly (7ebd87a7a 2020-05-08) ices on libc 0.2.70 + [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" } diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index ff122e21e4f8f..65ccf605ea98f 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -12,7 +12,6 @@ popd >/dev/null # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true -rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true rm -r sysroot/ 2>/dev/null || true # Build libs diff --git a/clean_all.sh b/clean_all.sh index a77d1486fe283..b64399bb7c836 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -1,5 +1,5 @@ #!/bin/bash --verbose set -e -rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/,Cargo.lock} perf.data{,.old} +rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/} perf.data{,.old} rm -rf regex/ simple-raytracer/ diff --git a/prepare.sh b/prepare.sh index c0ff44eaf5d02..8d57e77018e24 100755 --- a/prepare.sh +++ b/prepare.sh @@ -1,7 +1,7 @@ #!/bin/bash --verbose set -e -rustup component add rust-src rustc-dev +rustup component add rust-src rustc-dev llvm-tools-preview ./build_sysroot/prepare_sysroot_src.sh cargo install hyperfine || echo "Skipping hyperfine install" diff --git a/rust-toolchain b/rust-toolchain index e40c16e06f2c7..923f005a83081 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-05-09 +nightly-2020-05-25 diff --git a/rustup.sh b/rustup.sh index 01ce5bb78be0f..b911320f7a08d 100755 --- a/rustup.sh +++ b/rustup.sh @@ -17,9 +17,12 @@ case $1 in ./clean_all.sh ./prepare.sh + + (cd build_sysroot && cargo update) + ;; "commit") - git add rust-toolchain + git add rust-toolchain build_sysroot/Cargo.lock git commit -m "Rustup to $(rustc -V)" ;; *) diff --git a/src/archive.rs b/src/archive.rs index d3c24c556f361..ba5249d412f00 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -94,7 +94,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { )); } - fn add_native_library(&mut self, name: rustc_ast::ast::Name) { + fn add_native_library(&mut self, name: rustc_span::symbol::Symbol) { let location = find_library(name, &self.config.lib_search_paths, self.config.sess); self.add_archive(location.clone(), |_| false) .unwrap_or_else(|e| { diff --git a/src/base.rs b/src/base.rs index cbef8d288c8e3..b3751a0202943 100644 --- a/src/base.rs +++ b/src/base.rs @@ -305,6 +305,28 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { *destination, )); } + TerminatorKind::InlineAsm { + template, + operands, + options: _, + destination, + } => { + match template { + &[] => { + assert_eq!(operands, &[]); + match *destination { + Some(destination) => { + let destination_block = fx.get_block(destination); + fx.bcx.ins().jump(destination_block, &[]); + } + None => bug!(), + } + + // Black box + } + _ => unimpl_fatal!(fx.tcx, bb_data.terminator().source_info.span, "Inline assembly is not supported"), + } + } TerminatorKind::Resume | TerminatorKind::Abort => { trap_unreachable(fx, "[corruption] Unwinding bb reached."); } @@ -615,7 +637,7 @@ fn trans_stmt<'tcx>( | StatementKind::AscribeUserType(..) => {} StatementKind::LlvmInlineAsm(asm) => { - use rustc_ast::ast::Name; + use rustc_span::symbol::Symbol; let LlvmInlineAsm { asm, outputs: _, @@ -632,37 +654,14 @@ fn trans_stmt<'tcx>( asm_str_style: _, } = asm; match &*asm_code.as_str() { - "" => { - assert_eq!(inputs, &[Name::intern("r")]); - assert!(outputs.is_empty(), "{:?}", outputs); - - // Black box - } - "cpuid" | "cpuid\n" => { - assert_eq!(inputs, &[Name::intern("{eax}"), Name::intern("{ecx}")]); - - assert_eq!(outputs.len(), 4); - for (i, c) in (&["={eax}", "={ebx}", "={ecx}", "={edx}"]) - .iter() - .enumerate() - { - assert_eq!(&outputs[i].constraint.as_str(), c); - assert!(!outputs[i].is_rw); - assert!(!outputs[i].is_indirect); - } - - assert_eq!(clobbers, &[Name::intern("rbx")]); - - assert!(!volatile); - assert!(!alignstack); - + cpuid if cpuid.contains("cpuid") => { crate::trap::trap_unimplemented( fx, "__cpuid_count arch intrinsic is not supported", ); } "xgetbv" => { - assert_eq!(inputs, &[Name::intern("{ecx}")]); + assert_eq!(inputs, &[Symbol::intern("{ecx}")]); assert_eq!(outputs.len(), 2); for (i, c) in (&["={eax}", "={edx}"]).iter().enumerate() { diff --git a/src/constant.rs b/src/constant.rs index eea2e3c1f00e1..efc7d82408400 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -111,7 +111,7 @@ pub(crate) fn trans_const_value<'tcx>( return CValue::const_val(fx, layout, data); } Scalar::Ptr(ptr) => { - let alloc_kind = fx.tcx.alloc_map.lock().get(ptr.alloc_id); + let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); @@ -163,7 +163,7 @@ fn pointer_for_allocation<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { - let alloc_id = fx.tcx.alloc_map.lock().create_memory_alloc(alloc); + let alloc_id = fx.tcx.create_memory_alloc(alloc); fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); @@ -260,7 +260,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let (data_id, alloc) = match todo_item { TodoItem::Alloc(alloc_id) => { //println!("alloc_id {}", alloc_id); - let alloc = match tcx.alloc_map.lock().get(alloc_id).unwrap() { + let alloc = match tcx.get_global_alloc(alloc_id).unwrap() { GlobalAlloc::Memory(alloc) => alloc, GlobalAlloc::Function(_) | GlobalAlloc::Static(_) => unreachable!(), }; @@ -314,11 +314,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu read_target_uint(endianness, bytes).unwrap() }; - // Don't inline `reloc_target_alloc` into the match. That would cause `tcx.alloc_map` - // to be locked for the duration of the match. `data_id_for_static` however may try - // to lock `tcx.alloc_map` itself while calculating the layout of the target static. - // This would cause a panic in single threaded rustc and a deadlock for parallel rustc. - let reloc_target_alloc = tcx.alloc_map.lock().get(reloc).unwrap(); + let reloc_target_alloc = tcx.get_global_alloc(reloc).unwrap(); let data_id = match reloc_target_alloc { GlobalAlloc::Function(instance) => { assert_eq!(addend, 0); diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 91b4b51e84b5f..6c5d5c48d860b 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -54,10 +54,10 @@ fn emit_module( let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { None } else { - rustc_incremental::copy_cgu_workproducts_to_incr_comp_cache_dir( + rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir( tcx.sess, &name, - &[tmp_file.clone()], + &Some(tmp_file.clone()), ) }; @@ -80,7 +80,7 @@ fn reuse_workproduct_for_cgu( let incr_comp_session_dir = tcx.sess.incr_comp_session_dir(); let mut object = None; let work_product = cgu.work_product(tcx); - for saved_file in &work_product.saved_files { + if let Some(saved_file) = &work_product.saved_file { let obj_out = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); object = Some(obj_out.clone()); let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index bf3241b8834cc..e72e15a3279ad 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -17,7 +17,7 @@ pub(crate) fn codegen_crate( tcx.sess.abort_if_errors(); if std::env::var("CG_CLIF_JIT").is_ok() - && tcx.sess.crate_types.get().contains(&rustc_session::config::CrateType::Executable) + && tcx.sess.crate_types().contains(&rustc_session::config::CrateType::Executable) { #[cfg(not(target_arch = "wasm32"))] let _: ! = jit::run_jit(tcx); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 8ae4848a7dff4..d97973667f303 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -517,6 +517,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( _ if intrinsic.starts_with("unchecked_") || intrinsic == "exact_div", (c x, c y) { // FIXME trap on overflow let bin_op = match intrinsic { + "unchecked_add" => BinOp::Add, "unchecked_sub" => BinOp::Sub, "unchecked_div" | "exact_div" => BinOp::Div, "unchecked_rem" => BinOp::Rem, diff --git a/src/metadata.rs b/src/metadata.rs index daf2127a37654..052d7e4a27cce 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -73,8 +73,7 @@ pub(crate) fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) let kind = tcx .sess - .crate_types - .borrow() + .crate_types() .iter() .map(|ty| match *ty { config::CrateType::Executable From d7682f52af1830966c5a6d41b058f8415f2a245c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 25 May 2020 13:00:15 +0200 Subject: [PATCH 1311/1566] Disable failing libcore test --- ...022-core-Disable-not-compiling-tests.patch | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch index cd450a9af95cb..36f83c0fcccac 100644 --- a/patches/0022-core-Disable-not-compiling-tests.patch +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -119,5 +119,25 @@ index 6609bc3..241b497 100644 #[test] #[should_panic(expected = "index 0 greater than length of slice")] +diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs +index b73b621..d6cc3f8 100644 +--- a/src/libcore/tests/iter.rs ++++ b/src/libcore/tests/iter.rs +@@ -2541,6 +2541,7 @@ fn test_steps_between() { + + // Skip u64/i64 to avoid differences with 32-bit vs 64-bit platforms + ++ /* + assert_eq!(Step::steps_between(&20_u128, &200_u128), Some(180_usize)); + assert_eq!(Step::steps_between(&-20_i128, &80_i128), Some(100_usize)); + if cfg!(target_pointer_width = "64") { +@@ -2552,6 +2553,7 @@ fn test_steps_between() { + Step::steps_between(&-0x1_0000_0000_0000_0000_i128, &0x1_0000_0000_0000_0000_i128,), + None, + ); ++ */ + } + + #[test] -- 2.21.0 (Apple Git-122) From 47f0256d56c00afdafbdc18cb40957bc9cde13db Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 25 May 2020 13:04:36 +0200 Subject: [PATCH 1312/1566] Update Cranelift --- Cargo.lock | 24 ++++++++++++------------ src/debuginfo/line_info.rs | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6750f697c6d6e..bd548cab9cd6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" [[package]] name = "cranelift-entity" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" [[package]] name = "cranelift-frontend" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#ee2f861fdda3903588573b9dbbf658eec2a949bd" +source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -277,9 +277,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.23" +version = "0.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36727ea09f6e363ddebb29b2d2620052267cc1fc6e0da7da63317938eb4104c" +checksum = "5842bece8a4b1690ffa6d9d959081c1d5d851ee4337a36c0a121fafe8c16add2" dependencies = [ "log", "rustc-hash", diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 92a9de1e17667..83e462c8193d6 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -196,7 +196,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let mut func_end = 0; if let Some(ref mcr) = &context.mach_compile_result { - for &MachSrcLoc { start, end, loc } in mcr.sections.get_srclocs_sorted() { + for &MachSrcLoc { start, end, loc } in mcr.buffer.get_srclocs_sorted() { line_program.row().address_offset = start as u64; if !loc.is_default() { let source_info = *source_info_set.get_index(loc.bits() as usize).unwrap(); @@ -209,7 +209,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { line_program.end_sequence(func_end as u64); - func_end = mcr.sections.total_size(); + func_end = mcr.buffer.total_size(); } else { let encinfo = isa.encoding_info(); let mut blocks = func.layout.blocks().collect::>(); From 14a4adb482166981dcc85ddf640872a580bd1a5a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 25 May 2020 13:08:50 +0200 Subject: [PATCH 1313/1566] Update depencencies --- Cargo.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd548cab9cd6b..63689e95620b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "anyhow" -version = "1.0.28" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a60d744a80c30fcb657dfe2c1b22bcb3e814c1a1e3674f32bf5820b570fbff" +checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" [[package]] name = "ar" @@ -32,9 +32,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.52" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" [[package]] name = "cfg-if" @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" +checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" [[package]] name = "libloading" @@ -248,18 +248,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.12" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319" +checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" +checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" dependencies = [ "proc-macro2", ] @@ -355,9 +355,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "syn" -version = "1.0.19" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e5aa70697bb26ee62214ae3288465ecec0000f05182f039b477001f08f5ae7" +checksum = "f87bc5b2815ebb664de0392fdf1b95b6d10e160f86d9f64ff65e5679841ca06a" dependencies = [ "proc-macro2", "quote", @@ -372,18 +372,18 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "thiserror" -version = "1.0.16" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d12a1dae4add0f0d568eebc7bf142f145ba1aa2544cafb195c76f0f409091b60" +checksum = "b13f926965ad00595dd129fa12823b04bbf866e9085ab0a5f2b05b850fbfc344" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.16" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f34e0c1caaa462fd840ec6b768946ea1e7842620d94fe29d5b847138f521269" +checksum = "893582086c2f98cde18f906265a65b5030a074b1046c674ae898be6519a7f479" dependencies = [ "proc-macro2", "quote", From 1c76bdc53a7e1719ea81ffe737cb7e52a9a15ad7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 May 2020 11:08:41 +0200 Subject: [PATCH 1314/1566] Remove already fixed FIXME in driver/jit.rs --- src/driver/jit.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 08d21b5cc9f6b..d4f1798184544 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -52,7 +52,6 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { .into_iter() .collect::>(); - // FIXME register with unwind runtime let mut unwind_context = UnwindContext::new(tcx, &mut jit_module); super::time(tcx, "codegen mono items", || { From bb4cc18cf27c5e0cccfd91e5da489321222d52aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 29 May 2020 09:48:00 +0300 Subject: [PATCH 1315/1566] Add simple-raytracer to .gitignore (#1023) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e98128dd09e13..7b21bbb6492e1 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ perf.data.old /build_sysroot/sysroot_src /rust /regex +/simple-raytracer From 6dd0246199f967b0f76d44c89c8eb1be2b312b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 29 May 2020 07:25:28 +0300 Subject: [PATCH 1316/1566] Dump clif with --emit llvm-ir in release mode Currently it's not possible to dump llvm-ir in release build. With this patch we allow it with `--emit llvm-ir`. In debug build we dump clif always as before. Fixes #1020 --- src/base.rs | 2 -- src/optimize/mod.rs | 1 - src/pretty_clif.rs | 7 ++++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index b3751a0202943..ac6e55f1cfe8c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -77,7 +77,6 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let local_map = fx.local_map; let cold_blocks = fx.cold_blocks; - #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &context.func, &clif_comments, None); // Verify function @@ -106,7 +105,6 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( ); // Write optimized function to file for debugging - #[cfg(debug_assertions)] { let value_ranges = context .build_value_labels_ranges(cx.module.isa()) diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index d59df98e7500c..f4a33ddd82e81 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -18,7 +18,6 @@ pub(crate) fn optimize_function<'tcx>( return; // FIXME classify optimizations over opt levels } self::stack2reg::optimize_function(ctx, clif_comments); - #[cfg(debug_assertions)] crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None); crate::base::verify_func(tcx, &*clif_comments, &ctx.func); } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index c3b8bee956c05..420680e96a116 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -6,6 +6,8 @@ use cranelift_codegen::{ write::{FuncWriter, PlainWriter}, }; +use rustc_session::config::OutputType; + use crate::prelude::*; /// This module provides the [CommentWriter] which makes it possible @@ -198,7 +200,6 @@ impl FunctionCx<'_, '_, B> { } } -#[cfg(debug_assertions)] pub(crate) fn write_clif_file<'tcx>( tcx: TyCtxt<'tcx>, postfix: &str, @@ -207,6 +208,10 @@ pub(crate) fn write_clif_file<'tcx>( mut clif_comments: &CommentWriter, value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>, ) { + if !(cfg!(debug_assertions) || tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly)) { + return; + } + use std::io::Write; let symbol_name = tcx.symbol_name(instance).name.as_str(); From c0ad988a3a994720904be8d77e92004daadda91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 29 May 2020 11:53:58 +0300 Subject: [PATCH 1317/1566] Update src/pretty_clif.rs Co-authored-by: bjorn3 --- src/pretty_clif.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 420680e96a116..60dd97ab3fb4e 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -208,7 +208,7 @@ pub(crate) fn write_clif_file<'tcx>( mut clif_comments: &CommentWriter, value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>, ) { - if !(cfg!(debug_assertions) || tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly)) { + if !cfg!(debug_assertions) && !tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly) { return; } From acbfa06ea2aa298de1591c8bb9a483151f254c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 29 May 2020 12:06:29 +0300 Subject: [PATCH 1318/1566] Mark blocks that call cold funs as cold (#1021) --- src/abi/mod.rs | 13 +++++++++++-- src/base.rs | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f4a2fd566aca3..8f59fa91bfb49 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -4,6 +4,7 @@ mod pass_mode; mod returning; use rustc_target::spec::abi::Abi; +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use cranelift_codegen::ir::AbiParam; @@ -431,6 +432,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( pub(crate) fn codegen_terminator_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, span: Span, + current_block: Block, func: &Operand<'tcx>, args: &[Operand<'tcx>], destination: Option<(Place<'tcx>, BasicBlock)>, @@ -440,8 +442,6 @@ pub(crate) fn codegen_terminator_call<'tcx>( .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); - // FIXME mark the current block as cold when calling a `#[cold]` function. - let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); // Handle special calls like instrinsics and empty drop glue. @@ -479,6 +479,15 @@ pub(crate) fn codegen_terminator_call<'tcx>( None }; + let is_cold = + instance.map(|inst| + fx.tcx.codegen_fn_attrs(inst.def_id()) + .flags.contains(CodegenFnAttrFlags::COLD)) + .unwrap_or(false); + if is_cold { + fx.cold_blocks.insert(current_block); + } + // Unpack arguments tuple for closures let args = if fn_sig.abi == Abi::RustCall { assert_eq!(args.len(), 2, "rust-call abi requires two arguments"); diff --git a/src/base.rs b/src/base.rs index b3751a0202943..201b0f7a181ae 100644 --- a/src/base.rs +++ b/src/base.rs @@ -300,6 +300,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, bb_data.terminator().source_info.span, + block, func, args, *destination, From 648b634e21a7d8541d84fc454700d5cb7fd7f3f4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 4 Jun 2020 19:57:12 +0200 Subject: [PATCH 1319/1566] 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 1fee499763f23..d7c331de73444 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 8042ca8978974..2732c6902b1ce 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 93eda4be31a9b..82014f594d23b 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 2e2b0052dee8b..95bcad2cd173e 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 923f005a83081..039471e8c7271 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 16b320930d9b6..f6ffc372ab5a4 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 efc7d82408400..84981c72fc0ce 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 83e462c8193d6..31431404cc3f7 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 2a360dd00c282..d13067bb3fff4 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), }; From 6b54b7c9f44713e565743aff3d07ad475c553131 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Jun 2020 12:16:05 +0200 Subject: [PATCH 1320/1566] Remove sign extension for ty::Int from CValue::const_val --- src/value_and_place.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 5779009535b64..5ddaf09caea9e 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -217,17 +217,13 @@ impl<'tcx> CValue<'tcx> { .iconst(types::I64, (const_val >> 64) as u64 as i64); fx.bcx.ins().iconcat(lsb, msb) } - ty::Bool | ty::Char | ty::Uint(_) | ty::Ref(..) + ty::Bool | ty::Char | ty::Uint(_) | ty::Int(_) | ty::Ref(..) | ty::RawPtr(..) => { fx .bcx .ins() .iconst(clif_ty, u64::try_from(const_val).expect("uint") as i64) } - ty::Int(_) => { - let const_val = rustc_middle::mir::interpret::sign_extend(const_val, layout.size); - fx.bcx.ins().iconst(clif_ty, i64::try_from(const_val as i128).unwrap()) - } ty::Float(FloatTy::F32) => { fx.bcx.ins().f32const(Ieee32::with_bits(u32::try_from(const_val).unwrap())) } From bc555764bd0b2ada6f2804c717a0179c8eb7c406 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Jun 2020 12:40:33 +0200 Subject: [PATCH 1321/1566] Update Cranelift --- Cargo.lock | 57 ++++++++++++++++++++++---------------------- Cargo.toml | 2 +- src/debuginfo/mod.rs | 47 ++++++++++++++++-------------------- 3 files changed, 49 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 63689e95620b5..52c0d62ebd947 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,16 +44,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,8 +70,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,18 +79,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" [[package]] name = "cranelift-entity" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" [[package]] name = "cranelift-frontend" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "cranelift-codegen", "log", @@ -100,8 +100,8 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,8 +112,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,8 +122,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,8 +133,8 @@ dependencies = [ [[package]] name = "cranelift-simplejit" -version = "0.63.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#51f9ac2150bd880dc7b92952ba92e72ea3ab60b7" +version = "0.64.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -184,11 +184,10 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "gimli" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" +checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" dependencies = [ - "byteorder", "indexmap", ] @@ -227,9 +226,9 @@ dependencies = [ [[package]] name = "mach" -version = "0.2.3" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" dependencies = [ "libc", ] @@ -277,9 +276,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.24" +version = "0.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5842bece8a4b1690ffa6d9d959081c1d5d851ee4337a36c0a121fafe8c16add2" +checksum = "cca5b48c9db66c5ba084e4660b4c0cfe8b551a96074bc04b7c11de86ad0bf1f9" dependencies = [ "log", "rustc-hash", @@ -288,9 +287,9 @@ dependencies = [ [[package]] name = "region" -version = "2.1.2" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" dependencies = [ "bitflags", "libc", diff --git a/Cargo.toml b/Cargo.toml index e9e6008f6cf38..2c8de8a107866 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ default-features = false features = ["read", "std", "write"] # We don't need WASM support [dependencies.gimli] -version = "0.20.0" +version = "0.21.0" default-features = false features = ["write"] # We don't need read support diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index d13067bb3fff4..e48694cb8b95b 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -9,8 +9,8 @@ use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; use gimli::write::{ - self, Address, AttributeValue, DwarfUnit, Expression, LineProgram, - LineString, Location, LocationList, Range, RangeList, UnitEntryId, Writer, + Address, AttributeValue, DwarfUnit, Expression, LineProgram, + LineString, Location, LocationList, Range, RangeList, UnitEntryId, }; use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; @@ -187,7 +187,7 @@ impl<'tcx> DebugContext<'tcx> { let type_entry = self.dwarf.unit.get_mut(type_id); //type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc_hir::Mutability::Mut)); - type_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(pointee)); + type_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(pointee)); type_id } @@ -213,7 +213,7 @@ impl<'tcx> DebugContext<'tcx> { field_entry.set(gimli::DW_AT_name, AttributeValue::String(field_def.ident.as_str().to_string().into_bytes())); field_entry.set(gimli::DW_AT_data_member_location, AttributeValue::Udata(field_offset.bytes())); - field_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(field_type)); + field_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(field_type)); } type_id @@ -291,7 +291,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); - var_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(dw_ty)); + var_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty)); var_id } @@ -341,15 +341,13 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let name = format!("{}{}", base_name, i); let dw_ty = self.debug_context.dwarf_ty_for_clif_ty(param.value_type); - let loc = Expression( - translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap(), - ); + let loc = translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap(); let arg_id = self.debug_context.dwarf.unit.add(self.entry_id, gimli::DW_TAG_formal_parameter); let var_entry = self.debug_context.dwarf.unit.get_mut(arg_id); var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); - var_entry.set(gimli::DW_AT_type, AttributeValue::ThisUnitEntryRef(dw_ty)); + var_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty)); var_entry.set(gimli::DW_AT_location, AttributeValue::Exprloc(loc)); } @@ -413,9 +411,7 @@ fn place_location<'a, 'tcx>( symbol: func_debug_ctx.symbol, addend: i64::from(value_loc_range.end), }, - data: Expression( - translate_loc(isa, value_loc_range.loc, &context.func.stack_slots).unwrap(), - ), + data: translate_loc(isa, value_loc_range.loc, &context.func.stack_slots).unwrap(), }) .collect(), ); @@ -425,40 +421,37 @@ fn place_location<'a, 'tcx>( } else { // FIXME set value labels for unused locals - AttributeValue::Exprloc(Expression(vec![])) + AttributeValue::Exprloc(Expression::new()) } } CPlaceInner::Addr(_, _) => { // FIXME implement this (used by arguments and returns) - AttributeValue::Exprloc(Expression(vec![])) + AttributeValue::Exprloc(Expression::new()) // For PointerBase::Stack: - //AttributeValue::Exprloc(Expression(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())) + //AttributeValue::Exprloc(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap()) } } } // Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137 -fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option> { +fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option { match loc { ValueLoc::Reg(reg) => { let machine_reg = isa.map_dwarf_register(reg).unwrap(); - assert!(machine_reg <= 32); // FIXME - Some(vec![gimli::constants::DW_OP_reg0.0 + machine_reg as u8]) + let mut expr = Expression::new(); + expr.op_reg(gimli::Register(machine_reg)); + Some(expr) } ValueLoc::Stack(ss) => { if let Some(ss_offset) = stack_slots[ss].offset { - let endian = gimli::RunTimeEndian::Little; - let mut writer = write::EndianVec::new(endian); - writer - .write_u8(gimli::constants::DW_OP_breg0.0 + X86_64::RBP.0 as u8) - .expect("bp wr"); - writer.write_sleb128(ss_offset as i64 + 16).expect("ss wr"); - let buf = writer.into_vec(); - return Some(buf); + let mut expr = Expression::new(); + expr.op_breg(X86_64::RBP, ss_offset as i64 + 16); + Some(expr) + } else { + None } - None } _ => None, } From 456c14f9e8c4e42fd97730c33a39833c124de8ad Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 5 Jun 2020 12:43:42 +0200 Subject: [PATCH 1322/1566] Update dependencies --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52c0d62ebd947..0a31ef679c27d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -193,18 +193,18 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292" +checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" dependencies = [ "autocfg", ] [[package]] name = "libc" -version = "0.2.70" +version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3baa92041a6fec78c687fa0cc2b3fae8884f743d672cf551bed1d6dac6988d0f" +checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" [[package]] name = "libloading" @@ -247,9 +247,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101" +checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" dependencies = [ "unicode-xid", ] @@ -354,9 +354,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "syn" -version = "1.0.24" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f87bc5b2815ebb664de0392fdf1b95b6d10e160f86d9f64ff65e5679841ca06a" +checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2" dependencies = [ "proc-macro2", "quote", From eb489599d6976edd7f5652bdfef49159a9ecb9e1 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2020 05:26:17 +0000 Subject: [PATCH 1323/1566] Bump cranelift-codegen from `00abfcd` to `4bb5894` Bumps [cranelift-codegen](https://github.com/bytecodealliance/wasmtime) from `00abfcd` to `4bb5894`. - [Release notes](https://github.com/bytecodealliance/wasmtime/releases) - [Commits](https://github.com/bytecodealliance/wasmtime/compare/00abfcd943fdef8af5c8b2afed09e7ecef512b02...4bb58940c74c37bdba8630810645cbd41dd0ff7e) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a31ef679c27d..7048dcddba2d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" [[package]] name = "cranelift-entity" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" [[package]] name = "cranelift-frontend" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#00abfcd943fdef8af5c8b2afed09e7ecef512b02" +source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" dependencies = [ "cranelift-codegen", "cranelift-module", From cef9255c0ed8e3756344b12f238fb5bcf7b085e2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 11 Jun 2020 13:12:35 +0200 Subject: [PATCH 1324/1566] Rustup to rustc 1.46.0-nightly (449e8eaa2 2020-06-10) --- rust-toolchain | 2 +- src/base.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 039471e8c7271..532598108c524 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-04 +nightly-2020-06-11 diff --git a/src/base.rs b/src/base.rs index f6ffc372ab5a4..fb51e4badce45 100644 --- a/src/base.rs +++ b/src/base.rs @@ -334,7 +334,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { trap_unreachable(fx, "[corruption] Hit unreachable code."); } TerminatorKind::Yield { .. } - | TerminatorKind::FalseEdges { .. } + | TerminatorKind::FalseEdge { .. } | TerminatorKind::FalseUnwind { .. } | TerminatorKind::DropAndReplace { .. } | TerminatorKind::GeneratorDrop => { From b84c9764db3982c11efc8edd81c29750e5ad7d7d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 12 Jun 2020 18:41:50 +0200 Subject: [PATCH 1325/1566] Rustup to rustc 1.46.0-nightly (a37c32e2d 2020-06-11) --- rust-toolchain | 2 +- src/base.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 532598108c524..b68fcc008f9c7 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-11 +nightly-2020-06-12 diff --git a/src/base.rs b/src/base.rs index fb51e4badce45..34c2020472628 100644 --- a/src/base.rs +++ b/src/base.rs @@ -292,12 +292,13 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { func, args, destination, + fn_span, cleanup: _, from_hir_call: _, } => { fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, - bb_data.terminator().source_info.span, + *fn_span, block, func, args, From e4596aa08090d9f70c049155ea2b6c44c74af693 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 12 Jun 2020 19:07:04 +0200 Subject: [PATCH 1326/1566] Update Cranelift --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7048dcddba2d2..13f66e2ec2c6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,16 +44,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,8 +70,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,18 +79,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" [[package]] name = "cranelift-entity" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" [[package]] name = "cranelift-frontend" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "cranelift-codegen", "log", @@ -100,8 +100,8 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,8 +112,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,8 +122,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -133,8 +133,8 @@ dependencies = [ [[package]] name = "cranelift-simplejit" -version = "0.64.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#4bb58940c74c37bdba8630810645cbd41dd0ff7e" +version = "0.65.0" +source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -276,9 +276,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.25" +version = "0.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca5b48c9db66c5ba084e4660b4c0cfe8b551a96074bc04b7c11de86ad0bf1f9" +checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" dependencies = [ "log", "rustc-hash", From e1a77a5ce6b13aadc834c8e0e695b196b330ad08 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 12 Jun 2020 19:11:40 +0200 Subject: [PATCH 1327/1566] Update dependencies --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13f66e2ec2c6e..82cee31f2fb6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,9 +256,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ "proc-macro2", ] @@ -354,9 +354,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "syn" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2" +checksum = "b5304cfdf27365b7585c25d4af91b35016ed21ef88f17ced89c7093b43dba8b6" dependencies = [ "proc-macro2", "quote", From ba7cdf21be525e39cbbee8804703cfe26e0ac7c6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 12 Jun 2020 19:31:35 +0200 Subject: [PATCH 1328/1566] Emit unwind info for main and alloc shim Fixes #988 --- src/allocator.rs | 15 ++++++++++++--- src/driver/aot.rs | 14 ++++++++------ src/driver/jit.rs | 4 ++-- src/main_shim.rs | 10 ++++++++-- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 2ea4a1659f8bf..8dae5dcf38591 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -13,7 +13,11 @@ use crate::prelude::*; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; /// Returns whether an allocator shim was created -pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut Module) -> bool { +pub(crate) fn codegen( + tcx: TyCtxt<'_>, + module: &mut Module, + unwind_context: &mut UnwindContext<'_>, +) -> bool { let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| { use rustc_middle::middle::dependency_format::Linkage; list.iter().any(|&linkage| linkage == Linkage::Dynamic) @@ -21,14 +25,18 @@ pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut Module, kind: AllocatorKind) { +fn codegen_inner( + module: &mut Module, + unwind_context: &mut UnwindContext<'_>, + kind: AllocatorKind, +) { let usize_ty = module.target_config().pointer_type(); for method in ALLOCATOR_METHODS { @@ -99,5 +107,6 @@ fn codegen_inner(module: &mut Module, kind: AllocatorKin &mut ctx, &mut cranelift_codegen::binemit::NullTrapSink {}, ).unwrap(); + unwind_context.add_function(func_id, &ctx, module.isa()); } } diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 6c5d5c48d860b..27c76fbee1d31 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -123,7 +123,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege let mut unwind_context = UnwindContext::new(tcx, &mut module); super::codegen_mono_items(tcx, &mut module, debug.as_mut(), &mut unwind_context, mono_items); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context); emit_module( tcx, @@ -185,19 +185,21 @@ pub(super) fn run_aot( tcx.sess.abort_if_errors(); let mut allocator_module = new_module(tcx, "allocator_shim".to_string()); - let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module); + let mut allocator_unwind_context = UnwindContext::new(tcx, &mut allocator_module); + let created_alloc_shim = crate::allocator::codegen( + tcx, + &mut allocator_module, + &mut allocator_unwind_context, + ); let allocator_module = if created_alloc_shim { - // FIXME create .eh_frame for allocator shim - let unwind_context = UnwindContext::new(tcx, &mut allocator_module); - let ModuleCodegenResult(module, work_product) = emit_module( tcx, "allocator_shim".to_string(), ModuleKind::Allocator, allocator_module, None, - unwind_context, + allocator_unwind_context, ); if let Some((id, product)) = work_product { work_products.insert(id, product); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index d4f1798184544..fa88029ceb93b 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -57,8 +57,8 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { super::time(tcx, "codegen mono items", || { super::codegen_mono_items(tcx, &mut jit_module, None, &mut unwind_context, mono_items); }); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module); - crate::allocator::codegen(tcx, &mut jit_module); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context); + crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context); jit_module.finalize_definitions(); diff --git a/src/main_shim.rs b/src/main_shim.rs index c45b0eb8cd42e..7366c6a9c0a54 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -2,7 +2,11 @@ use crate::prelude::*; /// Create the `main` function which will initialize the rust runtime and call /// users main function. -pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module) { +pub(crate) fn maybe_create_entry_wrapper( + tcx: TyCtxt<'_>, + module: &mut Module, + unwind_context: &mut UnwindContext<'_>, +) { use rustc_hir::lang_items::StartFnLangItem; use rustc_session::config::EntryFnType; @@ -22,11 +26,12 @@ pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module, m: &mut Module, + unwind_context: &mut UnwindContext<'_>, rust_main_def_id: DefId, use_start_lang_item: bool, ) { @@ -109,5 +114,6 @@ pub(crate) fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module Date: Fri, 12 Jun 2020 21:15:13 +0200 Subject: [PATCH 1329/1566] Remove all non-tcx references from CodegenCx --- src/base.rs | 6 +++--- src/debuginfo/unwind.rs | 4 ++-- src/driver/aot.rs | 20 +++++--------------- src/driver/jit.rs | 7 ++++--- src/driver/mod.rs | 19 ++++++------------- src/lib.rs | 29 +++++++++++++++++++---------- 6 files changed, 39 insertions(+), 46 deletions(-) diff --git a/src/base.rs b/src/base.rs index 34c2020472628..acdfba4323af3 100644 --- a/src/base.rs +++ b/src/base.rs @@ -3,8 +3,8 @@ use rustc_index::vec::IndexVec; use crate::prelude::*; -pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( - cx: &mut crate::CodegenCx<'clif, 'tcx, B>, +pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( + cx: &mut crate::CodegenCx<'tcx, B>, instance: Instance<'tcx>, linkage: Linkage, ) { @@ -39,7 +39,7 @@ pub(crate) fn trans_fn<'clif, 'tcx, B: Backend + 'static>( let mut fx = FunctionCx { tcx, - module: cx.module, + module: &mut cx.module, pointer_type, instance, diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index a0f933d7c62b1..a8e52f99b67e7 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -15,12 +15,12 @@ pub(crate) struct UnwindContext<'tcx> { impl<'tcx> UnwindContext<'tcx> { pub(crate) fn new( tcx: TyCtxt<'tcx>, - module: &mut Module, + isa: &dyn TargetIsa, ) -> Self { let mut frame_table = FrameTable::default(); - let cie_id = if let Some(cie) = module.isa().create_systemv_cie() { + let cie_id = if let Some(cie) = isa.create_systemv_cie() { Some(frame_table.add_cie(cie)) } else { None diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 27c76fbee1d31..303031c0c036c 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -108,21 +108,11 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege let cgu = tcx.codegen_unit(cgu_name); let mono_items = cgu.items_in_deterministic_order(tcx); - let mut module = new_module(tcx, cgu_name.as_str().to_string()); + let module = new_module(tcx, cgu_name.as_str().to_string()); - let mut debug = if tcx.sess.opts.debuginfo != DebugInfo::None { - let debug = DebugContext::new( - tcx, - module.isa(), - ); - Some(debug) - } else { - None - }; - - let mut unwind_context = UnwindContext::new(tcx, &mut module); - - super::codegen_mono_items(tcx, &mut module, debug.as_mut(), &mut unwind_context, mono_items); + let mut cx = CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); + super::codegen_mono_items(&mut cx, mono_items); + let (mut module, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context); emit_module( @@ -185,7 +175,7 @@ pub(super) fn run_aot( tcx.sess.abort_if_errors(); let mut allocator_module = new_module(tcx, "allocator_shim".to_string()); - let mut allocator_unwind_context = UnwindContext::new(tcx, &mut allocator_module); + let mut allocator_unwind_context = UnwindContext::new(tcx, allocator_module.isa()); let created_alloc_shim = crate::allocator::codegen( tcx, &mut allocator_module, diff --git a/src/driver/jit.rs b/src/driver/jit.rs index fa88029ceb93b..ab6c9da25addb 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -52,10 +52,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { .into_iter() .collect::>(); - let mut unwind_context = UnwindContext::new(tcx, &mut jit_module); + let mut cx = CodegenCx::new(tcx, jit_module, false); - super::time(tcx, "codegen mono items", || { - super::codegen_mono_items(tcx, &mut jit_module, None, &mut unwind_context, mono_items); + let (mut jit_module, _debug, mut unwind_context) = super::time(tcx, "codegen mono items", || { + super::codegen_mono_items(&mut cx, mono_items); + tcx.sess.time("finalize CodegenCx", || cx.finalize()) }); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context); crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index e72e15a3279ad..ded3bbe1e2cf8 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -30,20 +30,15 @@ pub(crate) fn codegen_crate( } fn codegen_mono_items<'tcx>( - tcx: TyCtxt<'tcx>, - module: &mut Module, - debug_context: Option<&mut DebugContext<'tcx>>, - unwind_context: &mut UnwindContext<'tcx>, + cx: &mut CodegenCx<'tcx, impl Backend + 'static>, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { - let mut cx = CodegenCx::new(tcx, module, debug_context, unwind_context); - - tcx.sess.time("predefine functions", || { + cx.tcx.sess.time("predefine functions", || { for &(mono_item, (linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = - get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); + get_function_name_and_sig(cx.tcx, cx.module.isa().triple(), instance, false); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); cx.module.declare_function(&name, linkage, &sig).unwrap(); } @@ -54,14 +49,12 @@ fn codegen_mono_items<'tcx>( for (mono_item, (linkage, visibility)) in mono_items { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - trans_mono_item(&mut cx, mono_item, linkage); + trans_mono_item(cx, mono_item, linkage); } - - tcx.sess.time("finalize CodegenCx", || cx.finalize()); } -fn trans_mono_item<'clif, 'tcx, B: Backend + 'static>( - cx: &mut crate::CodegenCx<'clif, 'tcx, B>, +fn trans_mono_item<'tcx, B: Backend + 'static>( + cx: &mut crate::CodegenCx<'tcx, B>, mono_item: MonoItem<'tcx>, linkage: Linkage, ) { diff --git a/src/lib.rs b/src/lib.rs index 4e3fbc3eaaa40..afaeb6d1e25a3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -126,23 +126,31 @@ mod prelude { } } -pub(crate) struct CodegenCx<'clif, 'tcx, B: Backend + 'static> { +pub(crate) struct CodegenCx<'tcx, B: Backend + 'static> { tcx: TyCtxt<'tcx>, - module: &'clif mut Module, + module: Module, constants_cx: ConstantCx, cached_context: Context, vtables: FxHashMap<(Ty<'tcx>, Option>), DataId>, - debug_context: Option<&'clif mut DebugContext<'tcx>>, - unwind_context: &'clif mut UnwindContext<'tcx>, + debug_context: Option>, + unwind_context: UnwindContext<'tcx>, } -impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { +impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { fn new( tcx: TyCtxt<'tcx>, - module: &'clif mut Module, - debug_context: Option<&'clif mut DebugContext<'tcx>>, - unwind_context: &'clif mut UnwindContext<'tcx>, + module: Module, + debug_info: bool, ) -> Self { + let unwind_context = UnwindContext::new(tcx, module.isa()); + let debug_context = if debug_info { + Some(DebugContext::new( + tcx, + module.isa(), + )) + } else { + None + }; CodegenCx { tcx, module, @@ -154,8 +162,9 @@ impl<'clif, 'tcx, B: Backend + 'static> CodegenCx<'clif, 'tcx, B> { } } - fn finalize(self) { - self.constants_cx.finalize(self.tcx, self.module); + fn finalize(mut self) -> (Module, Option>, UnwindContext<'tcx>) { + self.constants_cx.finalize(self.tcx, &mut self.module); + (self.module, self.debug_context, self.unwind_context) } } From eb5ce4e92ae8d512804279fda1101032c7ec9f28 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 13 Jun 2020 17:03:34 +0200 Subject: [PATCH 1330/1566] Remove FunctionDebugContext --- src/base.rs | 11 ++-- src/debuginfo/line_info.rs | 27 ++++----- src/debuginfo/mod.rs | 118 +++++++++++++++---------------------- src/lib.rs | 2 +- 4 files changed, 67 insertions(+), 91 deletions(-) diff --git a/src/base.rs b/src/base.rs index acdfba4323af3..244e06f76278e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -15,10 +15,6 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Declare function let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); - let mut debug_context = cx - .debug_context - .as_mut() - .map(|debug_context| FunctionDebugContext::new(debug_context, instance, func_id, &name)); // Make FunctionBuilder let context = &mut cx.cached_context; @@ -122,11 +118,12 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Define debuginfo for function let isa = cx.module.isa(); + let debug_context = &mut cx.debug_context; let unwind_context = &mut cx.unwind_context; tcx.sess.time("generate debug info", || { - debug_context - .as_mut() - .map(|x| x.define(context, isa, &source_info_set, local_map)); + if let Some(debug_context) = debug_context { + debug_context.define_function(instance, func_id, &name, isa, context, &source_info_set, local_map); + } unwind_context.add_function(func_id, &context, isa); }); diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 31431404cc3f7..1a84f6584d48d 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -119,21 +119,21 @@ impl<'tcx> DebugContext<'tcx> { AttributeValue::Udata(loc.col.to_usize() as u64), ); } -} -impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { pub(super) fn create_debug_lines( &mut self, - context: &Context, isa: &dyn cranelift_codegen::isa::TargetIsa, + symbol: usize, + entry_id: UnitEntryId, + context: &Context, + function_span: Span, source_info_set: &indexmap::IndexSet, ) -> CodeOffset { - let tcx = self.debug_context.tcx; - let line_program = &mut self.debug_context.dwarf.unit.line_program; + let tcx = self.tcx; + let line_program = &mut self.dwarf.unit.line_program; let func = &context.func; - let line_strings = &mut self.debug_context.dwarf.line_strings; - let function_span = self.mir.span; + let line_strings = &mut self.dwarf.line_strings; let mut last_span = None; let mut last_file = None; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { @@ -189,7 +189,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { }; line_program.begin_sequence(Some(Address::Symbol { - symbol: self.symbol, + symbol, addend: 0, })); @@ -202,7 +202,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let source_info = *source_info_set.get_index(loc.bits() as usize).unwrap(); create_row_for_span(line_program, source_info.span); } else { - create_row_for_span(line_program, self.mir.span); + create_row_for_span(line_program, function_span); } func_end = end; } @@ -223,7 +223,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); create_row_for_span(line_program, source_info.span); } else { - create_row_for_span(line_program, self.mir.span); + create_row_for_span(line_program, function_span); } func_end = offset + size; } @@ -233,18 +233,17 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { assert_ne!(func_end, 0); - let entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); + let entry = self.dwarf.unit.get_mut(entry_id); entry.set( gimli::DW_AT_low_pc, AttributeValue::Address(Address::Symbol { - symbol: self.symbol, + symbol, addend: 0, }), ); entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(func_end as u64)); - self.debug_context - .emit_location(self.entry_id, self.mir.span); + self.emit_location(entry_id, function_span); func_end } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index e48694cb8b95b..bfcb7cfd2146d 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -233,34 +233,44 @@ impl<'tcx> DebugContext<'tcx> { type_id } -} -pub(crate) struct FunctionDebugContext<'a, 'tcx> { - debug_context: &'a mut DebugContext<'tcx>, - entry_id: UnitEntryId, - symbol: usize, - instance: Instance<'tcx>, - mir: &'tcx mir::Body<'tcx>, -} + fn define_local(&mut self, scope: UnitEntryId, name: String, ty: Ty<'tcx>) -> UnitEntryId { + let dw_ty = self.dwarf_ty(ty); + + let var_id = self + .dwarf + .unit + .add(scope, gimli::DW_TAG_variable); + let var_entry = self.dwarf.unit.get_mut(var_id); + + var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); + var_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty)); -impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { - pub(crate) fn new( - debug_context: &'a mut DebugContext<'tcx>, + var_id + } + + pub(crate) fn define_function( + &mut self, instance: Instance<'tcx>, func_id: FuncId, name: &str, - ) -> Self { - let mir = debug_context.tcx.instance_mir(instance.def); + isa: &dyn TargetIsa, + context: &Context, + source_info_set: &indexmap::IndexSet, + local_map: FxHashMap>, + ) { + let symbol = func_id.as_u32() as usize; + let mir = self.tcx.instance_mir(instance.def); - // FIXME: add to appropriate scope intead of root - let scope = debug_context.dwarf.unit.root(); + // FIXME: add to appropriate scope instead of root + let scope = self.dwarf.unit.root(); - let entry_id = debug_context + let entry_id = self .dwarf .unit .add(scope, gimli::DW_TAG_subprogram); - let entry = debug_context.dwarf.unit.get_mut(entry_id); - let name_id = debug_context.dwarf.strings.add(name); + let entry = self.dwarf.unit.get_mut(entry_id); + let name_id = self.dwarf.strings.add(name); // Gdb requires DW_AT_name. Otherwise the DW_TAG_subprogram is skipped. entry.set( gimli::DW_AT_name, @@ -271,46 +281,14 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { AttributeValue::StringRef(name_id), ); - FunctionDebugContext { - debug_context, - entry_id, - symbol: func_id.as_u32() as usize, - instance, - mir, - } - } - - fn define_local(&mut self, name: String, ty: Ty<'tcx>) -> UnitEntryId { - let dw_ty = self.debug_context.dwarf_ty(ty); - - let var_id = self - .debug_context - .dwarf - .unit - .add(self.entry_id, gimli::DW_TAG_variable); - let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); - - var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); - var_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty)); - - var_id - } - - pub(crate) fn define( - &mut self, - context: &Context, - isa: &dyn TargetIsa, - source_info_set: &indexmap::IndexSet, - local_map: FxHashMap>, - ) { - let end = self.create_debug_lines(context, isa, source_info_set); + let end = self.create_debug_lines(isa, symbol, entry_id, context, mir.span, source_info_set); - self.debug_context + self .unit_range_list .0 .push(Range::StartLength { begin: Address::Symbol { - symbol: self.symbol, + symbol, addend: 0, }, length: u64::from(end), @@ -320,10 +298,10 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { return; // Not yet implemented for the AArch64 backend. } - let func_entry = self.debug_context.dwarf.unit.get_mut(self.entry_id); + let func_entry = self.dwarf.unit.get_mut(entry_id); // Gdb requires both DW_AT_low_pc and DW_AT_high_pc. Otherwise the DW_TAG_subprogram is skipped. func_entry.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Symbol { - symbol: self.symbol, + symbol, addend: 0, })); // Using Udata for DW_AT_high_pc requires at least DWARF4 @@ -340,11 +318,11 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { }; let name = format!("{}{}", base_name, i); - let dw_ty = self.debug_context.dwarf_ty_for_clif_ty(param.value_type); + let dw_ty = self.dwarf_ty_for_clif_ty(param.value_type); let loc = translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap(); - let arg_id = self.debug_context.dwarf.unit.add(self.entry_id, gimli::DW_TAG_formal_parameter); - let var_entry = self.debug_context.dwarf.unit.get_mut(arg_id); + let arg_id = self.dwarf.unit.add(entry_id, gimli::DW_TAG_formal_parameter); + let var_entry = self.dwarf.unit.get_mut(arg_id); var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); var_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty)); @@ -355,17 +333,18 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { if false { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); - for (local, _local_decl) in self.mir.local_decls.iter_enumerated() { - let ty = self.debug_context.tcx.subst_and_normalize_erasing_regions( - self.instance.substs, + for (local, _local_decl) in mir.local_decls.iter_enumerated() { + let ty = self.tcx.subst_and_normalize_erasing_regions( + instance.substs, ty::ParamEnv::reveal_all(), - &self.mir.local_decls[local].ty, + &mir.local_decls[local].ty, ); - let var_id = self.define_local(format!("{:?}", local), ty); + let var_id = self.define_local(entry_id, format!("{:?}", local), ty); let location = place_location( self, isa, + symbol, context, &local_map, &value_labels_ranges, @@ -375,7 +354,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { }, ); - let var_entry = self.debug_context.dwarf.unit.get_mut(var_id); + let var_entry = self.dwarf.unit.get_mut(var_id); var_entry.set(gimli::DW_AT_location, location); } } @@ -384,9 +363,10 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { } } -fn place_location<'a, 'tcx>( - func_debug_ctx: &mut FunctionDebugContext<'a, 'tcx>, +fn place_location<'tcx>( + debug_context: &mut DebugContext<'tcx>, isa: &dyn TargetIsa, + symbol: usize, context: &Context, local_map: &FxHashMap>, #[allow(rustc::default_hash_types)] @@ -404,18 +384,18 @@ fn place_location<'a, 'tcx>( .iter() .map(|value_loc_range| Location::StartEnd { begin: Address::Symbol { - symbol: func_debug_ctx.symbol, + symbol, addend: i64::from(value_loc_range.start), }, end: Address::Symbol { - symbol: func_debug_ctx.symbol, + symbol, addend: i64::from(value_loc_range.end), }, data: translate_loc(isa, value_loc_range.loc, &context.func.stack_slots).unwrap(), }) .collect(), ); - let loc_list_id = func_debug_ctx.debug_context.dwarf.unit.locations.add(loc_list); + let loc_list_id = debug_context.dwarf.unit.locations.add(loc_list); AttributeValue::LocationListRef(loc_list_id) } else { diff --git a/src/lib.rs b/src/lib.rs index afaeb6d1e25a3..517ccd41706ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,7 +106,7 @@ mod prelude { pub(crate) use crate::base::{trans_operand, trans_place}; pub(crate) use crate::cast::*; pub(crate) use crate::common::*; - pub(crate) use crate::debuginfo::{DebugContext, FunctionDebugContext, UnwindContext}; + pub(crate) use crate::debuginfo::{DebugContext, UnwindContext}; pub(crate) use crate::pointer::Pointer; pub(crate) use crate::trap::*; pub(crate) use crate::value_and_place::{CPlace, CPlaceInner, CValue}; From 9510791fce1e5f6c5e78c0524dd1c5d253e5ba1d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 13 Jun 2020 19:19:38 +0200 Subject: [PATCH 1331/1566] Compile sysroot in release mode by default Fixes #938 --- build_sysroot/Cargo.toml | 1 + build_sysroot/build_sysroot.sh | 2 +- test.sh | 6 +----- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index ef39a0d87f630..a4f766cf89cb3 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -21,3 +21,4 @@ rustc-std-workspace-std = { path = "./sysroot_src/src/tools/rustc-std-workspace- [profile.release] debug = true +incremental = true diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 65ccf605ea98f..e08fc51999d9c 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -18,7 +18,7 @@ rm -r sysroot/ 2>/dev/null || true export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked" if [[ "$1" == "--release" ]]; then sysroot_channel='release' - RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release + RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=2" cargo build --target $TARGET_TRIPLE --release else sysroot_channel='debug' cargo build --target $TARGET_TRIPLE diff --git a/test.sh b/test.sh index 190fd7b291abb..cea435d896300 100755 --- a/test.sh +++ b/test.sh @@ -38,7 +38,7 @@ $RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitr $RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers echo "[BUILD] sysroot" -time ./build_sysroot/build_sysroot.sh +time ./build_sysroot/build_sysroot.sh --release echo "[AOT] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE @@ -71,10 +71,6 @@ $RUN_WRAPPER ./target/out/track-caller-attribute echo "[BUILD] mod_bench" $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE -# FIXME linker gives multiple definitions error on Linux -#echo "[BUILD] sysroot in release mode" -#./build_sysroot/build_sysroot.sh --release - pushd simple-raytracer if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then echo "[BENCH COMPILE] ebobby/simple-raytracer" From bd6e0e6e1218a7cc63ee57848096efad1a1bb54b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 10:24:24 +0200 Subject: [PATCH 1332/1566] Rustup to rustc 1.46.0-nightly (f315c35a7 2020-06-15) --- build_sysroot/Cargo.lock | 8 ++++---- rust-toolchain | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index d7c331de73444..7b66c220d486d 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -25,9 +25,9 @@ checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" [[package]] name = "backtrace" -version = "0.3.48" +version = "0.3.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df2f85c8a2abbe3b7d7e748052fdd9b76a0458fdeb16ad4223f5eca78c7c130" +checksum = "05100821de9e028f12ae3d189176b41ee198341eb8f369956407fea2f5cc666c" dependencies = [ "backtrace-sys", "cfg-if", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" +checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909" dependencies = [ "compiler_builtins", "libc", diff --git a/rust-toolchain b/rust-toolchain index b68fcc008f9c7..dce0ff04cc7b4 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-12 +nightly-2020-06-16 From d471c1b5217e7109c1d000acc3c81a191a2c0383 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 10:38:12 +0200 Subject: [PATCH 1333/1566] Update Cranelift --- Cargo.lock | 30 +++++++++++++++--------------- Cargo.toml | 2 +- src/backend.rs | 32 ++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82cee31f2fb6b..dd47b093b0b6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,8 +123,9 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ + "anyhow", "cranelift-codegen", "cranelift-module", "object", @@ -134,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#2dbe98b823e39cbd1bffe9c137b684d6a94f280a" +source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -235,13 +236,12 @@ dependencies = [ [[package]] name = "object" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5666bbb90bc4d1e5bdcb26c0afda1822d25928341e9384ab187a9b37ab69e36" +checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" dependencies = [ "crc32fast", "indexmap", - "target-lexicon", "wasmparser", ] @@ -397,9 +397,9 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" [[package]] name = "wasmparser" -version = "0.51.4" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" +checksum = "747467da102640806cf6643e032a70174e7768839bcac7e71a0a9aaa54761d59" [[package]] name = "winapi" diff --git a/Cargo.toml b/Cargo.toml index 2c8de8a107866..b656ed7cb5780 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ indexmap = "1.0.2" cfg-if = "0.1.10" [dependencies.object] -version = "0.18.0" +version = "0.19.0" default-features = false features = ["read", "std", "write"] # We don't need WASM support diff --git a/src/backend.rs b/src/backend.rs index 5077c77ec3379..294f6952ae20c 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -58,7 +58,7 @@ impl WriteDebugInfo for ObjectProduct { id: SectionId, data: Vec, ) -> (object::write::SectionId, object::write::SymbolId) { - let name = if self.object.format() == target_lexicon::BinaryFormat::Macho { + let name = if self.object.format() == object::BinaryFormat::MachO { id.name().replace('.', "__") // machO expects __debug_info instead of .debug_info } else { id.name().to_string() @@ -109,8 +109,32 @@ impl Emit for ObjectProduct { pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec { let triple = crate::build_isa(sess, true).triple().clone(); - let mut metadata_object = - object::write::Object::new(triple.binary_format, triple.architecture); + + let binary_format = match triple.binary_format { + target_lexicon::BinaryFormat::Elf => object::BinaryFormat::Elf, + target_lexicon::BinaryFormat::Coff => object::BinaryFormat::Coff, + target_lexicon::BinaryFormat::Macho => object::BinaryFormat::MachO, + target_lexicon::BinaryFormat::Wasm => sess.fatal("binary format wasm is unsupported"), + target_lexicon::BinaryFormat::Unknown => sess.fatal("binary format is unknown"), + }; + let architecture = match triple.architecture { + target_lexicon::Architecture::I386 + | target_lexicon::Architecture::I586 + | target_lexicon::Architecture::I686 => object::Architecture::I386, + target_lexicon::Architecture::X86_64 => object::Architecture::X86_64, + target_lexicon::Architecture::Arm(_) => object::Architecture::Arm, + target_lexicon::Architecture::Aarch64(_) => object::Architecture::Aarch64, + architecture => sess.fatal(&format!( + "target architecture {:?} is unsupported", + architecture, + )) + }; + let endian = match triple.endianness().unwrap() { + target_lexicon::Endianness::Little => object::Endianness::Little, + target_lexicon::Endianness::Big => object::Endianness::Big, + }; + + let mut metadata_object = object::write::Object::new(binary_format, architecture, endian); metadata_object.add_file_symbol(name.as_bytes().to_vec()); f(&mut metadata_object); metadata_object.write().unwrap() @@ -124,7 +148,7 @@ pub(crate) fn make_module(sess: &Session, name: String) -> Module { crate::build_isa(sess, true), name + ".o", cranelift_module::default_libcall_names(), - ), + ).unwrap(), ); module } From 5443f39f8718a2d9ff1be4b6ce99807690ab516f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 10:41:19 +0200 Subject: [PATCH 1334/1566] Update dependencies --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd47b093b0b6f..3999a85d3ebe5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,18 +371,18 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "thiserror" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13f926965ad00595dd129fa12823b04bbf866e9085ab0a5f2b05b850fbfc344" +checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "893582086c2f98cde18f906265a65b5030a074b1046c674ae898be6519a7f479" +checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" dependencies = [ "proc-macro2", "quote", From a76748e54a052c401e97648aac553bcc65ca0fcf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 10:42:44 +0200 Subject: [PATCH 1335/1566] Fix warnings in alloc_example.rs --- example/alloc_example.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/example/alloc_example.rs b/example/alloc_example.rs index f75103c76a524..dc2ad4c676e80 100644 --- a/example/alloc_example.rs +++ b/example/alloc_example.rs @@ -18,16 +18,12 @@ extern "C" { #[panic_handler] fn panic_handler(_: &core::panic::PanicInfo) -> ! { - unsafe { - core::intrinsics::abort(); - } + core::intrinsics::abort(); } #[alloc_error_handler] fn alloc_error_handler(_: alloc::alloc::Layout) -> ! { - unsafe { - core::intrinsics::abort(); - } + core::intrinsics::abort(); } #[start] From fcd596714bd50bf33ee4bbd8a0c36f646f116fc6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 10:54:18 +0200 Subject: [PATCH 1336/1566] Remove pin of the libc crate for the sysroot The latest libc version has fixed the compilation error --- build_sysroot/Cargo.lock | 5 ++--- build_sysroot/Cargo.toml | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 7b66c220d486d..3183d7660c60e 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -135,9 +135,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.69" +version = "0.2.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" +checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" dependencies = [ "rustc-std-workspace-core", ] @@ -229,7 +229,6 @@ dependencies = [ "alloc_system", "compiler_builtins", "core", - "libc", "std", "test", ] diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index a4f766cf89cb3..bb66d201a5172 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -12,8 +12,6 @@ test = { path = "./sysroot_src/src/libtest" } alloc_system = { path = "./alloc_system" } -libc = { version = "=0.2.69", default-features = false } # FIXME rustc 1.45.0-nightly (7ebd87a7a 2020-05-08) ices on libc 0.2.70 - [patch.crates-io] rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" } From af0fa74615b1b30145b6762ae2eec3ca4c6c391c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 11:02:26 +0200 Subject: [PATCH 1337/1566] [CI] Run the compile step with CARGO_INCREMENTAL=1 --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 29c848bdf9eff..db7e7b8c9476b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,6 +57,8 @@ jobs: with: command: rustc args: --release -- -Zrun_dsymutil=no + env: + CARGO_INCREMENTAL: 1 - name: Test run: | From b6144483ef86ae6f3e0e0a3188c174d16e33825f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 11:08:06 +0200 Subject: [PATCH 1338/1566] Revert "[CI] Run the compile step with CARGO_INCREMENTAL=1" This reverts commit af0fa74615b1b30145b6762ae2eec3ca4c6c391c. It didn't do anything --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index db7e7b8c9476b..29c848bdf9eff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,8 +57,6 @@ jobs: with: command: rustc args: --release -- -Zrun_dsymutil=no - env: - CARGO_INCREMENTAL: 1 - name: Test run: | From daad966be73fabe13d6704476e1581ac555a281e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 11:36:39 +0200 Subject: [PATCH 1339/1566] Some changes necessary for Windows support cc #977 --- config.sh | 4 ++++ src/abi/mod.rs | 10 ++-------- src/base.rs | 11 +++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config.sh b/config.sh index 0f75e331a7e7e..9a745ad59520e 100644 --- a/config.sh +++ b/config.sh @@ -12,6 +12,7 @@ fi HOST_TRIPLE=$(rustc -vV | grep host | cut -d: -f2 | tr -d " ") TARGET_TRIPLE=$HOST_TRIPLE +#TARGET_TRIPLE="x86_64-pc-windows-gnu" #TARGET_TRIPLE="aarch64-unknown-linux-gnu" linker='' @@ -21,6 +22,9 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. linker='-Clinker=aarch64-linux-gnu-gcc' RUN_WRAPPER='qemu-aarch64 -L /usr/aarch64-linux-gnu' + elif [[ "$TARGET_TRIPLE" == "x86_64-pc-windows-gnu" ]]; then + # We are cross-compiling for Windows. Run tests in wine. + RUN_WRAPPER='wine' else echo "Unknown non-native platform" fi diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 8f59fa91bfb49..8b00304e04094 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -85,18 +85,12 @@ fn clif_sig_from_fn_sig<'tcx>( requires_caller_location: bool, ) -> Signature { let abi = match sig.abi { - Abi::System => { - if tcx.sess.target.target.options.is_like_windows { - unimplemented!() - } else { - Abi::C - } - } + Abi::System => Abi::C, abi => abi, }; let (call_conv, inputs, output): (CallConv, Vec>, Ty<'tcx>) = match abi { Abi::Rust => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), - Abi::C => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), + Abi::C | Abi::Unadjusted => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().kind { diff --git a/src/base.rs b/src/base.rs index 244e06f76278e..547ed01503e25 100644 --- a/src/base.rs +++ b/src/base.rs @@ -679,6 +679,17 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } + // ___chkstk, ___chkstk_ms and __alloca are only used on Windows + _ if fx.tcx.symbol_name(fx.instance).name.as_str().starts_with("___chkstk") => { + crate::trap::trap_unimplemented(fx, "Stack probes are not supported"); + } + _ if fx.tcx.symbol_name(fx.instance).name.as_str() == "__alloca" => { + crate::trap::trap_unimplemented(fx, "Alloca is not supported"); + } + // Used in sys::windows::abort_internal + "int $$0x29" => { + crate::trap::trap_unimplemented(fx, "Windows abort"); + } _ => unimpl_fatal!(fx.tcx, stmt.source_info.span, "Inline assembly is not supported"), } } From 282e3055e1f00b53e8653fb037b7f2b31d57545e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 11:40:21 +0200 Subject: [PATCH 1340/1566] Only run ranlib when necessary --- src/archive.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index ba5249d412f00..3cd650a755dfb 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -220,14 +220,16 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { // Finalize archive std::mem::drop(builder); - // Run ranlib to be able to link the archive - let status = std::process::Command::new("ranlib") - .arg(self.config.dst) - .status() - .expect("Couldn't run ranlib"); - - if !status.success() { - self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); + if self.update_symbols { + // Run ranlib to be able to link the archive + let status = std::process::Command::new("ranlib") + .arg(self.config.dst) + .status() + .expect("Couldn't run ranlib"); + + if !status.success() { + self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); + } } } } From d4187e6aae855f16651aca4973839aec8c58eb29 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 11:50:58 +0200 Subject: [PATCH 1341/1566] Make mini_core_hello_world work on Windows once TLS is supported --- example/mini_core.rs | 7 ++++--- example/mini_core_hello_world.rs | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 2732c6902b1ce..ccca19ccf8cca 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -403,7 +403,7 @@ pub trait FnMut: FnOnce { #[track_caller] pub fn panic(_msg: &str) -> ! { unsafe { - libc::puts("Panicking\n\0" as *const str as *const u8); + libc::puts("Panicking\n\0" as *const str as *const i8); intrinsics::abort(); } } @@ -502,9 +502,10 @@ pub mod intrinsics { } pub mod libc { - #[link(name = "c")] + #[cfg_attr(not(windows), link(name = "c"))] + #[cfg_attr(windows, link(name = "msvcrt"))] extern "C" { - pub fn puts(s: *const u8) -> i32; + pub fn puts(s: *const i8) -> i32; pub fn printf(format: *const i8, ...) -> i32; pub fn malloc(size: usize) -> *mut u8; pub fn free(ptr: *mut u8); diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 82014f594d23b..12c6638dd92db 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -12,7 +12,7 @@ extern crate mini_core; use mini_core::*; use mini_core::libc::*; -unsafe extern "C" fn my_puts(s: *const u8) { +unsafe extern "C" fn my_puts(s: *const i8) { puts(s); } @@ -37,7 +37,7 @@ trait SomeTrait { impl SomeTrait for &'static str { fn object_safe(&self) { unsafe { - puts(*self as *const str as *const u8); + puts(*self as *const str as *const i8); } } } @@ -52,7 +52,7 @@ struct NoisyDropInner; impl Drop for NoisyDrop { fn drop(&mut self) { unsafe { - puts(self.text as *const str as *const u8); + puts(self.text as *const str as *const i8); } } } @@ -60,7 +60,7 @@ impl Drop for NoisyDrop { impl Drop for NoisyDropInner { fn drop(&mut self) { unsafe { - puts("Inner got dropped!\0" as *const str as *const u8); + puts("Inner got dropped!\0" as *const str as *const i8); } } } @@ -82,9 +82,9 @@ fn start( argv: *const *const u8, ) -> isize { if argc == 3 { - unsafe { puts(*argv); } - unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const u8)); } - unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const u8)); } + unsafe { puts(*argv as *const i8); } + unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const i8)); } + unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const i8)); } } main().report(); @@ -154,11 +154,11 @@ fn main() { printf("Hello %s\n\0" as *const str as *const i8, "printf\0" as *const str as *const i8); let hello: &[u8] = b"Hello\0" as &[u8; 6]; - let ptr: *const u8 = hello as *const [u8] as *const u8; + let ptr: *const i8 = hello as *const [u8] as *const i8; puts(ptr); let world: Box<&str> = box "World!\0"; - puts(*world as *const str as *const u8); + puts(*world as *const str as *const i8); world as Box; assert_eq!(intrinsics::bitreverse(0b10101000u8), 0b00010101u8); @@ -242,13 +242,13 @@ fn main() { assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); extern { - #[linkage = "weak"] + #[linkage = "extern_weak"] static ABC: *const u8; } { extern { - #[linkage = "weak"] + #[linkage = "extern_weak"] static ABC: *const u8; } } @@ -351,7 +351,7 @@ fn test_tls() { // TLS of main thread must not have been changed by the other thread. assert_eq!(TLS, 42); - puts("TLS works!\n\0" as *const str as *const u8); + puts("TLS works!\n\0" as *const str as *const i8); } } From 3086e44733499da24272640f73b7a0822e4b548a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 16 Jun 2020 13:27:24 +0200 Subject: [PATCH 1342/1566] Only call build_value_labels_ranges when necessary --- src/base.rs | 31 ++++++++++++++++--------------- src/optimize/mod.rs | 2 +- src/pretty_clif.rs | 16 +++++++++++----- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/base.rs b/src/base.rs index 547ed01503e25..ee4af783d9f9a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -73,7 +73,14 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let local_map = fx.local_map; let cold_blocks = fx.cold_blocks; - crate::pretty_clif::write_clif_file(cx.tcx, "unopt", instance, &context.func, &clif_comments, None); + crate::pretty_clif::write_clif_file( + cx.tcx, + "unopt", + None, + instance, + &context, + &clif_comments, + ); // Verify function verify_func(tcx, &clif_comments, &context.func); @@ -101,20 +108,14 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( ); // Write optimized function to file for debugging - { - let value_ranges = context - .build_value_labels_ranges(cx.module.isa()) - .expect("value location ranges"); - - crate::pretty_clif::write_clif_file( - cx.tcx, - "opt", - instance, - &context.func, - &clif_comments, - Some(&value_ranges), - ); - } + crate::pretty_clif::write_clif_file( + cx.tcx, + "opt", + Some(cx.module.isa()), + instance, + &context, + &clif_comments, + ); // Define debuginfo for function let isa = cx.module.isa(); diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index f4a33ddd82e81..90f5876e2f140 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -18,6 +18,6 @@ pub(crate) fn optimize_function<'tcx>( return; // FIXME classify optimizations over opt levels } self::stack2reg::optimize_function(ctx, clif_comments); - crate::pretty_clif::write_clif_file(tcx, "stack2reg", instance, &ctx.func, &*clif_comments, None); + crate::pretty_clif::write_clif_file(tcx, "stack2reg", None, instance, &ctx, &*clif_comments); crate::base::verify_func(tcx, &*clif_comments, &ctx.func); } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 60dd97ab3fb4e..8b1e611ef2f85 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -203,16 +203,22 @@ impl FunctionCx<'_, '_, B> { pub(crate) fn write_clif_file<'tcx>( tcx: TyCtxt<'tcx>, postfix: &str, + isa: Option<&dyn cranelift_codegen::isa::TargetIsa>, instance: Instance<'tcx>, - func: &cranelift_codegen::ir::Function, + context: &cranelift_codegen::Context, mut clif_comments: &CommentWriter, - value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>, ) { + use std::io::Write; + if !cfg!(debug_assertions) && !tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly) { return; } - use std::io::Write; + let value_ranges = isa.map(|isa| { + context + .build_value_labels_ranges(isa) + .expect("value location ranges") + }); let symbol_name = tcx.symbol_name(instance).name.as_str(); let clif_file_name = format!( @@ -227,12 +233,12 @@ pub(crate) fn write_clif_file<'tcx>( cranelift_codegen::write::decorate_function( &mut clif_comments, &mut clif, - &func, + &context.func, &DisplayFunctionAnnotations { isa: Some(&*crate::build_isa( tcx.sess, true, /* PIC doesn't matter here */ )), - value_ranges, + value_ranges: value_ranges.as_ref(), }, ) .unwrap(); From 266ca933f40c6f14f39ba1e681729908a6276054 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 11:10:27 +0200 Subject: [PATCH 1343/1566] Rustup to rustc 1.46.0-nightly (2d8bd9b74 2020-06-19) --- rust-toolchain | 2 +- src/base.rs | 4 ++-- src/discriminant.rs | 50 ++++++++++++++++++++++----------------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index dce0ff04cc7b4..a7e2f7c2d283a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-16 +nightly-2020-06-20 diff --git a/src/base.rs b/src/base.rs index ee4af783d9f9a..ab7ae75a3658f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -340,11 +340,11 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { bug!("shouldn't exist at trans {:?}", bb_data.terminator()); } TerminatorKind::Drop { - location, + place, target, unwind: _, } => { - let drop_place = trans_place(fx, *location); + let drop_place = trans_place(fx, *place); crate::abi::codegen_drop(fx, bb_data.terminator().source_info.span, drop_place); let target_block = fx.get_block(*target); diff --git a/src/discriminant.rs b/src/discriminant.rs index b51851f0dc9df..d15d74225716e 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -1,6 +1,6 @@ //! Adapted from https://github.com/rust-lang/rust/blob/d760df5aea483aae041c9a241e7acacf48f75035/src/librustc_codegen_ssa/mir/place.rs -use rustc_target::abi::{DiscriminantKind, Int, Variants}; +use rustc_target::abi::{TagEncoding, Int, Variants}; use crate::prelude::*; @@ -18,12 +18,12 @@ pub(crate) fn codegen_set_discriminant<'tcx>( assert_eq!(index, variant_index); } Variants::Multiple { - discr: _, - discr_index, - discr_kind: DiscriminantKind::Tag, + tag: _, + tag_field, + tag_encoding: TagEncoding::Direct, variants: _, } => { - let ptr = place.place_field(fx, mir::Field::new(discr_index)); + let ptr = place.place_field(fx, mir::Field::new(tag_field)); let to = layout .ty .discriminant_for_variant(fx.tcx, variant_index) @@ -33,10 +33,10 @@ pub(crate) fn codegen_set_discriminant<'tcx>( ptr.write_cvalue(fx, discr); } Variants::Multiple { - discr: _, - discr_index, - discr_kind: - DiscriminantKind::Niche { + tag: _, + tag_field, + tag_encoding: + TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start, @@ -44,7 +44,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( variants: _, } => { if variant_index != dataful_variant { - let niche = place.place_field(fx, mir::Field::new(discr_index)); + let niche = place.place_field(fx, mir::Field::new(tag_field)); let niche_value = variant_index.as_u32() - niche_variants.start().as_u32(); let niche_value = u128::from(niche_value).wrapping_add(niche_start); let niche_llval = CValue::const_val(fx, niche.layout(), niche_value); @@ -69,7 +69,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>( ); } - let (discr_scalar, discr_index, discr_kind) = match &layout.variants { + let (tag_scalar, tag_field, tag_encoding) = match &layout.variants { Variants::Single { index } => { let discr_val = layout .ty @@ -78,30 +78,30 @@ pub(crate) fn codegen_get_discriminant<'tcx>( return CValue::const_val(fx, dest_layout, discr_val); } Variants::Multiple { - discr, - discr_index, - discr_kind, + tag, + tag_field, + tag_encoding, variants: _, - } => (discr, *discr_index, discr_kind), + } => (tag, *tag_field, tag_encoding), }; let cast_to = fx.clif_type(dest_layout.ty).unwrap(); // Read the tag/niche-encoded discriminant from memory. - let encoded_discr = value.value_field(fx, mir::Field::new(discr_index)); - let encoded_discr = encoded_discr.load_scalar(fx); + let tag = value.value_field(fx, mir::Field::new(tag_field)); + let tag = tag.load_scalar(fx); // Decode the discriminant (specifically if it's niche-encoded). - match *discr_kind { - DiscriminantKind::Tag => { - let signed = match discr_scalar.value { + match *tag_encoding { + TagEncoding::Direct => { + let signed = match tag_scalar.value { Int(_, signed) => signed, _ => false, }; - let val = clif_intcast(fx, encoded_discr, cast_to, signed); - return CValue::by_val(val, dest_layout); + let val = clif_intcast(fx, tag, cast_to, signed); + CValue::by_val(val, dest_layout) } - DiscriminantKind::Niche { + TagEncoding::Niche { dataful_variant, ref niche_variants, niche_start, @@ -119,12 +119,12 @@ pub(crate) fn codegen_get_discriminant<'tcx>( // that might not fit in the same type, on top of needing an extra // comparison (see also the comment on `let niche_discr`). let relative_discr = if niche_start == 0 { - encoded_discr + tag } else { // FIXME handle niche_start > i64::MAX fx.bcx .ins() - .iadd_imm(encoded_discr, -i64::try_from(niche_start).unwrap()) + .iadd_imm(tag, -i64::try_from(niche_start).unwrap()) }; let relative_max = niche_variants.end().as_u32() - niche_variants.start().as_u32(); let is_niche = { From b4d9d8a4ccee32d35b75df474856152c7a000a92 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 11:21:52 +0200 Subject: [PATCH 1344/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3999a85d3ebe5..00cb7545bc006 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#647d2b423131c533af57e59e98928ca5d1f6887e" +source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" dependencies = [ "cranelift-codegen", "cranelift-module", From f718378f115f487b5ff6270453a9cbb79d808562 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 11:31:48 +0200 Subject: [PATCH 1345/1566] Ignore libcore test that requires unwinding support --- patches/0023-core-Ignore-failing-tests.patch | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index b6b1e93bb6bf3..4df67fceb1a29 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -10,6 +10,26 @@ Subject: [PATCH] [core] Ignore failing tests src/libcore/tests/time.rs | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) +diff --git a/src/libcore/tests/array.rs b/src/libcore/tests/array.rs +index 4bc44e9..8e3c7a4 100644 +--- a/src/libcore/tests/array.rs ++++ b/src/libcore/tests/array.rs +@@ -242,6 +242,7 @@ fn iterator_drops() { + assert_eq!(i.get(), 5); + } + ++/* + // This test does not work on targets without panic=unwind support. + // To work around this problem, test is marked is should_panic, so it will + // be automagically skipped on unsuitable targets, such as +@@ -283,6 +284,7 @@ fn array_default_impl_avoids_leaks_on_panic() { + assert_eq!(COUNTER.load(Relaxed), 0); + panic!("test succeeded") + } ++*/ + + #[test] + fn empty_array_is_always_default() { diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index c9096b7..be37fcd 100644 --- a/src/libcore/tests/iter.rs From 5c6bf836fe3d4cfda1b827a5cd3982e5a588c0ff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 12:01:24 +0200 Subject: [PATCH 1346/1566] Implement #[link_section] Fixes #1047 --- example/std_example.rs | 2 ++ ...g-initialization-on-linux-to-not-req.patch | 26 ------------------- src/constant.rs | 15 ++++++----- src/driver/jit.rs | 5 ++-- test.sh | 2 +- 5 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch diff --git a/example/std_example.rs b/example/std_example.rs index d7e8cf73ea8f1..530e5549b43a8 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -5,6 +5,8 @@ use std::io::Write; use std::ops::Generator; fn main() { + println!("{:?}", std::env::args().collect::>()); + let mutex = std::sync::Mutex::new(()); let _guard = mutex.lock().unwrap(); diff --git a/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch b/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch deleted file mode 100644 index 599da32ee8288..0000000000000 --- a/patches/0024-libstd-Revert-arg-initialization-on-linux-to-not-req.patch +++ /dev/null @@ -1,26 +0,0 @@ -From eaa0c3eac2067c7c08913653ebef10c103c1255f Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Mon, 16 Dec 2019 11:46:10 +0100 -Subject: [PATCH] [libstd] Revert arg initialization on linux to not require - #[link_section] - ---- - src/libstd/sys/unix/args.rs | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/src/libstd/sys/unix/args.rs b/src/libstd/sys/unix/args.rs -index 2ed1585..b4b021a 100644 ---- a/src/libstd/sys/unix/args.rs -+++ b/src/libstd/sys/unix/args.rs -@@ -83,7 +83,7 @@ mod imp { - // On Linux-GNU, we rely on `ARGV_INIT_ARRAY` below to initialize - // `ARGC` and `ARGV`. But in Miri that does not actually happen so we - // still initialize here. -- #[cfg(any(miri, not(all(target_os = "linux", target_env = "gnu"))))] -+ // `#[link_section]` is not yet supported by cg_clif - really_init(_argc, _argv); - } - --- -2.20.1 - diff --git a/src/constant.rs b/src/constant.rs index 84981c72fc0ce..cb797b3a5fe15 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -264,7 +264,7 @@ fn data_id_for_static( 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 { + let (data_id, alloc, section_name) = match todo_item { TodoItem::Alloc(alloc_id) => { //println!("alloc_id {}", alloc_id); let alloc = match tcx.get_global_alloc(alloc_id).unwrap() { @@ -272,14 +272,12 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu GlobalAlloc::Function(_) | GlobalAlloc::Static(_) => unreachable!(), }; let data_id = data_id_for_alloc_id(module, alloc_id, alloc.align); - (data_id, alloc) + (data_id, alloc, None) } TodoItem::Static(def_id) => { //println!("static {:?}", def_id); - if tcx.is_foreign_item(def_id) { - continue; - } + let section_name = tcx.codegen_fn_attrs(def_id).link_section.map(|s| s.as_str()); let const_ = tcx.const_eval_poly(def_id).unwrap(); @@ -298,7 +296,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu Linkage::Export // FIXME Set hidden visibility }, ); - (data_id, alloc) + (data_id, alloc, section_name) } }; @@ -309,6 +307,11 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let mut data_ctx = DataContext::new(); + if let Some(section_name) = section_name { + // FIXME set correct segment for Mach-O files + data_ctx.set_segment_section("", &*section_name); + } + let bytes = alloc.inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); data_ctx.define(bytes.into_boxed_slice()); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index ab6c9da25addb..15e4947ca46c9 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -75,9 +75,8 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { unsafe { ::std::mem::transmute(finalized_main) }; let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new()); - let args = args - .split(" ") - .chain(Some(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())) + let args = std::iter::once(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string()) + .chain(args.split(" ")) .map(|arg| CString::new(arg).unwrap()) .collect::>(); let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); diff --git a/test.sh b/test.sh index cea435d896300..7127ba79fe985 100755 --- a/test.sh +++ b/test.sh @@ -58,7 +58,7 @@ $RUN_WRAPPER ./target/out/dst_field_align || (echo $?; false) echo "[AOT] std_example" $RUSTC example/std_example.rs --crate-type bin --target $TARGET_TRIPLE -$RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/std_example arg echo "[AOT] subslice-patterns-const-eval" $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE From ef4186a85b4c9bd94d258e3280cb239f26b8436e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 13:23:31 +0200 Subject: [PATCH 1347/1566] Use Cranelift legalization for icmp.i128 The previous translation was wrong for signed 128bit comparisions This fixes several libcore tests --- example/std_example.rs | 6 ++ ...022-core-Disable-not-compiling-tests.patch | 22 +---- patches/0023-core-Ignore-failing-tests.patch | 93 ------------------- src/common.rs | 45 --------- src/intrinsics/mod.rs | 12 +-- src/num.rs | 2 +- 6 files changed, 14 insertions(+), 166 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index 530e5549b43a8..7038df874a467 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -81,6 +81,12 @@ fn main() { assert_eq!(houndred_f32 as i128, 100); assert_eq!(houndred_f64 as i128, 100); + // Test signed 128bit comparing + let max = usize::MAX as i128; + if 100i128 < 0i128 || 100i128 > max { + panic!(); + } + let _a = 1u32 << 2u8; let empty: [i32; 0] = []; diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch index 36f83c0fcccac..282d476bd7504 100644 --- a/patches/0022-core-Disable-not-compiling-tests.patch +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -119,25 +119,5 @@ index 6609bc3..241b497 100644 #[test] #[should_panic(expected = "index 0 greater than length of slice")] -diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index b73b621..d6cc3f8 100644 ---- a/src/libcore/tests/iter.rs -+++ b/src/libcore/tests/iter.rs -@@ -2541,6 +2541,7 @@ fn test_steps_between() { - - // Skip u64/i64 to avoid differences with 32-bit vs 64-bit platforms - -+ /* - assert_eq!(Step::steps_between(&20_u128, &200_u128), Some(180_usize)); - assert_eq!(Step::steps_between(&-20_i128, &80_i128), Some(100_usize)); - if cfg!(target_pointer_width = "64") { -@@ -2552,6 +2553,7 @@ fn test_steps_between() { - Step::steps_between(&-0x1_0000_0000_0000_0000_i128, &0x1_0000_0000_0000_0000_i128,), - None, - ); -+ */ - } - - #[test] --- +-- 2.21.0 (Apple Git-122) diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index 4df67fceb1a29..18b5ed3d3bdd3 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -66,87 +66,6 @@ index c9096b7..be37fcd 100644 fn test_successors() { let mut powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10)); assert_eq!(powers_of_10.by_ref().collect::>(), &[1, 10, 100, 1_000, 10_000]); -diff --git a/src/libcore/tests/num/bignum.rs b/src/libcore/tests/num/bignum.rs -index b9e15ec..32f6de8 100644 ---- a/src/libcore/tests/num/bignum.rs -+++ b/src/libcore/tests/num/bignum.rs -@@ -3,6 +3,7 @@ use core::num::bignum::tests::Big8x3 as Big; - - #[test] - #[should_panic] -+#[ignore] - fn test_from_u64_overflow() { - Big::from_u64(0x1000000); - } -@@ -19,12 +20,14 @@ fn test_add() { - - #[test] - #[should_panic] -+#[ignore] - fn test_add_overflow_1() { - Big::from_small(1).add(&Big::from_u64(0xffffff)); - } - - #[test] - #[should_panic] -+#[ignore] - fn test_add_overflow_2() { - Big::from_u64(0xffffff).add(&Big::from_small(1)); - } -@@ -42,6 +45,7 @@ fn test_add_small() { - - #[test] - #[should_panic] -+#[ignore] - fn test_add_small_overflow() { - Big::from_u64(0xffffff).add_small(1); - } -@@ -76,6 +80,7 @@ fn test_mul_small() { - - #[test] - #[should_panic] -+#[ignore] - fn test_mul_small_overflow() { - Big::from_u64(0x800000).mul_small(2); - } -@@ -118,12 +123,14 @@ fn test_mul_pow5() { - - #[test] - #[should_panic] -+#[ignore] - fn test_mul_pow5_overflow_1() { - Big::from_small(1).mul_pow5(12); - } - - #[test] - #[should_panic] -+#[ignore] - fn test_mul_pow5_overflow_2() { - Big::from_small(230).mul_pow5(8); - } -@@ -141,12 +148,14 @@ fn test_mul_digits() { - - #[test] - #[should_panic] -+#[ignore] - fn test_mul_digits_overflow_1() { - Big::from_u64(0x800000).mul_digits(&[2]); - } - - #[test] - #[should_panic] -+#[ignore] - fn test_mul_digits_overflow_2() { - Big::from_u64(0x1000).mul_digits(&[0, 0x10]); - } -@@ -206,6 +215,7 @@ fn test_get_bit() { - - #[test] - #[should_panic] -+#[ignore] - fn test_get_bit_out_of_range() { - Big::from_small(42).get_bit(24); - } diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index a17c094..5bb11d2 100644 --- a/src/libcore/tests/num/mod.rs @@ -159,18 +78,6 @@ index a17c094..5bb11d2 100644 fn from_str_issue7588() { let u: Option = u8::from_str_radix("1000", 10).ok(); assert_eq!(u, None); -@@ -613,11 +614,9 @@ test_impl_try_from_signed_to_unsigned_err! { test_try_i64u32, i64, u32 } - test_impl_try_from_signed_to_unsigned_err! { test_try_i128u8, i128, u8 } - test_impl_try_from_signed_to_unsigned_err! { test_try_i128u16, i128, u16 } - test_impl_try_from_signed_to_unsigned_err! { test_try_i128u32, i128, u32 } --test_impl_try_from_signed_to_unsigned_err! { test_try_i128u64, i128, u64 } - - assume_usize_width! { - test_impl_try_from_signed_to_unsigned_err! { test_try_isizeu8, isize, u8 } -- test_impl_try_from_signed_to_unsigned_err! { test_try_i128usize, i128, usize } - - cfg_block! { - #[cfg(target_pointer_width = "16")] { @@ -640,6 +639,7 @@ macro_rules! test_float { mod $modname { // FIXME(nagisa): these tests should test for sign of -0.0 diff --git a/src/common.rs b/src/common.rs index 0547e02b43972..e3312eb135390 100644 --- a/src/common.rs +++ b/src/common.rs @@ -81,51 +81,6 @@ pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { } } -pub(crate) fn codegen_icmp( - fx: &mut FunctionCx<'_, '_, impl Backend>, - intcc: IntCC, - lhs: Value, - rhs: Value, -) -> Value { - let lhs_ty = fx.bcx.func.dfg.value_type(lhs); - let rhs_ty = fx.bcx.func.dfg.value_type(rhs); - assert_eq!(lhs_ty, rhs_ty); - if lhs_ty == types::I128 { - // FIXME legalize `icmp.i128` in Cranelift - - let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs); - let (rhs_lsb, rhs_msb) = fx.bcx.ins().isplit(rhs); - - match intcc { - IntCC::Equal => { - let lsb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_lsb, rhs_lsb); - let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); - fx.bcx.ins().band(lsb_eq, msb_eq) - } - IntCC::NotEqual => { - let lsb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_lsb, rhs_lsb); - let msb_ne = fx.bcx.ins().icmp(IntCC::NotEqual, lhs_msb, rhs_msb); - fx.bcx.ins().bor(lsb_ne, msb_ne) - } - _ => { - // if msb_eq { - // lsb_cc - // } else { - // msb_cc - // } - - let msb_eq = fx.bcx.ins().icmp(IntCC::Equal, lhs_msb, rhs_msb); - let lsb_cc = fx.bcx.ins().icmp(intcc, lhs_lsb, rhs_lsb); - let msb_cc = fx.bcx.ins().icmp(intcc, lhs_msb, rhs_msb); - - fx.bcx.ins().select(msb_eq, lsb_cc, msb_cc) - } - } - } else { - fx.bcx.ins().icmp(intcc, lhs, rhs) - } -} - pub(crate) fn codegen_icmp_imm( fx: &mut FunctionCx<'_, '_, impl Backend>, intcc: IntCC, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index d97973667f303..594d24b581e36 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -126,7 +126,7 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ let old = $fx.bcx.ins().load(clif_ty, MemFlags::new(), $ptr, 0); // Compare - let is_eq = codegen_icmp($fx, IntCC::SignedGreaterThan, old, $src); + let is_eq = $fx.bcx.ins().icmp(IntCC::SignedGreaterThan, old, $src); let new = $fx.bcx.ins().select(is_eq, old, $src); // Write new @@ -257,7 +257,7 @@ macro simd_cmp { if let Some(vector_ty) = vector_ty { let x = $x.load_scalar($fx); let y = $y.load_scalar($fx); - let val = codegen_icmp($fx, IntCC::$cc, x, y); + let val = $fx.bcx.ins().icmp(IntCC::$cc, x, y); // HACK This depends on the fact that icmp for vectors represents bools as 0 and !0, not 0 and 1. let val = $fx.bcx.ins().raw_bitcast(vector_ty, val); @@ -271,7 +271,7 @@ macro simd_cmp { $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = match lane_layout.ty.kind { - ty::Uint(_) | ty::Int(_) => codegen_icmp(fx, IntCC::$cc, x_lane, y_lane), + ty::Uint(_) | ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) @@ -288,8 +288,8 @@ macro simd_cmp { $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { let res_lane = match lane_layout.ty.kind { - ty::Uint(_) => codegen_icmp(fx, IntCC::$cc_u, x_lane, y_lane), - ty::Int(_) => codegen_icmp(fx, IntCC::$cc_s, x_lane, y_lane), + ty::Uint(_) => fx.bcx.ins().icmp(IntCC::$cc_u, x_lane, y_lane), + ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc_s, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) @@ -869,7 +869,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let old = fx.bcx.ins().load(clif_ty, MemFlags::new(), ptr, 0); // Compare - let is_eq = codegen_icmp(fx, IntCC::Equal, old, test_old); + let is_eq = fx.bcx.ins().icmp(IntCC::Equal, old, test_old); let new = fx.bcx.ins().select(is_eq, new, old); // Keep old if not equal to test_old // Write new diff --git a/src/num.rs b/src/num.rs index b0d04f1227989..5acff80768eaf 100644 --- a/src/num.rs +++ b/src/num.rs @@ -46,7 +46,7 @@ fn codegen_compare_bin_op<'tcx>( rhs: Value, ) -> CValue<'tcx> { let intcc = crate::num::bin_op_to_intcc(bin_op, signed).unwrap(); - let val = codegen_icmp(fx, intcc, lhs, rhs); + let val = fx.bcx.ins().icmp(intcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)) } From 177348fbb49631c9ea6ec974c709e9a6530820aa Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 14:26:05 +0200 Subject: [PATCH 1348/1566] Unignore some more libcore tests --- patches/0023-core-Ignore-failing-tests.patch | 24 ++++---------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index 18b5ed3d3bdd3..1c9097f21abe8 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -38,31 +38,15 @@ index c9096b7..be37fcd 100644 } #[test] -+#[ignore] ++#[ignore] // checked_mul impl not yet checking for overflow fn test_iterator_step_by_nth_overflow() { #[cfg(target_pointer_width = "8")] type Bigger = u16; -@@ -2184,6 +2185,7 @@ fn test_range_inclusive_folds() { - } - - #[test] -+#[ignore] - fn test_range_size_hint() { - assert_eq!((0..0usize).size_hint(), (0, Some(0))); - assert_eq!((0..100usize).size_hint(), (100, Some(100))); -@@ -2210,6 +2212,7 @@ fn test_range_size_hint() { - } - - #[test] -+#[ignore] - fn test_range_inclusive_size_hint() { - assert_eq!((1..=0usize).size_hint(), (0, Some(0))); - assert_eq!((0..=0usize).size_hint(), (1, Some(1))); @@ -2305,6 +2308,7 @@ fn test_repeat_with_take_collect() { } #[test] -+#[ignore] ++#[ignore] // checked_mul impl not yet checking for overflow fn test_successors() { let mut powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10)); assert_eq!(powers_of_10.by_ref().collect::>(), &[1, 10, 100, 1_000, 10_000]); @@ -74,7 +58,7 @@ index a17c094..5bb11d2 100644 } #[test] -+#[ignore] ++#[ignore] // checked_mul impl not yet checking for overflow fn from_str_issue7588() { let u: Option = u8::from_str_radix("1000", 10).ok(); assert_eq!(u, None); @@ -102,7 +86,7 @@ index fac70c4..9107a02 100644 } #[test] -+#[ignore] ++#[ignore] // checked_mul impl not yet checking for overflow fn checked_mul() { assert_eq!(Duration::new(0, 1).checked_mul(2), Some(Duration::new(0, 2))); assert_eq!(Duration::new(1, 1).checked_mul(3), Some(Duration::new(3, 3))); From 5f54cc7658ffb538fa9ad06727ca0bedd009beaf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 15:15:28 +0200 Subject: [PATCH 1349/1566] Implement checked_mul Fixes #6 --- Readme.md | 2 +- example/std_example.rs | 23 ++++++++++ patches/0023-core-Ignore-failing-tests.patch | 40 ----------------- src/num.rs | 46 +++++++++++++++----- 4 files changed, 60 insertions(+), 51 deletions(-) diff --git a/Readme.md b/Readme.md index e850b320fe282..1146f7e415edf 100644 --- a/Readme.md +++ b/Readme.md @@ -67,6 +67,6 @@ function jit_calc() { ## Not yet supported * Good non-rust abi support ([several problems](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) -* Checked binops ([some missing instructions in cranelift](https://github.com/bytecodealliance/wasmtime/issues/1044)) + * Proc macros * Inline assembly ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1041), not coming soon) * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171), some basic things work) diff --git a/example/std_example.rs b/example/std_example.rs index 7038df874a467..ebac391f1e590 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -87,6 +87,8 @@ fn main() { panic!(); } + test_checked_mul(); + let _a = 1u32 << 2u8; let empty: [i32; 0] = []; @@ -258,6 +260,27 @@ unsafe fn test_mm_extract_epi8() { assert_eq!(r2, 3); } +fn test_checked_mul() { + let u: Option = u8::from_str_radix("1000", 10).ok(); + assert_eq!(u, None); + + assert_eq!(1u8.checked_mul(255u8), Some(255u8)); + assert_eq!(255u8.checked_mul(255u8), None); + assert_eq!(1i8.checked_mul(127i8), Some(127i8)); + assert_eq!(127i8.checked_mul(127i8), None); + assert_eq!((-1i8).checked_mul(-127i8), Some(127i8)); + assert_eq!(1i8.checked_mul(-128i8), Some(-128i8)); + assert_eq!((-128i8).checked_mul(-128i8), None); + + assert_eq!(1u64.checked_mul(u64::max_value()), Some(u64::max_value())); + assert_eq!(u64::max_value().checked_mul(u64::max_value()), None); + assert_eq!(1i64.checked_mul(i64::max_value()), Some(i64::max_value())); + assert_eq!(i64::max_value().checked_mul(i64::max_value()), None); + assert_eq!((-1i64).checked_mul(i64::min_value() + 1), Some(i64::max_value())); + assert_eq!(1i64.checked_mul(i64::min_value()), Some(i64::min_value())); + assert_eq!(i64::min_value().checked_mul(i64::min_value()), None); +} + #[derive(PartialEq)] enum LoopState { Continue(()), diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index 1c9097f21abe8..bb3a03338f2da 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -30,38 +30,10 @@ index 4bc44e9..8e3c7a4 100644 #[test] fn empty_array_is_always_default() { -diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs -index c9096b7..be37fcd 100644 ---- a/src/libcore/tests/iter.rs -+++ b/src/libcore/tests/iter.rs -@@ -342,6 +342,7 @@ fn test_iterator_step_by_nth() { - } - - #[test] -+#[ignore] // checked_mul impl not yet checking for overflow - fn test_iterator_step_by_nth_overflow() { - #[cfg(target_pointer_width = "8")] - type Bigger = u16; -@@ -2305,6 +2308,7 @@ fn test_repeat_with_take_collect() { - } - - #[test] -+#[ignore] // checked_mul impl not yet checking for overflow - fn test_successors() { - let mut powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10)); - assert_eq!(powers_of_10.by_ref().collect::>(), &[1, 10, 100, 1_000, 10_000]); diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index a17c094..5bb11d2 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs -@@ -63,6 +63,7 @@ pub fn test_num(ten: T, two: T) where - } - - #[test] -+#[ignore] // checked_mul impl not yet checking for overflow - fn from_str_issue7588() { - let u: Option = u8::from_str_radix("1000", 10).ok(); - assert_eq!(u, None); @@ -640,6 +639,7 @@ macro_rules! test_float { mod $modname { // FIXME(nagisa): these tests should test for sign of -0.0 @@ -78,17 +50,5 @@ index a17c094..5bb11d2 100644 fn max() { assert_eq!((0.0 as $fty).max(0.0), 0.0); assert_eq!((-0.0 as $fty).max(-0.0), -0.0); -diff --git a/src/libcore/tests/time.rs b/src/libcore/tests/time.rs -index fac70c4..9107a02 100644 ---- a/src/libcore/tests/time.rs -+++ b/src/libcore/tests/time.rs -@@ -127,6 +127,7 @@ fn mul() { - } - - #[test] -+#[ignore] // checked_mul impl not yet checking for overflow - fn checked_mul() { - assert_eq!(Duration::new(0, 1).checked_mul(2), Some(Duration::new(0, 2))); - assert_eq!(Duration::new(1, 1).checked_mul(3), Some(Duration::new(3, 3))); -- 2.21.0 (Apple Git-122) diff --git a/src/num.rs b/src/num.rs index 5acff80768eaf..5cf281cba6f77 100644 --- a/src/num.rs +++ b/src/num.rs @@ -245,16 +245,42 @@ pub(crate) fn trans_checked_int_binop<'tcx>( (val, has_overflow) } BinOp::Mul => { - let val = fx.bcx.ins().imul(lhs, rhs); - /*let val_hi = if !signed { - fx.bcx.ins().umulhi(lhs, rhs) - } else { - fx.bcx.ins().smulhi(lhs, rhs) - }; - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0);*/ - // TODO: check for overflow - let has_overflow = fx.bcx.ins().bconst(types::B1, false); - (val, has_overflow) + let ty = fx.bcx.func.dfg.value_type(lhs); + match ty { + types::I8 | types::I16 | types::I32 if !signed => { + let lhs = fx.bcx.ins().uextend(ty.double_width().unwrap(), lhs); + let rhs = fx.bcx.ins().uextend(ty.double_width().unwrap(), rhs); + let val = fx.bcx.ins().imul(lhs, rhs); + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, val, (1 << ty.bits()) - 1); + let val = fx.bcx.ins().ireduce(ty, val); + (val, has_overflow) + } + types::I8 | types::I16 | types::I32 if signed => { + let lhs = fx.bcx.ins().sextend(ty.double_width().unwrap(), lhs); + let rhs = fx.bcx.ins().sextend(ty.double_width().unwrap(), rhs); + let val = fx.bcx.ins().imul(lhs, rhs); + let has_underflow = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, val, -(1 << (ty.bits() - 1))); + let has_overflow = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThan, val, (1 << (ty.bits() - 1)) - 1); + let val = fx.bcx.ins().ireduce(ty, val); + (val, fx.bcx.ins().bor(has_underflow, has_overflow)) + } + types::I64 => { + //let val = fx.easy_call("__mulodi4", &[lhs, rhs, overflow_ptr], types::I64); + let val = fx.bcx.ins().imul(lhs, rhs); + let has_overflow = if !signed { + let val_hi = fx.bcx.ins().umulhi(lhs, rhs); + fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0) + } else { + let val_hi = fx.bcx.ins().smulhi(lhs, rhs); + let not_all_zero = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0); + let not_all_ones = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, u64::try_from((1u128 << ty.bits()) - 1).unwrap() as i64); + fx.bcx.ins().band(not_all_zero, not_all_ones) + }; + (val, has_overflow) + } + types::I128 => unreachable!("i128 should have been handled by codegen_i128::maybe_codegen"), + _ => unreachable!("invalid non-integer type {}", ty), + } } BinOp::Shl => { let val = fx.bcx.ins().ishl(lhs, rhs); From 392348d3d1941f3960a9179da44a6016cac03506 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 15:29:12 +0200 Subject: [PATCH 1350/1566] Ignore less of the libcore float tests --- patches/0023-core-Ignore-failing-tests.patch | 46 ++++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index bb3a03338f2da..e1d0cdcd42b46 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -34,21 +34,41 @@ diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index a17c094..5bb11d2 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs -@@ -640,6 +639,7 @@ macro_rules! test_float { - mod $modname { - // FIXME(nagisa): these tests should test for sign of -0.0 - #[test] -+ #[ignore] - fn min() { - assert_eq!((0.0 as $fty).min(0.0), 0.0); - assert_eq!((-0.0 as $fty).min(-0.0), -0.0); -@@ -662,6 +662,7 @@ macro_rules! test_float { - assert!(($nan as $fty).min($nan).is_nan()); +@@ -651,11 +651,12 @@ macro_rules! test_float { + assert_eq!((9.0 as $fty).min($neginf), $neginf); + assert_eq!(($neginf as $fty).min(-9.0), $neginf); + assert_eq!((-9.0 as $fty).min($neginf), $neginf); +- assert_eq!(($nan as $fty).min(9.0), 9.0); +- assert_eq!(($nan as $fty).min(-9.0), -9.0); +- assert_eq!((9.0 as $fty).min($nan), 9.0); +- assert_eq!((-9.0 as $fty).min($nan), -9.0); +- assert!(($nan as $fty).min($nan).is_nan()); ++ // Cranelift fmin has NaN propagation ++ //assert_eq!(($nan as $fty).min(9.0), 9.0); ++ //assert_eq!(($nan as $fty).min(-9.0), -9.0); ++ //assert_eq!((9.0 as $fty).min($nan), 9.0); ++ //assert_eq!((-9.0 as $fty).min($nan), -9.0); ++ //assert!(($nan as $fty).min($nan).is_nan()); } #[test] -+ #[ignore] fn max() { - assert_eq!((0.0 as $fty).max(0.0), 0.0); - assert_eq!((-0.0 as $fty).max(-0.0), -0.0); +@@ -673,11 +674,12 @@ macro_rules! test_float { + assert_eq!((9.0 as $fty).max($neginf), 9.0); + assert_eq!(($neginf as $fty).max(-9.0), -9.0); + assert_eq!((-9.0 as $fty).max($neginf), -9.0); +- assert_eq!(($nan as $fty).max(9.0), 9.0); +- assert_eq!(($nan as $fty).max(-9.0), -9.0); +- assert_eq!((9.0 as $fty).max($nan), 9.0); +- assert_eq!((-9.0 as $fty).max($nan), -9.0); +- assert!(($nan as $fty).max($nan).is_nan()); ++ // Cranelift fmax has NaN propagation ++ //assert_eq!(($nan as $fty).max(9.0), 9.0); ++ //assert_eq!(($nan as $fty).max(-9.0), -9.0); ++ //assert_eq!((9.0 as $fty).max($nan), 9.0); ++ //assert_eq!((-9.0 as $fty).max($nan), -9.0); ++ //assert!(($nan as $fty).max($nan).is_nan()); + } + #[test] + fn rem_euclid() { -- 2.21.0 (Apple Git-122) From 431cebdca1a0d74a7252d22f2cfa220325c05b21 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 16:22:03 +0200 Subject: [PATCH 1351/1566] Introduce #[cfg(target_feature = "cg_clif")] --- patches/0016-Disable-cpuid-intrinsic.patch | 6 ++++-- src/lib.rs | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/patches/0016-Disable-cpuid-intrinsic.patch b/patches/0016-Disable-cpuid-intrinsic.patch index ac24bc6e88c24..0cccdb13ad6f9 100644 --- a/patches/0016-Disable-cpuid-intrinsic.patch +++ b/patches/0016-Disable-cpuid-intrinsic.patch @@ -11,12 +11,14 @@ diff --git a/src/stdarch/crates/core_arch/src/x86/cpuid.rs b/src/stdarch/crates/ index f313c42..ff952bc 100644 --- a/src/stdarch/crates/core_arch/src/x86/cpuid.rs +++ b/src/stdarch/crates/core_arch/src/x86/cpuid.rs -@@ -84,6 +84,9 @@ pub unsafe fn __cpuid(leaf: u32) -> CpuidResult { +@@ -84,6 +84,11 @@ pub unsafe fn __cpuid(leaf: u32) -> CpuidResult { /// Does the host support the `cpuid` instruction? #[inline] pub fn has_cpuid() -> bool { + // __cpuid intrinsic is not yet implemented -+ return false; ++ #[cfg(target_feature = "cg_clif")] { ++ return false; ++ } + #[cfg(target_env = "sgx")] { diff --git a/src/lib.rs b/src/lib.rs index 517ccd41706ce..cb89afbf6197b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -188,11 +188,13 @@ impl CodegenBackend for CraneliftCodegenBackend { // rustdoc needs to be able to document functions that use all the features, so // whitelist them all target_features_whitelist::all_known_features() + .chain(Some(("cg_clif", None))) .map(|(a, b)| (a.to_string(), b)) .collect() } else { target_features_whitelist::target_feature_whitelist(tcx.sess) .iter() + .chain(&Some(("cg_clif", None))) .map(|&(a, b)| (a.to_string(), b)) .collect() } @@ -200,6 +202,10 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn provide_extern(&self, _providers: &mut Providers<'_>) {} + fn target_features(&self, _sess: &Session) -> Vec { + vec![rustc_span::Symbol::intern("cg_clif")] + } + fn codegen_crate<'tcx>( &self, tcx: TyCtxt<'tcx>, From eb8fd197ab174306de96f8f1c8bc7019c4b5ccda Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 18:44:49 +0200 Subject: [PATCH 1352/1566] Prelude cleanup --- src/abi/mod.rs | 6 +++--- src/archive.rs | 3 +-- src/base.rs | 12 ++++++------ src/common.rs | 10 ---------- src/driver/aot.rs | 4 ++-- src/driver/jit.rs | 2 +- src/driver/mod.rs | 6 +++--- src/intrinsics/mod.rs | 2 +- src/lib.rs | 28 ++++++++++------------------ 9 files changed, 27 insertions(+), 46 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 8b00304e04094..4e9ab4e7a0506 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -169,7 +169,7 @@ pub(crate) fn get_function_name_and_sig<'tcx>( let fn_sig = tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_sig_for_fn_abi(tcx, inst)); if fn_sig.c_variadic && !support_vararg { - unimpl_fatal!(tcx, tcx.def_span(inst.def_id()), "Variadic function definitions are not yet supported"); + tcx.sess.span_fatal(tcx.def_span(inst.def_id()), "Variadic function definitions are not yet supported"); } let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, false, inst.def.requires_caller_location(tcx)); (tcx.symbol_name(inst).name.as_str().to_string(), sig) @@ -601,7 +601,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { if fn_sig.abi != Abi::C { - unimpl_fatal!(fx.tcx, span, "Variadic call for non-C abi {:?}", fn_sig.abi); + fx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); let abi_params = call_args @@ -610,7 +610,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - unimpl_fatal!(fx.tcx, span, "Non int ty {:?} for variadic call", ty); + fx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); } AbiParam::new(ty) }) diff --git a/src/archive.rs b/src/archive.rs index 3cd650a755dfb..f4685d3d9e166 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,8 +1,7 @@ use std::fs::File; use std::path::{Path, PathBuf}; -use crate::prelude::*; - +use rustc_session::Session; use rustc_codegen_ssa::back::archive::{find_library, ArchiveBuilder}; use rustc_codegen_ssa::METADATA_FILENAME; diff --git a/src/base.rs b/src/base.rs index ab7ae75a3658f..54aa409de1166 100644 --- a/src/base.rs +++ b/src/base.rs @@ -134,12 +134,12 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( pub(crate) fn verify_func(tcx: TyCtxt<'_>, writer: &crate::pretty_clif::CommentWriter, func: &Function) { tcx.sess.time("verify clif ir", || { - let flags = settings::Flags::new(settings::builder()); - match ::cranelift_codegen::verify_function(&func, &flags) { + let flags = cranelift_codegen::settings::Flags::new(cranelift_codegen::settings::builder()); + match cranelift_codegen::verify_function(&func, &flags) { Ok(_) => {} Err(err) => { tcx.sess.err(&format!("{:?}", err)); - let pretty_error = ::cranelift_codegen::print_errors::pretty_verifier_error( + let pretty_error = cranelift_codegen::print_errors::pretty_verifier_error( &func, None, Some(Box::new(writer)), @@ -323,7 +323,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { // Black box } - _ => unimpl_fatal!(fx.tcx, bb_data.terminator().source_info.span, "Inline assembly is not supported"), + _ => fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, "Inline assembly is not supported"), } } TerminatorKind::Resume | TerminatorKind::Abort => { @@ -363,7 +363,7 @@ fn trans_stmt<'tcx>( cur_block: Block, stmt: &Statement<'tcx>, ) { - let _print_guard = PrintOnPanic(|| format!("stmt {:?}", stmt)); + let _print_guard = crate::PrintOnPanic(|| format!("stmt {:?}", stmt)); fx.set_debug_loc(stmt.source_info); @@ -691,7 +691,7 @@ fn trans_stmt<'tcx>( "int $$0x29" => { crate::trap::trap_unimplemented(fx, "Windows abort"); } - _ => unimpl_fatal!(fx.tcx, stmt.source_info.span, "Inline assembly is not supported"), + _ => fx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), } } } diff --git a/src/common.rs b/src/common.rs index e3312eb135390..ec58a7d3d29e1 100644 --- a/src/common.rs +++ b/src/common.rs @@ -302,16 +302,6 @@ impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { } } -impl<'tcx, B: Backend> BackendTypes for FunctionCx<'_, 'tcx, B> { - type Value = Value; - type Function = Value; - type BasicBlock = Block; - type Type = Type; - type Funclet = !; - type DIScope = !; - type DIVariable = !; -} - impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub(crate) fn monomorphize(&self, value: &T) -> T where diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 303031c0c036c..9b05a146020e9 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -4,7 +4,7 @@ use rustc_middle::mir::mono::CodegenUnit; use rustc_session::config::{DebugInfo, OutputType}; use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_codegen_ssa::back::linker::LinkerInfo; -use rustc_codegen_ssa::CrateInfo; +use rustc_codegen_ssa::{CrateInfo, CodegenResults, CompiledModule, ModuleKind}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use crate::prelude::*; @@ -110,7 +110,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege let module = new_module(tcx, cgu_name.as_str().to_string()); - let mut cx = CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); + let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); super::codegen_mono_items(&mut cx, mono_items); let (mut module, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 15e4947ca46c9..93535cd16def6 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -52,7 +52,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { .into_iter() .collect::>(); - let mut cx = CodegenCx::new(tcx, jit_module, false); + let mut cx = crate::CodegenCx::new(tcx, jit_module, false); let (mut jit_module, _debug, mut unwind_context) = super::time(tcx, "codegen mono items", || { super::codegen_mono_items(&mut cx, mono_items); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index ded3bbe1e2cf8..d75b6e05f3206 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -30,7 +30,7 @@ pub(crate) fn codegen_crate( } fn codegen_mono_items<'tcx>( - cx: &mut CodegenCx<'tcx, impl Backend + 'static>, + cx: &mut crate::CodegenCx<'tcx, impl Backend + 'static>, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { cx.tcx.sess.time("predefine functions", || { @@ -62,9 +62,9 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( match mono_item { MonoItem::Fn(inst) => { let _inst_guard = - PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name.as_str())); + crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name.as_str())); debug_assert!(!inst.substs.needs_infer()); - let _mir_guard = PrintOnPanic(|| { + let _mir_guard = crate::PrintOnPanic(|| { match inst.def { InstanceDef::Item(_) | InstanceDef::DropGlue(_, _) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 594d24b581e36..32447b7a92587 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -452,7 +452,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - unimpl_fatal!(fx.tcx, span, "unsupported intrinsic {}", intrinsic); + fx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); }; assume, (c _a) {}; diff --git a/src/lib.rs b/src/lib.rs index cb89afbf6197b..3a96184ad75e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,11 +29,13 @@ use std::any::Any; use rustc_errors::ErrorReported; use rustc_middle::dep_graph::{DepGraph, WorkProduct, WorkProductId}; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; +use rustc_session::Session; use rustc_session::config::OutputFilenames; use rustc_middle::ty::query::Providers; +use rustc_codegen_ssa::CodegenResults; use rustc_codegen_ssa::traits::CodegenBackend; -use cranelift_codegen::settings; +use cranelift_codegen::settings::{self, Configurable}; use crate::constant::ConstantCx; use crate::prelude::*; @@ -75,7 +77,6 @@ mod prelude { pub(crate) use rustc_middle::bug; pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE}; pub(crate) use rustc_middle::mir::{self, *}; - pub(crate) use rustc_session::Session; pub(crate) use rustc_middle::ty::layout::{self, TyAndLayout}; pub(crate) use rustc_target::abi::{Abi, LayoutOf, Scalar, Size, VariantIdx}; pub(crate) use rustc_middle::ty::{ @@ -86,9 +87,6 @@ mod prelude { pub(crate) use rustc_index::vec::Idx; - pub(crate) use rustc_codegen_ssa::traits::*; - pub(crate) use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleKind}; - pub(crate) use cranelift_codegen::Context; pub(crate) use cranelift_codegen::entity::EntitySet; pub(crate) use cranelift_codegen::ir::{AbiParam, Block, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; @@ -96,7 +94,6 @@ mod prelude { pub(crate) use cranelift_codegen::ir::function::Function; pub(crate) use cranelift_codegen::ir::types; pub(crate) use cranelift_codegen::isa::{self, CallConv}; - pub(crate) use cranelift_codegen::settings::{self, Configurable}; pub(crate) use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; pub(crate) use cranelift_module::{ self, Backend, DataContext, DataId, FuncId, Linkage, Module, @@ -110,23 +107,18 @@ mod prelude { pub(crate) use crate::pointer::Pointer; pub(crate) use crate::trap::*; pub(crate) use crate::value_and_place::{CPlace, CPlaceInner, CValue}; - pub(crate) use crate::CodegenCx; +} - pub(crate) struct PrintOnPanic String>(pub F); - impl String> Drop for PrintOnPanic { - fn drop(&mut self) { - if ::std::thread::panicking() { - println!("{}", (self.0)()); - } +struct PrintOnPanic String>(F); +impl String> Drop for PrintOnPanic { + fn drop(&mut self) { + if ::std::thread::panicking() { + println!("{}", (self.0)()); } } - - pub(crate) macro unimpl_fatal($tcx:expr, $span:expr, $($tt:tt)*) { - $tcx.sess.span_fatal($span, &format!($($tt)*)); - } } -pub(crate) struct CodegenCx<'tcx, B: Backend + 'static> { +struct CodegenCx<'tcx, B: Backend + 'static> { tcx: TyCtxt<'tcx>, module: Module, constants_cx: ConstantCx, From fc5e583006b4b7e8d248789de1258232c6fc01c4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 19:03:54 +0200 Subject: [PATCH 1353/1566] Warn on unsupported pass modes for extern "C" cc #10 --- src/abi/mod.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 4e9ab4e7a0506..dbfca15ead9fd 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -81,6 +81,7 @@ fn clif_sig_from_fn_sig<'tcx>( tcx: TyCtxt<'tcx>, triple: &target_lexicon::Triple, sig: FnSig<'tcx>, + span: Span, is_vtable_fn: bool, requires_caller_location: bool, ) -> Signature { @@ -118,7 +119,25 @@ fn clif_sig_from_fn_sig<'tcx>( .layout_of(ParamEnv::reveal_all().and(tcx.mk_mut_ptr(tcx.mk_unit()))) .unwrap(); } - get_pass_mode(tcx, layout).get_param_ty(tcx).into_iter() + let pass_mode = get_pass_mode(tcx, layout); + if abi != Abi::Rust && abi != Abi::RustCall && abi != Abi::RustIntrinsic { + match pass_mode { + PassMode::NoPass | PassMode::ByVal(_) => {} + PassMode::ByValPair(_, _) | PassMode::ByRef { sized: _ } => { + tcx.sess.span_warn( + span, + &format!( + "Argument of type `{:?}` with pass mode `{:?}` is not yet supported \ + for non-rust abi `{}`. Calling this function may result in a crash.", + layout.ty, + pass_mode, + abi, + ), + ); + } + } + } + pass_mode.get_param_ty(tcx).into_iter() }) .flatten(); @@ -171,7 +190,7 @@ pub(crate) fn get_function_name_and_sig<'tcx>( if fn_sig.c_variadic && !support_vararg { tcx.sess.span_fatal(tcx.def_span(inst.def_id()), "Variadic function definitions are not yet supported"); } - let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, false, inst.def.requires_caller_location(tcx)); + let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, tcx.def_span(inst.def_id()), false, inst.def.requires_caller_location(tcx)); (tcx.symbol_name(inst).name.as_str().to_string(), sig) } @@ -584,6 +603,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( fx.tcx, fx.triple(), fn_sig, + span, is_virtual_call, false, // calls through function pointers never pass the caller location ); @@ -654,6 +674,7 @@ pub(crate) fn codegen_drop<'tcx>( fx.tcx, fx.triple(), fn_sig, + span, true, false, // `drop_in_place` is never `#[track_caller]` ); From b79102c933aff3393a2b392339dec0e8291ef5ee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 20 Jun 2020 19:14:58 +0200 Subject: [PATCH 1354/1566] Disable "LTO is not supported" warning for sysroot build --- build_sysroot/Cargo.toml | 4 ++++ src/lib.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index bb66d201a5172..339e0d5fdc799 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -17,6 +17,10 @@ rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" } rustc-std-workspace-std = { path = "./sysroot_src/src/tools/rustc-std-workspace-std" } +[profile.dev] +lto = "off" + [profile.release] debug = true incremental = true +lto = "off" diff --git a/src/lib.rs b/src/lib.rs index 3a96184ad75e8..3e562977b8ee2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -164,7 +164,7 @@ struct CraneliftCodegenBackend; impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { - if sess.lto() != rustc_session::config::Lto::No { + if sess.lto() != rustc_session::config::Lto::No && sess.opts.cg.embed_bitcode { sess.warn("LTO is not supported. You may get a linker error."); } } From 9c0d18c8db1e60343f61641a71d8b69bb1ad6233 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 21 Jun 2020 10:35:45 +0200 Subject: [PATCH 1355/1566] Simplify assert_assignable Assignments are no longer used to implicitly cast between &mut T and &T --- src/value_and_place.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 5ddaf09caea9e..f27fe271e9ee3 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -362,17 +362,6 @@ impl<'tcx> CPlace<'tcx> { to_ty: Ty<'tcx>, ) { match (&from_ty.kind, &to_ty.kind) { - (ty::Ref(_, t, Mutability::Not), ty::Ref(_, u, Mutability::Not)) - | (ty::Ref(_, t, Mutability::Mut), ty::Ref(_, u, Mutability::Not)) - | (ty::Ref(_, t, Mutability::Mut), ty::Ref(_, u, Mutability::Mut)) => { - assert_assignable(fx, t, u); - // &mut T -> &T is allowed - // &'a T -> &'b T is allowed - } - (ty::Ref(_, _, Mutability::Not), ty::Ref(_, _, Mutability::Mut)) => panic!( - "Cant assign value of type {} to place of type {}", - from_ty, to_ty - ), (ty::FnPtr(_), ty::FnPtr(_)) => { let from_sig = fx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), From 1f3dd4f91c83271b6a42a778949a199d2acd63c6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 23 Jun 2020 11:41:35 +0200 Subject: [PATCH 1356/1566] Prevent different vtables with the same name Fixes #987 --- src/vtable.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/vtable.rs b/src/vtable.rs index 8302047a44e12..c0cb70f3ff646 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -136,12 +136,13 @@ fn build_vtable<'tcx>( .module .declare_data( &format!( - "__vtable.{}.for.{:?}", + "__vtable.{}.for.{:?}.{}", trait_ref .as_ref() .map(|trait_ref| format!("{:?}", trait_ref.skip_binder()).into()) .unwrap_or(std::borrow::Cow::Borrowed("???")), - layout.ty + layout.ty, + fx.vtables.len(), ), Linkage::Local, false, @@ -158,10 +159,7 @@ fn build_vtable<'tcx>( ) .unwrap(); - match fx.module.define_data(data_id, &data_ctx) { - Ok(()) | Err(cranelift_module::ModuleError::DuplicateDefinition(_)) => {} - err => err.unwrap(), - } + fx.module.define_data(data_id, &data_ctx).unwrap(); data_id } From f77fab81198dd37d491c5e8ca4b0fa443a476f5a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jun 2020 11:52:13 +0200 Subject: [PATCH 1357/1566] Rustup to rustc 1.46.0-nightly (6bb3dbfc6 2020-06-22) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index a7e2f7c2d283a..3996824011ca4 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-20 +nightly-2020-06-23 From 98c83d21f55b5b66e55f6908f31dbd0cd1a96f59 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jun 2020 11:54:11 +0200 Subject: [PATCH 1358/1566] Remove leftover of removed hack --- src/abi/mod.rs | 15 +++++---------- src/base.rs | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index dbfca15ead9fd..4bf06a7490a7d 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -306,7 +306,6 @@ fn local_place<'tcx>( pub(crate) fn codegen_fn_prelude<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_block: Block, - should_codegen_locals: bool, ) { let ssa_analyzed = crate::analyze::analyze(fx); @@ -424,17 +423,13 @@ pub(crate) fn codegen_fn_prelude<'tcx>( } } - // HACK should_codegen_locals required for the ``implement ` as FnOnce>::call_once` - // without `alloca``` hack in `base::trans_fn`. - if should_codegen_locals { - for local in fx.mir.vars_and_temps_iter() { - let ty = fx.monomorphize(&fx.mir.local_decls[local].ty); - let layout = fx.layout_of(ty); + for local in fx.mir.vars_and_temps_iter() { + let ty = fx.monomorphize(&fx.mir.local_decls[local].ty); + let layout = fx.layout_of(ty); - let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; + let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; - local_place(fx, local, layout, is_ssa); - } + local_place(fx, local, layout, is_ssa); } fx.bcx diff --git a/src/base.rs b/src/base.rs index 54aa409de1166..a205a0525fbcc 100644 --- a/src/base.rs +++ b/src/base.rs @@ -61,7 +61,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( crate::trap::trap_unreachable(&mut fx, "function has uninhabited argument"); } else { tcx.sess.time("codegen clif ir", || { - tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block, true)); + tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block)); codegen_fn_content(&mut fx); }); } From a3cd293148e0678074cbbec06e5d3e9159a14ea0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 24 Jun 2020 12:10:20 +0200 Subject: [PATCH 1359/1566] Don't perform a double substitution in some cases --- src/common.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common.rs b/src/common.rs index ec58a7d3d29e1..1d69018be50a4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -305,13 +305,17 @@ impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub(crate) fn monomorphize(&self, value: &T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable<'tcx> + Copy, { - self.tcx.subst_and_normalize_erasing_regions( - self.instance.substs, - ty::ParamEnv::reveal_all(), - value, - ) + if let Some(substs) = self.instance.substs_for_mir_body() { + self.tcx.subst_and_normalize_erasing_regions( + substs, + ty::ParamEnv::reveal_all(), + value, + ) + } else { + self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) + } } pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option { From eda840a498d1cf796d3be386c8f985ec0d17e91f Mon Sep 17 00:00:00 2001 From: Vitaly Shukela Date: Thu, 25 Jun 2020 18:59:46 +0300 Subject: [PATCH 1360/1566] Longer README about how to use this instead of `cargo run` (#1054) * Longer README about how to use this instead of `cargo run` Resolves #1052. Co-authored-by: bjorn3 --- Readme.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 1146f7e415edf..23167f82bfeb3 100644 --- a/Readme.md +++ b/Readme.md @@ -13,14 +13,20 @@ $ ./test.sh --release ## Usage -`$cg_clif_dir` is the directory you cloned this repo into in the following instructions. +rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects. + +Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`prepare.sh` and `test.sh`). ### Cargo +In the directory with your project (where you can do the usual `cargo build`), run: + ```bash $ CHANNEL="release" $cg_clif_dir/cargo.sh run ``` +This should build and run your project with rustc_codegen_cranelift instead of the usual LLVM backend. + If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. ### Rustc From 58ffc47bbf759fa8fd9d51a67fe4a277984054ad Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 25 Jun 2020 18:01:55 +0200 Subject: [PATCH 1361/1566] Add goal and better current status to readme --- Readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Readme.md b/Readme.md index 23167f82bfeb3..6759403b64fa9 100644 --- a/Readme.md +++ b/Readme.md @@ -2,6 +2,8 @@ > ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠ +The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). This has the potential to improve compilation times in debug mode. If your project doesn't use any of the things listed under "Not yet supported", it should probably work fine. If not please open an issue. + ## Building ```bash From 48d4bc2fb6469465b9104e2095f4c0ad38b7cfb5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jun 2020 11:29:39 +0200 Subject: [PATCH 1362/1566] Rustup to rustc 1.46.0-nightly (7750c3d46 2020-06-26) --- build_sysroot/Cargo.lock | 4 ++-- example/mini_core.rs | 1 + rust-toolchain | 2 +- src/abi/mod.rs | 3 +-- src/base.rs | 2 +- src/constant.rs | 2 +- src/intrinsics/mod.rs | 10 ++++++++++ 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 3183d7660c60e..d26dfd186b904 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.54" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" +checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368" [[package]] name = "cfg-if" diff --git a/example/mini_core.rs b/example/mini_core.rs index ccca19ccf8cca..bc5610855aea2 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -388,6 +388,7 @@ pub struct PhantomData; #[lang = "fn_once"] #[rustc_paren_sugar] pub trait FnOnce { + #[lang = "fn_once_output"] type Output; extern "rust-call" fn call_once(self, args: Args) -> Self::Output; diff --git a/rust-toolchain b/rust-toolchain index 3996824011ca4..87ae49d6620b4 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-23 +nightly-2020-06-27 diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 4bf06a7490a7d..a70314758d0b3 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -377,9 +377,8 @@ pub(crate) fn codegen_fn_prelude<'tcx>( let local_decl = &fx.mir.local_decls[local]; // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( - fx.tcx, + fx.tcx.at(local_decl.source_info.span), ParamEnv::reveal_all(), - local_decl.source_info.span, ); if local_decl.mutability == mir::Mutability::Not && !internally_mutable { // We wont mutate this argument, so it is fine to borrow the backing storage diff --git a/src/base.rs b/src/base.rs index a205a0525fbcc..8d2087b352831 100644 --- a/src/base.rs +++ b/src/base.rs @@ -219,7 +219,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, } => { if !fx.tcx.sess.overflow_checks() { - if let mir::AssertKind::OverflowNeg = *msg { + if let mir::AssertKind::OverflowNeg(_) = *msg { let target = fx.get_block(*target); fx.bcx.ins().jump(target, &[]); continue; diff --git a/src/constant.rs b/src/constant.rs index cb797b3a5fe15..d4ec9b68ff312 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -219,7 +219,7 @@ fn data_id_for_static( let is_mutable = if tcx.is_mutable_static(def_id) { true } else { - !ty.is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + !ty.is_freeze(tcx.at(DUMMY_SP), ParamEnv::reveal_all()) }; let align = tcx .layout_of(ParamEnv::reveal_all().and(ty)) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 32447b7a92587..c74ed2d306117 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -816,6 +816,16 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( ret.write_cvalue(fx, val); }; + ptr_guaranteed_eq, (c a, c b) { + let val = crate::num::trans_ptr_binop(fx, BinOp::Eq, a, b); + ret.write_cvalue(fx, val); + }; + + ptr_guaranteed_ne, (c a, c b) { + let val = crate::num::trans_ptr_binop(fx, BinOp::Ne, a, b); + ret.write_cvalue(fx, val); + }; + caller_location, () { let caller_location = fx.get_caller_location(span); ret.write_cvalue(fx, caller_location); From ef924329a1dc09b150d87a9183f7a467ee54c4f7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jun 2020 11:37:08 +0200 Subject: [PATCH 1363/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00cb7545bc006..9e19eeb067b39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#f4e3e4efde28ac90be9fd68dcbda2943b3851155" +source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" dependencies = [ "cranelift-codegen", "cranelift-module", From 4bfc4a14b668fff3aa8fc1500bb27be8c7fefc17 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jun 2020 11:37:34 +0200 Subject: [PATCH 1364/1566] Update dependencies --- Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e19eeb067b39..7cb64cec02863 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,9 +32,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.54" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" +checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368" [[package]] name = "cfg-if" @@ -354,9 +354,9 @@ checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] name = "syn" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5304cfdf27365b7585c25d4af91b35016ed21ef88f17ced89c7093b43dba8b6" +checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" dependencies = [ "proc-macro2", "quote", @@ -391,9 +391,9 @@ dependencies = [ [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "wasmparser" @@ -403,9 +403,9 @@ checksum = "747467da102640806cf6643e032a70174e7768839bcac7e71a0a9aaa54761d59" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", From 3227203fe64fe966ad04f50f7aea232f00fbed6a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 27 Jun 2020 11:58:44 +0200 Subject: [PATCH 1365/1566] Don't use a 1-to-1 mapping between mir local and cranelift_frontend variable --- src/abi/comments.rs | 8 +++++--- src/base.rs | 1 + src/common.rs | 7 +++---- src/debuginfo/mod.rs | 5 +++-- src/value_and_place.rs | 23 +++++++++++++---------- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 4405f98addff6..0bfc00c836784 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -2,6 +2,8 @@ use std::borrow::Cow; use rustc_middle::mir; +use cranelift_codegen::entity::EntityRef; + use crate::abi::pass_mode::*; use crate::prelude::*; @@ -72,9 +74,9 @@ pub(super) fn add_local_place_comments<'tcx>( } = layout; let (kind, extra) = match *place.inner() { - CPlaceInner::Var(var) => { - assert_eq!(local, var); - ("ssa", std::borrow::Cow::Borrowed("")) + CPlaceInner::Var(place_local, var) => { + assert_eq!(local, place_local); + ("ssa", Cow::Owned(format!(",var={}", var.index()))) } CPlaceInner::Addr(ptr, meta) => { let meta = if let Some(meta) = meta { diff --git a/src/base.rs b/src/base.rs index 8d2087b352831..20081a408fe96 100644 --- a/src/base.rs +++ b/src/base.rs @@ -51,6 +51,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( constants_cx: &mut cx.constants_cx, vtables: &mut cx.vtables, source_info_set: indexmap::IndexSet::new(), + next_ssa_var: 0, }; let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()); diff --git a/src/common.rs b/src/common.rs index 1d69018be50a4..248ac14d7e451 100644 --- a/src/common.rs +++ b/src/common.rs @@ -6,10 +6,6 @@ use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use crate::prelude::*; -pub(crate) fn mir_var(loc: Local) -> Variable { - Variable::with_u32(loc.index() as u32) -} - pub(crate) fn pointer_ty(tcx: TyCtxt<'_>) -> types::Type { match tcx.data_layout.pointer_size.bits() { 16 => types::I16, @@ -258,6 +254,9 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) vtables: &'clif mut FxHashMap<(Ty<'tcx>, Option>), DataId>, pub(crate) source_info_set: indexmap::IndexSet, + + /// This should only be accessed by `CPlace::new_var`. + pub(crate) next_ssa_var: u32, } impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index bfcb7cfd2146d..4b22f06f3d14a 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -4,6 +4,7 @@ mod unwind; use crate::prelude::*; +use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; @@ -376,8 +377,8 @@ fn place_location<'tcx>( assert!(place.projection.is_empty()); // FIXME implement them match local_map[&place.local].inner() { - CPlaceInner::Var(local) => { - let value_label = cranelift_codegen::ir::ValueLabel::from_u32(local.as_u32()); + CPlaceInner::Var(_local, var) => { + let value_label = cranelift_codegen::ir::ValueLabel::new(var.index()); if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { let loc_list = LocationList( value_loc_ranges diff --git a/src/value_and_place.rs b/src/value_and_place.rs index f27fe271e9ee3..c25458856b68e 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -1,5 +1,6 @@ use crate::prelude::*; +use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir::immediates::Offset32; fn codegen_field<'tcx>( @@ -256,7 +257,7 @@ pub(crate) struct CPlace<'tcx> { #[derive(Debug, Copy, Clone)] pub(crate) enum CPlaceInner { - Var(Local), + Var(Local, Variable), Addr(Pointer, Option), } @@ -301,10 +302,12 @@ impl<'tcx> CPlace<'tcx> { local: Local, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { + let var = Variable::with_u32(fx.next_ssa_var); + fx.next_ssa_var += 1; fx.bcx - .declare_var(mir_var(local), fx.clif_type(layout.ty).unwrap()); + .declare_var(var, fx.clif_type(layout.ty).unwrap()); CPlace { - inner: CPlaceInner::Var(local), + inner: CPlaceInner::Var(local, var), layout, } } @@ -326,9 +329,9 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> { let layout = self.layout(); match self.inner { - CPlaceInner::Var(var) => { - let val = fx.bcx.use_var(mir_var(var)); - fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); + CPlaceInner::Var(_local, var) => { + let val = fx.bcx.use_var(var); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::new(var.index())); CValue::by_val(val, layout) } CPlaceInner::Addr(ptr, extra) => { @@ -351,7 +354,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn to_ptr_maybe_unsized(self) -> (Pointer, Option) { match self.inner { CPlaceInner::Addr(ptr, extra) => (ptr, extra), - CPlaceInner::Var(_) => bug!("Expected CPlace::Addr, found {:?}", self), + CPlaceInner::Var(_, _) => bug!("Expected CPlace::Addr, found {:?}", self), } } @@ -442,7 +445,7 @@ impl<'tcx> CPlace<'tcx> { let dst_layout = self.layout(); let to_ptr = match self.inner { - CPlaceInner::Var(var) => { + CPlaceInner::Var(_local, var) => { let data = CValue(from.0, dst_layout).load_scalar(fx); let src_ty = fx.bcx.func.dfg.value_type(data); let dst_ty = fx.clif_type(self.layout().ty).unwrap(); @@ -459,8 +462,8 @@ impl<'tcx> CPlace<'tcx> { } _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty), }; - fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::from_u32(var.as_u32())); - fx.bcx.def_var(mir_var(var), data); + fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx.def_var(var, data); return; } CPlaceInner::Addr(ptr, None) => { From 57d9dda09ff11dd4481ecd1963b68b4705e21230 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Jun 2020 18:31:36 +0200 Subject: [PATCH 1366/1566] Rustup to rustc 1.46.0-nightly (0ca7f74db 2020-06-29) --- build_sysroot/Cargo.lock | 8 ++++---- rust-toolchain | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index d26dfd186b904..75b3c86fd4e47 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.55" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368" +checksum = "77c1f1d60091c1b73e2b1f4560ab419204b178e625fa945ded7b660becd2bd46" [[package]] name = "cfg-if" @@ -257,9 +257,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", diff --git a/rust-toolchain b/rust-toolchain index 87ae49d6620b4..acc2c472b548a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-27 +nightly-2020-06-30 From c1b1a5a9dc0d9dc1ff575a84309851557f245ed9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Jun 2020 18:41:28 +0200 Subject: [PATCH 1367/1566] Update cc --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7cb64cec02863..675dd9303bef2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,9 +32,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.55" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1be3409f94d7bdceeb5f5fac551039d9b3f00e25da7a74fc4d33400a0d96368" +checksum = "77c1f1d60091c1b73e2b1f4560ab419204b178e625fa945ded7b660becd2bd46" [[package]] name = "cfg-if" From 5262fec06d5cc1971ffdeaf63553c270dad69b85 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 30 Jun 2020 18:48:26 +0200 Subject: [PATCH 1368/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 675dd9303bef2..e602982957446 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/#c91a9313b532067bb53eea44a182bb0c5bd2ebf4" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" dependencies = [ "cranelift-codegen", "cranelift-module", diff --git a/Cargo.toml b/Cargo.toml index b656ed7cb5780..d2eb888ff6e52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,10 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", features = ["unwind"] } -cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/" } -cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/" } -cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/" } +cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] } +cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } +cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } +cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } target-lexicon = "0.10.0" ar = "0.8.0" @@ -42,7 +42,7 @@ features = ["write"] # We don't need read support #gimli = { path = "../" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/" } +cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } libloading = "0.6.0" [profile.dev] From de336e17e4800299aa21d7531c351d7ec1eab6b9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Apr 2020 20:54:04 +0200 Subject: [PATCH 1369/1566] Fix trap_unreachable_ret_value --- src/trap.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/trap.rs b/src/trap.rs index bf644cd5f2f16..4b7f64ce0a911 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -56,7 +56,9 @@ pub(crate) fn trap_unreachable_ret_value<'tcx>( dest_layout: TyAndLayout<'tcx>, msg: impl AsRef, ) -> CValue<'tcx> { - trap_unreachable(fx, msg); + codegen_print(fx, msg.as_ref()); + let true_ = fx.bcx.ins().iconst(types::I32, 1); + fx.bcx.ins().trapnz(true_, TrapCode::UnreachableCodeReached); CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout) } From aa6a4acd787b87e1ca19fb27da79ce072b9725ab Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 12:32:23 +0200 Subject: [PATCH 1370/1566] Fix ptr_offset_from intrinsic --- src/intrinsics/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index c74ed2d306117..a9954aff6d1d2 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -812,7 +812,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let pointee_size: u64 = fx.layout_of(T).size.bytes(); let diff = fx.bcx.ins().isub(ptr, base); // FIXME this can be an exact division. - let val = CValue::by_val(fx.bcx.ins().udiv_imm(diff, pointee_size as i64), isize_layout); + let val = CValue::by_val(fx.bcx.ins().sdiv_imm(diff, pointee_size as i64), isize_layout); ret.write_cvalue(fx, val); }; From e2ab2885c262d5993ec3de4b4ccb6ffd52783f56 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 12:15:11 +0200 Subject: [PATCH 1371/1566] Mark allocations as mutable when necessary --- src/constant.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index d4ec9b68ff312..5c760a467c631 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -132,7 +132,7 @@ pub(crate) fn trans_const_value<'tcx>( let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); - let data_id = data_id_for_alloc_id(fx.module, ptr.alloc_id, alloc.align); + let data_id = data_id_for_alloc_id(fx.module, ptr.alloc_id, alloc.align, alloc.mutability); 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!("{:?}", ptr.alloc_id)); @@ -182,7 +182,7 @@ fn pointer_for_allocation<'tcx>( ) -> crate::pointer::Pointer { let alloc_id = fx.tcx.create_memory_alloc(alloc); fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align); + let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align, alloc.mutability); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] @@ -195,12 +195,13 @@ fn data_id_for_alloc_id( module: &mut Module, alloc_id: AllocId, align: Align, + mutability: rustc_hir::Mutability, ) -> DataId { module .declare_data( &format!("__alloc_{}", alloc_id.0), Linkage::Local, - false, + mutability == rustc_hir::Mutability::Mut, false, Some(align.bytes() as u8), ) @@ -271,7 +272,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu GlobalAlloc::Memory(alloc) => alloc, GlobalAlloc::Function(_) | GlobalAlloc::Static(_) => unreachable!(), }; - let data_id = data_id_for_alloc_id(module, alloc_id, alloc.align); + let data_id = data_id_for_alloc_id(module, alloc_id, alloc.align, alloc.mutability); (data_id, alloc, None) } TodoItem::Static(def_id) => { @@ -333,9 +334,9 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu data_ctx.write_function_addr(offset.bytes() as u32, local_func_id); continue; } - GlobalAlloc::Memory(_) => { + GlobalAlloc::Memory(target_alloc) => { cx.todo.push(TodoItem::Alloc(reloc)); - data_id_for_alloc_id(module, reloc, alloc.align) + data_id_for_alloc_id(module, reloc, target_alloc.align, target_alloc.mutability) } GlobalAlloc::Static(def_id) => { if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { From cc0268fa1ad6aab1b4b7d34a86ad3f9962675d78 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 14:13:03 +0200 Subject: [PATCH 1372/1566] Mask shift amount --- src/num.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/num.rs b/src/num.rs index 5cf281cba6f77..22269b5ee29e5 100644 --- a/src/num.rs +++ b/src/num.rs @@ -168,16 +168,18 @@ pub(crate) fn trans_int_binop<'tcx>( BinOp::BitOr => b.bor(lhs, rhs), BinOp::Shl => { let lhs_ty = fx.bcx.func.dfg.value_type(lhs); - let rhs = clif_intcast(fx, rhs, lhs_ty, false); - fx.bcx.ins().ishl(lhs, rhs) + let actual_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1)); + let actual_shift = clif_intcast(fx, actual_shift, types::I8, false); + fx.bcx.ins().ishl(lhs, actual_shift) } BinOp::Shr => { let lhs_ty = fx.bcx.func.dfg.value_type(lhs); - let rhs = clif_intcast(fx, rhs, lhs_ty, false); + let actual_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1)); + let actual_shift = clif_intcast(fx, actual_shift, types::I8, false); if signed { - fx.bcx.ins().sshr(lhs, rhs) + fx.bcx.ins().sshr(lhs, actual_shift) } else { - fx.bcx.ins().ushr(lhs, rhs) + fx.bcx.ins().ushr(lhs, actual_shift) } } // Compare binops handles by `codegen_binop`. @@ -283,7 +285,10 @@ pub(crate) fn trans_checked_int_binop<'tcx>( } } BinOp::Shl => { - let val = fx.bcx.ins().ishl(lhs, rhs); + let lhs_ty = fx.bcx.func.dfg.value_type(lhs); + let actual_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1)); + let actual_shift = clif_intcast(fx, actual_shift, types::I8, false); + let val = fx.bcx.ins().ishl(lhs, actual_shift); let ty = fx.bcx.func.dfg.value_type(val); let max_shift = i64::from(ty.bits()) - 1; let has_overflow = @@ -291,10 +296,13 @@ pub(crate) fn trans_checked_int_binop<'tcx>( (val, has_overflow) } BinOp::Shr => { + let lhs_ty = fx.bcx.func.dfg.value_type(lhs); + let actual_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1)); + let actual_shift = clif_intcast(fx, actual_shift, types::I8, false); let val = if !signed { - fx.bcx.ins().ushr(lhs, rhs) + fx.bcx.ins().ushr(lhs, actual_shift) } else { - fx.bcx.ins().sshr(lhs, rhs) + fx.bcx.ins().sshr(lhs, actual_shift) }; let ty = fx.bcx.func.dfg.value_type(val); let max_shift = i64::from(ty.bits()) - 1; From bf2ba159723dfe88cfdf301efde4efb7881d98f9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 17:06:59 +0200 Subject: [PATCH 1373/1566] When casting enum to integer sign extend the discriminant if necessary --- src/base.rs | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/base.rs b/src/base.rs index 20081a408fe96..85c0c21c33daa 100644 --- a/src/base.rs +++ b/src/base.rs @@ -515,12 +515,43 @@ fn trans_stmt<'tcx>( _ => unreachable!("cast adt {} -> {}", from_ty, to_ty), } - let discr = crate::discriminant::codegen_get_discriminant( - fx, - operand, - fx.layout_of(to_ty), - ); - lval.write_cvalue(fx, discr); + use rustc_target::abi::{TagEncoding, Int, Variants}; + + match &operand.layout().variants { + Variants::Single { index } => { + let discr = operand.layout().ty.discriminant_for_variant(fx.tcx, *index).unwrap(); + let discr = if discr.ty.is_signed() { + rustc_middle::mir::interpret::sign_extend(discr.val, fx.layout_of(discr.ty).size) + } else { + discr.val + }; + + let discr = CValue::const_val(fx, fx.layout_of(to_ty), discr); + lval.write_cvalue(fx, discr); + } + Variants::Multiple { + tag, + tag_field, + tag_encoding: TagEncoding::Direct, + variants: _, + } => { + let cast_to = fx.clif_type(dest_layout.ty).unwrap(); + + // Read the tag/niche-encoded discriminant from memory. + let encoded_discr = operand.value_field(fx, mir::Field::new(*tag_field)); + let encoded_discr = encoded_discr.load_scalar(fx); + + // Decode the discriminant (specifically if it's niche-encoded). + let signed = match tag.value { + Int(_, signed) => signed, + _ => false, + }; + let val = clif_intcast(fx, encoded_discr, cast_to, signed); + let val = CValue::by_val(val, dest_layout); + lval.write_cvalue(fx, val); + } + Variants::Multiple { ..} => unreachable!(), + } } else { let to_clif_ty = fx.clif_type(to_ty).unwrap(); let from = operand.load_scalar(fx); From f5f24c7a5c9d975c5edc16d19ae613853ff3f4e7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 17:28:45 +0200 Subject: [PATCH 1374/1566] Implement a few volatile intrinsics --- src/intrinsics/mod.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index a9954aff6d1d2..98509847b830f 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -471,7 +471,26 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( assert_eq!(args.len(), 3); let byte_amount = fx.bcx.ins().imul(count, elem_size); - if intrinsic.ends_with("_nonoverlapping") { + if intrinsic.contains("nonoverlapping") { + // FIXME emit_small_memcpy + fx.bcx.call_memcpy(fx.module.target_config(), dst, src, byte_amount); + } else { + // FIXME emit_small_memmove + fx.bcx.call_memmove(fx.module.target_config(), dst, src, byte_amount); + } + }; + // NOTE: the volatile variants have src and dst swapped + volatile_copy_memory | volatile_copy_nonoverlapping_memory, (v dst, v src, v count) { + let elem_size: u64 = fx.layout_of(elem_ty).size.bytes(); + let elem_size = fx + .bcx + .ins() + .iconst(fx.pointer_type, elem_size as i64); + assert_eq!(args.len(), 3); + let byte_amount = fx.bcx.ins().imul(count, elem_size); + + // FIXME make the copy actually volatile when using emit_small_mem{cpy,move} + if intrinsic.contains("nonoverlapping") { // FIXME emit_small_memcpy fx.bcx.call_memcpy(fx.module.target_config(), dst, src, byte_amount); } else { @@ -633,11 +652,13 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( transmute, (c from) { ret.write_cvalue_transmute(fx, from); }; - write_bytes, (c dst, v val, v count) { + write_bytes | volatile_set_memory, (c dst, v val, v count) { let pointee_ty = dst.layout().ty.builtin_deref(true).unwrap().ty; let pointee_size = fx.layout_of(pointee_ty).size.bytes(); let count = fx.bcx.ins().imul_imm(count, pointee_size as i64); let dst_ptr = dst.load_scalar(fx); + // FIXME make the memset actually volatile when switching to emit_small_memset + // FIXME use emit_small_memset fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); }; ctlz | ctlz_nonzero, (v arg) { From c674a32ab8ac535463021e655c91ba5283d5148d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 1 May 2020 17:35:20 +0200 Subject: [PATCH 1375/1566] Implement f*_fast intrinsics --- src/intrinsics/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 98509847b830f..58eed4c2f594e 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -987,6 +987,18 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let ret_val = CValue::const_val(fx, ret.layout(), 0); ret.write_cvalue(fx, ret_val); }; + + fadd_fast | fsub_fast | fmul_fast | fdiv_fast | frem_fast, (c x, c y) { + let res = crate::num::trans_float_binop(fx, match intrinsic { + "fadd_fast" => BinOp::Add, + "fsub_fast" => BinOp::Sub, + "fmul_fast" => BinOp::Mul, + "fdiv_fast" => BinOp::Div, + "frem_fast" => BinOp::Rem, + _ => unreachable!(), + }, x, y); + ret.write_cvalue(fx, res); + }; } if let Some((_, dest)) = destination { From eb89a2c092b8189ee71b34862a3e2fec48bb1c6a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 10 May 2020 18:17:58 +0200 Subject: [PATCH 1376/1566] Implement float_to_int_unchecked intrinsic --- src/intrinsics/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 58eed4c2f594e..aa950067f7b58 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -999,6 +999,16 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }, x, y); ret.write_cvalue(fx, res); }; + float_to_int_unchecked, (v f) { + let res = crate::cast::clif_int_or_float_cast( + fx, + f, + false, + fx.clif_type(ret.layout().ty).unwrap(), + type_sign(ret.layout().ty), + ); + ret.write_cvalue(fx, CValue::by_val(res, ret.layout())); + }; } if let Some((_, dest)) = destination { From a299d0e632772718a7e0bae3f0964a7a3aa7c2e0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Apr 2020 19:00:25 +0200 Subject: [PATCH 1377/1566] Don't panic on unevaluatable promoted constants --- src/common.rs | 3 ++- src/constant.rs | 32 +++++++++++++++++++++++--------- src/intrinsics/mod.rs | 3 ++- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/common.rs b/src/common.rs index 248ac14d7e451..08afe18ae5de4 100644 --- a/src/common.rs +++ b/src/common.rs @@ -351,7 +351,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { )); crate::constant::trans_const_value( self, - ty::Const::from_value(self.tcx, const_loc, self.tcx.caller_location_ty()), + const_loc, + self.tcx.caller_location_ty(), ) } diff --git a/src/constant.rs b/src/constant.rs index 5c760a467c631..8a22ddefbb27a 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -72,7 +72,9 @@ pub(crate) fn trans_constant<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { - let const_ = match constant.literal.val { + let const_ = fx.monomorphize(&constant.literal); + let const_val = match const_.val { + ConstKind::Value(const_val) => const_val, ConstKind::Unevaluated(def_id, ref substs, promoted) if fx.tcx.is_static(def_id) => { assert!(substs.is_empty()); assert!(promoted.is_none()); @@ -83,17 +85,33 @@ pub(crate) fn trans_constant<'tcx>( fx.layout_of(fx.monomorphize(&constant.literal.ty)), ).to_cvalue(fx); } - _ => fx.monomorphize(&constant.literal).eval(fx.tcx, ParamEnv::reveal_all()), + ConstKind::Unevaluated(def_id, ref substs, promoted) => { + match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def_id, substs, promoted, None) { + Ok(const_val) => const_val, + Err(_) => { + if promoted.is_none() { + fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + } + return crate::trap::trap_unreachable_ret_value( + fx, + fx.layout_of(const_.ty), + "erroneous constant encountered", + ); + } + } + } + ConstKind::Param(_) | ConstKind::Infer(_) | ConstKind::Bound(_, _) + | ConstKind::Placeholder(_) | ConstKind::Error(_) => unreachable!("{:?}", const_), }; - trans_const_value(fx, const_) + trans_const_value(fx, const_val, const_.ty) } pub(crate) fn trans_const_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - const_: &'tcx Const<'tcx>, + const_val: ConstValue<'tcx>, + ty: Ty<'tcx> ) -> CValue<'tcx> { - let ty = fx.monomorphize(&const_.ty); let layout = fx.layout_of(ty); assert!(!layout.is_unsized(), "sized const value"); @@ -103,10 +121,6 @@ pub(crate) fn trans_const_value<'tcx>( layout, ); } - let const_val = match const_.val { - ConstKind::Value(const_val) => const_val, - _ => unreachable!("Const {:?} should have been evaluated", const_), - }; match const_val { ConstValue::Scalar(x) => { diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index aa950067f7b58..a5aec52a7e442 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -822,7 +822,8 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); let val = crate::constant::trans_const_value( fx, - ty::Const::from_value(fx.tcx, const_val, ret.layout().ty), + const_val, + ret.layout().ty, ); ret.write_cvalue(fx, val); }; From f3a91164a2404c773eebe5ac7b8b8af100979303 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 2 Jul 2020 19:48:03 +0200 Subject: [PATCH 1378/1566] Rustup to rustc 1.46.0-nightly (f781babf8 2020-07-01) --- build_sysroot/Cargo.lock | 4 ++-- example/mini_core.rs | 2 +- example/track-caller-attribute.rs | 10 ++++------ rust-toolchain | 2 +- src/abi/mod.rs | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 75b3c86fd4e47..f7bd624a014a1 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c1f1d60091c1b73e2b1f4560ab419204b178e625fa945ded7b660becd2bd46" +checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe" [[package]] name = "cfg-if" diff --git a/example/mini_core.rs b/example/mini_core.rs index bc5610855aea2..a8db81fa06d59 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,7 +1,7 @@ #![feature( no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, untagged_unions, decl_macro, rustc_attrs, transparent_unions, optin_builtin_traits, - thread_local, track_caller + thread_local, )] #![no_core] #![allow(dead_code)] diff --git a/example/track-caller-attribute.rs b/example/track-caller-attribute.rs index 40bf369a6fee3..93bab17e46b27 100644 --- a/example/track-caller-attribute.rs +++ b/example/track-caller-attribute.rs @@ -2,8 +2,6 @@ // run-pass -#![feature(track_caller)] - use std::panic::Location; #[track_caller] @@ -22,21 +20,21 @@ fn nested_tracked() -> &'static Location<'static> { fn main() { let location = Location::caller(); assert_eq!(location.file(), file!()); - assert_eq!(location.line(), 23); + assert_eq!(location.line(), 21); assert_eq!(location.column(), 20); let tracked = tracked(); assert_eq!(tracked.file(), file!()); - assert_eq!(tracked.line(), 28); + assert_eq!(tracked.line(), 26); assert_eq!(tracked.column(), 19); let nested = nested_intrinsic(); assert_eq!(nested.file(), file!()); - assert_eq!(nested.line(), 15); + assert_eq!(nested.line(), 13); assert_eq!(nested.column(), 5); let contained = nested_tracked(); assert_eq!(contained.file(), file!()); - assert_eq!(contained.line(), 19); + assert_eq!(contained.line(), 17); assert_eq!(contained.column(), 5); } diff --git a/rust-toolchain b/rust-toolchain index acc2c472b548a..066aa78c0074c 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-06-30 +nightly-2020-07-02 diff --git a/src/abi/mod.rs b/src/abi/mod.rs index a70314758d0b3..00f5f0336a869 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -37,7 +37,7 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx let env_ty = tcx.closure_env_ty(def_id, substs).unwrap(); sig.map_bound(|sig| tcx.mk_fn_sig( - std::iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), + std::iter::once(env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), sig.output(), sig.c_variadic, sig.unsafety, From bc966492c2296e21cac4df0407f59b5a0cde2aff Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 2 Jul 2020 21:58:11 +0200 Subject: [PATCH 1379/1566] Update Cranelift --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e602982957446..52caa4fd18a71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4d57ae99e391251ef9e369ca8bed59d5c33a3ce0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -236,9 +236,9 @@ dependencies = [ [[package]] name = "object" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cbca9424c482ee628fa549d9c812e2cd22f1180b9222c9200fdfa6eb31aecb2" +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" dependencies = [ "crc32fast", "indexmap", @@ -397,9 +397,9 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "wasmparser" -version = "0.54.0" +version = "0.57.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "747467da102640806cf6643e032a70174e7768839bcac7e71a0a9aaa54761d59" +checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" [[package]] name = "winapi" diff --git a/Cargo.toml b/Cargo.toml index d2eb888ff6e52..0a0172429f38a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ indexmap = "1.0.2" cfg-if = "0.1.10" [dependencies.object] -version = "0.19.0" +version = "0.20.0" default-features = false features = ["read", "std", "write"] # We don't need WASM support From aa80ed0a2ddf61acc136e5ae89ee1608046b9493 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 2 Jul 2020 19:23:21 -0300 Subject: [PATCH 1380/1566] Store pairs in SSA --- src/abi/comments.rs | 4 ++ src/abi/mod.rs | 6 ++- src/analyze.rs | 3 +- src/common.rs | 17 +++++++ src/debuginfo/mod.rs | 5 +++ src/value_and_place.rs | 100 ++++++++++++++++++++++++++++++++++++++++- 6 files changed, 131 insertions(+), 4 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 0bfc00c836784..7c4d7b12f6e99 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -78,6 +78,10 @@ pub(super) fn add_local_place_comments<'tcx>( assert_eq!(local, place_local); ("ssa", Cow::Owned(format!(",var={}", var.index()))) } + CPlaceInner::VarPair(place_local, var1, var2) => { + assert_eq!(local, place_local); + ("ssa", Cow::Owned(format!(",var=({}, {})", var1.index(), var2.index()))) + } CPlaceInner::Addr(ptr, meta) => { let meta = if let Some(meta) = meta { Cow::Owned(format!(",meta={}", meta)) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index a70314758d0b3..066383fd83195 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -290,7 +290,11 @@ fn local_place<'tcx>( is_ssa: bool, ) -> CPlace<'tcx> { let place = if is_ssa { - CPlace::new_var(fx, local, layout) + if let rustc_target::abi::Abi::ScalarPair(_, _) = layout.abi { + CPlace::new_var_pair(fx, local, layout) + } else { + CPlace::new_var(fx, local, layout) + } } else { CPlace::new_stack_slot(fx, layout) }; diff --git a/src/analyze.rs b/src/analyze.rs index afb8ac409fe64..c3436785d90f0 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -11,7 +11,8 @@ pub(crate) enum SsaKind { pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { let mut flag_map = fx.mir.local_decls.iter().map(|local_decl| { - if fx.clif_type(fx.monomorphize(&local_decl.ty)).is_some() { + let ty = fx.monomorphize(&local_decl.ty); + if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() { SsaKind::Ssa } else { SsaKind::NotSsa diff --git a/src/common.rs b/src/common.rs index 248ac14d7e451..02b05e5b2dd15 100644 --- a/src/common.rs +++ b/src/common.rs @@ -67,6 +67,19 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<(types::Type, types::Type)> { + Some(match ty.kind { + ty::Tuple(substs) if substs.len() == 2 => { + let mut types = substs.types(); + ( + clif_type_from_ty(tcx, types.next().unwrap())?, + clif_type_from_ty(tcx, types.next().unwrap())?, + ) + } + _ => return None, + }) +} + /// Is a pointer to this type a fat ptr? pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not }); @@ -321,6 +334,10 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { clif_type_from_ty(self.tcx, ty) } + pub(crate) fn clif_pair_type(&self, ty: Ty<'tcx>) -> Option<(Type, Type)> { + clif_pair_type_from_ty(self.tcx, ty) + } + pub(crate) fn get_block(&self, bb: BasicBlock) -> Block { *self.block_map.get(bb).unwrap() } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 4b22f06f3d14a..709c85d240979 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -405,6 +405,11 @@ fn place_location<'tcx>( AttributeValue::Exprloc(Expression::new()) } } + CPlaceInner::VarPair(_, _, _) => { + // FIXME implement this + + AttributeValue::Exprloc(Expression::new()) + } CPlaceInner::Addr(_, _) => { // FIXME implement this (used by arguments and returns) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index c25458856b68e..a55bfddeaaf9a 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -179,12 +179,25 @@ impl<'tcx> CValue<'tcx> { _ => unreachable!("value_field for ByVal with abi {:?}", layout.abi), } } + CValueInner::ByValPair(val1, val2) => { + match layout.abi { + Abi::ScalarPair(_, _) => { + let val = match field.as_u32() { + 0 => val1, + 1 => val2, + _ => bug!("field should be 0 or 1"), + }; + let field_layout = layout.field(&*fx, usize::from(field)); + CValue::by_val(val, field_layout) + } + _ => unreachable!("value_field for ByValPair with abi {:?}", layout.abi), + } + } CValueInner::ByRef(ptr, None) => { let (field_ptr, field_layout) = codegen_field(fx, ptr, None, layout, field); CValue::by_ref(field_ptr, field_layout) } CValueInner::ByRef(_, Some(_)) => todo!(), - _ => bug!("place_field for {:?}", self), } } @@ -258,6 +271,7 @@ pub(crate) struct CPlace<'tcx> { #[derive(Debug, Copy, Clone)] pub(crate) enum CPlaceInner { Var(Local, Variable), + VarPair(Local, Variable, Variable), Addr(Pointer, Option), } @@ -312,6 +326,25 @@ impl<'tcx> CPlace<'tcx> { } } + pub(crate) fn new_var_pair( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + local: Local, + layout: TyAndLayout<'tcx>, + ) -> CPlace<'tcx> { + let var1 = Variable::with_u32(fx.next_ssa_var); + fx.next_ssa_var += 1; + let var2 = Variable::with_u32(fx.next_ssa_var); + fx.next_ssa_var += 1; + + let (ty1, ty2) = fx.clif_pair_type(layout.ty).unwrap(); + fx.bcx.declare_var(var1, ty1); + fx.bcx.declare_var(var2, ty2); + CPlace { + inner: CPlaceInner::VarPair(local, var1, var2), + layout, + } + } + pub(crate) fn for_ptr(ptr: Pointer, layout: TyAndLayout<'tcx>) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::Addr(ptr, None), @@ -334,6 +367,13 @@ impl<'tcx> CPlace<'tcx> { fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::new(var.index())); CValue::by_val(val, layout) } + CPlaceInner::VarPair(_local, var1, var2) => { + let val1 = fx.bcx.use_var(var1); + fx.bcx.set_val_label(val1, cranelift_codegen::ir::ValueLabel::new(var1.index())); + let val2 = fx.bcx.use_var(var2); + fx.bcx.set_val_label(val2, cranelift_codegen::ir::ValueLabel::new(var2.index())); + CValue::by_val_pair(val1, val2, layout) + } CPlaceInner::Addr(ptr, extra) => { if let Some(extra) = extra { CValue::by_ref_unsized(ptr, extra, layout) @@ -354,7 +394,8 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn to_ptr_maybe_unsized(self) -> (Pointer, Option) { match self.inner { CPlaceInner::Addr(ptr, extra) => (ptr, extra), - CPlaceInner::Var(_, _) => bug!("Expected CPlace::Addr, found {:?}", self), + CPlaceInner::Var(_, _) + | CPlaceInner::VarPair(_, _, _) => bug!("Expected CPlace::Addr, found {:?}", self), } } @@ -466,6 +507,45 @@ impl<'tcx> CPlace<'tcx> { fx.bcx.def_var(var, data); return; } + CPlaceInner::VarPair(_local, var1, var2) => { + let (data1, data2) = CValue(from.0, dst_layout).load_scalar_pair(fx); + let (dst_ty1, dst_ty2) = fx.clif_pair_type(self.layout().ty).unwrap(); + + let src_ty1 = fx.bcx.func.dfg.value_type(data1); + let data = match (src_ty1, dst_ty1) { + (_, _) if src_ty1 == dst_ty1 => data1, + + // This is a `write_cvalue_transmute`. + (types::I32, types::F32) | (types::F32, types::I32) + | (types::I64, types::F64) | (types::F64, types::I64) => { + fx.bcx.ins().bitcast(dst_ty1, data1) + } + _ if src_ty1.is_vector() && dst_ty1.is_vector() => { + fx.bcx.ins().raw_bitcast(dst_ty1, data1) + } + _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty1, dst_ty1), + }; + fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var1.index())); + fx.bcx.def_var(var1, data); + + let src_ty2 = fx.bcx.func.dfg.value_type(data2); + let data = match (src_ty2, dst_ty2) { + (_, _) if src_ty2 == dst_ty2 => data2, + + // This is a `write_cvalue_transmute`. + (types::I32, types::F32) | (types::F32, types::I32) + | (types::I64, types::F64) | (types::F64, types::I64) => { + fx.bcx.ins().bitcast(dst_ty2, data2) + } + _ if src_ty2.is_vector() && dst_ty2.is_vector() => { + fx.bcx.ins().raw_bitcast(dst_ty2, data2) + } + _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty2, dst_ty2), + }; + fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var2.index())); + fx.bcx.def_var(var2, data); + return; + } CPlaceInner::Addr(ptr, None) => { if dst_layout.size == Size::ZERO || dst_layout.abi == Abi::Uninhabited { return; @@ -529,6 +609,22 @@ impl<'tcx> CPlace<'tcx> { field: mir::Field, ) -> CPlace<'tcx> { let layout = self.layout(); + if let CPlaceInner::VarPair(local, var1, var2) = self.inner { + let layout = layout.field(&*fx, field.index()); + + match field.as_u32() { + 0 => return CPlace { + inner: CPlaceInner::Var(local, var1), + layout, + }, + 1 => return CPlace { + inner: CPlaceInner::Var(local, var2), + layout, + }, + _ => unreachable!("field should be 0 or 1"), + } + } + let (base, extra) = self.to_ptr_maybe_unsized(); let (field_ptr, field_layout) = codegen_field(fx, base, extra, layout, field); From 9ec2be7d63ce1857721efab8b4a6d5fdd762e1b0 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 3 Jul 2020 09:43:02 -0300 Subject: [PATCH 1381/1566] Extract transmute_value as a function to avoid code repetition --- src/value_and_place.rs | 77 +++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index a55bfddeaaf9a..1d0990163bb4f 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -469,6 +469,30 @@ impl<'tcx> CPlace<'tcx> { #[cfg_attr(not(debug_assertions), allow(unused_variables))] method: &'static str, ) { + fn transmute_value<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + var: Variable, + data: Value, + dst_ty: Type, + ) { + let src_ty = fx.bcx.func.dfg.value_type(data); + let data = match (src_ty, dst_ty) { + (_, _) if src_ty == dst_ty => data, + + // This is a `write_cvalue_transmute`. + (types::I32, types::F32) | (types::F32, types::I32) + | (types::I64, types::F64) | (types::F64, types::I64) => { + fx.bcx.ins().bitcast(dst_ty, data) + } + _ if src_ty.is_vector() && dst_ty.is_vector() => { + fx.bcx.ins().raw_bitcast(dst_ty, data) + } + _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty), + }; + fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx.def_var(var, data); + } + assert_eq!(self.layout().size, from.layout().size); #[cfg(debug_assertions)] @@ -488,62 +512,15 @@ impl<'tcx> CPlace<'tcx> { let to_ptr = match self.inner { CPlaceInner::Var(_local, var) => { let data = CValue(from.0, dst_layout).load_scalar(fx); - let src_ty = fx.bcx.func.dfg.value_type(data); let dst_ty = fx.clif_type(self.layout().ty).unwrap(); - let data = match (src_ty, dst_ty) { - (_, _) if src_ty == dst_ty => data, - - // This is a `write_cvalue_transmute`. - (types::I32, types::F32) | (types::F32, types::I32) - | (types::I64, types::F64) | (types::F64, types::I64) => { - fx.bcx.ins().bitcast(dst_ty, data) - } - _ if src_ty.is_vector() && dst_ty.is_vector() => { - fx.bcx.ins().raw_bitcast(dst_ty, data) - } - _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty), - }; - fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var.index())); - fx.bcx.def_var(var, data); + transmute_value(fx, var, data, dst_ty); return; } CPlaceInner::VarPair(_local, var1, var2) => { let (data1, data2) = CValue(from.0, dst_layout).load_scalar_pair(fx); let (dst_ty1, dst_ty2) = fx.clif_pair_type(self.layout().ty).unwrap(); - - let src_ty1 = fx.bcx.func.dfg.value_type(data1); - let data = match (src_ty1, dst_ty1) { - (_, _) if src_ty1 == dst_ty1 => data1, - - // This is a `write_cvalue_transmute`. - (types::I32, types::F32) | (types::F32, types::I32) - | (types::I64, types::F64) | (types::F64, types::I64) => { - fx.bcx.ins().bitcast(dst_ty1, data1) - } - _ if src_ty1.is_vector() && dst_ty1.is_vector() => { - fx.bcx.ins().raw_bitcast(dst_ty1, data1) - } - _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty1, dst_ty1), - }; - fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var1.index())); - fx.bcx.def_var(var1, data); - - let src_ty2 = fx.bcx.func.dfg.value_type(data2); - let data = match (src_ty2, dst_ty2) { - (_, _) if src_ty2 == dst_ty2 => data2, - - // This is a `write_cvalue_transmute`. - (types::I32, types::F32) | (types::F32, types::I32) - | (types::I64, types::F64) | (types::F64, types::I64) => { - fx.bcx.ins().bitcast(dst_ty2, data2) - } - _ if src_ty2.is_vector() && dst_ty2.is_vector() => { - fx.bcx.ins().raw_bitcast(dst_ty2, data2) - } - _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty2, dst_ty2), - }; - fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var2.index())); - fx.bcx.def_var(var2, data); + transmute_value(fx, var1, data1, dst_ty1); + transmute_value(fx, var2, data2, dst_ty2); return; } CPlaceInner::Addr(ptr, None) => { From ef01b4e3dda14e592946d74169b6ed9ed71cc9b7 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 3 Jul 2020 09:48:19 -0300 Subject: [PATCH 1382/1566] Store fat pointers in ssa variables --- src/common.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common.rs b/src/common.rs index 02b05e5b2dd15..c5f2e3dee438e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -76,6 +76,13 @@ fn clif_pair_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<(type clif_type_from_ty(tcx, types.next().unwrap())?, ) } + ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => { + if has_ptr_meta(tcx, pointee_ty) { + (pointer_ty(tcx), pointer_ty(tcx)) + } else { + return None + } + } _ => return None, }) } From 21edec4ea5bec5b4da691232b3d832cc5d35acf7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 16:39:36 +0200 Subject: [PATCH 1383/1566] Fix core::hint::black_box support --- src/base.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/base.rs b/src/base.rs index 85c0c21c33daa..053f6e81d5ee7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -689,6 +689,9 @@ fn trans_stmt<'tcx>( asm_str_style: _, } = asm; match &*asm_code.as_str() { + "" => { + // Black box + } cpuid if cpuid.contains("cpuid") => { crate::trap::trap_unimplemented( fx, From 798fb856515fd2e9aeedbfe21a903c09cf85c165 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 16:40:57 +0200 Subject: [PATCH 1384/1566] Fix assert_assignable --- src/value_and_place.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 1d0990163bb4f..c9516a98bfe44 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -406,6 +406,10 @@ impl<'tcx> CPlace<'tcx> { to_ty: Ty<'tcx>, ) { match (&from_ty.kind, &to_ty.kind) { + (ty::Ref(_, a, _), ty::Ref(_, b, _)) + | (ty::RawPtr(TypeAndMut { ty: a, mutbl: _}), ty::RawPtr(TypeAndMut { ty: b, mutbl: _})) => { + assert_assignable(fx, a, b); + } (ty::FnPtr(_), ty::FnPtr(_)) => { let from_sig = fx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), From 92dc61aba200b8df43720da2e3e9f302db03a2e3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 16:43:26 +0200 Subject: [PATCH 1385/1566] Only display codegen time when CG_CLIF_DISPLAY_CG_TIME=1 --- Readme.md | 2 +- src/driver/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 6759403b64fa9..61595e97730f4 100644 --- a/Readme.md +++ b/Readme.md @@ -69,7 +69,7 @@ function jit_calc() { to make it possible to use incremental mode for all analyses performed by rustc without caching object files when their content should have been changed by a change to cg_clif.
CG_CLIF_DISPLAY_CG_TIME
-
Display the time it took to perform codegen for a crate
+
If "1", display the time it took to perform codegen for a crate
## Not yet supported diff --git a/src/driver/mod.rs b/src/driver/mod.rs index d75b6e05f3206..9a60b1e6a33c0 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -109,7 +109,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( } fn time(tcx: TyCtxt<'_>, name: &'static str, f: impl FnOnce() -> R) -> R { - if std::env::var("CG_CLIF_DISPLAY_CG_TIME").is_ok() { + if std::env::var("CG_CLIF_DISPLAY_CG_TIME").as_ref().map(|val| &**val) == Ok("1") { println!("[{:<30}: {}] start", tcx.crate_name(LOCAL_CRATE), name); let before = std::time::Instant::now(); let res = tcx.sess.time(name, f); From 4ada18fd77dd27da06a6233bf4b99c90e986b541 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 16:43:59 +0200 Subject: [PATCH 1386/1566] Add sess.abort_if_errors() to link --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3e562977b8ee2..b1e624d87f047 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -234,6 +234,8 @@ impl CodegenBackend for CraneliftCodegenBackend { ) -> Result<(), ErrorReported> { use rustc_codegen_ssa::back::link::link_binary; + sess.abort_if_errors(); + let codegen_results = *res .downcast::() .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); From 8d639cd778bb11fed2c230d8071664e24d30a84f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 16:44:26 +0200 Subject: [PATCH 1387/1566] Test signed 128bit discriminants --- example/std_example.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index ebac391f1e590..0c8fa8c0ba970 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -103,6 +103,14 @@ fn main() { Box::pin(move |mut _task_context| { yield (); }).as_mut().resume(0); + + #[derive(Copy, Clone)] + enum Nums { + NegOne = -1, + } + + let kind = Nums::NegOne; + assert_eq!(-1i128, kind as i128); } #[target_feature(enable = "sse2")] From 699da394ccd44de318da444bae28e472882ca830 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 16:52:37 +0200 Subject: [PATCH 1388/1566] Validate simd and atomic intrinsic types --- src/intrinsics/mod.rs | 75 +++++++++++++++++++++++++++++++++++------- src/intrinsics/simd.rs | 23 +++++++++++++ 2 files changed, 87 insertions(+), 11 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index a5aec52a7e442..5fb47729c1108 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -138,6 +138,27 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ crate::atomic_shim::unlock_global_lock($fx); } +macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { + match $ty.kind { + ty::Uint(_) | ty::Int(_) => {} + _ => { + $fx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); + // Prevent verifier error + crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); + return; + } + } +} + +macro validate_simd_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { + if !$ty.is_simd() { + $fx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); + // Prevent verifier error + crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); + return; + } +} + fn lane_type_and_count<'tcx>( tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>, @@ -866,12 +887,15 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); + validate_atomic_type!(fx, intrinsic, span, inner_layout.ty); let val = CValue::by_ref(Pointer::new(ptr.load_scalar(fx)), inner_layout); ret.write_cvalue(fx, val); crate::atomic_shim::unlock_global_lock(fx); }; _ if intrinsic.starts_with("atomic_store"), (v ptr, c val) { + validate_atomic_type!(fx, intrinsic, span, val.layout().ty); + crate::atomic_shim::lock_global_lock(fx); let dest = CPlace::for_ptr(Pointer::new(ptr), val.layout()); @@ -880,6 +904,8 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( crate::atomic_shim::unlock_global_lock(fx); }; _ if intrinsic.starts_with("atomic_xchg"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, T); + crate::atomic_shim::lock_global_lock(fx); // Read old @@ -893,7 +919,12 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( crate::atomic_shim::unlock_global_lock(fx); }; - _ if intrinsic.starts_with("atomic_cxchg"), (v ptr, v test_old, v new) { // both atomic_cxchg_* and atomic_cxchgweak_* + _ if intrinsic.starts_with("atomic_cxchg"), (v ptr, c test_old, c new) { // both atomic_cxchg_* and atomic_cxchgweak_* + validate_atomic_type!(fx, intrinsic, span, T); + + let test_old = test_old.load_scalar(fx); + let new = new.load_scalar(fx); + crate::atomic_shim::lock_global_lock(fx); // Read old @@ -913,16 +944,26 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( crate::atomic_shim::unlock_global_lock(fx); }; - _ if intrinsic.starts_with("atomic_xadd"), (v ptr, v amount) { + _ if intrinsic.starts_with("atomic_xadd"), (v ptr, c amount) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let amount = amount.load_scalar(fx); atomic_binop_return_old! (fx, iadd(ptr, amount) -> ret); }; - _ if intrinsic.starts_with("atomic_xsub"), (v ptr, v amount) { + _ if intrinsic.starts_with("atomic_xsub"), (v ptr, c amount) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let amount = amount.load_scalar(fx); atomic_binop_return_old! (fx, isub(ptr, amount) -> ret); }; - _ if intrinsic.starts_with("atomic_and"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_and"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let src = src.load_scalar(fx); atomic_binop_return_old! (fx, band(ptr, src) -> ret); }; - _ if intrinsic.starts_with("atomic_nand"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_nand"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, T); + + let src = src.load_scalar(fx); + crate::atomic_shim::lock_global_lock(fx); let clif_ty = fx.clif_type(T).unwrap(); @@ -934,23 +975,35 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( crate::atomic_shim::unlock_global_lock(fx); }; - _ if intrinsic.starts_with("atomic_or"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_or"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let src = src.load_scalar(fx); atomic_binop_return_old! (fx, bor(ptr, src) -> ret); }; - _ if intrinsic.starts_with("atomic_xor"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_xor"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let src = src.load_scalar(fx); atomic_binop_return_old! (fx, bxor(ptr, src) -> ret); }; - _ if intrinsic.starts_with("atomic_max"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_max"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let src = src.load_scalar(fx); atomic_minmax!(fx, IntCC::SignedGreaterThan, (ptr, src) -> ret); }; - _ if intrinsic.starts_with("atomic_umax"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_umax"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let src = src.load_scalar(fx); atomic_minmax!(fx, IntCC::UnsignedGreaterThan, (ptr, src) -> ret); }; - _ if intrinsic.starts_with("atomic_min"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_min"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let src = src.load_scalar(fx); atomic_minmax!(fx, IntCC::SignedLessThan, (ptr, src) -> ret); }; - _ if intrinsic.starts_with("atomic_umin"), (v ptr, v src) { + _ if intrinsic.starts_with("atomic_umin"), (v ptr, c src) { + validate_atomic_type!(fx, intrinsic, span, ret.layout().ty); + let src = src.load_scalar(fx); atomic_minmax!(fx, IntCC::UnsignedLessThan, (ptr, src) -> ret); }; diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index cf7decb046492..32f561bdd3631 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -21,6 +21,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; simd_cast, (c a) { + validate_simd_type!(fx, intrinsic, span, a.layout().ty); simd_for_each_lane(fx, a, ret, |fx, lane_layout, ret_lane_layout, lane| { let ret_lane_ty = fx.clif_type(ret_lane_layout.ty).unwrap(); @@ -33,26 +34,34 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; simd_eq, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_cmp!(fx, Equal(x, y) -> ret); }; simd_ne, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_cmp!(fx, NotEqual(x, y) -> ret); }; simd_lt, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_cmp!(fx, UnsignedLessThan|SignedLessThan(x, y) -> ret); }; simd_le, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_cmp!(fx, UnsignedLessThanOrEqual|SignedLessThanOrEqual(x, y) -> ret); }; simd_gt, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_cmp!(fx, UnsignedGreaterThan|SignedGreaterThan(x, y) -> ret); }; simd_ge, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_cmp!(fx, UnsignedGreaterThanOrEqual|SignedGreaterThanOrEqual(x, y) -> ret); }; // simd_shuffle32(x: T, y: T, idx: [u32; 32]) -> U _ if intrinsic.starts_with("simd_shuffle"), (c x, c y, o idx) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); + let n: u16 = intrinsic["simd_shuffle".len()..].parse().unwrap(); assert_eq!(x.layout(), y.layout()); @@ -105,6 +114,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; simd_insert, (c base, o idx, v _val) { + // FIXME validate let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { @@ -132,6 +142,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; simd_extract, (c v, o idx) { + validate_simd_type!(fx, intrinsic, span, v.layout().ty); let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { @@ -155,34 +166,44 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; simd_add, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_flt_binop!(fx, iadd|fadd(x, y) -> ret); }; simd_sub, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_flt_binop!(fx, isub|fsub(x, y) -> ret); }; simd_mul, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_flt_binop!(fx, imul|fmul(x, y) -> ret); }; simd_div, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_flt_binop!(fx, udiv|sdiv|fdiv(x, y) -> ret); }; simd_shl, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_binop!(fx, ishl(x, y) -> ret); }; simd_shr, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_binop!(fx, ushr|sshr(x, y) -> ret); }; simd_and, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_binop!(fx, band(x, y) -> ret); }; simd_or, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_binop!(fx, bor(x, y) -> ret); }; simd_xor, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_int_binop!(fx, bxor(x, y) -> ret); }; simd_fma, (c a, c b, c c) { + validate_simd_type!(fx, intrinsic, span, a.layout().ty); assert_eq!(a.layout(), b.layout()); assert_eq!(a.layout(), c.layout()); let layout = a.layout(); @@ -205,9 +226,11 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; simd_fmin, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_flt_binop!(fx, fmin(x, y) -> ret); }; simd_fmax, (c x, c y) { + validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_flt_binop!(fx, fmax(x, y) -> ret); }; } From 6345e4a1bcee38c42ee5817426beda78f43431ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 16:52:56 +0200 Subject: [PATCH 1389/1566] Implement variant_count intrinisic --- src/intrinsics/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 5fb47729c1108..d93da0fb0873a 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -838,7 +838,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( dest.write_cvalue(fx, val); }; - size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name, () { + size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () { let const_val = fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); let val = crate::constant::trans_const_value( From 6089a68718075da126794ae9c78911a9fa27f069 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 3 Jul 2020 18:23:53 +0200 Subject: [PATCH 1390/1566] Account for Rvalue::AddressOf in analyze --- src/analyze.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/analyze.rs b/src/analyze.rs index c3436785d90f0..7bd2c802868df 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -23,7 +23,7 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec match &place_and_rval.1 { - Rvalue::Ref(_, _, place) => { + Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place)=> { not_ssa(&mut flag_map, place.local) } _ => {} From bbe8bedd2a2bccad4aea0dc072a68474da67bfd4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 13:13:29 +0200 Subject: [PATCH 1391/1566] Rustup to rustc 1.46.0-nightly (8aa18cbdc 2020-07-08) --- build_sysroot/Cargo.lock | 16 ++++++++-------- rust-toolchain | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index f7bd624a014a1..2975e8acf6980 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -25,9 +25,9 @@ checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" [[package]] name = "backtrace" -version = "0.3.49" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05100821de9e028f12ae3d189176b41ee198341eb8f369956407fea2f5cc666c" +checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" dependencies = [ "backtrace-sys", "cfg-if", @@ -51,9 +51,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe" +checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" [[package]] name = "cfg-if" @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909" +checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" dependencies = [ "compiler_builtins", "libc", @@ -135,9 +135,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" +checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" dependencies = [ "rustc-std-workspace-core", ] diff --git a/rust-toolchain b/rust-toolchain index 066aa78c0074c..83dfc825f79d8 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-07-02 +nightly-2020-07-09 From 8e519643d203158d9630684f61778a8185328af5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 13:17:38 +0200 Subject: [PATCH 1392/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52caa4fd18a71..9db971e7599be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5ed74abeee4c5c30bdd00207bf1111f09becf2ff" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" dependencies = [ "cranelift-codegen", "cranelift-module", From b6150be206b22954455a4f7c258ac195f79e84ae Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 13:23:45 +0200 Subject: [PATCH 1393/1566] Update dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9db971e7599be..7ed00cd4895bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,9 +32,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c1f1d60091c1b73e2b1f4560ab419204b178e625fa945ded7b660becd2bd46" +checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" [[package]] name = "cfg-if" @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.71" +version = "0.2.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" +checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" [[package]] name = "libloading" @@ -348,9 +348,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "smallvec" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" +checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" [[package]] name = "syn" From ac773718522d12b897c1e927bfcb5b083e35d19e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 14:23:00 +0200 Subject: [PATCH 1394/1566] Add a feature flag for the JIT --- Cargo.toml | 8 +++++--- src/atomic_shim.rs | 1 + src/debuginfo/emit.rs | 5 +++-- src/debuginfo/unwind.rs | 1 + src/driver/mod.rs | 8 ++++---- src/lib.rs | 1 + 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0a0172429f38a..6c455c51dad04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ crate-type = ["dylib"] cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] } cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } +cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true } cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } target-lexicon = "0.10.0" @@ -19,6 +20,7 @@ ar = "0.8.0" byteorder = "1.2.7" indexmap = "1.0.2" cfg-if = "0.1.10" +libloading = { version = "0.6.0", optional = true } [dependencies.object] version = "0.20.0" @@ -41,9 +43,9 @@ features = ["write"] # We don't need read support #[patch.crates-io] #gimli = { path = "../" } -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } -libloading = "0.6.0" +[features] +default = ["jit"] +jit = ["cranelift-simplejit", "libloading"] [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index d277b33e1b624..b317f31ff9009 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -5,6 +5,7 @@ use crate::prelude::*; +#[cfg(feature = "jit")] #[no_mangle] pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 9cce630fed52f..219fa18305144 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -1,5 +1,3 @@ -use std::convert::TryInto; - use rustc_data_structures::fx::FxHashMap; use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer}; @@ -70,10 +68,13 @@ impl WriterRelocate { } } + #[cfg(feature = "jit")] pub(super) fn relocate_for_jit( mut self, jit_module: &mut cranelift_module::Module, ) -> Vec { + use std::convert::TryInto; + for reloc in self.relocs.drain(..) { match reloc.name { super::DebugRelocName::Section(_) => unreachable!(), diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index a8e52f99b67e7..4bc3859652db2 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -69,6 +69,7 @@ impl<'tcx> UnwindContext<'tcx> { } } + #[cfg(feature = "jit")] pub(crate) unsafe fn register_jit( self, jit_module: &mut Module, diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 9a60b1e6a33c0..112741b619115 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -6,7 +6,7 @@ use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; use crate::prelude::*; mod aot; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(feature = "jit")] mod jit; pub(crate) fn codegen_crate( @@ -19,11 +19,11 @@ pub(crate) fn codegen_crate( if std::env::var("CG_CLIF_JIT").is_ok() && tcx.sess.crate_types().contains(&rustc_session::config::CrateType::Executable) { - #[cfg(not(target_arch = "wasm32"))] + #[cfg(feature = "jit")] let _: ! = jit::run_jit(tcx); - #[cfg(target_arch = "wasm32")] - panic!("jit not supported on wasm"); + #[cfg(not(feature = "jit"))] + tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift"); } aot::run_aot(tcx, metadata, need_metadata_module) diff --git a/src/lib.rs b/src/lib.rs index b1e624d87f047..93144ae09a048 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ #![warn(unused_lifetimes)] extern crate flate2; +#[cfg(feature = "jit")] extern crate libc; extern crate rustc_middle; extern crate rustc_codegen_ssa; From 1987a3b6c099e069368ac7caf30ea6d46595ca5f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 15:25:37 +0200 Subject: [PATCH 1395/1566] Handle SysV64 abi --- src/abi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 2c1181c757575..2323dcc2083b2 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -91,7 +91,7 @@ fn clif_sig_from_fn_sig<'tcx>( }; let (call_conv, inputs, output): (CallConv, Vec>, Ty<'tcx>) = match abi { Abi::Rust => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), - Abi::C | Abi::Unadjusted => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), + Abi::C | Abi::Unadjusted | Abi::SysV64 => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().kind { From 037d411bf44a9a7c70d41773e355b74155bfea3a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 16:55:38 +0200 Subject: [PATCH 1396/1566] Implement global_asm! using an external assembler Fixes #1061 --- example/mini_core.rs | 4 ++ example/mini_core_hello_world.rs | 20 +++++++ src/driver/aot.rs | 89 ++++++++++++++++++++++++++++++-- src/driver/jit.rs | 7 ++- src/driver/mod.rs | 19 ++----- 5 files changed, 121 insertions(+), 18 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index a8db81fa06d59..94336154748ab 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -562,6 +562,10 @@ pub macro line() { /* compiler built-in */ } #[rustc_macro_transparency = "semitransparent"] pub macro cfg() { /* compiler built-in */ } +#[rustc_builtin_macro] +#[rustc_macro_transparency = "semitransparent"] +pub macro global_asm() { /* compiler built-in */ } + pub static A_STATIC: u8 = 42; #[lang = "panic_location"] diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 12c6638dd92db..d83fb2aece91d 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -284,6 +284,26 @@ fn main() { #[cfg(not(jit))] test_tls(); + + #[cfg(not(jit))] + unsafe { + global_asm_test(); + } +} + +#[cfg(not(jit))] +extern "C" { + fn global_asm_test(); +} + +#[cfg(not(jit))] +global_asm! { + " + .global global_asm_test + global_asm_test: + // comment that would normally be removed by LLVM + ret + " } #[repr(C)] diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 9b05a146020e9..028de9b1564df 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::middle::cstore::EncodedMetadata; use rustc_middle::mir::mono::CodegenUnit; @@ -110,19 +112,33 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege let module = new_module(tcx, cgu_name.as_str().to_string()); + let mut global_asm = Vec::new(); let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); - super::codegen_mono_items(&mut cx, mono_items); + super::codegen_mono_items(&mut cx, &mut global_asm, mono_items); let (mut module, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context); - emit_module( + let global_asm = global_asm.into_iter().map(|hir_id| { + let item = tcx.hir().expect_item(hir_id); + if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind { + asm.as_str().to_string() + } else { + bug!("Expected GlobalAsm found {:?}", item); + } + }).collect::>().join("\n"); + + let codegen_result = emit_module( tcx, cgu.name().as_str().to_string(), ModuleKind::Regular, module, debug, unwind_context, - ) + ); + + codegen_global_asm(tcx, &cgu.name().as_str(), &global_asm); + + codegen_result } pub(super) fn run_aot( @@ -253,6 +269,73 @@ pub(super) fn run_aot( }, work_products)) } +fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { + use std::io::Write; + use std::process::{Command, Stdio}; + + if global_asm.is_empty() { + return; + } + + // Remove all LLVM style comments + let global_asm = global_asm.lines().map(|line| { + if let Some(index) = line.find("//") { + &line[0..index] + } else { + line + } + }).collect::>().join("\n"); + + let output_object_file = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(cgu_name)); + + // Assemble `global_asm` + let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm"); + let mut child = Command::new("as") + .arg("-o").arg(&global_asm_object_file) + .stdin(Stdio::piped()) + .spawn() + .expect("Failed to spawn `as`."); + child.stdin.take().unwrap().write_all(global_asm.as_bytes()).unwrap(); + let status = child.wait().expect("Failed to wait for `as`."); + if !status.success() { + tcx.sess.fatal(&format!("Failed to assemble `{}`", global_asm)); + } + + // Link the global asm and main object file together + let main_object_file = add_file_stem_postfix(output_object_file.clone(), ".main"); + std::fs::rename(&output_object_file, &main_object_file).unwrap(); + let status = Command::new("ld") + .arg("-r") // Create a new object file + .arg("-o").arg(output_object_file) + .arg(&main_object_file) + .arg(&global_asm_object_file) + .status() + .unwrap(); + if !status.success() { + tcx.sess.fatal(&format!( + "Failed to link `{}` and `{}` together", + main_object_file.display(), + global_asm_object_file.display(), + )); + } + + std::fs::remove_file(global_asm_object_file).unwrap(); + std::fs::remove_file(main_object_file).unwrap(); +} + +fn add_file_stem_postfix(mut path: PathBuf, postfix: &str) -> PathBuf { + let mut new_filename = path.file_stem().unwrap().to_owned(); + new_filename.push(postfix); + if let Some(extension) = path.extension() { + new_filename.push("."); + new_filename.push(extension); + } + path.set_file_name(new_filename); + path +} + // Adapted from https://github.com/rust-lang/rust/blob/303d8aff6092709edd4dbd35b1c88e9aa40bf6d8/src/librustc_codegen_ssa/base.rs#L922-L953 fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse { if !tcx.dep_graph.is_fully_enabled() { diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 93535cd16def6..138792084b2e4 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -55,7 +55,12 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let mut cx = crate::CodegenCx::new(tcx, jit_module, false); let (mut jit_module, _debug, mut unwind_context) = super::time(tcx, "codegen mono items", || { - super::codegen_mono_items(&mut cx, mono_items); + let mut global_asm = Vec::new(); + super::codegen_mono_items(&mut cx, &mut global_asm, mono_items); + for hir_id in global_asm { + let item = tcx.hir().expect_item(hir_id); + tcx.sess.span_err(item.span, "Global asm is not supported in JIT mode"); + } tcx.sess.time("finalize CodegenCx", || cx.finalize()) }); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 112741b619115..8872b6f1da400 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,5 +1,6 @@ use std::any::Any; +use rustc_hir::HirId; use rustc_middle::middle::cstore::EncodedMetadata; use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; @@ -31,6 +32,7 @@ pub(crate) fn codegen_crate( fn codegen_mono_items<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Backend + 'static>, + global_asm: &mut Vec, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { cx.tcx.sess.time("predefine functions", || { @@ -49,12 +51,13 @@ fn codegen_mono_items<'tcx>( for (mono_item, (linkage, visibility)) in mono_items { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - trans_mono_item(cx, mono_item, linkage); + trans_mono_item(cx, global_asm, mono_item, linkage); } } fn trans_mono_item<'tcx, B: Backend + 'static>( cx: &mut crate::CodegenCx<'tcx, B>, + global_asm: &mut Vec, mono_item: MonoItem<'tcx>, linkage: Linkage, ) { @@ -91,19 +94,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( crate::constant::codegen_static(&mut cx.constants_cx, def_id); } MonoItem::GlobalAsm(hir_id) => { - let item = tcx.hir().expect_item(hir_id); - if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind { - // FIXME implement global asm using an external assembler - if asm.as_str().contains("__rust_probestack") { - return; - } else { - tcx - .sess - .fatal(&format!("Unimplemented global asm mono item \"{}\"", asm)); - } - } else { - bug!("Expected GlobalAsm found {:?}", item); - } + global_asm.push(hir_id); } } } From 893497c93e4a68d99642843a5d46f0c9afeb98b3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 18:55:46 +0200 Subject: [PATCH 1397/1566] Infer the path of toolchain binaries from the linker path --- src/archive.rs | 4 +- src/driver/aot.rs | 7 ++- src/lib.rs | 1 + src/toolchain.rs | 115 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 src/toolchain.rs diff --git a/src/archive.rs b/src/archive.rs index f4685d3d9e166..6ae07a3bb7bfe 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -220,8 +220,10 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { std::mem::drop(builder); if self.update_symbols { + let ranlib = crate::toolchain::get_toolchain_binary(self.config.sess, "ranlib"); + // Run ranlib to be able to link the archive - let status = std::process::Command::new("ranlib") + let status = std::process::Command::new(ranlib) .arg(self.config.dst) .status() .expect("Couldn't run ranlib"); diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 028de9b1564df..4128148ed363d 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -277,6 +277,9 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { return; } + let assembler = crate::toolchain::get_toolchain_binary(tcx.sess, "as"); + let linker = crate::toolchain::get_toolchain_binary(tcx.sess, "ld"); + // Remove all LLVM style comments let global_asm = global_asm.lines().map(|line| { if let Some(index) = line.find("//") { @@ -292,7 +295,7 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { // Assemble `global_asm` let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm"); - let mut child = Command::new("as") + let mut child = Command::new(assembler) .arg("-o").arg(&global_asm_object_file) .stdin(Stdio::piped()) .spawn() @@ -306,7 +309,7 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { // Link the global asm and main object file together let main_object_file = add_file_stem_postfix(output_object_file.clone(), ".main"); std::fs::rename(&output_object_file, &main_object_file).unwrap(); - let status = Command::new("ld") + let status = Command::new(linker) .arg("-r") // Create a new object file .arg("-o").arg(output_object_file) .arg(&main_object_file) diff --git a/src/lib.rs b/src/lib.rs index 93144ae09a048..fe1f79988bef5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,6 +64,7 @@ mod optimize; mod pointer; mod pretty_clif; mod target_features_whitelist; +mod toolchain; mod trap; mod unsize; mod value_and_place; diff --git a/src/toolchain.rs b/src/toolchain.rs new file mode 100644 index 0000000000000..2a31b8834384b --- /dev/null +++ b/src/toolchain.rs @@ -0,0 +1,115 @@ +use std::path::PathBuf; + +use rustc_middle::bug; +use rustc_session::Session; +use rustc_target::spec::LinkerFlavor; + +/// Tries to infer the path of a binary for the target toolchain from the linker name. +pub(crate) fn get_toolchain_binary(sess: &Session, tool: &str) -> PathBuf { + let (mut linker, _linker_flavor) = linker_and_flavor(sess); + let linker_file_name = linker.file_name().and_then(|name| name.to_str()).unwrap_or_else(|| { + sess.fatal("couldn't extract file name from specified linker") + }); + + if linker_file_name == "ld.lld" { + if tool != "ld" { + linker.set_file_name(tool) + } + } else { + let tool_file_name = linker_file_name + .replace("ld", tool) + .replace("gcc", tool) + .replace("clang", tool) + .replace("cc", tool); + + linker.set_file_name(tool_file_name) + } + + linker +} + +// Adapted from https://github.com/rust-lang/rust/blob/5db778affee7c6600c8e7a177c48282dab3f6292/src/librustc_codegen_ssa/back/link.rs#L848-L931 +fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { + fn infer_from( + sess: &Session, + linker: Option, + flavor: Option, + ) -> Option<(PathBuf, LinkerFlavor)> { + match (linker, flavor) { + (Some(linker), Some(flavor)) => Some((linker, flavor)), + // only the linker flavor is known; use the default linker for the selected flavor + (None, Some(flavor)) => Some(( + PathBuf::from(match flavor { + LinkerFlavor::Em => { + if cfg!(windows) { + "emcc.bat" + } else { + "emcc" + } + } + LinkerFlavor::Gcc => { + if cfg!(any(target_os = "solaris", target_os = "illumos")) { + // On historical Solaris systems, "cc" may have + // been Sun Studio, which is not flag-compatible + // with "gcc". This history casts a long shadow, + // and many modern illumos distributions today + // ship GCC as "gcc" without also making it + // available as "cc". + "gcc" + } else { + "cc" + } + } + LinkerFlavor::Ld => "ld", + LinkerFlavor::Msvc => "link.exe", + LinkerFlavor::Lld(_) => "lld", + LinkerFlavor::PtxLinker => "rust-ptx-linker", + }), + flavor, + )), + (Some(linker), None) => { + let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { + sess.fatal("couldn't extract file stem from specified linker") + }); + + let flavor = if stem == "emcc" { + LinkerFlavor::Em + } else if stem == "gcc" + || stem.ends_with("-gcc") + || stem == "clang" + || stem.ends_with("-clang") + { + LinkerFlavor::Gcc + } else if stem == "ld" || stem == "ld.lld" || stem.ends_with("-ld") { + LinkerFlavor::Ld + } else if stem == "link" || stem == "lld-link" { + LinkerFlavor::Msvc + } else if stem == "lld" || stem == "rust-lld" { + LinkerFlavor::Lld(sess.target.target.options.lld_flavor) + } else { + // fall back to the value in the target spec + sess.target.target.linker_flavor + }; + + Some((linker, flavor)) + } + (None, None) => None, + } + } + + // linker and linker flavor specified via command line have precedence over what the target + // specification specifies + if let Some(ret) = infer_from(sess, sess.opts.cg.linker.clone(), sess.opts.cg.linker_flavor) { + return ret; + } + + if let Some(ret) = infer_from( + sess, + sess.target.target.options.linker.clone().map(PathBuf::from), + Some(sess.target.target.linker_flavor), + ) { + return ret; + } + + bug!("Not enough information provided to determine how to invoke the linker"); +} From 8cf38181ad4506af85a5cd68b3d5a13c038f04ef Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 18:56:17 +0200 Subject: [PATCH 1398/1566] Disable global_asm! on macOS for now --- example/mini_core_hello_world.rs | 6 +++--- src/driver/aot.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index d83fb2aece91d..9c2ab5a5165cd 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -285,18 +285,18 @@ fn main() { #[cfg(not(jit))] test_tls(); - #[cfg(not(jit))] + #[cfg(all(not(jit), target_os = "linux"))] unsafe { global_asm_test(); } } -#[cfg(not(jit))] +#[cfg(all(not(jit), target_os = "linux"))] extern "C" { fn global_asm_test(); } -#[cfg(not(jit))] +#[cfg(all(not(jit), target_os = "linux"))] global_asm! { " .global global_asm_test diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 4128148ed363d..48445c43a92eb 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -277,6 +277,15 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { return; } + if tcx.sess.target.target.options.is_like_osx || tcx.sess.target.target.options.is_like_windows { + if global_asm.contains("__rust_probestack") { + return; + } + + // FIXME fix linker error on macOS + tcx.sess.fatal("global_asm! is not yet supported on macOS and Windows"); + } + let assembler = crate::toolchain::get_toolchain_binary(tcx.sess, "as"); let linker = crate::toolchain::get_toolchain_binary(tcx.sess, "ld"); From 35701d8caab0eff01b73d5335ac4b8e63f6ff689 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 9 Jul 2020 19:24:53 +0200 Subject: [PATCH 1399/1566] Move global_asm into CodegenCx --- src/driver/aot.rs | 14 ++------------ src/driver/jit.rs | 12 +++++------- src/driver/mod.rs | 13 ++++++++----- src/lib.rs | 6 ++++-- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 48445c43a92eb..0f76e8d2195be 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -112,21 +112,11 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege let module = new_module(tcx, cgu_name.as_str().to_string()); - let mut global_asm = Vec::new(); let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); - super::codegen_mono_items(&mut cx, &mut global_asm, mono_items); - let (mut module, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); + super::codegen_mono_items(&mut cx, mono_items); + let (mut module, global_asm, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context); - let global_asm = global_asm.into_iter().map(|hir_id| { - let item = tcx.hir().expect_item(hir_id); - if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind { - asm.as_str().to_string() - } else { - bug!("Expected GlobalAsm found {:?}", item); - } - }).collect::>().join("\n"); - let codegen_result = emit_module( tcx, cgu.name().as_str().to_string(), diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 138792084b2e4..b27ad7b438472 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -54,15 +54,13 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let mut cx = crate::CodegenCx::new(tcx, jit_module, false); - let (mut jit_module, _debug, mut unwind_context) = super::time(tcx, "codegen mono items", || { - let mut global_asm = Vec::new(); - super::codegen_mono_items(&mut cx, &mut global_asm, mono_items); - for hir_id in global_asm { - let item = tcx.hir().expect_item(hir_id); - tcx.sess.span_err(item.span, "Global asm is not supported in JIT mode"); - } + let (mut jit_module, global_asm, _debug, mut unwind_context) = super::time(tcx, "codegen mono items", || { + super::codegen_mono_items(&mut cx, mono_items); tcx.sess.time("finalize CodegenCx", || cx.finalize()) }); + if !global_asm.is_empty() { + tcx.sess.fatal("Global asm is not supported in JIT mode"); + } crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context); crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 8872b6f1da400..f8446cbeddddb 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,6 +1,5 @@ use std::any::Any; -use rustc_hir::HirId; use rustc_middle::middle::cstore::EncodedMetadata; use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; @@ -32,7 +31,6 @@ pub(crate) fn codegen_crate( fn codegen_mono_items<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Backend + 'static>, - global_asm: &mut Vec, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { cx.tcx.sess.time("predefine functions", || { @@ -51,13 +49,12 @@ fn codegen_mono_items<'tcx>( for (mono_item, (linkage, visibility)) in mono_items { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - trans_mono_item(cx, global_asm, mono_item, linkage); + trans_mono_item(cx, mono_item, linkage); } } fn trans_mono_item<'tcx, B: Backend + 'static>( cx: &mut crate::CodegenCx<'tcx, B>, - global_asm: &mut Vec, mono_item: MonoItem<'tcx>, linkage: Linkage, ) { @@ -94,7 +91,13 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( crate::constant::codegen_static(&mut cx.constants_cx, def_id); } MonoItem::GlobalAsm(hir_id) => { - global_asm.push(hir_id); + let item = tcx.hir().expect_item(hir_id); + if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind { + cx.global_asm.push_str(&*asm.as_str()); + cx.global_asm.push_str("\n\n"); + } else { + bug!("Expected GlobalAsm found {:?}", item); + } } } } diff --git a/src/lib.rs b/src/lib.rs index fe1f79988bef5..804a58de26fe4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,6 +123,7 @@ impl String> Drop for PrintOnPanic { struct CodegenCx<'tcx, B: Backend + 'static> { tcx: TyCtxt<'tcx>, module: Module, + global_asm: String, constants_cx: ConstantCx, cached_context: Context, vtables: FxHashMap<(Ty<'tcx>, Option>), DataId>, @@ -148,6 +149,7 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { CodegenCx { tcx, module, + global_asm: String::new(), constants_cx: ConstantCx::default(), cached_context: Context::new(), vtables: FxHashMap::default(), @@ -156,9 +158,9 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } } - fn finalize(mut self) -> (Module, Option>, UnwindContext<'tcx>) { + fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { self.constants_cx.finalize(self.tcx, &mut self.module); - (self.module, self.debug_context, self.unwind_context) + (self.module, self.global_asm, self.debug_context, self.unwind_context) } } From 726e329f46e3916306cf3557c19dcdb54a021c2f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Jul 2020 14:45:45 +0200 Subject: [PATCH 1400/1566] Add basic inline asm support for x86_64 --- Readme.md | 5 +- src/base.rs | 29 +++--- src/common.rs | 1 + src/driver/aot.rs | 2 +- src/inline_asm.rs | 220 ++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 6 files changed, 243 insertions(+), 15 deletions(-) create mode 100644 src/inline_asm.rs diff --git a/Readme.md b/Readme.md index 61595e97730f4..3639b0e7d469b 100644 --- a/Readme.md +++ b/Readme.md @@ -76,5 +76,8 @@ function jit_calc() { * Good non-rust abi support ([several problems](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) * Proc macros -* Inline assembly ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1041), not coming soon) +* Inline assembly ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1041) + * On Linux there is support for invoking an external assembler for `global_asm!` and `asm!`. + `llvm_asm!` will remain unimplemented forever. `asm!` doesn't yet support reg classes. You + have to specify specific registers instead. * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171), some basic things work) diff --git a/src/base.rs b/src/base.rs index 053f6e81d5ee7..1bd5559c33501 100644 --- a/src/base.rs +++ b/src/base.rs @@ -36,6 +36,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let mut fx = FunctionCx { tcx, module: &mut cx.module, + global_asm: &mut cx.global_asm, pointer_type, instance, @@ -307,24 +308,26 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { TerminatorKind::InlineAsm { template, operands, - options: _, + options, destination, line_spans: _, } => { - match template { - &[] => { - assert_eq!(operands, &[]); - match *destination { - Some(destination) => { - let destination_block = fx.get_block(destination); - fx.bcx.ins().jump(destination_block, &[]); - } - None => bug!(), - } + crate::inline_asm::codegen_inline_asm( + fx, + bb_data.terminator().source_info.span, + template, + operands, + *options, + ); - // Black box + match *destination { + Some(destination) => { + let destination_block = fx.get_block(destination); + fx.bcx.ins().jump(destination_block, &[]); + } + None => { + crate::trap::trap_unreachable(fx, "[corruption] Returned from noreturn inline asm"); } - _ => fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, "Inline assembly is not supported"), } } TerminatorKind::Resume | TerminatorKind::Abort => { diff --git a/src/common.rs b/src/common.rs index 616eb57307e93..bf0d4957bc32b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -254,6 +254,7 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` pub(crate) tcx: TyCtxt<'tcx>, pub(crate) module: &'clif mut Module, + pub(crate) global_asm: &'clif mut String, pub(crate) pointer_type: Type, // Cached from module pub(crate) instance: Instance<'tcx>, diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 0f76e8d2195be..4510614cf43cc 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -273,7 +273,7 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { } // FIXME fix linker error on macOS - tcx.sess.fatal("global_asm! is not yet supported on macOS and Windows"); + tcx.sess.fatal("asm! and global_asm! are not yet supported on macOS and Windows"); } let assembler = crate::toolchain::get_toolchain_binary(tcx.sess, "as"); diff --git a/src/inline_asm.rs b/src/inline_asm.rs new file mode 100644 index 0000000000000..e2bbdd5ce9172 --- /dev/null +++ b/src/inline_asm.rs @@ -0,0 +1,220 @@ +use crate::prelude::*; + +use std::fmt::Write; + +use rustc_ast::ast::{InlineAsmTemplatePiece, InlineAsmOptions}; +use rustc_middle::mir::InlineAsmOperand; +use rustc_target::asm::*; + +pub(crate) fn codegen_inline_asm<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + _span: Span, + template: &[InlineAsmTemplatePiece], + operands: &[InlineAsmOperand<'tcx>], + options: InlineAsmOptions, +) { + // FIXME add .eh_frame unwind info directives + + if template.is_empty() { + // Black box + return; + } + + let mut slot_size = Size::from_bytes(0); + let mut clobbered_regs = Vec::new(); + let mut inputs = Vec::new(); + let mut outputs = Vec::new(); + + let mut new_slot = |reg_class: InlineAsmRegClass| { + let reg_size = reg_class + .supported_types(InlineAsmArch::X86_64) + .iter() + .map(|(ty, _)| ty.size()) + .max() + .unwrap(); + let align = rustc_target::abi::Align::from_bytes(reg_size.bytes()).unwrap(); + slot_size = slot_size.align_to(align); + let offset = slot_size; + slot_size += reg_size; + offset + }; + + // FIXME overlap input and output slots to save stack space + for operand in operands { + match *operand { + InlineAsmOperand::In { reg, ref value } => { + let reg = expect_reg(reg); + clobbered_regs.push((reg, new_slot(reg.reg_class()))); + inputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_operand(fx, value).load_scalar(fx))); + } + InlineAsmOperand::Out { reg, late: _, place } => { + let reg = expect_reg(reg); + clobbered_regs.push((reg, new_slot(reg.reg_class()))); + if let Some(place) = place { + outputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_place(fx, place))); + } + } + InlineAsmOperand::InOut { reg, late: _, ref in_value, out_place } => { + let reg = expect_reg(reg); + clobbered_regs.push((reg, new_slot(reg.reg_class()))); + inputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_operand(fx, in_value).load_scalar(fx))); + if let Some(out_place) = out_place { + outputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_place(fx, out_place))); + } + } + InlineAsmOperand::Const { value: _ } => todo!(), + InlineAsmOperand::SymFn { value: _ } => todo!(), + InlineAsmOperand::SymStatic { def_id: _ } => todo!(), + } + } + + let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, /*FIXME*/0); + + let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); + fx.global_asm.push_str(&generated_asm); + + call_inline_asm(fx, &asm_name, slot_size, inputs, outputs); +} + +fn generate_asm_wrapper( + asm_name: &str, + arch: InlineAsmArch, + options: InlineAsmOptions, + template: &[InlineAsmTemplatePiece], + clobbered_regs: Vec<(InlineAsmReg, Size)>, + inputs: &[(InlineAsmReg, Size, Value)], + outputs: &[(InlineAsmReg, Size, CPlace<'_>)], +) -> String { + let mut generated_asm = String::new(); + writeln!(generated_asm, ".globl {}", asm_name).unwrap(); + writeln!(generated_asm, ".type {},@function", asm_name).unwrap(); + writeln!(generated_asm, ".section .text.{},\"ax\",@progbits", asm_name).unwrap(); + writeln!(generated_asm, "{}:", asm_name).unwrap(); + + generated_asm.push_str(".intel_syntax noprefix\n"); + generated_asm.push_str(" push rbp\n"); + generated_asm.push_str(" mov rbp,rdi\n"); + + // Save clobbered registers + if !options.contains(InlineAsmOptions::NORETURN) { + // FIXME skip registers saved by the calling convention + for &(reg, offset) in &clobbered_regs { + save_register(&mut generated_asm, arch, reg, offset); + } + } + + // Write input registers + for &(reg, offset, _value) in inputs { + restore_register(&mut generated_asm, arch, reg, offset); + } + + if options.contains(InlineAsmOptions::ATT_SYNTAX) { + generated_asm.push_str(".att_syntax\n"); + } + + // The actual inline asm + for piece in template { + match piece { + InlineAsmTemplatePiece::String(s) => { + generated_asm.push_str(s); + } + InlineAsmTemplatePiece::Placeholder { operand_idx: _, modifier: _, span: _ } => todo!(), + } + } + generated_asm.push('\n'); + + if options.contains(InlineAsmOptions::ATT_SYNTAX) { + generated_asm.push_str(".intel_syntax noprefix\n"); + } + + if !options.contains(InlineAsmOptions::NORETURN) { + // Read output registers + for &(reg, offset, _place) in outputs { + save_register(&mut generated_asm, arch, reg, offset); + } + + // Restore clobbered registers + for &(reg, offset) in clobbered_regs.iter().rev() { + restore_register(&mut generated_asm, arch, reg, offset); + } + + generated_asm.push_str(" pop rbp\n"); + generated_asm.push_str(" ret\n"); + } else { + generated_asm.push_str(" ud2\n"); + } + + generated_asm.push_str(".att_syntax\n"); + writeln!(generated_asm, ".size {name}, .-{name}", name=asm_name).unwrap(); + generated_asm.push_str(".text\n"); + generated_asm.push_str("\n\n"); + + generated_asm +} + +fn call_inline_asm<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + asm_name: &str, + slot_size: Size, + inputs: Vec<(InlineAsmReg, Size, Value)>, + outputs: Vec<(InlineAsmReg, Size, CPlace<'tcx>)>, +) { + let stack_slot = fx.bcx.func.create_stack_slot(StackSlotData { + kind: StackSlotKind::ExplicitSlot, + offset: None, + size: u32::try_from(slot_size.bytes()).unwrap(), + }); + #[cfg(debug_assertions)] + fx.add_comment(stack_slot, "inline asm scratch slot"); + + let inline_asm_func = fx.module.declare_function(asm_name, Linkage::Import, &Signature { + call_conv: CallConv::SystemV, + params: vec![AbiParam::new(fx.pointer_type)], + returns: vec![], + }).unwrap(); + let inline_asm_func = fx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); + #[cfg(debug_assertions)] + fx.add_comment(inline_asm_func, asm_name); + + for (_reg, offset, value) in inputs { + fx.bcx.ins().stack_store(value, stack_slot, i32::try_from(offset.bytes()).unwrap()); + } + + let stack_slot_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); + fx.bcx.ins().call(inline_asm_func, &[stack_slot_addr]); + + for (_reg, offset, place) in outputs { + let ty = fx.clif_type(place.layout().ty).unwrap(); + let value = fx.bcx.ins().stack_load(ty, stack_slot, i32::try_from(offset.bytes()).unwrap()); + place.write_cvalue(fx, CValue::by_val(value, place.layout())); + } +} + +fn expect_reg(reg_or_class: InlineAsmRegOrRegClass) -> InlineAsmReg { + match reg_or_class { + InlineAsmRegOrRegClass::Reg(reg) => reg, + InlineAsmRegOrRegClass::RegClass(class) => unimplemented!("{:?}", class), + } +} + +fn save_register(generated_asm: &mut String, arch: InlineAsmArch, reg: InlineAsmReg, offset: Size) { + match arch { + InlineAsmArch::X86_64 => { + write!(generated_asm, " mov [rbp+0x{:x}], ", offset.bytes()).unwrap(); + reg.emit(generated_asm, InlineAsmArch::X86_64, None).unwrap(); + generated_asm.push('\n'); + } + _ => unimplemented!("save_register for {:?}", arch), + } +} + +fn restore_register(generated_asm: &mut String, arch: InlineAsmArch, reg: InlineAsmReg, offset: Size) { + match arch { + InlineAsmArch::X86_64 => { + generated_asm.push_str(" mov "); + reg.emit(generated_asm, InlineAsmArch::X86_64, None).unwrap(); + writeln!(generated_asm, ", [rbp+0x{:x}]", offset.bytes()).unwrap(); + } + _ => unimplemented!("restore_register for {:?}", arch), + } +} diff --git a/src/lib.rs b/src/lib.rs index 804a58de26fe4..041c05722efd5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,6 +55,7 @@ mod constant; mod debuginfo; mod discriminant; mod driver; +mod inline_asm; mod intrinsics; mod linkage; mod main_shim; From 190e36a5f8ba49140df2bd9abf0cadd06ea89822 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Jul 2020 11:02:23 +0200 Subject: [PATCH 1401/1566] Make everything in example.rs public --- example/example.rs | 78 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/example/example.rs b/example/example.rs index 5878e8548d926..d5c122bf681ff 100644 --- a/example/example.rs +++ b/example/example.rs @@ -6,11 +6,11 @@ extern crate mini_core; use mini_core::*; -fn abc(a: u8) -> u8 { +pub fn abc(a: u8) -> u8 { a * 2 } -fn bcd(b: bool, a: u8) -> u8 { +pub fn bcd(b: bool, a: u8) -> u8 { if b { a * 2 } else { @@ -18,84 +18,84 @@ fn bcd(b: bool, a: u8) -> u8 { } } -fn call() { +pub fn call() { abc(42); } -fn indirect_call() { +pub fn indirect_call() { let f: fn() = call; f(); } -enum BoolOption { +pub enum BoolOption { Some(bool), None, } -fn option_unwrap_or(o: BoolOption, d: bool) -> bool { +pub fn option_unwrap_or(o: BoolOption, d: bool) -> bool { match o { BoolOption::Some(b) => b, BoolOption::None => d, } } -fn ret_42() -> u8 { +pub fn ret_42() -> u8 { 42 } -fn return_str() -> &'static str { +pub fn return_str() -> &'static str { "hello world" } -fn promoted_val() -> &'static u8 { +pub fn promoted_val() -> &'static u8 { &(1 * 2) } -fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 { +pub fn cast_ref_to_raw_ptr(abc: &u8) -> *const u8 { abc as *const u8 } -fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { +pub fn cmp_raw_ptr(a: *const u8, b: *const u8) -> bool { a == b } -fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { +pub fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { ( a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8, b as u32, ) } -fn char_cast(c: char) -> u8 { +pub fn char_cast(c: char) -> u8 { c as u8 } pub struct DebugTuple(()); -fn debug_tuple() -> DebugTuple { +pub fn debug_tuple() -> DebugTuple { DebugTuple(()) } -fn size_of() -> usize { +pub fn size_of() -> usize { intrinsics::size_of::() } -fn use_size_of() -> usize { +pub fn use_size_of() -> usize { size_of::() } -unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { +pub unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) { intrinsics::copy::(src, dst, 1); } -unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { +pub unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) { let copy2 = &intrinsics::copy::; copy2(src, dst, 1); } -const ABC: u8 = 6 * 7; +pub const ABC: u8 = 6 * 7; -fn use_const() -> u8 { +pub fn use_const() -> u8 { ABC } @@ -107,7 +107,7 @@ pub fn call_closure_2arg() { (|_, _| {})(0u8, 42u16) } -struct IsNotEmpty; +pub struct IsNotEmpty; impl<'a, 'b> FnOnce<(&'a &'b [u16],)> for IsNotEmpty { type Output = (u8, u8); @@ -129,55 +129,55 @@ pub fn call_is_not_empty() { IsNotEmpty.call_once((&(&[0u16] as &[_]),)); } -fn eq_char(a: char, b: char) -> bool { +pub fn eq_char(a: char, b: char) -> bool { a == b } -unsafe fn transmute(c: char) -> u32 { +pub unsafe fn transmute(c: char) -> u32 { intrinsics::transmute(c) } -unsafe fn deref_str_ptr(s: *const str) -> &'static str { +pub unsafe fn deref_str_ptr(s: *const str) -> &'static str { &*s } -fn use_array(arr: [u8; 3]) -> u8 { +pub fn use_array(arr: [u8; 3]) -> u8 { arr[1] } -fn repeat_array() -> [u8; 3] { +pub fn repeat_array() -> [u8; 3] { [0; 3] } -fn array_as_slice(arr: &[u8; 3]) -> &[u8] { +pub fn array_as_slice(arr: &[u8; 3]) -> &[u8] { arr } -unsafe fn use_ctlz_nonzero(a: u16) -> u16 { +pub unsafe fn use_ctlz_nonzero(a: u16) -> u16 { intrinsics::ctlz_nonzero(a) } -fn ptr_as_usize(ptr: *const u8) -> usize { +pub fn ptr_as_usize(ptr: *const u8) -> usize { ptr as usize } -fn float_cast(a: f32, b: f64) -> (f64, f32) { +pub fn float_cast(a: f32, b: f64) -> (f64, f32) { (a as f64, b as f32) } -fn int_to_float(a: u8, b: i32) -> (f64, f32) { +pub fn int_to_float(a: u8, b: i32) -> (f64, f32) { (a as f64, b as f32) } -fn make_array() -> [u8; 3] { +pub fn make_array() -> [u8; 3] { [42, 0, 5] } -fn some_promoted_tuple() -> &'static (&'static str, &'static str) { +pub fn some_promoted_tuple() -> &'static (&'static str, &'static str) { &("abc", "some") } -fn index_slice(s: &[u8]) -> u8 { +pub fn index_slice(s: &[u8]) -> u8 { s[2] } @@ -185,21 +185,21 @@ pub struct StrWrapper { s: str, } -fn str_wrapper_get(w: &StrWrapper) -> &str { +pub fn str_wrapper_get(w: &StrWrapper) -> &str { &w.s } -fn i16_as_i8(a: i16) -> i8 { +pub fn i16_as_i8(a: i16) -> i8 { a as i8 } -struct Unsized(u8, str); +pub struct Unsized(u8, str); -fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 { +pub fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 { &u.0 } -fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str { +pub fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str { &u.1 } From 2ab1084ed44284e4f1d44c2a5b4e982a5539d37d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 12 Jul 2020 20:27:45 +0200 Subject: [PATCH 1402/1566] Add simple profile filter rust script (#1065) --- filter_profile.rs | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100755 filter_profile.rs diff --git a/filter_profile.rs b/filter_profile.rs new file mode 100755 index 0000000000000..82bf53934b847 --- /dev/null +++ b/filter_profile.rs @@ -0,0 +1,124 @@ +#!/bin/bash +#![forbid(unsafe_code)]/* This line is ignored by bash +# This block is ignored by rustc +CHANNEL="release" +source ./config.sh +CG_CLIF_JIT=1 PROFILE=$1 OUTPUT=$2 exec $RUSTC $0 --crate-type bin -Cprefer-dynamic +#*/ + +//! This program filters away uninteresting samples and trims uninteresting frames for stackcollapse +//! profiles. +//! +//! Usage: ./filter_profile.rs +//! +//! This file is specially crafted to be both a valid bash script and valid rust source file. If +//! executed as bash script this will run the rust source using cg_clif in JIT mode. + +use std::io::Write; + +fn main() -> Result<(), Box> { + let profile_name = std::env::var("PROFILE").unwrap(); + let output_name = std::env::var("OUTPUT").unwrap(); + if profile_name.is_empty() || output_name.is_empty() { + println!("Usage: ./filter_profile.rs "); + std::process::exit(1); + } + let profile = std::fs::read_to_string(profile_name) + .map_err(|err| format!("Failed to read profile {}", err))?; + let mut output = std::fs::OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .open(output_name)?; + + for line in profile.lines() { + let mut stack = &line[..line.rfind(" ").unwrap()]; + let count = &line[line.rfind(" ").unwrap() + 1..]; + + // Filter away uninteresting samples + if !stack.contains("rustc_codegen_cranelift") { + continue; + } + + if stack.contains("rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items") + || stack.contains("rustc_incremental::assert_dep_graph::assert_dep_graph") + || stack.contains("rustc_symbol_mangling::test::report_symbol_names") + { + continue; + } + + // Trim start + if let Some(index) = stack.find("rustc_interface::passes::configure_and_expand") { + stack = &stack[index..]; + } else if let Some(index) = stack.find("rustc_interface::passes::analysis") { + stack = &stack[index..]; + } else if let Some(index) = stack.find("rustc_interface::passes::start_codegen") { + stack = &stack[index..]; + } else if let Some(index) = stack.find("rustc_interface::queries::Linker::link") { + stack = &stack[index..]; + } + + if let Some(index) = stack.find("rustc_codegen_cranelift::driver::aot::module_codegen") { + stack = &stack[index..]; + } + + // Trim end + const MALLOC: &str = "malloc"; + if let Some(index) = stack.find(MALLOC) { + stack = &stack[..index + MALLOC.len()]; + } + + const FREE: &str = "free"; + if let Some(index) = stack.find(FREE) { + stack = &stack[..index + FREE.len()]; + } + + const TYPECK_ITEM_BODIES: &str = "rustc_typeck::check::typeck_item_bodies"; + if let Some(index) = stack.find(TYPECK_ITEM_BODIES) { + stack = &stack[..index + TYPECK_ITEM_BODIES.len()]; + } + + const COLLECT_AND_PARTITION_MONO_ITEMS: &str = + "rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items"; + if let Some(index) = stack.find(COLLECT_AND_PARTITION_MONO_ITEMS) { + stack = &stack[..index + COLLECT_AND_PARTITION_MONO_ITEMS.len()]; + } + + const ASSERT_DEP_GRAPH: &str = "rustc_incremental::assert_dep_graph::assert_dep_graph"; + if let Some(index) = stack.find(ASSERT_DEP_GRAPH) { + stack = &stack[..index + ASSERT_DEP_GRAPH.len()]; + } + + const REPORT_SYMBOL_NAMES: &str = "rustc_symbol_mangling::test::report_symbol_names"; + if let Some(index) = stack.find(REPORT_SYMBOL_NAMES) { + stack = &stack[..index + REPORT_SYMBOL_NAMES.len()]; + } + + const ENCODE_METADATA: &str = "rustc_middle::ty::context::TyCtxt::encode_metadata"; + if let Some(index) = stack.find(ENCODE_METADATA) { + stack = &stack[..index + ENCODE_METADATA.len()]; + } + + const SUBST_AND_NORMALIZE_ERASING_REGIONS: &str = "rustc_middle::ty::normalize_erasing_regions::::subst_and_normalize_erasing_regions"; + if let Some(index) = stack.find(SUBST_AND_NORMALIZE_ERASING_REGIONS) { + stack = &stack[..index + SUBST_AND_NORMALIZE_ERASING_REGIONS.len()]; + } + + const NORMALIZE_ERASING_LATE_BOUND_REGIONS: &str = "rustc_middle::ty::normalize_erasing_regions::::normalize_erasing_late_bound_regions"; + if let Some(index) = stack.find(NORMALIZE_ERASING_LATE_BOUND_REGIONS) { + stack = &stack[..index + NORMALIZE_ERASING_LATE_BOUND_REGIONS.len()]; + } + + const INST_BUILD: &str = "::build"; + if let Some(index) = stack.find(INST_BUILD) { + stack = &stack[..index + INST_BUILD.len()]; + } + + output.write_all(stack.as_bytes())?; + output.write_all(&*b" ")?; + output.write_all(count.as_bytes())?; + output.write_all(&*b"\n")?; + } + + Ok(()) +} From cc8744c004b2c15dcebeae514b3a023d08347309 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 12 Jul 2020 21:08:00 +0200 Subject: [PATCH 1403/1566] Set rust-analyzer.linkedProjects for vscode --- .vscode/settings.json | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000..a33e82a017f1b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,50 @@ +{ + "rust-analyzer.linkedProjects": [ + "./Cargo.toml", + //"./build_sysroot/sysroot_src/src/libstd/Cargo.toml", + { + "roots": [ + "./example/mini_core.rs", + "./example/mini_core_hello_world.rs", + "./example/mod_bench.rs" + ], + "crates": [ + { + "root_module": "./example/mini_core.rs", + "edition": "2018", + "deps": [], + "cfg": [], + }, + { + "root_module": "./example/mini_core_hello_world.rs", + "edition": "2018", + "deps": [{ "crate": 0, "name": "mini_core" }], + "cfg": [], + }, + { + "root_module": "./example/mod_bench.rs", + "edition": "2018", + "deps": [], + "cfg": [], + }, + ] + }, + { + "roots": ["./analyze_profile.rs"], + "crates": [ + { + "root_module": "./analyze_profile.rs", + "edition": "2018", + "deps": [{ "crate": 1, "name": "std" }], + "cfg": [], + }, + { + "root_module": "./build_sysroot/sysroot_src/src/libstd/lib.rs", + "edition": "2018", + "deps": [], + "cfg": [], + }, + ] + } + ] +} From d983813e0f81c9ee3f6dad372752b8d8c7259f7a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Jul 2020 11:45:16 +0200 Subject: [PATCH 1404/1566] Move RUSTDOCFLAGS to config.sh --- cargo.sh | 2 +- config.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cargo.sh b/cargo.sh index 3e756696d9c21..9b83deaf7ab98 100755 --- a/cargo.sh +++ b/cargo.sh @@ -20,4 +20,4 @@ fi cmd=$1 shift -RUSTDOCFLAGS=$RUSTFLAGS cargo +${TOOLCHAIN} $cmd --target $TARGET_TRIPLE $@ +cargo +${TOOLCHAIN} $cmd --target $TARGET_TRIPLE $@ diff --git a/config.sh b/config.sh index 9a745ad59520e..902743d54c732 100644 --- a/config.sh +++ b/config.sh @@ -31,6 +31,7 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then fi export RUSTFLAGS=$linker' -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +export RUSTDOCFLAGS=$RUSTFLAGS # FIXME remove once the atomic shim is gone if [[ `uname` == 'Darwin' ]]; then From c9d5e7da58621774567317f76c9086d819e11649 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Jul 2020 19:32:31 +0200 Subject: [PATCH 1405/1566] Rustup to rustc 1.46.0-nightly (9d09331e0 2020-07-12) --- rust-toolchain | 2 +- src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 83dfc825f79d8..b5d2f81756827 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-07-09 +nightly-2020-07-13 diff --git a/src/lib.rs b/src/lib.rs index 041c05722efd5..1096dbd227d66 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,8 +178,8 @@ impl CodegenBackend for CraneliftCodegenBackend { Box::new(crate::metadata::CraneliftMetadataLoader) } - fn provide(&self, providers: &mut Providers<'_>) { - providers.target_features_whitelist = |tcx, cnum| { + fn provide(&self, providers: &mut Providers) { + providers.supported_target_features = |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); if tcx.sess.opts.actually_rustdoc { // rustdoc needs to be able to document functions that use all the features, so @@ -197,7 +197,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } }; } - fn provide_extern(&self, _providers: &mut Providers<'_>) {} + fn provide_extern(&self, _providers: &mut Providers) {} fn target_features(&self, _sess: &Session) -> Vec { vec![rustc_span::Symbol::intern("cg_clif")] From 3dd65486f40071d35396d5914eea689caa2a7b69 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Jul 2020 19:35:21 +0200 Subject: [PATCH 1406/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ed00cd4895bb..6dba7411fd107 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c35a9631cdffc00a32b416f9cb0b80f182b716e" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" dependencies = [ "cranelift-codegen", "cranelift-module", From 8dfb1daea7a79ad983058098a091a2f4a7525cc9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Jul 2020 19:41:52 +0200 Subject: [PATCH 1407/1566] Update dependencies --- Cargo.lock | 4 ++-- Cargo.toml | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dba7411fd107..e1f4192fa2e26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -354,9 +354,9 @@ checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" [[package]] name = "syn" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" +checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 6c455c51dad04..084435b6dd391 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,8 @@ cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", bran cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true } cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } target-lexicon = "0.10.0" +gimli = { version = "0.21.0", default-features = false, features = ["write"]} +object = { version = "0.20.0", default-features = false, features = ["read", "std", "write"] } ar = "0.8.0" byteorder = "1.2.7" @@ -22,16 +24,6 @@ indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } -[dependencies.object] -version = "0.20.0" -default-features = false -features = ["read", "std", "write"] # We don't need WASM support - -[dependencies.gimli] -version = "0.21.0" -default-features = false -features = ["write"] # We don't need read support - # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/wasmtime/"] #cranelift-codegen = { path = "../wasmtime/cranelift/codegen" } From 4ec2831ebcf96775fe6de97ab4c73eb1368b667a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 13 Jul 2020 19:45:46 +0200 Subject: [PATCH 1408/1566] No silent truncating of SwitchInt values --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 1bd5559c33501..a1e7a33d607f2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -283,7 +283,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { let mut switch = ::cranelift_frontend::Switch::new(); for (i, value) in values.iter().enumerate() { let block = fx.get_block(targets[i]); - switch.set_entry(*value as u64, block); + switch.set_entry((*value).try_into().unwrap(), block); } let otherwise_block = fx.get_block(targets[targets.len() - 1]); switch.emit(&mut fx.bcx, discr, otherwise_block); From a0580610b244b246c29f9ff0062c9039de1afcdb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Jul 2020 16:38:50 +0200 Subject: [PATCH 1409/1566] Use `From::from` instead of `as` where possible --- src/abi/mod.rs | 2 +- src/base.rs | 12 ++++++------ src/cast.rs | 8 ++++---- src/common.rs | 24 ++++++++++++------------ src/debuginfo/line_info.rs | 10 +++++----- src/debuginfo/mod.rs | 2 +- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 2323dcc2083b2..f53aad1c259a1 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -273,7 +273,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let ret_vals = self.lib_call(name, input_tys, return_tys, &args); match *ret_vals { [] => CValue::by_ref( - Pointer::const_addr(self, self.pointer_type.bytes() as i64), + Pointer::const_addr(self, i64::from(self.pointer_type.bytes())), return_layout, ), [val] => CValue::by_val(val, return_layout), diff --git a/src/base.rs b/src/base.rs index a1e7a33d607f2..155f9dea8bc16 100644 --- a/src/base.rs +++ b/src/base.rs @@ -778,10 +778,10 @@ pub(crate) fn trans_place<'tcx>( from_end, } => { let index = if !from_end { - fx.bcx.ins().iconst(fx.pointer_type, offset as i64) + fx.bcx.ins().iconst(fx.pointer_type, i64::from(offset)) } else { let len = codegen_array_len(fx, cplace); - fx.bcx.ins().iadd_imm(len, -(offset as i64)) + fx.bcx.ins().iadd_imm(len, -i64::from(offset)) }; cplace = cplace.place_index(fx, index); } @@ -795,8 +795,8 @@ pub(crate) fn trans_place<'tcx>( let elem_layout = fx.layout_of(elem_ty); let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( - ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), - fx.layout_of(fx.tcx.mk_array(elem_ty, to as u64 - from as u64)), + ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), + fx.layout_of(fx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), ); } ty::Slice(elem_ty) => { @@ -805,8 +805,8 @@ pub(crate) fn trans_place<'tcx>( let (ptr, len) = cplace.to_ptr_maybe_unsized(); let len = len.unwrap(); cplace = CPlace::for_ptr_with_extra( - ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64), - fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), + ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), + fx.bcx.ins().iadd_imm(len, -(i64::from(from) + i64::from(to))), cplace.layout(), ); } diff --git a/src/cast.rs b/src/cast.rs index 395a270efd9dc..36e060496b1da 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -160,10 +160,10 @@ pub(crate) fn clif_int_or_float_cast( fx.bcx.ins().fcvt_to_uint_sat(types::I32, from) }; let (min, max) = match (to_ty, to_signed) { - (types::I8, false) => (0, u8::MAX as i64), - (types::I16, false) => (0, u16::MAX as i64), - (types::I8, true) => (i8::MIN as i64, i8::MAX as i64), - (types::I16, true) => (i16::MIN as i64, i16::MAX as i64), + (types::I8, false) => (0, i64::from(u8::MAX)), + (types::I16, false) => (0, i64::from(u16::MAX)), + (types::I8, true) => (i64::from(i8::MIN), i64::from(i8::MAX)), + (types::I16, true) => (i64::from(i16::MIN), i64::from(i16::MAX)), _ => unreachable!(), }; let min_val = fx.bcx.ins().iconst(types::I32, min); diff --git a/src/common.rs b/src/common.rs index bf0d4957bc32b..c8fcbbe1d37fe 100644 --- a/src/common.rs +++ b/src/common.rs @@ -172,8 +172,8 @@ fn resolve_128bit_value_imm(func: &Function, val: Value) -> Option { return None; }; - let lsb = resolve_normal_value_imm(func, lsb)? as u64 as u128; - let msb = resolve_normal_value_imm(func, msb)? as u64 as u128; + let lsb = u128::from(resolve_normal_value_imm(func, lsb)? as u64); + let msb = u128::from(resolve_normal_value_imm(func, msb)? as u64); Some(msb << 64 | lsb) } @@ -182,7 +182,7 @@ pub(crate) fn resolve_value_imm(func: &Function, val: Value) -> Option { if func.dfg.value_type(val) == types::I128 { resolve_128bit_value_imm(func, val) } else { - resolve_normal_value_imm(func, val).map(|imm| imm as u64 as u128) + resolve_normal_value_imm(func, val).map(|imm| u128::from(imm as u64)) } } @@ -217,21 +217,21 @@ pub(crate) fn type_min_max_value(bcx: &mut FunctionBuilder<'_>, ty: Type, signed (types::I8, false) | (types::I16, false) | (types::I32, false) | (types::I64, false) => { 0i64 } - (types::I8, true) => i8::MIN as i64, - (types::I16, true) => i16::MIN as i64, - (types::I32, true) => i32::MIN as i64, + (types::I8, true) => i64::from(i8::MIN), + (types::I16, true) => i64::from(i16::MIN), + (types::I32, true) => i64::from(i32::MIN), (types::I64, true) => i64::MIN, _ => unreachable!(), }; let max = match (ty, signed) { - (types::I8, false) => u8::MAX as i64, - (types::I16, false) => u16::MAX as i64, - (types::I32, false) => u32::MAX as i64, + (types::I8, false) => i64::from(u8::MAX), + (types::I16, false) => i64::from(u16::MAX), + (types::I32, false) => i64::from(u32::MAX), (types::I64, false) => u64::MAX as i64, - (types::I8, true) => i8::MAX as i64, - (types::I16, true) => i16::MAX as i64, - (types::I32, true) => i32::MAX as i64, + (types::I8, true) => i64::from(i8::MAX), + (types::I16, true) => i64::from(i16::MAX), + (types::I32, true) => i64::from(i32::MAX), (types::I64, true) => i64::MAX, _ => unreachable!(), }; diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 1a84f6584d48d..89dccb8545fc6 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -197,7 +197,7 @@ impl<'tcx> DebugContext<'tcx> { if let Some(ref mcr) = &context.mach_compile_result { for &MachSrcLoc { start, end, loc } in mcr.buffer.get_srclocs_sorted() { - line_program.row().address_offset = start as u64; + line_program.row().address_offset = u64::from(start); if !loc.is_default() { let source_info = *source_info_set.get_index(loc.bits() as usize).unwrap(); create_row_for_span(line_program, source_info.span); @@ -207,7 +207,7 @@ impl<'tcx> DebugContext<'tcx> { func_end = end; } - line_program.end_sequence(func_end as u64); + line_program.end_sequence(u64::from(func_end)); func_end = mcr.buffer.total_size(); } else { @@ -218,7 +218,7 @@ impl<'tcx> DebugContext<'tcx> { for block in blocks { for (offset, inst, size) in func.inst_offsets(block, &encinfo) { let srcloc = func.srclocs[inst]; - line_program.row().address_offset = offset as u64; + line_program.row().address_offset = u64::from(offset); if !srcloc.is_default() { let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); create_row_for_span(line_program, source_info.span); @@ -228,7 +228,7 @@ impl<'tcx> DebugContext<'tcx> { func_end = offset + size; } } - line_program.end_sequence(func_end as u64); + line_program.end_sequence(u64::from(func_end)); } assert_ne!(func_end, 0); @@ -241,7 +241,7 @@ impl<'tcx> DebugContext<'tcx> { addend: 0, }), ); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(func_end as u64)); + entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(func_end))); self.emit_location(entry_id, function_span); diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 709c85d240979..f3ba3b5ad117f 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -433,7 +433,7 @@ fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) - ValueLoc::Stack(ss) => { if let Some(ss_offset) = stack_slots[ss].offset { let mut expr = Expression::new(); - expr.op_breg(X86_64::RBP, ss_offset as i64 + 16); + expr.op_breg(X86_64::RBP, i64::from(ss_offset) + 16); Some(expr) } else { None From 3e67eb1b44c2570024211701925bf287d4c7bdc5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 14 Jul 2020 21:14:14 +0200 Subject: [PATCH 1410/1566] Update Cranelift Fixes #757 (through bytecodealliance/wasmtime#1939) --- Cargo.lock | 24 ++++++++++++------------ src/base.rs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1f4192fa2e26..6f068b28d446a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,7 +45,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "cranelift-entity", ] @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "byteorder", "cranelift-bforest", @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -80,17 +80,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" [[package]] name = "cranelift-entity" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" [[package]] name = "cranelift-frontend" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "cranelift-codegen", "log", @@ -101,7 +101,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "anyhow", "cranelift-codegen", @@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4b6ebc0c27014ac566f9989d0f59b6e6f1f9ccd0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -276,9 +276,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.26" +version = "0.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c03092d79e0fd610932d89ed53895a38c0dd3bcd317a0046e69940de32f1d95" +checksum = "b9ba8aaf5fe7cf307c6dbdaeed85478961d29e25e3bee5169e11b92fa9f027a8" dependencies = [ "log", "rustc-hash", diff --git a/src/base.rs b/src/base.rs index 155f9dea8bc16..6d9867274abec 100644 --- a/src/base.rs +++ b/src/base.rs @@ -283,7 +283,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { let mut switch = ::cranelift_frontend::Switch::new(); for (i, value) in values.iter().enumerate() { let block = fx.get_block(targets[i]); - switch.set_entry((*value).try_into().unwrap(), block); + switch.set_entry(*value, block); } let otherwise_block = fx.get_block(targets[targets.len() - 1]); switch.emit(&mut fx.bcx, discr, otherwise_block); From 748d516e0d468534c9dfccf00b99da55634ae2d2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 11 Jul 2020 21:19:10 +0200 Subject: [PATCH 1411/1566] Use builtin ranlib instead of running external ranlib This makes it possible to create rlibs for any target without installing a toolchain for the target Fixes #763 --- Cargo.lock | 3 +- Cargo.toml | 2 +- src/archive.rs | 139 +++++++++++++++++++++++++++---------------------- 3 files changed, 79 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f068b28d446a..3fc3623d8b68f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,8 +9,7 @@ checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" [[package]] name = "ar" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "450575f58f7bee32816abbff470cbc47797397c2a81e0eaced4b98436daf52e1" +source = "git+https://github.com/bjorn3/rust-ar.git?branch=do_not_remove_cg_clif_ranlib#de9ab0e56bf3a208381d342aa5b60f9ff2891648" [[package]] name = "autocfg" diff --git a/Cargo.toml b/Cargo.toml index 084435b6dd391..f16d45cd46a25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ target-lexicon = "0.10.0" gimli = { version = "0.21.0", default-features = false, features = ["write"]} object = { version = "0.20.0", default-features = false, features = ["read", "std", "write"] } -ar = "0.8.0" +ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } byteorder = "1.2.7" indexmap = "1.0.2" cfg-if = "0.1.10" diff --git a/src/archive.rs b/src/archive.rs index 6ae07a3bb7bfe..0e5820936bc59 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,3 +1,4 @@ +use std::collections::BTreeMap; use std::fs::File; use std::path::{Path, PathBuf}; @@ -5,12 +6,14 @@ use rustc_session::Session; use rustc_codegen_ssa::back::archive::{find_library, ArchiveBuilder}; use rustc_codegen_ssa::METADATA_FILENAME; +use object::{Object, SymbolKind}; + struct ArchiveConfig<'a> { sess: &'a Session, dst: PathBuf, lib_search_paths: Vec, - use_native_ar: bool, use_gnu_style_archive: bool, + no_builtin_ranlib: bool, } #[derive(Debug)] @@ -38,9 +41,9 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { sess, dst: output.to_path_buf(), lib_search_paths: archive_search_paths(sess), - use_native_ar: false, - // FIXME test for linux and System V derivatives instead use_gnu_style_archive: sess.target.target.options.archive_format == "gnu", + // FIXME fix builtin ranlib on macOS + no_builtin_ranlib: sess.target.target.options.is_like_osx, }; let (src_archives, entries) = if let Some(input) = input { @@ -141,85 +144,97 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn build(mut self) { - use std::process::Command; - - fn add_file_using_ar(archive: &Path, file: &Path) { - Command::new("ar") - .arg("r") // add or replace file - .arg("-c") // silence created file message - .arg(archive) - .arg(&file) - .status() - .unwrap(); - } - - enum BuilderKind<'a> { + enum BuilderKind { Bsd(ar::Builder), Gnu(ar::GnuBuilder), - NativeAr(&'a Path), } - let mut builder = if self.config.use_native_ar { - BuilderKind::NativeAr(&self.config.dst) - } else if self.config.use_gnu_style_archive { - BuilderKind::Gnu(ar::GnuBuilder::new( - File::create(&self.config.dst).unwrap(), - self.entries - .iter() - .map(|(name, _)| name.as_bytes().to_vec()) - .collect(), - )) - } else { - BuilderKind::Bsd(ar::Builder::new(File::create(&self.config.dst).unwrap())) - }; + let mut symbol_table = BTreeMap::new(); - // Add all files - for (entry_name, entry) in self.entries.into_iter() { - match entry { + let mut entries = Vec::new(); + + for (entry_name, entry) in self.entries { + // FIXME only read the symbol table of the object files to avoid having to keep all + // object files in memory at once, or read them twice. + let data = match entry { ArchiveEntry::FromArchive { archive_index, entry_index, } => { - let (ref src_archive_path, ref mut src_archive) = + // FIXME read symbols from symtab + use std::io::Read; + let (ref _src_archive_path, ref mut src_archive) = self.src_archives[archive_index]; - let entry = src_archive.jump_to_entry(entry_index).unwrap(); - let header = entry.header().clone(); + let mut entry = src_archive.jump_to_entry(entry_index).unwrap(); + let mut data = Vec::new(); + entry.read_to_end(&mut data).unwrap(); + data - match builder { - BuilderKind::Bsd(ref mut builder) => { - builder.append(&header, entry).unwrap() - } - BuilderKind::Gnu(ref mut builder) => { - builder.append(&header, entry).unwrap() - } - BuilderKind::NativeAr(archive_file) => { - Command::new("ar") - .arg("x") - .arg(src_archive_path) - .arg(&entry_name) - .status() - .unwrap(); - add_file_using_ar(archive_file, Path::new(&entry_name)); - std::fs::remove_file(entry_name).unwrap(); + } + ArchiveEntry::File(file) => { + std::fs::read(file).unwrap() + } + }; + + if !self.config.no_builtin_ranlib { + match object::File::parse(&data) { + Ok(object) => { + symbol_table.insert(entry_name.as_bytes().to_vec(), object.symbols().filter_map(|(_index, symbol)| { + if symbol.is_undefined() || symbol.is_local() || symbol.kind() != SymbolKind::Data && symbol.kind() != SymbolKind::Text && symbol.kind() != SymbolKind::Tls { + None + } else { + symbol.name().map(|name| name.as_bytes().to_vec()) + } + }).collect::>()); + } + Err(err) => { + let err = err.to_string(); + if err == "Unknown file magic" { + // Not an object file; skip it. + } else { + self.config.sess.fatal(&format!("Error parsing `{}` during archive creation: {}", entry_name, err)); } } } - ArchiveEntry::File(file) => match builder { - BuilderKind::Bsd(ref mut builder) => builder - .append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()) - .unwrap(), - BuilderKind::Gnu(ref mut builder) => builder - .append_file(entry_name.as_bytes(), &mut File::open(file).unwrap()) - .unwrap(), - BuilderKind::NativeAr(archive_file) => add_file_using_ar(archive_file, &file), - }, + } + + entries.push((entry_name, data)); + } + + let mut builder = if self.config.use_gnu_style_archive { + BuilderKind::Gnu(ar::GnuBuilder::new( + File::create(&self.config.dst).unwrap(), + entries + .iter() + .map(|(name, _)| name.as_bytes().to_vec()) + .collect(), + ar::GnuSymbolTableFormat::Size32, + symbol_table, + ).unwrap()) + } else { + BuilderKind::Bsd(ar::Builder::new( + File::create(&self.config.dst).unwrap(), + symbol_table, + ).unwrap()) + }; + + // Add all files + for (entry_name, data) in entries.into_iter() { + let header = ar::Header::new(entry_name.into_bytes(), data.len() as u64); + match builder { + BuilderKind::Bsd(ref mut builder) => builder + .append(&header, &mut &*data) + .unwrap(), + BuilderKind::Gnu(ref mut builder) => builder + .append(&header, &mut &*data) + .unwrap(), } } // Finalize archive std::mem::drop(builder); - if self.update_symbols { + if self.config.no_builtin_ranlib { let ranlib = crate::toolchain::get_toolchain_binary(self.config.sess, "ranlib"); // Run ranlib to be able to link the archive From 4a21cff957fd7f5fe2d4f27f19f39635157da067 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 16 Jul 2020 12:55:03 +0200 Subject: [PATCH 1412/1566] Remove usage of extern_weak in fast_thread_local --- ...-of-extern_weak-in-fast_thread_local.patch | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 patches/0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch diff --git a/patches/0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch b/patches/0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch new file mode 100644 index 0000000000000..06f8301ae4de6 --- /dev/null +++ b/patches/0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch @@ -0,0 +1,45 @@ +From 7496bb94a2fb2bc34629c9781c3bc3a470becaee Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Fri, 10 Apr 2020 13:47:42 +0200 +Subject: [PATCH] Remove usage of extern_weak in fast_thread_local + +--- + src/libstd/sys/unix/fast_thread_local.rs | 20 -------------------- + 1 files changed, 0 insertions(+), 20 deletions(-) + +diff --git a/src/libstd/sys/unix/fast_thread_local.rs b/src/libstd/sys/unix/fast_thread_local.rs +index 8730b4d..8d6e3d5 100644 +--- a/src/libstd/sys/unix/fast_thread_local.rs ++++ b/src/libstd/sys/unix/fast_thread_local.rs +@@ -15,28 +15,8 @@ + target_os = "emscripten" + ))] + pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { +- use crate::mem; + use crate::sys_common::thread_local::register_dtor_fallback; + +- extern "C" { +- #[linkage = "extern_weak"] +- static __dso_handle: *mut u8; +- #[linkage = "extern_weak"] +- static __cxa_thread_atexit_impl: *const libc::c_void; +- } +- if !__cxa_thread_atexit_impl.is_null() { +- type F = unsafe extern "C" fn( +- dtor: unsafe extern "C" fn(*mut u8), +- arg: *mut u8, +- dso_handle: *mut u8, +- ) -> libc::c_int; +- mem::transmute::<*const libc::c_void, F>(__cxa_thread_atexit_impl)( +- dtor, +- t, +- &__dso_handle as *const _ as *mut _, +- ); +- return; +- } + register_dtor_fallback(t, dtor); + } + +-- +2.20.1 + From e87651c3f23e6ad63cc1ee359115ad72e50d3ba9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 29 Jun 2020 11:23:49 +0200 Subject: [PATCH 1413/1566] Add test for SwitchInt on 128bit integers --- example/std_example.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index 0c8fa8c0ba970..e0af1ff912b40 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -111,6 +111,17 @@ fn main() { let kind = Nums::NegOne; assert_eq!(-1i128, kind as i128); + + let options = [1u128]; + match options[0] { + 1 => (), + 0 => loop {}, + v => panic(v), + }; +} + +fn panic(_: u128) { + panic!(); } #[target_feature(enable = "sse2")] From ccfd1b9334aa1c3175ce29596b3083b68eaae5d7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 16 Jul 2020 14:58:41 +0200 Subject: [PATCH 1414/1566] Initialize the atomic mutex in a constructor for proc macros --- src/atomic_shim.rs | 35 ++++++++++++++++++++++++++++++++++- src/backend.rs | 28 +++++++++++++++++++++++++++- src/driver/aot.rs | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 91 insertions(+), 5 deletions(-) diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index b317f31ff9009..942f2c8c99afa 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -10,7 +10,7 @@ use crate::prelude::*; pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; pub(crate) fn init_global_lock(module: &mut Module, bcx: &mut FunctionBuilder<'_>) { - if std::env::var("CG_CLIF_JIT").is_ok () { + if std::env::var("CG_CLIF_JIT").is_ok() { // When using JIT, dylibs won't find the __cg_clif_global_atomic_mutex data object defined here, // so instead define it in the cg_clif dylib. @@ -47,6 +47,39 @@ pub(crate) fn init_global_lock(module: &mut Module, bcx: &mut Func bcx.ins().call(pthread_mutex_init, &[atomic_mutex, nullptr]); } +pub(crate) fn init_global_lock_constructor( + module: &mut Module, + constructor_name: &str +) -> FuncId { + let sig = Signature::new(CallConv::SystemV); + let init_func_id = module + .declare_function(constructor_name, Linkage::Export, &sig) + .unwrap(); + + let mut ctx = Context::new(); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig); + { + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); + + let block = bcx.create_block(); + bcx.switch_to_block(block); + + crate::atomic_shim::init_global_lock(module, &mut bcx); + + bcx.ins().return_(&[]); + bcx.seal_all_blocks(); + bcx.finalize(); + } + module.define_function( + init_func_id, + &mut ctx, + &mut cranelift_codegen::binemit::NullTrapSink {}, + ).unwrap(); + + init_func_id +} + pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { let atomic_mutex = fx.module.declare_data( "__cg_clif_global_atomic_mutex", diff --git a/src/backend.rs b/src/backend.rs index 294f6952ae20c..e375fffb6cb62 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -97,6 +97,32 @@ impl WriteDebugInfo for ObjectProduct { } } +// FIXME remove once atomic instructions are implemented in Cranelift. +pub(crate) trait AddConstructor { + fn add_constructor(&mut self, func_id: FuncId); +} + +impl AddConstructor for ObjectProduct { + fn add_constructor(&mut self, func_id: FuncId) { + let symbol = self.function_symbol(func_id); + let segment = self.object.segment_name(object::write::StandardSegment::Data); + let init_array_section = self.object.add_section(segment.to_vec(), b".init_array".to_vec(), SectionKind::Data); + self.object.append_section_data( + init_array_section, + &std::iter::repeat(0).take(8 /*FIXME pointer size*/).collect::>(), + 8, + ); + self.object.add_relocation(init_array_section, object::write::Relocation { + offset: 0, + size: 64, // FIXME pointer size + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + symbol, + addend: 0, + }).unwrap(); + } +} + pub(crate) trait Emit { fn emit(self) -> Vec; } @@ -140,7 +166,7 @@ pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object metadata_object.write().unwrap() } -pub(crate) type Backend = impl cranelift_module::Backend; +pub(crate) type Backend = impl cranelift_module::Backend; pub(crate) fn make_module(sess: &Session, name: String) -> Module { let module: Module = Module::new( diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 4510614cf43cc..38ca44c4bfbd0 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -11,7 +11,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use crate::prelude::*; -use crate::backend::{Emit, WriteDebugInfo}; +use crate::backend::{AddConstructor, Emit, WriteDebugInfo}; fn new_module(tcx: TyCtxt<'_>, name: String) -> Module { let module = crate::backend::make_module(tcx.sess, name); @@ -35,8 +35,9 @@ fn emit_module( mut module: Module, debug: Option>, unwind_context: UnwindContext<'_>, + map_product: impl FnOnce(B::Product) -> B::Product, ) -> ModuleCodegenResult - where B::Product: Emit + WriteDebugInfo, + where B::Product: AddConstructor + Emit + WriteDebugInfo, { module.finalize_definitions(); let mut product = module.finish(); @@ -47,6 +48,8 @@ fn emit_module( unwind_context.emit(&mut product); + let product = map_product(product); + let tmp_file = tcx .output_filenames(LOCAL_CRATE) .temp_path(OutputType::Object, Some(&name)); @@ -110,7 +113,23 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege let cgu = tcx.codegen_unit(cgu_name); let mono_items = cgu.items_in_deterministic_order(tcx); - let module = new_module(tcx, cgu_name.as_str().to_string()); + let mut module = new_module(tcx, cgu_name.as_str().to_string()); + + // Initialize the global atomic mutex using a constructor for proc-macros. + // FIXME implement atomic instructions in Cranelift. + let mut init_atomics_mutex_from_constructor = None; + if tcx.sess.crate_types().contains(&rustc_session::config::CrateType::ProcMacro) { + if mono_items.iter().any(|(mono_item, _)| { + match mono_item { + rustc_middle::mir::mono::MonoItem::Static(def_id) => { + tcx.symbol_name(Instance::mono(tcx, *def_id)).name.as_str().contains("__rustc_proc_macro_decls_") + } + _ => false, + } + }) { + init_atomics_mutex_from_constructor = Some(crate::atomic_shim::init_global_lock_constructor(&mut module, &format!("{}_init_atomics_mutex", cgu_name.as_str()))); + } + } let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); super::codegen_mono_items(&mut cx, mono_items); @@ -124,6 +143,13 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege module, debug, unwind_context, + |mut product| { + if let Some(func_id) = init_atomics_mutex_from_constructor { + product.add_constructor(func_id); + } + + product + } ); codegen_global_asm(tcx, &cgu.name().as_str(), &global_asm); @@ -196,6 +222,7 @@ pub(super) fn run_aot( allocator_module, None, allocator_unwind_context, + |product| product, ); if let Some((id, product)) = work_product { work_products.insert(id, product); From 942039b2328c14e62183d609ca43c115db816631 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 20 Apr 2020 17:13:43 +0200 Subject: [PATCH 1415/1566] Pass ByRef values at fixed stack offset for extern "C" This makes it possible to build proc macros using cg_clif --- Cargo.lock | 44 ++++++++++++++++++++++---------------------- cargo.sh | 2 +- src/abi/mod.rs | 22 +++++++++++++--------- src/abi/pass_mode.rs | 19 ++++++++++--------- src/abi/returning.rs | 20 ++++++++++---------- src/debuginfo/mod.rs | 1 + test.sh | 6 +++--- 7 files changed, 60 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fc3623d8b68f..bdc01941351d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,16 +43,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "byteorder", "cranelift-bforest", @@ -69,8 +69,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -78,18 +78,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" [[package]] name = "cranelift-entity" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" [[package]] name = "cranelift-frontend" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "cranelift-codegen", "log", @@ -99,8 +99,8 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "anyhow", "cranelift-codegen", @@ -111,8 +111,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -121,8 +121,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "anyhow", "cranelift-codegen", @@ -133,8 +133,8 @@ dependencies = [ [[package]] name = "cranelift-simplejit" -version = "0.65.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4ba3ee33682c293747a672bfb87d5235bb1e62b3" +version = "0.66.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -275,9 +275,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.27" +version = "0.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ba8aaf5fe7cf307c6dbdaeed85478961d29e25e3bee5169e11b92fa9f027a8" +checksum = "3598bed0895fe0f72a9e0b00ef9e3a3c8af978a8401b2f2046dec5927de6364a" dependencies = [ "log", "rustc-hash", diff --git a/cargo.sh b/cargo.sh index 9b83deaf7ab98..5ee21f467e215 100755 --- a/cargo.sh +++ b/cargo.sh @@ -20,4 +20,4 @@ fi cmd=$1 shift -cargo +${TOOLCHAIN} $cmd --target $TARGET_TRIPLE $@ +cargo +${TOOLCHAIN} $cmd $@ diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f53aad1c259a1..1989b2b08b392 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -6,7 +6,7 @@ mod returning; use rustc_target::spec::abi::Abi; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; -use cranelift_codegen::ir::AbiParam; +use cranelift_codegen::ir::{AbiParam, ArgumentPurpose}; use self::pass_mode::*; use crate::prelude::*; @@ -123,7 +123,11 @@ fn clif_sig_from_fn_sig<'tcx>( if abi != Abi::Rust && abi != Abi::RustCall && abi != Abi::RustIntrinsic { match pass_mode { PassMode::NoPass | PassMode::ByVal(_) => {} - PassMode::ByValPair(_, _) | PassMode::ByRef { sized: _ } => { + PassMode::ByRef { size: Some(size) } => { + let purpose = ArgumentPurpose::StructArgument(u32::try_from(size.bytes()).expect("struct too big to pass on stack")); + return EmptySinglePair::Single(AbiParam::special(pointer_ty(tcx), purpose)).into_iter(); + } + PassMode::ByValPair(_, _) | PassMode::ByRef { size: None } => { tcx.sess.span_warn( span, &format!( @@ -137,7 +141,7 @@ fn clif_sig_from_fn_sig<'tcx>( } } } - pass_mode.get_param_ty(tcx).into_iter() + pass_mode.get_param_ty(tcx).map(AbiParam::new).into_iter() }) .flatten(); @@ -145,26 +149,26 @@ fn clif_sig_from_fn_sig<'tcx>( tcx, tcx.layout_of(ParamEnv::reveal_all().and(output)).unwrap(), ) { - PassMode::NoPass => (inputs.map(AbiParam::new).collect(), vec![]), + PassMode::NoPass => (inputs.collect(), vec![]), PassMode::ByVal(ret_ty) => ( - inputs.map(AbiParam::new).collect(), + inputs.collect(), vec![AbiParam::new(ret_ty)], ), PassMode::ByValPair(ret_ty_a, ret_ty_b) => ( - inputs.map(AbiParam::new).collect(), + inputs.collect(), vec![AbiParam::new(ret_ty_a), AbiParam::new(ret_ty_b)], ), - PassMode::ByRef { sized: true } => { + PassMode::ByRef { size: Some(_) } => { ( Some(pointer_ty(tcx)) // First param is place to put return val .into_iter() + .map(|ty| AbiParam::special(ty, ArgumentPurpose::StructReturn)) .chain(inputs) - .map(AbiParam::new) .collect(), vec![], ) } - PassMode::ByRef { sized: false } => todo!(), + PassMode::ByRef { size: None } => todo!(), }; if requires_caller_location { diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 68af0e6ca0fa8..390637e8e440e 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -7,7 +7,7 @@ pub(super) enum PassMode { NoPass, ByVal(Type), ByValPair(Type, Type), - ByRef { sized: bool }, + ByRef { size: Option }, } #[derive(Copy, Clone, Debug)] @@ -70,8 +70,8 @@ impl PassMode { PassMode::NoPass => Empty, PassMode::ByVal(clif_type) => Single(clif_type), PassMode::ByValPair(a, b) => Pair(a, b), - PassMode::ByRef { sized: true } => Single(pointer_ty(tcx)), - PassMode::ByRef { sized: false } => Pair(pointer_ty(tcx), pointer_ty(tcx)), + PassMode::ByRef { size: Some(_) } => Single(pointer_ty(tcx)), + PassMode::ByRef { size: None } => Pair(pointer_ty(tcx), pointer_ty(tcx)), } } } @@ -93,16 +93,17 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) // Returning (i128, i128) by-val-pair would take 4 regs, while only 3 are // available on x86_64. Cranelift gets confused when too many return params // are used. - PassMode::ByRef { sized: true } + PassMode::ByRef { size: Some(layout.size) } } else { PassMode::ByValPair(a, b) } } // FIXME implement Vector Abi in a cg_llvm compatible way - Abi::Vector { .. } => PassMode::ByRef { sized: true }, + Abi::Vector { .. } => PassMode::ByRef { size: Some(layout.size) }, - &Abi::Aggregate { sized } => PassMode::ByRef { sized }, + Abi::Aggregate { sized: true } => PassMode::ByRef { size: Some(layout.size) }, + Abi::Aggregate { sized: false } => PassMode::ByRef { size: None }, } } } @@ -118,7 +119,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( let (a, b) = arg.load_scalar_pair(fx); Pair(a, b) } - PassMode::ByRef { sized: _ } => { + PassMode::ByRef { size: _ } => { match arg.force_stack(fx) { (ptr, None) => Single(ptr.get_addr(fx)), (ptr, Some(meta)) => Pair(ptr.get_addr(fx), meta), @@ -164,8 +165,8 @@ pub(super) fn cvalue_for_param<'tcx>( let (a, b) = block_params.assert_pair(); Some(CValue::by_val_pair(a, b, layout)) } - PassMode::ByRef { sized: true } => Some(CValue::by_ref(Pointer::new(block_params.assert_single()), layout)), - PassMode::ByRef { sized: false } => { + PassMode::ByRef { size: Some(_) } => Some(CValue::by_ref(Pointer::new(block_params.assert_single()), layout)), + PassMode::ByRef { size: None } => { let (ptr, meta) = block_params.assert_pair(); Some(CValue::by_ref_unsized(Pointer::new(ptr), meta, layout)) } diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 449c77c3c09b5..e445a12b2a882 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -9,7 +9,7 @@ pub(crate) fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyAndL match get_pass_mode(tcx, dest_layout) { PassMode::NoPass | PassMode::ByVal(_) => true, // FIXME Make it possible to return ByValPair and ByRef to an ssa var. - PassMode::ByValPair(_, _) | PassMode::ByRef { sized: _ } => false + PassMode::ByValPair(_, _) | PassMode::ByRef { size: _ } => false } } @@ -33,14 +33,14 @@ pub(super) fn codegen_return_param( Empty } - PassMode::ByRef { sized: true } => { + PassMode::ByRef { size: Some(_) } => { let ret_param = fx.bcx.append_block_param(start_block, fx.pointer_type); fx.local_map .insert(RETURN_PLACE, CPlace::for_ptr(Pointer::new(ret_param), ret_layout)); Single(ret_param) } - PassMode::ByRef { sized: false } => todo!(), + PassMode::ByRef { size: None } => todo!(), }; #[cfg(not(debug_assertions))] @@ -69,11 +69,11 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( let output_pass_mode = get_pass_mode(fx.tcx, ret_layout); let return_ptr = match output_pass_mode { PassMode::NoPass => None, - PassMode::ByRef { sized: true } => match ret_place { + PassMode::ByRef { size: Some(_)} => match ret_place { Some(ret_place) => Some(ret_place.to_ptr().get_addr(fx)), - None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), + None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), // FIXME allocate temp stack slot }, - PassMode::ByRef { sized: false } => todo!(), + PassMode::ByRef { size: None } => todo!(), PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None, }; @@ -94,8 +94,8 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( ret_place.write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_layout)); } } - PassMode::ByRef { sized: true } => {} - PassMode::ByRef { sized: false } => todo!(), + PassMode::ByRef { size: Some(_) } => {} + PassMode::ByRef { size: None } => todo!(), } (call_inst, meta) @@ -103,10 +103,10 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { match get_pass_mode(fx.tcx, return_layout(fx)) { - PassMode::NoPass | PassMode::ByRef { sized: true } => { + PassMode::NoPass | PassMode::ByRef { size: Some(_) } => { fx.bcx.ins().return_(&[]); } - PassMode::ByRef { sized: false } => todo!(), + PassMode::ByRef { size: None } => todo!(), PassMode::ByVal(_) => { let place = fx.get_local_place(RETURN_PLACE); let ret_val = place.to_cvalue(fx).load_scalar(fx); diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index f3ba3b5ad117f..37dc9f4e3c5bb 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -313,6 +313,7 @@ impl<'tcx> DebugContext<'tcx> { use cranelift_codegen::ir::ArgumentPurpose; let base_name = match param.purpose { ArgumentPurpose::Normal => "arg", + ArgumentPurpose::StructArgument(_) => "struct_arg", ArgumentPurpose::StructReturn => "sret", ArgumentPurpose::Link | ArgumentPurpose::FramePointer | ArgumentPurpose::CalleeSaved => continue, ArgumentPurpose::VMContext | ArgumentPurpose::SignatureId | ArgumentPurpose::StackLimit => unreachable!(), diff --git a/test.sh b/test.sh index 7127ba79fe985..74ead626e692c 100755 --- a/test.sh +++ b/test.sh @@ -74,12 +74,12 @@ $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE pushd simple-raytracer if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then echo "[BENCH COMPILE] ebobby/simple-raytracer" - hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "rm -r target/*/debug || true" \ - "RUSTFLAGS='' cargo build --target $TARGET_TRIPLE" \ + hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \ + "RUSTFLAGS='' cargo build" \ "../cargo.sh build" echo "[BENCH RUN] ebobby/simple-raytracer" - cp ./target/*/debug/main ./raytracer_cg_clif + cp ./target/debug/main ./raytracer_cg_clif hyperfine --runs ${RUN_RUNS:-10} ./raytracer_cg_llvm ./raytracer_cg_clif else echo "[BENCH COMPILE] ebobby/simple-raytracer (skipped)" From 34823a7e4c9d13abe7b92056b3c76af7ef9336ec Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Jul 2020 19:15:33 +0200 Subject: [PATCH 1416/1566] Rustup to rustc 1.46.0-nightly (5c9e5df3a 2020-07-16) --- ...-usage-of-extern_weak-in-thread_local_dtor.patch} | 12 ++++++------ rust-toolchain | 2 +- src/abi/mod.rs | 6 +++--- src/base.rs | 6 +++--- src/constant.rs | 10 +++++----- src/driver/aot.rs | 2 +- src/driver/mod.rs | 2 +- src/main_shim.rs | 2 +- src/pretty_clif.rs | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) rename patches/{0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch => 0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch} (73%) diff --git a/patches/0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch b/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch similarity index 73% rename from patches/0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch rename to patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch index 06f8301ae4de6..0a25e6b3302d5 100644 --- a/patches/0025-Remove-usage-of-extern_weak-in-fast_thread_local.patch +++ b/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch @@ -1,22 +1,22 @@ From 7496bb94a2fb2bc34629c9781c3bc3a470becaee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 10 Apr 2020 13:47:42 +0200 -Subject: [PATCH] Remove usage of extern_weak in fast_thread_local +Subject: [PATCH] Remove usage of extern_weak in thread_local_dtor --- - src/libstd/sys/unix/fast_thread_local.rs | 20 -------------------- + src/libstd/sys/unix/thread_local_dtor.rs | 20 -------------------- 1 files changed, 0 insertions(+), 20 deletions(-) -diff --git a/src/libstd/sys/unix/fast_thread_local.rs b/src/libstd/sys/unix/fast_thread_local.rs +diff --git a/src/libstd/sys/unix/thread_local_dtor.rs b/src/libstd/sys/unix/thread_local_dtor.rs index 8730b4d..8d6e3d5 100644 ---- a/src/libstd/sys/unix/fast_thread_local.rs -+++ b/src/libstd/sys/unix/fast_thread_local.rs +--- a/src/libstd/sys/unix/thread_local_dtor.rs ++++ b/src/libstd/sys/unix/thread_local_dtor.rs @@ -15,28 +15,8 @@ target_os = "emscripten" ))] pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::mem; - use crate::sys_common::thread_local::register_dtor_fallback; + use crate::sys_common::thread_local_dtor::register_dtor_fallback; - extern "C" { - #[linkage = "extern_weak"] diff --git a/rust-toolchain b/rust-toolchain index b5d2f81756827..1903f2c25cde3 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-07-13 +nightly-2020-07-17 diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 1989b2b08b392..1b67f3d6f15f2 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -195,7 +195,7 @@ pub(crate) fn get_function_name_and_sig<'tcx>( tcx.sess.span_fatal(tcx.def_span(inst.def_id()), "Variadic function definitions are not yet supported"); } let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, tcx.def_span(inst.def_id()), false, inst.def.requires_caller_location(tcx)); - (tcx.symbol_name(inst).name.as_str().to_string(), sig) + (tcx.symbol_name(inst).name.to_string(), sig) } /// Instance must be monomorphized @@ -465,10 +465,10 @@ pub(crate) fn codegen_terminator_call<'tcx>( .unwrap() .unwrap(); - if fx.tcx.symbol_name(instance).name.as_str().starts_with("llvm.") { + if fx.tcx.symbol_name(instance).name.starts_with("llvm.") { crate::intrinsics::codegen_llvm_intrinsic_call( fx, - &fx.tcx.symbol_name(instance).name.as_str(), + &fx.tcx.symbol_name(instance).name, substs, args, destination, diff --git a/src/base.rs b/src/base.rs index 6d9867274abec..f7fdea6514020 100644 --- a/src/base.rs +++ b/src/base.rs @@ -266,7 +266,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { }); let instance = Instance::mono(fx.tcx, def_id); - let symbol_name = fx.tcx.symbol_name(instance).name.as_str(); + let symbol_name = fx.tcx.symbol_name(instance).name; fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); @@ -719,10 +719,10 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } // ___chkstk, ___chkstk_ms and __alloca are only used on Windows - _ if fx.tcx.symbol_name(fx.instance).name.as_str().starts_with("___chkstk") => { + _ if fx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { crate::trap::trap_unimplemented(fx, "Stack probes are not supported"); } - _ if fx.tcx.symbol_name(fx.instance).name.as_str() == "__alloca" => { + _ if fx.tcx.symbol_name(fx.instance).name == "__alloca" => { crate::trap::trap_unimplemented(fx, "Alloca is not supported"); } // Used in sys::windows::abort_internal diff --git a/src/constant.rs b/src/constant.rs index 8a22ddefbb27a..139dcb5988f30 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -75,18 +75,18 @@ pub(crate) fn trans_constant<'tcx>( let const_ = fx.monomorphize(&constant.literal); let const_val = match const_.val { ConstKind::Value(const_val) => const_val, - ConstKind::Unevaluated(def_id, ref substs, promoted) if fx.tcx.is_static(def_id) => { + ConstKind::Unevaluated(def, ref substs, promoted) if fx.tcx.is_static(def.did) => { assert!(substs.is_empty()); assert!(promoted.is_none()); return codegen_static_ref( fx, - def_id, + def.did, fx.layout_of(fx.monomorphize(&constant.literal.ty)), ).to_cvalue(fx); } - ConstKind::Unevaluated(def_id, ref substs, promoted) => { - match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def_id, substs, promoted, None) { + ConstKind::Unevaluated(def, ref substs, promoted) => { + match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { Ok(const_val) => const_val, Err(_) => { if promoted.is_none() { @@ -229,7 +229,7 @@ fn data_id_for_static( linkage: Linkage, ) -> DataId { let instance = Instance::mono(tcx, def_id); - let symbol_name = tcx.symbol_name(instance).name.as_str(); + let symbol_name = tcx.symbol_name(instance).name; let ty = instance.monomorphic_ty(tcx); let is_mutable = if tcx.is_mutable_static(def_id) { true diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 38ca44c4bfbd0..d6d62598efb03 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -122,7 +122,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege if mono_items.iter().any(|(mono_item, _)| { match mono_item { rustc_middle::mir::mono::MonoItem::Static(def_id) => { - tcx.symbol_name(Instance::mono(tcx, *def_id)).name.as_str().contains("__rustc_proc_macro_decls_") + tcx.symbol_name(Instance::mono(tcx, *def_id)).name.contains("__rustc_proc_macro_decls_") } _ => false, } diff --git a/src/driver/mod.rs b/src/driver/mod.rs index f8446cbeddddb..1d81efb880df7 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -62,7 +62,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( match mono_item { MonoItem::Fn(inst) => { let _inst_guard = - crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name.as_str())); + crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name)); debug_assert!(!inst.substs.needs_infer()); let _mir_guard = crate::PrintOnPanic(|| { match inst.def { diff --git a/src/main_shim.rs b/src/main_shim.rs index 7366c6a9c0a54..98148355b271b 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -22,7 +22,7 @@ pub(crate) fn maybe_create_entry_wrapper( }; let instance = Instance::mono(tcx, main_def_id); - if module.get_name(&*tcx.symbol_name(instance).name.as_str()).is_none() { + if module.get_name(&*tcx.symbol_name(instance).name).is_none() { return; } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 8b1e611ef2f85..0dcd2c269e83e 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -74,7 +74,7 @@ impl CommentWriter { pub(crate) fn new<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self { let global_comments = if cfg!(debug_assertions) { vec![ - format!("symbol {}", tcx.symbol_name(instance).name.as_str()), + format!("symbol {}", tcx.symbol_name(instance).name), format!("instance {:?}", instance), format!( "sig {:?}", @@ -220,7 +220,7 @@ pub(crate) fn write_clif_file<'tcx>( .expect("value location ranges") }); - let symbol_name = tcx.symbol_name(instance).name.as_str(); + let symbol_name = tcx.symbol_name(instance).name; let clif_file_name = format!( "{}/{}__{}.{}.clif", concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), From 26e7bc1ed68e5be33c75417997319f37bb4fc806 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 17 Jul 2020 19:18:40 +0200 Subject: [PATCH 1417/1566] Update log dependency --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdc01941351d0..1a48e268c8ecb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -217,9 +217,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.8" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ "cfg-if", ] From 0b211be054ff4922e0edc2b989b1745fa4d59c68 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 19 Jul 2020 14:45:58 +0200 Subject: [PATCH 1418/1566] Use SystemV abi for extern "sysv64" even on Windows --- src/abi/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 1b67f3d6f15f2..0a6d54c73b3e4 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -91,7 +91,8 @@ fn clif_sig_from_fn_sig<'tcx>( }; let (call_conv, inputs, output): (CallConv, Vec>, Ty<'tcx>) = match abi { Abi::Rust => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), - Abi::C | Abi::Unadjusted | Abi::SysV64 => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), + Abi::C | Abi::Unadjusted => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), + Abi::SysV64 => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); let extra_args = match sig.inputs().last().unwrap().kind { From edc0a3470b7eff4c25fe39b0109cb5442a223c6c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 19 Jul 2020 14:54:18 +0200 Subject: [PATCH 1419/1566] Implement simd_insert --- example/std_example.rs | 9 +++++++++ src/intrinsics/simd.rs | 20 ++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index e0af1ff912b40..dee228a7d108c 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -146,6 +146,7 @@ unsafe fn test_simd() { // FIXME(#666) implement `#[rustc_arg_required_const(..)]` support //test_mm_extract_epi8(); + //test_mm_insert_epi16(); let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); assert_eq!(mask1, 1); @@ -279,6 +280,14 @@ unsafe fn test_mm_extract_epi8() { assert_eq!(r2, 3); } +#[target_feature(enable = "sse2")] +unsafe fn test_mm_insert_epi16() { + let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); + let r = _mm_insert_epi16(a, 9, 0); + let e = _mm_setr_epi16(9, 1, 2, 3, 4, 5, 6, 7); + assert_eq_m128i(r, e); +} + fn test_checked_mul() { let u: Option = u8::from_str_radix("1000", 10).ok(); assert_eq!(u, None); diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 32f561bdd3631..92fd00f049c4c 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -33,6 +33,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }); }; + // FIXME support float comparisons simd_eq, (c x, c y) { validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_cmp!(fx, Equal(x, y) -> ret); @@ -113,7 +114,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( } }; - simd_insert, (c base, o idx, v _val) { + simd_insert, (c base, o idx, c val) { // FIXME validate let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const @@ -132,13 +133,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); } - // FIXME implement this - fx.tcx.sess.span_warn( - fx.mir.span, - "`simd_insert` is not yet implemented. Calling this function will panic.", - ); - let val = crate::trap::trap_unimplemented_ret_value(fx, ret.layout(), "`simd_insert` is not yet implemented"); - ret.write_cvalue(fx, val); + ret.write_cvalue(fx, base); + let ret_lane = ret.place_field(fx, mir::Field::new(idx.try_into().unwrap())); + ret_lane.write_cvalue(fx, val); }; simd_extract, (c v, o idx) { @@ -233,5 +230,12 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( validate_simd_type!(fx, intrinsic, span, x.layout().ty); simd_flt_binop!(fx, fmax(x, y) -> ret); }; + + // simd_fabs + // simd_saturating_add + // simd_bitmask + // simd_select + // simd_reduce_add_{,un}ordered + // simd_rem } } From 9b9a2e4f9132a0d32c6c0f09c8b6f9c78377aff6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 21 Jul 2020 00:22:53 +0200 Subject: [PATCH 1420/1566] Update README.md for #1068 --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index 3639b0e7d469b..0bbd771a727a8 100644 --- a/Readme.md +++ b/Readme.md @@ -75,7 +75,6 @@ function jit_calc() { ## Not yet supported * Good non-rust abi support ([several problems](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10)) - * Proc macros * Inline assembly ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1041) * On Linux there is support for invoking an external assembler for `global_asm!` and `asm!`. `llvm_asm!` will remain unimplemented forever. `asm!` doesn't yet support reg classes. You From 1ffc3079b036ffb115a37b7ac90f9013db607f74 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 23 Jul 2020 11:42:44 +0200 Subject: [PATCH 1421/1566] Rustup to rustc 1.47.0-nightly (bbebe7351 2020-07-22) --- build_sysroot/Cargo.lock | 93 +++++++++++++++++++++++++++------------- rust-toolchain | 2 +- src/abi/mod.rs | 4 +- src/constant.rs | 2 +- 4 files changed, 68 insertions(+), 33 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 2975e8acf6980..0cf603a14a33b 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -1,5 +1,27 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "addr2line" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +dependencies = [ + "compiler_builtins", + "gimli", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + [[package]] name = "alloc" version = "0.0.0" @@ -23,32 +45,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" -[[package]] -name = "backtrace" -version = "0.3.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" -dependencies = [ - "backtrace-sys", - "cfg-if", - "compiler_builtins", - "libc", - "rustc-demangle", - "rustc-std-workspace-core", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" -dependencies = [ - "cc", - "compiler_builtins", - "libc", - "rustc-std-workspace-core", -] - [[package]] name = "cc" version = "1.0.58" @@ -110,6 +106,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + [[package]] name = "hashbrown" version = "0.6.3" @@ -135,10 +142,33 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.72" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" +checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" dependencies = [ + "adler", + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "object" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", "rustc-std-workspace-core", ] @@ -146,6 +176,7 @@ dependencies = [ name = "panic_abort" version = "0.0.0" dependencies = [ + "cfg-if", "compiler_builtins", "core", "libc", @@ -205,8 +236,8 @@ dependencies = [ name = "std" version = "0.0.0" dependencies = [ + "addr2line", "alloc", - "backtrace", "cfg-if", "compiler_builtins", "core", @@ -215,8 +246,11 @@ dependencies = [ "hashbrown", "hermit-abi", "libc", + "miniz_oxide", + "object", "panic_abort", "panic_unwind", + "rustc-demangle", "unwind", "wasi", ] @@ -245,6 +279,7 @@ dependencies = [ name = "test" version = "0.0.0" dependencies = [ + "cfg-if", "core", "getopts", "libc", diff --git a/rust-toolchain b/rust-toolchain index 1903f2c25cde3..3e0f3c6663286 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-07-17 +nightly-2020-07-23 diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 0a6d54c73b3e4..cbbdb1fab0b11 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -15,7 +15,7 @@ pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return}; // Copied from https://github.com/rust-lang/rust/blob/b2c1a606feb1fbdb0ac0acba76f881ef172ed474/src/librustc_middle/ty/layout.rs#L2287 pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { - let ty = instance.monomorphic_ty(tcx); + let ty = instance.ty(tcx, ParamEnv::reveal_all()); match ty.kind { ty::FnDef(..) | // Shims currently have type FnPtr. Not sure this should remain. @@ -660,7 +660,7 @@ pub(crate) fn codegen_drop<'tcx>( if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything } else { - let drop_fn_ty = drop_fn.monomorphic_ty(fx.tcx); + let drop_fn_ty = drop_fn.ty(fx.tcx, ParamEnv::reveal_all()); let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), &drop_fn_ty.fn_sig(fx.tcx), diff --git a/src/constant.rs b/src/constant.rs index 139dcb5988f30..82d50a1e444a3 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -230,7 +230,7 @@ fn data_id_for_static( ) -> DataId { let instance = Instance::mono(tcx, def_id); let symbol_name = tcx.symbol_name(instance).name; - let ty = instance.monomorphic_ty(tcx); + let ty = instance.ty(tcx, ParamEnv::reveal_all()); let is_mutable = if tcx.is_mutable_static(def_id) { true } else { From 3f2589acd949622704cb10a026ab1da4e37c9ba4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 23 Jul 2020 12:37:03 +0200 Subject: [PATCH 1422/1566] Fix multiple inline asm blocks in the same function --- src/base.rs | 2 ++ src/common.rs | 2 ++ src/inline_asm.rs | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index f7fdea6514020..57396004c12d3 100644 --- a/src/base.rs +++ b/src/base.rs @@ -53,6 +53,8 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( vtables: &mut cx.vtables, source_info_set: indexmap::IndexSet::new(), next_ssa_var: 0, + + inline_asm_index: 0, }; let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()); diff --git a/src/common.rs b/src/common.rs index c8fcbbe1d37fe..39a918b60f30f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -278,6 +278,8 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { /// This should only be accessed by `CPlace::new_var`. pub(crate) next_ssa_var: u32, + + pub(crate) inline_asm_index: u32, } impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { diff --git a/src/inline_asm.rs b/src/inline_asm.rs index e2bbdd5ce9172..4c3fe87dae3dd 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -68,7 +68,9 @@ pub(crate) fn codegen_inline_asm<'tcx>( } } - let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, /*FIXME*/0); + let inline_asm_index = fx.inline_asm_index; + fx.inline_asm_index += 1; + let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, inline_asm_index); let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); fx.global_asm.push_str(&generated_asm); From 95511cb3eebec837a5c3efa3c87c1fc70dc0c1ba Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 23 Jul 2020 12:37:27 +0200 Subject: [PATCH 1423/1566] Add unaligned_volatile_{load,store} intrinsics --- src/intrinsics/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index d93da0fb0873a..ae2fe30989ad3 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -823,17 +823,19 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( } }; - volatile_load, (c ptr) { + volatile_load | unaligned_volatile_load, (c ptr) { // Cranelift treats loads as volatile by default // FIXME ignore during stack2reg optimization + // FIXME correctly handle unaligned_volatile_load let inner_layout = fx.layout_of(ptr.layout().ty.builtin_deref(true).unwrap().ty); let val = CValue::by_ref(Pointer::new(ptr.load_scalar(fx)), inner_layout); ret.write_cvalue(fx, val); }; - volatile_store, (v ptr, c val) { + volatile_store | unaligned_volatile_store, (v ptr, c val) { // Cranelift treats stores as volatile by default // FIXME ignore during stack2reg optimization + // FIXME correctly handle unaligned_volatile_store let dest = CPlace::for_ptr(Pointer::new(ptr), val.layout()); dest.write_cvalue(fx, val); }; From 1b8df386aa72bc3dacb803f7d4deb4eadd63b56f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 23 Jul 2020 18:07:38 +0200 Subject: [PATCH 1424/1566] Fix -Zpolymorphize --- src/abi/mod.rs | 74 +++++++++++++++++++++++++----------------------- src/base.rs | 9 +++--- src/common.rs | 2 +- src/constant.rs | 2 +- src/main_shim.rs | 7 +++-- src/vtable.rs | 4 +-- 6 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index cbbdb1fab0b11..fcf05be865399 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -13,14 +13,26 @@ use crate::prelude::*; pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return}; -// Copied from https://github.com/rust-lang/rust/blob/b2c1a606feb1fbdb0ac0acba76f881ef172ed474/src/librustc_middle/ty/layout.rs#L2287 +// Copied from https://github.com/rust-lang/rust/blob/f52c72948aa1dd718cc1f168d21c91c584c0a662/src/librustc_middle/ty/layout.rs#L2301 pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { - let ty = instance.ty(tcx, ParamEnv::reveal_all()); + use rustc_middle::ty::subst::Subst; + + // FIXME(davidtwco,eddyb): A `ParamEnv` should be passed through to this function. + let ty = instance.ty(tcx, ty::ParamEnv::reveal_all()); match ty.kind { - ty::FnDef(..) | - // Shims currently have type FnPtr. Not sure this should remain. - ty::FnPtr(_) => { - let mut sig = ty.fn_sig(tcx); + ty::FnDef(..) => { + // HACK(davidtwco,eddyb): This is a workaround for polymorphization considering + // parameters unused if they show up in the signature, but not in the `mir::Body` + // (i.e. due to being inside a projection that got normalized, see + // `src/test/ui/polymorphization/normalized_sig_types.rs`), and codegen not keeping + // track of a polymorphization `ParamEnv` to allow normalizing later. + let mut sig = match ty.kind { + ty::FnDef(def_id, substs) => tcx + .normalize_erasing_regions(tcx.param_env(def_id), tcx.fn_sig(def_id)) + .subst(tcx, substs), + _ => unreachable!(), + }; + if let ty::InstanceDef::VtableShim(..) = instance.def { // Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`. sig = sig.map_bound(|mut sig| { @@ -36,13 +48,15 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx let sig = substs.as_closure().sig(); let env_ty = tcx.closure_env_ty(def_id, substs).unwrap(); - sig.map_bound(|sig| tcx.mk_fn_sig( - std::iter::once(env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), - sig.output(), - sig.c_variadic, - sig.unsafety, - sig.abi - )) + sig.map_bound(|sig| { + tcx.mk_fn_sig( + std::iter::once(env_ty.skip_binder()).chain(sig.inputs().iter().cloned()), + sig.output(), + sig.c_variadic, + sig.unsafety, + sig.abi, + ) + }) } ty::Generator(_, substs, _) => { let sig = substs.as_generator().poly_sig(); @@ -50,18 +64,16 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty); - let pin_did = tcx.lang_items().pin_type().unwrap(); + let pin_did = tcx.require_lang_item(rustc_hir::LangItem::PinTypeLangItem, None); let pin_adt_ref = tcx.adt_def(pin_did); let pin_substs = tcx.intern_substs(&[env_ty.into()]); let env_ty = tcx.mk_adt(pin_adt_ref, pin_substs); sig.map_bound(|sig| { - let state_did = tcx.lang_items().gen_state().unwrap(); + let state_did = tcx.require_lang_item(rustc_hir::LangItem::GeneratorStateLangItem, None); let state_adt_ref = tcx.adt_def(state_did); - let state_substs = tcx.intern_substs(&[ - sig.yield_ty.into(), - sig.return_ty.into(), - ]); + let state_substs = + tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); tcx.mk_fn_sig( @@ -69,11 +81,11 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx &ret_ty, false, rustc_hir::Unsafety::Normal, - rustc_target::spec::abi::Abi::Rust + rustc_target::spec::abi::Abi::Rust, ) }) } - _ => bug!("unexpected type {:?} in Instance::fn_sig", ty) + _ => bug!("unexpected type {:?} in Instance::fn_sig", ty), } } @@ -464,7 +476,8 @@ pub(crate) fn codegen_terminator_call<'tcx>( 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() - .unwrap(); + .unwrap() + .polymorphize(fx.tcx); if fx.tcx.symbol_name(instance).name.starts_with("llvm.") { crate::intrinsics::codegen_llvm_intrinsic_call( @@ -655,7 +668,7 @@ pub(crate) fn codegen_drop<'tcx>( drop_place: CPlace<'tcx>, ) { let ty = drop_place.layout().ty; - let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty); + let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty).polymorphize(fx.tcx); if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything @@ -685,16 +698,7 @@ pub(crate) fn codegen_drop<'tcx>( fx.bcx.ins().call_indirect(sig, drop_fn, &[ptr]); } _ => { - let instance = match drop_fn_ty.kind { - ty::FnDef(def_id, substs) => { - Instance::resolve(fx.tcx, ParamEnv::reveal_all(), def_id, substs) - .unwrap() - .unwrap() - } - _ => unreachable!("{:?}", drop_fn_ty), - }; - - assert!(!matches!(instance.def, InstanceDef::Virtual(_, _))); + assert!(!matches!(drop_fn.def, InstanceDef::Virtual(_, _))); let arg_place = CPlace::new_stack_slot( fx, @@ -712,13 +716,13 @@ pub(crate) fn codegen_drop<'tcx>( let mut call_args: Vec = arg_value.into_iter().collect::>(); - if instance.def.requires_caller_location(fx.tcx) { + if drop_fn.def.requires_caller_location(fx.tcx) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); } - let func_ref = fx.get_function_ref(instance); + let func_ref = fx.get_function_ref(drop_fn); fx.bcx.ins().call(func_ref, &call_args); } } diff --git a/src/base.rs b/src/base.rs index 57396004c12d3..cd8152066fa55 100644 --- a/src/base.rs +++ b/src/base.rs @@ -267,7 +267,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) }); - let instance = Instance::mono(fx.tcx, def_id); + let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); let symbol_name = fx.tcx.symbol_name(instance).name; fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); @@ -469,7 +469,8 @@ fn trans_stmt<'tcx>( ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( Instance::resolve_for_fn_ptr(fx.tcx, ParamEnv::reveal_all(), def_id, substs) - .unwrap(), + .unwrap() + .polymorphize(fx.tcx), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, to_layout)); @@ -580,7 +581,7 @@ fn trans_stmt<'tcx>( def_id, substs, ty::ClosureKind::FnOnce, - ); + ).polymorphize(fx.tcx); let func_ref = fx.get_function_ref(instance); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); @@ -641,7 +642,7 @@ fn trans_stmt<'tcx>( .fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); } }; - let instance = ty::Instance::mono(fx.tcx, def_id); + let instance = ty::Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); let func_ref = fx.get_function_ref(instance); let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); let ptr = fx.bcx.inst_results(call)[0]; diff --git a/src/common.rs b/src/common.rs index 39a918b60f30f..c807bde15c30c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -287,7 +287,7 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { type TyAndLayout = TyAndLayout<'tcx>; fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { - assert!(!ty.needs_subst()); + assert!(!ty.still_further_specializable()); self.tcx .layout_of(ParamEnv::reveal_all().and(&ty)) .unwrap_or_else(|e| { diff --git a/src/constant.rs b/src/constant.rs index 82d50a1e444a3..e3d96528972a2 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -228,7 +228,7 @@ fn data_id_for_static( def_id: DefId, linkage: Linkage, ) -> DataId { - let instance = Instance::mono(tcx, def_id); + let instance = Instance::mono(tcx, def_id).polymorphize(tcx); let symbol_name = tcx.symbol_name(instance).name; let ty = instance.ty(tcx, ParamEnv::reveal_all()); let is_mutable = if tcx.is_mutable_static(def_id) { diff --git a/src/main_shim.rs b/src/main_shim.rs index 98148355b271b..a256446df93c9 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -21,7 +21,7 @@ pub(crate) fn maybe_create_entry_wrapper( None => return, }; - let instance = Instance::mono(tcx, main_def_id); + let instance = Instance::mono(tcx, main_def_id).polymorphize(tcx); if module.get_name(&*tcx.symbol_name(instance).name).is_none() { return; } @@ -58,7 +58,7 @@ pub(crate) fn maybe_create_entry_wrapper( .declare_function("main", Linkage::Export, &cmain_sig) .unwrap(); - let instance = Instance::mono(tcx, rust_main_def_id); + let instance = Instance::mono(tcx, rust_main_def_id).polymorphize(tcx); let (main_name, main_sig) = get_function_name_and_sig(tcx, m.isa().triple(), instance, false); @@ -90,7 +90,8 @@ pub(crate) fn maybe_create_entry_wrapper( tcx.intern_substs(&[main_ret_ty.into()]), ) .unwrap() - .unwrap(); + .unwrap() + .polymorphize(tcx); let start_func_id = import_function(tcx, m, start_instance); let main_val = bcx diff --git a/src/vtable.rs b/src/vtable.rs index c0cb70f3ff646..601c37d82c885 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -93,7 +93,7 @@ fn build_vtable<'tcx>( let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, layout.ty)); + import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.tcx)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -109,7 +109,7 @@ fn build_vtable<'tcx>( Some(import_function( tcx, fx.module, - Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap(), + Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.tcx), )) }) }); From 66343bf4fc986332dc355dc922a7d68f84e5fd97 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 24 Jul 2020 14:21:31 +0200 Subject: [PATCH 1425/1566] Default cargo.sh to release build of cg_clif --- Readme.md | 4 ++-- cargo.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 0bbd771a727a8..2448505825015 100644 --- a/Readme.md +++ b/Readme.md @@ -24,12 +24,12 @@ Assuming `$cg_clif_dir` is the directory you cloned this repo into and you follo In the directory with your project (where you can do the usual `cargo build`), run: ```bash -$ CHANNEL="release" $cg_clif_dir/cargo.sh run +$ $cg_clif_dir/cargo.sh run ``` This should build and run your project with rustc_codegen_cranelift instead of the usual LLVM backend. -If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. +If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should set `CHANNEL="debug"`. ### Rustc diff --git a/cargo.sh b/cargo.sh index 5ee21f467e215..d5be7773d342b 100755 --- a/cargo.sh +++ b/cargo.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ -z $CHANNEL ]; then -export CHANNEL='debug' +export CHANNEL='release' fi pushd $(dirname "$0") >/dev/null From abc99c62595831127e8ac4dfd6ccacd7ccbf9942 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 27 Mar 2020 20:55:54 +0100 Subject: [PATCH 1426/1566] Allow storing SIMD vectors in SSA values --- src/common.rs | 12 ++++++++++++ src/lib.rs | 9 ++++++--- src/pretty_clif.rs | 3 ++- src/value_and_place.rs | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/common.rs b/src/common.rs index c807bde15c30c..166486c49a178 100644 --- a/src/common.rs +++ b/src/common.rs @@ -62,6 +62,18 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { + let (element, count) = match &tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().abi { + Abi::Vector { element, count } => (element.clone(), *count), + _ => unreachable!(), + }; + + match scalar_to_clif_type(tcx, element).by(u16::try_from(count).unwrap()) { + // Cranelift currently only implements icmp for 128bit vectors. + Some(vector_ty) if vector_ty.bits() == 128 => vector_ty, + _ => return None, + } + } ty::Param(_) => bug!("ty param {:?}", ty), _ => return None, }) diff --git a/src/lib.rs b/src/lib.rs index 1096dbd227d66..0376672fba7ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -299,6 +299,8 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box Box( let target_triple = crate::target_triple(tcx.sess); writeln!(file, "test compile").unwrap(); writeln!(file, "set is_pic").unwrap(); - writeln!(file, "target {}", target_triple).unwrap(); + writeln!(file, "set enable_simd").unwrap(); + writeln!(file, "target {} haswell", target_triple).unwrap(); writeln!(file, "").unwrap(); file.write(clif.as_bytes()).unwrap(); } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index c9516a98bfe44..477a417639e9b 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -589,6 +589,8 @@ impl<'tcx> CPlace<'tcx> { fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, ) -> CPlace<'tcx> { + // FIXME handle simd values + let layout = self.layout(); if let CPlaceInner::VarPair(local, var1, var2) = self.inner { let layout = layout.field(&*fx, field.index()); From 08fc673190ef43b111a6fea2fadf7de25bf7f282 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Mar 2020 15:21:58 +0100 Subject: [PATCH 1427/1566] Handle SIMD vectors in CPlace::place_field --- src/abi/comments.rs | 1 + src/debuginfo/mod.rs | 5 ++++ src/value_and_place.rs | 66 ++++++++++++++++++++++++++++++++---------- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 7c4d7b12f6e99..357c28c832a95 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -82,6 +82,7 @@ pub(super) fn add_local_place_comments<'tcx>( assert_eq!(local, place_local); ("ssa", Cow::Owned(format!(",var=({}, {})", var1.index(), var2.index()))) } + CPlaceInner::VarLane(_local, _var, _lane) => unreachable!(), CPlaceInner::Addr(ptr, meta) => { let meta = if let Some(meta) = meta { Cow::Owned(format!(",meta={}", meta)) diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 37dc9f4e3c5bb..2c92fd0e47cc3 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -411,6 +411,11 @@ fn place_location<'tcx>( AttributeValue::Exprloc(Expression::new()) } + CPlaceInner::VarLane(_, _, _) => { + // FIXME implement this + + AttributeValue::Exprloc(Expression::new()) + } CPlaceInner::Addr(_, _) => { // FIXME implement this (used by arguments and returns) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 477a417639e9b..d0e8a4b0c9f24 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -272,6 +272,7 @@ pub(crate) struct CPlace<'tcx> { pub(crate) enum CPlaceInner { Var(Local, Variable), VarPair(Local, Variable, Variable), + VarLane(Local, Variable, u8), Addr(Pointer, Option), } @@ -374,6 +375,12 @@ impl<'tcx> CPlace<'tcx> { fx.bcx.set_val_label(val2, cranelift_codegen::ir::ValueLabel::new(var2.index())); CValue::by_val_pair(val1, val2, layout) } + CPlaceInner::VarLane(_local, var, lane) => { + let val = fx.bcx.use_var(var); + fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::new(var.index())); + let val = fx.bcx.ins().extractlane(val, lane); + CValue::by_val(val, layout) + } CPlaceInner::Addr(ptr, extra) => { if let Some(extra) = extra { CValue::by_ref_unsized(ptr, extra, layout) @@ -395,7 +402,8 @@ impl<'tcx> CPlace<'tcx> { match self.inner { CPlaceInner::Addr(ptr, extra) => (ptr, extra), CPlaceInner::Var(_, _) - | CPlaceInner::VarPair(_, _, _) => bug!("Expected CPlace::Addr, found {:?}", self), + | CPlaceInner::VarPair(_, _, _) + | CPlaceInner::VarLane(_, _, _) => bug!("Expected CPlace::Addr, found {:?}", self), } } @@ -527,6 +535,22 @@ impl<'tcx> CPlace<'tcx> { transmute_value(fx, var2, data2, dst_ty2); return; } + CPlaceInner::VarLane(_local, var, lane) => { + let data = from.load_scalar(fx); + + // First get the old vector + let vector = fx.bcx.use_var(var); + fx.bcx.set_val_label(vector, cranelift_codegen::ir::ValueLabel::new(var.index())); + + // Next insert the written lane into the vector + let vector = fx.bcx.ins().insertlane(vector, data, lane); + + // Finally write the new vector + fx.bcx.set_val_label(vector, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx.def_var(var, vector); + + return; + } CPlaceInner::Addr(ptr, None) => { if dst_layout.size == Size::ZERO || dst_layout.abi == Abi::Uninhabited { return; @@ -589,23 +613,33 @@ impl<'tcx> CPlace<'tcx> { fx: &mut FunctionCx<'_, 'tcx, impl Backend>, field: mir::Field, ) -> CPlace<'tcx> { - // FIXME handle simd values - let layout = self.layout(); - if let CPlaceInner::VarPair(local, var1, var2) = self.inner { - let layout = layout.field(&*fx, field.index()); - - match field.as_u32() { - 0 => return CPlace { - inner: CPlaceInner::Var(local, var1), - layout, - }, - 1 => return CPlace { - inner: CPlaceInner::Var(local, var2), - layout, - }, - _ => unreachable!("field should be 0 or 1"), + + match self.inner { + CPlaceInner::Var(local, var) => { + if let Abi::Vector { .. } = layout.abi { + return CPlace { + inner: CPlaceInner::VarLane(local, var, field.as_u32().try_into().unwrap()), + layout: layout.field(fx, field.as_u32().try_into().unwrap()), + }; + } + } + CPlaceInner::VarPair(local, var1, var2) => { + let layout = layout.field(&*fx, field.index()); + + match field.as_u32() { + 0 => return CPlace { + inner: CPlaceInner::Var(local, var1), + layout, + }, + 1 => return CPlace { + inner: CPlaceInner::Var(local, var2), + layout, + }, + _ => unreachable!("field should be 0 or 1"), + } } + _ => {} } let (base, extra) = self.to_ptr_maybe_unsized(); From 67028cee5177aa5e5f9300114c9a8449258adb3a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Mar 2020 15:33:50 +0100 Subject: [PATCH 1428/1566] Use PassMode::ByVal for Abi::Vector --- src/abi/pass_mode.rs | 8 +++++++- src/intrinsics/mod.rs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 390637e8e440e..02604a3757201 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -100,7 +100,13 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) } // FIXME implement Vector Abi in a cg_llvm compatible way - Abi::Vector { .. } => PassMode::ByRef { size: Some(layout.size) }, + Abi::Vector { .. } => { + if let Some(vector_ty) = crate::intrinsics::clif_vector_type(tcx, layout) { + PassMode::ByVal(vector_ty) + } else { + PassMode::ByRef { size: Some(layout.size) } + } + } Abi::Aggregate { sized: true } => PassMode::ByRef { size: Some(layout.size) }, Abi::Aggregate { sized: false } => PassMode::ByRef { size: None }, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index ae2fe30989ad3..ea7326edc04f8 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -175,7 +175,7 @@ fn lane_type_and_count<'tcx>( (lane_layout, lane_count) } -fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Option { +pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Option { let (element, count) = match &layout.abi { Abi::Vector { element, count } => (element.clone(), *count), _ => unreachable!(), From e8f1c5c53ab10a72f17ca0816b5890377ba5fc9c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 29 Mar 2020 12:02:00 +0200 Subject: [PATCH 1429/1566] Don't forbid i64x2 as simd type --- src/intrinsics/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index ea7326edc04f8..546864fc47752 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -182,10 +182,8 @@ pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx }; match scalar_to_clif_type(tcx, element).by(u16::try_from(count).unwrap()) { - // Cranelift currently only implements icmp for 128bit vectors. While 64bit lanes are - // supported, this needs either the `use_sse41_simd` or `use_sse42_simd` target flag - // to be enabled. - Some(vector_ty) if vector_ty.bits() == 128 && vector_ty.lane_type() != types::I64 => Some(vector_ty), + // Cranelift currently only implements icmp for 128bit vectors. + Some(vector_ty) if vector_ty.bits() == 128 => Some(vector_ty), _ => None, } } From c1efc33941c53720f31a2667176e82deddad6a51 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jul 2020 13:17:49 +0200 Subject: [PATCH 1430/1566] Fix panic --- src/common.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common.rs b/src/common.rs index 166486c49a178..4213158108863 100644 --- a/src/common.rs +++ b/src/common.rs @@ -83,10 +83,12 @@ fn clif_pair_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<(type Some(match ty.kind { ty::Tuple(substs) if substs.len() == 2 => { let mut types = substs.types(); - ( - clif_type_from_ty(tcx, types.next().unwrap())?, - clif_type_from_ty(tcx, types.next().unwrap())?, - ) + let a = clif_type_from_ty(tcx, types.next().unwrap())?; + let b = clif_type_from_ty(tcx, types.next().unwrap())?; + if a.is_vector() || b.is_vector() { + return None; + } + (a, b) } ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => { if has_ptr_meta(tcx, pointee_ty) { From e02ffdf7956b3a36b2e45ada9e8dc2e3ab302c4f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 25 Jul 2020 16:15:42 +0200 Subject: [PATCH 1431/1566] Use nehalem instead of haswell as target cpu --- src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0376672fba7ae..38ff7e90b3b11 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -320,7 +320,9 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box Date: Thu, 30 Jul 2020 14:58:27 +0200 Subject: [PATCH 1432/1566] Rustup to rustc 1.47.0-nightly (db0492ace 2020-07-29) --- build_sysroot/Cargo.lock | 87 ++++++------------- build_sysroot/Cargo.toml | 14 +-- build_sysroot/alloc_system/Cargo.toml | 2 +- build_sysroot/prepare_sysroot_src.sh | 4 +- patches/0016-Disable-cpuid-intrinsic.patch | 8 +- ...022-core-Disable-not-compiling-tests.patch | 48 +++++----- patches/0023-core-Ignore-failing-tests.patch | 20 ++--- ...-of-extern_weak-in-thread_local_dtor.patch | 8 +- rust-toolchain | 2 +- 9 files changed, 80 insertions(+), 113 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 0cf603a14a33b..f23e44f8d1878 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -1,27 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "addr2line" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" -dependencies = [ - "compiler_builtins", - "gimli", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-core", -] - [[package]] name = "alloc" version = "0.0.0" @@ -45,6 +23,32 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +[[package]] +name = "backtrace" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" +dependencies = [ + "backtrace-sys", + "cfg-if", + "compiler_builtins", + "libc", + "rustc-demangle", + "rustc-std-workspace-core", +] + +[[package]] +name = "backtrace-sys" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" +dependencies = [ + "cc", + "compiler_builtins", + "libc", + "rustc-std-workspace-core", +] + [[package]] name = "cc" version = "1.0.58" @@ -106,17 +110,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "gimli" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - [[package]] name = "hashbrown" version = "0.6.3" @@ -149,29 +142,6 @@ dependencies = [ "rustc-std-workspace-core", ] -[[package]] -name = "miniz_oxide" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" -dependencies = [ - "adler", - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - -[[package]] -name = "object" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - [[package]] name = "panic_abort" version = "0.0.0" @@ -236,8 +206,8 @@ dependencies = [ name = "std" version = "0.0.0" dependencies = [ - "addr2line", "alloc", + "backtrace", "cfg-if", "compiler_builtins", "core", @@ -246,11 +216,8 @@ dependencies = [ "hashbrown", "hermit-abi", "libc", - "miniz_oxide", - "object", "panic_abort", "panic_unwind", - "rustc-demangle", "unwind", "wasi", ] diff --git a/build_sysroot/Cargo.toml b/build_sysroot/Cargo.toml index 339e0d5fdc799..e562dedb5324b 100644 --- a/build_sysroot/Cargo.toml +++ b/build_sysroot/Cargo.toml @@ -4,18 +4,18 @@ name = "sysroot" version = "0.0.0" [dependencies] -core = { path = "./sysroot_src/src/libcore" } +core = { path = "./sysroot_src/library/core" } compiler_builtins = "0.1" -alloc = { path = "./sysroot_src/src/liballoc" } -std = { path = "./sysroot_src/src/libstd", features = ["panic_unwind", "backtrace"] } -test = { path = "./sysroot_src/src/libtest" } +alloc = { path = "./sysroot_src/library/alloc" } +std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] } +test = { path = "./sysroot_src/library/test" } alloc_system = { path = "./alloc_system" } [patch.crates-io] -rustc-std-workspace-core = { path = "./sysroot_src/src/tools/rustc-std-workspace-core" } -rustc-std-workspace-alloc = { path = "./sysroot_src/src/tools/rustc-std-workspace-alloc" } -rustc-std-workspace-std = { path = "./sysroot_src/src/tools/rustc-std-workspace-std" } +rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" } +rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" } [profile.dev] lto = "off" diff --git a/build_sysroot/alloc_system/Cargo.toml b/build_sysroot/alloc_system/Cargo.toml index 221faab32bd83..9fffca843006f 100644 --- a/build_sysroot/alloc_system/Cargo.toml +++ b/build_sysroot/alloc_system/Cargo.toml @@ -8,6 +8,6 @@ path = "lib.rs" test = false doc = false [dependencies] -core = { path = "../sysroot_src/src/libcore" } +core = { path = "../sysroot_src/library/core" } libc = { version = "0.2.43", features = ['rustc-dep-of-std'], default-features = false } compiler_builtins = "0.1" diff --git a/build_sysroot/prepare_sysroot_src.sh b/build_sysroot/prepare_sysroot_src.sh index 882454754ed82..14aa77478f54d 100755 --- a/build_sysroot/prepare_sysroot_src.sh +++ b/build_sysroot/prepare_sysroot_src.sh @@ -11,8 +11,8 @@ if [ ! -e $SRC_DIR ]; then fi rm -rf $DST_DIR -mkdir -p $DST_DIR/src -cp -r $SRC_DIR/src $DST_DIR/ +mkdir -p $DST_DIR/library +cp -r $SRC_DIR/library $DST_DIR/ pushd $DST_DIR echo "[GIT] init" diff --git a/patches/0016-Disable-cpuid-intrinsic.patch b/patches/0016-Disable-cpuid-intrinsic.patch index 0cccdb13ad6f9..c1d24c3c0c569 100644 --- a/patches/0016-Disable-cpuid-intrinsic.patch +++ b/patches/0016-Disable-cpuid-intrinsic.patch @@ -4,13 +4,13 @@ Date: Sat, 6 Apr 2019 12:16:21 +0200 Subject: [PATCH] Remove usage of unsized locals --- - src/stdarch/crates/core_arch/src/x86/cpuid.rs | 2 ++ + library/stdarch/crates/core_arch/src/x86/cpuid.rs | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) -diff --git a/src/stdarch/crates/core_arch/src/x86/cpuid.rs b/src/stdarch/crates/core_arch/src/x86/cpuid.rs +diff --git a/library/stdarch/crates/core_arch/src/x86/cpuid.rs b/library/stdarch/crates/core_arch/src/x86/cpuid.rs index f313c42..ff952bc 100644 ---- a/src/stdarch/crates/core_arch/src/x86/cpuid.rs -+++ b/src/stdarch/crates/core_arch/src/x86/cpuid.rs +--- a/library/stdarch/crates/core_arch/src/x86/cpuid.rs ++++ b/library/stdarch/crates/core_arch/src/x86/cpuid.rs @@ -84,6 +84,11 @@ pub unsafe fn __cpuid(leaf: u32) -> CpuidResult { /// Does the host support the `cpuid` instruction? #[inline] diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch index 282d476bd7504..213b7bb5f29d3 100644 --- a/patches/0022-core-Disable-not-compiling-tests.patch +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -4,20 +4,20 @@ Date: Sun, 24 Nov 2019 15:10:23 +0100 Subject: [PATCH] [core] Disable not compiling tests --- - src/libcore/tests/Cargo.toml | 8 ++++++++ - src/libcore/tests/num/flt2dec/mod.rs | 1 - - src/libcore/tests/num/int_macros.rs | 2 ++ - src/libcore/tests/num/uint_macros.rs | 2 ++ - src/libcore/tests/ptr.rs | 2 ++ - src/libcore/tests/slice.rs | 2 ++ + library/core/tests/Cargo.toml | 8 ++++++++ + library/core/tests/num/flt2dec/mod.rs | 1 - + library/core/tests/num/int_macros.rs | 2 ++ + library/core/tests/num/uint_macros.rs | 2 ++ + library/core/tests/ptr.rs | 2 ++ + library/core/tests/slice.rs | 2 ++ 6 files changed, 16 insertions(+), 1 deletion(-) - create mode 100644 src/libcore/tests/Cargo.toml + create mode 100644 library/core/tests/Cargo.toml -diff --git a/src/libcore/tests/Cargo.toml b/src/libcore/tests/Cargo.toml +diff --git a/library/core/tests/Cargo.toml b/library/core/tests/Cargo.toml new file mode 100644 index 0000000..46fd999 --- /dev/null -+++ b/src/libcore/tests/Cargo.toml ++++ b/library/core/tests/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "core" @@ -27,10 +27,10 @@ index 0000000..46fd999 +[lib] +name = "coretests" +path = "lib.rs" -diff --git a/src/libcore/tests/num/flt2dec/mod.rs b/src/libcore/tests/num/flt2dec/mod.rs +diff --git a/library/core/tests/num/flt2dec/mod.rs b/library/core/tests/num/flt2dec/mod.rs index a35897e..f0bf645 100644 ---- a/src/libcore/tests/num/flt2dec/mod.rs -+++ b/src/libcore/tests/num/flt2dec/mod.rs +--- a/library/core/tests/num/flt2dec/mod.rs ++++ b/library/core/tests/num/flt2dec/mod.rs @@ -13,7 +13,6 @@ mod strategy { mod dragon; mod grisu; @@ -39,10 +39,10 @@ index a35897e..f0bf645 100644 pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { -diff --git a/src/libcore/tests/num/int_macros.rs b/src/libcore/tests/num/int_macros.rs +diff --git a/library/core/tests/num/int_macros.rs b/library/core/tests/num/int_macros.rs index 0475aeb..9558198 100644 ---- a/src/libcore/tests/num/int_macros.rs -+++ b/src/libcore/tests/num/int_macros.rs +--- a/library/core/tests/num/int_macros.rs ++++ b/library/core/tests/num/int_macros.rs @@ -88,6 +88,7 @@ mod tests { assert_eq!(x.trailing_ones(), 0); } @@ -59,10 +59,10 @@ index 0475aeb..9558198 100644 #[test] fn test_swap_bytes() { -diff --git a/src/libcore/tests/num/uint_macros.rs b/src/libcore/tests/num/uint_macros.rs +diff --git a/library/core/tests/num/uint_macros.rs b/library/core/tests/num/uint_macros.rs index 04ed14f..a6e372e 100644 ---- a/src/libcore/tests/num/uint_macros.rs -+++ b/src/libcore/tests/num/uint_macros.rs +--- a/library/core/tests/num/uint_macros.rs ++++ b/library/core/tests/num/uint_macros.rs @@ -52,6 +52,7 @@ mod tests { assert_eq!(x.trailing_ones(), 0); } @@ -79,10 +79,10 @@ index 04ed14f..a6e372e 100644 #[test] fn test_swap_bytes() { -diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs +diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index 1a6be3a..42dbd59 100644 ---- a/src/libcore/tests/ptr.rs -+++ b/src/libcore/tests/ptr.rs +--- a/library/core/tests/ptr.rs ++++ b/library/core/tests/ptr.rs @@ -250,6 +250,7 @@ fn test_unsized_nonnull() { assert!(ys == zs); } @@ -99,10 +99,10 @@ index 1a6be3a..42dbd59 100644 #[test] #[cfg_attr(miri, ignore)] // Miri does not compute a maximal `mid` for `align_offset` -diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs +diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 6609bc3..241b497 100644 ---- a/src/libcore/tests/slice.rs -+++ b/src/libcore/tests/slice.rs +--- a/library/core/tests/slice.rs ++++ b/library/core/tests/slice.rs @@ -1209,6 +1209,7 @@ fn brute_force_rotate_test_1() { } } diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index e1d0cdcd42b46..8104b8d767a11 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -4,16 +4,16 @@ Date: Sun, 24 Nov 2019 15:34:06 +0100 Subject: [PATCH] [core] Ignore failing tests --- - src/libcore/tests/iter.rs | 4 ++++ - src/libcore/tests/num/bignum.rs | 10 ++++++++++ - src/libcore/tests/num/mod.rs | 5 +++-- - src/libcore/tests/time.rs | 1 + + library/core/tests/iter.rs | 4 ++++ + library/core/tests/num/bignum.rs | 10 ++++++++++ + library/core/tests/num/mod.rs | 5 +++-- + library/core/tests/time.rs | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) -diff --git a/src/libcore/tests/array.rs b/src/libcore/tests/array.rs +diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs index 4bc44e9..8e3c7a4 100644 ---- a/src/libcore/tests/array.rs -+++ b/src/libcore/tests/array.rs +--- a/library/core/tests/array.rs ++++ b/library/core/tests/array.rs @@ -242,6 +242,7 @@ fn iterator_drops() { assert_eq!(i.get(), 5); } @@ -30,10 +30,10 @@ index 4bc44e9..8e3c7a4 100644 #[test] fn empty_array_is_always_default() { -diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs +diff --git a/library/core/tests/num/mod.rs b/library/core/tests/num/mod.rs index a17c094..5bb11d2 100644 ---- a/src/libcore/tests/num/mod.rs -+++ b/src/libcore/tests/num/mod.rs +--- a/library/core/tests/num/mod.rs ++++ b/library/core/tests/num/mod.rs @@ -651,11 +651,12 @@ macro_rules! test_float { assert_eq!((9.0 as $fty).min($neginf), $neginf); assert_eq!(($neginf as $fty).min(-9.0), $neginf); diff --git a/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch b/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch index 0a25e6b3302d5..29b891c6eb5c6 100644 --- a/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch +++ b/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch @@ -4,13 +4,13 @@ Date: Fri, 10 Apr 2020 13:47:42 +0200 Subject: [PATCH] Remove usage of extern_weak in thread_local_dtor --- - src/libstd/sys/unix/thread_local_dtor.rs | 20 -------------------- + library/std/src/sys/unix/thread_local_dtor.rs | 20 -------------------- 1 files changed, 0 insertions(+), 20 deletions(-) -diff --git a/src/libstd/sys/unix/thread_local_dtor.rs b/src/libstd/sys/unix/thread_local_dtor.rs +diff --git a/library/std/src/sys/unix/thread_local_dtor.rs b/library/std/src/sys/unix/thread_local_dtor.rs index 8730b4d..8d6e3d5 100644 ---- a/src/libstd/sys/unix/thread_local_dtor.rs -+++ b/src/libstd/sys/unix/thread_local_dtor.rs +--- a/library/std/src/sys/unix/thread_local_dtor.rs ++++ b/library/std/src/sys/unix/thread_local_dtor.rs @@ -15,28 +15,8 @@ target_os = "emscripten" ))] diff --git a/rust-toolchain b/rust-toolchain index 3e0f3c6663286..3f271bd5c84e8 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-07-23 +nightly-2020-07-30 From b97a873c9b3a64a17706f085351a72700ccd6b52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Jul 2020 15:14:19 +0200 Subject: [PATCH 1433/1566] Fix test path --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 74ead626e692c..38d9d87138b38 100755 --- a/test.sh +++ b/test.sh @@ -89,7 +89,7 @@ else fi popd -pushd build_sysroot/sysroot_src/src/libcore/tests +pushd build_sysroot/sysroot_src/library/core/tests echo "[TEST] libcore" rm -r ./target || true ../../../../../cargo.sh test From 9f635de5c73209b635a53f2bcf9bf00c73de0678 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Jul 2020 16:37:31 +0200 Subject: [PATCH 1434/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a48e268c8ecb..e68792fb4d452 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" [[package]] name = "cranelift-entity" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" [[package]] name = "cranelift-frontend" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "anyhow", "cranelift-codegen", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#5c5a30f76c35e15697fc150fb00c4b86be621d66" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" dependencies = [ "cranelift-codegen", "cranelift-module", From c5899526e4a6244ca200900e3f825c72e8ad5559 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 30 Jul 2020 16:43:53 +0200 Subject: [PATCH 1435/1566] Update dependencies --- Cargo.lock | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e68792fb4d452..57ba07fa9ad0a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "anyhow" -version = "1.0.31" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" +checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" [[package]] name = "ar" @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480f641ccf0faf324e20c1d3e53d81b7484c698b42ea677f6907ae4db195371" +checksum = "6eab5ee3df98a279d9b316b1af6ac95422127b1290317e6d18c1743c99418b01" dependencies = [ "errno-dragonfly", "libc", @@ -191,20 +191,30 @@ dependencies = [ "indexmap", ] +[[package]] +name = "hashbrown" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +dependencies = [ + "autocfg", +] + [[package]] name = "indexmap" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" +checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" dependencies = [ "autocfg", + "hashbrown", ] [[package]] name = "libc" -version = "0.2.72" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" +checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" [[package]] name = "libloading" @@ -246,9 +256,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" dependencies = [ "unicode-xid", ] @@ -353,9 +363,9 @@ checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" [[package]] name = "syn" -version = "1.0.34" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b" +checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250" dependencies = [ "proc-macro2", "quote", From 50ecea0c18eb9fa572828217ce87315c9e5a5b80 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Tue, 4 Aug 2020 03:33:31 +0300 Subject: [PATCH 1436/1566] Remove cargo home perms workaround --- .github/workflows/main.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 29c848bdf9eff..a95d1929c9192 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,11 +16,6 @@ jobs: steps: - uses: actions/checkout@v2 - # https://github.com/actions/cache/issues/133 - - name: Fixup owner of ~/.cargo/ - # Don't remove the trailing /. It is necessary to follow the symlink. - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ - - name: Cache cargo installed crates uses: actions/cache@v1.1.2 with: From 3e4ddca409c0b01d2981fe9e5a15c03cd41f1b24 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 5 Aug 2020 13:55:27 +0200 Subject: [PATCH 1437/1566] Rustup to rustc 1.47.0-nightly (f9d422ea7 2020-08-04) --- build_sysroot/Cargo.lock | 91 +++++++++++++++++++---------- build_sysroot/alloc_system/lib.rs | 96 ------------------------------- rust-toolchain | 2 +- src/lib.rs | 1 - 4 files changed, 63 insertions(+), 127 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index f23e44f8d1878..53d5364b554cb 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -1,5 +1,27 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "addr2line" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +dependencies = [ + "compiler_builtins", + "gimli", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-core", +] + [[package]] name = "alloc" version = "0.0.0" @@ -23,32 +45,6 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" -[[package]] -name = "backtrace" -version = "0.3.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" -dependencies = [ - "backtrace-sys", - "cfg-if", - "compiler_builtins", - "libc", - "rustc-demangle", - "rustc-std-workspace-core", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" -dependencies = [ - "cc", - "compiler_builtins", - "libc", - "rustc-std-workspace-core", -] - [[package]] name = "cc" version = "1.0.58" @@ -110,6 +106,17 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + [[package]] name = "hashbrown" version = "0.6.3" @@ -135,13 +142,36 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.73" +version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" +checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" dependencies = [ "rustc-std-workspace-core", ] +[[package]] +name = "miniz_oxide" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +dependencies = [ + "adler", + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "object" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +dependencies = [ + "compiler_builtins", + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + [[package]] name = "panic_abort" version = "0.0.0" @@ -206,8 +236,8 @@ dependencies = [ name = "std" version = "0.0.0" dependencies = [ + "addr2line", "alloc", - "backtrace", "cfg-if", "compiler_builtins", "core", @@ -216,8 +246,11 @@ dependencies = [ "hashbrown", "hermit-abi", "libc", + "miniz_oxide", + "object", "panic_abort", "panic_unwind", + "rustc-demangle", "unwind", "wasi", ] diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index bb0ceb229f46f..e80a584e981a0 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -72,102 +72,6 @@ use core::intrinsics; /// independently of the standard library’s global allocator. #[stable(feature = "alloc_system_type", since = "1.28.0")] pub struct System; -#[unstable(feature = "allocator_api", issue = "32838")] -unsafe impl AllocRef for System { - #[inline] - fn alloc(&mut self, layout: Layout, init: AllocInit) -> Result { - unsafe { - let size = layout.size(); - if size == 0 { - Ok(MemoryBlock { ptr: layout.dangling(), size: 0 }) - } else { - let raw_ptr = match init { - AllocInit::Uninitialized => GlobalAlloc::alloc(self, layout), - AllocInit::Zeroed => GlobalAlloc::alloc_zeroed(self, layout), - }; - let ptr = NonNull::new(raw_ptr).ok_or(AllocErr)?; - Ok(MemoryBlock { ptr, size }) - } - } - } - - #[inline] - unsafe fn dealloc(&mut self, ptr: NonNull, layout: Layout) { - if layout.size() != 0 { - GlobalAlloc::dealloc(self, ptr.as_ptr(), layout) - } - } - - #[inline] - unsafe fn grow( - &mut self, - ptr: NonNull, - layout: Layout, - new_size: usize, - placement: ReallocPlacement, - init: AllocInit, - ) -> Result { - let size = layout.size(); - debug_assert!( - new_size >= size, - "`new_size` must be greater than or equal to `memory.size()`" - ); - - if size == new_size { - return Ok(MemoryBlock { ptr, size }); - } - - match placement { - ReallocPlacement::InPlace => Err(AllocErr), - ReallocPlacement::MayMove if layout.size() == 0 => { - let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); - self.alloc(new_layout, init) - } - ReallocPlacement::MayMove => { - // `realloc` probably checks for `new_size > size` or something similar. - intrinsics::assume(new_size > size); - let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); - let memory = - MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }; - init.init_offset(memory, size); - Ok(memory) - } - } - } - - #[inline] - unsafe fn shrink( - &mut self, - ptr: NonNull, - layout: Layout, - new_size: usize, - placement: ReallocPlacement, - ) -> Result { - let size = layout.size(); - debug_assert!( - new_size <= size, - "`new_size` must be smaller than or equal to `memory.size()`" - ); - - if size == new_size { - return Ok(MemoryBlock { ptr, size }); - } - - match placement { - ReallocPlacement::InPlace => Err(AllocErr), - ReallocPlacement::MayMove if new_size == 0 => { - self.dealloc(ptr, layout); - Ok(MemoryBlock { ptr: layout.dangling(), size: 0 }) - } - ReallocPlacement::MayMove => { - // `realloc` probably checks for `new_size < size` or something similar. - intrinsics::assume(new_size < size); - let ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size); - Ok(MemoryBlock { ptr: NonNull::new(ptr).ok_or(AllocErr)?, size: new_size }) - } - } - } -} #[cfg(any(windows, unix, target_os = "cloudabi", target_os = "redox"))] mod realloc_fallback { use core::alloc::{GlobalAlloc, Layout}; diff --git a/rust-toolchain b/rust-toolchain index 3f271bd5c84e8..d16b27f6dbd57 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-07-30 +nightly-2020-08-05 diff --git a/src/lib.rs b/src/lib.rs index 38ff7e90b3b11..d389248c0125a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ #![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds, never_type)] -#![allow(intra_doc_link_resolution_failure)] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] From da09c576e795c33623b84c74db5382395b030e11 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 5 Aug 2020 13:59:35 +0200 Subject: [PATCH 1438/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57ba07fa9ad0a..a64183ab6d0de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" [[package]] name = "cranelift-entity" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" [[package]] name = "cranelift-frontend" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "anyhow", "cranelift-codegen", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#79abcdb035769d1e34d6a4d5f81cbd5abd969695" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" dependencies = [ "cranelift-codegen", "cranelift-module", From 5afffb823c3e8af9b77c877af78cf3753d1e7072 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 5 Aug 2020 14:02:54 +0200 Subject: [PATCH 1439/1566] Update syn --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a64183ab6d0de..8e5f6c0f017ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,9 +363,9 @@ checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" [[package]] name = "syn" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250" +checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" dependencies = [ "proc-macro2", "quote", From 240e1785324ba33d3f116d0b733236d967888224 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Aug 2020 16:14:11 +0200 Subject: [PATCH 1440/1566] Don't panic on io errors Fixes #920 --- src/archive.rs | 23 ++++++++++++++++------- src/driver/aot.rs | 8 ++++++-- src/lib.rs | 2 +- src/pretty_clif.rs | 25 ++++++++++++------------- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 0e5820936bc59..0878e54545ed9 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -149,6 +149,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { Gnu(ar::GnuBuilder), } + let sess = self.config.sess; + let mut symbol_table = BTreeMap::new(); let mut entries = Vec::new(); @@ -169,10 +171,11 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let mut data = Vec::new(); entry.read_to_end(&mut data).unwrap(); data - } ArchiveEntry::File(file) => { - std::fs::read(file).unwrap() + std::fs::read(file).unwrap_or_else(|err| { + sess.fatal(&format!("error while reading object file during archive building: {}", err)); + }) } }; @@ -192,7 +195,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { if err == "Unknown file magic" { // Not an object file; skip it. } else { - self.config.sess.fatal(&format!("Error parsing `{}` during archive creation: {}", entry_name, err)); + sess.fatal(&format!("error parsing `{}` during archive creation: {}", entry_name, err)); } } } @@ -203,7 +206,9 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { let mut builder = if self.config.use_gnu_style_archive { BuilderKind::Gnu(ar::GnuBuilder::new( - File::create(&self.config.dst).unwrap(), + File::create(&self.config.dst).unwrap_or_else(|err| { + sess.fatal(&format!("error opening destination during archive building: {}", err)); + }), entries .iter() .map(|(name, _)| name.as_bytes().to_vec()) @@ -213,7 +218,9 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { ).unwrap()) } else { BuilderKind::Bsd(ar::Builder::new( - File::create(&self.config.dst).unwrap(), + File::create(&self.config.dst).unwrap_or_else(|err| { + sess.fatal(&format!("error opening destination during archive building: {}", err)); + }), symbol_table, ).unwrap()) }; @@ -260,8 +267,10 @@ impl<'a> ArArchiveBuilder<'a> { let mut i = 0; while let Some(entry) = archive.next_entry() { - let entry = entry.unwrap(); - let file_name = String::from_utf8(entry.header().identifier().to_vec()).unwrap(); + let entry = entry?; + let file_name = String::from_utf8(entry.header().identifier().to_vec()).map_err(|err| { + std::io::Error::new(std::io::ErrorKind::InvalidData, err) + })?; if !skip(&file_name) { self.entries.push(( file_name, diff --git a/src/driver/aot.rs b/src/driver/aot.rs index d6d62598efb03..9f6b0c5147576 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -54,7 +54,9 @@ fn emit_module( .output_filenames(LOCAL_CRATE) .temp_path(OutputType::Object, Some(&name)); let obj = product.emit(); - std::fs::write(&tmp_file, obj).unwrap(); + if let Err(err) = std::fs::write(&tmp_file, obj) { + tcx.sess.fatal(&format!("error writing object file: {}", err)); + } let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { None @@ -254,7 +256,9 @@ pub(super) fn run_aot( crate::metadata::write_metadata(tcx, object); }); - std::fs::write(&tmp_file, obj).unwrap(); + if let Err(err) = std::fs::write(&tmp_file, obj) { + tcx.sess.fatal(&format!("error writing metadata object file: {}", err)); + } (metadata_cgu_name, tmp_file) }); diff --git a/src/lib.rs b/src/lib.rs index d389248c0125a..bc0bae9c28dab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds, never_type)] +#![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds, never_type, try_blocks)] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 64346c423c8af..ef48a9f358ecc 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -243,19 +243,18 @@ pub(crate) fn write_clif_file<'tcx>( ) .unwrap(); - match ::std::fs::File::create(clif_file_name) { - Ok(mut file) => { - let target_triple = crate::target_triple(tcx.sess); - writeln!(file, "test compile").unwrap(); - writeln!(file, "set is_pic").unwrap(); - writeln!(file, "set enable_simd").unwrap(); - writeln!(file, "target {} haswell", target_triple).unwrap(); - writeln!(file, "").unwrap(); - file.write(clif.as_bytes()).unwrap(); - } - Err(e) => { - tcx.sess.warn(&format!("err opening clif file: {:?}", e)); - } + let res: std::io::Result<()> = try { + let mut file = std::fs::File::create(clif_file_name)?; + let target_triple = crate::target_triple(tcx.sess); + writeln!(file, "test compile")?; + writeln!(file, "set is_pic")?; + writeln!(file, "set enable_simd")?; + writeln!(file, "target {} haswell", target_triple)?; + writeln!(file, "")?; + file.write(clif.as_bytes())?; + }; + if let Err(err) = res { + tcx.sess.warn(&format!("err writing clif file: {}", err)); } } From fb0e5c62119debd0d7766f43cafa5b8d67bc5cb0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Aug 2020 16:17:34 +0200 Subject: [PATCH 1441/1566] Fix some warnings --- build_sysroot/alloc_system/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/build_sysroot/alloc_system/lib.rs b/build_sysroot/alloc_system/lib.rs index e80a584e981a0..ca145e4f2a520 100644 --- a/build_sysroot/alloc_system/lib.rs +++ b/build_sysroot/alloc_system/lib.rs @@ -42,9 +42,6 @@ const MIN_ALIGN: usize = 8; target_arch = "sparc64")))] #[allow(dead_code)] const MIN_ALIGN: usize = 16; -use core::alloc::*; -use core::ptr::NonNull; -use core::intrinsics; /// The default memory allocator provided by the operating system. /// From 8664ccc27f8be927fa029faf6f950239a6449d0c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Aug 2020 16:19:42 +0200 Subject: [PATCH 1442/1566] Remove ArchiveConfig --- src/archive.rs | 51 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/archive.rs b/src/archive.rs index 0878e54545ed9..a34ede57e7991 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -8,14 +8,6 @@ use rustc_codegen_ssa::METADATA_FILENAME; use object::{Object, SymbolKind}; -struct ArchiveConfig<'a> { - sess: &'a Session, - dst: PathBuf, - lib_search_paths: Vec, - use_gnu_style_archive: bool, - no_builtin_ranlib: bool, -} - #[derive(Debug)] enum ArchiveEntry { FromArchive { @@ -26,7 +18,12 @@ enum ArchiveEntry { } pub(crate) struct ArArchiveBuilder<'a> { - config: ArchiveConfig<'a>, + sess: &'a Session, + dst: PathBuf, + lib_search_paths: Vec, + use_gnu_style_archive: bool, + no_builtin_ranlib: bool, + src_archives: Vec<(PathBuf, ar::Archive)>, // Don't use `HashMap` here, as the order is important. `rust.metadata.bin` must always be at // the end of an archive for linkers to not get confused. @@ -37,14 +34,6 @@ pub(crate) struct ArArchiveBuilder<'a> { impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self { use rustc_codegen_ssa::back::link::archive_search_paths; - let config = ArchiveConfig { - sess, - dst: output.to_path_buf(), - lib_search_paths: archive_search_paths(sess), - use_gnu_style_archive: sess.target.target.options.archive_format == "gnu", - // FIXME fix builtin ranlib on macOS - no_builtin_ranlib: sess.target.target.options.is_like_osx, - }; let (src_archives, entries) = if let Some(input) = input { let mut archive = ar::Archive::new(File::open(input).unwrap()); @@ -69,7 +58,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { }; ArArchiveBuilder { - config, + sess, + dst: output.to_path_buf(), + lib_search_paths: archive_search_paths(sess), + use_gnu_style_archive: sess.target.target.options.archive_format == "gnu", + // FIXME fix builtin ranlib on macOS + no_builtin_ranlib: sess.target.target.options.is_like_osx, + src_archives, entries, update_symbols: false, @@ -97,7 +92,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } fn add_native_library(&mut self, name: rustc_span::symbol::Symbol) { - let location = find_library(name, &self.config.lib_search_paths, self.config.sess); + let location = find_library(name, &self.lib_search_paths, self.sess); self.add_archive(location.clone(), |_| false) .unwrap_or_else(|e| { panic!( @@ -149,7 +144,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { Gnu(ar::GnuBuilder), } - let sess = self.config.sess; + let sess = self.sess; let mut symbol_table = BTreeMap::new(); @@ -179,7 +174,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } }; - if !self.config.no_builtin_ranlib { + if !self.no_builtin_ranlib { match object::File::parse(&data) { Ok(object) => { symbol_table.insert(entry_name.as_bytes().to_vec(), object.symbols().filter_map(|(_index, symbol)| { @@ -204,9 +199,9 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { entries.push((entry_name, data)); } - let mut builder = if self.config.use_gnu_style_archive { + let mut builder = if self.use_gnu_style_archive { BuilderKind::Gnu(ar::GnuBuilder::new( - File::create(&self.config.dst).unwrap_or_else(|err| { + File::create(&self.dst).unwrap_or_else(|err| { sess.fatal(&format!("error opening destination during archive building: {}", err)); }), entries @@ -218,7 +213,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { ).unwrap()) } else { BuilderKind::Bsd(ar::Builder::new( - File::create(&self.config.dst).unwrap_or_else(|err| { + File::create(&self.dst).unwrap_or_else(|err| { sess.fatal(&format!("error opening destination during archive building: {}", err)); }), symbol_table, @@ -241,17 +236,17 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { // Finalize archive std::mem::drop(builder); - if self.config.no_builtin_ranlib { - let ranlib = crate::toolchain::get_toolchain_binary(self.config.sess, "ranlib"); + if self.no_builtin_ranlib { + let ranlib = crate::toolchain::get_toolchain_binary(self.sess, "ranlib"); // Run ranlib to be able to link the archive let status = std::process::Command::new(ranlib) - .arg(self.config.dst) + .arg(self.dst) .status() .expect("Couldn't run ranlib"); if !status.success() { - self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); + self.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); } } } From f79e8e8487e2b34875e351cac61e70455da0b1a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Aug 2020 16:30:22 +0200 Subject: [PATCH 1443/1566] Rustup to rustc 1.47.0-nightly (09f4c9f50 2020-08-07) --- build_sysroot/Cargo.lock | 8 ++++---- rust-toolchain | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 53d5364b554cb..b4f5db535d07f 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -41,9 +41,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "0.1.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" [[package]] name = "cc" @@ -119,9 +119,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.6.3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" +checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" dependencies = [ "autocfg", "compiler_builtins", diff --git a/rust-toolchain b/rust-toolchain index d16b27f6dbd57..c3d07709f7d9d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-08-05 +nightly-2020-08-08 From 49b7fac44313030da598146b11b61840fa5a5d8b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 8 Aug 2020 16:32:03 +0200 Subject: [PATCH 1444/1566] Enable simd insert and extract tests Working since rust-lang/stdarch#876 Fixes #666 --- example/std_example.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/example/std_example.rs b/example/std_example.rs index dee228a7d108c..184b63e5d833b 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -144,9 +144,8 @@ unsafe fn test_simd() { test_mm_cvtepi8_epi16(); test_mm_cvtsi128_si64(); - // FIXME(#666) implement `#[rustc_arg_required_const(..)]` support - //test_mm_extract_epi8(); - //test_mm_insert_epi16(); + test_mm_extract_epi8(); + test_mm_insert_epi16(); let mask1 = _mm_movemask_epi8(dbg!(_mm_setr_epi8(255u8 as i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))); assert_eq!(mask1, 1); From 8c7c091244f8d820c5de59541c15c817d62e18c6 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 9 Aug 2020 19:42:37 +0200 Subject: [PATCH 1445/1566] Rustup to rustc 1.47.0-nightly (ceedf1d5f 2020-08-08) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index c3d07709f7d9d..79144d2eda64b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-08-08 +nightly-2020-08-09 From 847cc7ab2a96c9d2f3c225dc8e86f19a24eefcb4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Aug 2020 14:19:23 +0200 Subject: [PATCH 1446/1566] Disable the inline asm support using a feature flag --- Cargo.toml | 3 ++- src/driver/aot.rs | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f16d45cd46a25..511c348abf325 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,9 @@ libloading = { version = "0.6.0", optional = true } #gimli = { path = "../" } [features] -default = ["jit"] +default = ["jit", "inline_asm"] jit = ["cranelift-simplejit", "libloading"] +inline_asm = [] [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 9f6b0c5147576..17688caada47f 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -298,13 +298,20 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { return; } - if tcx.sess.target.target.options.is_like_osx || tcx.sess.target.target.options.is_like_windows { + if cfg!(not(feature = "inline_asm")) + || tcx.sess.target.target.options.is_like_osx + || tcx.sess.target.target.options.is_like_windows + { if global_asm.contains("__rust_probestack") { return; } // FIXME fix linker error on macOS - tcx.sess.fatal("asm! and global_asm! are not yet supported on macOS and Windows"); + if cfg!(not(feature = "inline_asm")) { + tcx.sess.fatal("asm! and global_asm! support is disabled while compiling rustc_codegen_cranelift"); + } else { + tcx.sess.fatal("asm! and global_asm! are not yet supported on macOS and Windows"); + } } let assembler = crate::toolchain::get_toolchain_binary(tcx.sess, "as"); From c1a68b1386c26b92f2c6126bee8cc808f4ff93a5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Aug 2020 18:55:32 +0200 Subject: [PATCH 1447/1566] Emulate the cpuid arch intrinsic --- example/std_example.rs | 2 + patches/0016-Disable-cpuid-intrinsic.patch | 27 --------- src/base.rs | 52 +++++++++++------ src/intrinsics/cpuid.rs | 67 ++++++++++++++++++++++ src/intrinsics/mod.rs | 2 + 5 files changed, 107 insertions(+), 43 deletions(-) delete mode 100644 patches/0016-Disable-cpuid-intrinsic.patch create mode 100644 src/intrinsics/cpuid.rs diff --git a/example/std_example.rs b/example/std_example.rs index 184b63e5d833b..8e6ab2d712c3e 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -126,6 +126,8 @@ fn panic(_: u128) { #[target_feature(enable = "sse2")] unsafe fn test_simd() { + assert!(is_x86_feature_detected!("sse2")); + let x = _mm_setzero_si128(); let y = _mm_set1_epi16(7); let or = _mm_or_si128(x, y); diff --git a/patches/0016-Disable-cpuid-intrinsic.patch b/patches/0016-Disable-cpuid-intrinsic.patch deleted file mode 100644 index c1d24c3c0c569..0000000000000 --- a/patches/0016-Disable-cpuid-intrinsic.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 7403e2998345ef0650fd50628d7098d4d1e88e5c Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Sat, 6 Apr 2019 12:16:21 +0200 -Subject: [PATCH] Remove usage of unsized locals - ---- - library/stdarch/crates/core_arch/src/x86/cpuid.rs | 2 ++ - 1 files changed, 2 insertions(+), 0 deletions(-) - -diff --git a/library/stdarch/crates/core_arch/src/x86/cpuid.rs b/library/stdarch/crates/core_arch/src/x86/cpuid.rs -index f313c42..ff952bc 100644 ---- a/library/stdarch/crates/core_arch/src/x86/cpuid.rs -+++ b/library/stdarch/crates/core_arch/src/x86/cpuid.rs -@@ -84,6 +84,11 @@ pub unsafe fn __cpuid(leaf: u32) -> CpuidResult { - /// Does the host support the `cpuid` instruction? - #[inline] - pub fn has_cpuid() -> bool { -+ // __cpuid intrinsic is not yet implemented -+ #[cfg(target_feature = "cg_clif")] { -+ return false; -+ } -+ - #[cfg(target_env = "sgx")] - { - false --- -2.20.1 (Apple Git-117) diff --git a/src/base.rs b/src/base.rs index cd8152066fa55..83e13265d054d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -681,37 +681,57 @@ fn trans_stmt<'tcx>( use rustc_span::symbol::Symbol; let LlvmInlineAsm { asm, - outputs: _, - inputs: _, + outputs, + inputs, } = &**asm; let rustc_hir::LlvmInlineAsmInner { asm: asm_code, // Name - outputs, // Vec - inputs, // Vec + outputs: output_names, // Vec + inputs: input_names, // Vec clobbers, // Vec volatile, // bool alignstack, // bool - dialect: _, // rustc_ast::ast::AsmDialect + dialect: _, asm_str_style: _, } = asm; - match &*asm_code.as_str() { + match asm_code.as_str().trim() { "" => { // Black box } - cpuid if cpuid.contains("cpuid") => { - crate::trap::trap_unimplemented( - fx, - "__cpuid_count arch intrinsic is not supported", - ); + "mov %rbx, %rsi\n cpuid\n xchg %rbx, %rsi" => { + assert_eq!(input_names, &[Symbol::intern("{eax}"), Symbol::intern("{ecx}")]); + assert_eq!(output_names.len(), 4); + for (i, c) in (&["={eax}", "={esi}", "={ecx}", "={edx}"]).iter().enumerate() { + assert_eq!(&output_names[i].constraint.as_str(), c); + assert!(!output_names[i].is_rw); + assert!(!output_names[i].is_indirect); + } + + assert_eq!(clobbers, &[]); + + assert!(!volatile); + assert!(!alignstack); + + assert_eq!(inputs.len(), 2); + let leaf = trans_operand(fx, &inputs[0].1).load_scalar(fx); // %eax + let subleaf = trans_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx + + let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); + + assert_eq!(outputs.len(), 4); + trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32))); } "xgetbv" => { - assert_eq!(inputs, &[Symbol::intern("{ecx}")]); + assert_eq!(input_names, &[Symbol::intern("{ecx}")]); - assert_eq!(outputs.len(), 2); + assert_eq!(output_names.len(), 2); for (i, c) in (&["={eax}", "={edx}"]).iter().enumerate() { - assert_eq!(&outputs[i].constraint.as_str(), c); - assert!(!outputs[i].is_rw); - assert!(!outputs[i].is_indirect); + assert_eq!(&output_names[i].constraint.as_str(), c); + assert!(!output_names[i].is_rw); + assert!(!output_names[i].is_indirect); } assert_eq!(clobbers, &[]); diff --git a/src/intrinsics/cpuid.rs b/src/intrinsics/cpuid.rs new file mode 100644 index 0000000000000..cbfeefed69234 --- /dev/null +++ b/src/intrinsics/cpuid.rs @@ -0,0 +1,67 @@ +use crate::prelude::*; + +/// Emulates a subset of the cpuid call. +/// +/// This emulates an intel cpu with sse and sse2 support, but which doesn't support anything else. +pub(crate) fn codegen_cpuid_call<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + leaf: Value, + _subleaf: Value, +) -> (Value, Value, Value, Value) { + let leaf_0 = fx.bcx.create_block(); + let leaf_1 = fx.bcx.create_block(); + let leaf_8000_0000 = fx.bcx.create_block(); + let leaf_8000_0001 = fx.bcx.create_block(); + let unsupported_leaf = fx.bcx.create_block(); + + let dest = fx.bcx.create_block(); + let eax = fx.bcx.append_block_param(dest, types::I32); + let ebx = fx.bcx.append_block_param(dest, types::I32); + let ecx = fx.bcx.append_block_param(dest, types::I32); + let edx = fx.bcx.append_block_param(dest, types::I32); + + let mut switch = cranelift_frontend::Switch::new(); + switch.set_entry(0, leaf_0); + switch.set_entry(1, leaf_1); + switch.set_entry(0x8000_0000, leaf_8000_0000); + switch.set_entry(0x8000_0001, leaf_8000_0001); + switch.emit(&mut fx.bcx, leaf, unsupported_leaf); + + fx.bcx.switch_to_block(leaf_0); + let max_basic_leaf = fx.bcx.ins().iconst(types::I32, 1); + let vend0 = fx.bcx.ins().iconst(types::I32, i64::from(u32::from_le_bytes(*b"Genu"))); + let vend2 = fx.bcx.ins().iconst(types::I32, i64::from(u32::from_le_bytes(*b"ineI"))); + let vend1 = fx.bcx.ins().iconst(types::I32, i64::from(u32::from_le_bytes(*b"ntel"))); + fx.bcx.ins().jump(dest, &[max_basic_leaf, vend0, vend1, vend2]); + + fx.bcx.switch_to_block(leaf_1); + let cpu_signature = fx.bcx.ins().iconst(types::I32, 0); + let additional_information = fx.bcx.ins().iconst(types::I32, 0); + let ecx_features = fx.bcx.ins().iconst( + types::I32, + 0, + ); + let edx_features = fx.bcx.ins().iconst( + types::I32, + 1 << 25 /* sse */ | 1 << 26 /* sse2 */, + ); + fx.bcx.ins().jump(dest, &[cpu_signature, additional_information, ecx_features, edx_features]); + + fx.bcx.switch_to_block(leaf_8000_0000); + let extended_max_basic_leaf = fx.bcx.ins().iconst(types::I32, 0); + let zero = fx.bcx.ins().iconst(types::I32, 0); + fx.bcx.ins().jump(dest, &[extended_max_basic_leaf, zero, zero, zero]); + + fx.bcx.switch_to_block(leaf_8000_0001); + let zero = fx.bcx.ins().iconst(types::I32, 0); + let proc_info_ecx = fx.bcx.ins().iconst(types::I32, 0); + let proc_info_edx = fx.bcx.ins().iconst(types::I32, 0); + fx.bcx.ins().jump(dest, &[zero, zero, proc_info_ecx, proc_info_edx]); + + fx.bcx.switch_to_block(unsupported_leaf); + crate::trap::trap_unreachable(fx, "__cpuid_count arch intrinsic doesn't yet support specified leaf"); + + fx.bcx.switch_to_block(dest); + + (eax, ebx, ecx, edx) +} diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 546864fc47752..488c08815bace 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -1,6 +1,8 @@ +mod cpuid; mod llvm; mod simd; +pub(crate) use cpuid::codegen_cpuid_call; pub(crate) use llvm::codegen_llvm_intrinsic_call; use crate::prelude::*; From 3d46a30469c4156fefb7ef046953ea19c4d6a2f2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Aug 2020 20:55:03 +0200 Subject: [PATCH 1448/1566] Fix ppv-lite86 with simd enabled This fixes older rand versions that enable the simd feature of ppv-lite86 --- .gitignore | 1 + clean_all.sh | 2 +- ...1-rand-Enable-c2-chacha-simd-feature.patch | 23 +++++++++++++ .../0002-rand-Disable-failing-test.patch | 33 +++++++++++++++++++ prepare.sh | 7 ++++ src/intrinsics/llvm.rs | 25 ++++++++++++++ test.sh | 5 +++ 7 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 crate_patches/0001-rand-Enable-c2-chacha-simd-feature.patch create mode 100644 crate_patches/0002-rand-Disable-failing-test.patch diff --git a/.gitignore b/.gitignore index 7b21bbb6492e1..0da9927b479b4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ perf.data.old /build_sysroot/sysroot /build_sysroot/sysroot_src /rust +/rand /regex /simple-raytracer diff --git a/clean_all.sh b/clean_all.sh index b64399bb7c836..3003a0ea2d102 100755 --- a/clean_all.sh +++ b/clean_all.sh @@ -2,4 +2,4 @@ set -e rm -rf target/ build_sysroot/{sysroot/,sysroot_src/,target/} perf.data{,.old} -rm -rf regex/ simple-raytracer/ +rm -rf rand/ regex/ simple-raytracer/ diff --git a/crate_patches/0001-rand-Enable-c2-chacha-simd-feature.patch b/crate_patches/0001-rand-Enable-c2-chacha-simd-feature.patch new file mode 100644 index 0000000000000..01dc0fcc53761 --- /dev/null +++ b/crate_patches/0001-rand-Enable-c2-chacha-simd-feature.patch @@ -0,0 +1,23 @@ +From 9c5663e36391fa20becf84f3af2e82afa5bb720b Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 15 Aug 2020 19:56:03 +0200 +Subject: [PATCH] [rand] Enable c2-chacha simd feature + +--- + rand_chacha/Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/rand_chacha/Cargo.toml b/rand_chacha/Cargo.toml +index 9190b7f..872cca2 100644 +--- a/rand_chacha/Cargo.toml ++++ b/rand_chacha/Cargo.toml +@@ -24,5 +24,5 @@ ppv-lite86 = { version = "0.2.8", default-features = false } + + [features] + default = ["std"] +-std = ["ppv-lite86/std"] ++std = ["ppv-lite86/std", "ppv-lite86/simd"] + simd = [] # deprecated +-- +2.20.1 + diff --git a/crate_patches/0002-rand-Disable-failing-test.patch b/crate_patches/0002-rand-Disable-failing-test.patch new file mode 100644 index 0000000000000..19fd20d726901 --- /dev/null +++ b/crate_patches/0002-rand-Disable-failing-test.patch @@ -0,0 +1,33 @@ +From a8fb97120d71252538b6b026695df40d02696bdb Mon Sep 17 00:00:00 2001 +From: bjorn3 +Date: Sat, 15 Aug 2020 20:04:38 +0200 +Subject: [PATCH] [rand] Disable failing test + +--- + src/distributions/uniform.rs | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/distributions/uniform.rs b/src/distributions/uniform.rs +index 480b859..c80bb6f 100644 +--- a/src/distributions/uniform.rs ++++ b/src/distributions/uniform.rs +@@ -1085,7 +1085,7 @@ mod tests { + _ => panic!("`UniformDurationMode` was not serialized/deserialized correctly") + } + } +- ++ + #[test] + #[cfg(feature = "serde1")] + fn test_uniform_serialization() { +@@ -1314,6 +1314,7 @@ mod tests { + not(target_arch = "wasm32"), + not(target_arch = "asmjs") + ))] ++ #[ignore] // FIXME + fn test_float_assertions() { + use super::SampleUniform; + use std::panic::catch_unwind; +-- +2.20.1 + diff --git a/prepare.sh b/prepare.sh index 8d57e77018e24..87f96f5dcf41f 100755 --- a/prepare.sh +++ b/prepare.sh @@ -5,6 +5,13 @@ rustup component add rust-src rustc-dev llvm-tools-preview ./build_sysroot/prepare_sysroot_src.sh cargo install hyperfine || echo "Skipping hyperfine install" +git clone https://github.com/rust-random/rand.git || echo "rust-random/rand has already been cloned" +pushd rand +git checkout -- . +git checkout 0f933f9c7176e53b2a3c7952ded484e1783f0bf1 +git am ../crate_patches/*-rand-*.patch +popd + git clone https://github.com/rust-lang/regex.git || echo "rust-lang/regex has already been cloned" pushd regex git checkout -- . diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index b99a3dffa11c2..c85daaa0e2e3d 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -94,6 +94,31 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( bool_to_zero_or_max_uint(fx, res_lane_layout, res_lane) }); }; + llvm.x86.sse2.psrli.d, (c a, o imm8) { + let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const"); + simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| { + let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) { + imm8 if imm8 < 32 => fx.bcx.ins().ushr_imm(lane, i64::from(imm8 as u8)), + _ => fx.bcx.ins().iconst(types::I32, 0), + }; + CValue::by_val(res_lane, res_lane_layout) + }); + }; + llvm.x86.sse2.pslli.d, (c a, o imm8) { + let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const"); + simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| { + let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) { + imm8 if imm8 < 32 => fx.bcx.ins().ishl_imm(lane, i64::from(imm8 as u8)), + _ => fx.bcx.ins().iconst(types::I32, 0), + }; + CValue::by_val(res_lane, res_lane_layout) + }); + }; + llvm.x86.sse2.storeu.dq, (v mem_addr, c a) { + // FIXME correctly handle the unalignment + let dest = CPlace::for_ptr(Pointer::new(mem_addr), a.layout()); + dest.write_cvalue(fx, a); + }; } if let Some((_, dest)) = destination { diff --git a/test.sh b/test.sh index 38d9d87138b38..95c6c6a582f69 100755 --- a/test.sh +++ b/test.sh @@ -71,6 +71,11 @@ $RUN_WRAPPER ./target/out/track-caller-attribute echo "[BUILD] mod_bench" $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE +pushd rand +rm -r ./target || true +../cargo.sh test --workspace +popd + pushd simple-raytracer if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then echo "[BENCH COMPILE] ebobby/simple-raytracer" From 0703e98bf6346fcd95bd86cfbd1a953f4480ad44 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 15 Aug 2020 21:04:33 +0200 Subject: [PATCH 1449/1566] Remove cg_clif fake target feature --- src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bc0bae9c28dab..d285936e22bfb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,13 +184,11 @@ impl CodegenBackend for CraneliftCodegenBackend { // rustdoc needs to be able to document functions that use all the features, so // whitelist them all target_features_whitelist::all_known_features() - .chain(Some(("cg_clif", None))) .map(|(a, b)| (a.to_string(), b)) .collect() } else { target_features_whitelist::target_feature_whitelist(tcx.sess) .iter() - .chain(&Some(("cg_clif", None))) .map(|&(a, b)| (a.to_string(), b)) .collect() } @@ -199,7 +197,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn provide_extern(&self, _providers: &mut Providers) {} fn target_features(&self, _sess: &Session) -> Vec { - vec![rustc_span::Symbol::intern("cg_clif")] + vec![] } fn codegen_crate<'tcx>( From 4757371aba4e8aaf2cebb4ba32299cf7f9364aaf Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Aug 2020 11:48:46 +0200 Subject: [PATCH 1450/1566] Fix ambiguity between object and cranelift_object::object --- src/backend.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend.rs b/src/backend.rs index e375fffb6cb62..59b339eb57c05 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -8,7 +8,7 @@ use cranelift_module::{FuncId, Module}; use object::{SectionKind, SymbolFlags, RelocationKind, RelocationEncoding}; use object::write::*; -use cranelift_object::*; +use cranelift_object::{ObjectBackend, ObjectBuilder, ObjectProduct}; use gimli::SectionId; From f0069dac0046e85b4e944b0e67a064a626b25759 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Aug 2020 20:55:22 +0200 Subject: [PATCH 1451/1566] Fix panic in when debug assertions are enabled --- src/intrinsics/cpuid.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/intrinsics/cpuid.rs b/src/intrinsics/cpuid.rs index cbfeefed69234..9d971d97b88c6 100644 --- a/src/intrinsics/cpuid.rs +++ b/src/intrinsics/cpuid.rs @@ -62,6 +62,7 @@ pub(crate) fn codegen_cpuid_call<'tcx>( crate::trap::trap_unreachable(fx, "__cpuid_count arch intrinsic doesn't yet support specified leaf"); fx.bcx.switch_to_block(dest); + fx.bcx.ins().nop(); (eax, ebx, ecx, edx) } From 7e203efce89cddf1644f5f2a65ab75df60fff00f Mon Sep 17 00:00:00 2001 From: Craig Mayhew Date: Mon, 17 Aug 2020 21:28:12 +0100 Subject: [PATCH 1452/1566] Enforce linux style line endings to support WSL (#1073) * Enforce linux style line endings to support WSL If you clone in windows, but run under WSL, the line endings cause errors. This enforces linux style line endings. * Update .gitattributes to use text=auto Co-authored-by: bjorn3 Co-authored-by: bjorn3 --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000..6313b56c57848 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf From 33b6a9081a775610ca73c54b0cde095001155231 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 19 Aug 2020 13:51:49 +0200 Subject: [PATCH 1453/1566] Add workaround for rust-lang/rust#74946 Fixes #1072 --- build_sysroot/build_sysroot.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index e08fc51999d9c..b4b7c5e5e01e8 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -18,7 +18,8 @@ rm -r sysroot/ 2>/dev/null || true export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked" if [[ "$1" == "--release" ]]; then sysroot_channel='release' - RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=2" cargo build --target $TARGET_TRIPLE --release + # FIXME Enable incremental again once rust-lang/rust#74946 is fixed + CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=2" cargo build --target $TARGET_TRIPLE --release else sysroot_channel='debug' cargo build --target $TARGET_TRIPLE From f4e22f0bff9a07c8951ce2c881df15aa6af09fb7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 19 Aug 2020 14:05:57 +0200 Subject: [PATCH 1454/1566] [gh actions] Remove actions-rs/cargo step It is not very useful and increases compilation time, as the CARGO_INCREMENTAL env var differs between it and the cargo invocation in test.sh --- .github/workflows/main.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a95d1929c9192..7196d55ab6ebc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,13 +46,6 @@ jobs: git config --global user.name "User" ./prepare.sh - # Compile is a separate step, as the actions-rs/cargo action supports error annotations - - name: Compile - uses: actions-rs/cargo@v1.0.3 - with: - command: rustc - args: --release -- -Zrun_dsymutil=no - - name: Test run: | # Enable backtraces for easier debugging From 03209e1e2d128a29a92d0669987d0e1de5e486c3 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 19 Aug 2020 14:07:43 +0200 Subject: [PATCH 1455/1566] Don't disable incremental cache for cargo.sh cc #1052 --- config.sh | 1 - test.sh | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config.sh b/config.sh index 902743d54c732..b47da434c647b 100644 --- a/config.sh +++ b/config.sh @@ -45,4 +45,3 @@ export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustl export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH export CG_CLIF_DISPLAY_CG_TIME=1 -export CG_CLIF_INCR_CACHE_DISABLED=1 diff --git a/test.sh b/test.sh index 95c6c6a582f69..230e464d2796f 100755 --- a/test.sh +++ b/test.sh @@ -1,7 +1,7 @@ #!/bin/bash - set -e +# Build cg_clif if [[ "$1" == "--release" ]]; then export CHANNEL='release' CARGO_INCREMENTAL=1 cargo rustc --release -- -Zrun_dsymutil=no @@ -10,11 +10,15 @@ else cargo rustc -- -Zrun_dsymutil=no fi +# Config source config.sh +export CG_CLIF_INCR_CACHE_DISABLED=1 +# Cleanup rm -r target/out || true mkdir -p target/out/clif +# Perform all tests echo "[BUILD] mini_core" $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE From 50cd72d5905a020500e912bc2913e0013e9cebab Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 19 Aug 2020 14:14:32 +0200 Subject: [PATCH 1456/1566] Bump actions/cache to v2 --- .github/workflows/main.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7196d55ab6ebc..841e1a0870ed3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,25 +17,21 @@ jobs: - uses: actions/checkout@v2 - name: Cache cargo installed crates - uses: actions/cache@v1.1.2 + uses: actions/cache@v2 with: path: ~/.cargo/bin - key: cargo-installed-crates2-${{ matrix.os }} + key: ${{ runner.os }}-cargo-installed-crates - - name: Cache cargo registry - uses: actions/cache@v1 + - name: Cache cargo registry and index + uses: actions/cache@v2 with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry2-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v1 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-registry-and-index-${{ hashFiles('**/Cargo.lock') }} - name: Cache cargo target dir - uses: actions/cache@v1.1.2 + uses: actions/cache@v2 with: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} From 7752718e5b5ca2ba7d74497dfa11a208da47afcb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 19 Aug 2020 18:52:56 +0200 Subject: [PATCH 1457/1566] Update target_feature_whitelist --- src/lib.rs | 2 +- src/target_features_whitelist.rs | 77 +++++++++++++++++++------------- 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d285936e22bfb..07b70155f0f21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,7 +187,7 @@ impl CodegenBackend for CraneliftCodegenBackend { .map(|(a, b)| (a.to_string(), b)) .collect() } else { - target_features_whitelist::target_feature_whitelist(tcx.sess) + target_features_whitelist::supported_target_features(tcx.sess) .iter() .map(|&(a, b)| (a.to_string(), b)) .collect() diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index de433cca514a6..04c8fde48d8d5 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -2,18 +2,20 @@ use rustc_span::symbol::{sym, Symbol}; use rustc_session::Session; -// Copied from https://github.com/rust-lang/rust/blob/f69b07144a151f46aaee1b6230ba4160e9394562/src/librustc_codegen_llvm/llvm_util.rs#L93-L264 +// Copied from https://github.com/rust-lang/rust/blob/e7f6ed14d5de2199d0e8a3c1e41f80e43885cb5c/src/librustc_codegen_llvm/llvm_util.rs#L139-L275 // WARNING: the features after applying `to_llvm_feature` must be known // to LLVM or the feature detection code will walk past the end of the feature // array, leading to crashes. -const ARM_WHITELIST: &[(&str, Option)] = &[ +const ARM_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("aclass", Some(sym::arm_target_feature)), ("mclass", Some(sym::arm_target_feature)), ("rclass", Some(sym::arm_target_feature)), ("dsp", Some(sym::arm_target_feature)), ("neon", Some(sym::arm_target_feature)), + ("crc", Some(sym::arm_target_feature)), + ("crypto", Some(sym::arm_target_feature)), ("v5te", Some(sym::arm_target_feature)), ("v6", Some(sym::arm_target_feature)), ("v6k", Some(sym::arm_target_feature)), @@ -23,9 +25,13 @@ const ARM_WHITELIST: &[(&str, Option)] = &[ ("vfp2", Some(sym::arm_target_feature)), ("vfp3", Some(sym::arm_target_feature)), ("vfp4", Some(sym::arm_target_feature)), + // This is needed for inline assembly, but shouldn't be stabilized as-is + // since it should be enabled per-function using #[instruction_set], not + // #[target_feature]. + ("thumb-mode", Some(sym::arm_target_feature)), ]; -const AARCH64_WHITELIST: &[(&str, Option)] = &[ +const AARCH64_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("fp", Some(sym::aarch64_target_feature)), ("neon", Some(sym::aarch64_target_feature)), ("sve", Some(sym::aarch64_target_feature)), @@ -37,12 +43,13 @@ const AARCH64_WHITELIST: &[(&str, Option)] = &[ ("fp16", Some(sym::aarch64_target_feature)), ("rcpc", Some(sym::aarch64_target_feature)), ("dotprod", Some(sym::aarch64_target_feature)), + ("tme", Some(sym::aarch64_target_feature)), ("v8.1a", Some(sym::aarch64_target_feature)), ("v8.2a", Some(sym::aarch64_target_feature)), ("v8.3a", Some(sym::aarch64_target_feature)), ]; -const X86_WHITELIST: &[(&str, Option)] = &[ +const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("adx", Some(sym::adx_target_feature)), ("aes", None), ("avx", None), @@ -86,12 +93,12 @@ const X86_WHITELIST: &[(&str, Option)] = &[ ("xsaves", None), ]; -const HEXAGON_WHITELIST: &[(&str, Option)] = &[ +const HEXAGON_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("hvx", Some(sym::hexagon_target_feature)), - ("hvx-double", Some(sym::hexagon_target_feature)), + ("hvx-length128b", Some(sym::hexagon_target_feature)), ]; -const POWERPC_WHITELIST: &[(&str, Option)] = &[ +const POWERPC_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("altivec", Some(sym::powerpc_target_feature)), ("power8-altivec", Some(sym::powerpc_target_feature)), ("power9-altivec", Some(sym::powerpc_target_feature)), @@ -100,43 +107,51 @@ const POWERPC_WHITELIST: &[(&str, Option)] = &[ ("vsx", Some(sym::powerpc_target_feature)), ]; -const MIPS_WHITELIST: &[(&str, Option)] = &[ - ("fp64", Some(sym::mips_target_feature)), - ("msa", Some(sym::mips_target_feature)), +const MIPS_ALLOWED_FEATURES: &[(&str, Option)] = + &[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))]; + +const RISCV_ALLOWED_FEATURES: &[(&str, Option)] = &[ + ("m", Some(sym::riscv_target_feature)), + ("a", Some(sym::riscv_target_feature)), + ("c", Some(sym::riscv_target_feature)), + ("f", Some(sym::riscv_target_feature)), + ("d", Some(sym::riscv_target_feature)), + ("e", Some(sym::riscv_target_feature)), ]; -const WASM_WHITELIST: &[(&str, Option)] = &[ +const WASM_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("simd128", Some(sym::wasm_target_feature)), ("atomics", Some(sym::wasm_target_feature)), + ("nontrapping-fptoint", Some(sym::wasm_target_feature)), ]; /// When rustdoc is running, provide a list of all known features so that all their respective /// primitives may be documented. /// -/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this -/// iterator! -pub(crate) fn all_known_features() -> impl Iterator)> { - ARM_WHITELIST - .iter() +/// IMPORTANT: If you're adding another feature list above, make sure to add it to this iterator! +pub fn all_known_features() -> impl Iterator)> { + std::iter::empty() + .chain(ARM_ALLOWED_FEATURES.iter()) + .chain(AARCH64_ALLOWED_FEATURES.iter()) + .chain(X86_ALLOWED_FEATURES.iter()) + .chain(HEXAGON_ALLOWED_FEATURES.iter()) + .chain(POWERPC_ALLOWED_FEATURES.iter()) + .chain(MIPS_ALLOWED_FEATURES.iter()) + .chain(RISCV_ALLOWED_FEATURES.iter()) + .chain(WASM_ALLOWED_FEATURES.iter()) .cloned() - .chain(AARCH64_WHITELIST.iter().cloned()) - .chain(X86_WHITELIST.iter().cloned()) - .chain(HEXAGON_WHITELIST.iter().cloned()) - .chain(POWERPC_WHITELIST.iter().cloned()) - .chain(MIPS_WHITELIST.iter().cloned()) - .chain(WASM_WHITELIST.iter().cloned()) } -pub(crate) fn target_feature_whitelist(sess: &Session) -> &'static [(&'static str, Option)] { +pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Option)] { match &*sess.target.target.arch { - "arm" => ARM_WHITELIST, - "aarch64" => AARCH64_WHITELIST, - "x86" | "x86_64" => X86_WHITELIST, - "hexagon" => HEXAGON_WHITELIST, - "mips" | "mips64" => MIPS_WHITELIST, - "powerpc" | "powerpc64" => POWERPC_WHITELIST, - // wasm32 on emscripten does not support these target features - "wasm32" if !sess.target.target.options.is_like_emscripten => WASM_WHITELIST, + "arm" => ARM_ALLOWED_FEATURES, + "aarch64" => AARCH64_ALLOWED_FEATURES, + "x86" | "x86_64" => X86_ALLOWED_FEATURES, + "hexagon" => HEXAGON_ALLOWED_FEATURES, + "mips" | "mips64" => MIPS_ALLOWED_FEATURES, + "powerpc" | "powerpc64" => POWERPC_ALLOWED_FEATURES, + "riscv32" | "riscv64" => RISCV_ALLOWED_FEATURES, + "wasm32" => WASM_ALLOWED_FEATURES, _ => &[], } } From ee2addd010a8cd8b8665dce8a32f8b18d101bc71 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 20 Aug 2020 13:22:07 +0200 Subject: [PATCH 1458/1566] Don't test x86_64 simd on archs other than x86_64 --- example/std_example.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/example/std_example.rs b/example/std_example.rs index 8e6ab2d712c3e..079b429904911 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -1,5 +1,6 @@ #![feature(core_intrinsics, generators, generator_trait, is_sorted)] +#[cfg(target_arch = "x86_64")] use std::arch::x86_64::*; use std::io::Write; use std::ops::Generator; @@ -96,6 +97,7 @@ fn main() { println!("{:?}", std::intrinsics::caller_location()); + #[cfg(target_arch = "x86_64")] unsafe { test_simd(); } @@ -124,6 +126,7 @@ fn panic(_: u128) { panic!(); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_simd() { assert!(is_x86_feature_detected!("sse2")); @@ -153,6 +156,7 @@ unsafe fn test_simd() { assert_eq!(mask1, 1); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_slli_si128() { #[rustfmt::skip] @@ -193,6 +197,7 @@ unsafe fn test_mm_slli_si128() { assert_eq_m128i(r, _mm_set1_epi8(0)); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_movemask_epi8() { #[rustfmt::skip] @@ -206,6 +211,7 @@ unsafe fn test_mm_movemask_epi8() { assert_eq!(r, 0b10100100_00100101); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "avx2")] unsafe fn test_mm256_movemask_epi8() { let a = _mm256_set1_epi8(-1); @@ -214,6 +220,7 @@ unsafe fn test_mm256_movemask_epi8() { assert_eq!(r, e); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_add_epi8() { let a = _mm_setr_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); @@ -229,6 +236,7 @@ unsafe fn test_mm_add_epi8() { assert_eq_m128i(r, e); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_add_pd() { let a = _mm_setr_pd(1.0, 2.0); @@ -237,12 +245,14 @@ unsafe fn test_mm_add_pd() { assert_eq_m128d(r, _mm_setr_pd(6.0, 12.0)); } +#[cfg(target_arch = "x86_64")] fn assert_eq_m128i(x: std::arch::x86_64::__m128i, y: std::arch::x86_64::__m128i) { unsafe { assert_eq!(std::mem::transmute::<_, [u8; 16]>(x), std::mem::transmute::<_, [u8; 16]>(y)); } } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { if _mm_movemask_pd(_mm_cmpeq_pd(a, b)) != 0b11 { @@ -250,12 +260,14 @@ pub unsafe fn assert_eq_m128d(a: __m128d, b: __m128d) { } } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_cvtsi128_si64() { let r = _mm_cvtsi128_si64(std::mem::transmute::<[i64; 2], _>([5, 0])); assert_eq!(r, 5); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse4.1")] unsafe fn test_mm_cvtepi8_epi16() { let a = _mm_set1_epi8(10); @@ -268,6 +280,7 @@ unsafe fn test_mm_cvtepi8_epi16() { assert_eq_m128i(r, e); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse4.1")] unsafe fn test_mm_extract_epi8() { #[rustfmt::skip] @@ -281,6 +294,7 @@ unsafe fn test_mm_extract_epi8() { assert_eq!(r2, 3); } +#[cfg(target_arch = "x86_64")] #[target_feature(enable = "sse2")] unsafe fn test_mm_insert_epi16() { let a = _mm_setr_epi16(0, 1, 2, 3, 4, 5, 6, 7); From 02b7cdc316b733649635fe7df1051429b0dfe25b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 20 Aug 2020 15:21:26 +0200 Subject: [PATCH 1459/1566] Update Cranelift and object --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e5f6c0f017ad..77d1fd0b40578 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" [[package]] name = "cranelift-entity" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" [[package]] name = "cranelift-frontend" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "anyhow", "cranelift-codegen", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#8cfff2695713bce54c465a16005663aa143c7385" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "object" -version = "0.20.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" +checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" dependencies = [ "crc32fast", "indexmap", @@ -285,9 +285,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.28" +version = "0.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3598bed0895fe0f72a9e0b00ef9e3a3c8af978a8401b2f2046dec5927de6364a" +checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" dependencies = [ "log", "rustc-hash", diff --git a/Cargo.toml b/Cargo.toml index 511c348abf325..e178e29925b03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", b cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } target-lexicon = "0.10.0" gimli = { version = "0.21.0", default-features = false, features = ["write"]} -object = { version = "0.20.0", default-features = false, features = ["read", "std", "write"] } +object = { version = "0.21.1", default-features = false, features = ["read", "std", "write"] } ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } byteorder = "1.2.7" From ca9fc101c00e33a0735a3bd2fa44eeeb7841422f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 16 Aug 2020 21:20:12 +0200 Subject: [PATCH 1460/1566] Fix weak linkage This removes the last sysroot patch apart from the few patches that disable tests --- example/mini_core_hello_world.rs | 17 ++-- ...-of-extern_weak-in-thread_local_dtor.patch | 45 ----------- src/constant.rs | 80 ++++++++++--------- src/linkage.rs | 8 +- 4 files changed, 60 insertions(+), 90 deletions(-) delete mode 100644 patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 9c2ab5a5165cd..d79f9f5f79c5b 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -241,19 +241,22 @@ fn main() { assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); - extern { - #[linkage = "extern_weak"] - static ABC: *const u8; - } - + #[cfg(not(jit))] { extern { #[linkage = "extern_weak"] static ABC: *const u8; } - } - unsafe { assert_eq!(ABC as usize, 0); } + { + extern { + #[linkage = "extern_weak"] + static ABC: *const u8; + } + } + + unsafe { assert_eq!(ABC as usize, 0); } + } &mut (|| Some(0 as *const ())) as &mut dyn FnMut() -> Option<*const ()>; diff --git a/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch b/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch deleted file mode 100644 index 29b891c6eb5c6..0000000000000 --- a/patches/0025-Remove-usage-of-extern_weak-in-thread_local_dtor.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 7496bb94a2fb2bc34629c9781c3bc3a470becaee Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Fri, 10 Apr 2020 13:47:42 +0200 -Subject: [PATCH] Remove usage of extern_weak in thread_local_dtor - ---- - library/std/src/sys/unix/thread_local_dtor.rs | 20 -------------------- - 1 files changed, 0 insertions(+), 20 deletions(-) - -diff --git a/library/std/src/sys/unix/thread_local_dtor.rs b/library/std/src/sys/unix/thread_local_dtor.rs -index 8730b4d..8d6e3d5 100644 ---- a/library/std/src/sys/unix/thread_local_dtor.rs -+++ b/library/std/src/sys/unix/thread_local_dtor.rs -@@ -15,28 +15,8 @@ - target_os = "emscripten" - ))] - pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { -- use crate::mem; - use crate::sys_common::thread_local_dtor::register_dtor_fallback; - -- extern "C" { -- #[linkage = "extern_weak"] -- static __dso_handle: *mut u8; -- #[linkage = "extern_weak"] -- static __cxa_thread_atexit_impl: *const libc::c_void; -- } -- if !__cxa_thread_atexit_impl.is_null() { -- type F = unsafe extern "C" fn( -- dtor: unsafe extern "C" fn(*mut u8), -- arg: *mut u8, -- dso_handle: *mut u8, -- ) -> libc::c_int; -- mem::transmute::<*const libc::c_void, F>(__cxa_thread_atexit_impl)( -- dtor, -- t, -- &__dso_handle as *const _ as *mut _, -- ); -- return; -- } - register_dtor_fallback(t, dtor); - } - --- -2.20.1 - diff --git a/src/constant.rs b/src/constant.rs index e3d96528972a2..0ed05c56d7439 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -43,8 +43,7 @@ pub(crate) fn codegen_tls_ref<'tcx>( 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 data_id = data_id_for_static(fx.tcx, fx.module, def_id, false); 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)); @@ -57,8 +56,7 @@ fn codegen_static_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'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 data_id = data_id_for_static(fx.tcx, fx.module, def_id, false); 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)); @@ -159,8 +157,7 @@ pub(crate) fn trans_const_value<'tcx>( } Some(GlobalAlloc::Static(def_id)) => { assert!(fx.tcx.is_static(def_id)); - 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 data_id = data_id_for_static(fx.tcx, fx.module, def_id, false); 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)); @@ -226,8 +223,20 @@ fn data_id_for_static( tcx: TyCtxt<'_>, module: &mut Module, def_id: DefId, - linkage: Linkage, + definition: bool, ) -> DataId { + let rlinkage = tcx.codegen_fn_attrs(def_id).linkage; + let linkage = if definition { + crate::linkage::get_static_linkage(tcx, def_id) + } else { + if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak) + || rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny) { + Linkage::Preemptible + } else { + Linkage::Import + } + }; + let instance = Instance::mono(tcx, def_id).polymorphize(tcx); let symbol_name = tcx.symbol_name(instance).name; let ty = instance.ty(tcx, ParamEnv::reveal_all()); @@ -255,26 +264,39 @@ fn data_id_for_static( ) .unwrap(); - if linkage == Linkage::Preemptible { - if let ty::RawPtr(_) = ty.kind { - } else { - tcx.sess.span_fatal( - tcx.def_span(def_id), - "must have type `*const T` or `*mut T` due to `#[linkage]` attribute", + if rlinkage.is_some() { + // Comment copied from https://github.com/rust-lang/rust/blob/45060c2a66dfd667f88bd8b94261b28a58d85bd5/src/librustc_codegen_llvm/consts.rs#L141 + // Declare an internal global `extern_with_linkage_foo` which + // is initialized with the address of `foo`. If `foo` is + // discarded during linking (for example, if `foo` has weak + // linkage and there are no definitions), then + // `extern_with_linkage_foo` will instead be initialized to + // zero. + + let ref_name = format!("_rust_extern_with_linkage_{}", symbol_name); + let ref_data_id = module + .declare_data( + &ref_name, + Linkage::Local, + true, + false, + Some(align.try_into().unwrap()), ) - } - + .unwrap(); let mut data_ctx = DataContext::new(); - data_ctx.define_zeroinit(pointer_ty(tcx).bytes() as usize); - match module.define_data(data_id, &data_ctx) { - // Everytime a weak static is referenced, there will be a zero pointer definition, + let data = module.declare_data_in_data(data_id, &mut data_ctx); + data_ctx.define(std::iter::repeat(0).take(pointer_ty(tcx).bytes() as usize).collect()); + data_ctx.write_data_addr(0, data, 0); + match module.define_data(ref_data_id, &data_ctx) { + // Every time the static is referenced there will be another definition of this global, // so duplicate definitions are expected and allowed. Err(ModuleError::DuplicateDefinition(_)) => {} res => res.unwrap(), } + ref_data_id + } else { + data_id } - - data_id } fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mut ConstantCx) { @@ -301,16 +323,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu _ => bug!("static const eval returned {:#?}", const_), }; - let data_id = data_id_for_static( - tcx, - module, - def_id, - if tcx.is_reachable_non_generic(def_id) { - Linkage::Export - } else { - Linkage::Export // FIXME Set hidden visibility - }, - ); + let data_id = data_id_for_static(tcx, module, def_id, true); (data_id, alloc, section_name) } }; @@ -360,12 +373,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu // Don't push a `TodoItem::Static` here, as it will cause statics used by // multiple crates to be duplicated between them. It isn't necessary anyway, // as it will get pushed by `codegen_static` when necessary. - data_id_for_static( - tcx, - module, - def_id, - crate::linkage::get_static_ref_linkage(tcx, def_id), - ) + data_id_for_static(tcx, module, def_id, false) } }; diff --git a/src/linkage.rs b/src/linkage.rs index 379c39ca63700..23940c33f1fea 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -11,7 +11,7 @@ pub(crate) fn get_clif_linkage(mono_item: MonoItem<'_>, linkage: RLinkage, visib } } -pub(crate) fn get_static_ref_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage { +pub(crate) fn get_static_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage { let fn_attrs = tcx.codegen_fn_attrs(def_id); if let Some(linkage) = fn_attrs.linkage { @@ -22,6 +22,10 @@ pub(crate) fn get_static_ref_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage _ => panic!("{:?}", linkage), } } else { - Linkage::Import + if tcx.is_reachable_non_generic(def_id) { + Linkage::Export + } else { + Linkage::Export // FIXME use Linkage::Hidden + } } } From e64f523b2750ef8275ad9d1625afab6d9707898a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 20 Aug 2020 16:51:01 +0200 Subject: [PATCH 1461/1566] Evaluate all mir.required_consts and report any errors Fixes #981 --- src/base.rs | 2 ++ src/constant.rs | 26 +++++++++++++++++++++++++- src/lib.rs | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 83e13265d054d..eed96598b1ec4 100644 --- a/src/base.rs +++ b/src/base.rs @@ -157,6 +157,8 @@ pub(crate) fn verify_func(tcx: TyCtxt<'_>, writer: &crate::pretty_clif::CommentW } fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { + crate::constant::check_constants(fx); + for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { let block = fx.get_block(bb); fx.bcx.switch_to_block(block); diff --git a/src/constant.rs b/src/constant.rs index 0ed05c56d7439..b5c9b92100dcf 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,8 +1,9 @@ use rustc_span::DUMMY_SP; +use rustc_errors::ErrorReported; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::{ - read_target_uint, AllocId, Allocation, ConstValue, GlobalAlloc, Pointer, Scalar, + read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Pointer, Scalar, }; use rustc_middle::ty::{Const, ConstKind}; use rustc_target::abi::Align; @@ -34,6 +35,29 @@ impl ConstantCx { } } +pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Backend>) { + for constant in &fx.mir.required_consts { + let const_ = fx.monomorphize(&constant.literal); + match const_.val { + ConstKind::Value(_) => {} + ConstKind::Unevaluated(def, ref substs, promoted) => { + if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + match err { + ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { + fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + } + ErrorHandled::TooGeneric => { + span_bug!(constant.span, "codgen encountered polymorphic constant: {:?}", err); + } + } + } + } + ConstKind::Param(_) | ConstKind::Infer(_) | ConstKind::Bound(_, _) + | ConstKind::Placeholder(_) | ConstKind::Error(_) => unreachable!("{:?}", const_), + } + } +} + pub(crate) fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { constants_cx.todo.push(TodoItem::Static(def_id)); } diff --git a/src/lib.rs b/src/lib.rs index 07b70155f0f21..6394937605a68 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,7 @@ extern crate flate2; #[cfg(feature = "jit")] extern crate libc; +#[macro_use] extern crate rustc_middle; extern crate rustc_codegen_ssa; extern crate rustc_data_structures; From 2a14fb7bf2b107aab0e712b35291514bfbd29a6d Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 11:24:02 +0200 Subject: [PATCH 1462/1566] jit: Add `NULL` as terminating argv --- src/driver/jit.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/driver/jit.rs b/src/driver/jit.rs index b27ad7b438472..129e36f170ac3 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -82,8 +82,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { .chain(args.split(" ")) .map(|arg| CString::new(arg).unwrap()) .collect::>(); - let argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); - // TODO: Rust doesn't care, but POSIX argv has a NULL sentinel at the end + let mut argv = args.iter().map(|arg| arg.as_ptr()).collect::>(); + + // Push a null pointer as a terminating argument. This is required by POSIX and + // useful as some dynamic linkers use it as a marker to jump over. + argv.push(std::ptr::null()); let ret = f(args.len() as c_int, argv.as_ptr()); From a1fc2eb00d74c775d0ce0082e2948b31f8ae1bc7 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 13:43:47 +0200 Subject: [PATCH 1463/1566] linkage: Change linkage to hidden on non-exported symbols --- src/linkage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linkage.rs b/src/linkage.rs index 23940c33f1fea..4307e3592b784 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -25,7 +25,7 @@ pub(crate) fn get_static_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage { if tcx.is_reachable_non_generic(def_id) { Linkage::Export } else { - Linkage::Export // FIXME use Linkage::Hidden + Linkage::Hidden } } } From 5a59c24eeee2097ff64b0578704a5eb7a4dd07f8 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 15:18:10 +0200 Subject: [PATCH 1464/1566] FunctionCx: Store reference to CodegenCx instead --- src/common.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/common.rs b/src/common.rs index 4213158108863..a575f03e350cc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -265,9 +265,7 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool { } pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { - // FIXME use a reference to `CodegenCx` instead of `tcx`, `module` and `constants` and `caches` - pub(crate) tcx: TyCtxt<'tcx>, - pub(crate) module: &'clif mut Module, + pub(crate) codegen_cx: &'clif CodegenCx<'tcx, B>, pub(crate) global_asm: &'clif mut String, pub(crate) pointer_type: Type, // Cached from module @@ -285,7 +283,6 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) cold_blocks: EntitySet, pub(crate) clif_comments: crate::pretty_clif::CommentWriter, - pub(crate) constants_cx: &'clif mut crate::constant::ConstantCx, pub(crate) vtables: &'clif mut FxHashMap<(Ty<'tcx>, Option>), DataId>, pub(crate) source_info_set: indexmap::IndexSet, From 297d65c247511a1415975d6a1d850f9484a6f3c0 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 15:18:39 +0200 Subject: [PATCH 1465/1566] FunctionCx: WIP: Replace .tcx with .codegen_cx.tcx --- src/abi/mod.rs | 50 +++++++++++++------------- src/abi/pass_mode.rs | 6 ++-- src/abi/returning.rs | 6 ++-- src/analyze.rs | 4 +-- src/base.rs | 74 +++++++++++++++++++------------------- src/cast.rs | 16 ++++----- src/codegen_i128.rs | 42 +++++++++++----------- src/common.rs | 24 ++++++------- src/constant.rs | 28 +++++++-------- src/debuginfo/line_info.rs | 4 +-- src/debuginfo/mod.rs | 8 ++--- src/debuginfo/unwind.rs | 4 +-- src/discriminant.rs | 4 +-- src/driver/mod.rs | 8 ++--- src/inline_asm.rs | 2 +- src/intrinsics/llvm.rs | 6 ++-- src/intrinsics/mod.rs | 38 ++++++++++---------- src/intrinsics/simd.rs | 26 +++++++------- src/lib.rs | 2 +- src/num.rs | 16 ++++----- src/trap.rs | 4 +-- src/unsize.rs | 4 +-- src/value_and_place.rs | 32 ++++++++--------- src/vtable.rs | 30 ++++++++-------- 24 files changed, 219 insertions(+), 219 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index fcf05be865399..c2af33215c166 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -226,7 +226,7 @@ pub(crate) fn import_function<'tcx>( impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let func_id = import_function(self.tcx, self.module, inst); + let func_id = import_function(selfcodegen_cx.tcx, self.module, inst); let func_ref = self .module .declare_func_in_func(func_id, &mut self.bcx.func); @@ -374,9 +374,9 @@ pub(crate) fn codegen_fn_prelude<'tcx>( .collect::, Ty<'tcx>)>>(); assert!(fx.caller_location.is_none()); - if fx.instance.def.requires_caller_location(fx.tcx) { + if fx.instance.def.requires_caller_location(fxcodegen_cx.tcx) { // Store caller location for `#[track_caller]`. - fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.tcx.caller_location_ty()).unwrap()); + fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fxcodegen_cx.tcx.caller_location_ty()).unwrap()); } fx.bcx.switch_to_block(start_block); @@ -398,7 +398,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( let local_decl = &fx.mir.local_decls[local]; // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( - fx.tcx.at(local_decl.source_info.span), + fxcodegen_cx.tcx.at(local_decl.source_info.span), ParamEnv::reveal_all(), ); if local_decl.mutability == mir::Mutability::Not && !internally_mutable { @@ -465,24 +465,24 @@ pub(crate) fn codegen_terminator_call<'tcx>( args: &[Operand<'tcx>], destination: Option<(Place<'tcx>, BasicBlock)>, ) { - let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); + let fn_ty = fx.monomorphize(&func.ty(fx.mir, fxcodegen_cx.tcx)); let fn_sig = fx - .tcx - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); + codegen_cx.tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fxcodegen_cx.tcx)); let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); // Handle special calls like instrinsics 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) + let instance = ty::Instance::resolve(fxcodegen_cx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) .unwrap() .unwrap() - .polymorphize(fx.tcx); + .polymorphize(fxcodegen_cx.tcx); - if fx.tcx.symbol_name(instance).name.starts_with("llvm.") { + if fxcodegen_cx.tcx.symbol_name(instance).name.starts_with("llvm.") { crate::intrinsics::codegen_llvm_intrinsic_call( fx, - &fx.tcx.symbol_name(instance).name, + &fxcodegen_cx.tcx.symbol_name(instance).name, substs, args, destination, @@ -510,7 +510,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let is_cold = instance.map(|inst| - fx.tcx.codegen_fn_attrs(inst.def_id()) + fxcodegen_cx.tcx.codegen_fn_attrs(inst.def_id()) .flags.contains(CodegenFnAttrFlags::COLD)) .unwrap_or(false); if is_cold { @@ -558,7 +558,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( nop_inst, format!( "virtual call; self arg pass mode: {:?}", - get_pass_mode(fx.tcx, args[0].layout()) + get_pass_mode(fxcodegen_cx.tcx, args[0].layout()) ), ); } @@ -608,7 +608,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( ) .collect::>(); - if instance.map(|inst| inst.def.requires_caller_location(fx.tcx)).unwrap_or(false) { + if instance.map(|inst| inst.def.requires_caller_location(fxcodegen_cx.tcx)).unwrap_or(false) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); @@ -616,7 +616,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let call_inst = if let Some(func_ref) = func_ref { let sig = clif_sig_from_fn_sig( - fx.tcx, + fxcodegen_cx.tcx, fx.triple(), fn_sig, span, @@ -637,7 +637,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { if fn_sig.abi != Abi::C { - fx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); + fxcodegen_cx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); let abi_params = call_args @@ -646,7 +646,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - fx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); + fxcodegen_cx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); } AbiParam::new(ty) }) @@ -668,17 +668,17 @@ pub(crate) fn codegen_drop<'tcx>( drop_place: CPlace<'tcx>, ) { let ty = drop_place.layout().ty; - let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty).polymorphize(fx.tcx); + let drop_fn = Instance::resolve_drop_in_place(fxcodegen_cx.tcx, ty).polymorphize(fxcodegen_cx.tcx); if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything } else { - let drop_fn_ty = drop_fn.ty(fx.tcx, ParamEnv::reveal_all()); - let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( + let drop_fn_ty = drop_fn.ty(fxcodegen_cx.tcx, ParamEnv::reveal_all()); + let fn_sig = fxcodegen_cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &drop_fn_ty.fn_sig(fx.tcx), + &drop_fn_ty.fn_sig(fxcodegen_cx.tcx), ); - assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); + assert_eq!(fn_sig.output(), fxcodegen_cx.tcx.mk_unit()); match ty.kind { ty::Dynamic(..) => { @@ -687,7 +687,7 @@ pub(crate) fn codegen_drop<'tcx>( let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); let sig = clif_sig_from_fn_sig( - fx.tcx, + fxcodegen_cx.tcx, fx.triple(), fn_sig, span, @@ -702,7 +702,7 @@ pub(crate) fn codegen_drop<'tcx>( let arg_place = CPlace::new_stack_slot( fx, - fx.layout_of(fx.tcx.mk_ref( + fx.layout_of(fxcodegen_cx.tcx.mk_ref( &ty::RegionKind::ReErased, TypeAndMut { ty, @@ -716,7 +716,7 @@ pub(crate) fn codegen_drop<'tcx>( let mut call_args: Vec = arg_value.into_iter().collect::>(); - if drop_fn.def.requires_caller_location(fx.tcx) { + if drop_fn.def.requires_caller_location(fxcodegen_cx.tcx) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 02604a3757201..fd2ec94f29b49 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -118,7 +118,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, ) -> EmptySinglePair { - match get_pass_mode(fx.tcx, arg.layout()) { + match get_pass_mode(fxcodegen_cx.tcx, arg.layout()) { PassMode::NoPass => Empty, PassMode::ByVal(_) => Single(arg.load_scalar(fx)), PassMode::ByValPair(_, _) => { @@ -144,13 +144,13 @@ pub(super) fn cvalue_for_param<'tcx>( arg_ty: Ty<'tcx>, ) -> Option> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.tcx, layout); + let pass_mode = get_pass_mode(fxcodegen_cx.tcx, layout); if let PassMode::NoPass = pass_mode { return None; } - let clif_types = pass_mode.get_param_ty(fx.tcx); + let clif_types = pass_mode.get_param_ty(fxcodegen_cx.tcx); let block_params = clif_types.map(|t| fx.bcx.append_block_param(start_block, t)); #[cfg(debug_assertions)] diff --git a/src/abi/returning.rs b/src/abi/returning.rs index e445a12b2a882..05144e2a565cc 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -19,7 +19,7 @@ pub(super) fn codegen_return_param( start_block: Block, ) { let ret_layout = return_layout(fx); - let ret_pass_mode = get_pass_mode(fx.tcx, ret_layout); + let ret_pass_mode = get_pass_mode(fxcodegen_cx.tcx, ret_layout); let ret_param = match ret_pass_mode { PassMode::NoPass => { fx.local_map @@ -66,7 +66,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( ) -> (Inst, T) { let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fx.tcx, ret_layout); + let output_pass_mode = get_pass_mode(fxcodegen_cx.tcx, ret_layout); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef { size: Some(_)} => match ret_place { @@ -102,7 +102,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( } pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { - match get_pass_mode(fx.tcx, return_layout(fx)) { + match get_pass_mode(fxcodegen_cx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { size: Some(_) } => { fx.bcx.ins().return_(&[]); } diff --git a/src/analyze.rs b/src/analyze.rs index 7bd2c802868df..5e9e88b7980dd 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -35,8 +35,8 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { if let Some((dest_place, _dest_bb)) = destination { - let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty)); - if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) { + let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fxcodegen_cx.tcx).ty)); + if !crate::abi::can_return_to_ssa_var(fxcodegen_cx.tcx, dest_layout) { not_ssa(&mut flag_map, dest_place.local) } } diff --git a/src/base.rs b/src/base.rs index eed96598b1ec4..767e838e61eb8 100644 --- a/src/base.rs +++ b/src/base.rs @@ -8,7 +8,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( instance: Instance<'tcx>, linkage: Linkage, ) { - let tcx = cx.tcx; + let tcx = cxcodegen_cx.tcx; let mir = tcx.instance_mir(instance.def); @@ -78,7 +78,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let cold_blocks = fx.cold_blocks; crate::pretty_clif::write_clif_file( - cx.tcx, + cxcodegen_cx.tcx, "unopt", None, instance, @@ -113,7 +113,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Write optimized function to file for debugging crate::pretty_clif::write_clif_file( - cx.tcx, + cxcodegen_cx.tcx, "opt", Some(cx.module.isa()), instance, @@ -224,7 +224,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { target, cleanup: _, } => { - if !fx.tcx.sess.overflow_checks() { + if !fxcodegen_cx.tcx.sess.overflow_checks() { if let mir::AssertKind::OverflowNeg(_) = *msg { let target = fx.get_block(*target); fx.bcx.ins().jump(target, &[]); @@ -265,12 +265,12 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } }; - let def_id = fx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { - fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) + let def_id = fxcodegen_cx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { + fxcodegen_cx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) }); - let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); - let symbol_name = fx.tcx.symbol_name(instance).name; + let instance = Instance::mono(fxcodegen_cx.tcx, def_id).polymorphize(fxcodegen_cx.tcx); + let symbol_name = fxcodegen_cx.tcx.symbol_name(instance).name; fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); @@ -300,7 +300,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, from_hir_call: _, } => { - fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( + fxcodegen_cx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, *fn_span, block, @@ -419,7 +419,7 @@ fn trans_stmt<'tcx>( let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let res = if !fx.tcx.sess.overflow_checks() { + let res = if !fxcodegen_cx.tcx.sess.overflow_checks() { let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); @@ -465,14 +465,14 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, res); } Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, to_ty) => { - let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)); + let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fxcodegen_cx.tcx)); let to_layout = fx.layout_of(fx.monomorphize(to_ty)); match from_ty.kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( - Instance::resolve_for_fn_ptr(fx.tcx, ParamEnv::reveal_all(), def_id, substs) + Instance::resolve_for_fn_ptr(fxcodegen_cx.tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap() - .polymorphize(fx.tcx), + .polymorphize(fxcodegen_cx.tcx), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, to_layout)); @@ -501,7 +501,7 @@ fn trans_stmt<'tcx>( |ty::TypeAndMut { ty: pointee_ty, mutbl: _, - }| has_ptr_meta(fx.tcx, pointee_ty), + }| has_ptr_meta(fxcodegen_cx.tcx, pointee_ty), ) .unwrap_or(false) } @@ -527,7 +527,7 @@ fn trans_stmt<'tcx>( match &operand.layout().variants { Variants::Single { index } => { - let discr = operand.layout().ty.discriminant_for_variant(fx.tcx, *index).unwrap(); + let discr = operand.layout().ty.discriminant_for_variant(fxcodegen_cx.tcx, *index).unwrap(); let discr = if discr.ty.is_signed() { rustc_middle::mir::interpret::sign_extend(discr.val, fx.layout_of(discr.ty).size) } else { @@ -579,11 +579,11 @@ fn trans_stmt<'tcx>( match operand.layout().ty.kind { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( - fx.tcx, + fxcodegen_cx.tcx, def_id, substs, ty::ClosureKind::FnOnce, - ).polymorphize(fx.tcx); + ).polymorphize(fxcodegen_cx.tcx); let func_ref = fx.get_function_ref(instance); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); @@ -606,9 +606,9 @@ fn trans_stmt<'tcx>( let operand = trans_operand(fx, operand); let times = fx .monomorphize(times) - .eval(fx.tcx, ParamEnv::reveal_all()) + .eval(fxcodegen_cx.tcx, ParamEnv::reveal_all()) .val - .try_to_bits(fx.tcx.data_layout.pointer_size) + .try_to_bits(fxcodegen_cx.tcx.data_layout.pointer_size) .unwrap(); for i in 0..times { let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); @@ -618,14 +618,14 @@ fn trans_stmt<'tcx>( } Rvalue::Len(place) => { let place = trans_place(fx, *place); - let usize_layout = fx.layout_of(fx.tcx.types.usize); + let usize_layout = fx.layout_of(fxcodegen_cx.tcx.types.usize); let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { use rustc_hir::lang_items::ExchangeMallocFnLangItem; - let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); + let usize_type = fx.clif_type(fxcodegen_cx.tcx.types.usize).unwrap(); let content_ty = fx.monomorphize(content_ty); let layout = fx.layout_of(content_ty); let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64); @@ -633,18 +633,18 @@ fn trans_stmt<'tcx>( .bcx .ins() .iconst(usize_type, layout.align.abi.bytes() as i64); - let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty)); + let box_layout = fx.layout_of(fxcodegen_cx.tcx.mk_box(content_ty)); // Allocate space: - let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) { + let def_id = match fxcodegen_cx.tcx.lang_items().require(ExchangeMallocFnLangItem) { Ok(id) => id, Err(s) => { - fx.tcx + fxcodegen_cx.tcx .sess .fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); } }; - let instance = ty::Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); + let instance = ty::Instance::mono(fxcodegen_cx.tcx, def_id).polymorphize(fxcodegen_cx.tcx); let func_ref = fx.get_function_ref(instance); let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); let ptr = fx.bcx.inst_results(call)[0]; @@ -654,9 +654,9 @@ fn trans_stmt<'tcx>( assert!(lval .layout() .ty - .is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); + .is_sized(fxcodegen_cx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); - let val = CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), ty_size.into()); + let val = CValue::const_val(fx, fx.layout_of(fxcodegen_cx.tcx.types.usize), ty_size.into()); lval.write_cvalue(fx, val); } Rvalue::Aggregate(kind, operands) => match **kind { @@ -721,10 +721,10 @@ fn trans_stmt<'tcx>( let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); assert_eq!(outputs.len(), 4); - trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fxcodegen_cx.tcx.types.u32))); + trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fxcodegen_cx.tcx.types.u32))); + trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fxcodegen_cx.tcx.types.u32))); + trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fxcodegen_cx.tcx.types.u32))); } "xgetbv" => { assert_eq!(input_names, &[Symbol::intern("{ecx}")]); @@ -744,17 +744,17 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } // ___chkstk, ___chkstk_ms and __alloca are only used on Windows - _ if fx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { + _ if fxcodegen_cx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { crate::trap::trap_unimplemented(fx, "Stack probes are not supported"); } - _ if fx.tcx.symbol_name(fx.instance).name == "__alloca" => { + _ if fxcodegen_cx.tcx.symbol_name(fx.instance).name == "__alloca" => { crate::trap::trap_unimplemented(fx, "Alloca is not supported"); } // Used in sys::windows::abort_internal "int $$0x29" => { crate::trap::trap_unimplemented(fx, "Windows abort"); } - _ => fx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), + _ => fxcodegen_cx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), } } } @@ -767,8 +767,8 @@ fn codegen_array_len<'tcx>( match place.layout().ty.kind { ty::Array(_elem_ty, len) => { let len = fx.monomorphize(&len) - .eval(fx.tcx, ParamEnv::reveal_all()) - .eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64; + .eval(fxcodegen_cx.tcx, ParamEnv::reveal_all()) + .eval_usize(fxcodegen_cx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place @@ -821,7 +821,7 @@ pub(crate) fn trans_place<'tcx>( let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), - fx.layout_of(fx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), + fx.layout_of(fxcodegen_cx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), ); } ty::Slice(elem_ty) => { diff --git a/src/cast.rs b/src/cast.rs index 36e060496b1da..acec7add7f01c 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -86,14 +86,14 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = if from_signed { - fx.tcx.types.i128 + fxcodegen_cx.tcx.types.i128 } else { - fx.tcx.types.u128 + fxcodegen_cx.tcx.types.u128 }; let to_rust_ty = match to_ty { - types::F32 => fx.tcx.types.f32, - types::F64 => fx.tcx.types.f64, + types::F32 => fxcodegen_cx.tcx.types.f32, + types::F64 => fxcodegen_cx.tcx.types.f64, _ => unreachable!(), }; @@ -131,15 +131,15 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = match from_ty { - types::F32 => fx.tcx.types.f32, - types::F64 => fx.tcx.types.f64, + types::F32 => fxcodegen_cx.tcx.types.f32, + types::F64 => fxcodegen_cx.tcx.types.f64, _ => unreachable!(), }; let to_rust_ty = if to_signed { - fx.tcx.types.i128 + fxcodegen_cx.tcx.types.i128 } else { - fx.tcx.types.u128 + fxcodegen_cx.tcx.types.u128 }; return fx diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index e2bb5b17ba2d3..c2fa7cf373e5f 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -9,7 +9,7 @@ pub(crate) fn maybe_codegen<'tcx>( lhs: CValue<'tcx>, rhs: CValue<'tcx>, ) -> Option> { - if lhs.layout().ty != fx.tcx.types.u128 && lhs.layout().ty != fx.tcx.types.i128 { + if lhs.layout().ty != fxcodegen_cx.tcx.types.u128 && lhs.layout().ty != fxcodegen_cx.tcx.types.i128 { return None; } @@ -25,7 +25,7 @@ pub(crate) fn maybe_codegen<'tcx>( } BinOp::Add | BinOp::Sub if !checked => return None, BinOp::Add => { - let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); + let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty) } else { @@ -33,7 +33,7 @@ pub(crate) fn maybe_codegen<'tcx>( }); } BinOp::Sub => { - let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); + let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty) } else { @@ -43,7 +43,7 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { let res = if checked { - let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); + let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); if is_signed { fx.easy_call("__rust_i128_mulo", &[lhs, rhs], out_ty) } else { @@ -51,9 +51,9 @@ pub(crate) fn maybe_codegen<'tcx>( } } else { let val_ty = if is_signed { - fx.tcx.types.i128 + fxcodegen_cx.tcx.types.i128 } else { - fx.tcx.types.u128 + fxcodegen_cx.tcx.types.u128 }; fx.easy_call("__multi3", &[lhs, rhs], val_ty) }; @@ -62,17 +62,17 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Div => { assert!(!checked); if is_signed { - Some(fx.easy_call("__divti3", &[lhs, rhs], fx.tcx.types.i128)) + Some(fx.easy_call("__divti3", &[lhs, rhs], fxcodegen_cx.tcx.types.i128)) } else { - Some(fx.easy_call("__udivti3", &[lhs, rhs], fx.tcx.types.u128)) + Some(fx.easy_call("__udivti3", &[lhs, rhs], fxcodegen_cx.tcx.types.u128)) } } BinOp::Rem => { assert!(!checked); if is_signed { - Some(fx.easy_call("__modti3", &[lhs, rhs], fx.tcx.types.i128)) + Some(fx.easy_call("__modti3", &[lhs, rhs], fxcodegen_cx.tcx.types.i128)) } else { - Some(fx.easy_call("__umodti3", &[lhs, rhs], fx.tcx.types.u128)) + Some(fx.easy_call("__umodti3", &[lhs, rhs], fxcodegen_cx.tcx.types.u128)) } } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { @@ -104,7 +104,7 @@ pub(crate) fn maybe_codegen<'tcx>( let val = match (bin_op, is_signed) { (BinOp::Shr, false) => { let val = fx.bcx.ins().iconcat(lhs_msb, all_zeros); - Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.u128))) + Some(CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.u128))) } (BinOp::Shr, true) => { let sign = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, lhs_msb, 0); @@ -112,13 +112,13 @@ pub(crate) fn maybe_codegen<'tcx>( let all_sign_bits = fx.bcx.ins().select(sign, all_zeros, all_ones); let val = fx.bcx.ins().iconcat(lhs_msb, all_sign_bits); - Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.i128))) + Some(CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.i128))) } (BinOp::Shl, _) => { let val_ty = if is_signed { - fx.tcx.types.i128 + fxcodegen_cx.tcx.types.i128 } else { - fx.tcx.types.u128 + fxcodegen_cx.tcx.types.u128 }; let val = fx.bcx.ins().iconcat(all_zeros, lhs_lsb); Some(CValue::by_val(val, fx.layout_of(val_ty))) @@ -127,7 +127,7 @@ pub(crate) fn maybe_codegen<'tcx>( }; if let Some(val) = val { if let Some(is_overflow) = is_overflow { - let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); + let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); let val = val.load_scalar(fx); return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))); } else { @@ -137,24 +137,24 @@ pub(crate) fn maybe_codegen<'tcx>( } let truncated_rhs = clif_intcast(fx, rhs_val, types::I32, false); - let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fx.tcx.types.u32)); + let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fxcodegen_cx.tcx.types.u32)); let val = match (bin_op, is_signed) { (BinOp::Shl, false) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.tcx.types.u128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.u128) } (BinOp::Shl, true) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.tcx.types.i128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.i128) } (BinOp::Shr, false) => { - fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fx.tcx.types.u128) + fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.u128) } (BinOp::Shr, true) => { - fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fx.tcx.types.i128) + fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.i128) } (_, _) => unreachable!(), }; if let Some(is_overflow) = is_overflow { - let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); + let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); let val = val.load_scalar(fx); Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) } else { diff --git a/src/common.rs b/src/common.rs index a575f03e350cc..f8c26c54ae006 100644 --- a/src/common.rs +++ b/src/common.rs @@ -299,11 +299,11 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { assert!(!ty.still_further_specializable()); - self.tcx + selfcodegen_cx.tcx .layout_of(ParamEnv::reveal_all().and(&ty)) .unwrap_or_else(|e| { if let layout::LayoutError::SizeOverflow(_) = e { - self.tcx.sess.fatal(&e.to_string()) + selfcodegen_cx.tcx.sess.fatal(&e.to_string()) } else { bug!("failed to get layout for `{}`: {}", ty, e) } @@ -313,13 +313,13 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend + 'static> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx, B> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { - self.tcx + selfcodegen_cx.tcx } } impl<'tcx, B: Backend + 'static> rustc_target::abi::HasDataLayout for FunctionCx<'_, 'tcx, B> { fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { - &self.tcx.data_layout + &selfcodegen_cx.tcx.data_layout } } @@ -331,7 +331,7 @@ impl<'tcx, B: Backend + 'static> layout::HasParamEnv<'tcx> for FunctionCx<'_, 't impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { fn target_spec(&self) -> &Target { - &self.tcx.sess.target.target + &selfcodegen_cx.tcx.sess.target.target } } @@ -341,22 +341,22 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { T: TypeFoldable<'tcx> + Copy, { if let Some(substs) = self.instance.substs_for_mir_body() { - self.tcx.subst_and_normalize_erasing_regions( + selfcodegen_cx.tcx.subst_and_normalize_erasing_regions( substs, ty::ParamEnv::reveal_all(), value, ) } else { - self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) + selfcodegen_cx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) } } pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option { - clif_type_from_ty(self.tcx, ty) + clif_type_from_ty(selfcodegen_cx.tcx, ty) } pub(crate) fn clif_pair_type(&self, ty: Ty<'tcx>) -> Option<(Type, Type)> { - clif_pair_type_from_ty(self.tcx, ty) + clif_pair_type_from_ty(selfcodegen_cx.tcx, ty) } pub(crate) fn get_block(&self, bb: BasicBlock) -> Block { @@ -381,8 +381,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); - let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo()); - let const_loc = self.tcx.const_caller_location(( + let caller = selfcodegen_cx.tcx.sess.source_map().lookup_char_pos(topmost.lo()); + let const_loc = selfcodegen_cx.tcx.const_caller_location(( rustc_span::symbol::Symbol::intern(&caller.file.name.to_string()), caller.line as u32, caller.col_display as u32 + 1, @@ -390,7 +390,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { crate::constant::trans_const_value( self, const_loc, - self.tcx.caller_location_ty(), + selfcodegen_cx.tcx.caller_location_ty(), ) } diff --git a/src/constant.rs b/src/constant.rs index b5c9b92100dcf..a695b26d1b796 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -41,10 +41,10 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Backend>) { match const_.val { ConstKind::Value(_) => {} ConstKind::Unevaluated(def, ref substs, promoted) => { - if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + if let Err(err) = fxcodegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { match err { ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { - fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fxcodegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } ErrorHandled::TooGeneric => { span_bug!(constant.span, "codgen encountered polymorphic constant: {:?}", err); @@ -67,7 +67,7 @@ pub(crate) fn codegen_tls_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { - let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false); + let data_id = data_id_for_static(fxcodegen_cx.tcx, fx.module, def_id, false); 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)); @@ -80,7 +80,7 @@ fn codegen_static_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false); + let data_id = data_id_for_static(fxcodegen_cx.tcx, fx.module, def_id, false); 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)); @@ -97,7 +97,7 @@ pub(crate) fn trans_constant<'tcx>( let const_ = fx.monomorphize(&constant.literal); let const_val = match const_.val { ConstKind::Value(const_val) => const_val, - ConstKind::Unevaluated(def, ref substs, promoted) if fx.tcx.is_static(def.did) => { + ConstKind::Unevaluated(def, ref substs, promoted) if fxcodegen_cx.tcx.is_static(def.did) => { assert!(substs.is_empty()); assert!(promoted.is_none()); @@ -108,11 +108,11 @@ pub(crate) fn trans_constant<'tcx>( ).to_cvalue(fx); } ConstKind::Unevaluated(def, ref substs, promoted) => { - match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + match fxcodegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { Ok(const_val) => const_val, Err(_) => { if promoted.is_none() { - fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fxcodegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } return crate::trap::trap_unreachable_ret_value( fx, @@ -154,7 +154,7 @@ pub(crate) fn trans_const_value<'tcx>( ); let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used alloc.write_scalar(fx, ptr, x.into(), size).unwrap(); - let alloc = fx.tcx.intern_const_alloc(alloc); + let alloc = fxcodegen_cx.tcx.intern_const_alloc(alloc); return CValue::by_ref(pointer_for_allocation(fx, alloc), layout); } @@ -164,7 +164,7 @@ pub(crate) fn trans_const_value<'tcx>( return CValue::const_val(fx, layout, data); } Scalar::Ptr(ptr) => { - let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id); + let alloc_kind = fxcodegen_cx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); @@ -175,13 +175,13 @@ pub(crate) fn trans_const_value<'tcx>( fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { - let func_id = crate::abi::import_function(fx.tcx, fx.module, instance); + let func_id = crate::abi::import_function(fxcodegen_cx.tcx, fx.module, instance); let local_func_id = fx.module.declare_func_in_func(func_id, &mut fx.bcx.func); fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) } Some(GlobalAlloc::Static(def_id)) => { - assert!(fx.tcx.is_static(def_id)); - let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false); + assert!(fxcodegen_cx.tcx.is_static(def_id)); + let data_id = data_id_for_static(fxcodegen_cx.tcx, fx.module, def_id, false); 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)); @@ -215,7 +215,7 @@ fn pointer_for_allocation<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { - let alloc_id = fx.tcx.create_memory_alloc(alloc); + let alloc_id = fxcodegen_cx.tcx.create_memory_alloc(alloc); fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align, alloc.mutability); @@ -419,7 +419,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( match operand { Operand::Copy(_) | Operand::Move(_) => None, Operand::Constant(const_) => { - Some(fx.monomorphize(&const_.literal).eval(fx.tcx, ParamEnv::reveal_all())) + Some(fx.monomorphize(&const_.literal).eval(fxcodegen_cx.tcx, ParamEnv::reveal_all())) } } } diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 89dccb8545fc6..1ceb8b4af2417 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -95,7 +95,7 @@ fn line_program_add_file( impl<'tcx> DebugContext<'tcx> { pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { - let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo()); + let loc = selfcodegen_cx.tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file( &mut self.dwarf.unit.line_program, @@ -129,7 +129,7 @@ impl<'tcx> DebugContext<'tcx> { function_span: Span, source_info_set: &indexmap::IndexSet, ) -> CodeOffset { - let tcx = self.tcx; + let tcx = selfcodegen_cx.tcx; let line_program = &mut self.dwarf.unit.line_program; let func = &context.func; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 2c92fd0e47cc3..7385eb296d250 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -165,7 +165,7 @@ impl<'tcx> DebugContext<'tcx> { }; let name = format!("{}", ty); - let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + let layout = selfcodegen_cx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); let type_id = match ty.kind { ty::Bool => primitive(&mut self.dwarf, gimli::DW_ATE_boolean), @@ -203,7 +203,7 @@ impl<'tcx> DebugContext<'tcx> { for (field_idx, field_def) in variant.fields.iter().enumerate() { let field_offset = layout.fields.offset(field_idx); let field_layout = layout.field(&layout::LayoutCx { - tcx: self.tcx, + tcx: selfcodegen_cx.tcx, param_env: ParamEnv::reveal_all(), }, field_idx).unwrap(); @@ -261,7 +261,7 @@ impl<'tcx> DebugContext<'tcx> { local_map: FxHashMap>, ) { let symbol = func_id.as_u32() as usize; - let mir = self.tcx.instance_mir(instance.def); + let mir = selfcodegen_cx.tcx.instance_mir(instance.def); // FIXME: add to appropriate scope instead of root let scope = self.dwarf.unit.root(); @@ -336,7 +336,7 @@ impl<'tcx> DebugContext<'tcx> { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); for (local, _local_decl) in mir.local_decls.iter_enumerated() { - let ty = self.tcx.subst_and_normalize_erasing_regions( + let ty = selfcodegen_cx.tcx.subst_and_normalize_erasing_regions( instance.substs, ty::ParamEnv::reveal_all(), &mir.local_decls[local].ty, diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 4bc3859652db2..06beda1da3f80 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -54,7 +54,7 @@ impl<'tcx> UnwindContext<'tcx> { } pub(crate) fn emit(self, product: &mut P) { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(selfcodegen_cx.tcx))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if !eh_frame.0.writer.slice().is_empty() { @@ -74,7 +74,7 @@ impl<'tcx> UnwindContext<'tcx> { self, jit_module: &mut Module, ) -> Option { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(selfcodegen_cx.tcx))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if eh_frame.0.writer.slice().is_empty() { diff --git a/src/discriminant.rs b/src/discriminant.rs index d15d74225716e..89568e2344a1a 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -26,7 +26,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( let ptr = place.place_field(fx, mir::Field::new(tag_field)); let to = layout .ty - .discriminant_for_variant(fx.tcx, variant_index) + .discriminant_for_variant(fxcodegen_cx.tcx, variant_index) .unwrap() .val; let discr = CValue::const_val(fx, ptr.layout(), to); @@ -73,7 +73,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>( Variants::Single { index } => { let discr_val = layout .ty - .discriminant_for_variant(fx.tcx, *index) + .discriminant_for_variant(fxcodegen_cx.tcx, *index) .map_or(u128::from(index.as_u32()), |discr| discr.val); return CValue::const_val(fx, dest_layout, discr_val); } diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 1d81efb880df7..fce702f86b951 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -33,12 +33,12 @@ fn codegen_mono_items<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Backend + 'static>, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { - cx.tcx.sess.time("predefine functions", || { + cxcodegen_cx.tcx.sess.time("predefine functions", || { for &(mono_item, (linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = - get_function_name_and_sig(cx.tcx, cx.module.isa().triple(), instance, false); + get_function_name_and_sig(cxcodegen_cx.tcx, cx.module.isa().triple(), instance, false); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); cx.module.declare_function(&name, linkage, &sig).unwrap(); } @@ -58,7 +58,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( mono_item: MonoItem<'tcx>, linkage: Linkage, ) { - let tcx = cx.tcx; + let tcx = cxcodegen_cx.tcx; match mono_item { MonoItem::Fn(inst) => { let _inst_guard = @@ -85,7 +85,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( } }); - cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); + cxcodegen_cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 4c3fe87dae3dd..80cbae1a72020 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -70,7 +70,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( let inline_asm_index = fx.inline_asm_index; fx.inline_asm_index += 1; - let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, inline_asm_index); + let asm_name = format!("{}__inline_asm_{}", fxcodegen_cx.tcx.symbol_name(fx.instance).name, inline_asm_index); let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); fx.global_asm.push_str(&generated_asm); diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index c85daaa0e2e3d..8e8665f780343 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -30,13 +30,13 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); + fxcodegen_cx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); crate::trap::trap_unimplemented(fx, intrinsic); }; // Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8` llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb | llvm.x86.sse2.movmsk.pd, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, a.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, a.layout()); let lane_ty = fx.clif_type(lane_layout.ty).unwrap(); assert!(lane_count <= 32); @@ -61,7 +61,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( res = fx.bcx.ins().bor(res, a_lane_sign); } - let res = CValue::by_val(res, fx.layout_of(fx.tcx.types.i32)); + let res = CValue::by_val(res, fx.layout_of(fxcodegen_cx.tcx.types.i32)); ret.write_cvalue(fx, res); }; llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) { diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 488c08815bace..56dd171eeceb0 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -88,7 +88,7 @@ macro call_intrinsic_match { let ($($arg,)*) = ( $(trans_operand($fx, $arg),)* ); - let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty); + let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fxcodegen_cx.tcx.types.$ty); $ret.write_cvalue($fx, res); if let Some((_, dest)) = $destination { @@ -144,7 +144,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { match $ty.kind { ty::Uint(_) | ty::Int(_) => {} _ => { - $fx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); + $fxcodegen_cx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -154,7 +154,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { macro validate_simd_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { if !$ty.is_simd() { - $fx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); + $fxcodegen_cx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -203,8 +203,8 @@ fn simd_for_each_lane<'tcx, B: Backend>( ) { let layout = val.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane_idx in 0..lane_count { @@ -233,8 +233,8 @@ fn simd_pair_for_each_lane<'tcx, B: Backend>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { @@ -273,7 +273,7 @@ fn bool_to_zero_or_max_uint<'tcx>( macro simd_cmp { ($fx:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { - let vector_ty = clif_vector_type($fx.tcx, $x.layout()); + let vector_ty = clif_vector_type($fxcodegen_cx.tcx, $x.layout()); if let Some(vector_ty) = vector_ty { let x = $x.load_scalar($fx); @@ -390,7 +390,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fx.tcx.item_name(def_id).as_str(); + let intrinsic = fxcodegen_cx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; let ret = match destination { @@ -423,7 +423,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( return; } - let usize_layout = fx.layout_of(fx.tcx.types.usize); + let usize_layout = fx.layout_of(fxcodegen_cx.tcx.types.usize); call_intrinsic_match! { fx, intrinsic, substs, ret, destination, args, @@ -473,7 +473,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); + fxcodegen_cx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); }; assume, (c _a) {}; @@ -684,7 +684,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ctlz | ctlz_nonzero, (v arg) { // FIXME trap on `ctlz_nonzero` with zero arg. - let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { + let res = if T == fxcodegen_cx.tcx.types.u128 || T == fxcodegen_cx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_lz = fx.bcx.ins().clz(lsb); @@ -701,7 +701,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; cttz | cttz_nonzero, (v arg) { // FIXME trap on `cttz_nonzero` with zero arg. - let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { + let res = if T == fxcodegen_cx.tcx.types.u128 || T == fxcodegen_cx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_tz = fx.bcx.ins().ctz(lsb); @@ -842,7 +842,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () { let const_val = - fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); + fxcodegen_cx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); let val = crate::constant::trans_const_value( fx, const_val, @@ -852,7 +852,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ptr_offset_from, (v ptr, v base) { - let isize_layout = fx.layout_of(fx.tcx.types.isize); + let isize_layout = fx.layout_of(fxcodegen_cx.tcx.types.isize); let pointee_size: u64 = fx.layout_of(T).size.bytes(); let diff = fx.bcx.ins().isub(ptr, base); @@ -1011,22 +1011,22 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( minnumf32, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f32)); ret.write_cvalue(fx, val); }; minnumf64, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f64)); ret.write_cvalue(fx, val); }; maxnumf32, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f32)); ret.write_cvalue(fx, val); }; maxnumf64, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f64)); ret.write_cvalue(fx, val); }; diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 92fd00f049c4c..b6e63a52469a3 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -11,13 +11,13 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fx.tcx.item_name(def_id).as_str(); + let intrinsic = fxcodegen_cx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); + fxcodegen_cx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); }; simd_cast, (c a) { @@ -68,8 +68,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_type, lane_count) = lane_type_and_count(fx.tcx, layout); - let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); + let (lane_type, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); + let (ret_lane_type, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); assert_eq!(lane_type, ret_lane_type); assert_eq!(n, ret_lane_count); @@ -92,7 +92,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( (0..ret_lane_count).map(|i| { let i = usize::try_from(i).unwrap(); let idx = rustc_middle::mir::interpret::read_target_uint( - fx.tcx.data_layout.endian, + fxcodegen_cx.tcx.data_layout.endian, &idx_bytes[4*i.. 4*i + 4], ).expect("read_target_uint"); u16::try_from(idx).expect("try_from u32") @@ -119,7 +119,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.tcx.sess.span_warn( + fxcodegen_cx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -128,9 +128,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, base.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, base.layout()); if idx >= lane_count.into() { - fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); + fxcodegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); } ret.write_cvalue(fx, base); @@ -143,7 +143,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.tcx.sess.span_warn( + fxcodegen_cx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -153,9 +153,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, v.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, v.layout()); if idx >= lane_count.into() { - fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); + fxcodegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); } let ret_lane = v.value_field(fx, mir::Field::new(idx.try_into().unwrap())); @@ -205,8 +205,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(a.layout(), c.layout()); let layout = a.layout(); - let (_lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); + let (_lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { diff --git a/src/lib.rs b/src/lib.rs index 6394937605a68..56a57b50b0dc7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,7 +160,7 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { - self.constants_cx.finalize(self.tcx, &mut self.module); + self.constants_cx.finalize(selfcodegen_cx.tcx, &mut self.module); (self.module, self.global_asm, self.debug_context, self.unwind_context) } } diff --git a/src/num.rs b/src/num.rs index 22269b5ee29e5..ef5bd105b1aec 100644 --- a/src/num.rs +++ b/src/num.rs @@ -48,7 +48,7 @@ fn codegen_compare_bin_op<'tcx>( let intcc = crate::num::bin_op_to_intcc(bin_op, signed).unwrap(); let val = fx.bcx.ins().icmp(intcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)) + CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.bool)) } pub(crate) fn codegen_binop<'tcx>( @@ -66,8 +66,8 @@ pub(crate) fn codegen_binop<'tcx>( let rhs = in_rhs.load_scalar(fx); let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (in_lhs.layout().ty.kind == fx.tcx.types.i8.kind - || in_lhs.layout().ty.kind == fx.tcx.types.i16.kind) + && (in_lhs.layout().ty.kind == fxcodegen_cx.tcx.types.i8.kind + || in_lhs.layout().ty.kind == fxcodegen_cx.tcx.types.i16.kind) { // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. ( @@ -118,7 +118,7 @@ pub(crate) fn trans_bool_binop<'tcx>( _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; - CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) + CValue::by_val(res, fx.layout_of(fxcodegen_cx.tcx.types.bool)) } pub(crate) fn trans_int_binop<'tcx>( @@ -323,7 +323,7 @@ pub(crate) fn trans_checked_int_binop<'tcx>( // FIXME directly write to result place instead let out_place = CPlace::new_stack_slot( fx, - fx.layout_of(fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter())), + fx.layout_of(fxcodegen_cx.tcx.mk_tup([in_lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter())), ); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); @@ -368,7 +368,7 @@ pub(crate) fn trans_float_binop<'tcx>( }; let val = fx.bcx.ins().fcmp(fltcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - return CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)); + return CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.bool)); } _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; @@ -383,7 +383,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { let is_thin_ptr = in_lhs.layout().ty.builtin_deref(true).map(|TypeAndMut { ty, mutbl: _}| { - !has_ptr_meta(fx.tcx, ty) + !has_ptr_meta(fxcodegen_cx.tcx, ty) }).unwrap_or(true); if is_thin_ptr { @@ -440,7 +440,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( CValue::by_val( fx.bcx.ins().bint(types::I8, res), - fx.layout_of(fx.tcx.types.bool), + fx.layout_of(fxcodegen_cx.tcx.types.bool), ) } } diff --git a/src/trap.rs b/src/trap.rs index 4b7f64ce0a911..563ac37cda217 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -8,7 +8,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms Linkage::Import, &Signature { call_conv: CallConv::triple_default(fx.triple()), - params: vec![AbiParam::new(pointer_ty(fx.tcx))], + params: vec![AbiParam::new(pointer_ty(fxcodegen_cx.tcx))], returns: vec![AbiParam::new(types::I32)], }, ) @@ -19,7 +19,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms fx.add_comment(puts, "puts"); } - let symbol_name = fx.tcx.symbol_name(fx.instance); + let symbol_name = fxcodegen_cx.tcx.symbol_name(fx.instance); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); let msg_ptr = fx.anonymous_str("trap", &real_msg); fx.bcx.ins().call(puts, &[msg_ptr]); diff --git a/src/unsize.rs b/src/unsize.rs index affb36d7d3712..363186a8c6425 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -15,12 +15,12 @@ pub(crate) fn unsized_info<'tcx>( old_info: Option, ) -> Value { let (source, target) = - fx.tcx + fxcodegen_cx.tcx .struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); match (&source.kind, &target.kind) { (&ty::Array(_, len), &ty::Slice(_)) => fx.bcx.ins().iconst( fx.pointer_type, - len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64, + len.eval_usize(fxcodegen_cx.tcx, ParamEnv::reveal_all()) as i64, ), (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker diff --git a/src/value_and_place.rs b/src/value_and_place.rs index d0e8a4b0c9f24..2e8db1a1e65b8 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -35,10 +35,10 @@ fn codegen_field<'tcx>( let unaligned_offset = field_offset.bytes(); let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout, extra); - let one = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 1); + let one = fx.bcx.ins().iconst(pointer_ty(fxcodegen_cx.tcx), 1); let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); let and_lhs = fx.bcx.ins().iadd_imm(align_sub_1, unaligned_offset as i64); - let zero = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 0); + let zero = fx.bcx.ins().iconst(pointer_ty(fxcodegen_cx.tcx), 0); let and_rhs = fx.bcx.ins().isub(zero, unsized_align); let offset = fx.bcx.ins().band(and_lhs, and_rhs); @@ -119,9 +119,9 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.abi { - Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), + Abi::Scalar(ref scalar) => scalar_to_clif_type(fxcodegen_cx.tcx, scalar.clone()), Abi::Vector { ref element, count } => { - scalar_to_clif_type(fx.tcx, element.clone()) + scalar_to_clif_type(fxcodegen_cx.tcx, element.clone()) .by(u16::try_from(count).unwrap()).unwrap() } _ => unreachable!("{:?}", layout.ty), @@ -146,9 +146,9 @@ impl<'tcx> CValue<'tcx> { Abi::ScalarPair(a, b) => (a, b), _ => unreachable!("load_scalar_pair({:?})", self), }; - let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); - let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); - let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); + let b_offset = scalar_pair_calculate_b_offset(fxcodegen_cx.tcx, a_scalar, b_scalar); + let clif_ty1 = scalar_to_clif_type(fxcodegen_cx.tcx, a_scalar.clone()); + let clif_ty2 = scalar_to_clif_type(fxcodegen_cx.tcx, b_scalar.clone()); let val1 = ptr.load(fx, clif_ty1, MemFlags::new()); let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); (val1, val2) @@ -419,13 +419,13 @@ impl<'tcx> CPlace<'tcx> { assert_assignable(fx, a, b); } (ty::FnPtr(_), ty::FnPtr(_)) => { - let from_sig = fx.tcx.normalize_erasing_late_bound_regions( + let from_sig = fxcodegen_cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &from_ty.fn_sig(fx.tcx), + &from_ty.fn_sig(fxcodegen_cx.tcx), ); - let to_sig = fx.tcx.normalize_erasing_late_bound_regions( + let to_sig = fxcodegen_cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &to_ty.fn_sig(fx.tcx), + &to_ty.fn_sig(fxcodegen_cx.tcx), ); assert_eq!( from_sig, to_sig, @@ -436,10 +436,10 @@ impl<'tcx> CPlace<'tcx> { } (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { let from_traits = fx - .tcx + codegen_cx.tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), from_traits); let to_traits = fx - .tcx + codegen_cx.tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), to_traits); assert_eq!( from_traits, to_traits, @@ -569,7 +569,7 @@ impl<'tcx> CPlace<'tcx> { } Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let (value, extra) = from.load_scalar_pair(fx); - let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); + let b_offset = scalar_pair_calculate_b_offset(fxcodegen_cx.tcx, a_scalar, b_scalar); to_ptr.store(fx, value, MemFlags::new()); to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); return; @@ -673,7 +673,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); - if has_ptr_meta(fx.tcx, inner_layout.ty) { + if has_ptr_meta(fxcodegen_cx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); CPlace::for_ptr_with_extra(Pointer::new(addr), extra, inner_layout) } else { @@ -682,7 +682,7 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - if has_ptr_meta(fx.tcx, self.layout().ty) { + if has_ptr_meta(fxcodegen_cx.tcx, self.layout().ty) { let (ptr, extra) = self.to_ptr_maybe_unsized(); let ptr = CValue::by_val_pair( ptr.get_addr(fx), diff --git a/src/vtable.rs b/src/vtable.rs index 601c37d82c885..910c0d4b12197 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -13,9 +13,9 @@ fn vtable_memflags() -> MemFlags { } pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.tcx), + pointer_ty(fxcodegen_cx.tcx), vtable_memflags(), vtable, (DROP_FN_INDEX * usize_size) as i32, @@ -23,9 +23,9 @@ pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: } pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.tcx), + pointer_ty(fxcodegen_cx.tcx), vtable_memflags(), vtable, (SIZE_INDEX * usize_size) as i32, @@ -33,9 +33,9 @@ pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Val } pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.tcx), + pointer_ty(fxcodegen_cx.tcx), vtable_memflags(), vtable, (ALIGN_INDEX * usize_size) as i32, @@ -57,9 +57,9 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( ) }; - let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); + let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( - pointer_ty(fx.tcx), + pointer_ty(fxcodegen_cx.tcx), vtable_memflags(), vtable, ((idx + 3) * usize_size as usize) as i32, @@ -89,11 +89,11 @@ fn build_vtable<'tcx>( layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> DataId { - let tcx = fx.tcx; - let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; + let tcx = fxcodegen_cx.tcx; + let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.tcx)); + import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fxcodegen_cx.tcx)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -109,7 +109,7 @@ fn build_vtable<'tcx>( Some(import_function( tcx, fx.module, - Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.tcx), + Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fxcodegen_cx.tcx), )) }) }); @@ -121,8 +121,8 @@ fn build_vtable<'tcx>( .collect::>() .into_boxed_slice(); - write_usize(fx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); - write_usize(fx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); + write_usize(fxcodegen_cx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); + write_usize(fxcodegen_cx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); data_ctx.define(data); for (i, component) in components.into_iter().enumerate() { @@ -148,7 +148,7 @@ fn build_vtable<'tcx>( false, false, Some( - fx.tcx + fxcodegen_cx.tcx .data_layout .pointer_align .pref From cb69c7019c91f284a28d83ab898ee2d8dd0653f2 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 15:19:09 +0200 Subject: [PATCH 1466/1566] FunctionCx: Replace .module with .codegen_cx.module --- src/abi/mod.rs | 8 ++++---- src/atomic_shim.rs | 28 ++++++++++++++-------------- src/base.rs | 16 ++++++++-------- src/common.rs | 8 ++++---- src/constant.rs | 24 ++++++++++++------------ src/driver/mod.rs | 4 ++-- src/inline_asm.rs | 4 ++-- src/intrinsics/mod.rs | 10 +++++----- src/lib.rs | 4 ++-- src/trap.rs | 4 ++-- src/value_and_place.rs | 2 +- src/vtable.rs | 12 ++++++------ 12 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index c2af33215c166..73f6e3719cd92 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -226,9 +226,9 @@ pub(crate) fn import_function<'tcx>( impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let func_id = import_function(selfcodegen_cx.tcx, self.module, inst); + let func_id = import_function(selfcodegen_cx.tcx, selfcodegen_cx.module, inst); let func_ref = self - .module + codegen_cx.module .declare_func_in_func(func_id, &mut self.bcx.func); #[cfg(debug_assertions)] @@ -250,11 +250,11 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { call_conv: CallConv::triple_default(self.triple()), }; let func_id = self - .module + codegen_cx.module .declare_function(&name, Linkage::Import, &sig) .unwrap(); let func_ref = self - .module + codegen_cx.module .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); #[cfg(debug_assertions)] diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 942f2c8c99afa..7d64e16e88d28 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -81,7 +81,7 @@ pub(crate) fn init_global_lock_constructor( } pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fx.module.declare_data( + let atomic_mutex = fxcodegen_cx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, true, @@ -89,24 +89,24 @@ pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { None, ).unwrap(); - let pthread_mutex_lock = fx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fx.module.target_config().default_call_conv, + let pthread_mutex_lock = fxcodegen_cx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fxcodegen_cx.module.target_config().default_call_conv, params: vec![ - AbiParam::new(fx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + AbiParam::new(fxcodegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), ], returns: vec![AbiParam::new(types::I32 /* c_int */)], }).unwrap(); - let pthread_mutex_lock = fx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); + let pthread_mutex_lock = fxcodegen_cx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); - let atomic_mutex = fx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fxcodegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fxcodegen_cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_lock, &[atomic_mutex]); } pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fx.module.declare_data( + let atomic_mutex = fxcodegen_cx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, true, @@ -114,18 +114,18 @@ pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { None, ).unwrap(); - let pthread_mutex_unlock = fx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fx.module.target_config().default_call_conv, + let pthread_mutex_unlock = fxcodegen_cx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fxcodegen_cx.module.target_config().default_call_conv, params: vec![ - AbiParam::new(fx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + AbiParam::new(fxcodegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), ], returns: vec![AbiParam::new(types::I32 /* c_int */)], }).unwrap(); - let pthread_mutex_unlock = fx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); + let pthread_mutex_unlock = fxcodegen_cx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); - let atomic_mutex = fx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fxcodegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fxcodegen_cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_unlock, &[atomic_mutex]); } diff --git a/src/base.rs b/src/base.rs index 767e838e61eb8..bb7ee9e995b55 100644 --- a/src/base.rs +++ b/src/base.rs @@ -13,8 +13,8 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let mir = tcx.instance_mir(instance.def); // Declare function - let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); - let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); + let (name, sig) = get_function_name_and_sig(tcx, cxcodegen_cx.module.isa().triple(), instance, false); + let func_id = cxcodegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); // Make FunctionBuilder let context = &mut cx.cached_context; @@ -30,12 +30,12 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let block_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_block()).collect(); // Make FunctionCx - let pointer_type = cx.module.target_config().pointer_type(); + let pointer_type = cxcodegen_cx.module.target_config().pointer_type(); let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance); let mut fx = FunctionCx { tcx, - module: &mut cx.module, + module: &mut cxcodegen_cx.module, global_asm: &mut cx.global_asm, pointer_type, @@ -98,10 +98,10 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // instruction, which doesn't have an encoding. context.compute_cfg(); context.compute_domtree(); - context.eliminate_unreachable_code(cx.module.isa()).unwrap(); + context.eliminate_unreachable_code(cxcodegen_cx.module.isa()).unwrap(); // Define function - let module = &mut cx.module; + let module = &mut cxcodegen_cx.module; tcx.sess.time( "define function", || module.define_function( @@ -115,14 +115,14 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( crate::pretty_clif::write_clif_file( cxcodegen_cx.tcx, "opt", - Some(cx.module.isa()), + Some(cxcodegen_cx.module.isa()), instance, &context, &clif_comments, ); // Define debuginfo for function - let isa = cx.module.isa(); + let isa = cxcodegen_cx.module.isa(); let debug_context = &mut cx.debug_context; let unwind_context = &mut cx.unwind_context; tcx.sess.time("generate debug info", || { diff --git a/src/common.rs b/src/common.rs index f8c26c54ae006..56bf9df7cc2bb 100644 --- a/src/common.rs +++ b/src/common.rs @@ -395,7 +395,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub(crate) fn triple(&self) -> &target_lexicon::Triple { - self.module.isa().triple() + selfcodegen_cx.module.isa().triple() } pub(crate) fn anonymous_str(&mut self, prefix: &str, msg: &str) -> Value { @@ -408,7 +408,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let mut data_ctx = DataContext::new(); data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice()); let msg_id = self - .module + codegen_cx.module .declare_data( &format!("__{}_{:08x}", prefix, msg_hash), Linkage::Local, @@ -419,9 +419,9 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { .unwrap(); // Ignore DuplicateDefinition error, as the data will be the same - let _ = self.module.define_data(msg_id, &data_ctx); + let _ = selfcodegen_cx.module.define_data(msg_id, &data_ctx); - let local_msg_id = self.module.declare_data_in_func(msg_id, self.bcx.func); + let local_msg_id = selfcodegen_cx.module.declare_data_in_func(msg_id, self.bcx.func); #[cfg(debug_assertions)] { self.add_comment(local_msg_id, msg); diff --git a/src/constant.rs b/src/constant.rs index a695b26d1b796..0f84982cb3e3d 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -67,8 +67,8 @@ pub(crate) fn codegen_tls_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { - let data_id = data_id_for_static(fxcodegen_cx.tcx, fx.module, def_id, false); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_static(fxcodegen_cx.tcx, fxcodegen_cx.module, def_id, false); + let local_data_id = fxcodegen_cx.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); @@ -80,8 +80,8 @@ fn codegen_static_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fxcodegen_cx.tcx, fx.module, def_id, false); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_static(fxcodegen_cx.tcx, fxcodegen_cx.module, def_id, false); + let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); @@ -168,21 +168,21 @@ pub(crate) fn trans_const_value<'tcx>( let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); - let data_id = data_id_for_alloc_id(fx.module, ptr.alloc_id, alloc.align, alloc.mutability); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_alloc_id(fxcodegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); + let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", ptr.alloc_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { - let func_id = crate::abi::import_function(fxcodegen_cx.tcx, fx.module, instance); - let local_func_id = fx.module.declare_func_in_func(func_id, &mut fx.bcx.func); + let func_id = crate::abi::import_function(fxcodegen_cx.tcx, fxcodegen_cx.module, instance); + let local_func_id = fxcodegen_cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) } Some(GlobalAlloc::Static(def_id)) => { assert!(fxcodegen_cx.tcx.is_static(def_id)); - let data_id = data_id_for_static(fxcodegen_cx.tcx, fx.module, def_id, false); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_static(fxcodegen_cx.tcx, fxcodegen_cx.module, def_id, false); + let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) @@ -217,9 +217,9 @@ fn pointer_for_allocation<'tcx>( ) -> crate::pointer::Pointer { let alloc_id = fxcodegen_cx.tcx.create_memory_alloc(alloc); fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(fx.module, alloc_id, alloc.align, alloc.mutability); + let data_id = data_id_for_alloc_id(fxcodegen_cx.module, alloc_id, alloc.align, alloc.mutability); - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", alloc_id)); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index fce702f86b951..ceb0f169f07fc 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -38,9 +38,9 @@ fn codegen_mono_items<'tcx>( match mono_item { MonoItem::Fn(instance) => { let (name, sig) = - get_function_name_and_sig(cxcodegen_cx.tcx, cx.module.isa().triple(), instance, false); + get_function_name_and_sig(cxcodegen_cx.tcx, cxcodegen_cx.module.isa().triple(), instance, false); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - cx.module.declare_function(&name, linkage, &sig).unwrap(); + cxcodegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); } MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} } diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 80cbae1a72020..ed4b1d6e43072 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -169,12 +169,12 @@ fn call_inline_asm<'tcx>( #[cfg(debug_assertions)] fx.add_comment(stack_slot, "inline asm scratch slot"); - let inline_asm_func = fx.module.declare_function(asm_name, Linkage::Import, &Signature { + let inline_asm_func = fxcodegen_cx.module.declare_function(asm_name, Linkage::Import, &Signature { call_conv: CallConv::SystemV, params: vec![AbiParam::new(fx.pointer_type)], returns: vec![], }).unwrap(); - let inline_asm_func = fx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); + let inline_asm_func = fxcodegen_cx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(inline_asm_func, asm_name); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 56dd171eeceb0..1ff05170d7378 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -494,10 +494,10 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( if intrinsic.contains("nonoverlapping") { // FIXME emit_small_memcpy - fx.bcx.call_memcpy(fx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memcpy(fxcodegen_cx.module.target_config(), dst, src, byte_amount); } else { // FIXME emit_small_memmove - fx.bcx.call_memmove(fx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memmove(fxcodegen_cx.module.target_config(), dst, src, byte_amount); } }; // NOTE: the volatile variants have src and dst swapped @@ -513,10 +513,10 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( // FIXME make the copy actually volatile when using emit_small_mem{cpy,move} if intrinsic.contains("nonoverlapping") { // FIXME emit_small_memcpy - fx.bcx.call_memcpy(fx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memcpy(fxcodegen_cx.module.target_config(), dst, src, byte_amount); } else { // FIXME emit_small_memmove - fx.bcx.call_memmove(fx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memmove(fxcodegen_cx.module.target_config(), dst, src, byte_amount); } }; discriminant_value, (c ptr) { @@ -680,7 +680,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let dst_ptr = dst.load_scalar(fx); // FIXME make the memset actually volatile when switching to emit_small_memset // FIXME use emit_small_memset - fx.bcx.call_memset(fx.module.target_config(), dst_ptr, val, count); + fx.bcx.call_memset(fxcodegen_cx.module.target_config(), dst_ptr, val, count); }; ctlz | ctlz_nonzero, (v arg) { // FIXME trap on `ctlz_nonzero` with zero arg. diff --git a/src/lib.rs b/src/lib.rs index 56a57b50b0dc7..269c66e8b0c7a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,8 +160,8 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { - self.constants_cx.finalize(selfcodegen_cx.tcx, &mut self.module); - (self.module, self.global_asm, self.debug_context, self.unwind_context) + self.constants_cx.finalize(selfcodegen_cx.tcx, &mut selfcodegen_cx.module); + (selfcodegen_cx.module, self.global_asm, self.debug_context, self.unwind_context) } } diff --git a/src/trap.rs b/src/trap.rs index 563ac37cda217..2f059e2847657 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -2,7 +2,7 @@ use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { let puts = fx - .module + codegen_cx.module .declare_function( "puts", Linkage::Import, @@ -13,7 +13,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms }, ) .unwrap(); - let puts = fx.module.declare_func_in_func(puts, &mut fx.bcx.func); + let puts = fxcodegen_cx.module.declare_func_in_func(puts, &mut fx.bcx.func); #[cfg(debug_assertions)] { fx.add_comment(puts, "puts"); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 2e8db1a1e65b8..8db4afa00f932 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -595,7 +595,7 @@ impl<'tcx> CPlace<'tcx> { let src_align = src_layout.align.abi.bytes() as u8; let dst_align = dst_layout.align.abi.bytes() as u8; fx.bcx.emit_small_memory_copy( - fx.module.target_config(), + fxcodegen_cx.module.target_config(), to_addr, from_addr, size, diff --git a/src/vtable.rs b/src/vtable.rs index 910c0d4b12197..f11c881a65dd6 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -80,7 +80,7 @@ pub(crate) fn get_vtable<'tcx>( data_id }; - let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } @@ -93,7 +93,7 @@ fn build_vtable<'tcx>( let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, fx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fxcodegen_cx.tcx)); + import_function(tcx, fxcodegen_cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fxcodegen_cx.tcx)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -108,7 +108,7 @@ fn build_vtable<'tcx>( opt_mth.map_or(None, |(def_id, substs)| { Some(import_function( tcx, - fx.module, + fxcodegen_cx.module, Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fxcodegen_cx.tcx), )) }) @@ -127,13 +127,13 @@ fn build_vtable<'tcx>( for (i, component) in components.into_iter().enumerate() { if let Some(func_id) = component { - let func_ref = fx.module.declare_func_in_data(func_id, &mut data_ctx); + let func_ref = fxcodegen_cx.module.declare_func_in_data(func_id, &mut data_ctx); data_ctx.write_function_addr((i * usize_size) as u32, func_ref); } } let data_id = fx - .module + codegen_cx.module .declare_data( &format!( "__vtable.{}.for.{:?}.{}", @@ -159,7 +159,7 @@ fn build_vtable<'tcx>( ) .unwrap(); - fx.module.define_data(data_id, &data_ctx).unwrap(); + fxcodegen_cx.module.define_data(data_id, &data_ctx).unwrap(); data_id } From d199b83b5571f18391fc82d253ccd51d4a5cbaa3 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 15:19:48 +0200 Subject: [PATCH 1467/1566] FunctionCx: WIP: Replace .constants with codegen_cx.constants --- src/base.rs | 2 +- src/constant.rs | 4 ++-- src/driver/mod.rs | 2 +- src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/base.rs b/src/base.rs index bb7ee9e995b55..1466ae9f82856 100644 --- a/src/base.rs +++ b/src/base.rs @@ -49,7 +49,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( cold_blocks: EntitySet::new(), clif_comments, - constants_cx: &mut cx.constants_cx, + constants_cx: &mut cxcodegen_cx.constants_cx, vtables: &mut cx.vtables, source_info_set: indexmap::IndexSet::new(), next_ssa_var: 0, diff --git a/src/constant.rs b/src/constant.rs index 0f84982cb3e3d..1eb6042b0b281 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -167,7 +167,7 @@ pub(crate) fn trans_const_value<'tcx>( let alloc_kind = fxcodegen_cx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { - fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); + fxcodegen_cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); let data_id = data_id_for_alloc_id(fxcodegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] @@ -216,7 +216,7 @@ fn pointer_for_allocation<'tcx>( alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { let alloc_id = fxcodegen_cx.tcx.create_memory_alloc(alloc); - fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); + fxcodegen_cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fxcodegen_cx.module, alloc_id, alloc.align, alloc.mutability); let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index ceb0f169f07fc..ab397d7c7fd46 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -88,7 +88,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( cxcodegen_cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { - crate::constant::codegen_static(&mut cx.constants_cx, def_id); + crate::constant::codegen_static(&mut cxcodegen_cx.constants_cx, def_id); } MonoItem::GlobalAsm(hir_id) => { let item = tcx.hir().expect_item(hir_id); diff --git a/src/lib.rs b/src/lib.rs index 269c66e8b0c7a..9ab9ad8c81a35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,7 +160,7 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { - self.constants_cx.finalize(selfcodegen_cx.tcx, &mut selfcodegen_cx.module); + selfcodegen_cx.constants_cx.finalize(selfcodegen_cx.tcx, &mut selfcodegen_cx.module); (selfcodegen_cx.module, self.global_asm, self.debug_context, self.unwind_context) } } From ad4a7a1f0c87ecd0a520fce2078d1bcdb900f574 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 15:21:38 +0200 Subject: [PATCH 1468/1566] FunctionCx: WIP: Fix syntax error on sed codegen_cx -> .codegen_cx --- src/abi/mod.rs | 56 +++++++++++------------ src/abi/pass_mode.rs | 6 +-- src/abi/returning.rs | 6 +-- src/analyze.rs | 4 +- src/atomic_shim.rs | 28 ++++++------ src/base.rs | 92 +++++++++++++++++++------------------- src/cast.rs | 16 +++---- src/codegen_i128.rs | 42 ++++++++--------- src/common.rs | 34 +++++++------- src/constant.rs | 48 ++++++++++---------- src/debuginfo/line_info.rs | 4 +- src/debuginfo/mod.rs | 8 ++-- src/debuginfo/unwind.rs | 4 +- src/discriminant.rs | 4 +- src/driver/mod.rs | 12 ++--- src/inline_asm.rs | 6 +-- src/intrinsics/llvm.rs | 6 +-- src/intrinsics/mod.rs | 48 ++++++++++---------- src/intrinsics/simd.rs | 26 +++++------ src/lib.rs | 4 +- src/num.rs | 16 +++---- src/trap.rs | 8 ++-- src/unsize.rs | 4 +- src/value_and_place.rs | 34 +++++++------- src/vtable.rs | 40 ++++++++--------- 25 files changed, 278 insertions(+), 278 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 73f6e3719cd92..ca6680f1e14d2 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -226,9 +226,9 @@ pub(crate) fn import_function<'tcx>( impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let func_id = import_function(selfcodegen_cx.tcx, selfcodegen_cx.module, inst); + let func_id = import_function(self.codegen_cx.tcx, self.codegen_cx.module, inst); let func_ref = self - codegen_cx.module + .codegen_cx.module .declare_func_in_func(func_id, &mut self.bcx.func); #[cfg(debug_assertions)] @@ -250,11 +250,11 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { call_conv: CallConv::triple_default(self.triple()), }; let func_id = self - codegen_cx.module + .codegen_cx.module .declare_function(&name, Linkage::Import, &sig) .unwrap(); let func_ref = self - codegen_cx.module + .codegen_cx.module .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); #[cfg(debug_assertions)] @@ -374,9 +374,9 @@ pub(crate) fn codegen_fn_prelude<'tcx>( .collect::, Ty<'tcx>)>>(); assert!(fx.caller_location.is_none()); - if fx.instance.def.requires_caller_location(fxcodegen_cx.tcx) { + if fx.instance.def.requires_caller_location(fx.codegen_cx.tcx) { // Store caller location for `#[track_caller]`. - fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fxcodegen_cx.tcx.caller_location_ty()).unwrap()); + fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.codegen_cx.tcx.caller_location_ty()).unwrap()); } fx.bcx.switch_to_block(start_block); @@ -398,7 +398,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( let local_decl = &fx.mir.local_decls[local]; // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( - fxcodegen_cx.tcx.at(local_decl.source_info.span), + fx.codegen_cx.tcx.at(local_decl.source_info.span), ParamEnv::reveal_all(), ); if local_decl.mutability == mir::Mutability::Not && !internally_mutable { @@ -465,24 +465,24 @@ pub(crate) fn codegen_terminator_call<'tcx>( args: &[Operand<'tcx>], destination: Option<(Place<'tcx>, BasicBlock)>, ) { - let fn_ty = fx.monomorphize(&func.ty(fx.mir, fxcodegen_cx.tcx)); + let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.codegen_cx.tcx)); let fn_sig = fx - codegen_cx.tcx - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fxcodegen_cx.tcx)); + .codegen_cx.tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.codegen_cx.tcx)); let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); // Handle special calls like instrinsics and empty drop glue. let instance = if let ty::FnDef(def_id, substs) = fn_ty.kind { - let instance = ty::Instance::resolve(fxcodegen_cx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) + let instance = ty::Instance::resolve(fx.codegen_cx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) .unwrap() .unwrap() - .polymorphize(fxcodegen_cx.tcx); + .polymorphize(fx.codegen_cx.tcx); - if fxcodegen_cx.tcx.symbol_name(instance).name.starts_with("llvm.") { + if fx.codegen_cx.tcx.symbol_name(instance).name.starts_with("llvm.") { crate::intrinsics::codegen_llvm_intrinsic_call( fx, - &fxcodegen_cx.tcx.symbol_name(instance).name, + &fx.codegen_cx.tcx.symbol_name(instance).name, substs, args, destination, @@ -510,7 +510,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let is_cold = instance.map(|inst| - fxcodegen_cx.tcx.codegen_fn_attrs(inst.def_id()) + fx.codegen_cx.tcx.codegen_fn_attrs(inst.def_id()) .flags.contains(CodegenFnAttrFlags::COLD)) .unwrap_or(false); if is_cold { @@ -558,7 +558,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( nop_inst, format!( "virtual call; self arg pass mode: {:?}", - get_pass_mode(fxcodegen_cx.tcx, args[0].layout()) + get_pass_mode(fx.codegen_cx.tcx, args[0].layout()) ), ); } @@ -608,7 +608,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( ) .collect::>(); - if instance.map(|inst| inst.def.requires_caller_location(fxcodegen_cx.tcx)).unwrap_or(false) { + if instance.map(|inst| inst.def.requires_caller_location(fx.codegen_cx.tcx)).unwrap_or(false) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); @@ -616,7 +616,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let call_inst = if let Some(func_ref) = func_ref { let sig = clif_sig_from_fn_sig( - fxcodegen_cx.tcx, + fx.codegen_cx.tcx, fx.triple(), fn_sig, span, @@ -637,7 +637,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { if fn_sig.abi != Abi::C { - fxcodegen_cx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); + fx.codegen_cx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); let abi_params = call_args @@ -646,7 +646,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - fxcodegen_cx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); + fx.codegen_cx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); } AbiParam::new(ty) }) @@ -668,17 +668,17 @@ pub(crate) fn codegen_drop<'tcx>( drop_place: CPlace<'tcx>, ) { let ty = drop_place.layout().ty; - let drop_fn = Instance::resolve_drop_in_place(fxcodegen_cx.tcx, ty).polymorphize(fxcodegen_cx.tcx); + let drop_fn = Instance::resolve_drop_in_place(fx.codegen_cx.tcx, ty).polymorphize(fx.codegen_cx.tcx); if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything } else { - let drop_fn_ty = drop_fn.ty(fxcodegen_cx.tcx, ParamEnv::reveal_all()); - let fn_sig = fxcodegen_cx.tcx.normalize_erasing_late_bound_regions( + let drop_fn_ty = drop_fn.ty(fx.codegen_cx.tcx, ParamEnv::reveal_all()); + let fn_sig = fx.codegen_cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &drop_fn_ty.fn_sig(fxcodegen_cx.tcx), + &drop_fn_ty.fn_sig(fx.codegen_cx.tcx), ); - assert_eq!(fn_sig.output(), fxcodegen_cx.tcx.mk_unit()); + assert_eq!(fn_sig.output(), fx.codegen_cx.tcx.mk_unit()); match ty.kind { ty::Dynamic(..) => { @@ -687,7 +687,7 @@ pub(crate) fn codegen_drop<'tcx>( let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); let sig = clif_sig_from_fn_sig( - fxcodegen_cx.tcx, + fx.codegen_cx.tcx, fx.triple(), fn_sig, span, @@ -702,7 +702,7 @@ pub(crate) fn codegen_drop<'tcx>( let arg_place = CPlace::new_stack_slot( fx, - fx.layout_of(fxcodegen_cx.tcx.mk_ref( + fx.layout_of(fx.codegen_cx.tcx.mk_ref( &ty::RegionKind::ReErased, TypeAndMut { ty, @@ -716,7 +716,7 @@ pub(crate) fn codegen_drop<'tcx>( let mut call_args: Vec = arg_value.into_iter().collect::>(); - if drop_fn.def.requires_caller_location(fxcodegen_cx.tcx) { + if drop_fn.def.requires_caller_location(fx.codegen_cx.tcx) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index fd2ec94f29b49..7172a56ad2979 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -118,7 +118,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, ) -> EmptySinglePair { - match get_pass_mode(fxcodegen_cx.tcx, arg.layout()) { + match get_pass_mode(fx.codegen_cx.tcx, arg.layout()) { PassMode::NoPass => Empty, PassMode::ByVal(_) => Single(arg.load_scalar(fx)), PassMode::ByValPair(_, _) => { @@ -144,13 +144,13 @@ pub(super) fn cvalue_for_param<'tcx>( arg_ty: Ty<'tcx>, ) -> Option> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fxcodegen_cx.tcx, layout); + let pass_mode = get_pass_mode(fx.codegen_cx.tcx, layout); if let PassMode::NoPass = pass_mode { return None; } - let clif_types = pass_mode.get_param_ty(fxcodegen_cx.tcx); + let clif_types = pass_mode.get_param_ty(fx.codegen_cx.tcx); let block_params = clif_types.map(|t| fx.bcx.append_block_param(start_block, t)); #[cfg(debug_assertions)] diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 05144e2a565cc..51c0c144defe3 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -19,7 +19,7 @@ pub(super) fn codegen_return_param( start_block: Block, ) { let ret_layout = return_layout(fx); - let ret_pass_mode = get_pass_mode(fxcodegen_cx.tcx, ret_layout); + let ret_pass_mode = get_pass_mode(fx.codegen_cx.tcx, ret_layout); let ret_param = match ret_pass_mode { PassMode::NoPass => { fx.local_map @@ -66,7 +66,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( ) -> (Inst, T) { let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fxcodegen_cx.tcx, ret_layout); + let output_pass_mode = get_pass_mode(fx.codegen_cx.tcx, ret_layout); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef { size: Some(_)} => match ret_place { @@ -102,7 +102,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( } pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { - match get_pass_mode(fxcodegen_cx.tcx, return_layout(fx)) { + match get_pass_mode(fx.codegen_cx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { size: Some(_) } => { fx.bcx.ins().return_(&[]); } diff --git a/src/analyze.rs b/src/analyze.rs index 5e9e88b7980dd..466e0a312c075 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -35,8 +35,8 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { if let Some((dest_place, _dest_bb)) = destination { - let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fxcodegen_cx.tcx).ty)); - if !crate::abi::can_return_to_ssa_var(fxcodegen_cx.tcx, dest_layout) { + let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.codegen_cx.tcx).ty)); + if !crate::abi::can_return_to_ssa_var(fx.codegen_cx.tcx, dest_layout) { not_ssa(&mut flag_map, dest_place.local) } } diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 7d64e16e88d28..00dca2c34a6b1 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -81,7 +81,7 @@ pub(crate) fn init_global_lock_constructor( } pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fxcodegen_cx.module.declare_data( + let atomic_mutex = fx.codegen_cx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, true, @@ -89,24 +89,24 @@ pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { None, ).unwrap(); - let pthread_mutex_lock = fxcodegen_cx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fxcodegen_cx.module.target_config().default_call_conv, + let pthread_mutex_lock = fx.codegen_cx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fx.codegen_cx.module.target_config().default_call_conv, params: vec![ - AbiParam::new(fxcodegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + AbiParam::new(fx.codegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), ], returns: vec![AbiParam::new(types::I32 /* c_int */)], }).unwrap(); - let pthread_mutex_lock = fxcodegen_cx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); + let pthread_mutex_lock = fx.codegen_cx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); - let atomic_mutex = fxcodegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fxcodegen_cx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fx.codegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fx.codegen_cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_lock, &[atomic_mutex]); } pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fxcodegen_cx.module.declare_data( + let atomic_mutex = fx.codegen_cx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, true, @@ -114,18 +114,18 @@ pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { None, ).unwrap(); - let pthread_mutex_unlock = fxcodegen_cx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fxcodegen_cx.module.target_config().default_call_conv, + let pthread_mutex_unlock = fx.codegen_cx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fx.codegen_cx.module.target_config().default_call_conv, params: vec![ - AbiParam::new(fxcodegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + AbiParam::new(fx.codegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), ], returns: vec![AbiParam::new(types::I32 /* c_int */)], }).unwrap(); - let pthread_mutex_unlock = fxcodegen_cx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); + let pthread_mutex_unlock = fx.codegen_cx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); - let atomic_mutex = fxcodegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fxcodegen_cx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fx.codegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fx.codegen_cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_unlock, &[atomic_mutex]); } diff --git a/src/base.rs b/src/base.rs index 1466ae9f82856..cbb845af77c1b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -8,13 +8,13 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( instance: Instance<'tcx>, linkage: Linkage, ) { - let tcx = cxcodegen_cx.tcx; + let tcx = cx.codegen_cx.tcx; let mir = tcx.instance_mir(instance.def); // Declare function - let (name, sig) = get_function_name_and_sig(tcx, cxcodegen_cx.module.isa().triple(), instance, false); - let func_id = cxcodegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); + let (name, sig) = get_function_name_and_sig(tcx, cx.codegen_cx.module.isa().triple(), instance, false); + let func_id = cx.codegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); // Make FunctionBuilder let context = &mut cx.cached_context; @@ -30,12 +30,12 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let block_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_block()).collect(); // Make FunctionCx - let pointer_type = cxcodegen_cx.module.target_config().pointer_type(); + let pointer_type = cx.codegen_cx.module.target_config().pointer_type(); let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance); let mut fx = FunctionCx { tcx, - module: &mut cxcodegen_cx.module, + module: &mut cx.codegen_cx.module, global_asm: &mut cx.global_asm, pointer_type, @@ -49,7 +49,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( cold_blocks: EntitySet::new(), clif_comments, - constants_cx: &mut cxcodegen_cx.constants_cx, + constants_cx: &mut cx.codegen_cx.constants_cx, vtables: &mut cx.vtables, source_info_set: indexmap::IndexSet::new(), next_ssa_var: 0, @@ -78,7 +78,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let cold_blocks = fx.cold_blocks; crate::pretty_clif::write_clif_file( - cxcodegen_cx.tcx, + cx.codegen_cx.tcx, "unopt", None, instance, @@ -98,10 +98,10 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // instruction, which doesn't have an encoding. context.compute_cfg(); context.compute_domtree(); - context.eliminate_unreachable_code(cxcodegen_cx.module.isa()).unwrap(); + context.eliminate_unreachable_code(cx.codegen_cx.module.isa()).unwrap(); // Define function - let module = &mut cxcodegen_cx.module; + let module = &mut cx.codegen_cx.module; tcx.sess.time( "define function", || module.define_function( @@ -113,16 +113,16 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Write optimized function to file for debugging crate::pretty_clif::write_clif_file( - cxcodegen_cx.tcx, + cx.codegen_cx.tcx, "opt", - Some(cxcodegen_cx.module.isa()), + Some(cx.codegen_cx.module.isa()), instance, &context, &clif_comments, ); // Define debuginfo for function - let isa = cxcodegen_cx.module.isa(); + let isa = cx.codegen_cx.module.isa(); let debug_context = &mut cx.debug_context; let unwind_context = &mut cx.unwind_context; tcx.sess.time("generate debug info", || { @@ -224,7 +224,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { target, cleanup: _, } => { - if !fxcodegen_cx.tcx.sess.overflow_checks() { + if !fx.codegen_cx.tcx.sess.overflow_checks() { if let mir::AssertKind::OverflowNeg(_) = *msg { let target = fx.get_block(*target); fx.bcx.ins().jump(target, &[]); @@ -265,12 +265,12 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } }; - let def_id = fxcodegen_cx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { - fxcodegen_cx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) + let def_id = fx.codegen_cx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { + fx.codegen_cx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) }); - let instance = Instance::mono(fxcodegen_cx.tcx, def_id).polymorphize(fxcodegen_cx.tcx); - let symbol_name = fxcodegen_cx.tcx.symbol_name(instance).name; + let instance = Instance::mono(fx.codegen_cx.tcx, def_id).polymorphize(fx.codegen_cx.tcx); + let symbol_name = fx.codegen_cx.tcx.symbol_name(instance).name; fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); @@ -300,7 +300,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, from_hir_call: _, } => { - fxcodegen_cx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( + fx.codegen_cx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, *fn_span, block, @@ -419,7 +419,7 @@ fn trans_stmt<'tcx>( let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let res = if !fxcodegen_cx.tcx.sess.overflow_checks() { + let res = if !fx.codegen_cx.tcx.sess.overflow_checks() { let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); @@ -465,14 +465,14 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, res); } Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, to_ty) => { - let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fxcodegen_cx.tcx)); + let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.codegen_cx.tcx)); let to_layout = fx.layout_of(fx.monomorphize(to_ty)); match from_ty.kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( - Instance::resolve_for_fn_ptr(fxcodegen_cx.tcx, ParamEnv::reveal_all(), def_id, substs) + Instance::resolve_for_fn_ptr(fx.codegen_cx.tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap() - .polymorphize(fxcodegen_cx.tcx), + .polymorphize(fx.codegen_cx.tcx), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, to_layout)); @@ -501,7 +501,7 @@ fn trans_stmt<'tcx>( |ty::TypeAndMut { ty: pointee_ty, mutbl: _, - }| has_ptr_meta(fxcodegen_cx.tcx, pointee_ty), + }| has_ptr_meta(fx.codegen_cx.tcx, pointee_ty), ) .unwrap_or(false) } @@ -527,7 +527,7 @@ fn trans_stmt<'tcx>( match &operand.layout().variants { Variants::Single { index } => { - let discr = operand.layout().ty.discriminant_for_variant(fxcodegen_cx.tcx, *index).unwrap(); + let discr = operand.layout().ty.discriminant_for_variant(fx.codegen_cx.tcx, *index).unwrap(); let discr = if discr.ty.is_signed() { rustc_middle::mir::interpret::sign_extend(discr.val, fx.layout_of(discr.ty).size) } else { @@ -579,11 +579,11 @@ fn trans_stmt<'tcx>( match operand.layout().ty.kind { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( - fxcodegen_cx.tcx, + fx.codegen_cx.tcx, def_id, substs, ty::ClosureKind::FnOnce, - ).polymorphize(fxcodegen_cx.tcx); + ).polymorphize(fx.codegen_cx.tcx); let func_ref = fx.get_function_ref(instance); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); @@ -606,9 +606,9 @@ fn trans_stmt<'tcx>( let operand = trans_operand(fx, operand); let times = fx .monomorphize(times) - .eval(fxcodegen_cx.tcx, ParamEnv::reveal_all()) + .eval(fx.codegen_cx.tcx, ParamEnv::reveal_all()) .val - .try_to_bits(fxcodegen_cx.tcx.data_layout.pointer_size) + .try_to_bits(fx.codegen_cx.tcx.data_layout.pointer_size) .unwrap(); for i in 0..times { let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); @@ -618,14 +618,14 @@ fn trans_stmt<'tcx>( } Rvalue::Len(place) => { let place = trans_place(fx, *place); - let usize_layout = fx.layout_of(fxcodegen_cx.tcx.types.usize); + let usize_layout = fx.layout_of(fx.codegen_cx.tcx.types.usize); let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { use rustc_hir::lang_items::ExchangeMallocFnLangItem; - let usize_type = fx.clif_type(fxcodegen_cx.tcx.types.usize).unwrap(); + let usize_type = fx.clif_type(fx.codegen_cx.tcx.types.usize).unwrap(); let content_ty = fx.monomorphize(content_ty); let layout = fx.layout_of(content_ty); let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64); @@ -633,18 +633,18 @@ fn trans_stmt<'tcx>( .bcx .ins() .iconst(usize_type, layout.align.abi.bytes() as i64); - let box_layout = fx.layout_of(fxcodegen_cx.tcx.mk_box(content_ty)); + let box_layout = fx.layout_of(fx.codegen_cx.tcx.mk_box(content_ty)); // Allocate space: - let def_id = match fxcodegen_cx.tcx.lang_items().require(ExchangeMallocFnLangItem) { + let def_id = match fx.codegen_cx.tcx.lang_items().require(ExchangeMallocFnLangItem) { Ok(id) => id, Err(s) => { - fxcodegen_cx.tcx + fx.codegen_cx.tcx .sess .fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); } }; - let instance = ty::Instance::mono(fxcodegen_cx.tcx, def_id).polymorphize(fxcodegen_cx.tcx); + let instance = ty::Instance::mono(fx.codegen_cx.tcx, def_id).polymorphize(fx.codegen_cx.tcx); let func_ref = fx.get_function_ref(instance); let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); let ptr = fx.bcx.inst_results(call)[0]; @@ -654,9 +654,9 @@ fn trans_stmt<'tcx>( assert!(lval .layout() .ty - .is_sized(fxcodegen_cx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); + .is_sized(fx.codegen_cx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); - let val = CValue::const_val(fx, fx.layout_of(fxcodegen_cx.tcx.types.usize), ty_size.into()); + let val = CValue::const_val(fx, fx.layout_of(fx.codegen_cx.tcx.types.usize), ty_size.into()); lval.write_cvalue(fx, val); } Rvalue::Aggregate(kind, operands) => match **kind { @@ -721,10 +721,10 @@ fn trans_stmt<'tcx>( let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); assert_eq!(outputs.len(), 4); - trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fxcodegen_cx.tcx.types.u32))); - trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fxcodegen_cx.tcx.types.u32))); - trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fxcodegen_cx.tcx.types.u32))); - trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fxcodegen_cx.tcx.types.u32))); + trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.codegen_cx.tcx.types.u32))); + trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.codegen_cx.tcx.types.u32))); + trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.codegen_cx.tcx.types.u32))); + trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.codegen_cx.tcx.types.u32))); } "xgetbv" => { assert_eq!(input_names, &[Symbol::intern("{ecx}")]); @@ -744,17 +744,17 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } // ___chkstk, ___chkstk_ms and __alloca are only used on Windows - _ if fxcodegen_cx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { + _ if fx.codegen_cx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { crate::trap::trap_unimplemented(fx, "Stack probes are not supported"); } - _ if fxcodegen_cx.tcx.symbol_name(fx.instance).name == "__alloca" => { + _ if fx.codegen_cx.tcx.symbol_name(fx.instance).name == "__alloca" => { crate::trap::trap_unimplemented(fx, "Alloca is not supported"); } // Used in sys::windows::abort_internal "int $$0x29" => { crate::trap::trap_unimplemented(fx, "Windows abort"); } - _ => fxcodegen_cx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), + _ => fx.codegen_cx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), } } } @@ -767,8 +767,8 @@ fn codegen_array_len<'tcx>( match place.layout().ty.kind { ty::Array(_elem_ty, len) => { let len = fx.monomorphize(&len) - .eval(fxcodegen_cx.tcx, ParamEnv::reveal_all()) - .eval_usize(fxcodegen_cx.tcx, ParamEnv::reveal_all()) as i64; + .eval(fx.codegen_cx.tcx, ParamEnv::reveal_all()) + .eval_usize(fx.codegen_cx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place @@ -821,7 +821,7 @@ pub(crate) fn trans_place<'tcx>( let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), - fx.layout_of(fxcodegen_cx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), + fx.layout_of(fx.codegen_cx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), ); } ty::Slice(elem_ty) => { diff --git a/src/cast.rs b/src/cast.rs index acec7add7f01c..db465a581275a 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -86,14 +86,14 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = if from_signed { - fxcodegen_cx.tcx.types.i128 + fx.codegen_cx.tcx.types.i128 } else { - fxcodegen_cx.tcx.types.u128 + fx.codegen_cx.tcx.types.u128 }; let to_rust_ty = match to_ty { - types::F32 => fxcodegen_cx.tcx.types.f32, - types::F64 => fxcodegen_cx.tcx.types.f64, + types::F32 => fx.codegen_cx.tcx.types.f32, + types::F64 => fx.codegen_cx.tcx.types.f64, _ => unreachable!(), }; @@ -131,15 +131,15 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = match from_ty { - types::F32 => fxcodegen_cx.tcx.types.f32, - types::F64 => fxcodegen_cx.tcx.types.f64, + types::F32 => fx.codegen_cx.tcx.types.f32, + types::F64 => fx.codegen_cx.tcx.types.f64, _ => unreachable!(), }; let to_rust_ty = if to_signed { - fxcodegen_cx.tcx.types.i128 + fx.codegen_cx.tcx.types.i128 } else { - fxcodegen_cx.tcx.types.u128 + fx.codegen_cx.tcx.types.u128 }; return fx diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index c2fa7cf373e5f..bb927a4dd70bf 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -9,7 +9,7 @@ pub(crate) fn maybe_codegen<'tcx>( lhs: CValue<'tcx>, rhs: CValue<'tcx>, ) -> Option> { - if lhs.layout().ty != fxcodegen_cx.tcx.types.u128 && lhs.layout().ty != fxcodegen_cx.tcx.types.i128 { + if lhs.layout().ty != fx.codegen_cx.tcx.types.u128 && lhs.layout().ty != fx.codegen_cx.tcx.types.i128 { return None; } @@ -25,7 +25,7 @@ pub(crate) fn maybe_codegen<'tcx>( } BinOp::Add | BinOp::Sub if !checked => return None, BinOp::Add => { - let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); + let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty) } else { @@ -33,7 +33,7 @@ pub(crate) fn maybe_codegen<'tcx>( }); } BinOp::Sub => { - let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); + let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty) } else { @@ -43,7 +43,7 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { let res = if checked { - let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); + let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); if is_signed { fx.easy_call("__rust_i128_mulo", &[lhs, rhs], out_ty) } else { @@ -51,9 +51,9 @@ pub(crate) fn maybe_codegen<'tcx>( } } else { let val_ty = if is_signed { - fxcodegen_cx.tcx.types.i128 + fx.codegen_cx.tcx.types.i128 } else { - fxcodegen_cx.tcx.types.u128 + fx.codegen_cx.tcx.types.u128 }; fx.easy_call("__multi3", &[lhs, rhs], val_ty) }; @@ -62,17 +62,17 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Div => { assert!(!checked); if is_signed { - Some(fx.easy_call("__divti3", &[lhs, rhs], fxcodegen_cx.tcx.types.i128)) + Some(fx.easy_call("__divti3", &[lhs, rhs], fx.codegen_cx.tcx.types.i128)) } else { - Some(fx.easy_call("__udivti3", &[lhs, rhs], fxcodegen_cx.tcx.types.u128)) + Some(fx.easy_call("__udivti3", &[lhs, rhs], fx.codegen_cx.tcx.types.u128)) } } BinOp::Rem => { assert!(!checked); if is_signed { - Some(fx.easy_call("__modti3", &[lhs, rhs], fxcodegen_cx.tcx.types.i128)) + Some(fx.easy_call("__modti3", &[lhs, rhs], fx.codegen_cx.tcx.types.i128)) } else { - Some(fx.easy_call("__umodti3", &[lhs, rhs], fxcodegen_cx.tcx.types.u128)) + Some(fx.easy_call("__umodti3", &[lhs, rhs], fx.codegen_cx.tcx.types.u128)) } } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { @@ -104,7 +104,7 @@ pub(crate) fn maybe_codegen<'tcx>( let val = match (bin_op, is_signed) { (BinOp::Shr, false) => { let val = fx.bcx.ins().iconcat(lhs_msb, all_zeros); - Some(CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.u128))) + Some(CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.u128))) } (BinOp::Shr, true) => { let sign = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, lhs_msb, 0); @@ -112,13 +112,13 @@ pub(crate) fn maybe_codegen<'tcx>( let all_sign_bits = fx.bcx.ins().select(sign, all_zeros, all_ones); let val = fx.bcx.ins().iconcat(lhs_msb, all_sign_bits); - Some(CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.i128))) + Some(CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.i128))) } (BinOp::Shl, _) => { let val_ty = if is_signed { - fxcodegen_cx.tcx.types.i128 + fx.codegen_cx.tcx.types.i128 } else { - fxcodegen_cx.tcx.types.u128 + fx.codegen_cx.tcx.types.u128 }; let val = fx.bcx.ins().iconcat(all_zeros, lhs_lsb); Some(CValue::by_val(val, fx.layout_of(val_ty))) @@ -127,7 +127,7 @@ pub(crate) fn maybe_codegen<'tcx>( }; if let Some(val) = val { if let Some(is_overflow) = is_overflow { - let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); + let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); let val = val.load_scalar(fx); return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))); } else { @@ -137,24 +137,24 @@ pub(crate) fn maybe_codegen<'tcx>( } let truncated_rhs = clif_intcast(fx, rhs_val, types::I32, false); - let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fxcodegen_cx.tcx.types.u32)); + let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fx.codegen_cx.tcx.types.u32)); let val = match (bin_op, is_signed) { (BinOp::Shl, false) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.u128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.u128) } (BinOp::Shl, true) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.i128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.i128) } (BinOp::Shr, false) => { - fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.u128) + fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.u128) } (BinOp::Shr, true) => { - fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fxcodegen_cx.tcx.types.i128) + fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.i128) } (_, _) => unreachable!(), }; if let Some(is_overflow) = is_overflow { - let out_ty = fxcodegen_cx.tcx.mk_tup([lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter()); + let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); let val = val.load_scalar(fx); Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) } else { diff --git a/src/common.rs b/src/common.rs index 56bf9df7cc2bb..d959ddc2f4d41 100644 --- a/src/common.rs +++ b/src/common.rs @@ -265,7 +265,7 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool { } pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { - pub(crate) codegen_cx: &'clif CodegenCx<'tcx, B>, + pub(crate) .codegen_cx: &'clif CodegenCx<'tcx, B>, pub(crate) global_asm: &'clif mut String, pub(crate) pointer_type: Type, // Cached from module @@ -299,11 +299,11 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { assert!(!ty.still_further_specializable()); - selfcodegen_cx.tcx + self.codegen_cx.tcx .layout_of(ParamEnv::reveal_all().and(&ty)) .unwrap_or_else(|e| { if let layout::LayoutError::SizeOverflow(_) = e { - selfcodegen_cx.tcx.sess.fatal(&e.to_string()) + self.codegen_cx.tcx.sess.fatal(&e.to_string()) } else { bug!("failed to get layout for `{}`: {}", ty, e) } @@ -313,13 +313,13 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend + 'static> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx, B> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { - selfcodegen_cx.tcx + self.codegen_cx.tcx } } impl<'tcx, B: Backend + 'static> rustc_target::abi::HasDataLayout for FunctionCx<'_, 'tcx, B> { fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { - &selfcodegen_cx.tcx.data_layout + &self.codegen_cx.tcx.data_layout } } @@ -331,7 +331,7 @@ impl<'tcx, B: Backend + 'static> layout::HasParamEnv<'tcx> for FunctionCx<'_, 't impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { fn target_spec(&self) -> &Target { - &selfcodegen_cx.tcx.sess.target.target + &self.codegen_cx.tcx.sess.target.target } } @@ -341,22 +341,22 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { T: TypeFoldable<'tcx> + Copy, { if let Some(substs) = self.instance.substs_for_mir_body() { - selfcodegen_cx.tcx.subst_and_normalize_erasing_regions( + self.codegen_cx.tcx.subst_and_normalize_erasing_regions( substs, ty::ParamEnv::reveal_all(), value, ) } else { - selfcodegen_cx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) + self.codegen_cx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) } } pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option { - clif_type_from_ty(selfcodegen_cx.tcx, ty) + clif_type_from_ty(self.codegen_cx.tcx, ty) } pub(crate) fn clif_pair_type(&self, ty: Ty<'tcx>) -> Option<(Type, Type)> { - clif_pair_type_from_ty(selfcodegen_cx.tcx, ty) + clif_pair_type_from_ty(self.codegen_cx.tcx, ty) } pub(crate) fn get_block(&self, bb: BasicBlock) -> Block { @@ -381,8 +381,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); - let caller = selfcodegen_cx.tcx.sess.source_map().lookup_char_pos(topmost.lo()); - let const_loc = selfcodegen_cx.tcx.const_caller_location(( + let caller = self.codegen_cx.tcx.sess.source_map().lookup_char_pos(topmost.lo()); + let const_loc = self.codegen_cx.tcx.const_caller_location(( rustc_span::symbol::Symbol::intern(&caller.file.name.to_string()), caller.line as u32, caller.col_display as u32 + 1, @@ -390,12 +390,12 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { crate::constant::trans_const_value( self, const_loc, - selfcodegen_cx.tcx.caller_location_ty(), + self.codegen_cx.tcx.caller_location_ty(), ) } pub(crate) fn triple(&self) -> &target_lexicon::Triple { - selfcodegen_cx.module.isa().triple() + self.codegen_cx.module.isa().triple() } pub(crate) fn anonymous_str(&mut self, prefix: &str, msg: &str) -> Value { @@ -408,7 +408,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let mut data_ctx = DataContext::new(); data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice()); let msg_id = self - codegen_cx.module + .codegen_cx.module .declare_data( &format!("__{}_{:08x}", prefix, msg_hash), Linkage::Local, @@ -419,9 +419,9 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { .unwrap(); // Ignore DuplicateDefinition error, as the data will be the same - let _ = selfcodegen_cx.module.define_data(msg_id, &data_ctx); + let _ = self.codegen_cx.module.define_data(msg_id, &data_ctx); - let local_msg_id = selfcodegen_cx.module.declare_data_in_func(msg_id, self.bcx.func); + let local_msg_id = self.codegen_cx.module.declare_data_in_func(msg_id, self.bcx.func); #[cfg(debug_assertions)] { self.add_comment(local_msg_id, msg); diff --git a/src/constant.rs b/src/constant.rs index 1eb6042b0b281..2e0dd9d7edc06 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -41,10 +41,10 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Backend>) { match const_.val { ConstKind::Value(_) => {} ConstKind::Unevaluated(def, ref substs, promoted) => { - if let Err(err) = fxcodegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + if let Err(err) = fx.codegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { match err { ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { - fxcodegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.codegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } ErrorHandled::TooGeneric => { span_bug!(constant.span, "codgen encountered polymorphic constant: {:?}", err); @@ -67,8 +67,8 @@ pub(crate) fn codegen_tls_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { - let data_id = data_id_for_static(fxcodegen_cx.tcx, fxcodegen_cx.module, def_id, false); - let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_static(fx.codegen_cx.tcx, fx.codegen_cx.module, def_id, false); + let local_data_id = fx.codegen_cx.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); @@ -80,8 +80,8 @@ fn codegen_static_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fxcodegen_cx.tcx, fxcodegen_cx.module, def_id, false); - let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_static(fx.codegen_cx.tcx, fx.codegen_cx.module, def_id, false); + let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); @@ -97,7 +97,7 @@ pub(crate) fn trans_constant<'tcx>( let const_ = fx.monomorphize(&constant.literal); let const_val = match const_.val { ConstKind::Value(const_val) => const_val, - ConstKind::Unevaluated(def, ref substs, promoted) if fxcodegen_cx.tcx.is_static(def.did) => { + ConstKind::Unevaluated(def, ref substs, promoted) if fx.codegen_cx.tcx.is_static(def.did) => { assert!(substs.is_empty()); assert!(promoted.is_none()); @@ -108,11 +108,11 @@ pub(crate) fn trans_constant<'tcx>( ).to_cvalue(fx); } ConstKind::Unevaluated(def, ref substs, promoted) => { - match fxcodegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + match fx.codegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { Ok(const_val) => const_val, Err(_) => { if promoted.is_none() { - fxcodegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.codegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } return crate::trap::trap_unreachable_ret_value( fx, @@ -154,7 +154,7 @@ pub(crate) fn trans_const_value<'tcx>( ); let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used alloc.write_scalar(fx, ptr, x.into(), size).unwrap(); - let alloc = fxcodegen_cx.tcx.intern_const_alloc(alloc); + let alloc = fx.codegen_cx.tcx.intern_const_alloc(alloc); return CValue::by_ref(pointer_for_allocation(fx, alloc), layout); } @@ -164,25 +164,25 @@ pub(crate) fn trans_const_value<'tcx>( return CValue::const_val(fx, layout, data); } Scalar::Ptr(ptr) => { - let alloc_kind = fxcodegen_cx.tcx.get_global_alloc(ptr.alloc_id); + let alloc_kind = fx.codegen_cx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { - fxcodegen_cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); - let data_id = data_id_for_alloc_id(fxcodegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); - let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); + let data_id = data_id_for_alloc_id(fx.codegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); + let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", ptr.alloc_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { - let func_id = crate::abi::import_function(fxcodegen_cx.tcx, fxcodegen_cx.module, instance); - let local_func_id = fxcodegen_cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); + let func_id = crate::abi::import_function(fx.codegen_cx.tcx, fx.codegen_cx.module, instance); + let local_func_id = fx.codegen_cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) } Some(GlobalAlloc::Static(def_id)) => { - assert!(fxcodegen_cx.tcx.is_static(def_id)); - let data_id = data_id_for_static(fxcodegen_cx.tcx, fxcodegen_cx.module, def_id, false); - let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + assert!(fx.codegen_cx.tcx.is_static(def_id)); + let data_id = data_id_for_static(fx.codegen_cx.tcx, fx.codegen_cx.module, def_id, false); + let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) @@ -215,11 +215,11 @@ fn pointer_for_allocation<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { - let alloc_id = fxcodegen_cx.tcx.create_memory_alloc(alloc); - fxcodegen_cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(fxcodegen_cx.module, alloc_id, alloc.align, alloc.mutability); + let alloc_id = fx.codegen_cx.tcx.create_memory_alloc(alloc); + fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); + let data_id = data_id_for_alloc_id(fx.codegen_cx.module, alloc_id, alloc.align, alloc.mutability); - let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", alloc_id)); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); @@ -419,7 +419,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( match operand { Operand::Copy(_) | Operand::Move(_) => None, Operand::Constant(const_) => { - Some(fx.monomorphize(&const_.literal).eval(fxcodegen_cx.tcx, ParamEnv::reveal_all())) + Some(fx.monomorphize(&const_.literal).eval(fx.codegen_cx.tcx, ParamEnv::reveal_all())) } } } diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 1ceb8b4af2417..6167fb8a56d10 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -95,7 +95,7 @@ fn line_program_add_file( impl<'tcx> DebugContext<'tcx> { pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { - let loc = selfcodegen_cx.tcx.sess.source_map().lookup_char_pos(span.lo()); + let loc = self.codegen_cx.tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file( &mut self.dwarf.unit.line_program, @@ -129,7 +129,7 @@ impl<'tcx> DebugContext<'tcx> { function_span: Span, source_info_set: &indexmap::IndexSet, ) -> CodeOffset { - let tcx = selfcodegen_cx.tcx; + let tcx = self.codegen_cx.tcx; let line_program = &mut self.dwarf.unit.line_program; let func = &context.func; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 7385eb296d250..54d51e4d41af0 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -165,7 +165,7 @@ impl<'tcx> DebugContext<'tcx> { }; let name = format!("{}", ty); - let layout = selfcodegen_cx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + let layout = self.codegen_cx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); let type_id = match ty.kind { ty::Bool => primitive(&mut self.dwarf, gimli::DW_ATE_boolean), @@ -203,7 +203,7 @@ impl<'tcx> DebugContext<'tcx> { for (field_idx, field_def) in variant.fields.iter().enumerate() { let field_offset = layout.fields.offset(field_idx); let field_layout = layout.field(&layout::LayoutCx { - tcx: selfcodegen_cx.tcx, + tcx: self.codegen_cx.tcx, param_env: ParamEnv::reveal_all(), }, field_idx).unwrap(); @@ -261,7 +261,7 @@ impl<'tcx> DebugContext<'tcx> { local_map: FxHashMap>, ) { let symbol = func_id.as_u32() as usize; - let mir = selfcodegen_cx.tcx.instance_mir(instance.def); + let mir = self.codegen_cx.tcx.instance_mir(instance.def); // FIXME: add to appropriate scope instead of root let scope = self.dwarf.unit.root(); @@ -336,7 +336,7 @@ impl<'tcx> DebugContext<'tcx> { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); for (local, _local_decl) in mir.local_decls.iter_enumerated() { - let ty = selfcodegen_cx.tcx.subst_and_normalize_erasing_regions( + let ty = self.codegen_cx.tcx.subst_and_normalize_erasing_regions( instance.substs, ty::ParamEnv::reveal_all(), &mir.local_decls[local].ty, diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 06beda1da3f80..0c3686f4bb066 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -54,7 +54,7 @@ impl<'tcx> UnwindContext<'tcx> { } pub(crate) fn emit(self, product: &mut P) { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(selfcodegen_cx.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.codegen_cx.tcx))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if !eh_frame.0.writer.slice().is_empty() { @@ -74,7 +74,7 @@ impl<'tcx> UnwindContext<'tcx> { self, jit_module: &mut Module, ) -> Option { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(selfcodegen_cx.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.codegen_cx.tcx))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if eh_frame.0.writer.slice().is_empty() { diff --git a/src/discriminant.rs b/src/discriminant.rs index 89568e2344a1a..efe95322aae3b 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -26,7 +26,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( let ptr = place.place_field(fx, mir::Field::new(tag_field)); let to = layout .ty - .discriminant_for_variant(fxcodegen_cx.tcx, variant_index) + .discriminant_for_variant(fx.codegen_cx.tcx, variant_index) .unwrap() .val; let discr = CValue::const_val(fx, ptr.layout(), to); @@ -73,7 +73,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>( Variants::Single { index } => { let discr_val = layout .ty - .discriminant_for_variant(fxcodegen_cx.tcx, *index) + .discriminant_for_variant(fx.codegen_cx.tcx, *index) .map_or(u128::from(index.as_u32()), |discr| discr.val); return CValue::const_val(fx, dest_layout, discr_val); } diff --git a/src/driver/mod.rs b/src/driver/mod.rs index ab397d7c7fd46..81f0e874b3a02 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -33,14 +33,14 @@ fn codegen_mono_items<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Backend + 'static>, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { - cxcodegen_cx.tcx.sess.time("predefine functions", || { + cx.codegen_cx.tcx.sess.time("predefine functions", || { for &(mono_item, (linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = - get_function_name_and_sig(cxcodegen_cx.tcx, cxcodegen_cx.module.isa().triple(), instance, false); + get_function_name_and_sig(cx.codegen_cx.tcx, cx.codegen_cx.module.isa().triple(), instance, false); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - cxcodegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); + cx.codegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); } MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} } @@ -58,7 +58,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( mono_item: MonoItem<'tcx>, linkage: Linkage, ) { - let tcx = cxcodegen_cx.tcx; + let tcx = cx.codegen_cx.tcx; match mono_item { MonoItem::Fn(inst) => { let _inst_guard = @@ -85,10 +85,10 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( } }); - cxcodegen_cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); + cx.codegen_cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { - crate::constant::codegen_static(&mut cxcodegen_cx.constants_cx, def_id); + crate::constant::codegen_static(&mut cx.codegen_cx.constants_cx, def_id); } MonoItem::GlobalAsm(hir_id) => { let item = tcx.hir().expect_item(hir_id); diff --git a/src/inline_asm.rs b/src/inline_asm.rs index ed4b1d6e43072..45ade1f7a0bfd 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -70,7 +70,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( let inline_asm_index = fx.inline_asm_index; fx.inline_asm_index += 1; - let asm_name = format!("{}__inline_asm_{}", fxcodegen_cx.tcx.symbol_name(fx.instance).name, inline_asm_index); + let asm_name = format!("{}__inline_asm_{}", fx.codegen_cx.tcx.symbol_name(fx.instance).name, inline_asm_index); let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); fx.global_asm.push_str(&generated_asm); @@ -169,12 +169,12 @@ fn call_inline_asm<'tcx>( #[cfg(debug_assertions)] fx.add_comment(stack_slot, "inline asm scratch slot"); - let inline_asm_func = fxcodegen_cx.module.declare_function(asm_name, Linkage::Import, &Signature { + let inline_asm_func = fx.codegen_cx.module.declare_function(asm_name, Linkage::Import, &Signature { call_conv: CallConv::SystemV, params: vec![AbiParam::new(fx.pointer_type)], returns: vec![], }).unwrap(); - let inline_asm_func = fxcodegen_cx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); + let inline_asm_func = fx.codegen_cx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(inline_asm_func, asm_name); diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index 8e8665f780343..171eb51ccdff0 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -30,13 +30,13 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fxcodegen_cx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); + fx.codegen_cx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); crate::trap::trap_unimplemented(fx, intrinsic); }; // Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8` llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb | llvm.x86.sse2.movmsk.pd, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, a.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, a.layout()); let lane_ty = fx.clif_type(lane_layout.ty).unwrap(); assert!(lane_count <= 32); @@ -61,7 +61,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( res = fx.bcx.ins().bor(res, a_lane_sign); } - let res = CValue::by_val(res, fx.layout_of(fxcodegen_cx.tcx.types.i32)); + let res = CValue::by_val(res, fx.layout_of(fx.codegen_cx.tcx.types.i32)); ret.write_cvalue(fx, res); }; llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) { diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 1ff05170d7378..f73e9f765c02d 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -88,7 +88,7 @@ macro call_intrinsic_match { let ($($arg,)*) = ( $(trans_operand($fx, $arg),)* ); - let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fxcodegen_cx.tcx.types.$ty); + let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.codegen_cx.tcx.types.$ty); $ret.write_cvalue($fx, res); if let Some((_, dest)) = $destination { @@ -144,7 +144,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { match $ty.kind { ty::Uint(_) | ty::Int(_) => {} _ => { - $fxcodegen_cx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); + $fx.codegen_cx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -154,7 +154,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { macro validate_simd_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { if !$ty.is_simd() { - $fxcodegen_cx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); + $fx.codegen_cx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -203,8 +203,8 @@ fn simd_for_each_lane<'tcx, B: Backend>( ) { let layout = val.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane_idx in 0..lane_count { @@ -233,8 +233,8 @@ fn simd_pair_for_each_lane<'tcx, B: Backend>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { @@ -273,7 +273,7 @@ fn bool_to_zero_or_max_uint<'tcx>( macro simd_cmp { ($fx:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { - let vector_ty = clif_vector_type($fxcodegen_cx.tcx, $x.layout()); + let vector_ty = clif_vector_type($fx.codegen_cx.tcx, $x.layout()); if let Some(vector_ty) = vector_ty { let x = $x.load_scalar($fx); @@ -390,7 +390,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fxcodegen_cx.tcx.item_name(def_id).as_str(); + let intrinsic = fx.codegen_cx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; let ret = match destination { @@ -423,7 +423,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( return; } - let usize_layout = fx.layout_of(fxcodegen_cx.tcx.types.usize); + let usize_layout = fx.layout_of(fx.codegen_cx.tcx.types.usize); call_intrinsic_match! { fx, intrinsic, substs, ret, destination, args, @@ -473,7 +473,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fxcodegen_cx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); + fx.codegen_cx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); }; assume, (c _a) {}; @@ -494,10 +494,10 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( if intrinsic.contains("nonoverlapping") { // FIXME emit_small_memcpy - fx.bcx.call_memcpy(fxcodegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memcpy(fx.codegen_cx.module.target_config(), dst, src, byte_amount); } else { // FIXME emit_small_memmove - fx.bcx.call_memmove(fxcodegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memmove(fx.codegen_cx.module.target_config(), dst, src, byte_amount); } }; // NOTE: the volatile variants have src and dst swapped @@ -513,10 +513,10 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( // FIXME make the copy actually volatile when using emit_small_mem{cpy,move} if intrinsic.contains("nonoverlapping") { // FIXME emit_small_memcpy - fx.bcx.call_memcpy(fxcodegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memcpy(fx.codegen_cx.module.target_config(), dst, src, byte_amount); } else { // FIXME emit_small_memmove - fx.bcx.call_memmove(fxcodegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memmove(fx.codegen_cx.module.target_config(), dst, src, byte_amount); } }; discriminant_value, (c ptr) { @@ -680,11 +680,11 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let dst_ptr = dst.load_scalar(fx); // FIXME make the memset actually volatile when switching to emit_small_memset // FIXME use emit_small_memset - fx.bcx.call_memset(fxcodegen_cx.module.target_config(), dst_ptr, val, count); + fx.bcx.call_memset(fx.codegen_cx.module.target_config(), dst_ptr, val, count); }; ctlz | ctlz_nonzero, (v arg) { // FIXME trap on `ctlz_nonzero` with zero arg. - let res = if T == fxcodegen_cx.tcx.types.u128 || T == fxcodegen_cx.tcx.types.i128 { + let res = if T == fx.codegen_cx.tcx.types.u128 || T == fx.codegen_cx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_lz = fx.bcx.ins().clz(lsb); @@ -701,7 +701,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; cttz | cttz_nonzero, (v arg) { // FIXME trap on `cttz_nonzero` with zero arg. - let res = if T == fxcodegen_cx.tcx.types.u128 || T == fxcodegen_cx.tcx.types.i128 { + let res = if T == fx.codegen_cx.tcx.types.u128 || T == fx.codegen_cx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_tz = fx.bcx.ins().ctz(lsb); @@ -842,7 +842,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () { let const_val = - fxcodegen_cx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); + fx.codegen_cx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); let val = crate::constant::trans_const_value( fx, const_val, @@ -852,7 +852,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ptr_offset_from, (v ptr, v base) { - let isize_layout = fx.layout_of(fxcodegen_cx.tcx.types.isize); + let isize_layout = fx.layout_of(fx.codegen_cx.tcx.types.isize); let pointee_size: u64 = fx.layout_of(T).size.bytes(); let diff = fx.bcx.ins().isub(ptr, base); @@ -1011,22 +1011,22 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( minnumf32, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f32)); ret.write_cvalue(fx, val); }; minnumf64, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f64)); ret.write_cvalue(fx, val); }; maxnumf32, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f32)); ret.write_cvalue(fx, val); }; maxnumf64, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f64)); ret.write_cvalue(fx, val); }; diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index b6e63a52469a3..bdda4bd984034 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -11,13 +11,13 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fxcodegen_cx.tcx.item_name(def_id).as_str(); + let intrinsic = fx.codegen_cx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; intrinsic_match! { fx, intrinsic, substs, args, _ => { - fxcodegen_cx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); + fx.codegen_cx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); }; simd_cast, (c a) { @@ -68,8 +68,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_type, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); - let (ret_lane_type, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); + let (lane_type, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); + let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); assert_eq!(lane_type, ret_lane_type); assert_eq!(n, ret_lane_count); @@ -92,7 +92,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( (0..ret_lane_count).map(|i| { let i = usize::try_from(i).unwrap(); let idx = rustc_middle::mir::interpret::read_target_uint( - fxcodegen_cx.tcx.data_layout.endian, + fx.codegen_cx.tcx.data_layout.endian, &idx_bytes[4*i.. 4*i + 4], ).expect("read_target_uint"); u16::try_from(idx).expect("try_from u32") @@ -119,7 +119,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fxcodegen_cx.tcx.sess.span_warn( + fx.codegen_cx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -128,9 +128,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, base.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, base.layout()); if idx >= lane_count.into() { - fxcodegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); + fx.codegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); } ret.write_cvalue(fx, base); @@ -143,7 +143,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fxcodegen_cx.tcx.sess.span_warn( + fx.codegen_cx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -153,9 +153,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, v.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, v.layout()); if idx >= lane_count.into() { - fxcodegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); + fx.codegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); } let ret_lane = v.value_field(fx, mir::Field::new(idx.try_into().unwrap())); @@ -205,8 +205,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(a.layout(), c.layout()); let layout = a.layout(); - let (_lane_layout, lane_count) = lane_type_and_count(fxcodegen_cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fxcodegen_cx.tcx, ret.layout()); + let (_lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { diff --git a/src/lib.rs b/src/lib.rs index 9ab9ad8c81a35..87e8936a53e17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,8 +160,8 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { - selfcodegen_cx.constants_cx.finalize(selfcodegen_cx.tcx, &mut selfcodegen_cx.module); - (selfcodegen_cx.module, self.global_asm, self.debug_context, self.unwind_context) + self.codegen_cx.constants_cx.finalize(self.codegen_cx.tcx, &mut self.codegen_cx.module); + (self.codegen_cx.module, self.global_asm, self.debug_context, self.unwind_context) } } diff --git a/src/num.rs b/src/num.rs index ef5bd105b1aec..06721e1af127c 100644 --- a/src/num.rs +++ b/src/num.rs @@ -48,7 +48,7 @@ fn codegen_compare_bin_op<'tcx>( let intcc = crate::num::bin_op_to_intcc(bin_op, signed).unwrap(); let val = fx.bcx.ins().icmp(intcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.bool)) + CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.bool)) } pub(crate) fn codegen_binop<'tcx>( @@ -66,8 +66,8 @@ pub(crate) fn codegen_binop<'tcx>( let rhs = in_rhs.load_scalar(fx); let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (in_lhs.layout().ty.kind == fxcodegen_cx.tcx.types.i8.kind - || in_lhs.layout().ty.kind == fxcodegen_cx.tcx.types.i16.kind) + && (in_lhs.layout().ty.kind == fx.codegen_cx.tcx.types.i8.kind + || in_lhs.layout().ty.kind == fx.codegen_cx.tcx.types.i16.kind) { // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. ( @@ -118,7 +118,7 @@ pub(crate) fn trans_bool_binop<'tcx>( _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; - CValue::by_val(res, fx.layout_of(fxcodegen_cx.tcx.types.bool)) + CValue::by_val(res, fx.layout_of(fx.codegen_cx.tcx.types.bool)) } pub(crate) fn trans_int_binop<'tcx>( @@ -323,7 +323,7 @@ pub(crate) fn trans_checked_int_binop<'tcx>( // FIXME directly write to result place instead let out_place = CPlace::new_stack_slot( fx, - fx.layout_of(fxcodegen_cx.tcx.mk_tup([in_lhs.layout().ty, fxcodegen_cx.tcx.types.bool].iter())), + fx.layout_of(fx.codegen_cx.tcx.mk_tup([in_lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter())), ); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); @@ -368,7 +368,7 @@ pub(crate) fn trans_float_binop<'tcx>( }; let val = fx.bcx.ins().fcmp(fltcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - return CValue::by_val(val, fx.layout_of(fxcodegen_cx.tcx.types.bool)); + return CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.bool)); } _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; @@ -383,7 +383,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { let is_thin_ptr = in_lhs.layout().ty.builtin_deref(true).map(|TypeAndMut { ty, mutbl: _}| { - !has_ptr_meta(fxcodegen_cx.tcx, ty) + !has_ptr_meta(fx.codegen_cx.tcx, ty) }).unwrap_or(true); if is_thin_ptr { @@ -440,7 +440,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( CValue::by_val( fx.bcx.ins().bint(types::I8, res), - fx.layout_of(fxcodegen_cx.tcx.types.bool), + fx.layout_of(fx.codegen_cx.tcx.types.bool), ) } } diff --git a/src/trap.rs b/src/trap.rs index 2f059e2847657..d48bf6a4298c9 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -2,24 +2,24 @@ use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { let puts = fx - codegen_cx.module + .codegen_cx.module .declare_function( "puts", Linkage::Import, &Signature { call_conv: CallConv::triple_default(fx.triple()), - params: vec![AbiParam::new(pointer_ty(fxcodegen_cx.tcx))], + params: vec![AbiParam::new(pointer_ty(fx.codegen_cx.tcx))], returns: vec![AbiParam::new(types::I32)], }, ) .unwrap(); - let puts = fxcodegen_cx.module.declare_func_in_func(puts, &mut fx.bcx.func); + let puts = fx.codegen_cx.module.declare_func_in_func(puts, &mut fx.bcx.func); #[cfg(debug_assertions)] { fx.add_comment(puts, "puts"); } - let symbol_name = fxcodegen_cx.tcx.symbol_name(fx.instance); + let symbol_name = fx.codegen_cx.tcx.symbol_name(fx.instance); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); let msg_ptr = fx.anonymous_str("trap", &real_msg); fx.bcx.ins().call(puts, &[msg_ptr]); diff --git a/src/unsize.rs b/src/unsize.rs index 363186a8c6425..fec1bfd799f6a 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -15,12 +15,12 @@ pub(crate) fn unsized_info<'tcx>( old_info: Option, ) -> Value { let (source, target) = - fxcodegen_cx.tcx + fx.codegen_cx.tcx .struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); match (&source.kind, &target.kind) { (&ty::Array(_, len), &ty::Slice(_)) => fx.bcx.ins().iconst( fx.pointer_type, - len.eval_usize(fxcodegen_cx.tcx, ParamEnv::reveal_all()) as i64, + len.eval_usize(fx.codegen_cx.tcx, ParamEnv::reveal_all()) as i64, ), (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 8db4afa00f932..4483691013daf 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -35,10 +35,10 @@ fn codegen_field<'tcx>( let unaligned_offset = field_offset.bytes(); let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout, extra); - let one = fx.bcx.ins().iconst(pointer_ty(fxcodegen_cx.tcx), 1); + let one = fx.bcx.ins().iconst(pointer_ty(fx.codegen_cx.tcx), 1); let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); let and_lhs = fx.bcx.ins().iadd_imm(align_sub_1, unaligned_offset as i64); - let zero = fx.bcx.ins().iconst(pointer_ty(fxcodegen_cx.tcx), 0); + let zero = fx.bcx.ins().iconst(pointer_ty(fx.codegen_cx.tcx), 0); let and_rhs = fx.bcx.ins().isub(zero, unsized_align); let offset = fx.bcx.ins().band(and_lhs, and_rhs); @@ -119,9 +119,9 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.abi { - Abi::Scalar(ref scalar) => scalar_to_clif_type(fxcodegen_cx.tcx, scalar.clone()), + Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.codegen_cx.tcx, scalar.clone()), Abi::Vector { ref element, count } => { - scalar_to_clif_type(fxcodegen_cx.tcx, element.clone()) + scalar_to_clif_type(fx.codegen_cx.tcx, element.clone()) .by(u16::try_from(count).unwrap()).unwrap() } _ => unreachable!("{:?}", layout.ty), @@ -146,9 +146,9 @@ impl<'tcx> CValue<'tcx> { Abi::ScalarPair(a, b) => (a, b), _ => unreachable!("load_scalar_pair({:?})", self), }; - let b_offset = scalar_pair_calculate_b_offset(fxcodegen_cx.tcx, a_scalar, b_scalar); - let clif_ty1 = scalar_to_clif_type(fxcodegen_cx.tcx, a_scalar.clone()); - let clif_ty2 = scalar_to_clif_type(fxcodegen_cx.tcx, b_scalar.clone()); + let b_offset = scalar_pair_calculate_b_offset(fx.codegen_cx.tcx, a_scalar, b_scalar); + let clif_ty1 = scalar_to_clif_type(fx.codegen_cx.tcx, a_scalar.clone()); + let clif_ty2 = scalar_to_clif_type(fx.codegen_cx.tcx, b_scalar.clone()); let val1 = ptr.load(fx, clif_ty1, MemFlags::new()); let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); (val1, val2) @@ -419,13 +419,13 @@ impl<'tcx> CPlace<'tcx> { assert_assignable(fx, a, b); } (ty::FnPtr(_), ty::FnPtr(_)) => { - let from_sig = fxcodegen_cx.tcx.normalize_erasing_late_bound_regions( + let from_sig = fx.codegen_cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &from_ty.fn_sig(fxcodegen_cx.tcx), + &from_ty.fn_sig(fx.codegen_cx.tcx), ); - let to_sig = fxcodegen_cx.tcx.normalize_erasing_late_bound_regions( + let to_sig = fx.codegen_cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &to_ty.fn_sig(fxcodegen_cx.tcx), + &to_ty.fn_sig(fx.codegen_cx.tcx), ); assert_eq!( from_sig, to_sig, @@ -436,10 +436,10 @@ impl<'tcx> CPlace<'tcx> { } (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { let from_traits = fx - codegen_cx.tcx + .codegen_cx.tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), from_traits); let to_traits = fx - codegen_cx.tcx + .codegen_cx.tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), to_traits); assert_eq!( from_traits, to_traits, @@ -569,7 +569,7 @@ impl<'tcx> CPlace<'tcx> { } Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let (value, extra) = from.load_scalar_pair(fx); - let b_offset = scalar_pair_calculate_b_offset(fxcodegen_cx.tcx, a_scalar, b_scalar); + let b_offset = scalar_pair_calculate_b_offset(fx.codegen_cx.tcx, a_scalar, b_scalar); to_ptr.store(fx, value, MemFlags::new()); to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); return; @@ -595,7 +595,7 @@ impl<'tcx> CPlace<'tcx> { let src_align = src_layout.align.abi.bytes() as u8; let dst_align = dst_layout.align.abi.bytes() as u8; fx.bcx.emit_small_memory_copy( - fxcodegen_cx.module.target_config(), + fx.codegen_cx.module.target_config(), to_addr, from_addr, size, @@ -673,7 +673,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); - if has_ptr_meta(fxcodegen_cx.tcx, inner_layout.ty) { + if has_ptr_meta(fx.codegen_cx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); CPlace::for_ptr_with_extra(Pointer::new(addr), extra, inner_layout) } else { @@ -682,7 +682,7 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - if has_ptr_meta(fxcodegen_cx.tcx, self.layout().ty) { + if has_ptr_meta(fx.codegen_cx.tcx, self.layout().ty) { let (ptr, extra) = self.to_ptr_maybe_unsized(); let ptr = CValue::by_val_pair( ptr.get_addr(fx), diff --git a/src/vtable.rs b/src/vtable.rs index f11c881a65dd6..6a179b3dfeb41 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -13,9 +13,9 @@ fn vtable_memflags() -> MemFlags { } pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fxcodegen_cx.tcx), + pointer_ty(fx.codegen_cx.tcx), vtable_memflags(), vtable, (DROP_FN_INDEX * usize_size) as i32, @@ -23,9 +23,9 @@ pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: } pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fxcodegen_cx.tcx), + pointer_ty(fx.codegen_cx.tcx), vtable_memflags(), vtable, (SIZE_INDEX * usize_size) as i32, @@ -33,9 +33,9 @@ pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Val } pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fxcodegen_cx.tcx), + pointer_ty(fx.codegen_cx.tcx), vtable_memflags(), vtable, (ALIGN_INDEX * usize_size) as i32, @@ -57,9 +57,9 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( ) }; - let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes(); + let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( - pointer_ty(fxcodegen_cx.tcx), + pointer_ty(fx.codegen_cx.tcx), vtable_memflags(), vtable, ((idx + 3) * usize_size as usize) as i32, @@ -80,7 +80,7 @@ pub(crate) fn get_vtable<'tcx>( data_id }; - let local_data_id = fxcodegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } @@ -89,11 +89,11 @@ fn build_vtable<'tcx>( layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> DataId { - let tcx = fxcodegen_cx.tcx; - let usize_size = fx.layout_of(fxcodegen_cx.tcx.types.usize).size.bytes() as usize; + let tcx = fx.codegen_cx.tcx; + let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, fxcodegen_cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fxcodegen_cx.tcx)); + import_function(tcx, fx.codegen_cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.codegen_cx.tcx)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -108,8 +108,8 @@ fn build_vtable<'tcx>( opt_mth.map_or(None, |(def_id, substs)| { Some(import_function( tcx, - fxcodegen_cx.module, - Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fxcodegen_cx.tcx), + fx.codegen_cx.module, + Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.codegen_cx.tcx), )) }) }); @@ -121,19 +121,19 @@ fn build_vtable<'tcx>( .collect::>() .into_boxed_slice(); - write_usize(fxcodegen_cx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); - write_usize(fxcodegen_cx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); + write_usize(fx.codegen_cx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); + write_usize(fx.codegen_cx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); data_ctx.define(data); for (i, component) in components.into_iter().enumerate() { if let Some(func_id) = component { - let func_ref = fxcodegen_cx.module.declare_func_in_data(func_id, &mut data_ctx); + let func_ref = fx.codegen_cx.module.declare_func_in_data(func_id, &mut data_ctx); data_ctx.write_function_addr((i * usize_size) as u32, func_ref); } } let data_id = fx - codegen_cx.module + .codegen_cx.module .declare_data( &format!( "__vtable.{}.for.{:?}.{}", @@ -148,7 +148,7 @@ fn build_vtable<'tcx>( false, false, Some( - fxcodegen_cx.tcx + fx.codegen_cx.tcx .data_layout .pointer_align .pref @@ -159,7 +159,7 @@ fn build_vtable<'tcx>( ) .unwrap(); - fxcodegen_cx.module.define_data(data_id, &data_ctx).unwrap(); + fx.codegen_cx.module.define_data(data_id, &data_ctx).unwrap(); data_id } From 1a6365f95f1f41cc9225695f50a5a43f8ecf1833 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 15:25:36 +0200 Subject: [PATCH 1469/1566] FunctionCx: WIP: Fix overzealous sed usage --- src/base.rs | 2 +- src/common.rs | 2 +- src/constant.rs | 4 ++-- src/driver/mod.rs | 2 +- src/lib.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/base.rs b/src/base.rs index cbb845af77c1b..bdcb931b827b7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -49,7 +49,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( cold_blocks: EntitySet::new(), clif_comments, - constants_cx: &mut cx.codegen_cx.constants_cx, + constants_cx: &mut cx.constants_cx, vtables: &mut cx.vtables, source_info_set: indexmap::IndexSet::new(), next_ssa_var: 0, diff --git a/src/common.rs b/src/common.rs index d959ddc2f4d41..df91668c1e975 100644 --- a/src/common.rs +++ b/src/common.rs @@ -265,7 +265,7 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool { } pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { - pub(crate) .codegen_cx: &'clif CodegenCx<'tcx, B>, + pub(crate) codegen_cx: &'clif mut crate::CodegenCx<'tcx, B>, pub(crate) global_asm: &'clif mut String, pub(crate) pointer_type: Type, // Cached from module diff --git a/src/constant.rs b/src/constant.rs index 2e0dd9d7edc06..3c05e4aa793ed 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -167,7 +167,7 @@ pub(crate) fn trans_const_value<'tcx>( let alloc_kind = fx.codegen_cx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { - fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); + fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); let data_id = data_id_for_alloc_id(fx.codegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] @@ -216,7 +216,7 @@ fn pointer_for_allocation<'tcx>( alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { let alloc_id = fx.codegen_cx.tcx.create_memory_alloc(alloc); - fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); + fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(fx.codegen_cx.module, alloc_id, alloc.align, alloc.mutability); let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 81f0e874b3a02..797039d0fd2ec 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -88,7 +88,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( cx.codegen_cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { - crate::constant::codegen_static(&mut cx.codegen_cx.constants_cx, def_id); + crate::constant::codegen_static(&mut cx.constants_cx, def_id); } MonoItem::GlobalAsm(hir_id) => { let item = tcx.hir().expect_item(hir_id); diff --git a/src/lib.rs b/src/lib.rs index 87e8936a53e17..b9acc27efdf95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,7 +160,7 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { - self.codegen_cx.constants_cx.finalize(self.codegen_cx.tcx, &mut self.codegen_cx.module); + self.constants_cx.finalize(self.codegen_cx.tcx, &mut self.codegen_cx.module); (self.codegen_cx.module, self.global_asm, self.debug_context, self.unwind_context) } } From 429e75fe4007835e60e76bff38ed5d97cd134af3 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 15:49:16 +0200 Subject: [PATCH 1470/1566] FunctionCx: WIP: Remove more common fields from CodegenCx --- src/abi/mod.rs | 2 +- src/base.rs | 26 +++++++++++--------------- src/common.rs | 3 --- src/constant.rs | 16 ++++++++-------- src/debuginfo/line_info.rs | 4 ++-- src/debuginfo/mod.rs | 8 ++++---- src/debuginfo/unwind.rs | 4 ++-- src/driver/mod.rs | 10 +++++----- src/lib.rs | 4 ++-- src/vtable.rs | 4 ++-- 10 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index ca6680f1e14d2..65613754d0666 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -226,7 +226,7 @@ pub(crate) fn import_function<'tcx>( impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let func_id = import_function(self.codegen_cx.tcx, self.codegen_cx.module, inst); + let func_id = import_function(self.codegen_cx.tcx, &mut self.codegen_cx.module, inst); let func_ref = self .codegen_cx.module .declare_func_in_func(func_id, &mut self.bcx.func); diff --git a/src/base.rs b/src/base.rs index bdcb931b827b7..92d910dd9984e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -8,13 +8,13 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( instance: Instance<'tcx>, linkage: Linkage, ) { - let tcx = cx.codegen_cx.tcx; + let tcx = cx.tcx; let mir = tcx.instance_mir(instance.def); // Declare function - let (name, sig) = get_function_name_and_sig(tcx, cx.codegen_cx.module.isa().triple(), instance, false); - let func_id = cx.codegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); + let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); + let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); // Make FunctionBuilder let context = &mut cx.cached_context; @@ -30,13 +30,11 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let block_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_block()).collect(); // Make FunctionCx - let pointer_type = cx.codegen_cx.module.target_config().pointer_type(); + let pointer_type = cx.module.target_config().pointer_type(); let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance); let mut fx = FunctionCx { - tcx, - module: &mut cx.codegen_cx.module, - global_asm: &mut cx.global_asm, + codegen_cx: cx, pointer_type, instance, @@ -49,8 +47,6 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( cold_blocks: EntitySet::new(), clif_comments, - constants_cx: &mut cx.constants_cx, - vtables: &mut cx.vtables, source_info_set: indexmap::IndexSet::new(), next_ssa_var: 0, @@ -78,7 +74,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let cold_blocks = fx.cold_blocks; crate::pretty_clif::write_clif_file( - cx.codegen_cx.tcx, + cx.tcx, "unopt", None, instance, @@ -98,10 +94,10 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // instruction, which doesn't have an encoding. context.compute_cfg(); context.compute_domtree(); - context.eliminate_unreachable_code(cx.codegen_cx.module.isa()).unwrap(); + context.eliminate_unreachable_code(cx.module.isa()).unwrap(); // Define function - let module = &mut cx.codegen_cx.module; + let module = &mut cx.module; tcx.sess.time( "define function", || module.define_function( @@ -113,16 +109,16 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Write optimized function to file for debugging crate::pretty_clif::write_clif_file( - cx.codegen_cx.tcx, + cx.tcx, "opt", - Some(cx.codegen_cx.module.isa()), + Some(cx.module.isa()), instance, &context, &clif_comments, ); // Define debuginfo for function - let isa = cx.codegen_cx.module.isa(); + let isa = cx.module.isa(); let debug_context = &mut cx.debug_context; let unwind_context = &mut cx.unwind_context; tcx.sess.time("generate debug info", || { diff --git a/src/common.rs b/src/common.rs index df91668c1e975..bf7fc57081841 100644 --- a/src/common.rs +++ b/src/common.rs @@ -266,7 +266,6 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool { pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) codegen_cx: &'clif mut crate::CodegenCx<'tcx, B>, - pub(crate) global_asm: &'clif mut String, pub(crate) pointer_type: Type, // Cached from module pub(crate) instance: Instance<'tcx>, @@ -283,8 +282,6 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) cold_blocks: EntitySet, pub(crate) clif_comments: crate::pretty_clif::CommentWriter, - pub(crate) vtables: &'clif mut FxHashMap<(Ty<'tcx>, Option>), DataId>, - pub(crate) source_info_set: indexmap::IndexSet, /// This should only be accessed by `CPlace::new_var`. diff --git a/src/constant.rs b/src/constant.rs index 3c05e4aa793ed..7f047b04c9dcd 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -67,7 +67,7 @@ pub(crate) fn codegen_tls_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { - let data_id = data_id_for_static(fx.codegen_cx.tcx, fx.codegen_cx.module, def_id, false); + let data_id = data_id_for_static(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, def_id, false); let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("tls {:?}", def_id)); @@ -80,7 +80,7 @@ fn codegen_static_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fx.codegen_cx.tcx, fx.codegen_cx.module, def_id, false); + let data_id = data_id_for_static(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, def_id, false); let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); @@ -167,21 +167,21 @@ pub(crate) fn trans_const_value<'tcx>( let alloc_kind = fx.codegen_cx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { - fx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); - let data_id = data_id_for_alloc_id(fx.codegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); + fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); + let data_id = data_id_for_alloc_id(&mut fx.codegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", ptr.alloc_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { - let func_id = crate::abi::import_function(fx.codegen_cx.tcx, fx.codegen_cx.module, instance); + let func_id = crate::abi::import_function(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, instance); let local_func_id = fx.codegen_cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) } Some(GlobalAlloc::Static(def_id)) => { assert!(fx.codegen_cx.tcx.is_static(def_id)); - let data_id = data_id_for_static(fx.codegen_cx.tcx, fx.codegen_cx.module, def_id, false); + let data_id = data_id_for_static(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, def_id, false); let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); @@ -216,8 +216,8 @@ fn pointer_for_allocation<'tcx>( alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { let alloc_id = fx.codegen_cx.tcx.create_memory_alloc(alloc); - fx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(fx.codegen_cx.module, alloc_id, alloc.align, alloc.mutability); + fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); + let data_id = data_id_for_alloc_id(&mut fx.codegen_cx.module, alloc_id, alloc.align, alloc.mutability); let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 6167fb8a56d10..89dccb8545fc6 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -95,7 +95,7 @@ fn line_program_add_file( impl<'tcx> DebugContext<'tcx> { pub(super) fn emit_location(&mut self, entry_id: UnitEntryId, span: Span) { - let loc = self.codegen_cx.tcx.sess.source_map().lookup_char_pos(span.lo()); + let loc = self.tcx.sess.source_map().lookup_char_pos(span.lo()); let file_id = line_program_add_file( &mut self.dwarf.unit.line_program, @@ -129,7 +129,7 @@ impl<'tcx> DebugContext<'tcx> { function_span: Span, source_info_set: &indexmap::IndexSet, ) -> CodeOffset { - let tcx = self.codegen_cx.tcx; + let tcx = self.tcx; let line_program = &mut self.dwarf.unit.line_program; let func = &context.func; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 54d51e4d41af0..2c92fd0e47cc3 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -165,7 +165,7 @@ impl<'tcx> DebugContext<'tcx> { }; let name = format!("{}", ty); - let layout = self.codegen_cx.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); + let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); let type_id = match ty.kind { ty::Bool => primitive(&mut self.dwarf, gimli::DW_ATE_boolean), @@ -203,7 +203,7 @@ impl<'tcx> DebugContext<'tcx> { for (field_idx, field_def) in variant.fields.iter().enumerate() { let field_offset = layout.fields.offset(field_idx); let field_layout = layout.field(&layout::LayoutCx { - tcx: self.codegen_cx.tcx, + tcx: self.tcx, param_env: ParamEnv::reveal_all(), }, field_idx).unwrap(); @@ -261,7 +261,7 @@ impl<'tcx> DebugContext<'tcx> { local_map: FxHashMap>, ) { let symbol = func_id.as_u32() as usize; - let mir = self.codegen_cx.tcx.instance_mir(instance.def); + let mir = self.tcx.instance_mir(instance.def); // FIXME: add to appropriate scope instead of root let scope = self.dwarf.unit.root(); @@ -336,7 +336,7 @@ impl<'tcx> DebugContext<'tcx> { let value_labels_ranges = context.build_value_labels_ranges(isa).unwrap(); for (local, _local_decl) in mir.local_decls.iter_enumerated() { - let ty = self.codegen_cx.tcx.subst_and_normalize_erasing_regions( + let ty = self.tcx.subst_and_normalize_erasing_regions( instance.substs, ty::ParamEnv::reveal_all(), &mir.local_decls[local].ty, diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 0c3686f4bb066..4bc3859652db2 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -54,7 +54,7 @@ impl<'tcx> UnwindContext<'tcx> { } pub(crate) fn emit(self, product: &mut P) { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.codegen_cx.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if !eh_frame.0.writer.slice().is_empty() { @@ -74,7 +74,7 @@ impl<'tcx> UnwindContext<'tcx> { self, jit_module: &mut Module, ) -> Option { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.codegen_cx.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if eh_frame.0.writer.slice().is_empty() { diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 797039d0fd2ec..1d81efb880df7 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -33,14 +33,14 @@ fn codegen_mono_items<'tcx>( cx: &mut crate::CodegenCx<'tcx, impl Backend + 'static>, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { - cx.codegen_cx.tcx.sess.time("predefine functions", || { + cx.tcx.sess.time("predefine functions", || { for &(mono_item, (linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { let (name, sig) = - get_function_name_and_sig(cx.codegen_cx.tcx, cx.codegen_cx.module.isa().triple(), instance, false); + get_function_name_and_sig(cx.tcx, cx.module.isa().triple(), instance, false); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); - cx.codegen_cx.module.declare_function(&name, linkage, &sig).unwrap(); + cx.module.declare_function(&name, linkage, &sig).unwrap(); } MonoItem::Static(_) | MonoItem::GlobalAsm(_) => {} } @@ -58,7 +58,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( mono_item: MonoItem<'tcx>, linkage: Linkage, ) { - let tcx = cx.codegen_cx.tcx; + let tcx = cx.tcx; match mono_item { MonoItem::Fn(inst) => { let _inst_guard = @@ -85,7 +85,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( } }); - cx.codegen_cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); + cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); diff --git a/src/lib.rs b/src/lib.rs index b9acc27efdf95..6394937605a68 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,8 +160,8 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { - self.constants_cx.finalize(self.codegen_cx.tcx, &mut self.codegen_cx.module); - (self.codegen_cx.module, self.global_asm, self.debug_context, self.unwind_context) + self.constants_cx.finalize(self.tcx, &mut self.module); + (self.module, self.global_asm, self.debug_context, self.unwind_context) } } diff --git a/src/vtable.rs b/src/vtable.rs index 6a179b3dfeb41..f4d3a303bd319 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -93,7 +93,7 @@ fn build_vtable<'tcx>( let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, fx.codegen_cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.codegen_cx.tcx)); + import_function(tcx, &mut fx.codegen_cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.codegen_cx.tcx)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -108,7 +108,7 @@ fn build_vtable<'tcx>( opt_mth.map_or(None, |(def_id, substs)| { Some(import_function( tcx, - fx.codegen_cx.module, + &mut fx.codegen_cx.module, Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.codegen_cx.tcx), )) }) From 4cb2a2b793f3fd3cbfce976eeb3a1fbfbf37e7b2 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 16:14:33 +0200 Subject: [PATCH 1471/1566] FunctionCx: Fix field usage in inline_asm and vtable modules --- src/inline_asm.rs | 2 +- src/vtable.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 45ade1f7a0bfd..f0ae0854f84fc 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -73,7 +73,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( let asm_name = format!("{}__inline_asm_{}", fx.codegen_cx.tcx.symbol_name(fx.instance).name, inline_asm_index); let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); - fx.global_asm.push_str(&generated_asm); + fx.codegen_cx.global_asm.push_str(&generated_asm); call_inline_asm(fx, &asm_name, slot_size, inputs, outputs); } diff --git a/src/vtable.rs b/src/vtable.rs index f4d3a303bd319..6be801c844597 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -72,11 +72,11 @@ pub(crate) fn get_vtable<'tcx>( layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> Value { - let data_id = if let Some(data_id) = fx.vtables.get(&(layout.ty, trait_ref)) { + let data_id = if let Some(data_id) = fx.codegen_cx.vtables.get(&(layout.ty, trait_ref)) { *data_id } else { let data_id = build_vtable(fx, layout, trait_ref); - fx.vtables.insert((layout.ty, trait_ref), data_id); + fx.codegen_cx.vtables.insert((layout.ty, trait_ref), data_id); data_id }; @@ -142,7 +142,7 @@ fn build_vtable<'tcx>( .map(|trait_ref| format!("{:?}", trait_ref.skip_binder()).into()) .unwrap_or(std::borrow::Cow::Borrowed("???")), layout.ty, - fx.vtables.len(), + fx.codegen_cx.vtables.len(), ), Linkage::Local, false, From 7b534d653d71c3be1b0c52d3eca7a0dbd0b2936c Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 16:17:58 +0200 Subject: [PATCH 1472/1566] FunctionCx: Rename codegen_cx -> cx --- src/abi/mod.rs | 56 ++++++++++++++++----------------- src/abi/pass_mode.rs | 6 ++-- src/abi/returning.rs | 6 ++-- src/analyze.rs | 4 +-- src/atomic_shim.rs | 28 ++++++++--------- src/base.rs | 70 +++++++++++++++++++++--------------------- src/cast.rs | 16 +++++----- src/codegen_i128.rs | 42 ++++++++++++------------- src/common.rs | 34 ++++++++++---------- src/constant.rs | 48 ++++++++++++++--------------- src/discriminant.rs | 4 +-- src/inline_asm.rs | 8 ++--- src/intrinsics/llvm.rs | 6 ++-- src/intrinsics/mod.rs | 48 ++++++++++++++--------------- src/intrinsics/simd.rs | 26 ++++++++-------- src/num.rs | 16 +++++----- src/trap.rs | 8 ++--- src/unsize.rs | 4 +-- src/value_and_place.rs | 34 ++++++++++---------- src/vtable.rs | 46 +++++++++++++-------------- 20 files changed, 255 insertions(+), 255 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 65613754d0666..ec983667b1c7e 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -226,9 +226,9 @@ pub(crate) fn import_function<'tcx>( impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let func_id = import_function(self.codegen_cx.tcx, &mut self.codegen_cx.module, inst); + let func_id = import_function(self.cx.tcx, &mut self.cx.module, inst); let func_ref = self - .codegen_cx.module + .cx.module .declare_func_in_func(func_id, &mut self.bcx.func); #[cfg(debug_assertions)] @@ -250,11 +250,11 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { call_conv: CallConv::triple_default(self.triple()), }; let func_id = self - .codegen_cx.module + .cx.module .declare_function(&name, Linkage::Import, &sig) .unwrap(); let func_ref = self - .codegen_cx.module + .cx.module .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); #[cfg(debug_assertions)] @@ -374,9 +374,9 @@ pub(crate) fn codegen_fn_prelude<'tcx>( .collect::, Ty<'tcx>)>>(); assert!(fx.caller_location.is_none()); - if fx.instance.def.requires_caller_location(fx.codegen_cx.tcx) { + if fx.instance.def.requires_caller_location(fx.cx.tcx) { // Store caller location for `#[track_caller]`. - fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.codegen_cx.tcx.caller_location_ty()).unwrap()); + fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.cx.tcx.caller_location_ty()).unwrap()); } fx.bcx.switch_to_block(start_block); @@ -398,7 +398,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( let local_decl = &fx.mir.local_decls[local]; // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( - fx.codegen_cx.tcx.at(local_decl.source_info.span), + fx.cx.tcx.at(local_decl.source_info.span), ParamEnv::reveal_all(), ); if local_decl.mutability == mir::Mutability::Not && !internally_mutable { @@ -465,24 +465,24 @@ pub(crate) fn codegen_terminator_call<'tcx>( args: &[Operand<'tcx>], destination: Option<(Place<'tcx>, BasicBlock)>, ) { - let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.codegen_cx.tcx)); + let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.cx.tcx)); let fn_sig = fx - .codegen_cx.tcx - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.codegen_cx.tcx)); + .cx.tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.cx.tcx)); let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); // Handle special calls like instrinsics and empty drop glue. let instance = if let ty::FnDef(def_id, substs) = fn_ty.kind { - let instance = ty::Instance::resolve(fx.codegen_cx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) + let instance = ty::Instance::resolve(fx.cx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) .unwrap() .unwrap() - .polymorphize(fx.codegen_cx.tcx); + .polymorphize(fx.cx.tcx); - if fx.codegen_cx.tcx.symbol_name(instance).name.starts_with("llvm.") { + if fx.cx.tcx.symbol_name(instance).name.starts_with("llvm.") { crate::intrinsics::codegen_llvm_intrinsic_call( fx, - &fx.codegen_cx.tcx.symbol_name(instance).name, + &fx.cx.tcx.symbol_name(instance).name, substs, args, destination, @@ -510,7 +510,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let is_cold = instance.map(|inst| - fx.codegen_cx.tcx.codegen_fn_attrs(inst.def_id()) + fx.cx.tcx.codegen_fn_attrs(inst.def_id()) .flags.contains(CodegenFnAttrFlags::COLD)) .unwrap_or(false); if is_cold { @@ -558,7 +558,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( nop_inst, format!( "virtual call; self arg pass mode: {:?}", - get_pass_mode(fx.codegen_cx.tcx, args[0].layout()) + get_pass_mode(fx.cx.tcx, args[0].layout()) ), ); } @@ -608,7 +608,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( ) .collect::>(); - if instance.map(|inst| inst.def.requires_caller_location(fx.codegen_cx.tcx)).unwrap_or(false) { + if instance.map(|inst| inst.def.requires_caller_location(fx.cx.tcx)).unwrap_or(false) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); @@ -616,7 +616,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let call_inst = if let Some(func_ref) = func_ref { let sig = clif_sig_from_fn_sig( - fx.codegen_cx.tcx, + fx.cx.tcx, fx.triple(), fn_sig, span, @@ -637,7 +637,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { if fn_sig.abi != Abi::C { - fx.codegen_cx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); + fx.cx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); let abi_params = call_args @@ -646,7 +646,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - fx.codegen_cx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); + fx.cx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); } AbiParam::new(ty) }) @@ -668,17 +668,17 @@ pub(crate) fn codegen_drop<'tcx>( drop_place: CPlace<'tcx>, ) { let ty = drop_place.layout().ty; - let drop_fn = Instance::resolve_drop_in_place(fx.codegen_cx.tcx, ty).polymorphize(fx.codegen_cx.tcx); + let drop_fn = Instance::resolve_drop_in_place(fx.cx.tcx, ty).polymorphize(fx.cx.tcx); if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything } else { - let drop_fn_ty = drop_fn.ty(fx.codegen_cx.tcx, ParamEnv::reveal_all()); - let fn_sig = fx.codegen_cx.tcx.normalize_erasing_late_bound_regions( + let drop_fn_ty = drop_fn.ty(fx.cx.tcx, ParamEnv::reveal_all()); + let fn_sig = fx.cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &drop_fn_ty.fn_sig(fx.codegen_cx.tcx), + &drop_fn_ty.fn_sig(fx.cx.tcx), ); - assert_eq!(fn_sig.output(), fx.codegen_cx.tcx.mk_unit()); + assert_eq!(fn_sig.output(), fx.cx.tcx.mk_unit()); match ty.kind { ty::Dynamic(..) => { @@ -687,7 +687,7 @@ pub(crate) fn codegen_drop<'tcx>( let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); let sig = clif_sig_from_fn_sig( - fx.codegen_cx.tcx, + fx.cx.tcx, fx.triple(), fn_sig, span, @@ -702,7 +702,7 @@ pub(crate) fn codegen_drop<'tcx>( let arg_place = CPlace::new_stack_slot( fx, - fx.layout_of(fx.codegen_cx.tcx.mk_ref( + fx.layout_of(fx.cx.tcx.mk_ref( &ty::RegionKind::ReErased, TypeAndMut { ty, @@ -716,7 +716,7 @@ pub(crate) fn codegen_drop<'tcx>( let mut call_args: Vec = arg_value.into_iter().collect::>(); - if drop_fn.def.requires_caller_location(fx.codegen_cx.tcx) { + if drop_fn.def.requires_caller_location(fx.cx.tcx) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 7172a56ad2979..ffdd672ef7b6a 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -118,7 +118,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, ) -> EmptySinglePair { - match get_pass_mode(fx.codegen_cx.tcx, arg.layout()) { + match get_pass_mode(fx.cx.tcx, arg.layout()) { PassMode::NoPass => Empty, PassMode::ByVal(_) => Single(arg.load_scalar(fx)), PassMode::ByValPair(_, _) => { @@ -144,13 +144,13 @@ pub(super) fn cvalue_for_param<'tcx>( arg_ty: Ty<'tcx>, ) -> Option> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.codegen_cx.tcx, layout); + let pass_mode = get_pass_mode(fx.cx.tcx, layout); if let PassMode::NoPass = pass_mode { return None; } - let clif_types = pass_mode.get_param_ty(fx.codegen_cx.tcx); + let clif_types = pass_mode.get_param_ty(fx.cx.tcx); let block_params = clif_types.map(|t| fx.bcx.append_block_param(start_block, t)); #[cfg(debug_assertions)] diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 51c0c144defe3..b0044b9ea0f83 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -19,7 +19,7 @@ pub(super) fn codegen_return_param( start_block: Block, ) { let ret_layout = return_layout(fx); - let ret_pass_mode = get_pass_mode(fx.codegen_cx.tcx, ret_layout); + let ret_pass_mode = get_pass_mode(fx.cx.tcx, ret_layout); let ret_param = match ret_pass_mode { PassMode::NoPass => { fx.local_map @@ -66,7 +66,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( ) -> (Inst, T) { let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fx.codegen_cx.tcx, ret_layout); + let output_pass_mode = get_pass_mode(fx.cx.tcx, ret_layout); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef { size: Some(_)} => match ret_place { @@ -102,7 +102,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( } pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { - match get_pass_mode(fx.codegen_cx.tcx, return_layout(fx)) { + match get_pass_mode(fx.cx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { size: Some(_) } => { fx.bcx.ins().return_(&[]); } diff --git a/src/analyze.rs b/src/analyze.rs index 466e0a312c075..1e7d397bbe51a 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -35,8 +35,8 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { if let Some((dest_place, _dest_bb)) = destination { - let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.codegen_cx.tcx).ty)); - if !crate::abi::can_return_to_ssa_var(fx.codegen_cx.tcx, dest_layout) { + let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.cx.tcx).ty)); + if !crate::abi::can_return_to_ssa_var(fx.cx.tcx, dest_layout) { not_ssa(&mut flag_map, dest_place.local) } } diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 00dca2c34a6b1..2cacef77d1733 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -81,7 +81,7 @@ pub(crate) fn init_global_lock_constructor( } pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fx.codegen_cx.module.declare_data( + let atomic_mutex = fx.cx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, true, @@ -89,24 +89,24 @@ pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { None, ).unwrap(); - let pthread_mutex_lock = fx.codegen_cx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fx.codegen_cx.module.target_config().default_call_conv, + let pthread_mutex_lock = fx.cx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fx.cx.module.target_config().default_call_conv, params: vec![ - AbiParam::new(fx.codegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + AbiParam::new(fx.cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), ], returns: vec![AbiParam::new(types::I32 /* c_int */)], }).unwrap(); - let pthread_mutex_lock = fx.codegen_cx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); + let pthread_mutex_lock = fx.cx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); - let atomic_mutex = fx.codegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fx.codegen_cx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fx.cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fx.cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_lock, &[atomic_mutex]); } pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fx.codegen_cx.module.declare_data( + let atomic_mutex = fx.cx.module.declare_data( "__cg_clif_global_atomic_mutex", Linkage::Import, true, @@ -114,18 +114,18 @@ pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { None, ).unwrap(); - let pthread_mutex_unlock = fx.codegen_cx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fx.codegen_cx.module.target_config().default_call_conv, + let pthread_mutex_unlock = fx.cx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { + call_conv: fx.cx.module.target_config().default_call_conv, params: vec![ - AbiParam::new(fx.codegen_cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), + AbiParam::new(fx.cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), ], returns: vec![AbiParam::new(types::I32 /* c_int */)], }).unwrap(); - let pthread_mutex_unlock = fx.codegen_cx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); + let pthread_mutex_unlock = fx.cx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); - let atomic_mutex = fx.codegen_cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fx.codegen_cx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fx.cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); + let atomic_mutex = fx.bcx.ins().global_value(fx.cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_unlock, &[atomic_mutex]); } diff --git a/src/base.rs b/src/base.rs index 92d910dd9984e..662054d4e4fdd 100644 --- a/src/base.rs +++ b/src/base.rs @@ -34,7 +34,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let clif_comments = crate::pretty_clif::CommentWriter::new(tcx, instance); let mut fx = FunctionCx { - codegen_cx: cx, + cx, pointer_type, instance, @@ -220,7 +220,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { target, cleanup: _, } => { - if !fx.codegen_cx.tcx.sess.overflow_checks() { + if !fx.cx.tcx.sess.overflow_checks() { if let mir::AssertKind::OverflowNeg(_) = *msg { let target = fx.get_block(*target); fx.bcx.ins().jump(target, &[]); @@ -261,12 +261,12 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } }; - let def_id = fx.codegen_cx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { - fx.codegen_cx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) + let def_id = fx.cx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { + fx.cx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) }); - let instance = Instance::mono(fx.codegen_cx.tcx, def_id).polymorphize(fx.codegen_cx.tcx); - let symbol_name = fx.codegen_cx.tcx.symbol_name(instance).name; + let instance = Instance::mono(fx.cx.tcx, def_id).polymorphize(fx.cx.tcx); + let symbol_name = fx.cx.tcx.symbol_name(instance).name; fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); @@ -296,7 +296,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, from_hir_call: _, } => { - fx.codegen_cx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( + fx.cx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, *fn_span, block, @@ -415,7 +415,7 @@ fn trans_stmt<'tcx>( let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let res = if !fx.codegen_cx.tcx.sess.overflow_checks() { + let res = if !fx.cx.tcx.sess.overflow_checks() { let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); @@ -461,14 +461,14 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, res); } Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, to_ty) => { - let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.codegen_cx.tcx)); + let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.cx.tcx)); let to_layout = fx.layout_of(fx.monomorphize(to_ty)); match from_ty.kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( - Instance::resolve_for_fn_ptr(fx.codegen_cx.tcx, ParamEnv::reveal_all(), def_id, substs) + Instance::resolve_for_fn_ptr(fx.cx.tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap() - .polymorphize(fx.codegen_cx.tcx), + .polymorphize(fx.cx.tcx), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, to_layout)); @@ -497,7 +497,7 @@ fn trans_stmt<'tcx>( |ty::TypeAndMut { ty: pointee_ty, mutbl: _, - }| has_ptr_meta(fx.codegen_cx.tcx, pointee_ty), + }| has_ptr_meta(fx.cx.tcx, pointee_ty), ) .unwrap_or(false) } @@ -523,7 +523,7 @@ fn trans_stmt<'tcx>( match &operand.layout().variants { Variants::Single { index } => { - let discr = operand.layout().ty.discriminant_for_variant(fx.codegen_cx.tcx, *index).unwrap(); + let discr = operand.layout().ty.discriminant_for_variant(fx.cx.tcx, *index).unwrap(); let discr = if discr.ty.is_signed() { rustc_middle::mir::interpret::sign_extend(discr.val, fx.layout_of(discr.ty).size) } else { @@ -575,11 +575,11 @@ fn trans_stmt<'tcx>( match operand.layout().ty.kind { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( - fx.codegen_cx.tcx, + fx.cx.tcx, def_id, substs, ty::ClosureKind::FnOnce, - ).polymorphize(fx.codegen_cx.tcx); + ).polymorphize(fx.cx.tcx); let func_ref = fx.get_function_ref(instance); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); @@ -602,9 +602,9 @@ fn trans_stmt<'tcx>( let operand = trans_operand(fx, operand); let times = fx .monomorphize(times) - .eval(fx.codegen_cx.tcx, ParamEnv::reveal_all()) + .eval(fx.cx.tcx, ParamEnv::reveal_all()) .val - .try_to_bits(fx.codegen_cx.tcx.data_layout.pointer_size) + .try_to_bits(fx.cx.tcx.data_layout.pointer_size) .unwrap(); for i in 0..times { let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); @@ -614,14 +614,14 @@ fn trans_stmt<'tcx>( } Rvalue::Len(place) => { let place = trans_place(fx, *place); - let usize_layout = fx.layout_of(fx.codegen_cx.tcx.types.usize); + let usize_layout = fx.layout_of(fx.cx.tcx.types.usize); let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { use rustc_hir::lang_items::ExchangeMallocFnLangItem; - let usize_type = fx.clif_type(fx.codegen_cx.tcx.types.usize).unwrap(); + let usize_type = fx.clif_type(fx.cx.tcx.types.usize).unwrap(); let content_ty = fx.monomorphize(content_ty); let layout = fx.layout_of(content_ty); let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64); @@ -629,18 +629,18 @@ fn trans_stmt<'tcx>( .bcx .ins() .iconst(usize_type, layout.align.abi.bytes() as i64); - let box_layout = fx.layout_of(fx.codegen_cx.tcx.mk_box(content_ty)); + let box_layout = fx.layout_of(fx.cx.tcx.mk_box(content_ty)); // Allocate space: - let def_id = match fx.codegen_cx.tcx.lang_items().require(ExchangeMallocFnLangItem) { + let def_id = match fx.cx.tcx.lang_items().require(ExchangeMallocFnLangItem) { Ok(id) => id, Err(s) => { - fx.codegen_cx.tcx + fx.cx.tcx .sess .fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); } }; - let instance = ty::Instance::mono(fx.codegen_cx.tcx, def_id).polymorphize(fx.codegen_cx.tcx); + let instance = ty::Instance::mono(fx.cx.tcx, def_id).polymorphize(fx.cx.tcx); let func_ref = fx.get_function_ref(instance); let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); let ptr = fx.bcx.inst_results(call)[0]; @@ -650,9 +650,9 @@ fn trans_stmt<'tcx>( assert!(lval .layout() .ty - .is_sized(fx.codegen_cx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); + .is_sized(fx.cx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); - let val = CValue::const_val(fx, fx.layout_of(fx.codegen_cx.tcx.types.usize), ty_size.into()); + let val = CValue::const_val(fx, fx.layout_of(fx.cx.tcx.types.usize), ty_size.into()); lval.write_cvalue(fx, val); } Rvalue::Aggregate(kind, operands) => match **kind { @@ -717,10 +717,10 @@ fn trans_stmt<'tcx>( let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); assert_eq!(outputs.len(), 4); - trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.codegen_cx.tcx.types.u32))); - trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.codegen_cx.tcx.types.u32))); - trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.codegen_cx.tcx.types.u32))); - trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.codegen_cx.tcx.types.u32))); + trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.cx.tcx.types.u32))); + trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.cx.tcx.types.u32))); + trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.cx.tcx.types.u32))); + trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.cx.tcx.types.u32))); } "xgetbv" => { assert_eq!(input_names, &[Symbol::intern("{ecx}")]); @@ -740,17 +740,17 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } // ___chkstk, ___chkstk_ms and __alloca are only used on Windows - _ if fx.codegen_cx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { + _ if fx.cx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { crate::trap::trap_unimplemented(fx, "Stack probes are not supported"); } - _ if fx.codegen_cx.tcx.symbol_name(fx.instance).name == "__alloca" => { + _ if fx.cx.tcx.symbol_name(fx.instance).name == "__alloca" => { crate::trap::trap_unimplemented(fx, "Alloca is not supported"); } // Used in sys::windows::abort_internal "int $$0x29" => { crate::trap::trap_unimplemented(fx, "Windows abort"); } - _ => fx.codegen_cx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), + _ => fx.cx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), } } } @@ -763,8 +763,8 @@ fn codegen_array_len<'tcx>( match place.layout().ty.kind { ty::Array(_elem_ty, len) => { let len = fx.monomorphize(&len) - .eval(fx.codegen_cx.tcx, ParamEnv::reveal_all()) - .eval_usize(fx.codegen_cx.tcx, ParamEnv::reveal_all()) as i64; + .eval(fx.cx.tcx, ParamEnv::reveal_all()) + .eval_usize(fx.cx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place @@ -817,7 +817,7 @@ pub(crate) fn trans_place<'tcx>( let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), - fx.layout_of(fx.codegen_cx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), + fx.layout_of(fx.cx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), ); } ty::Slice(elem_ty) => { diff --git a/src/cast.rs b/src/cast.rs index db465a581275a..25ce5812f9bd4 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -86,14 +86,14 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = if from_signed { - fx.codegen_cx.tcx.types.i128 + fx.cx.tcx.types.i128 } else { - fx.codegen_cx.tcx.types.u128 + fx.cx.tcx.types.u128 }; let to_rust_ty = match to_ty { - types::F32 => fx.codegen_cx.tcx.types.f32, - types::F64 => fx.codegen_cx.tcx.types.f64, + types::F32 => fx.cx.tcx.types.f32, + types::F64 => fx.cx.tcx.types.f64, _ => unreachable!(), }; @@ -131,15 +131,15 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = match from_ty { - types::F32 => fx.codegen_cx.tcx.types.f32, - types::F64 => fx.codegen_cx.tcx.types.f64, + types::F32 => fx.cx.tcx.types.f32, + types::F64 => fx.cx.tcx.types.f64, _ => unreachable!(), }; let to_rust_ty = if to_signed { - fx.codegen_cx.tcx.types.i128 + fx.cx.tcx.types.i128 } else { - fx.codegen_cx.tcx.types.u128 + fx.cx.tcx.types.u128 }; return fx diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index bb927a4dd70bf..0b02d32c6518b 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -9,7 +9,7 @@ pub(crate) fn maybe_codegen<'tcx>( lhs: CValue<'tcx>, rhs: CValue<'tcx>, ) -> Option> { - if lhs.layout().ty != fx.codegen_cx.tcx.types.u128 && lhs.layout().ty != fx.codegen_cx.tcx.types.i128 { + if lhs.layout().ty != fx.cx.tcx.types.u128 && lhs.layout().ty != fx.cx.tcx.types.i128 { return None; } @@ -25,7 +25,7 @@ pub(crate) fn maybe_codegen<'tcx>( } BinOp::Add | BinOp::Sub if !checked => return None, BinOp::Add => { - let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); + let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty) } else { @@ -33,7 +33,7 @@ pub(crate) fn maybe_codegen<'tcx>( }); } BinOp::Sub => { - let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); + let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty) } else { @@ -43,7 +43,7 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { let res = if checked { - let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); + let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); if is_signed { fx.easy_call("__rust_i128_mulo", &[lhs, rhs], out_ty) } else { @@ -51,9 +51,9 @@ pub(crate) fn maybe_codegen<'tcx>( } } else { let val_ty = if is_signed { - fx.codegen_cx.tcx.types.i128 + fx.cx.tcx.types.i128 } else { - fx.codegen_cx.tcx.types.u128 + fx.cx.tcx.types.u128 }; fx.easy_call("__multi3", &[lhs, rhs], val_ty) }; @@ -62,17 +62,17 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Div => { assert!(!checked); if is_signed { - Some(fx.easy_call("__divti3", &[lhs, rhs], fx.codegen_cx.tcx.types.i128)) + Some(fx.easy_call("__divti3", &[lhs, rhs], fx.cx.tcx.types.i128)) } else { - Some(fx.easy_call("__udivti3", &[lhs, rhs], fx.codegen_cx.tcx.types.u128)) + Some(fx.easy_call("__udivti3", &[lhs, rhs], fx.cx.tcx.types.u128)) } } BinOp::Rem => { assert!(!checked); if is_signed { - Some(fx.easy_call("__modti3", &[lhs, rhs], fx.codegen_cx.tcx.types.i128)) + Some(fx.easy_call("__modti3", &[lhs, rhs], fx.cx.tcx.types.i128)) } else { - Some(fx.easy_call("__umodti3", &[lhs, rhs], fx.codegen_cx.tcx.types.u128)) + Some(fx.easy_call("__umodti3", &[lhs, rhs], fx.cx.tcx.types.u128)) } } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { @@ -104,7 +104,7 @@ pub(crate) fn maybe_codegen<'tcx>( let val = match (bin_op, is_signed) { (BinOp::Shr, false) => { let val = fx.bcx.ins().iconcat(lhs_msb, all_zeros); - Some(CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.u128))) + Some(CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.u128))) } (BinOp::Shr, true) => { let sign = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, lhs_msb, 0); @@ -112,13 +112,13 @@ pub(crate) fn maybe_codegen<'tcx>( let all_sign_bits = fx.bcx.ins().select(sign, all_zeros, all_ones); let val = fx.bcx.ins().iconcat(lhs_msb, all_sign_bits); - Some(CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.i128))) + Some(CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.i128))) } (BinOp::Shl, _) => { let val_ty = if is_signed { - fx.codegen_cx.tcx.types.i128 + fx.cx.tcx.types.i128 } else { - fx.codegen_cx.tcx.types.u128 + fx.cx.tcx.types.u128 }; let val = fx.bcx.ins().iconcat(all_zeros, lhs_lsb); Some(CValue::by_val(val, fx.layout_of(val_ty))) @@ -127,7 +127,7 @@ pub(crate) fn maybe_codegen<'tcx>( }; if let Some(val) = val { if let Some(is_overflow) = is_overflow { - let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); + let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); let val = val.load_scalar(fx); return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))); } else { @@ -137,24 +137,24 @@ pub(crate) fn maybe_codegen<'tcx>( } let truncated_rhs = clif_intcast(fx, rhs_val, types::I32, false); - let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fx.codegen_cx.tcx.types.u32)); + let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fx.cx.tcx.types.u32)); let val = match (bin_op, is_signed) { (BinOp::Shl, false) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.u128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.cx.tcx.types.u128) } (BinOp::Shl, true) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.i128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.cx.tcx.types.i128) } (BinOp::Shr, false) => { - fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.u128) + fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fx.cx.tcx.types.u128) } (BinOp::Shr, true) => { - fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fx.codegen_cx.tcx.types.i128) + fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fx.cx.tcx.types.i128) } (_, _) => unreachable!(), }; if let Some(is_overflow) = is_overflow { - let out_ty = fx.codegen_cx.tcx.mk_tup([lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter()); + let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); let val = val.load_scalar(fx); Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) } else { diff --git a/src/common.rs b/src/common.rs index bf7fc57081841..7283630f748d1 100644 --- a/src/common.rs +++ b/src/common.rs @@ -265,7 +265,7 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool { } pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { - pub(crate) codegen_cx: &'clif mut crate::CodegenCx<'tcx, B>, + pub(crate) cx: &'clif mut crate::CodegenCx<'tcx, B>, pub(crate) pointer_type: Type, // Cached from module pub(crate) instance: Instance<'tcx>, @@ -296,11 +296,11 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { assert!(!ty.still_further_specializable()); - self.codegen_cx.tcx + self.cx.tcx .layout_of(ParamEnv::reveal_all().and(&ty)) .unwrap_or_else(|e| { if let layout::LayoutError::SizeOverflow(_) = e { - self.codegen_cx.tcx.sess.fatal(&e.to_string()) + self.cx.tcx.sess.fatal(&e.to_string()) } else { bug!("failed to get layout for `{}`: {}", ty, e) } @@ -310,13 +310,13 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend + 'static> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx, B> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { - self.codegen_cx.tcx + self.cx.tcx } } impl<'tcx, B: Backend + 'static> rustc_target::abi::HasDataLayout for FunctionCx<'_, 'tcx, B> { fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { - &self.codegen_cx.tcx.data_layout + &self.cx.tcx.data_layout } } @@ -328,7 +328,7 @@ impl<'tcx, B: Backend + 'static> layout::HasParamEnv<'tcx> for FunctionCx<'_, 't impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { fn target_spec(&self) -> &Target { - &self.codegen_cx.tcx.sess.target.target + &self.cx.tcx.sess.target.target } } @@ -338,22 +338,22 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { T: TypeFoldable<'tcx> + Copy, { if let Some(substs) = self.instance.substs_for_mir_body() { - self.codegen_cx.tcx.subst_and_normalize_erasing_regions( + self.cx.tcx.subst_and_normalize_erasing_regions( substs, ty::ParamEnv::reveal_all(), value, ) } else { - self.codegen_cx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) + self.cx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) } } pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option { - clif_type_from_ty(self.codegen_cx.tcx, ty) + clif_type_from_ty(self.cx.tcx, ty) } pub(crate) fn clif_pair_type(&self, ty: Ty<'tcx>) -> Option<(Type, Type)> { - clif_pair_type_from_ty(self.codegen_cx.tcx, ty) + clif_pair_type_from_ty(self.cx.tcx, ty) } pub(crate) fn get_block(&self, bb: BasicBlock) -> Block { @@ -378,8 +378,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); - let caller = self.codegen_cx.tcx.sess.source_map().lookup_char_pos(topmost.lo()); - let const_loc = self.codegen_cx.tcx.const_caller_location(( + let caller = self.cx.tcx.sess.source_map().lookup_char_pos(topmost.lo()); + let const_loc = self.cx.tcx.const_caller_location(( rustc_span::symbol::Symbol::intern(&caller.file.name.to_string()), caller.line as u32, caller.col_display as u32 + 1, @@ -387,12 +387,12 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { crate::constant::trans_const_value( self, const_loc, - self.codegen_cx.tcx.caller_location_ty(), + self.cx.tcx.caller_location_ty(), ) } pub(crate) fn triple(&self) -> &target_lexicon::Triple { - self.codegen_cx.module.isa().triple() + self.cx.module.isa().triple() } pub(crate) fn anonymous_str(&mut self, prefix: &str, msg: &str) -> Value { @@ -405,7 +405,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let mut data_ctx = DataContext::new(); data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice()); let msg_id = self - .codegen_cx.module + .cx.module .declare_data( &format!("__{}_{:08x}", prefix, msg_hash), Linkage::Local, @@ -416,9 +416,9 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { .unwrap(); // Ignore DuplicateDefinition error, as the data will be the same - let _ = self.codegen_cx.module.define_data(msg_id, &data_ctx); + let _ = self.cx.module.define_data(msg_id, &data_ctx); - let local_msg_id = self.codegen_cx.module.declare_data_in_func(msg_id, self.bcx.func); + let local_msg_id = self.cx.module.declare_data_in_func(msg_id, self.bcx.func); #[cfg(debug_assertions)] { self.add_comment(local_msg_id, msg); diff --git a/src/constant.rs b/src/constant.rs index 7f047b04c9dcd..764d8a48ccf73 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -41,10 +41,10 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Backend>) { match const_.val { ConstKind::Value(_) => {} ConstKind::Unevaluated(def, ref substs, promoted) => { - if let Err(err) = fx.codegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + if let Err(err) = fx.cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { match err { ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { - fx.codegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } ErrorHandled::TooGeneric => { span_bug!(constant.span, "codgen encountered polymorphic constant: {:?}", err); @@ -67,8 +67,8 @@ pub(crate) fn codegen_tls_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { - let data_id = data_id_for_static(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, def_id, false); - let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_static(fx.cx.tcx, &mut fx.cx.module, def_id, false); + let local_data_id = fx.cx.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); @@ -80,8 +80,8 @@ fn codegen_static_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, def_id, false); - let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_static(fx.cx.tcx, &mut fx.cx.module, def_id, false); + let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); @@ -97,7 +97,7 @@ pub(crate) fn trans_constant<'tcx>( let const_ = fx.monomorphize(&constant.literal); let const_val = match const_.val { ConstKind::Value(const_val) => const_val, - ConstKind::Unevaluated(def, ref substs, promoted) if fx.codegen_cx.tcx.is_static(def.did) => { + ConstKind::Unevaluated(def, ref substs, promoted) if fx.cx.tcx.is_static(def.did) => { assert!(substs.is_empty()); assert!(promoted.is_none()); @@ -108,11 +108,11 @@ pub(crate) fn trans_constant<'tcx>( ).to_cvalue(fx); } ConstKind::Unevaluated(def, ref substs, promoted) => { - match fx.codegen_cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + match fx.cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { Ok(const_val) => const_val, Err(_) => { if promoted.is_none() { - fx.codegen_cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } return crate::trap::trap_unreachable_ret_value( fx, @@ -154,7 +154,7 @@ pub(crate) fn trans_const_value<'tcx>( ); let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used alloc.write_scalar(fx, ptr, x.into(), size).unwrap(); - let alloc = fx.codegen_cx.tcx.intern_const_alloc(alloc); + let alloc = fx.cx.tcx.intern_const_alloc(alloc); return CValue::by_ref(pointer_for_allocation(fx, alloc), layout); } @@ -164,25 +164,25 @@ pub(crate) fn trans_const_value<'tcx>( return CValue::const_val(fx, layout, data); } Scalar::Ptr(ptr) => { - let alloc_kind = fx.codegen_cx.tcx.get_global_alloc(ptr.alloc_id); + let alloc_kind = fx.cx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { - fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); - let data_id = data_id_for_alloc_id(&mut fx.codegen_cx.module, ptr.alloc_id, alloc.align, alloc.mutability); - let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + fx.cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); + let data_id = data_id_for_alloc_id(&mut fx.cx.module, ptr.alloc_id, alloc.align, alloc.mutability); + let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", ptr.alloc_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { - let func_id = crate::abi::import_function(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, instance); - let local_func_id = fx.codegen_cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); + let func_id = crate::abi::import_function(fx.cx.tcx, &mut fx.cx.module, instance); + let local_func_id = fx.cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) } Some(GlobalAlloc::Static(def_id)) => { - assert!(fx.codegen_cx.tcx.is_static(def_id)); - let data_id = data_id_for_static(fx.codegen_cx.tcx, &mut fx.codegen_cx.module, def_id, false); - let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + assert!(fx.cx.tcx.is_static(def_id)); + let data_id = data_id_for_static(fx.cx.tcx, &mut fx.cx.module, def_id, false); + let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) @@ -215,11 +215,11 @@ fn pointer_for_allocation<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { - let alloc_id = fx.codegen_cx.tcx.create_memory_alloc(alloc); - fx.codegen_cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(&mut fx.codegen_cx.module, alloc_id, alloc.align, alloc.mutability); + let alloc_id = fx.cx.tcx.create_memory_alloc(alloc); + fx.cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); + let data_id = data_id_for_alloc_id(&mut fx.cx.module, alloc_id, alloc.align, alloc.mutability); - let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", alloc_id)); let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id); @@ -419,7 +419,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( match operand { Operand::Copy(_) | Operand::Move(_) => None, Operand::Constant(const_) => { - Some(fx.monomorphize(&const_.literal).eval(fx.codegen_cx.tcx, ParamEnv::reveal_all())) + Some(fx.monomorphize(&const_.literal).eval(fx.cx.tcx, ParamEnv::reveal_all())) } } } diff --git a/src/discriminant.rs b/src/discriminant.rs index efe95322aae3b..97a92eaf512ca 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -26,7 +26,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( let ptr = place.place_field(fx, mir::Field::new(tag_field)); let to = layout .ty - .discriminant_for_variant(fx.codegen_cx.tcx, variant_index) + .discriminant_for_variant(fx.cx.tcx, variant_index) .unwrap() .val; let discr = CValue::const_val(fx, ptr.layout(), to); @@ -73,7 +73,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>( Variants::Single { index } => { let discr_val = layout .ty - .discriminant_for_variant(fx.codegen_cx.tcx, *index) + .discriminant_for_variant(fx.cx.tcx, *index) .map_or(u128::from(index.as_u32()), |discr| discr.val); return CValue::const_val(fx, dest_layout, discr_val); } diff --git a/src/inline_asm.rs b/src/inline_asm.rs index f0ae0854f84fc..0f162d6e94b6c 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -70,10 +70,10 @@ pub(crate) fn codegen_inline_asm<'tcx>( let inline_asm_index = fx.inline_asm_index; fx.inline_asm_index += 1; - let asm_name = format!("{}__inline_asm_{}", fx.codegen_cx.tcx.symbol_name(fx.instance).name, inline_asm_index); + let asm_name = format!("{}__inline_asm_{}", fx.cx.tcx.symbol_name(fx.instance).name, inline_asm_index); let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); - fx.codegen_cx.global_asm.push_str(&generated_asm); + fx.cx.global_asm.push_str(&generated_asm); call_inline_asm(fx, &asm_name, slot_size, inputs, outputs); } @@ -169,12 +169,12 @@ fn call_inline_asm<'tcx>( #[cfg(debug_assertions)] fx.add_comment(stack_slot, "inline asm scratch slot"); - let inline_asm_func = fx.codegen_cx.module.declare_function(asm_name, Linkage::Import, &Signature { + let inline_asm_func = fx.cx.module.declare_function(asm_name, Linkage::Import, &Signature { call_conv: CallConv::SystemV, params: vec![AbiParam::new(fx.pointer_type)], returns: vec![], }).unwrap(); - let inline_asm_func = fx.codegen_cx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); + let inline_asm_func = fx.cx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(inline_asm_func, asm_name); diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index 171eb51ccdff0..45d655fb5eda3 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -30,13 +30,13 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.codegen_cx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); + fx.cx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); crate::trap::trap_unimplemented(fx, intrinsic); }; // Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8` llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb | llvm.x86.sse2.movmsk.pd, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, a.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, a.layout()); let lane_ty = fx.clif_type(lane_layout.ty).unwrap(); assert!(lane_count <= 32); @@ -61,7 +61,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( res = fx.bcx.ins().bor(res, a_lane_sign); } - let res = CValue::by_val(res, fx.layout_of(fx.codegen_cx.tcx.types.i32)); + let res = CValue::by_val(res, fx.layout_of(fx.cx.tcx.types.i32)); ret.write_cvalue(fx, res); }; llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) { diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index f73e9f765c02d..454a0d2b91bc5 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -88,7 +88,7 @@ macro call_intrinsic_match { let ($($arg,)*) = ( $(trans_operand($fx, $arg),)* ); - let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.codegen_cx.tcx.types.$ty); + let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.cx.tcx.types.$ty); $ret.write_cvalue($fx, res); if let Some((_, dest)) = $destination { @@ -144,7 +144,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { match $ty.kind { ty::Uint(_) | ty::Int(_) => {} _ => { - $fx.codegen_cx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); + $fx.cx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -154,7 +154,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { macro validate_simd_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { if !$ty.is_simd() { - $fx.codegen_cx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); + $fx.cx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -203,8 +203,8 @@ fn simd_for_each_lane<'tcx, B: Backend>( ) { let layout = val.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane_idx in 0..lane_count { @@ -233,8 +233,8 @@ fn simd_pair_for_each_lane<'tcx, B: Backend>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { @@ -273,7 +273,7 @@ fn bool_to_zero_or_max_uint<'tcx>( macro simd_cmp { ($fx:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { - let vector_ty = clif_vector_type($fx.codegen_cx.tcx, $x.layout()); + let vector_ty = clif_vector_type($fx.cx.tcx, $x.layout()); if let Some(vector_ty) = vector_ty { let x = $x.load_scalar($fx); @@ -390,7 +390,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fx.codegen_cx.tcx.item_name(def_id).as_str(); + let intrinsic = fx.cx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; let ret = match destination { @@ -423,7 +423,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( return; } - let usize_layout = fx.layout_of(fx.codegen_cx.tcx.types.usize); + let usize_layout = fx.layout_of(fx.cx.tcx.types.usize); call_intrinsic_match! { fx, intrinsic, substs, ret, destination, args, @@ -473,7 +473,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.codegen_cx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); + fx.cx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); }; assume, (c _a) {}; @@ -494,10 +494,10 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( if intrinsic.contains("nonoverlapping") { // FIXME emit_small_memcpy - fx.bcx.call_memcpy(fx.codegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memcpy(fx.cx.module.target_config(), dst, src, byte_amount); } else { // FIXME emit_small_memmove - fx.bcx.call_memmove(fx.codegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memmove(fx.cx.module.target_config(), dst, src, byte_amount); } }; // NOTE: the volatile variants have src and dst swapped @@ -513,10 +513,10 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( // FIXME make the copy actually volatile when using emit_small_mem{cpy,move} if intrinsic.contains("nonoverlapping") { // FIXME emit_small_memcpy - fx.bcx.call_memcpy(fx.codegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memcpy(fx.cx.module.target_config(), dst, src, byte_amount); } else { // FIXME emit_small_memmove - fx.bcx.call_memmove(fx.codegen_cx.module.target_config(), dst, src, byte_amount); + fx.bcx.call_memmove(fx.cx.module.target_config(), dst, src, byte_amount); } }; discriminant_value, (c ptr) { @@ -680,11 +680,11 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let dst_ptr = dst.load_scalar(fx); // FIXME make the memset actually volatile when switching to emit_small_memset // FIXME use emit_small_memset - fx.bcx.call_memset(fx.codegen_cx.module.target_config(), dst_ptr, val, count); + fx.bcx.call_memset(fx.cx.module.target_config(), dst_ptr, val, count); }; ctlz | ctlz_nonzero, (v arg) { // FIXME trap on `ctlz_nonzero` with zero arg. - let res = if T == fx.codegen_cx.tcx.types.u128 || T == fx.codegen_cx.tcx.types.i128 { + let res = if T == fx.cx.tcx.types.u128 || T == fx.cx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_lz = fx.bcx.ins().clz(lsb); @@ -701,7 +701,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; cttz | cttz_nonzero, (v arg) { // FIXME trap on `cttz_nonzero` with zero arg. - let res = if T == fx.codegen_cx.tcx.types.u128 || T == fx.codegen_cx.tcx.types.i128 { + let res = if T == fx.cx.tcx.types.u128 || T == fx.cx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_tz = fx.bcx.ins().ctz(lsb); @@ -842,7 +842,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () { let const_val = - fx.codegen_cx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); + fx.cx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); let val = crate::constant::trans_const_value( fx, const_val, @@ -852,7 +852,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ptr_offset_from, (v ptr, v base) { - let isize_layout = fx.layout_of(fx.codegen_cx.tcx.types.isize); + let isize_layout = fx.layout_of(fx.cx.tcx.types.isize); let pointee_size: u64 = fx.layout_of(T).size.bytes(); let diff = fx.bcx.ins().isub(ptr, base); @@ -1011,22 +1011,22 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( minnumf32, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f32)); ret.write_cvalue(fx, val); }; minnumf64, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f64)); ret.write_cvalue(fx, val); }; maxnumf32, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f32)); ret.write_cvalue(fx, val); }; maxnumf64, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f64)); ret.write_cvalue(fx, val); }; diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index bdda4bd984034..0a564be44a028 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -11,13 +11,13 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fx.codegen_cx.tcx.item_name(def_id).as_str(); + let intrinsic = fx.cx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.codegen_cx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); + fx.cx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); }; simd_cast, (c a) { @@ -68,8 +68,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_type, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); - let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); + let (lane_type, lane_count) = lane_type_and_count(fx.cx.tcx, layout); + let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); assert_eq!(lane_type, ret_lane_type); assert_eq!(n, ret_lane_count); @@ -92,7 +92,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( (0..ret_lane_count).map(|i| { let i = usize::try_from(i).unwrap(); let idx = rustc_middle::mir::interpret::read_target_uint( - fx.codegen_cx.tcx.data_layout.endian, + fx.cx.tcx.data_layout.endian, &idx_bytes[4*i.. 4*i + 4], ).expect("read_target_uint"); u16::try_from(idx).expect("try_from u32") @@ -119,7 +119,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.codegen_cx.tcx.sess.span_warn( + fx.cx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -128,9 +128,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, base.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fx.cx.tcx, base.layout()); if idx >= lane_count.into() { - fx.codegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); + fx.cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); } ret.write_cvalue(fx, base); @@ -143,7 +143,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.codegen_cx.tcx.sess.span_warn( + fx.cx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -153,9 +153,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, v.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fx.cx.tcx, v.layout()); if idx >= lane_count.into() { - fx.codegen_cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); + fx.cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); } let ret_lane = v.value_field(fx, mir::Field::new(idx.try_into().unwrap())); @@ -205,8 +205,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(a.layout(), c.layout()); let layout = a.layout(); - let (_lane_layout, lane_count) = lane_type_and_count(fx.codegen_cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.codegen_cx.tcx, ret.layout()); + let (_lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { diff --git a/src/num.rs b/src/num.rs index 06721e1af127c..5b1097b2be752 100644 --- a/src/num.rs +++ b/src/num.rs @@ -48,7 +48,7 @@ fn codegen_compare_bin_op<'tcx>( let intcc = crate::num::bin_op_to_intcc(bin_op, signed).unwrap(); let val = fx.bcx.ins().icmp(intcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.bool)) + CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.bool)) } pub(crate) fn codegen_binop<'tcx>( @@ -66,8 +66,8 @@ pub(crate) fn codegen_binop<'tcx>( let rhs = in_rhs.load_scalar(fx); let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (in_lhs.layout().ty.kind == fx.codegen_cx.tcx.types.i8.kind - || in_lhs.layout().ty.kind == fx.codegen_cx.tcx.types.i16.kind) + && (in_lhs.layout().ty.kind == fx.cx.tcx.types.i8.kind + || in_lhs.layout().ty.kind == fx.cx.tcx.types.i16.kind) { // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. ( @@ -118,7 +118,7 @@ pub(crate) fn trans_bool_binop<'tcx>( _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; - CValue::by_val(res, fx.layout_of(fx.codegen_cx.tcx.types.bool)) + CValue::by_val(res, fx.layout_of(fx.cx.tcx.types.bool)) } pub(crate) fn trans_int_binop<'tcx>( @@ -323,7 +323,7 @@ pub(crate) fn trans_checked_int_binop<'tcx>( // FIXME directly write to result place instead let out_place = CPlace::new_stack_slot( fx, - fx.layout_of(fx.codegen_cx.tcx.mk_tup([in_lhs.layout().ty, fx.codegen_cx.tcx.types.bool].iter())), + fx.layout_of(fx.cx.tcx.mk_tup([in_lhs.layout().ty, fx.cx.tcx.types.bool].iter())), ); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); @@ -368,7 +368,7 @@ pub(crate) fn trans_float_binop<'tcx>( }; let val = fx.bcx.ins().fcmp(fltcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - return CValue::by_val(val, fx.layout_of(fx.codegen_cx.tcx.types.bool)); + return CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.bool)); } _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; @@ -383,7 +383,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { let is_thin_ptr = in_lhs.layout().ty.builtin_deref(true).map(|TypeAndMut { ty, mutbl: _}| { - !has_ptr_meta(fx.codegen_cx.tcx, ty) + !has_ptr_meta(fx.cx.tcx, ty) }).unwrap_or(true); if is_thin_ptr { @@ -440,7 +440,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( CValue::by_val( fx.bcx.ins().bint(types::I8, res), - fx.layout_of(fx.codegen_cx.tcx.types.bool), + fx.layout_of(fx.cx.tcx.types.bool), ) } } diff --git a/src/trap.rs b/src/trap.rs index d48bf6a4298c9..9b75e61ba761c 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -2,24 +2,24 @@ use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { let puts = fx - .codegen_cx.module + .cx.module .declare_function( "puts", Linkage::Import, &Signature { call_conv: CallConv::triple_default(fx.triple()), - params: vec![AbiParam::new(pointer_ty(fx.codegen_cx.tcx))], + params: vec![AbiParam::new(pointer_ty(fx.cx.tcx))], returns: vec![AbiParam::new(types::I32)], }, ) .unwrap(); - let puts = fx.codegen_cx.module.declare_func_in_func(puts, &mut fx.bcx.func); + let puts = fx.cx.module.declare_func_in_func(puts, &mut fx.bcx.func); #[cfg(debug_assertions)] { fx.add_comment(puts, "puts"); } - let symbol_name = fx.codegen_cx.tcx.symbol_name(fx.instance); + let symbol_name = fx.cx.tcx.symbol_name(fx.instance); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); let msg_ptr = fx.anonymous_str("trap", &real_msg); fx.bcx.ins().call(puts, &[msg_ptr]); diff --git a/src/unsize.rs b/src/unsize.rs index fec1bfd799f6a..5746f109afd15 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -15,12 +15,12 @@ pub(crate) fn unsized_info<'tcx>( old_info: Option, ) -> Value { let (source, target) = - fx.codegen_cx.tcx + fx.cx.tcx .struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); match (&source.kind, &target.kind) { (&ty::Array(_, len), &ty::Slice(_)) => fx.bcx.ins().iconst( fx.pointer_type, - len.eval_usize(fx.codegen_cx.tcx, ParamEnv::reveal_all()) as i64, + len.eval_usize(fx.cx.tcx, ParamEnv::reveal_all()) as i64, ), (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 4483691013daf..abe9437d42936 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -35,10 +35,10 @@ fn codegen_field<'tcx>( let unaligned_offset = field_offset.bytes(); let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout, extra); - let one = fx.bcx.ins().iconst(pointer_ty(fx.codegen_cx.tcx), 1); + let one = fx.bcx.ins().iconst(pointer_ty(fx.cx.tcx), 1); let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); let and_lhs = fx.bcx.ins().iadd_imm(align_sub_1, unaligned_offset as i64); - let zero = fx.bcx.ins().iconst(pointer_ty(fx.codegen_cx.tcx), 0); + let zero = fx.bcx.ins().iconst(pointer_ty(fx.cx.tcx), 0); let and_rhs = fx.bcx.ins().isub(zero, unsized_align); let offset = fx.bcx.ins().band(and_lhs, and_rhs); @@ -119,9 +119,9 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.abi { - Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.codegen_cx.tcx, scalar.clone()), + Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.cx.tcx, scalar.clone()), Abi::Vector { ref element, count } => { - scalar_to_clif_type(fx.codegen_cx.tcx, element.clone()) + scalar_to_clif_type(fx.cx.tcx, element.clone()) .by(u16::try_from(count).unwrap()).unwrap() } _ => unreachable!("{:?}", layout.ty), @@ -146,9 +146,9 @@ impl<'tcx> CValue<'tcx> { Abi::ScalarPair(a, b) => (a, b), _ => unreachable!("load_scalar_pair({:?})", self), }; - let b_offset = scalar_pair_calculate_b_offset(fx.codegen_cx.tcx, a_scalar, b_scalar); - let clif_ty1 = scalar_to_clif_type(fx.codegen_cx.tcx, a_scalar.clone()); - let clif_ty2 = scalar_to_clif_type(fx.codegen_cx.tcx, b_scalar.clone()); + let b_offset = scalar_pair_calculate_b_offset(fx.cx.tcx, a_scalar, b_scalar); + let clif_ty1 = scalar_to_clif_type(fx.cx.tcx, a_scalar.clone()); + let clif_ty2 = scalar_to_clif_type(fx.cx.tcx, b_scalar.clone()); let val1 = ptr.load(fx, clif_ty1, MemFlags::new()); let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); (val1, val2) @@ -419,13 +419,13 @@ impl<'tcx> CPlace<'tcx> { assert_assignable(fx, a, b); } (ty::FnPtr(_), ty::FnPtr(_)) => { - let from_sig = fx.codegen_cx.tcx.normalize_erasing_late_bound_regions( + let from_sig = fx.cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &from_ty.fn_sig(fx.codegen_cx.tcx), + &from_ty.fn_sig(fx.cx.tcx), ); - let to_sig = fx.codegen_cx.tcx.normalize_erasing_late_bound_regions( + let to_sig = fx.cx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &to_ty.fn_sig(fx.codegen_cx.tcx), + &to_ty.fn_sig(fx.cx.tcx), ); assert_eq!( from_sig, to_sig, @@ -436,10 +436,10 @@ impl<'tcx> CPlace<'tcx> { } (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { let from_traits = fx - .codegen_cx.tcx + .cx.tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), from_traits); let to_traits = fx - .codegen_cx.tcx + .cx.tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), to_traits); assert_eq!( from_traits, to_traits, @@ -569,7 +569,7 @@ impl<'tcx> CPlace<'tcx> { } Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let (value, extra) = from.load_scalar_pair(fx); - let b_offset = scalar_pair_calculate_b_offset(fx.codegen_cx.tcx, a_scalar, b_scalar); + let b_offset = scalar_pair_calculate_b_offset(fx.cx.tcx, a_scalar, b_scalar); to_ptr.store(fx, value, MemFlags::new()); to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); return; @@ -595,7 +595,7 @@ impl<'tcx> CPlace<'tcx> { let src_align = src_layout.align.abi.bytes() as u8; let dst_align = dst_layout.align.abi.bytes() as u8; fx.bcx.emit_small_memory_copy( - fx.codegen_cx.module.target_config(), + fx.cx.module.target_config(), to_addr, from_addr, size, @@ -673,7 +673,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); - if has_ptr_meta(fx.codegen_cx.tcx, inner_layout.ty) { + if has_ptr_meta(fx.cx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); CPlace::for_ptr_with_extra(Pointer::new(addr), extra, inner_layout) } else { @@ -682,7 +682,7 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - if has_ptr_meta(fx.codegen_cx.tcx, self.layout().ty) { + if has_ptr_meta(fx.cx.tcx, self.layout().ty) { let (ptr, extra) = self.to_ptr_maybe_unsized(); let ptr = CValue::by_val_pair( ptr.get_addr(fx), diff --git a/src/vtable.rs b/src/vtable.rs index 6be801c844597..8163d15836c37 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -13,9 +13,9 @@ fn vtable_memflags() -> MemFlags { } pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.codegen_cx.tcx), + pointer_ty(fx.cx.tcx), vtable_memflags(), vtable, (DROP_FN_INDEX * usize_size) as i32, @@ -23,9 +23,9 @@ pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: } pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.codegen_cx.tcx), + pointer_ty(fx.cx.tcx), vtable_memflags(), vtable, (SIZE_INDEX * usize_size) as i32, @@ -33,9 +33,9 @@ pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Val } pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.codegen_cx.tcx), + pointer_ty(fx.cx.tcx), vtable_memflags(), vtable, (ALIGN_INDEX * usize_size) as i32, @@ -57,9 +57,9 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( ) }; - let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes(); + let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( - pointer_ty(fx.codegen_cx.tcx), + pointer_ty(fx.cx.tcx), vtable_memflags(), vtable, ((idx + 3) * usize_size as usize) as i32, @@ -72,15 +72,15 @@ pub(crate) fn get_vtable<'tcx>( layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> Value { - let data_id = if let Some(data_id) = fx.codegen_cx.vtables.get(&(layout.ty, trait_ref)) { + let data_id = if let Some(data_id) = fx.cx.vtables.get(&(layout.ty, trait_ref)) { *data_id } else { let data_id = build_vtable(fx, layout, trait_ref); - fx.codegen_cx.vtables.insert((layout.ty, trait_ref), data_id); + fx.cx.vtables.insert((layout.ty, trait_ref), data_id); data_id }; - let local_data_id = fx.codegen_cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } @@ -89,11 +89,11 @@ fn build_vtable<'tcx>( layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> DataId { - let tcx = fx.codegen_cx.tcx; - let usize_size = fx.layout_of(fx.codegen_cx.tcx.types.usize).size.bytes() as usize; + let tcx = fx.cx.tcx; + let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, &mut fx.codegen_cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.codegen_cx.tcx)); + import_function(tcx, &mut fx.cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.cx.tcx)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -108,8 +108,8 @@ fn build_vtable<'tcx>( opt_mth.map_or(None, |(def_id, substs)| { Some(import_function( tcx, - &mut fx.codegen_cx.module, - Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.codegen_cx.tcx), + &mut fx.cx.module, + Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.cx.tcx), )) }) }); @@ -121,19 +121,19 @@ fn build_vtable<'tcx>( .collect::>() .into_boxed_slice(); - write_usize(fx.codegen_cx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); - write_usize(fx.codegen_cx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); + write_usize(fx.cx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); + write_usize(fx.cx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); data_ctx.define(data); for (i, component) in components.into_iter().enumerate() { if let Some(func_id) = component { - let func_ref = fx.codegen_cx.module.declare_func_in_data(func_id, &mut data_ctx); + let func_ref = fx.cx.module.declare_func_in_data(func_id, &mut data_ctx); data_ctx.write_function_addr((i * usize_size) as u32, func_ref); } } let data_id = fx - .codegen_cx.module + .cx.module .declare_data( &format!( "__vtable.{}.for.{:?}.{}", @@ -142,13 +142,13 @@ fn build_vtable<'tcx>( .map(|trait_ref| format!("{:?}", trait_ref.skip_binder()).into()) .unwrap_or(std::borrow::Cow::Borrowed("???")), layout.ty, - fx.codegen_cx.vtables.len(), + fx.cx.vtables.len(), ), Linkage::Local, false, false, Some( - fx.codegen_cx.tcx + fx.cx.tcx .data_layout .pointer_align .pref @@ -159,7 +159,7 @@ fn build_vtable<'tcx>( ) .unwrap(); - fx.codegen_cx.module.define_data(data_id, &data_ctx).unwrap(); + fx.cx.module.define_data(data_id, &data_ctx).unwrap(); data_id } From ea29b1818f42075f49dac460867d77e0d9c080a5 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 16:40:58 +0200 Subject: [PATCH 1473/1566] FunctionCx: Fix FunctionCx initialization in trans_fn() --- src/base.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/base.rs b/src/base.rs index 662054d4e4fdd..f8046ed3a8e41 100644 --- a/src/base.rs +++ b/src/base.rs @@ -16,14 +16,9 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); - // Make FunctionBuilder - let context = &mut cx.cached_context; - context.clear(); - context.func.name = ExternalName::user(0, func_id.as_u32()); - context.func.signature = sig; - context.func.collect_debug_info(); let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut context.func, &mut func_ctx); + let mut func = Function::new(); + let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); // Predefine blocks let start_block = bcx.create_block(); @@ -66,6 +61,13 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( }); } + // Make FunctionBuilder + let context = &mut fx.cx.cached_context; + context.clear(); + context.func.name = ExternalName::user(0, func_id.as_u32()); + context.func.signature = sig; + context.func.collect_debug_info(); + // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; let mut clif_comments = fx.clif_comments; @@ -74,7 +76,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let cold_blocks = fx.cold_blocks; crate::pretty_clif::write_clif_file( - cx.tcx, + fx.cx.tcx, "unopt", None, instance, @@ -94,10 +96,10 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // instruction, which doesn't have an encoding. context.compute_cfg(); context.compute_domtree(); - context.eliminate_unreachable_code(cx.module.isa()).unwrap(); + context.eliminate_unreachable_code(fx.cx.module.isa()).unwrap(); // Define function - let module = &mut cx.module; + let module = &mut fx.cx.module; tcx.sess.time( "define function", || module.define_function( @@ -109,18 +111,18 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Write optimized function to file for debugging crate::pretty_clif::write_clif_file( - cx.tcx, + fx.cx.tcx, "opt", - Some(cx.module.isa()), + Some(fx.cx.module.isa()), instance, &context, &clif_comments, ); // Define debuginfo for function - let isa = cx.module.isa(); - let debug_context = &mut cx.debug_context; - let unwind_context = &mut cx.unwind_context; + let isa = fx.cx.module.isa(); + let debug_context = &mut fx.cx.debug_context; + let unwind_context = &mut fx.cx.unwind_context; tcx.sess.time("generate debug info", || { if let Some(debug_context) = debug_context { debug_context.define_function(instance, func_id, &name, isa, context, &source_info_set, local_map); From 5cf457735203230d39cb3dca79731c62951962c5 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 16:45:50 +0200 Subject: [PATCH 1474/1566] FunctionCx: Add tcx field for easier access --- src/base.rs | 1 + src/common.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/base.rs b/src/base.rs index f8046ed3a8e41..73ebcc3be65f4 100644 --- a/src/base.rs +++ b/src/base.rs @@ -30,6 +30,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let mut fx = FunctionCx { cx, + tcx, pointer_type, instance, diff --git a/src/common.rs b/src/common.rs index 7283630f748d1..63b21023f8991 100644 --- a/src/common.rs +++ b/src/common.rs @@ -266,6 +266,7 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool { pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) cx: &'clif mut crate::CodegenCx<'tcx, B>, + pub(crate) tcx: TyCtxt<'tcx>, pub(crate) pointer_type: Type, // Cached from module pub(crate) instance: Instance<'tcx>, From 0d1f8c802e4903d06e758acc3f2d553e32a10b24 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 16:47:31 +0200 Subject: [PATCH 1475/1566] FunctionCx: Refactor `fx.cx.tcx` into `fx.tcx` --- src/abi/mod.rs | 50 ++++++++++++++--------------- src/abi/pass_mode.rs | 6 ++-- src/abi/returning.rs | 6 ++-- src/analyze.rs | 4 +-- src/base.rs | 72 +++++++++++++++++++++--------------------- src/cast.rs | 16 +++++----- src/codegen_i128.rs | 42 ++++++++++++------------ src/common.rs | 24 +++++++------- src/constant.rs | 28 ++++++++-------- src/discriminant.rs | 4 +-- src/driver/mod.rs | 2 +- src/inline_asm.rs | 2 +- src/intrinsics/llvm.rs | 6 ++-- src/intrinsics/mod.rs | 38 +++++++++++----------- src/intrinsics/simd.rs | 26 +++++++-------- src/num.rs | 16 +++++----- src/trap.rs | 4 +-- src/unsize.rs | 4 +-- src/value_and_place.rs | 32 +++++++++---------- src/vtable.rs | 30 +++++++++--------- 20 files changed, 206 insertions(+), 206 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index ec983667b1c7e..6007c83787f4b 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -226,7 +226,7 @@ pub(crate) fn import_function<'tcx>( impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Instance must be monomorphized pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { - let func_id = import_function(self.cx.tcx, &mut self.cx.module, inst); + let func_id = import_function(self.tcx, &mut self.cx.module, inst); let func_ref = self .cx.module .declare_func_in_func(func_id, &mut self.bcx.func); @@ -374,9 +374,9 @@ pub(crate) fn codegen_fn_prelude<'tcx>( .collect::, Ty<'tcx>)>>(); assert!(fx.caller_location.is_none()); - if fx.instance.def.requires_caller_location(fx.cx.tcx) { + if fx.instance.def.requires_caller_location(fx.tcx) { // Store caller location for `#[track_caller]`. - fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.cx.tcx.caller_location_ty()).unwrap()); + fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.tcx.caller_location_ty()).unwrap()); } fx.bcx.switch_to_block(start_block); @@ -398,7 +398,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( let local_decl = &fx.mir.local_decls[local]; // v this ! is important let internally_mutable = !val.layout().ty.is_freeze( - fx.cx.tcx.at(local_decl.source_info.span), + fx.tcx.at(local_decl.source_info.span), ParamEnv::reveal_all(), ); if local_decl.mutability == mir::Mutability::Not && !internally_mutable { @@ -465,24 +465,24 @@ pub(crate) fn codegen_terminator_call<'tcx>( args: &[Operand<'tcx>], destination: Option<(Place<'tcx>, BasicBlock)>, ) { - let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.cx.tcx)); + let fn_ty = fx.monomorphize(&func.ty(fx.mir, fx.tcx)); let fn_sig = fx - .cx.tcx - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.cx.tcx)); + .tcx + .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx)); let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); // Handle special calls like instrinsics and empty drop glue. let instance = if let ty::FnDef(def_id, substs) = fn_ty.kind { - let instance = ty::Instance::resolve(fx.cx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) + let instance = ty::Instance::resolve(fx.tcx, ty::ParamEnv::reveal_all(), def_id, substs) .unwrap() .unwrap() - .polymorphize(fx.cx.tcx); + .polymorphize(fx.tcx); - if fx.cx.tcx.symbol_name(instance).name.starts_with("llvm.") { + if fx.tcx.symbol_name(instance).name.starts_with("llvm.") { crate::intrinsics::codegen_llvm_intrinsic_call( fx, - &fx.cx.tcx.symbol_name(instance).name, + &fx.tcx.symbol_name(instance).name, substs, args, destination, @@ -510,7 +510,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let is_cold = instance.map(|inst| - fx.cx.tcx.codegen_fn_attrs(inst.def_id()) + fx.tcx.codegen_fn_attrs(inst.def_id()) .flags.contains(CodegenFnAttrFlags::COLD)) .unwrap_or(false); if is_cold { @@ -558,7 +558,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( nop_inst, format!( "virtual call; self arg pass mode: {:?}", - get_pass_mode(fx.cx.tcx, args[0].layout()) + get_pass_mode(fx.tcx, args[0].layout()) ), ); } @@ -608,7 +608,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( ) .collect::>(); - if instance.map(|inst| inst.def.requires_caller_location(fx.cx.tcx)).unwrap_or(false) { + if instance.map(|inst| inst.def.requires_caller_location(fx.tcx)).unwrap_or(false) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); @@ -616,7 +616,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let call_inst = if let Some(func_ref) = func_ref { let sig = clif_sig_from_fn_sig( - fx.cx.tcx, + fx.tcx, fx.triple(), fn_sig, span, @@ -637,7 +637,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { if fn_sig.abi != Abi::C { - fx.cx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); + fx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); let abi_params = call_args @@ -646,7 +646,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - fx.cx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); + fx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); } AbiParam::new(ty) }) @@ -668,17 +668,17 @@ pub(crate) fn codegen_drop<'tcx>( drop_place: CPlace<'tcx>, ) { let ty = drop_place.layout().ty; - let drop_fn = Instance::resolve_drop_in_place(fx.cx.tcx, ty).polymorphize(fx.cx.tcx); + let drop_fn = Instance::resolve_drop_in_place(fx.tcx, ty).polymorphize(fx.tcx); if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def { // we don't actually need to drop anything } else { - let drop_fn_ty = drop_fn.ty(fx.cx.tcx, ParamEnv::reveal_all()); - let fn_sig = fx.cx.tcx.normalize_erasing_late_bound_regions( + let drop_fn_ty = drop_fn.ty(fx.tcx, ParamEnv::reveal_all()); + let fn_sig = fx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &drop_fn_ty.fn_sig(fx.cx.tcx), + &drop_fn_ty.fn_sig(fx.tcx), ); - assert_eq!(fn_sig.output(), fx.cx.tcx.mk_unit()); + assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); match ty.kind { ty::Dynamic(..) => { @@ -687,7 +687,7 @@ pub(crate) fn codegen_drop<'tcx>( let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap()); let sig = clif_sig_from_fn_sig( - fx.cx.tcx, + fx.tcx, fx.triple(), fn_sig, span, @@ -702,7 +702,7 @@ pub(crate) fn codegen_drop<'tcx>( let arg_place = CPlace::new_stack_slot( fx, - fx.layout_of(fx.cx.tcx.mk_ref( + fx.layout_of(fx.tcx.mk_ref( &ty::RegionKind::ReErased, TypeAndMut { ty, @@ -716,7 +716,7 @@ pub(crate) fn codegen_drop<'tcx>( let mut call_args: Vec = arg_value.into_iter().collect::>(); - if drop_fn.def.requires_caller_location(fx.cx.tcx) { + if drop_fn.def.requires_caller_location(fx.tcx) { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index ffdd672ef7b6a..02604a3757201 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -118,7 +118,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, ) -> EmptySinglePair { - match get_pass_mode(fx.cx.tcx, arg.layout()) { + match get_pass_mode(fx.tcx, arg.layout()) { PassMode::NoPass => Empty, PassMode::ByVal(_) => Single(arg.load_scalar(fx)), PassMode::ByValPair(_, _) => { @@ -144,13 +144,13 @@ pub(super) fn cvalue_for_param<'tcx>( arg_ty: Ty<'tcx>, ) -> Option> { let layout = fx.layout_of(arg_ty); - let pass_mode = get_pass_mode(fx.cx.tcx, layout); + let pass_mode = get_pass_mode(fx.tcx, layout); if let PassMode::NoPass = pass_mode { return None; } - let clif_types = pass_mode.get_param_ty(fx.cx.tcx); + let clif_types = pass_mode.get_param_ty(fx.tcx); let block_params = clif_types.map(|t| fx.bcx.append_block_param(start_block, t)); #[cfg(debug_assertions)] diff --git a/src/abi/returning.rs b/src/abi/returning.rs index b0044b9ea0f83..e445a12b2a882 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -19,7 +19,7 @@ pub(super) fn codegen_return_param( start_block: Block, ) { let ret_layout = return_layout(fx); - let ret_pass_mode = get_pass_mode(fx.cx.tcx, ret_layout); + let ret_pass_mode = get_pass_mode(fx.tcx, ret_layout); let ret_param = match ret_pass_mode { PassMode::NoPass => { fx.local_map @@ -66,7 +66,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( ) -> (Inst, T) { let ret_layout = fx.layout_of(fn_sig.output()); - let output_pass_mode = get_pass_mode(fx.cx.tcx, ret_layout); + let output_pass_mode = get_pass_mode(fx.tcx, ret_layout); let return_ptr = match output_pass_mode { PassMode::NoPass => None, PassMode::ByRef { size: Some(_)} => match ret_place { @@ -102,7 +102,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( } pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { - match get_pass_mode(fx.cx.tcx, return_layout(fx)) { + match get_pass_mode(fx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { size: Some(_) } => { fx.bcx.ins().return_(&[]); } diff --git a/src/analyze.rs b/src/analyze.rs index 1e7d397bbe51a..7bd2c802868df 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -35,8 +35,8 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { if let Some((dest_place, _dest_bb)) = destination { - let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.cx.tcx).ty)); - if !crate::abi::can_return_to_ssa_var(fx.cx.tcx, dest_layout) { + let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty)); + if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) { not_ssa(&mut flag_map, dest_place.local) } } diff --git a/src/base.rs b/src/base.rs index 73ebcc3be65f4..27afe8bb4aa86 100644 --- a/src/base.rs +++ b/src/base.rs @@ -77,7 +77,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let cold_blocks = fx.cold_blocks; crate::pretty_clif::write_clif_file( - fx.cx.tcx, + fx.tcx, "unopt", None, instance, @@ -112,7 +112,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Write optimized function to file for debugging crate::pretty_clif::write_clif_file( - fx.cx.tcx, + fx.tcx, "opt", Some(fx.cx.module.isa()), instance, @@ -223,7 +223,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { target, cleanup: _, } => { - if !fx.cx.tcx.sess.overflow_checks() { + if !fx.tcx.sess.overflow_checks() { if let mir::AssertKind::OverflowNeg(_) = *msg { let target = fx.get_block(*target); fx.bcx.ins().jump(target, &[]); @@ -264,12 +264,12 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } }; - let def_id = fx.cx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { - fx.cx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) + let def_id = fx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { + fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) }); - let instance = Instance::mono(fx.cx.tcx, def_id).polymorphize(fx.cx.tcx); - let symbol_name = fx.cx.tcx.symbol_name(instance).name; + let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); + let symbol_name = fx.tcx.symbol_name(instance).name; fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); @@ -299,7 +299,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, from_hir_call: _, } => { - fx.cx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( + fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( fx, *fn_span, block, @@ -418,7 +418,7 @@ fn trans_stmt<'tcx>( let lhs = trans_operand(fx, lhs); let rhs = trans_operand(fx, rhs); - let res = if !fx.cx.tcx.sess.overflow_checks() { + let res = if !fx.tcx.sess.overflow_checks() { let val = crate::num::trans_int_binop(fx, *bin_op, lhs, rhs).load_scalar(fx); let is_overflow = fx.bcx.ins().iconst(types::I8, 0); @@ -464,14 +464,14 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, res); } Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, to_ty) => { - let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.cx.tcx)); + let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)); let to_layout = fx.layout_of(fx.monomorphize(to_ty)); match from_ty.kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( - Instance::resolve_for_fn_ptr(fx.cx.tcx, ParamEnv::reveal_all(), def_id, substs) + Instance::resolve_for_fn_ptr(fx.tcx, ParamEnv::reveal_all(), def_id, substs) .unwrap() - .polymorphize(fx.cx.tcx), + .polymorphize(fx.tcx), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, to_layout)); @@ -500,7 +500,7 @@ fn trans_stmt<'tcx>( |ty::TypeAndMut { ty: pointee_ty, mutbl: _, - }| has_ptr_meta(fx.cx.tcx, pointee_ty), + }| has_ptr_meta(fx.tcx, pointee_ty), ) .unwrap_or(false) } @@ -526,7 +526,7 @@ fn trans_stmt<'tcx>( match &operand.layout().variants { Variants::Single { index } => { - let discr = operand.layout().ty.discriminant_for_variant(fx.cx.tcx, *index).unwrap(); + let discr = operand.layout().ty.discriminant_for_variant(fx.tcx, *index).unwrap(); let discr = if discr.ty.is_signed() { rustc_middle::mir::interpret::sign_extend(discr.val, fx.layout_of(discr.ty).size) } else { @@ -578,11 +578,11 @@ fn trans_stmt<'tcx>( match operand.layout().ty.kind { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( - fx.cx.tcx, + fx.tcx, def_id, substs, ty::ClosureKind::FnOnce, - ).polymorphize(fx.cx.tcx); + ).polymorphize(fx.tcx); let func_ref = fx.get_function_ref(instance); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); @@ -605,9 +605,9 @@ fn trans_stmt<'tcx>( let operand = trans_operand(fx, operand); let times = fx .monomorphize(times) - .eval(fx.cx.tcx, ParamEnv::reveal_all()) + .eval(fx.tcx, ParamEnv::reveal_all()) .val - .try_to_bits(fx.cx.tcx.data_layout.pointer_size) + .try_to_bits(fx.tcx.data_layout.pointer_size) .unwrap(); for i in 0..times { let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); @@ -617,14 +617,14 @@ fn trans_stmt<'tcx>( } Rvalue::Len(place) => { let place = trans_place(fx, *place); - let usize_layout = fx.layout_of(fx.cx.tcx.types.usize); + let usize_layout = fx.layout_of(fx.tcx.types.usize); let len = codegen_array_len(fx, place); lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { use rustc_hir::lang_items::ExchangeMallocFnLangItem; - let usize_type = fx.clif_type(fx.cx.tcx.types.usize).unwrap(); + let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); let content_ty = fx.monomorphize(content_ty); let layout = fx.layout_of(content_ty); let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64); @@ -632,18 +632,18 @@ fn trans_stmt<'tcx>( .bcx .ins() .iconst(usize_type, layout.align.abi.bytes() as i64); - let box_layout = fx.layout_of(fx.cx.tcx.mk_box(content_ty)); + let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty)); // Allocate space: - let def_id = match fx.cx.tcx.lang_items().require(ExchangeMallocFnLangItem) { + let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) { Ok(id) => id, Err(s) => { - fx.cx.tcx + fx.tcx .sess .fatal(&format!("allocation of `{}` {}", box_layout.ty, s)); } }; - let instance = ty::Instance::mono(fx.cx.tcx, def_id).polymorphize(fx.cx.tcx); + let instance = ty::Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); let func_ref = fx.get_function_ref(instance); let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]); let ptr = fx.bcx.inst_results(call)[0]; @@ -653,9 +653,9 @@ fn trans_stmt<'tcx>( assert!(lval .layout() .ty - .is_sized(fx.cx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); + .is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); - let val = CValue::const_val(fx, fx.layout_of(fx.cx.tcx.types.usize), ty_size.into()); + let val = CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), ty_size.into()); lval.write_cvalue(fx, val); } Rvalue::Aggregate(kind, operands) => match **kind { @@ -720,10 +720,10 @@ fn trans_stmt<'tcx>( let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); assert_eq!(outputs.len(), 4); - trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.cx.tcx.types.u32))); - trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.cx.tcx.types.u32))); - trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.cx.tcx.types.u32))); - trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.cx.tcx.types.u32))); + trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32))); } "xgetbv" => { assert_eq!(input_names, &[Symbol::intern("{ecx}")]); @@ -743,17 +743,17 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } // ___chkstk, ___chkstk_ms and __alloca are only used on Windows - _ if fx.cx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { + _ if fx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { crate::trap::trap_unimplemented(fx, "Stack probes are not supported"); } - _ if fx.cx.tcx.symbol_name(fx.instance).name == "__alloca" => { + _ if fx.tcx.symbol_name(fx.instance).name == "__alloca" => { crate::trap::trap_unimplemented(fx, "Alloca is not supported"); } // Used in sys::windows::abort_internal "int $$0x29" => { crate::trap::trap_unimplemented(fx, "Windows abort"); } - _ => fx.cx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), + _ => fx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), } } } @@ -766,8 +766,8 @@ fn codegen_array_len<'tcx>( match place.layout().ty.kind { ty::Array(_elem_ty, len) => { let len = fx.monomorphize(&len) - .eval(fx.cx.tcx, ParamEnv::reveal_all()) - .eval_usize(fx.cx.tcx, ParamEnv::reveal_all()) as i64; + .eval(fx.tcx, ParamEnv::reveal_all()) + .eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place @@ -820,7 +820,7 @@ pub(crate) fn trans_place<'tcx>( let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), - fx.layout_of(fx.cx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), + fx.layout_of(fx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), ); } ty::Slice(elem_ty) => { diff --git a/src/cast.rs b/src/cast.rs index 25ce5812f9bd4..36e060496b1da 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -86,14 +86,14 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = if from_signed { - fx.cx.tcx.types.i128 + fx.tcx.types.i128 } else { - fx.cx.tcx.types.u128 + fx.tcx.types.u128 }; let to_rust_ty = match to_ty { - types::F32 => fx.cx.tcx.types.f32, - types::F64 => fx.cx.tcx.types.f64, + types::F32 => fx.tcx.types.f32, + types::F64 => fx.tcx.types.f64, _ => unreachable!(), }; @@ -131,15 +131,15 @@ pub(crate) fn clif_int_or_float_cast( ); let from_rust_ty = match from_ty { - types::F32 => fx.cx.tcx.types.f32, - types::F64 => fx.cx.tcx.types.f64, + types::F32 => fx.tcx.types.f32, + types::F64 => fx.tcx.types.f64, _ => unreachable!(), }; let to_rust_ty = if to_signed { - fx.cx.tcx.types.i128 + fx.tcx.types.i128 } else { - fx.cx.tcx.types.u128 + fx.tcx.types.u128 }; return fx diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 0b02d32c6518b..e2bb5b17ba2d3 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -9,7 +9,7 @@ pub(crate) fn maybe_codegen<'tcx>( lhs: CValue<'tcx>, rhs: CValue<'tcx>, ) -> Option> { - if lhs.layout().ty != fx.cx.tcx.types.u128 && lhs.layout().ty != fx.cx.tcx.types.i128 { + if lhs.layout().ty != fx.tcx.types.u128 && lhs.layout().ty != fx.tcx.types.i128 { return None; } @@ -25,7 +25,7 @@ pub(crate) fn maybe_codegen<'tcx>( } BinOp::Add | BinOp::Sub if !checked => return None, BinOp::Add => { - let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_addo", &[lhs, rhs], out_ty) } else { @@ -33,7 +33,7 @@ pub(crate) fn maybe_codegen<'tcx>( }); } BinOp::Sub => { - let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); return Some(if is_signed { fx.easy_call("__rust_i128_subo", &[lhs, rhs], out_ty) } else { @@ -43,7 +43,7 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"), BinOp::Mul => { let res = if checked { - let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); if is_signed { fx.easy_call("__rust_i128_mulo", &[lhs, rhs], out_ty) } else { @@ -51,9 +51,9 @@ pub(crate) fn maybe_codegen<'tcx>( } } else { let val_ty = if is_signed { - fx.cx.tcx.types.i128 + fx.tcx.types.i128 } else { - fx.cx.tcx.types.u128 + fx.tcx.types.u128 }; fx.easy_call("__multi3", &[lhs, rhs], val_ty) }; @@ -62,17 +62,17 @@ pub(crate) fn maybe_codegen<'tcx>( BinOp::Div => { assert!(!checked); if is_signed { - Some(fx.easy_call("__divti3", &[lhs, rhs], fx.cx.tcx.types.i128)) + Some(fx.easy_call("__divti3", &[lhs, rhs], fx.tcx.types.i128)) } else { - Some(fx.easy_call("__udivti3", &[lhs, rhs], fx.cx.tcx.types.u128)) + Some(fx.easy_call("__udivti3", &[lhs, rhs], fx.tcx.types.u128)) } } BinOp::Rem => { assert!(!checked); if is_signed { - Some(fx.easy_call("__modti3", &[lhs, rhs], fx.cx.tcx.types.i128)) + Some(fx.easy_call("__modti3", &[lhs, rhs], fx.tcx.types.i128)) } else { - Some(fx.easy_call("__umodti3", &[lhs, rhs], fx.cx.tcx.types.u128)) + Some(fx.easy_call("__umodti3", &[lhs, rhs], fx.tcx.types.u128)) } } BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => { @@ -104,7 +104,7 @@ pub(crate) fn maybe_codegen<'tcx>( let val = match (bin_op, is_signed) { (BinOp::Shr, false) => { let val = fx.bcx.ins().iconcat(lhs_msb, all_zeros); - Some(CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.u128))) + Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.u128))) } (BinOp::Shr, true) => { let sign = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, lhs_msb, 0); @@ -112,13 +112,13 @@ pub(crate) fn maybe_codegen<'tcx>( let all_sign_bits = fx.bcx.ins().select(sign, all_zeros, all_ones); let val = fx.bcx.ins().iconcat(lhs_msb, all_sign_bits); - Some(CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.i128))) + Some(CValue::by_val(val, fx.layout_of(fx.tcx.types.i128))) } (BinOp::Shl, _) => { let val_ty = if is_signed { - fx.cx.tcx.types.i128 + fx.tcx.types.i128 } else { - fx.cx.tcx.types.u128 + fx.tcx.types.u128 }; let val = fx.bcx.ins().iconcat(all_zeros, lhs_lsb); Some(CValue::by_val(val, fx.layout_of(val_ty))) @@ -127,7 +127,7 @@ pub(crate) fn maybe_codegen<'tcx>( }; if let Some(val) = val { if let Some(is_overflow) = is_overflow { - let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); let val = val.load_scalar(fx); return Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))); } else { @@ -137,24 +137,24 @@ pub(crate) fn maybe_codegen<'tcx>( } let truncated_rhs = clif_intcast(fx, rhs_val, types::I32, false); - let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fx.cx.tcx.types.u32)); + let truncated_rhs = CValue::by_val(truncated_rhs, fx.layout_of(fx.tcx.types.u32)); let val = match (bin_op, is_signed) { (BinOp::Shl, false) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.cx.tcx.types.u128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.tcx.types.u128) } (BinOp::Shl, true) => { - fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.cx.tcx.types.i128) + fx.easy_call("__ashlti3", &[lhs, truncated_rhs], fx.tcx.types.i128) } (BinOp::Shr, false) => { - fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fx.cx.tcx.types.u128) + fx.easy_call("__lshrti3", &[lhs, truncated_rhs], fx.tcx.types.u128) } (BinOp::Shr, true) => { - fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fx.cx.tcx.types.i128) + fx.easy_call("__ashrti3", &[lhs, truncated_rhs], fx.tcx.types.i128) } (_, _) => unreachable!(), }; if let Some(is_overflow) = is_overflow { - let out_ty = fx.cx.tcx.mk_tup([lhs.layout().ty, fx.cx.tcx.types.bool].iter()); + let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter()); let val = val.load_scalar(fx); Some(CValue::by_val_pair(val, is_overflow, fx.layout_of(out_ty))) } else { diff --git a/src/common.rs b/src/common.rs index 63b21023f8991..c8062e493ddb9 100644 --- a/src/common.rs +++ b/src/common.rs @@ -297,11 +297,11 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { fn layout_of(&self, ty: Ty<'tcx>) -> TyAndLayout<'tcx> { assert!(!ty.still_further_specializable()); - self.cx.tcx + self.tcx .layout_of(ParamEnv::reveal_all().and(&ty)) .unwrap_or_else(|e| { if let layout::LayoutError::SizeOverflow(_) = e { - self.cx.tcx.sess.fatal(&e.to_string()) + self.tcx.sess.fatal(&e.to_string()) } else { bug!("failed to get layout for `{}`: {}", ty, e) } @@ -311,13 +311,13 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { impl<'tcx, B: Backend + 'static> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx, B> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { - self.cx.tcx + self.tcx } } impl<'tcx, B: Backend + 'static> rustc_target::abi::HasDataLayout for FunctionCx<'_, 'tcx, B> { fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { - &self.cx.tcx.data_layout + &self.tcx.data_layout } } @@ -329,7 +329,7 @@ impl<'tcx, B: Backend + 'static> layout::HasParamEnv<'tcx> for FunctionCx<'_, 't impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { fn target_spec(&self) -> &Target { - &self.cx.tcx.sess.target.target + &self.tcx.sess.target.target } } @@ -339,22 +339,22 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { T: TypeFoldable<'tcx> + Copy, { if let Some(substs) = self.instance.substs_for_mir_body() { - self.cx.tcx.subst_and_normalize_erasing_regions( + self.tcx.subst_and_normalize_erasing_regions( substs, ty::ParamEnv::reveal_all(), value, ) } else { - self.cx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) + self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) } } pub(crate) fn clif_type(&self, ty: Ty<'tcx>) -> Option { - clif_type_from_ty(self.cx.tcx, ty) + clif_type_from_ty(self.tcx, ty) } pub(crate) fn clif_pair_type(&self, ty: Ty<'tcx>) -> Option<(Type, Type)> { - clif_pair_type_from_ty(self.cx.tcx, ty) + clif_pair_type_from_ty(self.tcx, ty) } pub(crate) fn get_block(&self, bb: BasicBlock) -> Block { @@ -379,8 +379,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); - let caller = self.cx.tcx.sess.source_map().lookup_char_pos(topmost.lo()); - let const_loc = self.cx.tcx.const_caller_location(( + let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo()); + let const_loc = self.tcx.const_caller_location(( rustc_span::symbol::Symbol::intern(&caller.file.name.to_string()), caller.line as u32, caller.col_display as u32 + 1, @@ -388,7 +388,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { crate::constant::trans_const_value( self, const_loc, - self.cx.tcx.caller_location_ty(), + self.tcx.caller_location_ty(), ) } diff --git a/src/constant.rs b/src/constant.rs index 764d8a48ccf73..8b0d3b913cb01 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -41,10 +41,10 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Backend>) { match const_.val { ConstKind::Value(_) => {} ConstKind::Unevaluated(def, ref substs, promoted) => { - if let Err(err) = fx.cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { match err { ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { - fx.cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } ErrorHandled::TooGeneric => { span_bug!(constant.span, "codgen encountered polymorphic constant: {:?}", err); @@ -67,7 +67,7 @@ pub(crate) fn codegen_tls_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { - let data_id = data_id_for_static(fx.cx.tcx, &mut fx.cx.module, def_id, false); + let data_id = data_id_for_static(fx.tcx, &mut fx.cx.module, def_id, false); let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("tls {:?}", def_id)); @@ -80,7 +80,7 @@ fn codegen_static_ref<'tcx>( def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { - let data_id = data_id_for_static(fx.cx.tcx, &mut fx.cx.module, def_id, false); + let data_id = data_id_for_static(fx.tcx, &mut fx.cx.module, def_id, false); let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); @@ -97,7 +97,7 @@ pub(crate) fn trans_constant<'tcx>( let const_ = fx.monomorphize(&constant.literal); let const_val = match const_.val { ConstKind::Value(const_val) => const_val, - ConstKind::Unevaluated(def, ref substs, promoted) if fx.cx.tcx.is_static(def.did) => { + ConstKind::Unevaluated(def, ref substs, promoted) if fx.tcx.is_static(def.did) => { assert!(substs.is_empty()); assert!(promoted.is_none()); @@ -108,11 +108,11 @@ pub(crate) fn trans_constant<'tcx>( ).to_cvalue(fx); } ConstKind::Unevaluated(def, ref substs, promoted) => { - match fx.cx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { Ok(const_val) => const_val, Err(_) => { if promoted.is_none() { - fx.cx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); } return crate::trap::trap_unreachable_ret_value( fx, @@ -154,7 +154,7 @@ pub(crate) fn trans_const_value<'tcx>( ); let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used alloc.write_scalar(fx, ptr, x.into(), size).unwrap(); - let alloc = fx.cx.tcx.intern_const_alloc(alloc); + let alloc = fx.tcx.intern_const_alloc(alloc); return CValue::by_ref(pointer_for_allocation(fx, alloc), layout); } @@ -164,7 +164,7 @@ pub(crate) fn trans_const_value<'tcx>( return CValue::const_val(fx, layout, data); } Scalar::Ptr(ptr) => { - let alloc_kind = fx.cx.tcx.get_global_alloc(ptr.alloc_id); + let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id); let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { fx.cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); @@ -175,13 +175,13 @@ pub(crate) fn trans_const_value<'tcx>( fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { - let func_id = crate::abi::import_function(fx.cx.tcx, &mut fx.cx.module, instance); + let func_id = crate::abi::import_function(fx.tcx, &mut fx.cx.module, instance); let local_func_id = fx.cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) } Some(GlobalAlloc::Static(def_id)) => { - assert!(fx.cx.tcx.is_static(def_id)); - let data_id = data_id_for_static(fx.cx.tcx, &mut fx.cx.module, def_id, false); + assert!(fx.tcx.is_static(def_id)); + let data_id = data_id_for_static(fx.tcx, &mut fx.cx.module, def_id, false); let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); @@ -215,7 +215,7 @@ fn pointer_for_allocation<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { - let alloc_id = fx.cx.tcx.create_memory_alloc(alloc); + let alloc_id = fx.tcx.create_memory_alloc(alloc); fx.cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); let data_id = data_id_for_alloc_id(&mut fx.cx.module, alloc_id, alloc.align, alloc.mutability); @@ -419,7 +419,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( match operand { Operand::Copy(_) | Operand::Move(_) => None, Operand::Constant(const_) => { - Some(fx.monomorphize(&const_.literal).eval(fx.cx.tcx, ParamEnv::reveal_all())) + Some(fx.monomorphize(&const_.literal).eval(fx.tcx, ParamEnv::reveal_all())) } } } diff --git a/src/discriminant.rs b/src/discriminant.rs index 97a92eaf512ca..d15d74225716e 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -26,7 +26,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( let ptr = place.place_field(fx, mir::Field::new(tag_field)); let to = layout .ty - .discriminant_for_variant(fx.cx.tcx, variant_index) + .discriminant_for_variant(fx.tcx, variant_index) .unwrap() .val; let discr = CValue::const_val(fx, ptr.layout(), to); @@ -73,7 +73,7 @@ pub(crate) fn codegen_get_discriminant<'tcx>( Variants::Single { index } => { let discr_val = layout .ty - .discriminant_for_variant(fx.cx.tcx, *index) + .discriminant_for_variant(fx.tcx, *index) .map_or(u128::from(index.as_u32()), |discr| discr.val); return CValue::const_val(fx, dest_layout, discr_val); } diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 1d81efb880df7..96cfa3edbe08b 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -85,7 +85,7 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( } }); - cx.tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); + tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 0f162d6e94b6c..d1783d621e55b 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -70,7 +70,7 @@ pub(crate) fn codegen_inline_asm<'tcx>( let inline_asm_index = fx.inline_asm_index; fx.inline_asm_index += 1; - let asm_name = format!("{}__inline_asm_{}", fx.cx.tcx.symbol_name(fx.instance).name, inline_asm_index); + let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, inline_asm_index); let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); fx.cx.global_asm.push_str(&generated_asm); diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index 45d655fb5eda3..c85daaa0e2e3d 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -30,13 +30,13 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.cx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); + fx.tcx.sess.warn(&format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); crate::trap::trap_unimplemented(fx, intrinsic); }; // Used by `_mm_movemask_epi8` and `_mm256_movemask_epi8` llvm.x86.sse2.pmovmskb.128 | llvm.x86.avx2.pmovmskb | llvm.x86.sse2.movmsk.pd, (c a) { - let (lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, a.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, a.layout()); let lane_ty = fx.clif_type(lane_layout.ty).unwrap(); assert!(lane_count <= 32); @@ -61,7 +61,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( res = fx.bcx.ins().bor(res, a_lane_sign); } - let res = CValue::by_val(res, fx.layout_of(fx.cx.tcx.types.i32)); + let res = CValue::by_val(res, fx.layout_of(fx.tcx.types.i32)); ret.write_cvalue(fx, res); }; llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) { diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 454a0d2b91bc5..b0d5988a6e433 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -88,7 +88,7 @@ macro call_intrinsic_match { let ($($arg,)*) = ( $(trans_operand($fx, $arg),)* ); - let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.cx.tcx.types.$ty); + let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty); $ret.write_cvalue($fx, res); if let Some((_, dest)) = $destination { @@ -144,7 +144,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { match $ty.kind { ty::Uint(_) | ty::Int(_) => {} _ => { - $fx.cx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); + $fx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -154,7 +154,7 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { macro validate_simd_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { if !$ty.is_simd() { - $fx.cx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); + $fx.tcx.sess.span_err($span, &format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", $intrinsic, $ty)); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -203,8 +203,8 @@ fn simd_for_each_lane<'tcx, B: Backend>( ) { let layout = val.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane_idx in 0..lane_count { @@ -233,8 +233,8 @@ fn simd_pair_for_each_lane<'tcx, B: Backend>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); + let (lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { @@ -273,7 +273,7 @@ fn bool_to_zero_or_max_uint<'tcx>( macro simd_cmp { ($fx:expr, $cc:ident($x:ident, $y:ident) -> $ret:ident) => { - let vector_ty = clif_vector_type($fx.cx.tcx, $x.layout()); + let vector_ty = clif_vector_type($fx.tcx, $x.layout()); if let Some(vector_ty) = vector_ty { let x = $x.load_scalar($fx); @@ -390,7 +390,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fx.cx.tcx.item_name(def_id).as_str(); + let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; let ret = match destination { @@ -423,7 +423,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( return; } - let usize_layout = fx.layout_of(fx.cx.tcx.types.usize); + let usize_layout = fx.layout_of(fx.tcx.types.usize); call_intrinsic_match! { fx, intrinsic, substs, ret, destination, args, @@ -473,7 +473,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.cx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); + fx.tcx.sess.span_fatal(span, &format!("unsupported intrinsic {}", intrinsic)); }; assume, (c _a) {}; @@ -684,7 +684,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ctlz | ctlz_nonzero, (v arg) { // FIXME trap on `ctlz_nonzero` with zero arg. - let res = if T == fx.cx.tcx.types.u128 || T == fx.cx.tcx.types.i128 { + let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_lz = fx.bcx.ins().clz(lsb); @@ -701,7 +701,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; cttz | cttz_nonzero, (v arg) { // FIXME trap on `cttz_nonzero` with zero arg. - let res = if T == fx.cx.tcx.types.u128 || T == fx.cx.tcx.types.i128 { + let res = if T == fx.tcx.types.u128 || T == fx.tcx.types.i128 { // FIXME verify this algorithm is correct let (lsb, msb) = fx.bcx.ins().isplit(arg); let lsb_tz = fx.bcx.ins().ctz(lsb); @@ -842,7 +842,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( size_of | pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () { let const_val = - fx.cx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); + fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap(); let val = crate::constant::trans_const_value( fx, const_val, @@ -852,7 +852,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( }; ptr_offset_from, (v ptr, v base) { - let isize_layout = fx.layout_of(fx.cx.tcx.types.isize); + let isize_layout = fx.layout_of(fx.tcx.types.isize); let pointee_size: u64 = fx.layout_of(T).size.bytes(); let diff = fx.bcx.ins().isub(ptr, base); @@ -1011,22 +1011,22 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( minnumf32, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32)); ret.write_cvalue(fx, val); }; minnumf64, (v a, v b) { let val = fx.bcx.ins().fmin(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64)); ret.write_cvalue(fx, val); }; maxnumf32, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f32)); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32)); ret.write_cvalue(fx, val); }; maxnumf64, (v a, v b) { let val = fx.bcx.ins().fmax(a, b); - let val = CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.f64)); + let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64)); ret.write_cvalue(fx, val); }; diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 0a564be44a028..92fd00f049c4c 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -11,13 +11,13 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let def_id = instance.def_id(); let substs = instance.substs; - let intrinsic = fx.cx.tcx.item_name(def_id).as_str(); + let intrinsic = fx.tcx.item_name(def_id).as_str(); let intrinsic = &intrinsic[..]; intrinsic_match! { fx, intrinsic, substs, args, _ => { - fx.cx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); + fx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic)); }; simd_cast, (c a) { @@ -68,8 +68,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(x.layout(), y.layout()); let layout = x.layout(); - let (lane_type, lane_count) = lane_type_and_count(fx.cx.tcx, layout); - let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); + let (lane_type, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_type, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); assert_eq!(lane_type, ret_lane_type); assert_eq!(n, ret_lane_count); @@ -92,7 +92,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( (0..ret_lane_count).map(|i| { let i = usize::try_from(i).unwrap(); let idx = rustc_middle::mir::interpret::read_target_uint( - fx.cx.tcx.data_layout.endian, + fx.tcx.data_layout.endian, &idx_bytes[4*i.. 4*i + 4], ).expect("read_target_uint"); u16::try_from(idx).expect("try_from u32") @@ -119,7 +119,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.cx.tcx.sess.span_warn( + fx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -128,9 +128,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx.cx.tcx, base.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, base.layout()); if idx >= lane_count.into() { - fx.cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); + fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count)); } ret.write_cvalue(fx, base); @@ -143,7 +143,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.cx.tcx.sess.span_warn( + fx.tcx.sess.span_warn( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); @@ -153,9 +153,9 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); - let (_lane_type, lane_count) = lane_type_and_count(fx.cx.tcx, v.layout()); + let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, v.layout()); if idx >= lane_count.into() { - fx.cx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); + fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count)); } let ret_lane = v.value_field(fx, mir::Field::new(idx.try_into().unwrap())); @@ -205,8 +205,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( assert_eq!(a.layout(), c.layout()); let layout = a.layout(); - let (_lane_layout, lane_count) = lane_type_and_count(fx.cx.tcx, layout); - let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.cx.tcx, ret.layout()); + let (_lane_layout, lane_count) = lane_type_and_count(fx.tcx, layout); + let (ret_lane_layout, ret_lane_count) = lane_type_and_count(fx.tcx, ret.layout()); assert_eq!(lane_count, ret_lane_count); for lane in 0..lane_count { diff --git a/src/num.rs b/src/num.rs index 5b1097b2be752..22269b5ee29e5 100644 --- a/src/num.rs +++ b/src/num.rs @@ -48,7 +48,7 @@ fn codegen_compare_bin_op<'tcx>( let intcc = crate::num::bin_op_to_intcc(bin_op, signed).unwrap(); let val = fx.bcx.ins().icmp(intcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.bool)) + CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)) } pub(crate) fn codegen_binop<'tcx>( @@ -66,8 +66,8 @@ pub(crate) fn codegen_binop<'tcx>( let rhs = in_rhs.load_scalar(fx); let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (in_lhs.layout().ty.kind == fx.cx.tcx.types.i8.kind - || in_lhs.layout().ty.kind == fx.cx.tcx.types.i16.kind) + && (in_lhs.layout().ty.kind == fx.tcx.types.i8.kind + || in_lhs.layout().ty.kind == fx.tcx.types.i16.kind) { // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. ( @@ -118,7 +118,7 @@ pub(crate) fn trans_bool_binop<'tcx>( _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; - CValue::by_val(res, fx.layout_of(fx.cx.tcx.types.bool)) + CValue::by_val(res, fx.layout_of(fx.tcx.types.bool)) } pub(crate) fn trans_int_binop<'tcx>( @@ -323,7 +323,7 @@ pub(crate) fn trans_checked_int_binop<'tcx>( // FIXME directly write to result place instead let out_place = CPlace::new_stack_slot( fx, - fx.layout_of(fx.cx.tcx.mk_tup([in_lhs.layout().ty, fx.cx.tcx.types.bool].iter())), + fx.layout_of(fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter())), ); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); @@ -368,7 +368,7 @@ pub(crate) fn trans_float_binop<'tcx>( }; let val = fx.bcx.ins().fcmp(fltcc, lhs, rhs); let val = fx.bcx.ins().bint(types::I8, val); - return CValue::by_val(val, fx.layout_of(fx.cx.tcx.types.bool)); + return CValue::by_val(val, fx.layout_of(fx.tcx.types.bool)); } _ => unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs, in_rhs), }; @@ -383,7 +383,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { let is_thin_ptr = in_lhs.layout().ty.builtin_deref(true).map(|TypeAndMut { ty, mutbl: _}| { - !has_ptr_meta(fx.cx.tcx, ty) + !has_ptr_meta(fx.tcx, ty) }).unwrap_or(true); if is_thin_ptr { @@ -440,7 +440,7 @@ pub(crate) fn trans_ptr_binop<'tcx>( CValue::by_val( fx.bcx.ins().bint(types::I8, res), - fx.layout_of(fx.cx.tcx.types.bool), + fx.layout_of(fx.tcx.types.bool), ) } } diff --git a/src/trap.rs b/src/trap.rs index 9b75e61ba761c..05be1d1706b7d 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -8,7 +8,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms Linkage::Import, &Signature { call_conv: CallConv::triple_default(fx.triple()), - params: vec![AbiParam::new(pointer_ty(fx.cx.tcx))], + params: vec![AbiParam::new(pointer_ty(fx.tcx))], returns: vec![AbiParam::new(types::I32)], }, ) @@ -19,7 +19,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms fx.add_comment(puts, "puts"); } - let symbol_name = fx.cx.tcx.symbol_name(fx.instance); + let symbol_name = fx.tcx.symbol_name(fx.instance); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg); let msg_ptr = fx.anonymous_str("trap", &real_msg); fx.bcx.ins().call(puts, &[msg_ptr]); diff --git a/src/unsize.rs b/src/unsize.rs index 5746f109afd15..affb36d7d3712 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -15,12 +15,12 @@ pub(crate) fn unsized_info<'tcx>( old_info: Option, ) -> Value { let (source, target) = - fx.cx.tcx + fx.tcx .struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); match (&source.kind, &target.kind) { (&ty::Array(_, len), &ty::Slice(_)) => fx.bcx.ins().iconst( fx.pointer_type, - len.eval_usize(fx.cx.tcx, ParamEnv::reveal_all()) as i64, + len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64, ), (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker diff --git a/src/value_and_place.rs b/src/value_and_place.rs index abe9437d42936..4b03860c17a9d 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -35,10 +35,10 @@ fn codegen_field<'tcx>( let unaligned_offset = field_offset.bytes(); let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout, extra); - let one = fx.bcx.ins().iconst(pointer_ty(fx.cx.tcx), 1); + let one = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 1); let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); let and_lhs = fx.bcx.ins().iadd_imm(align_sub_1, unaligned_offset as i64); - let zero = fx.bcx.ins().iconst(pointer_ty(fx.cx.tcx), 0); + let zero = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 0); let and_rhs = fx.bcx.ins().isub(zero, unsized_align); let offset = fx.bcx.ins().band(and_lhs, and_rhs); @@ -119,9 +119,9 @@ impl<'tcx> CValue<'tcx> { match self.0 { CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.abi { - Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.cx.tcx, scalar.clone()), + Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), Abi::Vector { ref element, count } => { - scalar_to_clif_type(fx.cx.tcx, element.clone()) + scalar_to_clif_type(fx.tcx, element.clone()) .by(u16::try_from(count).unwrap()).unwrap() } _ => unreachable!("{:?}", layout.ty), @@ -146,9 +146,9 @@ impl<'tcx> CValue<'tcx> { Abi::ScalarPair(a, b) => (a, b), _ => unreachable!("load_scalar_pair({:?})", self), }; - let b_offset = scalar_pair_calculate_b_offset(fx.cx.tcx, a_scalar, b_scalar); - let clif_ty1 = scalar_to_clif_type(fx.cx.tcx, a_scalar.clone()); - let clif_ty2 = scalar_to_clif_type(fx.cx.tcx, b_scalar.clone()); + let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); + let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); + let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); let val1 = ptr.load(fx, clif_ty1, MemFlags::new()); let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); (val1, val2) @@ -419,13 +419,13 @@ impl<'tcx> CPlace<'tcx> { assert_assignable(fx, a, b); } (ty::FnPtr(_), ty::FnPtr(_)) => { - let from_sig = fx.cx.tcx.normalize_erasing_late_bound_regions( + let from_sig = fx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &from_ty.fn_sig(fx.cx.tcx), + &from_ty.fn_sig(fx.tcx), ); - let to_sig = fx.cx.tcx.normalize_erasing_late_bound_regions( + let to_sig = fx.tcx.normalize_erasing_late_bound_regions( ParamEnv::reveal_all(), - &to_ty.fn_sig(fx.cx.tcx), + &to_ty.fn_sig(fx.tcx), ); assert_eq!( from_sig, to_sig, @@ -436,10 +436,10 @@ impl<'tcx> CPlace<'tcx> { } (ty::Dynamic(from_traits, _), ty::Dynamic(to_traits, _)) => { let from_traits = fx - .cx.tcx + .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), from_traits); let to_traits = fx - .cx.tcx + .tcx .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), to_traits); assert_eq!( from_traits, to_traits, @@ -569,7 +569,7 @@ impl<'tcx> CPlace<'tcx> { } Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let (value, extra) = from.load_scalar_pair(fx); - let b_offset = scalar_pair_calculate_b_offset(fx.cx.tcx, a_scalar, b_scalar); + let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); to_ptr.store(fx, value, MemFlags::new()); to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); return; @@ -673,7 +673,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); - if has_ptr_meta(fx.cx.tcx, inner_layout.ty) { + if has_ptr_meta(fx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); CPlace::for_ptr_with_extra(Pointer::new(addr), extra, inner_layout) } else { @@ -682,7 +682,7 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { - if has_ptr_meta(fx.cx.tcx, self.layout().ty) { + if has_ptr_meta(fx.tcx, self.layout().ty) { let (ptr, extra) = self.to_ptr_maybe_unsized(); let ptr = CValue::by_val_pair( ptr.get_addr(fx), diff --git a/src/vtable.rs b/src/vtable.rs index 8163d15836c37..686d23c5d4be7 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -13,9 +13,9 @@ fn vtable_memflags() -> MemFlags { } pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.cx.tcx), + pointer_ty(fx.tcx), vtable_memflags(), vtable, (DROP_FN_INDEX * usize_size) as i32, @@ -23,9 +23,9 @@ pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: } pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.cx.tcx), + pointer_ty(fx.tcx), vtable_memflags(), vtable, (SIZE_INDEX * usize_size) as i32, @@ -33,9 +33,9 @@ pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Val } pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { - let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( - pointer_ty(fx.cx.tcx), + pointer_ty(fx.tcx), vtable_memflags(), vtable, (ALIGN_INDEX * usize_size) as i32, @@ -57,9 +57,9 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( ) }; - let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes(); + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); let func_ref = fx.bcx.ins().load( - pointer_ty(fx.cx.tcx), + pointer_ty(fx.tcx), vtable_memflags(), vtable, ((idx + 3) * usize_size as usize) as i32, @@ -89,11 +89,11 @@ fn build_vtable<'tcx>( layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> DataId { - let tcx = fx.cx.tcx; - let usize_size = fx.layout_of(fx.cx.tcx.types.usize).size.bytes() as usize; + let tcx = fx.tcx; + let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; let drop_in_place_fn = - import_function(tcx, &mut fx.cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.cx.tcx)); + import_function(tcx, &mut fx.cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.tcx)); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -109,7 +109,7 @@ fn build_vtable<'tcx>( Some(import_function( tcx, &mut fx.cx.module, - Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.cx.tcx), + Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.tcx), )) }) }); @@ -121,8 +121,8 @@ fn build_vtable<'tcx>( .collect::>() .into_boxed_slice(); - write_usize(fx.cx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); - write_usize(fx.cx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); + write_usize(fx.tcx, &mut data, SIZE_INDEX, layout.size.bytes()); + write_usize(fx.tcx, &mut data, ALIGN_INDEX, layout.align.abi.bytes()); data_ctx.define(data); for (i, component) in components.into_iter().enumerate() { @@ -148,7 +148,7 @@ fn build_vtable<'tcx>( false, false, Some( - fx.cx.tcx + fx.tcx .data_layout .pointer_align .pref From d65e500394640a042e03abe47c511e7d0049f523 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 18:53:34 +0200 Subject: [PATCH 1476/1566] FunctionCx: Swap context.func and empty function correctly --- src/base.rs | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/base.rs b/src/base.rs index 27afe8bb4aa86..bbf5031660b7e 100644 --- a/src/base.rs +++ b/src/base.rs @@ -16,8 +16,16 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); + // Make the FunctionBuilder let mut func_ctx = FunctionBuilderContext::new(); + cx.cached_context.clear(); + let mut func = Function::new(); + std::mem::swap(&mut cx.cached_context.func, &mut func); + func.name = ExternalName::user(0, func_id.as_u32()); + func.signature = sig; + func.collect_debug_info(); + let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); // Predefine blocks @@ -62,13 +70,6 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( }); } - // Make FunctionBuilder - let context = &mut fx.cx.cached_context; - context.clear(); - context.func.name = ExternalName::user(0, func_id.as_u32()); - context.func.signature = sig; - context.func.collect_debug_info(); - // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; let mut clif_comments = fx.clif_comments; @@ -76,8 +77,12 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let local_map = fx.local_map; let cold_blocks = fx.cold_blocks; + // Store function in context + let context = &mut cx.cached_context; + context.func = func; + crate::pretty_clif::write_clif_file( - fx.tcx, + tcx, "unopt", None, instance, @@ -97,10 +102,10 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // instruction, which doesn't have an encoding. context.compute_cfg(); context.compute_domtree(); - context.eliminate_unreachable_code(fx.cx.module.isa()).unwrap(); + context.eliminate_unreachable_code(cx.module.isa()).unwrap(); // Define function - let module = &mut fx.cx.module; + let module = &mut cx.module; tcx.sess.time( "define function", || module.define_function( @@ -112,18 +117,18 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Write optimized function to file for debugging crate::pretty_clif::write_clif_file( - fx.tcx, + tcx, "opt", - Some(fx.cx.module.isa()), + Some(cx.module.isa()), instance, &context, &clif_comments, ); // Define debuginfo for function - let isa = fx.cx.module.isa(); - let debug_context = &mut fx.cx.debug_context; - let unwind_context = &mut fx.cx.unwind_context; + let isa = cx.module.isa(); + let debug_context = &mut cx.debug_context; + let unwind_context = &mut cx.unwind_context; tcx.sess.time("generate debug info", || { if let Some(debug_context) = debug_context { debug_context.define_function(instance, func_id, &name, isa, context, &source_info_set, local_map); From 05797b2476401d53b724286f5ad4e28cd08c816f Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 19:03:35 +0200 Subject: [PATCH 1477/1566] trans_fn: Use replace() instead of new() + swap() --- src/base.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index bbf5031660b7e..86ba6ab114d1c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -20,8 +20,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let mut func_ctx = FunctionBuilderContext::new(); cx.cached_context.clear(); - let mut func = Function::new(); - std::mem::swap(&mut cx.cached_context.func, &mut func); + let mut func = std::mem::replace(&mut cx.cached_context.func, Function::new()); func.name = ExternalName::user(0, func_id.as_u32()); func.signature = sig; func.collect_debug_info(); From 7b994595da74e1855a58395da4ad2f7a169c8f34 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sat, 22 Aug 2020 19:05:22 +0200 Subject: [PATCH 1478/1566] trans_fn: Cleanup code --- src/base.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 86ba6ab114d1c..42068dde05d95 100644 --- a/src/base.rs +++ b/src/base.rs @@ -16,10 +16,10 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let (name, sig) = get_function_name_and_sig(tcx, cx.module.isa().triple(), instance, false); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); - // Make the FunctionBuilder - let mut func_ctx = FunctionBuilderContext::new(); cx.cached_context.clear(); + // Make the FunctionBuilder + let mut func_ctx = FunctionBuilderContext::new(); let mut func = std::mem::replace(&mut cx.cached_context.func, Function::new()); func.name = ExternalName::user(0, func_id.as_u32()); func.signature = sig; From 18348b1aec3d2705232fb6f7be862625384b0bf9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 23 Aug 2020 11:36:28 +0200 Subject: [PATCH 1479/1566] Rustup to rustc 1.47.0-nightly (663d2f5cd 2020-08-22) --- patches/0022-core-Disable-not-compiling-tests.patch | 2 +- patches/0023-core-Ignore-failing-tests.patch | 13 +++++++++++++ rust-toolchain | 2 +- src/base.rs | 1 + src/constant.rs | 4 ++-- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch index 213b7bb5f29d3..009b2fed0f93a 100644 --- a/patches/0022-core-Disable-not-compiling-tests.patch +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -98,7 +98,7 @@ index 1a6be3a..42dbd59 100644 +*/ #[test] - #[cfg_attr(miri, ignore)] // Miri does not compute a maximal `mid` for `align_offset` + fn align_offset_zst() { diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 6609bc3..241b497 100644 --- a/library/core/tests/slice.rs diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index 8104b8d767a11..ff8cece212cc5 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -30,6 +30,19 @@ index 4bc44e9..8e3c7a4 100644 #[test] fn empty_array_is_always_default() { +@@ -304,6 +304,7 @@ fn array_map() { + assert_eq!(b, [1, 2, 3]); + } + ++/* + // See note on above test for why `should_panic` is used. + #[test] + #[should_panic(expected = "test succeeded")] +@@ -332,3 +333,4 @@ fn array_map_drop_safety() { + assert_eq!(DROPPED.load(Ordering::SeqCst), num_to_create); + panic!("test succeeded") + } ++*/ diff --git a/library/core/tests/num/mod.rs b/library/core/tests/num/mod.rs index a17c094..5bb11d2 100644 --- a/library/core/tests/num/mod.rs diff --git a/rust-toolchain b/rust-toolchain index 79144d2eda64b..e3f84f1ce4d6b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-08-09 +nightly-2020-08-23 diff --git a/src/base.rs b/src/base.rs index 42068dde05d95..b83b09baa2bb6 100644 --- a/src/base.rs +++ b/src/base.rs @@ -760,6 +760,7 @@ fn trans_stmt<'tcx>( _ => fx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), } } + StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"), } } diff --git a/src/constant.rs b/src/constant.rs index 8b0d3b913cb01..933694b8292bc 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -364,7 +364,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu data_ctx.set_segment_section("", &*section_name); } - let bytes = alloc.inspect_with_undef_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); + let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); data_ctx.define(bytes.into_boxed_slice()); for &(offset, (_tag, reloc)) in alloc.relocations().iter() { @@ -372,7 +372,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let endianness = tcx.data_layout.endian; let offset = offset.bytes() as usize; let ptr_size = tcx.data_layout.pointer_size; - let bytes = &alloc.inspect_with_undef_and_ptr_outside_interpreter(offset..offset + ptr_size.bytes() as usize); + let bytes = &alloc.inspect_with_uninit_and_ptr_outside_interpreter(offset..offset + ptr_size.bytes() as usize); read_target_uint(endianness, bytes).unwrap() }; From c62f433e46c8f3b122857021acb448e9b8fb7972 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 15:00:09 +0200 Subject: [PATCH 1480/1566] remove_unused_stack_addr_and_stack_load: Remove clone() --- src/optimize/stack2reg.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index d6a9d6228c42a..cb68f1ccaf2d5 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -315,14 +315,13 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // Replace all unused stack_addr and stack_load instructions with nop. for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { - // FIXME remove clone - for &inst in stack_slot_users.stack_addr.clone().iter() { + while let Some(&inst) = stack_slot_users.stack_addr.iter().next() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { stack_slot_users.remove_unused_stack_addr(&mut opt_ctx.ctx.func, inst); } } - for &inst in stack_slot_users.stack_load.clone().iter() { + while let Some(&inst) = stack_slot_users.stack_load.iter().next() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { stack_slot_users.remove_unused_load(&mut opt_ctx.ctx.func, inst); } From 80ee042a36fd2cbdefc1b1ac09a930976d118a83 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 17:31:07 +0200 Subject: [PATCH 1481/1566] stack2reg: Re-add clone() to stop CI --- src/optimize/stack2reg.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index cb68f1ccaf2d5..444a006f19259 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -315,13 +315,14 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // Replace all unused stack_addr and stack_load instructions with nop. for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { - while let Some(&inst) = stack_slot_users.stack_addr.iter().next() { + // FIXME: Remove clone + for &inst in stack_slot_users.stack_addr.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { stack_slot_users.remove_unused_stack_addr(&mut opt_ctx.ctx.func, inst); } } - while let Some(&inst) = stack_slot_users.stack_load.iter().next() { + for &inst in stack_slot_users.stack_load.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { stack_slot_users.remove_unused_load(&mut opt_ctx.ctx.func, inst); } From b0ea85fb837ab62cd032e18d1429f7b9e2f05726 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 17:55:35 +0200 Subject: [PATCH 1482/1566] stack2reg: Remove self in remove_unused_stack_addr and() remove_unused_load() --- src/optimize/stack2reg.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 444a006f19259..2c8fe37a84f05 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -79,16 +79,14 @@ impl StackSlotUsage { }).collect::>() } - fn remove_unused_stack_addr(&mut self, func: &mut Function, inst: Inst) { + fn remove_unused_stack_addr(func: &mut Function, inst: Inst) { func.dfg.detach_results(inst); func.dfg.replace(inst).nop(); - self.stack_addr.remove(&inst); } - fn remove_unused_load(&mut self, func: &mut Function, load: Inst) { + fn remove_unused_load(func: &mut Function, load: Inst) { func.dfg.detach_results(load); func.dfg.replace(load).nop(); - self.stack_load.remove(&load); } fn remove_dead_store(&mut self, func: &mut Function, store: Inst) { @@ -315,18 +313,21 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // Replace all unused stack_addr and stack_load instructions with nop. for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { - // FIXME: Remove clone for &inst in stack_slot_users.stack_addr.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - stack_slot_users.remove_unused_stack_addr(&mut opt_ctx.ctx.func, inst); + StackSlotUsage::remove_unused_stack_addr(&mut opt_ctx.ctx.func, inst); + stack_slot_users.stack_addr.remove(&inst); } } + /* for &inst in stack_slot_users.stack_load.clone().iter() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - stack_slot_users.remove_unused_load(&mut opt_ctx.ctx.func, inst); + StackSlotUsage::remove_unused_load(&mut opt_ctx.ctx.func, inst); + stack_slot_users.stack_load.remove(&inst); } } + */ } } From eb6df58cdde7c4a83d960ba2e75f5c7421c94689 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 18:16:36 +0200 Subject: [PATCH 1483/1566] stack2reg: Remove clone() using filters --- src/optimize/stack2reg.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 2c8fe37a84f05..72762f563d3c3 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -312,22 +312,19 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { } // Replace all unused stack_addr and stack_load instructions with nop. + let mut func = &mut opt_ctx.ctx.func; for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { - for &inst in stack_slot_users.stack_addr.clone().iter() { - if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - StackSlotUsage::remove_unused_stack_addr(&mut opt_ctx.ctx.func, inst); - stack_slot_users.stack_addr.remove(&inst); - } - } - - /* - for &inst in stack_slot_users.stack_load.clone().iter() { - if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { - StackSlotUsage::remove_unused_load(&mut opt_ctx.ctx.func, inst); - stack_slot_users.stack_load.remove(&inst); - } - } - */ + stack_slot_users + .stack_addr + .iter() + .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) + .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, *inst)); + + stack_slot_users + .stack_load + .iter() + .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) + .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, *inst)); } } From 5c8c75b1d2a1fd8146daf71a3ef05acdca406d0b Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 18:36:42 +0200 Subject: [PATCH 1484/1566] stack2reg: Drain instead of only iterating --- src/optimize/stack2reg.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 72762f563d3c3..d1826a9af7221 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -316,15 +316,15 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { stack_slot_users .stack_addr - .iter() + .drain() .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) - .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, *inst)); + .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, inst)); stack_slot_users .stack_load - .iter() + .drain() .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) - .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, *inst)); + .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, inst)); } } From cb386896ee4df8f76758737044abe9300d6f8802 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 21:44:00 +0200 Subject: [PATCH 1485/1566] stack2reg: Switch to hashbrown::HashSet --- Cargo.lock | 8 ++++++++ Cargo.toml | 1 + src/optimize/stack2reg.rs | 21 +++++++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77d1fd0b40578..b072d9bd8c2ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,11 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "ahash" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" + [[package]] name = "anyhow" version = "1.0.32" @@ -197,6 +203,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" dependencies = [ + "ahash", "autocfg", ] @@ -325,6 +332,7 @@ dependencies = [ "cranelift-object", "cranelift-simplejit", "gimli", + "hashbrown", "indexmap", "libloading", "object", diff --git a/Cargo.toml b/Cargo.toml index e178e29925b03..858a0f0e33e3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ byteorder = "1.2.7" indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } +hashbrown = "0.8.1" # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/wasmtime/"] diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index d1826a9af7221..aceced41f2703 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -13,12 +13,15 @@ use std::collections::BTreeMap; use std::fmt; use std::ops::Not; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashSet, FxHasher}; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; +use hashbrown::HashSet; +use std::hash::BuildHasherDefault; + use crate::prelude::*; /// Workaround for `StackSlot` not implementing `Ord`. @@ -45,9 +48,9 @@ impl Ord for OrdStackSlot { #[derive(Debug, Default)] struct StackSlotUsage { - stack_addr: FxHashSet, - stack_load: FxHashSet, - stack_store: FxHashSet, + stack_addr: HashSet>, + stack_load: HashSet>, + stack_store: HashSet>, } impl StackSlotUsage { @@ -313,17 +316,19 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // Replace all unused stack_addr and stack_load instructions with nop. let mut func = &mut opt_ctx.ctx.func; + + // drain_filter() on hashbrown::HashSet drains the items that do *not* match the + // predicate. Once hashbrown gets updated to match the behaviour of std::drain_filter + // (0.8.2), the predicate will have to be reversed for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { stack_slot_users .stack_addr - .drain() - .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) + .drain_filter(|inst| !(stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))) .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, inst)); stack_slot_users .stack_load - .drain() - .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) + .drain_filter(|inst| !(stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))) .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, inst)); } } From 5dec38e94c0c9948ba578ae83ab94ecf4a0edb0a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 25 Aug 2020 18:31:59 +0200 Subject: [PATCH 1486/1566] Avoid temporary stack slot in drop codegen cc #322 --- src/abi/mod.rs | 19 +++++++------------ src/base.rs | 3 ++- src/value_and_place.rs | 16 +++++++++------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 6007c83787f4b..1d1aec3f91de4 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -700,18 +700,13 @@ pub(crate) fn codegen_drop<'tcx>( _ => { assert!(!matches!(drop_fn.def, InstanceDef::Virtual(_, _))); - let arg_place = CPlace::new_stack_slot( - fx, - fx.layout_of(fx.tcx.mk_ref( - &ty::RegionKind::ReErased, - TypeAndMut { - ty, - mutbl: crate::rustc_hir::Mutability::Mut, - }, - )), - ); - drop_place.write_place_ref(fx, arg_place); - let arg_value = arg_place.to_cvalue(fx); + let arg_value = drop_place.place_ref(fx, fx.layout_of(fx.tcx.mk_ref( + &ty::RegionKind::ReErased, + TypeAndMut { + ty, + mutbl: crate::rustc_hir::Mutability::Mut, + }, + ))); let arg_value = adjust_arg_for_abi(fx, arg_value); let mut call_args: Vec = arg_value.into_iter().collect::>(); diff --git a/src/base.rs b/src/base.rs index b83b09baa2bb6..2179c637e3a95 100644 --- a/src/base.rs +++ b/src/base.rs @@ -405,7 +405,8 @@ fn trans_stmt<'tcx>( } Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { let place = trans_place(fx, *place); - place.write_place_ref(fx, lval); + let ref_ = place.place_ref(fx, lval.layout()); + lval.write_cvalue(fx, ref_); } Rvalue::ThreadLocalRef(def_id) => { let val = crate::constant::codegen_tls_ref(fx, *def_id, lval.layout()); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 4b03860c17a9d..a48cc6600b4a6 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -681,18 +681,20 @@ impl<'tcx> CPlace<'tcx> { } } - pub(crate) fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + pub(crate) fn place_ref( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + layout: TyAndLayout<'tcx>, + ) -> CValue<'tcx> { if has_ptr_meta(fx.tcx, self.layout().ty) { let (ptr, extra) = self.to_ptr_maybe_unsized(); - let ptr = CValue::by_val_pair( + CValue::by_val_pair( ptr.get_addr(fx), extra.expect("unsized type without metadata"), - dest.layout(), - ); - dest.write_cvalue(fx, ptr); + layout, + ) } else { - let ptr = CValue::by_val(self.to_ptr().get_addr(fx), dest.layout()); - dest.write_cvalue(fx, ptr); + CValue::by_val(self.to_ptr().get_addr(fx), layout) } } From 4e685a512e66dfc5f66f49bc921cd77e1c9ab44a Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Fri, 28 Aug 2020 12:10:48 +0200 Subject: [PATCH 1487/1566] fmt: Run cargo fmt since it is available --- src/abi/comments.rs | 32 +++-- src/abi/mod.rs | 122 ++++++++++------ src/abi/pass_mode.rs | 37 ++--- src/abi/returning.rs | 15 +- src/allocator.rs | 12 +- src/analyze.rs | 28 ++-- src/archive.rs | 105 ++++++++------ src/atomic_shim.rs | 171 ++++++++++++++-------- src/backend.rs | 79 ++++++---- src/base.rs | 240 ++++++++++++++++++++----------- src/codegen_i128.rs | 2 +- src/common.rs | 60 +++++--- src/constant.rs | 138 +++++++++++++----- src/debuginfo/emit.rs | 4 +- src/debuginfo/line_info.rs | 54 +++---- src/debuginfo/mod.rs | 123 ++++++++++------ src/debuginfo/unwind.rs | 29 ++-- src/discriminant.rs | 2 +- src/driver/aot.rs | 180 ++++++++++++++--------- src/driver/jit.rs | 24 +++- src/driver/mod.rs | 32 ++++- src/inline_asm.rs | 115 ++++++++++++--- src/intrinsics/cpuid.rs | 53 +++++-- src/intrinsics/mod.rs | 28 ++-- src/intrinsics/simd.rs | 2 +- src/lib.rs | 63 +++++--- src/linkage.rs | 6 +- src/main_shim.rs | 11 +- src/metadata.rs | 13 +- src/num.rs | 53 +++++-- src/optimize/code_layout.rs | 10 +- src/optimize/mod.rs | 3 +- src/optimize/stack2reg.rs | 213 +++++++++++++++++++-------- src/pointer.rs | 56 +++++--- src/pretty_clif.rs | 10 +- src/target_features_whitelist.rs | 6 +- src/toolchain.rs | 22 ++- src/trap.rs | 3 +- src/value_and_place.rs | 196 ++++++++++++++++--------- src/vtable.rs | 19 +-- 40 files changed, 1575 insertions(+), 796 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 357c28c832a95..5d1a6c6ade50c 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -80,7 +80,10 @@ pub(super) fn add_local_place_comments<'tcx>( } CPlaceInner::VarPair(place_local, var1, var2) => { assert_eq!(local, place_local); - ("ssa", Cow::Owned(format!(",var=({}, {})", var1.index(), var2.index()))) + ( + "ssa", + Cow::Owned(format!(",var=({}, {})", var1.index(), var2.index())), + ) } CPlaceInner::VarLane(_local, _var, _lane) => unreachable!(), CPlaceInner::Addr(ptr, meta) => { @@ -90,15 +93,18 @@ pub(super) fn add_local_place_comments<'tcx>( Cow::Borrowed("") }; match ptr.base_and_offset() { - (crate::pointer::PointerBase::Addr(addr), offset) => { - ("reuse", format!("storage={}{}{}", addr, offset, meta).into()) - } - (crate::pointer::PointerBase::Stack(stack_slot), offset) => { - ("stack", format!("storage={}{}{}", stack_slot, offset, meta).into()) - } - (crate::pointer::PointerBase::Dangling(align), offset) => { - ("zst", format!("align={},offset={}", align.bytes(), offset).into()) - } + (crate::pointer::PointerBase::Addr(addr), offset) => ( + "reuse", + format!("storage={}{}{}", addr, offset, meta).into(), + ), + (crate::pointer::PointerBase::Stack(stack_slot), offset) => ( + "stack", + format!("storage={}{}{}", stack_slot, offset, meta).into(), + ), + (crate::pointer::PointerBase::Dangling(align), offset) => ( + "zst", + format!("align={},offset={}", align.bytes(), offset).into(), + ), } } }; @@ -111,7 +117,11 @@ pub(super) fn add_local_place_comments<'tcx>( size.bytes(), align.abi.bytes(), align.pref.bytes(), - if extra.is_empty() { "" } else { " " }, + if extra.is_empty() { + "" + } else { + " " + }, extra, )); } diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 1d1aec3f91de4..c09c70175e503 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -3,8 +3,8 @@ mod comments; mod pass_mode; mod returning; -use rustc_target::spec::abi::Abi; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; +use rustc_target::spec::abi::Abi; use cranelift_codegen::ir::{AbiParam, ArgumentPurpose}; @@ -14,7 +14,10 @@ use crate::prelude::*; pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return}; // Copied from https://github.com/rust-lang/rust/blob/f52c72948aa1dd718cc1f168d21c91c584c0a662/src/librustc_middle/ty/layout.rs#L2301 -pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { +pub(crate) fn fn_sig_for_fn_abi<'tcx>( + tcx: TyCtxt<'tcx>, + instance: Instance<'tcx>, +) -> ty::PolyFnSig<'tcx> { use rustc_middle::ty::subst::Subst; // FIXME(davidtwco,eddyb): A `ParamEnv` should be passed through to this function. @@ -70,10 +73,10 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx let env_ty = tcx.mk_adt(pin_adt_ref, pin_substs); sig.map_bound(|sig| { - let state_did = tcx.require_lang_item(rustc_hir::LangItem::GeneratorStateLangItem, None); + let state_did = + tcx.require_lang_item(rustc_hir::LangItem::GeneratorStateLangItem, None); let state_adt_ref = tcx.adt_def(state_did); - let state_substs = - tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]); + let state_substs = tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); tcx.mk_fn_sig( @@ -102,8 +105,16 @@ fn clif_sig_from_fn_sig<'tcx>( abi => abi, }; let (call_conv, inputs, output): (CallConv, Vec>, Ty<'tcx>) = match abi { - Abi::Rust => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), - Abi::C | Abi::Unadjusted => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), + Abi::Rust => ( + CallConv::triple_default(triple), + sig.inputs().to_vec(), + sig.output(), + ), + Abi::C | Abi::Unadjusted => ( + CallConv::triple_default(triple), + sig.inputs().to_vec(), + sig.output(), + ), Abi::SysV64 => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); @@ -116,7 +127,11 @@ fn clif_sig_from_fn_sig<'tcx>( (CallConv::triple_default(triple), inputs, sig.output()) } Abi::System => unreachable!(), - Abi::RustIntrinsic => (CallConv::triple_default(triple), sig.inputs().to_vec(), sig.output()), + Abi::RustIntrinsic => ( + CallConv::triple_default(triple), + sig.inputs().to_vec(), + sig.output(), + ), _ => unimplemented!("unsupported abi {:?}", sig.abi), }; @@ -163,10 +178,7 @@ fn clif_sig_from_fn_sig<'tcx>( tcx.layout_of(ParamEnv::reveal_all().and(output)).unwrap(), ) { PassMode::NoPass => (inputs.collect(), vec![]), - PassMode::ByVal(ret_ty) => ( - inputs.collect(), - vec![AbiParam::new(ret_ty)], - ), + PassMode::ByVal(ret_ty) => (inputs.collect(), vec![AbiParam::new(ret_ty)]), PassMode::ByValPair(ret_ty_a, ret_ty_b) => ( inputs.collect(), vec![AbiParam::new(ret_ty_a), AbiParam::new(ret_ty_b)], @@ -202,12 +214,24 @@ pub(crate) fn get_function_name_and_sig<'tcx>( support_vararg: bool, ) -> (String, Signature) { assert!(!inst.substs.needs_infer()); - let fn_sig = - tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_sig_for_fn_abi(tcx, inst)); + let fn_sig = tcx.normalize_erasing_late_bound_regions( + ParamEnv::reveal_all(), + &fn_sig_for_fn_abi(tcx, inst), + ); if fn_sig.c_variadic && !support_vararg { - tcx.sess.span_fatal(tcx.def_span(inst.def_id()), "Variadic function definitions are not yet supported"); + tcx.sess.span_fatal( + tcx.def_span(inst.def_id()), + "Variadic function definitions are not yet supported", + ); } - let sig = clif_sig_from_fn_sig(tcx, triple, fn_sig, tcx.def_span(inst.def_id()), false, inst.def.requires_caller_location(tcx)); + let sig = clif_sig_from_fn_sig( + tcx, + triple, + fn_sig, + tcx.def_span(inst.def_id()), + false, + inst.def.requires_caller_location(tcx), + ); (tcx.symbol_name(inst).name.to_string(), sig) } @@ -228,7 +252,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { let func_id = import_function(self.tcx, &mut self.cx.module, inst); let func_ref = self - .cx.module + .cx + .module .declare_func_in_func(func_id, &mut self.bcx.func); #[cfg(debug_assertions)] @@ -250,11 +275,13 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { call_conv: CallConv::triple_default(self.triple()), }; let func_id = self - .cx.module + .cx + .module .declare_function(&name, Linkage::Import, &sig) .unwrap(); let func_ref = self - .cx.module + .cx + .module .declare_func_in_func(func_id, &mut self.bcx.func); let call_inst = self.bcx.ins().call(func_ref, args); #[cfg(debug_assertions)] @@ -376,7 +403,9 @@ pub(crate) fn codegen_fn_prelude<'tcx>( assert!(fx.caller_location.is_none()); if fx.instance.def.requires_caller_location(fx.tcx) { // Store caller location for `#[track_caller]`. - fx.caller_location = Some(cvalue_for_param(fx, start_block, None, None, fx.tcx.caller_location_ty()).unwrap()); + fx.caller_location = Some( + cvalue_for_param(fx, start_block, None, None, fx.tcx.caller_location_ty()).unwrap(), + ); } fx.bcx.switch_to_block(start_block); @@ -502,17 +531,20 @@ pub(crate) fn codegen_terminator_call<'tcx>( fx.bcx.ins().jump(ret_block, &[]); return; } - _ => Some(instance) + _ => Some(instance), } } else { None }; - let is_cold = - instance.map(|inst| - fx.tcx.codegen_fn_attrs(inst.def_id()) - .flags.contains(CodegenFnAttrFlags::COLD)) - .unwrap_or(false); + let is_cold = instance + .map(|inst| { + fx.tcx + .codegen_fn_attrs(inst.def_id()) + .flags + .contains(CodegenFnAttrFlags::COLD) + }) + .unwrap_or(false); if is_cold { fx.cold_blocks.insert(current_block); } @@ -524,9 +556,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let pack_arg = trans_operand(fx, &args[1]); let tupled_arguments = match pack_arg.layout().ty.kind { - ty::Tuple(ref tupled_arguments) => { - tupled_arguments - } + ty::Tuple(ref tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; @@ -582,8 +612,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let nop_inst = fx.bcx.ins().nop(); fx.add_comment(nop_inst, "indirect call"); } - let func = trans_operand(fx, func) - .load_scalar(fx); + let func = trans_operand(fx, func).load_scalar(fx); ( Some(func), args.get(0) @@ -608,7 +637,10 @@ pub(crate) fn codegen_terminator_call<'tcx>( ) .collect::>(); - if instance.map(|inst| inst.def.requires_caller_location(fx.tcx)).unwrap_or(false) { + if instance + .map(|inst| inst.def.requires_caller_location(fx.tcx)) + .unwrap_or(false) + { // Pass the caller location for `#[track_caller]`. let caller_location = fx.get_caller_location(span); call_args.extend(adjust_arg_for_abi(fx, caller_location).into_iter()); @@ -637,7 +669,10 @@ pub(crate) fn codegen_terminator_call<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic { if fn_sig.abi != Abi::C { - fx.tcx.sess.span_fatal(span, &format!("Variadic call for non-C abi {:?}", fn_sig.abi)); + fx.tcx.sess.span_fatal( + span, + &format!("Variadic call for non-C abi {:?}", fn_sig.abi), + ); } let sig_ref = fx.bcx.func.dfg.call_signature(call_inst).unwrap(); let abi_params = call_args @@ -646,7 +681,9 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - fx.tcx.sess.span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); + fx.tcx + .sess + .span_fatal(span, &format!("Non int ty {:?} for variadic call", ty)); } AbiParam::new(ty) }) @@ -700,13 +737,16 @@ pub(crate) fn codegen_drop<'tcx>( _ => { assert!(!matches!(drop_fn.def, InstanceDef::Virtual(_, _))); - let arg_value = drop_place.place_ref(fx, fx.layout_of(fx.tcx.mk_ref( - &ty::RegionKind::ReErased, - TypeAndMut { - ty, - mutbl: crate::rustc_hir::Mutability::Mut, - }, - ))); + let arg_value = drop_place.place_ref( + fx, + fx.layout_of(fx.tcx.mk_ref( + &ty::RegionKind::ReErased, + TypeAndMut { + ty, + mutbl: crate::rustc_hir::Mutability::Mut, + }, + )), + ); let arg_value = adjust_arg_for_abi(fx, arg_value); let mut call_args: Vec = arg_value.into_iter().collect::>(); diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 02604a3757201..49aaf22058d21 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -83,9 +83,7 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) } else { match &layout.abi { Abi::Uninhabited => PassMode::NoPass, - Abi::Scalar(scalar) => { - PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())) - } + Abi::Scalar(scalar) => PassMode::ByVal(scalar_to_clif_type(tcx, scalar.clone())), Abi::ScalarPair(a, b) => { let a = scalar_to_clif_type(tcx, a.clone()); let b = scalar_to_clif_type(tcx, b.clone()); @@ -93,7 +91,9 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) // Returning (i128, i128) by-val-pair would take 4 regs, while only 3 are // available on x86_64. Cranelift gets confused when too many return params // are used. - PassMode::ByRef { size: Some(layout.size) } + PassMode::ByRef { + size: Some(layout.size), + } } else { PassMode::ByValPair(a, b) } @@ -104,11 +104,15 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) if let Some(vector_ty) = crate::intrinsics::clif_vector_type(tcx, layout) { PassMode::ByVal(vector_ty) } else { - PassMode::ByRef { size: Some(layout.size) } + PassMode::ByRef { + size: Some(layout.size), + } } } - Abi::Aggregate { sized: true } => PassMode::ByRef { size: Some(layout.size) }, + Abi::Aggregate { sized: true } => PassMode::ByRef { + size: Some(layout.size), + }, Abi::Aggregate { sized: false } => PassMode::ByRef { size: None }, } } @@ -125,22 +129,18 @@ pub(super) fn adjust_arg_for_abi<'tcx>( let (a, b) = arg.load_scalar_pair(fx); Pair(a, b) } - PassMode::ByRef { size: _ } => { - match arg.force_stack(fx) { - (ptr, None) => Single(ptr.get_addr(fx)), - (ptr, Some(meta)) => Pair(ptr.get_addr(fx), meta), - } - } + PassMode::ByRef { size: _ } => match arg.force_stack(fx) { + (ptr, None) => Single(ptr.get_addr(fx)), + (ptr, Some(meta)) => Pair(ptr.get_addr(fx), meta), + }, } } pub(super) fn cvalue_for_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_block: Block, - #[cfg_attr(not(debug_assertions), allow(unused_variables))] - local: Option, - #[cfg_attr(not(debug_assertions), allow(unused_variables))] - local_field: Option, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] local: Option, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] local_field: Option, arg_ty: Ty<'tcx>, ) -> Option> { let layout = fx.layout_of(arg_ty); @@ -171,7 +171,10 @@ pub(super) fn cvalue_for_param<'tcx>( let (a, b) = block_params.assert_pair(); Some(CValue::by_val_pair(a, b, layout)) } - PassMode::ByRef { size: Some(_) } => Some(CValue::by_ref(Pointer::new(block_params.assert_single()), layout)), + PassMode::ByRef { size: Some(_) } => Some(CValue::by_ref( + Pointer::new(block_params.assert_single()), + layout, + )), PassMode::ByRef { size: None } => { let (ptr, meta) = block_params.assert_pair(); Some(CValue::by_ref_unsized(Pointer::new(ptr), meta, layout)) diff --git a/src/abi/returning.rs b/src/abi/returning.rs index e445a12b2a882..dfb16b5fe4ca3 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -5,11 +5,14 @@ fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyAnd fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty)) } -pub(crate) fn can_return_to_ssa_var<'tcx>(tcx: TyCtxt<'tcx>, dest_layout: TyAndLayout<'tcx>) -> bool { +pub(crate) fn can_return_to_ssa_var<'tcx>( + tcx: TyCtxt<'tcx>, + dest_layout: TyAndLayout<'tcx>, +) -> bool { match get_pass_mode(tcx, dest_layout) { PassMode::NoPass | PassMode::ByVal(_) => true, // FIXME Make it possible to return ByValPair and ByRef to an ssa var. - PassMode::ByValPair(_, _) | PassMode::ByRef { size: _ } => false + PassMode::ByValPair(_, _) | PassMode::ByRef { size: _ } => false, } } @@ -35,8 +38,10 @@ pub(super) fn codegen_return_param( } PassMode::ByRef { size: Some(_) } => { let ret_param = fx.bcx.append_block_param(start_block, fx.pointer_type); - fx.local_map - .insert(RETURN_PLACE, CPlace::for_ptr(Pointer::new(ret_param), ret_layout)); + fx.local_map.insert( + RETURN_PLACE, + CPlace::for_ptr(Pointer::new(ret_param), ret_layout), + ); Single(ret_param) } @@ -69,7 +74,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( let output_pass_mode = get_pass_mode(fx.tcx, ret_layout); let return_ptr = match output_pass_mode { PassMode::NoPass => None, - PassMode::ByRef { size: Some(_)} => match ret_place { + PassMode::ByRef { size: Some(_) } => match ret_place { Some(ret_place) => Some(ret_place.to_ptr().get_addr(fx)), None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)), // FIXME allocate temp stack slot }, diff --git a/src/allocator.rs b/src/allocator.rs index 8dae5dcf38591..894e47dd439ca 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -102,11 +102,13 @@ fn codegen_inner( bcx.seal_all_blocks(); bcx.finalize(); } - module.define_function( - func_id, - &mut ctx, - &mut cranelift_codegen::binemit::NullTrapSink {}, - ).unwrap(); + module + .define_function( + func_id, + &mut ctx, + &mut cranelift_codegen::binemit::NullTrapSink {}, + ) + .unwrap(); unwind_context.add_function(func_id, &ctx, module.isa()); } } diff --git a/src/analyze.rs b/src/analyze.rs index 7bd2c802868df..055b371f43c3c 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -1,7 +1,7 @@ use crate::prelude::*; -use rustc_middle::mir::StatementKind::*; use rustc_index::vec::IndexVec; +use rustc_middle::mir::StatementKind::*; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub(crate) enum SsaKind { @@ -10,20 +10,25 @@ pub(crate) enum SsaKind { } pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { - let mut flag_map = fx.mir.local_decls.iter().map(|local_decl| { - let ty = fx.monomorphize(&local_decl.ty); - if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() { - SsaKind::Ssa - } else { - SsaKind::NotSsa - } - }).collect::>(); + let mut flag_map = fx + .mir + .local_decls + .iter() + .map(|local_decl| { + let ty = fx.monomorphize(&local_decl.ty); + if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() { + SsaKind::Ssa + } else { + SsaKind::NotSsa + } + }) + .collect::>(); for bb in fx.mir.basic_blocks().iter() { for stmt in bb.statements.iter() { match &stmt.kind { Assign(place_and_rval) => match &place_and_rval.1 { - Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place)=> { + Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => { not_ssa(&mut flag_map, place.local) } _ => {} @@ -35,7 +40,8 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { if let Some((dest_place, _dest_bb)) = destination { - let dest_layout = fx.layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty)); + let dest_layout = fx + .layout_of(fx.monomorphize(&dest_place.ty(&fx.mir.local_decls, fx.tcx).ty)); if !crate::abi::can_return_to_ssa_var(fx.tcx, dest_layout) { not_ssa(&mut flag_map, dest_place.local) } diff --git a/src/archive.rs b/src/archive.rs index a34ede57e7991..60975c89af6fb 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -2,9 +2,9 @@ use std::collections::BTreeMap; use std::fs::File; use std::path::{Path, PathBuf}; -use rustc_session::Session; use rustc_codegen_ssa::back::archive::{find_library, ArchiveBuilder}; use rustc_codegen_ssa::METADATA_FILENAME; +use rustc_session::Session; use object::{Object, SymbolKind}; @@ -167,30 +167,45 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { entry.read_to_end(&mut data).unwrap(); data } - ArchiveEntry::File(file) => { - std::fs::read(file).unwrap_or_else(|err| { - sess.fatal(&format!("error while reading object file during archive building: {}", err)); - }) - } + ArchiveEntry::File(file) => std::fs::read(file).unwrap_or_else(|err| { + sess.fatal(&format!( + "error while reading object file during archive building: {}", + err + )); + }), }; if !self.no_builtin_ranlib { match object::File::parse(&data) { Ok(object) => { - symbol_table.insert(entry_name.as_bytes().to_vec(), object.symbols().filter_map(|(_index, symbol)| { - if symbol.is_undefined() || symbol.is_local() || symbol.kind() != SymbolKind::Data && symbol.kind() != SymbolKind::Text && symbol.kind() != SymbolKind::Tls { - None - } else { - symbol.name().map(|name| name.as_bytes().to_vec()) - } - }).collect::>()); + symbol_table.insert( + entry_name.as_bytes().to_vec(), + object + .symbols() + .filter_map(|(_index, symbol)| { + if symbol.is_undefined() + || symbol.is_local() + || symbol.kind() != SymbolKind::Data + && symbol.kind() != SymbolKind::Text + && symbol.kind() != SymbolKind::Tls + { + None + } else { + symbol.name().map(|name| name.as_bytes().to_vec()) + } + }) + .collect::>(), + ); } Err(err) => { let err = err.to_string(); if err == "Unknown file magic" { // Not an object file; skip it. } else { - sess.fatal(&format!("error parsing `{}` during archive creation: {}", entry_name, err)); + sess.fatal(&format!( + "error parsing `{}` during archive creation: {}", + entry_name, err + )); } } } @@ -200,36 +215,44 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } let mut builder = if self.use_gnu_style_archive { - BuilderKind::Gnu(ar::GnuBuilder::new( - File::create(&self.dst).unwrap_or_else(|err| { - sess.fatal(&format!("error opening destination during archive building: {}", err)); - }), - entries - .iter() - .map(|(name, _)| name.as_bytes().to_vec()) - .collect(), - ar::GnuSymbolTableFormat::Size32, - symbol_table, - ).unwrap()) + BuilderKind::Gnu( + ar::GnuBuilder::new( + File::create(&self.dst).unwrap_or_else(|err| { + sess.fatal(&format!( + "error opening destination during archive building: {}", + err + )); + }), + entries + .iter() + .map(|(name, _)| name.as_bytes().to_vec()) + .collect(), + ar::GnuSymbolTableFormat::Size32, + symbol_table, + ) + .unwrap(), + ) } else { - BuilderKind::Bsd(ar::Builder::new( - File::create(&self.dst).unwrap_or_else(|err| { - sess.fatal(&format!("error opening destination during archive building: {}", err)); - }), - symbol_table, - ).unwrap()) + BuilderKind::Bsd( + ar::Builder::new( + File::create(&self.dst).unwrap_or_else(|err| { + sess.fatal(&format!( + "error opening destination during archive building: {}", + err + )); + }), + symbol_table, + ) + .unwrap(), + ) }; // Add all files for (entry_name, data) in entries.into_iter() { let header = ar::Header::new(entry_name.into_bytes(), data.len() as u64); match builder { - BuilderKind::Bsd(ref mut builder) => builder - .append(&header, &mut &*data) - .unwrap(), - BuilderKind::Gnu(ref mut builder) => builder - .append(&header, &mut &*data) - .unwrap(), + BuilderKind::Bsd(ref mut builder) => builder.append(&header, &mut &*data).unwrap(), + BuilderKind::Gnu(ref mut builder) => builder.append(&header, &mut &*data).unwrap(), } } @@ -246,7 +269,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { .expect("Couldn't run ranlib"); if !status.success() { - self.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); + self.sess + .fatal(&format!("Ranlib exited with code {:?}", status.code())); } } } @@ -263,9 +287,8 @@ impl<'a> ArArchiveBuilder<'a> { let mut i = 0; while let Some(entry) = archive.next_entry() { let entry = entry?; - let file_name = String::from_utf8(entry.header().identifier().to_vec()).map_err(|err| { - std::io::Error::new(std::io::ErrorKind::InvalidData, err) - })?; + let file_name = String::from_utf8(entry.header().identifier().to_vec()) + .map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidData, err))?; if !skip(&file_name) { self.entries.push(( file_name, diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 2cacef77d1733..2f9f9e3a4f744 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -7,7 +7,8 @@ use crate::prelude::*; #[cfg(feature = "jit")] #[no_mangle] -pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; +pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = + libc::PTHREAD_MUTEX_INITIALIZER; pub(crate) fn init_global_lock(module: &mut Module, bcx: &mut FunctionBuilder<'_>) { if std::env::var("CG_CLIF_JIT").is_ok() { @@ -19,28 +20,42 @@ pub(crate) fn init_global_lock(module: &mut Module, bcx: &mut Func let mut data_ctx = DataContext::new(); data_ctx.define_zeroinit(1024); // 1024 bytes should be big enough on all platforms. - let atomic_mutex = module.declare_data( - "__cg_clif_global_atomic_mutex", - Linkage::Export, - true, - false, - Some(16), - ).unwrap(); + let atomic_mutex = module + .declare_data( + "__cg_clif_global_atomic_mutex", + Linkage::Export, + true, + false, + Some(16), + ) + .unwrap(); module.define_data(atomic_mutex, &data_ctx).unwrap(); - let pthread_mutex_init = module.declare_function("pthread_mutex_init", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: module.target_config().default_call_conv, - params: vec![ - AbiParam::new(module.target_config().pointer_type() /* *mut pthread_mutex_t */), - AbiParam::new(module.target_config().pointer_type() /* *const pthread_mutex_attr_t */), - ], - returns: vec![AbiParam::new(types::I32 /* c_int */)], - }).unwrap(); + let pthread_mutex_init = module + .declare_function( + "pthread_mutex_init", + Linkage::Import, + &cranelift_codegen::ir::Signature { + call_conv: module.target_config().default_call_conv, + params: vec![ + AbiParam::new( + module.target_config().pointer_type(), /* *mut pthread_mutex_t */ + ), + AbiParam::new( + module.target_config().pointer_type(), /* *const pthread_mutex_attr_t */ + ), + ], + returns: vec![AbiParam::new(types::I32 /* c_int */)], + }, + ) + .unwrap(); let pthread_mutex_init = module.declare_func_in_func(pthread_mutex_init, bcx.func); let atomic_mutex = module.declare_data_in_func(atomic_mutex, bcx.func); - let atomic_mutex = bcx.ins().global_value(module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = bcx + .ins() + .global_value(module.target_config().pointer_type(), atomic_mutex); let nullptr = bcx.ins().iconst(module.target_config().pointer_type(), 0); @@ -49,7 +64,7 @@ pub(crate) fn init_global_lock(module: &mut Module, bcx: &mut Func pub(crate) fn init_global_lock_constructor( module: &mut Module, - constructor_name: &str + constructor_name: &str, ) -> FuncId { let sig = Signature::new(CallConv::SystemV); let init_func_id = module @@ -71,61 +86,99 @@ pub(crate) fn init_global_lock_constructor( bcx.seal_all_blocks(); bcx.finalize(); } - module.define_function( - init_func_id, - &mut ctx, - &mut cranelift_codegen::binemit::NullTrapSink {}, - ).unwrap(); + module + .define_function( + init_func_id, + &mut ctx, + &mut cranelift_codegen::binemit::NullTrapSink {}, + ) + .unwrap(); init_func_id } pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fx.cx.module.declare_data( - "__cg_clif_global_atomic_mutex", - Linkage::Import, - true, - false, - None, - ).unwrap(); - - let pthread_mutex_lock = fx.cx.module.declare_function("pthread_mutex_lock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fx.cx.module.target_config().default_call_conv, - params: vec![ - AbiParam::new(fx.cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), - ], - returns: vec![AbiParam::new(types::I32 /* c_int */)], - }).unwrap(); - - let pthread_mutex_lock = fx.cx.module.declare_func_in_func(pthread_mutex_lock, fx.bcx.func); + let atomic_mutex = fx + .cx + .module + .declare_data( + "__cg_clif_global_atomic_mutex", + Linkage::Import, + true, + false, + None, + ) + .unwrap(); + + let pthread_mutex_lock = fx + .cx + .module + .declare_function( + "pthread_mutex_lock", + Linkage::Import, + &cranelift_codegen::ir::Signature { + call_conv: fx.cx.module.target_config().default_call_conv, + params: vec![AbiParam::new( + fx.cx.module.target_config().pointer_type(), /* *mut pthread_mutex_t */ + )], + returns: vec![AbiParam::new(types::I32 /* c_int */)], + }, + ) + .unwrap(); + + let pthread_mutex_lock = fx + .cx + .module + .declare_func_in_func(pthread_mutex_lock, fx.bcx.func); let atomic_mutex = fx.cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fx.cx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fx + .bcx + .ins() + .global_value(fx.cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_lock, &[atomic_mutex]); } pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { - let atomic_mutex = fx.cx.module.declare_data( - "__cg_clif_global_atomic_mutex", - Linkage::Import, - true, - false, - None, - ).unwrap(); - - let pthread_mutex_unlock = fx.cx.module.declare_function("pthread_mutex_unlock", Linkage::Import, &cranelift_codegen::ir::Signature { - call_conv: fx.cx.module.target_config().default_call_conv, - params: vec![ - AbiParam::new(fx.cx.module.target_config().pointer_type() /* *mut pthread_mutex_t */), - ], - returns: vec![AbiParam::new(types::I32 /* c_int */)], - }).unwrap(); - - let pthread_mutex_unlock = fx.cx.module.declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); + let atomic_mutex = fx + .cx + .module + .declare_data( + "__cg_clif_global_atomic_mutex", + Linkage::Import, + true, + false, + None, + ) + .unwrap(); + + let pthread_mutex_unlock = fx + .cx + .module + .declare_function( + "pthread_mutex_unlock", + Linkage::Import, + &cranelift_codegen::ir::Signature { + call_conv: fx.cx.module.target_config().default_call_conv, + params: vec![AbiParam::new( + fx.cx.module.target_config().pointer_type(), /* *mut pthread_mutex_t */ + )], + returns: vec![AbiParam::new(types::I32 /* c_int */)], + }, + ) + .unwrap(); + + let pthread_mutex_unlock = fx + .cx + .module + .declare_func_in_func(pthread_mutex_unlock, fx.bcx.func); let atomic_mutex = fx.cx.module.declare_data_in_func(atomic_mutex, fx.bcx.func); - let atomic_mutex = fx.bcx.ins().global_value(fx.cx.module.target_config().pointer_type(), atomic_mutex); + let atomic_mutex = fx + .bcx + .ins() + .global_value(fx.cx.module.target_config().pointer_type(), atomic_mutex); fx.bcx.ins().call(pthread_mutex_unlock, &[atomic_mutex]); } diff --git a/src/backend.rs b/src/backend.rs index 59b339eb57c05..0d654aed160ca 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -5,8 +5,8 @@ use rustc_session::Session; use cranelift_module::{FuncId, Module}; -use object::{SectionKind, SymbolFlags, RelocationKind, RelocationEncoding}; use object::write::*; +use object::{RelocationEncoding, RelocationKind, SectionKind, SymbolFlags}; use cranelift_object::{ObjectBackend, ObjectBuilder, ObjectProduct}; @@ -20,7 +20,9 @@ pub(crate) trait WriteMetadata { impl WriteMetadata for object::write::Object { fn add_rustc_section(&mut self, symbol_name: String, data: Vec, _is_like_osx: bool) { - let segment = self.segment_name(object::write::StandardSegment::Data).to_vec(); + let segment = self + .segment_name(object::write::StandardSegment::Data) + .to_vec(); let section_id = self.add_section(segment, b".rustc".to_vec(), object::SectionKind::Data); let offset = self.append_section_data(section_id, &data, 1); // For MachO and probably PE this is necessary to prevent the linker from throwing away the @@ -62,7 +64,8 @@ impl WriteDebugInfo for ObjectProduct { id.name().replace('.', "__") // machO expects __debug_info instead of .debug_info } else { id.name().to_string() - }.into_bytes(); + } + .into_bytes(); let segment = self.object.segment_name(StandardSegment::Debug).to_vec(); let section_id = self.object.add_section(segment, name, SectionKind::Debug); @@ -78,22 +81,27 @@ impl WriteDebugInfo for ObjectProduct { reloc: &DebugReloc, ) { let (symbol, symbol_offset) = match reloc.name { - DebugRelocName::Section(id) => { - (section_map.get(&id).unwrap().1, 0) - } + DebugRelocName::Section(id) => (section_map.get(&id).unwrap().1, 0), DebugRelocName::Symbol(id) => { let symbol_id = self.function_symbol(FuncId::from_u32(id.try_into().unwrap())); - self.object.symbol_section_and_offset(symbol_id).expect("Debug reloc for undef sym???") + self.object + .symbol_section_and_offset(symbol_id) + .expect("Debug reloc for undef sym???") } }; - self.object.add_relocation(from.0, Relocation { - offset: u64::from(reloc.offset), - symbol, - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, - size: reloc.size * 8, - addend: i64::try_from(symbol_offset).unwrap() + reloc.addend, - }).unwrap(); + self.object + .add_relocation( + from.0, + Relocation { + offset: u64::from(reloc.offset), + symbol, + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + size: reloc.size * 8, + addend: i64::try_from(symbol_offset).unwrap() + reloc.addend, + }, + ) + .unwrap(); } } @@ -105,21 +113,32 @@ pub(crate) trait AddConstructor { impl AddConstructor for ObjectProduct { fn add_constructor(&mut self, func_id: FuncId) { let symbol = self.function_symbol(func_id); - let segment = self.object.segment_name(object::write::StandardSegment::Data); - let init_array_section = self.object.add_section(segment.to_vec(), b".init_array".to_vec(), SectionKind::Data); + let segment = self + .object + .segment_name(object::write::StandardSegment::Data); + let init_array_section = + self.object + .add_section(segment.to_vec(), b".init_array".to_vec(), SectionKind::Data); self.object.append_section_data( init_array_section, - &std::iter::repeat(0).take(8 /*FIXME pointer size*/).collect::>(), + &std::iter::repeat(0) + .take(8 /*FIXME pointer size*/) + .collect::>(), 8, ); - self.object.add_relocation(init_array_section, object::write::Relocation { - offset: 0, - size: 64, // FIXME pointer size - kind: RelocationKind::Absolute, - encoding: RelocationEncoding::Generic, - symbol, - addend: 0, - }).unwrap(); + self.object + .add_relocation( + init_array_section, + object::write::Relocation { + offset: 0, + size: 64, // FIXME pointer size + kind: RelocationKind::Absolute, + encoding: RelocationEncoding::Generic, + symbol, + addend: 0, + }, + ) + .unwrap(); } } @@ -153,7 +172,7 @@ pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object architecture => sess.fatal(&format!( "target architecture {:?} is unsupported", architecture, - )) + )), }; let endian = match triple.endianness().unwrap() { target_lexicon::Endianness::Little => object::Endianness::Little, @@ -166,7 +185,8 @@ pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object metadata_object.write().unwrap() } -pub(crate) type Backend = impl cranelift_module::Backend; +pub(crate) type Backend = + impl cranelift_module::Backend; pub(crate) fn make_module(sess: &Session, name: String) -> Module { let module: Module = Module::new( @@ -174,7 +194,8 @@ pub(crate) fn make_module(sess: &Session, name: String) -> Module { crate::build_isa(sess, true), name + ".o", cranelift_module::default_libcall_names(), - ).unwrap(), + ) + .unwrap(), ); module } diff --git a/src/base.rs b/src/base.rs index 2179c637e3a95..342c12ffc4118 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,5 +1,5 @@ -use rustc_middle::ty::adjustment::PointerCast; use rustc_index::vec::IndexVec; +use rustc_middle::ty::adjustment::PointerCast; use crate::prelude::*; @@ -29,7 +29,9 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Predefine blocks let start_block = bcx.create_block(); - let block_map: IndexVec = (0..mir.basic_blocks().len()).map(|_| bcx.create_block()).collect(); + let block_map: IndexVec = (0..mir.basic_blocks().len()) + .map(|_| bcx.create_block()) + .collect(); // Make FunctionCx let pointer_type = cx.module.target_config().pointer_type(); @@ -56,15 +58,22 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( inline_asm_index: 0, }; - let arg_uninhabited = fx.mir.args_iter().any(|arg| fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)).abi.is_uninhabited()); + let arg_uninhabited = fx.mir.args_iter().any(|arg| { + fx.layout_of(fx.monomorphize(&fx.mir.local_decls[arg].ty)) + .abi + .is_uninhabited() + }); if arg_uninhabited { - fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]); + 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"); } else { tcx.sess.time("codegen clif ir", || { - tcx.sess.time("codegen prelude", || crate::abi::codegen_fn_prelude(&mut fx, start_block)); + tcx.sess.time("codegen prelude", || { + crate::abi::codegen_fn_prelude(&mut fx, start_block) + }); codegen_fn_content(&mut fx); }); } @@ -80,21 +89,20 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let context = &mut cx.cached_context; context.func = func; - crate::pretty_clif::write_clif_file( - tcx, - "unopt", - None, - instance, - &context, - &clif_comments, - ); + crate::pretty_clif::write_clif_file(tcx, "unopt", None, instance, &context, &clif_comments); // Verify function verify_func(tcx, &clif_comments, &context.func); // Perform rust specific optimizations tcx.sess.time("optimize clif ir", || { - crate::optimize::optimize_function(tcx, instance, context, &cold_blocks, &mut clif_comments); + crate::optimize::optimize_function( + tcx, + instance, + context, + &cold_blocks, + &mut clif_comments, + ); }); // If the return block is not reachable, then the SSA builder may have inserted a `iconst.i128` @@ -105,14 +113,15 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( // Define function let module = &mut cx.module; - tcx.sess.time( - "define function", - || module.define_function( - func_id, - context, - &mut cranelift_codegen::binemit::NullTrapSink {}, - ).unwrap(), - ); + tcx.sess.time("define function", || { + module + .define_function( + func_id, + context, + &mut cranelift_codegen::binemit::NullTrapSink {}, + ) + .unwrap() + }); // Write optimized function to file for debugging crate::pretty_clif::write_clif_file( @@ -130,7 +139,15 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( let unwind_context = &mut cx.unwind_context; tcx.sess.time("generate debug info", || { if let Some(debug_context) = debug_context { - debug_context.define_function(instance, func_id, &name, isa, context, &source_info_set, local_map); + debug_context.define_function( + instance, + func_id, + &name, + isa, + context, + &source_info_set, + local_map, + ); } unwind_context.add_function(func_id, &context, isa); }); @@ -139,7 +156,11 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( context.clear(); } -pub(crate) fn verify_func(tcx: TyCtxt<'_>, writer: &crate::pretty_clif::CommentWriter, func: &Function) { +pub(crate) fn verify_func( + tcx: TyCtxt<'_>, + writer: &crate::pretty_clif::CommentWriter, + func: &Function, +) { tcx.sess.time("verify clif ir", || { let flags = cranelift_codegen::settings::Flags::new(cranelift_codegen::settings::builder()); match cranelift_codegen::verify_function(&func, &flags) { @@ -249,7 +270,9 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.bcx.switch_to_block(failure); - let location = fx.get_caller_location(bb_data.terminator().source_info.span).load_scalar(fx); + let location = fx + .get_caller_location(bb_data.terminator().source_info.span) + .load_scalar(fx); let args; let lang_item = match msg { @@ -262,20 +285,30 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { _ => { let msg_str = msg.description(); let msg_ptr = fx.anonymous_str("assert", msg_str); - let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap()); + let msg_len = fx + .bcx + .ins() + .iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap()); args = [msg_ptr, msg_len, location]; rustc_hir::lang_items::PanicFnLangItem } }; let def_id = fx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { - fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, &s) + fx.tcx + .sess + .span_fatal(bb_data.terminator().source_info.span, &s) }); let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); let symbol_name = fx.tcx.symbol_name(instance).name; - fx.lib_call(&*symbol_name, vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], vec![], &args); + fx.lib_call( + &*symbol_name, + vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], + vec![], + &args, + ); crate::trap::trap_unreachable(fx, "panic lang item returned"); } @@ -303,14 +336,16 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { cleanup: _, from_hir_call: _, } => { - fx.tcx.sess.time("codegen call", || crate::abi::codegen_terminator_call( - fx, - *fn_span, - block, - func, - args, - *destination, - )); + fx.tcx.sess.time("codegen call", || { + crate::abi::codegen_terminator_call( + fx, + *fn_span, + block, + func, + args, + *destination, + ) + }); } TerminatorKind::InlineAsm { template, @@ -333,7 +368,10 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.bcx.ins().jump(destination_block, &[]); } None => { - crate::trap::trap_unreachable(fx, "[corruption] Returned from noreturn inline asm"); + crate::trap::trap_unreachable( + fx, + "[corruption] Returned from noreturn inline asm", + ); } } } @@ -370,8 +408,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fn trans_stmt<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, - #[allow(unused_variables)] - cur_block: Block, + #[allow(unused_variables)] cur_block: Block, stmt: &Statement<'tcx>, ) { let _print_guard = crate::PrintOnPanic(|| format!("stmt {:?}", stmt)); @@ -439,30 +476,24 @@ fn trans_stmt<'tcx>( let layout = operand.layout(); let val = operand.load_scalar(fx); let res = match un_op { - UnOp::Not => { - match layout.ty.kind { - ty::Bool => { - let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); - CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout) - } - ty::Uint(_) | ty::Int(_) => { - CValue::by_val(fx.bcx.ins().bnot(val), layout) - } - _ => unreachable!("un op Not for {:?}", layout.ty), + UnOp::Not => match layout.ty.kind { + ty::Bool => { + let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); + CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout) } - } + ty::Uint(_) | ty::Int(_) => { + CValue::by_val(fx.bcx.ins().bnot(val), layout) + } + _ => unreachable!("un op Not for {:?}", layout.ty), + }, UnOp::Neg => match layout.ty.kind { ty::Int(IntTy::I128) => { // FIXME remove this case once ineg.i128 works let zero = CValue::const_val(fx, layout, 0); crate::num::trans_int_binop(fx, BinOp::Sub, zero, operand) } - ty::Int(_) => { - CValue::by_val(fx.bcx.ins().ineg(val), layout) - } - ty::Float(_) => { - CValue::by_val(fx.bcx.ins().fneg(val), layout) - } + ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout), + ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout), _ => unreachable!("un op Neg for {:?}", layout.ty), }, }; @@ -474,9 +505,14 @@ fn trans_stmt<'tcx>( match from_ty.kind { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( - Instance::resolve_for_fn_ptr(fx.tcx, ParamEnv::reveal_all(), def_id, substs) - .unwrap() - .polymorphize(fx.tcx), + Instance::resolve_for_fn_ptr( + fx.tcx, + ParamEnv::reveal_all(), + def_id, + substs, + ) + .unwrap() + .polymorphize(fx.tcx), ); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, to_layout)); @@ -505,7 +541,9 @@ fn trans_stmt<'tcx>( |ty::TypeAndMut { ty: pointee_ty, mutbl: _, - }| has_ptr_meta(fx.tcx, pointee_ty), + }| { + has_ptr_meta(fx.tcx, pointee_ty) + }, ) .unwrap_or(false) } @@ -527,13 +565,20 @@ fn trans_stmt<'tcx>( _ => unreachable!("cast adt {} -> {}", from_ty, to_ty), } - use rustc_target::abi::{TagEncoding, Int, Variants}; + use rustc_target::abi::{Int, TagEncoding, Variants}; match &operand.layout().variants { Variants::Single { index } => { - let discr = operand.layout().ty.discriminant_for_variant(fx.tcx, *index).unwrap(); + let discr = operand + .layout() + .ty + .discriminant_for_variant(fx.tcx, *index) + .unwrap(); let discr = if discr.ty.is_signed() { - rustc_middle::mir::interpret::sign_extend(discr.val, fx.layout_of(discr.ty).size) + rustc_middle::mir::interpret::sign_extend( + discr.val, + fx.layout_of(discr.ty).size, + ) } else { discr.val }; @@ -550,7 +595,8 @@ fn trans_stmt<'tcx>( let cast_to = fx.clif_type(dest_layout.ty).unwrap(); // Read the tag/niche-encoded discriminant from memory. - let encoded_discr = operand.value_field(fx, mir::Field::new(*tag_field)); + let encoded_discr = + operand.value_field(fx, mir::Field::new(*tag_field)); let encoded_discr = encoded_discr.load_scalar(fx); // Decode the discriminant (specifically if it's niche-encoded). @@ -562,7 +608,7 @@ fn trans_stmt<'tcx>( let val = CValue::by_val(val, dest_layout); lval.write_cvalue(fx, val); } - Variants::Multiple { ..} => unreachable!(), + Variants::Multiple { .. } => unreachable!(), } } else { let to_clif_ty = fx.clif_type(to_ty).unwrap(); @@ -578,7 +624,11 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, CValue::by_val(res, dest_layout)); } } - Rvalue::Cast(CastKind::Pointer(PointerCast::ClosureFnPointer(_)), operand, _to_ty) => { + Rvalue::Cast( + CastKind::Pointer(PointerCast::ClosureFnPointer(_)), + operand, + _to_ty, + ) => { let operand = trans_operand(fx, operand); match operand.layout().ty.kind { ty::Closure(def_id, substs) => { @@ -587,7 +637,8 @@ fn trans_stmt<'tcx>( def_id, substs, ty::ClosureKind::FnOnce, - ).polymorphize(fx.tcx); + ) + .polymorphize(fx.tcx); let func_ref = fx.get_function_ref(instance); let func_addr = fx.bcx.ins().func_addr(fx.pointer_type, func_ref); lval.write_cvalue(fx, CValue::by_val(func_addr, lval.layout())); @@ -660,7 +711,8 @@ fn trans_stmt<'tcx>( .ty .is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())); let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes(); - let val = CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), ty_size.into()); + let val = + CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), ty_size.into()); lval.write_cvalue(fx, val); } Rvalue::Aggregate(kind, operands) => match **kind { @@ -691,12 +743,12 @@ fn trans_stmt<'tcx>( inputs, } = &**asm; let rustc_hir::LlvmInlineAsmInner { - asm: asm_code, // Name + asm: asm_code, // Name outputs: output_names, // Vec inputs: input_names, // Vec - clobbers, // Vec - volatile, // bool - alignstack, // bool + clobbers, // Vec + volatile, // bool + alignstack, // bool dialect: _, asm_str_style: _, } = asm; @@ -705,9 +757,15 @@ fn trans_stmt<'tcx>( // Black box } "mov %rbx, %rsi\n cpuid\n xchg %rbx, %rsi" => { - assert_eq!(input_names, &[Symbol::intern("{eax}"), Symbol::intern("{ecx}")]); + assert_eq!( + input_names, + &[Symbol::intern("{eax}"), Symbol::intern("{ecx}")] + ); assert_eq!(output_names.len(), 4); - for (i, c) in (&["={eax}", "={esi}", "={ecx}", "={edx}"]).iter().enumerate() { + for (i, c) in (&["={eax}", "={esi}", "={ecx}", "={edx}"]) + .iter() + .enumerate() + { assert_eq!(&output_names[i].constraint.as_str(), c); assert!(!output_names[i].is_rw); assert!(!output_names[i].is_indirect); @@ -722,13 +780,18 @@ fn trans_stmt<'tcx>( let leaf = trans_operand(fx, &inputs[0].1).load_scalar(fx); // %eax let subleaf = trans_operand(fx, &inputs[1].1).load_scalar(fx); // %ecx - let (eax, ebx, ecx, edx) = crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); + let (eax, ebx, ecx, edx) = + crate::intrinsics::codegen_cpuid_call(fx, leaf, subleaf); assert_eq!(outputs.len(), 4); - trans_place(fx, outputs[0]).write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[1]).write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[2]).write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32))); - trans_place(fx, outputs[3]).write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[0]) + .write_cvalue(fx, CValue::by_val(eax, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[1]) + .write_cvalue(fx, CValue::by_val(ebx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[2]) + .write_cvalue(fx, CValue::by_val(ecx, fx.layout_of(fx.tcx.types.u32))); + trans_place(fx, outputs[3]) + .write_cvalue(fx, CValue::by_val(edx, fx.layout_of(fx.tcx.types.u32))); } "xgetbv" => { assert_eq!(input_names, &[Symbol::intern("{ecx}")]); @@ -748,7 +811,12 @@ fn trans_stmt<'tcx>( crate::trap::trap_unimplemented(fx, "_xgetbv arch intrinsic is not supported"); } // ___chkstk, ___chkstk_ms and __alloca are only used on Windows - _ if fx.tcx.symbol_name(fx.instance).name.starts_with("___chkstk") => { + _ if fx + .tcx + .symbol_name(fx.instance) + .name + .starts_with("___chkstk") => + { crate::trap::trap_unimplemented(fx, "Stack probes are not supported"); } _ if fx.tcx.symbol_name(fx.instance).name == "__alloca" => { @@ -758,7 +826,10 @@ fn trans_stmt<'tcx>( "int $$0x29" => { crate::trap::trap_unimplemented(fx, "Windows abort"); } - _ => fx.tcx.sess.span_fatal(stmt.source_info.span, "Inline assembly is not supported"), + _ => fx + .tcx + .sess + .span_fatal(stmt.source_info.span, "Inline assembly is not supported"), } } StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"), @@ -771,7 +842,8 @@ fn codegen_array_len<'tcx>( ) -> Value { match place.layout().ty.kind { ty::Array(_elem_ty, len) => { - let len = fx.monomorphize(&len) + let len = fx + .monomorphize(&len) .eval(fx.tcx, ParamEnv::reveal_all()) .eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64; fx.bcx.ins().iconst(fx.pointer_type, len) @@ -836,7 +908,9 @@ pub(crate) fn trans_place<'tcx>( let len = len.unwrap(); cplace = CPlace::for_ptr_with_extra( ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), - fx.bcx.ins().iadd_imm(len, -(i64::from(from) + i64::from(to))), + fx.bcx + .ins() + .iadd_imm(len, -(i64::from(from) + i64::from(to))), cplace.layout(), ); } diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index e2bb5b17ba2d3..cbce7d9d1287d 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -98,7 +98,7 @@ pub(crate) fn maybe_codegen<'tcx>( // Optimize `val >> 64`, because compiler_builtins uses it to deconstruct an 128bit // integer into its lsb and msb. // https://github.com/rust-lang-nursery/compiler-builtins/blob/79a6a1603d5672cbb9187ff41ff4d9b5048ac1cb/src/int/mod.rs#L217 - if resolve_value_imm(fx.bcx.func, rhs_val) == Some(64) { + if resolve_value_imm(fx.bcx.func, rhs_val) == Some(64) { let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); let all_zeros = fx.bcx.ins().iconst(types::I64, 0); let val = match (bin_op, is_signed) { diff --git a/src/common.rs b/src/common.rs index c8062e493ddb9..3c65e7aad2119 100644 --- a/src/common.rs +++ b/src/common.rs @@ -1,6 +1,6 @@ +use rustc_index::vec::IndexVec; use rustc_target::abi::{Integer, Primitive}; use rustc_target::spec::{HasTargetSpec, Target}; -use rustc_index::vec::IndexVec; use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; @@ -55,7 +55,11 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option types::F64, }, ty::FnPtr(_) => pointer_ty(tcx), - ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => { + ty::RawPtr(TypeAndMut { + ty: pointee_ty, + mutbl: _, + }) + | ty::Ref(_, pointee_ty, _) => { if has_ptr_meta(tcx, pointee_ty) { return None; } else { @@ -63,7 +67,8 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { - let (element, count) = match &tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().abi { + let (element, count) = match &tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().abi + { Abi::Vector { element, count } => (element.clone(), *count), _ => unreachable!(), }; @@ -79,7 +84,10 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<(types::Type, types::Type)> { +fn clif_pair_type_from_ty<'tcx>( + tcx: TyCtxt<'tcx>, + ty: Ty<'tcx>, +) -> Option<(types::Type, types::Type)> { Some(match ty.kind { ty::Tuple(substs) if substs.len() == 2 => { let mut types = substs.types(); @@ -90,11 +98,15 @@ fn clif_pair_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<(type } (a, b) } - ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => { + ty::RawPtr(TypeAndMut { + ty: pointee_ty, + mutbl: _, + }) + | ty::Ref(_, pointee_ty, _) => { if has_ptr_meta(tcx, pointee_ty) { (pointer_ty(tcx), pointer_ty(tcx)) } else { - return None + return None; } } _ => return None, @@ -103,8 +115,15 @@ fn clif_pair_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<(type /// Is a pointer to this type a fat ptr? pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { - let ptr_ty = tcx.mk_ptr(TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not }); - match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi { + let ptr_ty = tcx.mk_ptr(TypeAndMut { + ty, + mutbl: rustc_hir::Mutability::Not, + }); + match &tcx + .layout_of(ParamEnv::reveal_all().and(ptr_ty)) + .unwrap() + .abi + { Abi::Scalar(_) => false, Abi::ScalarPair(_, _) => true, abi => unreachable!("Abi of ptr to {:?} is {:?}???", ty, abi), @@ -200,7 +219,11 @@ pub(crate) fn resolve_value_imm(func: &Function, val: Value) -> Option { } } -pub(crate) fn type_min_max_value(bcx: &mut FunctionBuilder<'_>, ty: Type, signed: bool) -> (Value, Value) { +pub(crate) fn type_min_max_value( + bcx: &mut FunctionBuilder<'_>, + ty: Type, + signed: bool, +) -> (Value, Value) { assert!(ty.is_int()); if ty == types::I128 { @@ -339,13 +362,11 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { T: TypeFoldable<'tcx> + Copy, { if let Some(substs) = self.instance.substs_for_mir_body() { - self.tcx.subst_and_normalize_erasing_regions( - substs, - ty::ParamEnv::reveal_all(), - value, - ) + self.tcx + .subst_and_normalize_erasing_regions(substs, ty::ParamEnv::reveal_all(), value) } else { - self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) + self.tcx + .normalize_erasing_regions(ty::ParamEnv::reveal_all(), *value) } } @@ -385,11 +406,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { caller.line as u32, caller.col_display as u32 + 1, )); - crate::constant::trans_const_value( - self, - const_loc, - self.tcx.caller_location_ty(), - ) + crate::constant::trans_const_value(self, const_loc, self.tcx.caller_location_ty()) } pub(crate) fn triple(&self) -> &target_lexicon::Triple { @@ -406,7 +423,8 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { let mut data_ctx = DataContext::new(); data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice()); let msg_id = self - .cx.module + .cx + .module .declare_data( &format!("__{}_{:08x}", prefix, msg_hash), Linkage::Local, diff --git a/src/constant.rs b/src/constant.rs index 933694b8292bc..d1248110d06cd 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,5 +1,6 @@ use rustc_span::DUMMY_SP; +use rustc_data_structures::fx::FxHashSet; use rustc_errors::ErrorReported; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::{ @@ -7,7 +8,6 @@ use rustc_middle::mir::interpret::{ }; use rustc_middle::ty::{Const, ConstKind}; use rustc_target::abi::Align; -use rustc_data_structures::fx::FxHashSet; use cranelift_codegen::ir::GlobalValueData; use cranelift_module::*; @@ -41,19 +41,31 @@ pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Backend>) { match const_.val { ConstKind::Value(_) => {} ConstKind::Unevaluated(def, ref substs, promoted) => { - if let Err(err) = fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + if let Err(err) = + fx.tcx + .const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) + { match err { ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => { - fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.tcx + .sess + .span_err(constant.span, "erroneous constant encountered"); } ErrorHandled::TooGeneric => { - span_bug!(constant.span, "codgen encountered polymorphic constant: {:?}", err); + span_bug!( + constant.span, + "codgen encountered polymorphic constant: {:?}", + err + ); } } } } - ConstKind::Param(_) | ConstKind::Infer(_) | ConstKind::Bound(_, _) - | ConstKind::Placeholder(_) | ConstKind::Error(_) => unreachable!("{:?}", const_), + ConstKind::Param(_) + | ConstKind::Infer(_) + | ConstKind::Bound(_, _) + | ConstKind::Placeholder(_) + | ConstKind::Error(_) => unreachable!("{:?}", const_), } } } @@ -86,7 +98,10 @@ fn codegen_static_ref<'tcx>( fx.add_comment(local_data_id, format!("{:?}", def_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"); + 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) } @@ -105,14 +120,20 @@ pub(crate) fn trans_constant<'tcx>( fx, def.did, fx.layout_of(fx.monomorphize(&constant.literal.ty)), - ).to_cvalue(fx); + ) + .to_cvalue(fx); } ConstKind::Unevaluated(def, ref substs, promoted) => { - match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) { + match fx + .tcx + .const_eval_resolve(ParamEnv::reveal_all(), def, substs, promoted, None) + { Ok(const_val) => const_val, Err(_) => { if promoted.is_none() { - fx.tcx.sess.span_err(constant.span, "erroneous constant encountered"); + fx.tcx + .sess + .span_err(constant.span, "erroneous constant encountered"); } return crate::trap::trap_unreachable_ret_value( fx, @@ -122,8 +143,11 @@ pub(crate) fn trans_constant<'tcx>( } } } - ConstKind::Param(_) | ConstKind::Infer(_) | ConstKind::Bound(_, _) - | ConstKind::Placeholder(_) | ConstKind::Error(_) => unreachable!("{:?}", const_), + ConstKind::Param(_) + | ConstKind::Infer(_) + | ConstKind::Bound(_, _) + | ConstKind::Placeholder(_) + | ConstKind::Error(_) => unreachable!("{:?}", const_), }; trans_const_value(fx, const_val, const_.ty) @@ -132,7 +156,7 @@ pub(crate) fn trans_constant<'tcx>( pub(crate) fn trans_const_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, const_val: ConstValue<'tcx>, - ty: Ty<'tcx> + ty: Ty<'tcx>, ) -> CValue<'tcx> { let layout = fx.layout_of(ty); assert!(!layout.is_unsized(), "sized const value"); @@ -149,7 +173,9 @@ pub(crate) fn trans_const_value<'tcx>( if fx.clif_type(layout.ty).is_none() { let (size, align) = (layout.size, layout.align.pref); let mut alloc = Allocation::from_bytes( - std::iter::repeat(0).take(size.bytes_usize()).collect::>(), + std::iter::repeat(0) + .take(size.bytes_usize()) + .collect::>(), align, ); let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used @@ -168,44 +194,58 @@ pub(crate) fn trans_const_value<'tcx>( let base_addr = match alloc_kind { Some(GlobalAlloc::Memory(alloc)) => { fx.cx.constants_cx.todo.push(TodoItem::Alloc(ptr.alloc_id)); - let data_id = data_id_for_alloc_id(&mut fx.cx.module, ptr.alloc_id, alloc.align, alloc.mutability); - let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = data_id_for_alloc_id( + &mut fx.cx.module, + ptr.alloc_id, + alloc.align, + alloc.mutability, + ); + let local_data_id = + fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", ptr.alloc_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } Some(GlobalAlloc::Function(instance)) => { - let func_id = crate::abi::import_function(fx.tcx, &mut fx.cx.module, instance); - let local_func_id = fx.cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); + let func_id = + crate::abi::import_function(fx.tcx, &mut fx.cx.module, instance); + let local_func_id = + fx.cx.module.declare_func_in_func(func_id, &mut fx.bcx.func); fx.bcx.ins().func_addr(fx.pointer_type, local_func_id) } Some(GlobalAlloc::Static(def_id)) => { assert!(fx.tcx.is_static(def_id)); - let data_id = data_id_for_static(fx.tcx, &mut fx.cx.module, def_id, false); - let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); + let data_id = + data_id_for_static(fx.tcx, &mut fx.cx.module, def_id, false); + let local_data_id = + fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(local_data_id, format!("{:?}", def_id)); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } None => bug!("missing allocation {:?}", ptr.alloc_id), }; - let val = fx.bcx.ins().iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap()); + let val = fx + .bcx + .ins() + .iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap()); return CValue::by_val(val, layout); } } } - ConstValue::ByRef { alloc, offset } => { - CValue::by_ref( - pointer_for_allocation(fx, alloc) - .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), - layout, - ) - } + ConstValue::ByRef { alloc, offset } => CValue::by_ref( + pointer_for_allocation(fx, alloc) + .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), + layout, + ), ConstValue::Slice { data, start, end } => { let ptr = pointer_for_allocation(fx, data) .offset_i64(fx, i64::try_from(start).unwrap()) .get_addr(fx); - let len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(end.checked_sub(start).unwrap()).unwrap()); + let len = fx.bcx.ins().iconst( + fx.pointer_type, + i64::try_from(end.checked_sub(start).unwrap()).unwrap(), + ); CValue::by_val_pair(ptr, len, layout) } } @@ -254,7 +294,8 @@ fn data_id_for_static( crate::linkage::get_static_linkage(tcx, def_id) } else { if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak) - || rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny) { + || rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny) + { Linkage::Preemptible } else { Linkage::Import @@ -309,7 +350,11 @@ fn data_id_for_static( .unwrap(); let mut data_ctx = DataContext::new(); let data = module.declare_data_in_data(data_id, &mut data_ctx); - data_ctx.define(std::iter::repeat(0).take(pointer_ty(tcx).bytes() as usize).collect()); + data_ctx.define( + std::iter::repeat(0) + .take(pointer_ty(tcx).bytes() as usize) + .collect(), + ); data_ctx.write_data_addr(0, data, 0); match module.define_data(ref_data_id, &data_ctx) { // Every time the static is referenced there will be another definition of this global, @@ -338,7 +383,10 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu TodoItem::Static(def_id) => { //println!("static {:?}", def_id); - let section_name = tcx.codegen_fn_attrs(def_id).link_section.map(|s| s.as_str()); + let section_name = tcx + .codegen_fn_attrs(def_id) + .link_section + .map(|s| s.as_str()); let const_ = tcx.const_eval_poly(def_id).unwrap(); @@ -364,7 +412,9 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu data_ctx.set_segment_section("", &*section_name); } - let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); + let bytes = alloc + .inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()) + .to_vec(); data_ctx.define(bytes.into_boxed_slice()); for &(offset, (_tag, reloc)) in alloc.relocations().iter() { @@ -372,7 +422,9 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu let endianness = tcx.data_layout.endian; let offset = offset.bytes() as usize; let ptr_size = tcx.data_layout.pointer_size; - let bytes = &alloc.inspect_with_uninit_and_ptr_outside_interpreter(offset..offset + ptr_size.bytes() as usize); + let bytes = &alloc.inspect_with_uninit_and_ptr_outside_interpreter( + offset..offset + ptr_size.bytes() as usize, + ); read_target_uint(endianness, bytes).unwrap() }; @@ -390,8 +442,15 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu data_id_for_alloc_id(module, reloc, target_alloc.align, target_alloc.mutability) } GlobalAlloc::Static(def_id) => { - if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { - tcx.sess.fatal(&format!("Allocation {:?} contains reference to TLS value {:?}", alloc, def_id)); + if tcx + .codegen_fn_attrs(def_id) + .flags + .contains(CodegenFnAttrFlags::THREAD_LOCAL) + { + tcx.sess.fatal(&format!( + "Allocation {:?} contains reference to TLS value {:?}", + alloc, def_id + )); } // Don't push a `TodoItem::Static` here, as it will cause statics used by @@ -418,8 +477,9 @@ pub(crate) fn mir_operand_get_const_val<'tcx>( ) -> Option<&'tcx Const<'tcx>> { match operand { Operand::Copy(_) | Operand::Move(_) => None, - Operand::Constant(const_) => { - Some(fx.monomorphize(&const_.literal).eval(fx.tcx, ParamEnv::reveal_all())) - } + Operand::Constant(const_) => Some( + fx.monomorphize(&const_.literal) + .eval(fx.tcx, ParamEnv::reveal_all()), + ), } } diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 219fa18305144..01cb6d3484db3 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -83,7 +83,9 @@ impl WriterRelocate { cranelift_module::FuncId::from_u32(sym.try_into().unwrap()), ); let val = (addr as u64 as i64 + reloc.addend) as u64; - self.writer.write_udata_at(reloc.offset as usize, val, reloc.size).unwrap(); + self.writer + .write_udata_at(reloc.offset as usize, val, reloc.size) + .unwrap(); } } } diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 89dccb8545fc6..798064b07a588 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -3,13 +3,16 @@ use std::path::{Component, Path}; use crate::prelude::*; -use rustc_span::{FileName, SourceFile, SourceFileAndLine, Pos, SourceFileHash, SourceFileHashAlgorithm}; +use rustc_span::{ + FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHash, SourceFileHashAlgorithm, +}; use cranelift_codegen::binemit::CodeOffset; use cranelift_codegen::machinst::MachSrcLoc; use gimli::write::{ - Address, AttributeValue, FileId, LineProgram, LineString, FileInfo, LineStringTable, UnitEntryId, + Address, AttributeValue, FileId, FileInfo, LineProgram, LineString, LineStringTable, + UnitEntryId, }; // OPTIMIZATION: It is cheaper to do this in one pass than using `.parent()` and `.file_name()`. @@ -18,7 +21,11 @@ fn split_path_dir_and_file(path: &Path) -> (&Path, &OsStr) { let file_name = match iter.next_back() { Some(Component::Normal(p)) => p, component => { - panic!("Path component {:?} of path {} is an invalid filename", component, path.display()); + panic!( + "Path component {:?} of path {} is an invalid filename", + component, + path.display() + ); } }; let parent = iter.as_path(); @@ -27,11 +34,13 @@ fn split_path_dir_and_file(path: &Path) -> (&Path, &OsStr) { // OPTIMIZATION: Avoid UTF-8 validation on UNIX. fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] { - #[cfg(unix)] { + #[cfg(unix)] + { use std::os::unix::ffi::OsStrExt; return path.as_bytes(); } - #[cfg(not(unix))] { + #[cfg(not(unix))] + { return path.to_str().unwrap().as_bytes(); } } @@ -69,11 +78,7 @@ fn line_program_add_file( } else { line_program.default_directory() }; - let file_name = LineString::new( - file_name, - line_program.encoding(), - line_strings, - ); + let file_name = LineString::new(file_name, line_program.encoding(), line_strings); let info = make_file_info(file.src_hash); @@ -149,8 +154,7 @@ impl<'tcx> DebugContext<'tcx> { // In order to have a good line stepping behavior in debugger, we overwrite debug // locations of macro expansions with that of the outermost expansion site // (unless the crate is being compiled with `-Z debug-macros`). - let span = if !span.from_expansion() || - tcx.sess.opts.debugging_opts.debug_macros { + let span = if !span.from_expansion() || tcx.sess.opts.debugging_opts.debug_macros { span } else { // Walk up the macro expansion chain until we reach a non-expanded span. @@ -163,9 +167,13 @@ impl<'tcx> DebugContext<'tcx> { Ok(SourceFileAndLine { sf: file, line }) => { let line_pos = file.line_begin_pos(span.lo()); - (file, u64::try_from(line).unwrap() + 1, u64::from((span.lo() - line_pos).to_u32()) + 1) + ( + file, + u64::try_from(line).unwrap() + 1, + u64::from((span.lo() - line_pos).to_u32()) + 1, + ) } - Err(file) => (file, 0, 0) + Err(file) => (file, 0, 0), }; // line_program_add_file is very slow. @@ -188,10 +196,7 @@ impl<'tcx> DebugContext<'tcx> { line_program.generate_row(); }; - line_program.begin_sequence(Some(Address::Symbol { - symbol, - addend: 0, - })); + line_program.begin_sequence(Some(Address::Symbol { symbol, addend: 0 })); let mut func_end = 0; @@ -220,7 +225,8 @@ impl<'tcx> DebugContext<'tcx> { let srcloc = func.srclocs[inst]; line_program.row().address_offset = u64::from(offset); if !srcloc.is_default() { - let source_info = *source_info_set.get_index(srcloc.bits() as usize).unwrap(); + let source_info = + *source_info_set.get_index(srcloc.bits() as usize).unwrap(); create_row_for_span(line_program, source_info.span); } else { create_row_for_span(line_program, function_span); @@ -236,12 +242,12 @@ impl<'tcx> DebugContext<'tcx> { let entry = self.dwarf.unit.get_mut(entry_id); entry.set( gimli::DW_AT_low_pc, - AttributeValue::Address(Address::Symbol { - symbol, - addend: 0, - }), + AttributeValue::Address(Address::Symbol { symbol, addend: 0 }), + ); + entry.set( + gimli::DW_AT_high_pc, + AttributeValue::Udata(u64::from(func_end)), ); - entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(func_end))); self.emit_location(entry_id, function_span); diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 2c92fd0e47cc3..04330b6de60ca 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -10,8 +10,8 @@ use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::ValueLocRange; use gimli::write::{ - Address, AttributeValue, DwarfUnit, Expression, LineProgram, - LineString, Location, LocationList, Range, RangeList, UnitEntryId, + Address, AttributeValue, DwarfUnit, Expression, LineProgram, LineString, Location, + LocationList, Range, RangeList, UnitEntryId, }; use gimli::{Encoding, Format, LineEncoding, RunTimeEndian, X86_64}; @@ -66,7 +66,7 @@ impl<'tcx> DebugContext<'tcx> { Some(path) => { let name = path.to_string_lossy().into_owned(); (name, None) - }, + } None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), }; @@ -141,7 +141,10 @@ impl<'tcx> DebugContext<'tcx> { }; let type_entry = self.dwarf.unit.get_mut(type_id); - type_entry.set(gimli::DW_AT_name, AttributeValue::String(format!("{}", ty).replace('i', "u").into_bytes())); + type_entry.set( + gimli::DW_AT_name, + AttributeValue::String(format!("{}", ty).replace('i', "u").into_bytes()), + ); type_entry.set( gimli::DW_AT_byte_size, AttributeValue::Udata(u64::from(ty.bytes())), @@ -202,18 +205,29 @@ impl<'tcx> DebugContext<'tcx> { for (field_idx, field_def) in variant.fields.iter().enumerate() { let field_offset = layout.fields.offset(field_idx); - let field_layout = layout.field(&layout::LayoutCx { - tcx: self.tcx, - param_env: ParamEnv::reveal_all(), - }, field_idx).unwrap(); + let field_layout = layout + .field( + &layout::LayoutCx { + tcx: self.tcx, + param_env: ParamEnv::reveal_all(), + }, + field_idx, + ) + .unwrap(); let field_type = self.dwarf_ty(field_layout.ty); let field_id = self.dwarf.unit.add(type_id, gimli::DW_TAG_member); let field_entry = self.dwarf.unit.get_mut(field_id); - field_entry.set(gimli::DW_AT_name, AttributeValue::String(field_def.ident.as_str().to_string().into_bytes())); - field_entry.set(gimli::DW_AT_data_member_location, AttributeValue::Udata(field_offset.bytes())); + field_entry.set( + gimli::DW_AT_name, + AttributeValue::String(field_def.ident.as_str().to_string().into_bytes()), + ); + field_entry.set( + gimli::DW_AT_data_member_location, + AttributeValue::Udata(field_offset.bytes()), + ); field_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(field_type)); } @@ -238,10 +252,7 @@ impl<'tcx> DebugContext<'tcx> { fn define_local(&mut self, scope: UnitEntryId, name: String, ty: Ty<'tcx>) -> UnitEntryId { let dw_ty = self.dwarf_ty(ty); - let var_id = self - .dwarf - .unit - .add(scope, gimli::DW_TAG_variable); + let var_id = self.dwarf.unit.add(scope, gimli::DW_TAG_variable); let var_entry = self.dwarf.unit.get_mut(var_id); var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); @@ -266,34 +277,23 @@ impl<'tcx> DebugContext<'tcx> { // FIXME: add to appropriate scope instead of root let scope = self.dwarf.unit.root(); - let entry_id = self - .dwarf - .unit - .add(scope, gimli::DW_TAG_subprogram); + let entry_id = self.dwarf.unit.add(scope, gimli::DW_TAG_subprogram); let entry = self.dwarf.unit.get_mut(entry_id); let name_id = self.dwarf.strings.add(name); // Gdb requires DW_AT_name. Otherwise the DW_TAG_subprogram is skipped. - entry.set( - gimli::DW_AT_name, - AttributeValue::StringRef(name_id), - ); + entry.set(gimli::DW_AT_name, AttributeValue::StringRef(name_id)); entry.set( gimli::DW_AT_linkage_name, AttributeValue::StringRef(name_id), ); - let end = self.create_debug_lines(isa, symbol, entry_id, context, mir.span, source_info_set); + let end = + self.create_debug_lines(isa, symbol, entry_id, context, mir.span, source_info_set); - self - .unit_range_list - .0 - .push(Range::StartLength { - begin: Address::Symbol { - symbol, - addend: 0, - }, - length: u64::from(end), - }); + self.unit_range_list.0.push(Range::StartLength { + begin: Address::Symbol { symbol, addend: 0 }, + length: u64::from(end), + }); if isa.get_mach_backend().is_some() { return; // Not yet implemented for the AArch64 backend. @@ -301,29 +301,49 @@ impl<'tcx> DebugContext<'tcx> { let func_entry = self.dwarf.unit.get_mut(entry_id); // Gdb requires both DW_AT_low_pc and DW_AT_high_pc. Otherwise the DW_TAG_subprogram is skipped. - func_entry.set(gimli::DW_AT_low_pc, AttributeValue::Address(Address::Symbol { - symbol, - addend: 0, - })); + func_entry.set( + gimli::DW_AT_low_pc, + AttributeValue::Address(Address::Symbol { symbol, addend: 0 }), + ); // Using Udata for DW_AT_high_pc requires at least DWARF4 func_entry.set(gimli::DW_AT_high_pc, AttributeValue::Udata(u64::from(end))); // FIXME Remove once actual debuginfo for locals works. - for (i, (param, &val)) in context.func.signature.params.iter().zip(context.func.dfg.block_params(context.func.layout.entry_block().unwrap())).enumerate() { + for (i, (param, &val)) in context + .func + .signature + .params + .iter() + .zip( + context + .func + .dfg + .block_params(context.func.layout.entry_block().unwrap()), + ) + .enumerate() + { use cranelift_codegen::ir::ArgumentPurpose; let base_name = match param.purpose { ArgumentPurpose::Normal => "arg", ArgumentPurpose::StructArgument(_) => "struct_arg", ArgumentPurpose::StructReturn => "sret", - ArgumentPurpose::Link | ArgumentPurpose::FramePointer | ArgumentPurpose::CalleeSaved => continue, - ArgumentPurpose::VMContext | ArgumentPurpose::SignatureId | ArgumentPurpose::StackLimit => unreachable!(), + ArgumentPurpose::Link + | ArgumentPurpose::FramePointer + | ArgumentPurpose::CalleeSaved => continue, + ArgumentPurpose::VMContext + | ArgumentPurpose::SignatureId + | ArgumentPurpose::StackLimit => unreachable!(), }; let name = format!("{}{}", base_name, i); let dw_ty = self.dwarf_ty_for_clif_ty(param.value_type); - let loc = translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap(); + let loc = + translate_loc(isa, context.func.locations[val], &context.func.stack_slots).unwrap(); - let arg_id = self.dwarf.unit.add(entry_id, gimli::DW_TAG_formal_parameter); + let arg_id = self + .dwarf + .unit + .add(entry_id, gimli::DW_TAG_formal_parameter); let var_entry = self.dwarf.unit.get_mut(arg_id); var_entry.set(gimli::DW_AT_name, AttributeValue::String(name.into_bytes())); @@ -371,8 +391,10 @@ fn place_location<'tcx>( symbol: usize, context: &Context, local_map: &FxHashMap>, - #[allow(rustc::default_hash_types)] - value_labels_ranges: &std::collections::HashMap>, + #[allow(rustc::default_hash_types)] value_labels_ranges: &std::collections::HashMap< + ValueLabel, + Vec, + >, place: Place<'tcx>, ) -> AttributeValue { assert!(place.projection.is_empty()); // FIXME implement them @@ -393,7 +415,12 @@ fn place_location<'tcx>( symbol, addend: i64::from(value_loc_range.end), }, - data: translate_loc(isa, value_loc_range.loc, &context.func.stack_slots).unwrap(), + data: translate_loc( + isa, + value_loc_range.loc, + &context.func.stack_slots, + ) + .unwrap(), }) .collect(), ); @@ -428,7 +455,11 @@ fn place_location<'tcx>( } // Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137 -fn translate_loc(isa: &dyn TargetIsa, loc: ValueLoc, stack_slots: &StackSlots) -> Option { +fn translate_loc( + isa: &dyn TargetIsa, + loc: ValueLoc, + stack_slots: &StackSlots, +) -> Option { match loc { ValueLoc::Reg(reg) => { let machine_reg = isa.map_dwarf_register(reg).unwrap(); diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 4bc3859652db2..5fc68990b2a5b 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -use cranelift_codegen::isa::{TargetIsa, unwind::UnwindInfo}; +use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa}; use gimli::write::{Address, CieId, EhFrame, FrameTable, Section}; @@ -13,13 +13,9 @@ pub(crate) struct UnwindContext<'tcx> { } impl<'tcx> UnwindContext<'tcx> { - pub(crate) fn new( - tcx: TyCtxt<'tcx>, - isa: &dyn TargetIsa, - ) -> Self { + pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self { let mut frame_table = FrameTable::default(); - let cie_id = if let Some(cie) = isa.create_systemv_cie() { Some(frame_table.add_cie(cie)) } else { @@ -42,11 +38,14 @@ impl<'tcx> UnwindContext<'tcx> { match unwind_info { UnwindInfo::SystemV(unwind_info) => { - self.frame_table.add_fde(self.cie_id.unwrap(), unwind_info.to_fde(Address::Symbol { - symbol: func_id.as_u32() as usize, - addend: 0, - })); - }, + self.frame_table.add_fde( + self.cie_id.unwrap(), + unwind_info.to_fde(Address::Symbol { + symbol: func_id.as_u32() as usize, + addend: 0, + }), + ); + } UnwindInfo::WindowsX64(_) => { // FIXME implement this } @@ -54,7 +53,9 @@ impl<'tcx> UnwindContext<'tcx> { } pub(crate) fn emit(self, product: &mut P) { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian( + self.tcx, + ))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if !eh_frame.0.writer.slice().is_empty() { @@ -74,7 +75,9 @@ impl<'tcx> UnwindContext<'tcx> { self, jit_module: &mut Module, ) -> Option { - let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian(self.tcx))); + let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian( + self.tcx, + ))); self.frame_table.write_eh_frame(&mut eh_frame).unwrap(); if eh_frame.0.writer.slice().is_empty() { diff --git a/src/discriminant.rs b/src/discriminant.rs index d15d74225716e..53a6acd7c858e 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -1,6 +1,6 @@ //! Adapted from https://github.com/rust-lang/rust/blob/d760df5aea483aae041c9a241e7acacf48f75035/src/librustc_codegen_ssa/mir/place.rs -use rustc_target::abi::{TagEncoding, Int, Variants}; +use rustc_target::abi::{Int, TagEncoding, Variants}; use crate::prelude::*; diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 17688caada47f..2eecd8c3c0adb 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -1,13 +1,13 @@ use std::path::PathBuf; +use rustc_codegen_ssa::back::linker::LinkerInfo; +use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind}; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::middle::cstore::EncodedMetadata; use rustc_middle::mir::mono::CodegenUnit; -use rustc_session::config::{DebugInfo, OutputType}; use rustc_session::cgu_reuse_tracker::CguReuse; -use rustc_codegen_ssa::back::linker::LinkerInfo; -use rustc_codegen_ssa::{CrateInfo, CodegenResults, CompiledModule, ModuleKind}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_session::config::{DebugInfo, OutputType}; use crate::prelude::*; @@ -21,7 +21,6 @@ fn new_module(tcx: TyCtxt<'_>, name: String) -> Module struct ModuleCodegenResult(CompiledModule, Option<(WorkProductId, WorkProduct)>); - impl HashStable for ModuleCodegenResult { fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { // do nothing @@ -37,7 +36,8 @@ fn emit_module( unwind_context: UnwindContext<'_>, map_product: impl FnOnce(B::Product) -> B::Product, ) -> ModuleCodegenResult - where B::Product: AddConstructor + Emit + WriteDebugInfo, +where + B::Product: AddConstructor + Emit + WriteDebugInfo, { module.finalize_definitions(); let mut product = module.finish(); @@ -55,7 +55,8 @@ fn emit_module( .temp_path(OutputType::Object, Some(&name)); let obj = product.emit(); if let Err(err) = std::fs::write(&tmp_file, obj) { - tcx.sess.fatal(&format!("error writing object file: {}", err)); + tcx.sess + .fatal(&format!("error writing object file: {}", err)); } let work_product = if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() { @@ -88,7 +89,9 @@ fn reuse_workproduct_for_cgu( let mut object = None; let work_product = cgu.work_product(tcx); if let Some(saved_file) = &work_product.saved_file { - let obj_out = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&cgu.name().as_str())); + let obj_out = tcx + .output_filenames(LOCAL_CRATE) + .temp_path(OutputType::Object, Some(&cgu.name().as_str())); object = Some(obj_out.clone()); let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { @@ -120,22 +123,30 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege // Initialize the global atomic mutex using a constructor for proc-macros. // FIXME implement atomic instructions in Cranelift. let mut init_atomics_mutex_from_constructor = None; - if tcx.sess.crate_types().contains(&rustc_session::config::CrateType::ProcMacro) { - if mono_items.iter().any(|(mono_item, _)| { - match mono_item { - rustc_middle::mir::mono::MonoItem::Static(def_id) => { - tcx.symbol_name(Instance::mono(tcx, *def_id)).name.contains("__rustc_proc_macro_decls_") - } - _ => false, - } + if tcx + .sess + .crate_types() + .contains(&rustc_session::config::CrateType::ProcMacro) + { + if mono_items.iter().any(|(mono_item, _)| match mono_item { + rustc_middle::mir::mono::MonoItem::Static(def_id) => tcx + .symbol_name(Instance::mono(tcx, *def_id)) + .name + .contains("__rustc_proc_macro_decls_"), + _ => false, }) { - init_atomics_mutex_from_constructor = Some(crate::atomic_shim::init_global_lock_constructor(&mut module, &format!("{}_init_atomics_mutex", cgu_name.as_str()))); + init_atomics_mutex_from_constructor = + Some(crate::atomic_shim::init_global_lock_constructor( + &mut module, + &format!("{}_init_atomics_mutex", cgu_name.as_str()), + )); } } let mut cx = crate::CodegenCx::new(tcx, module, tcx.sess.opts.debuginfo != DebugInfo::None); super::codegen_mono_items(&mut cx, mono_items); - let (mut module, global_asm, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); + let (mut module, global_asm, debug, mut unwind_context) = + tcx.sess.time("finalize CodegenCx", || cx.finalize()); crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context); let codegen_result = emit_module( @@ -151,7 +162,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege } product - } + }, ); codegen_global_asm(tcx, &cgu.name().as_str(), &global_asm); @@ -181,40 +192,46 @@ pub(super) fn run_aot( } let modules = super::time(tcx, "codegen mono items", || { - cgus.iter().map(|cgu| { - let cgu_reuse = determine_cgu_reuse(tcx, cgu); - tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse); - - match cgu_reuse { - _ if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() => {} - CguReuse::No => {} - CguReuse::PreLto => { - return reuse_workproduct_for_cgu(tcx, &*cgu, &mut work_products); + cgus.iter() + .map(|cgu| { + let cgu_reuse = determine_cgu_reuse(tcx, cgu); + tcx.sess + .cgu_reuse_tracker + .set_actual_reuse(&cgu.name().as_str(), cgu_reuse); + + match cgu_reuse { + _ if std::env::var("CG_CLIF_INCR_CACHE_DISABLED").is_ok() => {} + CguReuse::No => {} + CguReuse::PreLto => { + return reuse_workproduct_for_cgu(tcx, &*cgu, &mut work_products); + } + CguReuse::PostLto => unreachable!(), } - CguReuse::PostLto => unreachable!(), - } - - let dep_node = cgu.codegen_dep_node(tcx); - let (ModuleCodegenResult(module, work_product), _) = - tcx.dep_graph.with_task(dep_node, tcx, cgu.name(), module_codegen, rustc_middle::dep_graph::hash_result); - if let Some((id, product)) = work_product { - work_products.insert(id, product); - } + let dep_node = cgu.codegen_dep_node(tcx); + let (ModuleCodegenResult(module, work_product), _) = tcx.dep_graph.with_task( + dep_node, + tcx, + cgu.name(), + module_codegen, + rustc_middle::dep_graph::hash_result, + ); + + if let Some((id, product)) = work_product { + work_products.insert(id, product); + } - module - }).collect::>() + module + }) + .collect::>() }); tcx.sess.abort_if_errors(); let mut allocator_module = new_module(tcx, "allocator_shim".to_string()); let mut allocator_unwind_context = UnwindContext::new(tcx, allocator_module.isa()); - let created_alloc_shim = crate::allocator::codegen( - tcx, - &mut allocator_module, - &mut allocator_unwind_context, - ); + let created_alloc_shim = + crate::allocator::codegen(tcx, &mut allocator_module, &mut allocator_unwind_context); let allocator_module = if created_alloc_shim { let ModuleCodegenResult(module, work_product) = emit_module( @@ -257,7 +274,8 @@ pub(super) fn run_aot( }); if let Err(err) = std::fs::write(&tmp_file, obj) { - tcx.sess.fatal(&format!("error writing metadata object file: {}", err)); + tcx.sess + .fatal(&format!("error writing metadata object file: {}", err)); } (metadata_cgu_name, tmp_file) @@ -277,17 +295,20 @@ pub(super) fn run_aot( rustc_incremental::assert_module_sources::assert_module_sources(tcx); } - Box::new((CodegenResults { - crate_name: tcx.crate_name(LOCAL_CRATE), - modules, - allocator_module, - metadata_module, - crate_hash: tcx.crate_hash(LOCAL_CRATE), - metadata, - windows_subsystem: None, // Windows is not yet supported - linker_info: LinkerInfo::new(tcx), - crate_info: CrateInfo::new(tcx), - }, work_products)) + Box::new(( + CodegenResults { + crate_name: tcx.crate_name(LOCAL_CRATE), + modules, + allocator_module, + metadata_module, + crate_hash: tcx.crate_hash(LOCAL_CRATE), + metadata, + windows_subsystem: None, // Windows is not yet supported + linker_info: LinkerInfo::new(tcx), + crate_info: CrateInfo::new(tcx), + }, + work_products, + )) } fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { @@ -308,9 +329,12 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { // FIXME fix linker error on macOS if cfg!(not(feature = "inline_asm")) { - tcx.sess.fatal("asm! and global_asm! support is disabled while compiling rustc_codegen_cranelift"); + tcx.sess.fatal( + "asm! and global_asm! support is disabled while compiling rustc_codegen_cranelift", + ); } else { - tcx.sess.fatal("asm! and global_asm! are not yet supported on macOS and Windows"); + tcx.sess + .fatal("asm! and global_asm! are not yet supported on macOS and Windows"); } } @@ -318,13 +342,17 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { let linker = crate::toolchain::get_toolchain_binary(tcx.sess, "ld"); // Remove all LLVM style comments - let global_asm = global_asm.lines().map(|line| { - if let Some(index) = line.find("//") { - &line[0..index] - } else { - line - } - }).collect::>().join("\n"); + let global_asm = global_asm + .lines() + .map(|line| { + if let Some(index) = line.find("//") { + &line[0..index] + } else { + line + } + }) + .collect::>() + .join("\n"); let output_object_file = tcx .output_filenames(LOCAL_CRATE) @@ -333,14 +361,21 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { // Assemble `global_asm` let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm"); let mut child = Command::new(assembler) - .arg("-o").arg(&global_asm_object_file) + .arg("-o") + .arg(&global_asm_object_file) .stdin(Stdio::piped()) .spawn() .expect("Failed to spawn `as`."); - child.stdin.take().unwrap().write_all(global_asm.as_bytes()).unwrap(); + child + .stdin + .take() + .unwrap() + .write_all(global_asm.as_bytes()) + .unwrap(); let status = child.wait().expect("Failed to wait for `as`."); if !status.success() { - tcx.sess.fatal(&format!("Failed to assemble `{}`", global_asm)); + tcx.sess + .fatal(&format!("Failed to assemble `{}`", global_asm)); } // Link the global asm and main object file together @@ -348,7 +383,8 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { std::fs::rename(&output_object_file, &main_object_file).unwrap(); let status = Command::new(linker) .arg("-r") // Create a new object file - .arg("-o").arg(output_object_file) + .arg("-o") + .arg(output_object_file) .arg(&main_object_file) .arg(&global_asm_object_file) .status() @@ -383,7 +419,11 @@ fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguR } let work_product_id = &cgu.work_product_id(); - if tcx.dep_graph.previous_work_product(work_product_id).is_none() { + if tcx + .dep_graph + .previous_work_product(work_product_id) + .is_none() + { // We don't have anything cached for this CGU. This can happen // if the CGU did not exist in the previous session. return CguReuse::No; diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 129e36f170ac3..195cea02cde87 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -11,9 +11,18 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { // Rustc opens us without the RTLD_GLOBAL flag, so __cg_clif_global_atomic_mutex will not be // exported. We fix this by opening ourself again as global. // FIXME remove once atomic_shim is gone - let cg_dylib = std::ffi::OsString::from(&tcx.sess.opts.debugging_opts.codegen_backend.as_ref().unwrap()); - std::mem::forget(libloading::os::unix::Library::open(Some(cg_dylib), libc::RTLD_NOW | libc::RTLD_GLOBAL).unwrap()); - + let cg_dylib = std::ffi::OsString::from( + &tcx.sess + .opts + .debugging_opts + .codegen_backend + .as_ref() + .unwrap(), + ); + std::mem::forget( + libloading::os::unix::Library::open(Some(cg_dylib), libc::RTLD_NOW | libc::RTLD_GLOBAL) + .unwrap(), + ); let imported_symbols = load_imported_symbols_for_jit(tcx); @@ -54,10 +63,11 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let mut cx = crate::CodegenCx::new(tcx, jit_module, false); - let (mut jit_module, global_asm, _debug, mut unwind_context) = super::time(tcx, "codegen mono items", || { - super::codegen_mono_items(&mut cx, mono_items); - tcx.sess.time("finalize CodegenCx", || cx.finalize()) - }); + let (mut jit_module, global_asm, _debug, mut unwind_context) = + super::time(tcx, "codegen mono items", || { + super::codegen_mono_items(&mut cx, mono_items); + tcx.sess.time("finalize CodegenCx", || cx.finalize()) + }); if !global_asm.is_empty() { tcx.sess.fatal("Global asm is not supported in JIT mode"); } diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 96cfa3edbe08b..304add6f60434 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -17,13 +17,17 @@ pub(crate) fn codegen_crate( tcx.sess.abort_if_errors(); if std::env::var("CG_CLIF_JIT").is_ok() - && tcx.sess.crate_types().contains(&rustc_session::config::CrateType::Executable) + && tcx + .sess + .crate_types() + .contains(&rustc_session::config::CrateType::Executable) { #[cfg(feature = "jit")] let _: ! = jit::run_jit(tcx); #[cfg(not(feature = "jit"))] - tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift"); + tcx.sess + .fatal("jit support was disabled when compiling rustc_codegen_cranelift"); } aot::run_aot(tcx, metadata, need_metadata_module) @@ -37,8 +41,12 @@ fn codegen_mono_items<'tcx>( for &(mono_item, (linkage, visibility)) in &mono_items { match mono_item { MonoItem::Fn(instance) => { - let (name, sig) = - get_function_name_and_sig(cx.tcx, cx.module.isa().triple(), instance, false); + let (name, sig) = get_function_name_and_sig( + cx.tcx, + cx.module.isa().triple(), + instance, + false, + ); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); cx.module.declare_function(&name, linkage, &sig).unwrap(); } @@ -85,7 +93,8 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( } }); - tcx.sess.time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); + tcx.sess + .time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } MonoItem::Static(def_id) => { crate::constant::codegen_static(&mut cx.constants_cx, def_id); @@ -103,12 +112,21 @@ fn trans_mono_item<'tcx, B: Backend + 'static>( } fn time(tcx: TyCtxt<'_>, name: &'static str, f: impl FnOnce() -> R) -> R { - if std::env::var("CG_CLIF_DISPLAY_CG_TIME").as_ref().map(|val| &**val) == Ok("1") { + if std::env::var("CG_CLIF_DISPLAY_CG_TIME") + .as_ref() + .map(|val| &**val) + == Ok("1") + { println!("[{:<30}: {}] start", tcx.crate_name(LOCAL_CRATE), name); let before = std::time::Instant::now(); let res = tcx.sess.time(name, f); let after = std::time::Instant::now(); - println!("[{:<30}: {}] end time: {:?}", tcx.crate_name(LOCAL_CRATE), name, after - before); + println!( + "[{:<30}: {}] end time: {:?}", + tcx.crate_name(LOCAL_CRATE), + name, + after - before + ); res } else { tcx.sess.time(name, f) diff --git a/src/inline_asm.rs b/src/inline_asm.rs index d1783d621e55b..35b175917446c 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -2,7 +2,7 @@ use crate::prelude::*; use std::fmt::Write; -use rustc_ast::ast::{InlineAsmTemplatePiece, InlineAsmOptions}; +use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_middle::mir::InlineAsmOperand; use rustc_target::asm::*; @@ -45,21 +45,46 @@ pub(crate) fn codegen_inline_asm<'tcx>( InlineAsmOperand::In { reg, ref value } => { let reg = expect_reg(reg); clobbered_regs.push((reg, new_slot(reg.reg_class()))); - inputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_operand(fx, value).load_scalar(fx))); + inputs.push(( + reg, + new_slot(reg.reg_class()), + crate::base::trans_operand(fx, value).load_scalar(fx), + )); } - InlineAsmOperand::Out { reg, late: _, place } => { + InlineAsmOperand::Out { + reg, + late: _, + place, + } => { let reg = expect_reg(reg); clobbered_regs.push((reg, new_slot(reg.reg_class()))); if let Some(place) = place { - outputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_place(fx, place))); + outputs.push(( + reg, + new_slot(reg.reg_class()), + crate::base::trans_place(fx, place), + )); } } - InlineAsmOperand::InOut { reg, late: _, ref in_value, out_place } => { + InlineAsmOperand::InOut { + reg, + late: _, + ref in_value, + out_place, + } => { let reg = expect_reg(reg); clobbered_regs.push((reg, new_slot(reg.reg_class()))); - inputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_operand(fx, in_value).load_scalar(fx))); + inputs.push(( + reg, + new_slot(reg.reg_class()), + crate::base::trans_operand(fx, in_value).load_scalar(fx), + )); if let Some(out_place) = out_place { - outputs.push((reg, new_slot(reg.reg_class()), crate::base::trans_place(fx, out_place))); + outputs.push(( + reg, + new_slot(reg.reg_class()), + crate::base::trans_place(fx, out_place), + )); } } InlineAsmOperand::Const { value: _ } => todo!(), @@ -70,9 +95,21 @@ pub(crate) fn codegen_inline_asm<'tcx>( let inline_asm_index = fx.inline_asm_index; fx.inline_asm_index += 1; - let asm_name = format!("{}__inline_asm_{}", fx.tcx.symbol_name(fx.instance).name, inline_asm_index); + let asm_name = format!( + "{}__inline_asm_{}", + fx.tcx.symbol_name(fx.instance).name, + inline_asm_index + ); - let generated_asm = generate_asm_wrapper(&asm_name, InlineAsmArch::X86_64, options, template, clobbered_regs, &inputs, &outputs); + let generated_asm = generate_asm_wrapper( + &asm_name, + InlineAsmArch::X86_64, + options, + template, + clobbered_regs, + &inputs, + &outputs, + ); fx.cx.global_asm.push_str(&generated_asm); call_inline_asm(fx, &asm_name, slot_size, inputs, outputs); @@ -90,7 +127,12 @@ fn generate_asm_wrapper( let mut generated_asm = String::new(); writeln!(generated_asm, ".globl {}", asm_name).unwrap(); writeln!(generated_asm, ".type {},@function", asm_name).unwrap(); - writeln!(generated_asm, ".section .text.{},\"ax\",@progbits", asm_name).unwrap(); + writeln!( + generated_asm, + ".section .text.{},\"ax\",@progbits", + asm_name + ) + .unwrap(); writeln!(generated_asm, "{}:", asm_name).unwrap(); generated_asm.push_str(".intel_syntax noprefix\n"); @@ -120,7 +162,11 @@ fn generate_asm_wrapper( InlineAsmTemplatePiece::String(s) => { generated_asm.push_str(s); } - InlineAsmTemplatePiece::Placeholder { operand_idx: _, modifier: _, span: _ } => todo!(), + InlineAsmTemplatePiece::Placeholder { + operand_idx: _, + modifier: _, + span: _, + } => todo!(), } } generated_asm.push('\n'); @@ -147,7 +193,7 @@ fn generate_asm_wrapper( } generated_asm.push_str(".att_syntax\n"); - writeln!(generated_asm, ".size {name}, .-{name}", name=asm_name).unwrap(); + writeln!(generated_asm, ".size {name}, .-{name}", name = asm_name).unwrap(); generated_asm.push_str(".text\n"); generated_asm.push_str("\n\n"); @@ -169,17 +215,30 @@ fn call_inline_asm<'tcx>( #[cfg(debug_assertions)] fx.add_comment(stack_slot, "inline asm scratch slot"); - let inline_asm_func = fx.cx.module.declare_function(asm_name, Linkage::Import, &Signature { - call_conv: CallConv::SystemV, - params: vec![AbiParam::new(fx.pointer_type)], - returns: vec![], - }).unwrap(); - let inline_asm_func = fx.cx.module.declare_func_in_func(inline_asm_func, &mut fx.bcx.func); + let inline_asm_func = fx + .cx + .module + .declare_function( + asm_name, + Linkage::Import, + &Signature { + call_conv: CallConv::SystemV, + params: vec![AbiParam::new(fx.pointer_type)], + returns: vec![], + }, + ) + .unwrap(); + let inline_asm_func = fx + .cx + .module + .declare_func_in_func(inline_asm_func, &mut fx.bcx.func); #[cfg(debug_assertions)] fx.add_comment(inline_asm_func, asm_name); for (_reg, offset, value) in inputs { - fx.bcx.ins().stack_store(value, stack_slot, i32::try_from(offset.bytes()).unwrap()); + fx.bcx + .ins() + .stack_store(value, stack_slot, i32::try_from(offset.bytes()).unwrap()); } let stack_slot_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); @@ -187,7 +246,10 @@ fn call_inline_asm<'tcx>( for (_reg, offset, place) in outputs { let ty = fx.clif_type(place.layout().ty).unwrap(); - let value = fx.bcx.ins().stack_load(ty, stack_slot, i32::try_from(offset.bytes()).unwrap()); + let value = fx + .bcx + .ins() + .stack_load(ty, stack_slot, i32::try_from(offset.bytes()).unwrap()); place.write_cvalue(fx, CValue::by_val(value, place.layout())); } } @@ -203,18 +265,25 @@ fn save_register(generated_asm: &mut String, arch: InlineAsmArch, reg: InlineAsm match arch { InlineAsmArch::X86_64 => { write!(generated_asm, " mov [rbp+0x{:x}], ", offset.bytes()).unwrap(); - reg.emit(generated_asm, InlineAsmArch::X86_64, None).unwrap(); + reg.emit(generated_asm, InlineAsmArch::X86_64, None) + .unwrap(); generated_asm.push('\n'); } _ => unimplemented!("save_register for {:?}", arch), } } -fn restore_register(generated_asm: &mut String, arch: InlineAsmArch, reg: InlineAsmReg, offset: Size) { +fn restore_register( + generated_asm: &mut String, + arch: InlineAsmArch, + reg: InlineAsmReg, + offset: Size, +) { match arch { InlineAsmArch::X86_64 => { generated_asm.push_str(" mov "); - reg.emit(generated_asm, InlineAsmArch::X86_64, None).unwrap(); + reg.emit(generated_asm, InlineAsmArch::X86_64, None) + .unwrap(); writeln!(generated_asm, ", [rbp+0x{:x}]", offset.bytes()).unwrap(); } _ => unimplemented!("restore_register for {:?}", arch), diff --git a/src/intrinsics/cpuid.rs b/src/intrinsics/cpuid.rs index 9d971d97b88c6..48891ab25452f 100644 --- a/src/intrinsics/cpuid.rs +++ b/src/intrinsics/cpuid.rs @@ -29,37 +29,60 @@ pub(crate) fn codegen_cpuid_call<'tcx>( fx.bcx.switch_to_block(leaf_0); let max_basic_leaf = fx.bcx.ins().iconst(types::I32, 1); - let vend0 = fx.bcx.ins().iconst(types::I32, i64::from(u32::from_le_bytes(*b"Genu"))); - let vend2 = fx.bcx.ins().iconst(types::I32, i64::from(u32::from_le_bytes(*b"ineI"))); - let vend1 = fx.bcx.ins().iconst(types::I32, i64::from(u32::from_le_bytes(*b"ntel"))); - fx.bcx.ins().jump(dest, &[max_basic_leaf, vend0, vend1, vend2]); + let vend0 = fx + .bcx + .ins() + .iconst(types::I32, i64::from(u32::from_le_bytes(*b"Genu"))); + let vend2 = fx + .bcx + .ins() + .iconst(types::I32, i64::from(u32::from_le_bytes(*b"ineI"))); + let vend1 = fx + .bcx + .ins() + .iconst(types::I32, i64::from(u32::from_le_bytes(*b"ntel"))); + fx.bcx + .ins() + .jump(dest, &[max_basic_leaf, vend0, vend1, vend2]); fx.bcx.switch_to_block(leaf_1); let cpu_signature = fx.bcx.ins().iconst(types::I32, 0); let additional_information = fx.bcx.ins().iconst(types::I32, 0); - let ecx_features = fx.bcx.ins().iconst( - types::I32, - 0, + let ecx_features = fx.bcx.ins().iconst(types::I32, 0); + let edx_features = fx + .bcx + .ins() + .iconst(types::I32, 1 << 25 /* sse */ | 1 << 26 /* sse2 */); + fx.bcx.ins().jump( + dest, + &[ + cpu_signature, + additional_information, + ecx_features, + edx_features, + ], ); - let edx_features = fx.bcx.ins().iconst( - types::I32, - 1 << 25 /* sse */ | 1 << 26 /* sse2 */, - ); - fx.bcx.ins().jump(dest, &[cpu_signature, additional_information, ecx_features, edx_features]); fx.bcx.switch_to_block(leaf_8000_0000); let extended_max_basic_leaf = fx.bcx.ins().iconst(types::I32, 0); let zero = fx.bcx.ins().iconst(types::I32, 0); - fx.bcx.ins().jump(dest, &[extended_max_basic_leaf, zero, zero, zero]); + fx.bcx + .ins() + .jump(dest, &[extended_max_basic_leaf, zero, zero, zero]); fx.bcx.switch_to_block(leaf_8000_0001); let zero = fx.bcx.ins().iconst(types::I32, 0); let proc_info_ecx = fx.bcx.ins().iconst(types::I32, 0); let proc_info_edx = fx.bcx.ins().iconst(types::I32, 0); - fx.bcx.ins().jump(dest, &[zero, zero, proc_info_ecx, proc_info_edx]); + fx.bcx + .ins() + .jump(dest, &[zero, zero, proc_info_ecx, proc_info_edx]); fx.bcx.switch_to_block(unsupported_leaf); - crate::trap::trap_unreachable(fx, "__cpuid_count arch intrinsic doesn't yet support specified leaf"); + crate::trap::trap_unreachable( + fx, + "__cpuid_count arch intrinsic doesn't yet support specified leaf", + ); fx.bcx.switch_to_block(dest); fx.bcx.ins().nop(); diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index b0d5988a6e433..e8bd3e4ac3efb 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -108,7 +108,7 @@ macro call_intrinsic_match { } } -macro atomic_binop_return_old($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) { +macro atomic_binop_return_old($fx:expr, $op:ident<$T:ident>($ptr:ident, $src:ident) -> $ret:ident) { crate::atomic_shim::lock_global_lock($fx); let clif_ty = $fx.clif_type($T).unwrap(); @@ -144,7 +144,13 @@ macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { match $ty.kind { ty::Uint(_) | ty::Int(_) => {} _ => { - $fx.tcx.sess.span_err($span, &format!("`{}` intrinsic: expected basic integer type, found `{:?}`", $intrinsic, $ty)); + $fx.tcx.sess.span_err( + $span, + &format!( + "`{}` intrinsic: expected basic integer type, found `{:?}`", + $intrinsic, $ty + ), + ); // Prevent verifier error crate::trap::trap_unreachable($fx, "compilation should not have succeeded"); return; @@ -170,10 +176,15 @@ fn lane_type_and_count<'tcx>( rustc_target::abi::FieldsShape::Array { stride: _, count } => u16::try_from(count).unwrap(), _ => unreachable!("lane_type_and_count({:?})", layout), }; - let lane_layout = layout.field(&ty::layout::LayoutCx { - tcx, - param_env: ParamEnv::reveal_all(), - }, 0).unwrap(); + let lane_layout = layout + .field( + &ty::layout::LayoutCx { + tcx, + param_env: ParamEnv::reveal_all(), + }, + 0, + ) + .unwrap(); (lane_layout, lane_count) } @@ -405,10 +416,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); } "transmute" => { - trap_unreachable( - fx, - "[corruption] Transmuting to uninhabited type.", - ); + trap_unreachable(fx, "[corruption] Transmuting to uninhabited type."); } _ => unimplemented!("unsupported instrinsic {}", intrinsic), } diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 92fd00f049c4c..cb6e1d2098355 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -1,5 +1,5 @@ -use crate::prelude::*; use super::*; +use crate::prelude::*; pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, diff --git a/src/lib.rs b/src/lib.rs index 6394937605a68..249c58b90311e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,11 @@ -#![feature(rustc_private, decl_macro, type_alias_impl_trait, associated_type_bounds, never_type, try_blocks)] +#![feature( + rustc_private, + decl_macro, + type_alias_impl_trait, + associated_type_bounds, + never_type, + try_blocks +)] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] @@ -7,6 +14,7 @@ extern crate flate2; extern crate libc; #[macro_use] extern crate rustc_middle; +extern crate rustc_ast; extern crate rustc_codegen_ssa; extern crate rustc_data_structures; extern crate rustc_errors; @@ -19,7 +27,6 @@ extern crate rustc_session; extern crate rustc_span; extern crate rustc_symbol_mangling; extern crate rustc_target; -extern crate rustc_ast; // This prevents duplicating functions and statics that are already part of the host rustc process. #[allow(unused_extern_crates)] @@ -27,14 +34,14 @@ extern crate rustc_driver; use std::any::Any; +use rustc_codegen_ssa::traits::CodegenBackend; +use rustc_codegen_ssa::CodegenResults; use rustc_errors::ErrorReported; use rustc_middle::dep_graph::{DepGraph, WorkProduct, WorkProductId}; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; -use rustc_session::Session; -use rustc_session::config::OutputFilenames; use rustc_middle::ty::query::Providers; -use rustc_codegen_ssa::CodegenResults; -use rustc_codegen_ssa::traits::CodegenBackend; +use rustc_session::config::OutputFilenames; +use rustc_session::Session; use cranelift_codegen::settings::{self, Configurable}; @@ -46,8 +53,8 @@ mod allocator; mod analyze; mod archive; mod atomic_shim; -mod base; mod backend; +mod base; mod cast; mod codegen_i128; mod common; @@ -77,26 +84,29 @@ mod prelude { pub(crate) use rustc_ast::ast::{FloatTy, IntTy, UintTy}; pub(crate) use rustc_span::Span; - pub(crate) use rustc_middle::bug; pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE}; + pub(crate) use rustc_middle::bug; pub(crate) use rustc_middle::mir::{self, *}; pub(crate) use rustc_middle::ty::layout::{self, TyAndLayout}; - pub(crate) use rustc_target::abi::{Abi, LayoutOf, Scalar, Size, VariantIdx}; pub(crate) use rustc_middle::ty::{ self, FnSig, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable, }; + pub(crate) use rustc_target::abi::{Abi, LayoutOf, Scalar, Size, VariantIdx}; pub(crate) use rustc_data_structures::fx::FxHashMap; pub(crate) use rustc_index::vec::Idx; - pub(crate) use cranelift_codegen::Context; pub(crate) use cranelift_codegen::entity::EntitySet; - pub(crate) use cranelift_codegen::ir::{AbiParam, Block, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value}; pub(crate) use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; pub(crate) use cranelift_codegen::ir::function::Function; pub(crate) use cranelift_codegen::ir::types; + pub(crate) use cranelift_codegen::ir::{ + AbiParam, Block, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, + StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value, + }; pub(crate) use cranelift_codegen::isa::{self, CallConv}; + pub(crate) use cranelift_codegen::Context; pub(crate) use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; pub(crate) use cranelift_module::{ self, Backend, DataContext, DataId, FuncId, Linkage, Module, @@ -133,17 +143,10 @@ struct CodegenCx<'tcx, B: Backend + 'static> { } impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { - fn new( - tcx: TyCtxt<'tcx>, - module: Module, - debug_info: bool, - ) -> Self { + fn new(tcx: TyCtxt<'tcx>, module: Module, debug_info: bool) -> Self { let unwind_context = UnwindContext::new(tcx, module.isa()); let debug_context = if debug_info { - Some(DebugContext::new( - tcx, - module.isa(), - )) + Some(DebugContext::new(tcx, module.isa())) } else { None }; @@ -159,9 +162,21 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } } - fn finalize(mut self) -> (Module, String, Option>, UnwindContext<'tcx>) { + fn finalize( + mut self, + ) -> ( + Module, + String, + Option>, + UnwindContext<'tcx>, + ) { self.constants_cx.finalize(self.tcx, &mut self.module); - (self.module, self.global_asm, self.debug_context, self.unwind_context) + ( + self.module, + self.global_asm, + self.debug_context, + self.unwind_context, + ) } } @@ -220,7 +235,9 @@ impl CodegenBackend for CraneliftCodegenBackend { sess: &Session, dep_graph: &DepGraph, ) -> Result, ErrorReported> { - let (codegen_results, work_products) = *ongoing_codegen.downcast::<(CodegenResults, FxHashMap)>().unwrap(); + let (codegen_results, work_products) = *ongoing_codegen + .downcast::<(CodegenResults, FxHashMap)>() + .unwrap(); sess.time("serialize_work_products", move || { rustc_incremental::save_work_product_index(sess, &dep_graph, work_products) diff --git a/src/linkage.rs b/src/linkage.rs index 4307e3592b784..fe5d1d6444363 100644 --- a/src/linkage.rs +++ b/src/linkage.rs @@ -2,7 +2,11 @@ use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility}; use crate::prelude::*; -pub(crate) fn get_clif_linkage(mono_item: MonoItem<'_>, linkage: RLinkage, visibility: Visibility) -> Linkage { +pub(crate) fn get_clif_linkage( + mono_item: MonoItem<'_>, + linkage: RLinkage, + visibility: Visibility, +) -> Linkage { match (linkage, visibility) { (RLinkage::External, Visibility::Default) => Linkage::Export, (RLinkage::Internal, Visibility::Default) => Linkage::Local, diff --git a/src/main_shim.rs b/src/main_shim.rs index a256446df93c9..c31657d5f0ca8 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -26,7 +26,13 @@ pub(crate) fn maybe_create_entry_wrapper( return; } - create_entry_fn(tcx, module, unwind_context, main_def_id, use_start_lang_item); + create_entry_fn( + tcx, + module, + unwind_context, + main_def_id, + use_start_lang_item, + ); fn create_entry_fn( tcx: TyCtxt<'_>, @@ -114,7 +120,8 @@ pub(crate) fn maybe_create_entry_wrapper( cmain_func_id, &mut ctx, &mut cranelift_codegen::binemit::NullTrapSink {}, - ).unwrap(); + ) + .unwrap(); unwind_context.add_function(cmain_func_id, &ctx, m.isa()); } } diff --git a/src/metadata.rs b/src/metadata.rs index 052d7e4a27cce..67137b0fa3bcb 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -2,12 +2,12 @@ use std::convert::TryFrom; use std::fs::File; use std::path::Path; -use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; -use rustc_session::config; -use rustc_middle::ty::TyCtxt; use rustc_codegen_ssa::METADATA_FILENAME; use rustc_data_structures::owning_ref::{self, OwningRef}; use rustc_data_structures::rustc_erase_owner; +use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; +use rustc_middle::ty::TyCtxt; +use rustc_session::config; use rustc_target::spec::Target; use crate::backend::WriteMetadata; @@ -27,7 +27,7 @@ impl MetadataLoader for CraneliftMetadataLoader { if entry.header().identifier() == METADATA_FILENAME.as_bytes() { let mut buf = Vec::with_capacity( usize::try_from(entry.header().size()) - .expect("Rlib metadata file too big to load into memory.") + .expect("Rlib metadata file too big to load into memory."), ); ::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?; let buf: OwningRef, [u8]> = OwningRef::new(buf).into(); @@ -59,7 +59,10 @@ impl MetadataLoader for CraneliftMetadataLoader { } // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112 -pub(crate) fn write_metadata(tcx: TyCtxt<'_>, product: &mut P) -> EncodedMetadata { +pub(crate) fn write_metadata( + tcx: TyCtxt<'_>, + product: &mut P, +) -> EncodedMetadata { use flate2::write::DeflateEncoder; use flate2::Compression; use std::io::Write; diff --git a/src/num.rs b/src/num.rs index 22269b5ee29e5..60a4337111a8d 100644 --- a/src/num.rs +++ b/src/num.rs @@ -253,7 +253,11 @@ pub(crate) fn trans_checked_int_binop<'tcx>( let lhs = fx.bcx.ins().uextend(ty.double_width().unwrap(), lhs); let rhs = fx.bcx.ins().uextend(ty.double_width().unwrap(), rhs); let val = fx.bcx.ins().imul(lhs, rhs); - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, val, (1 << ty.bits()) - 1); + let has_overflow = fx.bcx.ins().icmp_imm( + IntCC::UnsignedGreaterThan, + val, + (1 << ty.bits()) - 1, + ); let val = fx.bcx.ins().ireduce(ty, val); (val, has_overflow) } @@ -261,8 +265,15 @@ pub(crate) fn trans_checked_int_binop<'tcx>( let lhs = fx.bcx.ins().sextend(ty.double_width().unwrap(), lhs); let rhs = fx.bcx.ins().sextend(ty.double_width().unwrap(), rhs); let val = fx.bcx.ins().imul(lhs, rhs); - let has_underflow = fx.bcx.ins().icmp_imm(IntCC::SignedLessThan, val, -(1 << (ty.bits() - 1))); - let has_overflow = fx.bcx.ins().icmp_imm(IntCC::SignedGreaterThan, val, (1 << (ty.bits() - 1)) - 1); + let has_underflow = + fx.bcx + .ins() + .icmp_imm(IntCC::SignedLessThan, val, -(1 << (ty.bits() - 1))); + let has_overflow = fx.bcx.ins().icmp_imm( + IntCC::SignedGreaterThan, + val, + (1 << (ty.bits() - 1)) - 1, + ); let val = fx.bcx.ins().ireduce(ty, val); (val, fx.bcx.ins().bor(has_underflow, has_overflow)) } @@ -275,12 +286,18 @@ pub(crate) fn trans_checked_int_binop<'tcx>( } else { let val_hi = fx.bcx.ins().smulhi(lhs, rhs); let not_all_zero = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, 0); - let not_all_ones = fx.bcx.ins().icmp_imm(IntCC::NotEqual, val_hi, u64::try_from((1u128 << ty.bits()) - 1).unwrap() as i64); + let not_all_ones = fx.bcx.ins().icmp_imm( + IntCC::NotEqual, + val_hi, + u64::try_from((1u128 << ty.bits()) - 1).unwrap() as i64, + ); fx.bcx.ins().band(not_all_zero, not_all_ones) }; (val, has_overflow) } - types::I128 => unreachable!("i128 should have been handled by codegen_i128::maybe_codegen"), + types::I128 => { + unreachable!("i128 should have been handled by codegen_i128::maybe_codegen") + } _ => unreachable!("invalid non-integer type {}", ty), } } @@ -291,8 +308,10 @@ pub(crate) fn trans_checked_int_binop<'tcx>( let val = fx.bcx.ins().ishl(lhs, actual_shift); let ty = fx.bcx.func.dfg.value_type(val); let max_shift = i64::from(ty.bits()) - 1; - let has_overflow = - fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift); + let has_overflow = fx + .bcx + .ins() + .icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift); (val, has_overflow) } BinOp::Shr => { @@ -306,8 +325,10 @@ pub(crate) fn trans_checked_int_binop<'tcx>( }; let ty = fx.bcx.func.dfg.value_type(val); let max_shift = i64::from(ty.bits()) - 1; - let has_overflow = - fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift); + let has_overflow = fx + .bcx + .ins() + .icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift); (val, has_overflow) } _ => bug!( @@ -323,7 +344,10 @@ pub(crate) fn trans_checked_int_binop<'tcx>( // FIXME directly write to result place instead let out_place = CPlace::new_stack_slot( fx, - fx.layout_of(fx.tcx.mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter())), + fx.layout_of( + fx.tcx + .mk_tup([in_lhs.layout().ty, fx.tcx.types.bool].iter()), + ), ); let out_layout = out_place.layout(); out_place.write_cvalue(fx, CValue::by_val_pair(res, has_overflow, out_layout)); @@ -382,9 +406,12 @@ pub(crate) fn trans_ptr_binop<'tcx>( in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, ) -> CValue<'tcx> { - let is_thin_ptr = in_lhs.layout().ty.builtin_deref(true).map(|TypeAndMut { ty, mutbl: _}| { - !has_ptr_meta(fx.tcx, ty) - }).unwrap_or(true); + let is_thin_ptr = in_lhs + .layout() + .ty + .builtin_deref(true) + .map(|TypeAndMut { ty, mutbl: _ }| !has_ptr_meta(fx.tcx, ty)) + .unwrap_or(true); if is_thin_ptr { match bin_op { diff --git a/src/optimize/code_layout.rs b/src/optimize/code_layout.rs index ca9ff15ec10ff..f02732014d1e3 100644 --- a/src/optimize/code_layout.rs +++ b/src/optimize/code_layout.rs @@ -15,7 +15,10 @@ pub(super) fn optimize_function(ctx: &mut Context, cold_blocks: &EntitySet>(); for &inst in &insts { ctx.func.layout.remove_inst(inst); @@ -25,7 +28,10 @@ pub(super) fn optimize_function(ctx: &mut Context, cold_blocks: &EntitySet( tcx: TyCtxt<'tcx>, - #[cfg_attr(not(debug_assertions), allow(unused_variables))] - instance: Instance<'tcx>, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] instance: Instance<'tcx>, ctx: &mut Context, cold_blocks: &EntitySet, clif_comments: &mut crate::pretty_clif::CommentWriter, diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index aceced41f2703..7c0bd2710a6ea 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -16,8 +16,8 @@ use std::ops::Not; use rustc_data_structures::fx::{FxHashSet, FxHasher}; use cranelift_codegen::cursor::{Cursor, FuncCursor}; -use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use cranelift_codegen::ir::immediates::Offset32; +use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; use hashbrown::HashSet; use std::hash::BuildHasherDefault; @@ -55,31 +55,41 @@ struct StackSlotUsage { impl StackSlotUsage { fn potential_stores_for_load(&self, ctx: &Context, load: Inst) -> Vec { - self.stack_store.iter().cloned().filter(|&store| { - match spatial_overlap(&ctx.func, store, load) { - SpatialOverlap::No => false, // Can never be the source of the loaded value. - SpatialOverlap::Partial | SpatialOverlap::Full => true, - } - }).filter(|&store| { - match temporal_order(ctx, store, load) { - TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. - TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, - } - }).collect::>() + self.stack_store + .iter() + .cloned() + .filter(|&store| { + match spatial_overlap(&ctx.func, store, load) { + SpatialOverlap::No => false, // Can never be the source of the loaded value. + SpatialOverlap::Partial | SpatialOverlap::Full => true, + } + }) + .filter(|&store| { + match temporal_order(ctx, store, load) { + TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. + TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, + } + }) + .collect::>() } fn potential_loads_of_store(&self, ctx: &Context, store: Inst) -> Vec { - self.stack_load.iter().cloned().filter(|&load| { - match spatial_overlap(&ctx.func, store, load) { - SpatialOverlap::No => false, // Can never be the source of the loaded value. - SpatialOverlap::Partial | SpatialOverlap::Full => true, - } - }).filter(|&load| { - match temporal_order(ctx, store, load) { - TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. - TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, - } - }).collect::>() + self.stack_load + .iter() + .cloned() + .filter(|&load| { + match spatial_overlap(&ctx.func, store, load) { + SpatialOverlap::No => false, // Can never be the source of the loaded value. + SpatialOverlap::Partial | SpatialOverlap::Full => true, + } + }) + .filter(|&load| { + match temporal_order(ctx, store, load) { + TemporalOrder::NeverBefore => false, // Can never be the source of the loaded value. + TemporalOrder::MaybeBefore | TemporalOrder::DefinitivelyBefore => true, + } + }) + .collect::>() } fn remove_unused_stack_addr(func: &mut Function, inst: Inst) { @@ -134,14 +144,22 @@ impl<'a> OptimizeContext<'a> { stack_slot, offset: _, } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_addr.insert(inst); + stack_slot_usage_map + .entry(OrdStackSlot(stack_slot)) + .or_insert_with(StackSlotUsage::default) + .stack_addr + .insert(inst); } InstructionData::StackLoad { opcode: Opcode::StackLoad, stack_slot, offset: _, } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_load.insert(inst); + stack_slot_usage_map + .entry(OrdStackSlot(stack_slot)) + .or_insert_with(StackSlotUsage::default) + .stack_load + .insert(inst); } InstructionData::StackStore { opcode: Opcode::StackStore, @@ -149,7 +167,11 @@ impl<'a> OptimizeContext<'a> { stack_slot, offset: _, } => { - stack_slot_usage_map.entry(OrdStackSlot(stack_slot)).or_insert_with(StackSlotUsage::default).stack_store.insert(inst); + stack_slot_usage_map + .entry(OrdStackSlot(stack_slot)) + .or_insert_with(StackSlotUsage::default) + .stack_store + .insert(inst); } _ => {} } @@ -165,7 +187,6 @@ impl<'a> OptimizeContext<'a> { pub(super) fn optimize_function( ctx: &mut Context, - #[cfg_attr(not(debug_assertions), allow(unused_variables))] clif_comments: &mut crate::pretty_clif::CommentWriter, ) { combine_stack_addr_with_load_store(&mut ctx.func); @@ -176,7 +197,8 @@ pub(super) fn optimize_function( remove_unused_stack_addr_and_stack_load(&mut opt_ctx); - #[cfg(debug_assertions)] { + #[cfg(debug_assertions)] + { for (&OrdStackSlot(stack_slot), usage) in &opt_ctx.stack_slot_usage_map { clif_comments.add_comment(stack_slot, format!("used by: {:?}", usage)); } @@ -194,13 +216,16 @@ pub(super) fn optimize_function( #[cfg(debug_assertions)] for &store in &potential_stores { - clif_comments.add_comment(load, format!( - "Potential store -> load forwarding {} -> {} ({:?}, {:?})", - opt_ctx.ctx.func.dfg.display_inst(store, None), - opt_ctx.ctx.func.dfg.display_inst(load, None), - spatial_overlap(&opt_ctx.ctx.func, store, load), - temporal_order(&opt_ctx.ctx, store, load), - )); + clif_comments.add_comment( + load, + format!( + "Potential store -> load forwarding {} -> {} ({:?}, {:?})", + opt_ctx.ctx.func.dfg.display_inst(store, None), + opt_ctx.ctx.func.dfg.display_inst(load, None), + spatial_overlap(&opt_ctx.ctx.func, store, load), + temporal_order(&opt_ctx.ctx, store, load), + ), + ); } match *potential_stores { @@ -208,12 +233,17 @@ pub(super) fn optimize_function( #[cfg(debug_assertions)] clif_comments.add_comment(load, format!("[BUG?] Reading uninitialized memory")); } - [store] if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full && temporal_order(&opt_ctx.ctx, store, load) == TemporalOrder::DefinitivelyBefore => { + [store] + if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full + && temporal_order(&opt_ctx.ctx, store, load) + == TemporalOrder::DefinitivelyBefore => + { // Only one store could have been the origin of the value. let stored_value = opt_ctx.ctx.func.dfg.inst_args(store)[0]; #[cfg(debug_assertions)] - clif_comments.add_comment(load, format!("Store to load forward {} -> {}", store, load)); + clif_comments + .add_comment(load, format!("Store to load forward {} -> {}", store, load)); users.change_load_to_alias(&mut opt_ctx.ctx.func, load, stored_value); } @@ -226,13 +256,16 @@ pub(super) fn optimize_function( #[cfg(debug_assertions)] for &load in &potential_loads { - clif_comments.add_comment(store, format!( - "Potential load from store {} <- {} ({:?}, {:?})", - opt_ctx.ctx.func.dfg.display_inst(load, None), - opt_ctx.ctx.func.dfg.display_inst(store, None), - spatial_overlap(&opt_ctx.ctx.func, store, load), - temporal_order(&opt_ctx.ctx, store, load), - )); + clif_comments.add_comment( + store, + format!( + "Potential load from store {} <- {} ({:?}, {:?})", + opt_ctx.ctx.func.dfg.display_inst(load, None), + opt_ctx.ctx.func.dfg.display_inst(store, None), + spatial_overlap(&opt_ctx.ctx.func, store, load), + temporal_order(&opt_ctx.ctx, store, load), + ), + ); } if potential_loads.is_empty() { @@ -240,7 +273,14 @@ pub(super) fn optimize_function( // FIXME also remove stores when there is always a next store before a load. #[cfg(debug_assertions)] - clif_comments.add_comment(store, format!("Remove dead stack store {} of {}", opt_ctx.ctx.func.dfg.display_inst(store, None), stack_slot.0)); + clif_comments.add_comment( + store, + format!( + "Remove dead stack store {} of {}", + opt_ctx.ctx.func.dfg.display_inst(store, None), + stack_slot.0 + ), + ); users.remove_dead_store(&mut opt_ctx.ctx.func, store); } @@ -258,24 +298,52 @@ fn combine_stack_addr_with_load_store(func: &mut Function) { while let Some(_block) = cursor.next_block() { while let Some(inst) = cursor.next_inst() { match cursor.func.dfg[inst] { - InstructionData::Load { opcode: Opcode::Load, arg: addr, flags: _, offset } => { - if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { + InstructionData::Load { + opcode: Opcode::Load, + arg: addr, + flags: _, + offset, + } => { + if cursor.func.dfg.ctrl_typevar(inst) == types::I128 + || cursor.func.dfg.ctrl_typevar(inst).is_vector() + { continue; // WORKAROUD: stack_load.i128 not yet implemented } - if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { - if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { + if let Some((stack_slot, stack_addr_offset)) = + try_get_stack_slot_and_offset_for_addr(cursor.func, addr) + { + if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) + { let ty = cursor.func.dfg.ctrl_typevar(inst); - cursor.func.dfg.replace(inst).stack_load(ty, stack_slot, combined_offset); + cursor.func.dfg.replace(inst).stack_load( + ty, + stack_slot, + combined_offset, + ); } } } - InstructionData::Store { opcode: Opcode::Store, args: [value, addr], flags: _, offset } => { - if cursor.func.dfg.ctrl_typevar(inst) == types::I128 || cursor.func.dfg.ctrl_typevar(inst).is_vector() { + InstructionData::Store { + opcode: Opcode::Store, + args: [value, addr], + flags: _, + offset, + } => { + if cursor.func.dfg.ctrl_typevar(inst) == types::I128 + || cursor.func.dfg.ctrl_typevar(inst).is_vector() + { continue; // WORKAROUND: stack_store.i128 not yet implemented } - if let Some((stack_slot, stack_addr_offset)) = try_get_stack_slot_and_offset_for_addr(cursor.func, addr) { - if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) { - cursor.func.dfg.replace(inst).stack_store(value, stack_slot, combined_offset); + if let Some((stack_slot, stack_addr_offset)) = + try_get_stack_slot_and_offset_for_addr(cursor.func, addr) + { + if let Some(combined_offset) = offset.try_add_i64(stack_addr_offset.into()) + { + cursor.func.dfg.replace(inst).stack_store( + value, + stack_slot, + combined_offset, + ); } } } @@ -296,7 +364,10 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { if let ValueDef::Result(arg_origin, 0) = cursor.func.dfg.value_def(arg) { match cursor.func.dfg[arg_origin].opcode() { Opcode::StackAddr | Opcode::StackLoad => { - stack_addr_load_insts_users.entry(arg_origin).or_insert_with(FxHashSet::default).insert(inst); + stack_addr_load_insts_users + .entry(arg_origin) + .or_insert_with(FxHashSet::default) + .insert(inst); } _ => {} } @@ -309,7 +380,8 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { for inst in stack_addr_load_insts_users.keys() { let mut is_recorded_stack_addr_or_stack_load = false; for stack_slot_users in opt_ctx.stack_slot_usage_map.values() { - is_recorded_stack_addr_or_stack_load |= stack_slot_users.stack_addr.contains(inst) || stack_slot_users.stack_load.contains(inst); + is_recorded_stack_addr_or_stack_load |= stack_slot_users.stack_addr.contains(inst) + || stack_slot_users.stack_load.contains(inst); } assert!(is_recorded_stack_addr_or_stack_load); } @@ -323,23 +395,37 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { stack_slot_users .stack_addr - .drain_filter(|inst| !(stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))) + .drain_filter(|inst| { + !(stack_addr_load_insts_users + .get(inst) + .map(|users| users.is_empty()) + .unwrap_or(true)) + }) .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, inst)); stack_slot_users .stack_load - .drain_filter(|inst| !(stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))) + .drain_filter(|inst| { + !(stack_addr_load_insts_users + .get(inst) + .map(|users| users.is_empty()) + .unwrap_or(true)) + }) .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, inst)); } } -fn try_get_stack_slot_and_offset_for_addr(func: &Function, addr: Value) -> Option<(StackSlot, Offset32)> { +fn try_get_stack_slot_and_offset_for_addr( + func: &Function, + addr: Value, +) -> Option<(StackSlot, Offset32)> { if let ValueDef::Result(addr_inst, 0) = func.dfg.value_def(addr) { if let InstructionData::StackLoad { opcode: Opcode::StackAddr, stack_slot, offset, - } = func.dfg[addr_inst] { + } = func.dfg[addr_inst] + { return Some((stack_slot, offset)); } } @@ -390,7 +476,10 @@ fn spatial_overlap(func: &Function, src: Inst, dest: Inst) -> SpatialOverlap { } let src_end: i64 = src_offset.try_add_i64(i64::from(src_size)).unwrap().into(); - let dest_end: i64 = dest_offset.try_add_i64(i64::from(dest_size)).unwrap().into(); + let dest_end: i64 = dest_offset + .try_add_i64(i64::from(dest_size)) + .unwrap() + .into(); if src_end <= dest_offset.into() || dest_end <= src_offset.into() { return SpatialOverlap::No; } diff --git a/src/pointer.rs b/src/pointer.rs index a338e2b0197e8..5295b296cde5a 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -32,7 +32,10 @@ impl Pointer { } } - pub(crate) fn const_addr<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, addr: i64) -> Self { + pub(crate) fn const_addr<'a, 'tcx>( + fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + addr: i64, + ) -> Self { let addr = fx.bcx.ins().iconst(fx.pointer_type, addr); Pointer { base: PointerBase::Addr(addr), @@ -62,10 +65,15 @@ impl Pointer { fx.bcx.ins().iadd_imm(base_addr, offset) } } - PointerBase::Stack(stack_slot) => fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, self.offset), - PointerBase::Dangling(align) => { - fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()) + PointerBase::Stack(stack_slot) => { + fx.bcx + .ins() + .stack_addr(fx.pointer_type, stack_slot, self.offset) } + PointerBase::Dangling(align) => fx + .bcx + .ins() + .iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()), } } @@ -89,11 +97,16 @@ impl Pointer { } } else { let base_offset: i64 = self.offset.into(); - if let Some(new_offset) = base_offset.checked_add(extra_offset){ + if let Some(new_offset) = base_offset.checked_add(extra_offset) { let base_addr = match self.base { PointerBase::Addr(addr) => addr, - PointerBase::Stack(stack_slot) => fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0), - PointerBase::Dangling(align) => fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()), + PointerBase::Stack(stack_slot) => { + fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0) + } + PointerBase::Dangling(align) => fx + .bcx + .ins() + .iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()), }; let addr = fx.bcx.ins().iadd_imm(base_addr, new_offset); Pointer { @@ -101,7 +114,10 @@ impl Pointer { offset: Offset32::new(0), } } else { - panic!("self.offset ({}) + extra_offset ({}) not representable in i64", base_offset, extra_offset); + panic!( + "self.offset ({}) + extra_offset ({}) not representable in i64", + base_offset, extra_offset + ); } } } @@ -117,14 +133,20 @@ impl Pointer { offset: self.offset, }, PointerBase::Stack(stack_slot) => { - let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, self.offset); + let base_addr = fx + .bcx + .ins() + .stack_addr(fx.pointer_type, stack_slot, self.offset); Pointer { base: PointerBase::Addr(fx.bcx.ins().iadd(base_addr, extra_offset)), offset: Offset32::new(0), } } PointerBase::Dangling(align) => { - let addr = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()); + let addr = fx + .bcx + .ins() + .iconst(fx.pointer_type, i64::try_from(align.bytes()).unwrap()); Pointer { base: PointerBase::Addr(fx.bcx.ins().iadd(addr, extra_offset)), offset: self.offset, @@ -141,12 +163,14 @@ impl Pointer { ) -> Value { match self.base { PointerBase::Addr(base_addr) => fx.bcx.ins().load(ty, flags, base_addr, self.offset), - PointerBase::Stack(stack_slot) => if ty == types::I128 || ty.is_vector() { - // WORKAROUND for stack_load.i128 and stack_load.iXxY not being implemented - let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); - fx.bcx.ins().load(ty, flags, base_addr, self.offset) - } else { - fx.bcx.ins().stack_load(ty, stack_slot, self.offset) + PointerBase::Stack(stack_slot) => { + if ty == types::I128 || ty.is_vector() { + // WORKAROUND for stack_load.i128 and stack_load.iXxY not being implemented + let base_addr = fx.bcx.ins().stack_addr(fx.pointer_type, stack_slot, 0); + fx.bcx.ins().load(ty, flags, base_addr, self.offset) + } else { + fx.bcx.ins().stack_load(ty, stack_slot, self.offset) + } } PointerBase::Dangling(_align) => unreachable!(), } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index ef48a9f358ecc..6d8d085529c46 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -196,7 +196,7 @@ impl FunctionCx<'_, '_, B> { entity: E, comment: S, ) { - self.clif_comments.add_comment(entity, comment); + self.clif_comments.add_comment(entity, comment); } } @@ -210,7 +210,13 @@ pub(crate) fn write_clif_file<'tcx>( ) { use std::io::Write; - if !cfg!(debug_assertions) && !tcx.sess.opts.output_types.contains_key(&OutputType::LlvmAssembly) { + if !cfg!(debug_assertions) + && !tcx + .sess + .opts + .output_types + .contains_key(&OutputType::LlvmAssembly) + { return; } diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index 04c8fde48d8d5..a5d9b5e751a20 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -107,8 +107,10 @@ const POWERPC_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("vsx", Some(sym::powerpc_target_feature)), ]; -const MIPS_ALLOWED_FEATURES: &[(&str, Option)] = - &[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))]; +const MIPS_ALLOWED_FEATURES: &[(&str, Option)] = &[ + ("fp64", Some(sym::mips_target_feature)), + ("msa", Some(sym::mips_target_feature)), +]; const RISCV_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("m", Some(sym::riscv_target_feature)), diff --git a/src/toolchain.rs b/src/toolchain.rs index 2a31b8834384b..121f4477b80e0 100644 --- a/src/toolchain.rs +++ b/src/toolchain.rs @@ -7,9 +7,10 @@ use rustc_target::spec::LinkerFlavor; /// Tries to infer the path of a binary for the target toolchain from the linker name. pub(crate) fn get_toolchain_binary(sess: &Session, tool: &str) -> PathBuf { let (mut linker, _linker_flavor) = linker_and_flavor(sess); - let linker_file_name = linker.file_name().and_then(|name| name.to_str()).unwrap_or_else(|| { - sess.fatal("couldn't extract file name from specified linker") - }); + let linker_file_name = linker + .file_name() + .and_then(|name| name.to_str()) + .unwrap_or_else(|| sess.fatal("couldn't extract file name from specified linker")); if linker_file_name == "ld.lld" { if tool != "ld" { @@ -68,9 +69,12 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { flavor, )), (Some(linker), None) => { - let stem = linker.file_stem().and_then(|stem| stem.to_str()).unwrap_or_else(|| { - sess.fatal("couldn't extract file stem from specified linker") - }); + let stem = linker + .file_stem() + .and_then(|stem| stem.to_str()) + .unwrap_or_else(|| { + sess.fatal("couldn't extract file stem from specified linker") + }); let flavor = if stem == "emcc" { LinkerFlavor::Em @@ -99,7 +103,11 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { // linker and linker flavor specified via command line have precedence over what the target // specification specifies - if let Some(ret) = infer_from(sess, sess.opts.cg.linker.clone(), sess.opts.cg.linker_flavor) { + if let Some(ret) = infer_from( + sess, + sess.opts.cg.linker.clone(), + sess.opts.cg.linker_flavor, + ) { return ret; } diff --git a/src/trap.rs b/src/trap.rs index 05be1d1706b7d..e69e63e4d49e9 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -2,7 +2,8 @@ use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { let puts = fx - .cx.module + .cx + .module .declare_function( "puts", Linkage::Import, diff --git a/src/value_and_place.rs b/src/value_and_place.rs index a48cc6600b4a6..847c5fc787002 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -33,7 +33,8 @@ fn codegen_field<'tcx>( _ => { // We have to align the offset for DST's let unaligned_offset = field_offset.bytes(); - let (_, unsized_align) = crate::unsize::size_and_align_of_dst(fx, field_layout, extra); + let (_, unsized_align) = + crate::unsize::size_and_align_of_dst(fx, field_layout, extra); let one = fx.bcx.ins().iconst(pointer_ty(fx.tcx), 1); let align_sub_1 = fx.bcx.ins().isub(unsized_align, one); @@ -42,10 +43,7 @@ fn codegen_field<'tcx>( let and_rhs = fx.bcx.ins().isub(zero, unsized_align); let offset = fx.bcx.ins().band(and_lhs, and_rhs); - ( - base.offset_value(fx, offset), - field_layout, - ) + (base.offset_value(fx, offset), field_layout) } } } else { @@ -53,7 +51,11 @@ fn codegen_field<'tcx>( } } -fn scalar_pair_calculate_b_offset(tcx: TyCtxt<'_>, a_scalar: &Scalar, b_scalar: &Scalar) -> Offset32 { +fn scalar_pair_calculate_b_offset( + tcx: TyCtxt<'_>, + a_scalar: &Scalar, + b_scalar: &Scalar, +) -> Offset32 { let b_offset = a_scalar .value .size(&tcx) @@ -77,7 +79,11 @@ impl<'tcx> CValue<'tcx> { CValue(CValueInner::ByRef(ptr, None), layout) } - pub(crate) fn by_ref_unsized(ptr: Pointer, meta: Value, layout: TyAndLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_ref_unsized( + ptr: Pointer, + meta: Value, + layout: TyAndLayout<'tcx>, + ) -> CValue<'tcx> { CValue(CValueInner::ByRef(ptr, Some(meta)), layout) } @@ -85,7 +91,11 @@ impl<'tcx> CValue<'tcx> { CValue(CValueInner::ByVal(value), layout) } - pub(crate) fn by_val_pair(value: Value, extra: Value, layout: TyAndLayout<'tcx>) -> CValue<'tcx> { + pub(crate) fn by_val_pair( + value: Value, + extra: Value, + layout: TyAndLayout<'tcx>, + ) -> CValue<'tcx> { CValue(CValueInner::ByValPair(value, extra), layout) } @@ -94,7 +104,10 @@ impl<'tcx> CValue<'tcx> { } // FIXME remove - pub(crate) fn force_stack(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> (Pointer, Option) { + pub(crate) fn force_stack( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + ) -> (Pointer, Option) { let layout = self.1; match self.0 { CValueInner::ByRef(ptr, meta) => (ptr, meta), @@ -122,7 +135,8 @@ impl<'tcx> CValue<'tcx> { Abi::Scalar(ref scalar) => scalar_to_clif_type(fx.tcx, scalar.clone()), Abi::Vector { ref element, count } => { scalar_to_clif_type(fx.tcx, element.clone()) - .by(u16::try_from(count).unwrap()).unwrap() + .by(u16::try_from(count).unwrap()) + .unwrap() } _ => unreachable!("{:?}", layout.ty), }; @@ -153,7 +167,9 @@ impl<'tcx> CValue<'tcx> { let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); (val1, val2) } - CValueInner::ByRef(_, Some(_)) => bug!("load_scalar_pair for unsized value not allowed"), + CValueInner::ByRef(_, Some(_)) => { + bug!("load_scalar_pair for unsized value not allowed") + } CValueInner::ByVal(_) => bug!("Please use load_scalar for ByVal"), CValueInner::ByValPair(val1, val2) => (val1, val2), } @@ -166,33 +182,29 @@ impl<'tcx> CValue<'tcx> { ) -> CValue<'tcx> { let layout = self.1; match self.0 { - CValueInner::ByVal(val) => { - match layout.abi { - Abi::Vector { element: _, count } => { - let count = u8::try_from(count).expect("SIMD type with more than 255 lanes???"); - let field = u8::try_from(field.index()).unwrap(); - assert!(field < count); - let lane = fx.bcx.ins().extractlane(val, field); - let field_layout = layout.field(&*fx, usize::from(field)); - CValue::by_val(lane, field_layout) - } - _ => unreachable!("value_field for ByVal with abi {:?}", layout.abi), + CValueInner::ByVal(val) => match layout.abi { + Abi::Vector { element: _, count } => { + let count = u8::try_from(count).expect("SIMD type with more than 255 lanes???"); + let field = u8::try_from(field.index()).unwrap(); + assert!(field < count); + let lane = fx.bcx.ins().extractlane(val, field); + let field_layout = layout.field(&*fx, usize::from(field)); + CValue::by_val(lane, field_layout) } - } - CValueInner::ByValPair(val1, val2) => { - match layout.abi { - Abi::ScalarPair(_, _) => { - let val = match field.as_u32() { - 0 => val1, - 1 => val2, - _ => bug!("field should be 0 or 1"), - }; - let field_layout = layout.field(&*fx, usize::from(field)); - CValue::by_val(val, field_layout) - } - _ => unreachable!("value_field for ByValPair with abi {:?}", layout.abi), + _ => unreachable!("value_field for ByVal with abi {:?}", layout.abi), + }, + CValueInner::ByValPair(val1, val2) => match layout.abi { + Abi::ScalarPair(_, _) => { + let val = match field.as_u32() { + 0 => val1, + 1 => val2, + _ => bug!("field should be 0 or 1"), + }; + let field_layout = layout.field(&*fx, usize::from(field)); + CValue::by_val(val, field_layout) } - } + _ => unreachable!("value_field for ByValPair with abi {:?}", layout.abi), + }, CValueInner::ByRef(ptr, None) => { let (field_ptr, field_layout) = codegen_field(fx, ptr, None, layout, field); CValue::by_ref(field_ptr, field_layout) @@ -201,7 +213,11 @@ impl<'tcx> CValue<'tcx> { } } - pub(crate) fn unsize_value(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) { + pub(crate) fn unsize_value( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + dest: CPlace<'tcx>, + ) { crate::unsize::coerce_unsized_into(fx, self, dest); } @@ -217,7 +233,11 @@ impl<'tcx> CValue<'tcx> { match layout.ty.kind { ty::Bool => { - assert!(const_val == 0 || const_val == 1, "Invalid bool 0x{:032X}", const_val); + assert!( + const_val == 0 || const_val == 1, + "Invalid bool 0x{:032X}", + const_val + ); } _ => {} } @@ -254,8 +274,14 @@ impl<'tcx> CValue<'tcx> { } pub(crate) fn cast_pointer_to(self, layout: TyAndLayout<'tcx>) -> Self { - assert!(matches!(self.layout().ty.kind, ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..))); - assert!(matches!(layout.ty.kind, ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..))); + assert!(matches!( + self.layout().ty.kind, + ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) + )); + assert!(matches!( + layout.ty.kind, + ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) + )); assert_eq!(self.layout().abi, layout.abi); CValue(self.0, layout) } @@ -319,8 +345,7 @@ impl<'tcx> CPlace<'tcx> { ) -> CPlace<'tcx> { let var = Variable::with_u32(fx.next_ssa_var); fx.next_ssa_var += 1; - fx.bcx - .declare_var(var, fx.clif_type(layout.ty).unwrap()); + fx.bcx.declare_var(var, fx.clif_type(layout.ty).unwrap()); CPlace { inner: CPlaceInner::Var(local, var), layout, @@ -353,7 +378,11 @@ impl<'tcx> CPlace<'tcx> { } } - pub(crate) fn for_ptr_with_extra(ptr: Pointer, extra: Value, layout: TyAndLayout<'tcx>) -> CPlace<'tcx> { + pub(crate) fn for_ptr_with_extra( + ptr: Pointer, + extra: Value, + layout: TyAndLayout<'tcx>, + ) -> CPlace<'tcx> { CPlace { inner: CPlaceInner::Addr(ptr, Some(extra)), layout, @@ -365,19 +394,23 @@ impl<'tcx> CPlace<'tcx> { match self.inner { CPlaceInner::Var(_local, var) => { let val = fx.bcx.use_var(var); - fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx + .set_val_label(val, cranelift_codegen::ir::ValueLabel::new(var.index())); CValue::by_val(val, layout) } CPlaceInner::VarPair(_local, var1, var2) => { let val1 = fx.bcx.use_var(var1); - fx.bcx.set_val_label(val1, cranelift_codegen::ir::ValueLabel::new(var1.index())); + fx.bcx + .set_val_label(val1, cranelift_codegen::ir::ValueLabel::new(var1.index())); let val2 = fx.bcx.use_var(var2); - fx.bcx.set_val_label(val2, cranelift_codegen::ir::ValueLabel::new(var2.index())); + fx.bcx + .set_val_label(val2, cranelift_codegen::ir::ValueLabel::new(var2.index())); CValue::by_val_pair(val1, val2, layout) } CPlaceInner::VarLane(_local, var, lane) => { let val = fx.bcx.use_var(var); - fx.bcx.set_val_label(val, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx + .set_val_label(val, cranelift_codegen::ir::ValueLabel::new(var.index())); let val = fx.bcx.ins().extractlane(val, lane); CValue::by_val(val, layout) } @@ -407,7 +440,11 @@ impl<'tcx> CPlace<'tcx> { } } - pub(crate) fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) { + pub(crate) fn write_cvalue( + self, + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + from: CValue<'tcx>, + ) { fn assert_assignable<'tcx>( fx: &FunctionCx<'_, 'tcx, impl Backend>, from_ty: Ty<'tcx>, @@ -415,7 +452,10 @@ impl<'tcx> CPlace<'tcx> { ) { match (&from_ty.kind, &to_ty.kind) { (ty::Ref(_, a, _), ty::Ref(_, b, _)) - | (ty::RawPtr(TypeAndMut { ty: a, mutbl: _}), ty::RawPtr(TypeAndMut { ty: b, mutbl: _})) => { + | ( + ty::RawPtr(TypeAndMut { ty: a, mutbl: _ }), + ty::RawPtr(TypeAndMut { ty: b, mutbl: _ }), + ) => { assert_assignable(fx, a, b); } (ty::FnPtr(_), ty::FnPtr(_)) => { @@ -478,8 +518,7 @@ impl<'tcx> CPlace<'tcx> { self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>, - #[cfg_attr(not(debug_assertions), allow(unused_variables))] - method: &'static str, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] method: &'static str, ) { fn transmute_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, @@ -492,16 +531,17 @@ impl<'tcx> CPlace<'tcx> { (_, _) if src_ty == dst_ty => data, // This is a `write_cvalue_transmute`. - (types::I32, types::F32) | (types::F32, types::I32) - | (types::I64, types::F64) | (types::F64, types::I64) => { - fx.bcx.ins().bitcast(dst_ty, data) - } + (types::I32, types::F32) + | (types::F32, types::I32) + | (types::I64, types::F64) + | (types::F64, types::I64) => fx.bcx.ins().bitcast(dst_ty, data), _ if src_ty.is_vector() && dst_ty.is_vector() => { fx.bcx.ins().raw_bitcast(dst_ty, data) } _ => unreachable!("write_cvalue_transmute: {:?} -> {:?}", src_ty, dst_ty), }; - fx.bcx.set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx + .set_val_label(data, cranelift_codegen::ir::ValueLabel::new(var.index())); fx.bcx.def_var(var, data); } @@ -516,7 +556,14 @@ impl<'tcx> CPlace<'tcx> { }; fx.add_comment( fx.bcx.func.layout.last_inst(cur_block).unwrap(), - format!("{}: {:?}: {:?} <- {:?}: {:?}", method, self.inner(), self.layout().ty, from.0, from.layout().ty), + format!( + "{}: {:?}: {:?} <- {:?}: {:?}", + method, + self.inner(), + self.layout().ty, + from.0, + from.layout().ty + ), ); } @@ -540,13 +587,15 @@ impl<'tcx> CPlace<'tcx> { // First get the old vector let vector = fx.bcx.use_var(var); - fx.bcx.set_val_label(vector, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx + .set_val_label(vector, cranelift_codegen::ir::ValueLabel::new(var.index())); // Next insert the written lane into the vector let vector = fx.bcx.ins().insertlane(vector, data, lane); // Finally write the new vector - fx.bcx.set_val_label(vector, cranelift_codegen::ir::ValueLabel::new(var.index())); + fx.bcx + .set_val_label(vector, cranelift_codegen::ir::ValueLabel::new(var.index())); fx.bcx.def_var(var, vector); return; @@ -571,7 +620,9 @@ impl<'tcx> CPlace<'tcx> { let (value, extra) = from.load_scalar_pair(fx); let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); to_ptr.store(fx, value, MemFlags::new()); - to_ptr.offset(fx, b_offset).store(fx, extra, MemFlags::new()); + to_ptr + .offset(fx, b_offset) + .store(fx, extra, MemFlags::new()); return; } _ => {} @@ -628,14 +679,18 @@ impl<'tcx> CPlace<'tcx> { let layout = layout.field(&*fx, field.index()); match field.as_u32() { - 0 => return CPlace { - inner: CPlaceInner::Var(local, var1), - layout, - }, - 1 => return CPlace { - inner: CPlaceInner::Var(local, var2), - layout, - }, + 0 => { + return CPlace { + inner: CPlaceInner::Var(local, var1), + layout, + } + } + 1 => { + return CPlace { + inner: CPlaceInner::Var(local, var2), + layout, + } + } _ => unreachable!("field should be 0 or 1"), } } @@ -677,7 +732,10 @@ impl<'tcx> CPlace<'tcx> { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); CPlace::for_ptr_with_extra(Pointer::new(addr), extra, inner_layout) } else { - CPlace::for_ptr(Pointer::new(self.to_cvalue(fx).load_scalar(fx)), inner_layout) + CPlace::for_ptr( + Pointer::new(self.to_cvalue(fx).load_scalar(fx)), + inner_layout, + ) } } diff --git a/src/vtable.rs b/src/vtable.rs index 686d23c5d4be7..d23b077148e59 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -51,10 +51,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( arg.load_scalar_pair(fx) } else { let (ptr, vtable) = arg.try_to_ptr().unwrap(); - ( - ptr.get_addr(fx), - vtable.unwrap() - ) + (ptr.get_addr(fx), vtable.unwrap()) }; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes(); @@ -92,8 +89,11 @@ fn build_vtable<'tcx>( let tcx = fx.tcx; let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; - let drop_in_place_fn = - import_function(tcx, &mut fx.cx.module, Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.tcx)); + let drop_in_place_fn = import_function( + tcx, + &mut fx.cx.module, + Instance::resolve_drop_in_place(tcx, layout.ty).polymorphize(fx.tcx), + ); let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None]; @@ -109,7 +109,9 @@ fn build_vtable<'tcx>( Some(import_function( tcx, &mut fx.cx.module, - Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs).unwrap().polymorphize(fx.tcx), + Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs) + .unwrap() + .polymorphize(fx.tcx), )) }) }); @@ -133,7 +135,8 @@ fn build_vtable<'tcx>( } let data_id = fx - .cx.module + .cx + .module .declare_data( &format!( "__vtable.{}.for.{:?}.{}", From 9c848e19057fd3460bf703687ad371785032bac8 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Fri, 28 Aug 2020 12:20:24 +0200 Subject: [PATCH 1488/1566] fmt: Skip fn_sig_for_fn_abi() --- src/abi/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index c09c70175e503..fa91fef9eeeda 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -14,10 +14,8 @@ use crate::prelude::*; pub(crate) use self::returning::{can_return_to_ssa_var, codegen_return}; // Copied from https://github.com/rust-lang/rust/blob/f52c72948aa1dd718cc1f168d21c91c584c0a662/src/librustc_middle/ty/layout.rs#L2301 -pub(crate) fn fn_sig_for_fn_abi<'tcx>( - tcx: TyCtxt<'tcx>, - instance: Instance<'tcx>, -) -> ty::PolyFnSig<'tcx> { +#[rustfmt::skip] +pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty::PolyFnSig<'tcx> { use rustc_middle::ty::subst::Subst; // FIXME(davidtwco,eddyb): A `ParamEnv` should be passed through to this function. @@ -73,10 +71,10 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>( let env_ty = tcx.mk_adt(pin_adt_ref, pin_substs); sig.map_bound(|sig| { - let state_did = - tcx.require_lang_item(rustc_hir::LangItem::GeneratorStateLangItem, None); + let state_did = tcx.require_lang_item(rustc_hir::LangItem::GeneratorStateLangItem, None); let state_adt_ref = tcx.adt_def(state_did); - let state_substs = tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]); + let state_substs = + tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]); let ret_ty = tcx.mk_adt(state_adt_ref, state_substs); tcx.mk_fn_sig( From ed35bc8414f3b78c3f9a9bda221d8a750bd99476 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Fri, 28 Aug 2020 12:23:01 +0200 Subject: [PATCH 1489/1566] fmt: Skip src/target_features_whitelist.rs --- src/target_features_whitelist.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index a5d9b5e751a20..6fd032b4324a2 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -1,3 +1,5 @@ +#[rustfmt::skip] + use rustc_span::symbol::{sym, Symbol}; use rustc_session::Session; @@ -107,10 +109,8 @@ const POWERPC_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("vsx", Some(sym::powerpc_target_feature)), ]; -const MIPS_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("fp64", Some(sym::mips_target_feature)), - ("msa", Some(sym::mips_target_feature)), -]; +const MIPS_ALLOWED_FEATURES: &[(&str, Option)] = + &[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))]; const RISCV_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("m", Some(sym::riscv_target_feature)), From 365cebf779db2baee8fed65a4f01f4f3a356a6b8 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Fri, 28 Aug 2020 12:26:52 +0200 Subject: [PATCH 1490/1566] optimize: Remove conditional compilation on instance Co-authored-by: bjorn3 --- src/optimize/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 7ce6daee20514..33d75b36d9651 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -5,7 +5,7 @@ mod stack2reg; pub(crate) fn optimize_function<'tcx>( tcx: TyCtxt<'tcx>, - #[cfg_attr(not(debug_assertions), allow(unused_variables))] instance: Instance<'tcx>, + instance: Instance<'tcx>, ctx: &mut Context, cold_blocks: &EntitySet, clif_comments: &mut crate::pretty_clif::CommentWriter, From fc9f16bf0e056258f40e36d0afc2cc285ef08639 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Fri, 28 Aug 2020 12:28:55 +0200 Subject: [PATCH 1491/1566] fmt: Skip whole module with bang Co-authored-by: bjorn3 --- src/target_features_whitelist.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index 6fd032b4324a2..527522fca703d 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -1,4 +1,4 @@ -#[rustfmt::skip] +#![rustfmt::skip] use rustc_span::symbol::{sym, Symbol}; From a8e3f592c9ccbc49bf95c33dec8c2d4852a3faee Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 30 Aug 2020 11:14:11 +0200 Subject: [PATCH 1492/1566] Set notrap flag on loads and stores --- src/value_and_place.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 847c5fc787002..3e0d84387f3fd 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -140,7 +140,9 @@ impl<'tcx> CValue<'tcx> { } _ => unreachable!("{:?}", layout.ty), }; - ptr.load(fx, clif_ty, MemFlags::new()) + let mut flags = MemFlags::new(); + flags.set_notrap(); + ptr.load(fx, clif_ty, flags) } CValueInner::ByVal(value) => value, CValueInner::ByRef(_, Some(_)) => bug!("load_scalar for unsized value not allowed"), @@ -163,8 +165,10 @@ impl<'tcx> CValue<'tcx> { let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone()); let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone()); - let val1 = ptr.load(fx, clif_ty1, MemFlags::new()); - let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, MemFlags::new()); + let mut flags = MemFlags::new(); + flags.set_notrap(); + let val1 = ptr.load(fx, clif_ty1, flags); + let val2 = ptr.offset(fx, b_offset).load(fx, clif_ty2, flags); (val1, val2) } CValueInner::ByRef(_, Some(_)) => { @@ -609,20 +613,20 @@ impl<'tcx> CPlace<'tcx> { CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self), }; + let mut flags = MemFlags::new(); + flags.set_notrap(); match from.layout().abi { // FIXME make Abi::Vector work too Abi::Scalar(_) => { let val = from.load_scalar(fx); - to_ptr.store(fx, val, MemFlags::new()); + to_ptr.store(fx, val, flags); return; } Abi::ScalarPair(ref a_scalar, ref b_scalar) => { let (value, extra) = from.load_scalar_pair(fx); let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar); - to_ptr.store(fx, value, MemFlags::new()); - to_ptr - .offset(fx, b_offset) - .store(fx, extra, MemFlags::new()); + to_ptr.store(fx, value, flags); + to_ptr.offset(fx, b_offset).store(fx, extra, flags); return; } _ => {} @@ -630,7 +634,7 @@ impl<'tcx> CPlace<'tcx> { match from.0 { CValueInner::ByVal(val) => { - to_ptr.store(fx, val, MemFlags::new()); + to_ptr.store(fx, val, flags); } CValueInner::ByValPair(_, _) => { bug!( From 3b0f3a0a1e25e2ac207c99492fd2a0f6fc356f35 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 30 Aug 2020 13:02:53 +0200 Subject: [PATCH 1493/1566] Optimize SwitchInt for bools --- src/base.rs | 42 ++++++++++++++++---- src/optimize/mod.rs | 1 + src/optimize/peephole.rs | 83 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 7 deletions(-) create mode 100644 src/optimize/peephole.rs diff --git a/src/base.rs b/src/base.rs index 342c12ffc4118..01f7ecd86f49f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -110,6 +110,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( context.compute_cfg(); context.compute_domtree(); context.eliminate_unreachable_code(cx.module.isa()).unwrap(); + context.dce(cx.module.isa()).unwrap(); // Define function let module = &mut cx.module; @@ -315,18 +316,45 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { TerminatorKind::SwitchInt { discr, - switch_ty: _, + switch_ty, values, targets, } => { let discr = trans_operand(fx, discr).load_scalar(fx); - let mut switch = ::cranelift_frontend::Switch::new(); - for (i, value) in values.iter().enumerate() { - let block = fx.get_block(targets[i]); - switch.set_entry(*value, block); + + if switch_ty.kind == fx.tcx.types.bool.kind { + assert_eq!(targets.len(), 2); + let then_block = fx.get_block(targets[0]); + let else_block = fx.get_block(targets[1]); + let test_zero = match **values { + [0] => true, + [1] => false, + _ => unreachable!("{:?}", values), + }; + + let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr); + let (discr, is_inverted) = + crate::optimize::peephole::maybe_unwrap_bool_not(&mut fx.bcx, discr); + let test_zero = if is_inverted { !test_zero } else { test_zero }; + let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr); + let discr = + crate::optimize::peephole::make_branchable_value(&mut fx.bcx, discr); + if test_zero { + fx.bcx.ins().brz(discr, then_block, &[]); + fx.bcx.ins().jump(else_block, &[]); + } else { + fx.bcx.ins().brnz(discr, then_block, &[]); + fx.bcx.ins().jump(else_block, &[]); + } + } else { + let mut switch = ::cranelift_frontend::Switch::new(); + for (i, value) in values.iter().enumerate() { + let block = fx.get_block(targets[i]); + switch.set_entry(*value, block); + } + let otherwise_block = fx.get_block(targets[targets.len() - 1]); + switch.emit(&mut fx.bcx, discr, otherwise_block); } - let otherwise_block = fx.get_block(targets[targets.len() - 1]); - switch.emit(&mut fx.bcx, discr, otherwise_block); } TerminatorKind::Call { func, diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 33d75b36d9651..ae9692790896c 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -1,6 +1,7 @@ use crate::prelude::*; mod code_layout; +pub(crate) mod peephole; mod stack2reg; pub(crate) fn optimize_function<'tcx>( diff --git a/src/optimize/peephole.rs b/src/optimize/peephole.rs new file mode 100644 index 0000000000000..f8e0f3af3d0ad --- /dev/null +++ b/src/optimize/peephole.rs @@ -0,0 +1,83 @@ +//! Peephole optimizations that can be performed while creating clif ir. + +use cranelift_codegen::ir::{ + condcodes::IntCC, types, InstBuilder, InstructionData, Opcode, Value, ValueDef, +}; +use cranelift_frontend::FunctionBuilder; + +/// If the given value was produced by a `bint` instruction, return it's input, otherwise return the +/// given value. +pub(crate) fn maybe_unwrap_bint(bcx: &mut FunctionBuilder<'_>, arg: Value) -> Value { + if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) { + match bcx.func.dfg[arg_inst] { + InstructionData::Unary { + opcode: Opcode::Bint, + arg, + } => arg, + _ => arg, + } + } else { + arg + } +} + +/// If the given value was produced by the lowering of `Rvalue::Not` return the input and true, +/// otherwise return the given value and false. +pub(crate) fn maybe_unwrap_bool_not(bcx: &mut FunctionBuilder<'_>, arg: Value) -> (Value, bool) { + if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) { + match bcx.func.dfg[arg_inst] { + // This is the lowering of `Rvalue::Not` + InstructionData::IntCompareImm { + opcode: Opcode::IcmpImm, + cond: IntCC::Equal, + arg, + imm, + } if imm.bits() == 0 => (arg, true), + _ => (arg, false), + } + } else { + (arg, false) + } +} + +pub(crate) fn make_branchable_value(bcx: &mut FunctionBuilder<'_>, arg: Value) -> Value { + if bcx.func.dfg.value_type(arg).is_bool() { + return arg; + } + + (|| { + let arg_inst = if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) { + arg_inst + } else { + return None; + }; + + match bcx.func.dfg[arg_inst] { + // This is the lowering of Rvalue::Not + InstructionData::Load { + opcode: Opcode::Load, + arg: ptr, + flags, + offset, + } => { + // Using `load.i8 + uextend.i32` would legalize to `uload8 + ireduce.i8 + + // uextend.i32`. Just `uload8` is much faster. + match bcx.func.dfg.ctrl_typevar(arg_inst) { + types::I8 => Some(bcx.ins().uload8(types::I32, flags, ptr, offset)), + types::I16 => Some(bcx.ins().uload16(types::I32, flags, ptr, offset)), + _ => None, + } + } + _ => None, + } + })() + .unwrap_or_else(|| { + match bcx.func.dfg.value_type(arg) { + types::I8 | types::I32 => { + // WORKAROUND for brz.i8 and brnz.i8 not yet being implemented + bcx.ins().uextend(types::I32, arg) + } + _ => arg, + } + }) +} From bd2313fc117fe7779b3c61336b4a62b064141509 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 3 Sep 2020 15:38:57 -0700 Subject: [PATCH 1494/1566] Update to hashbrown 0.9 --- Cargo.toml | 2 +- src/optimize/stack2reg.rs | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 858a0f0e33e3f..187c75f6d5dc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ byteorder = "1.2.7" indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } -hashbrown = "0.8.1" +hashbrown = "0.9.0" # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/wasmtime/"] diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 7c0bd2710a6ea..b192a2ae832e6 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -389,27 +389,24 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // Replace all unused stack_addr and stack_load instructions with nop. let mut func = &mut opt_ctx.ctx.func; - // drain_filter() on hashbrown::HashSet drains the items that do *not* match the - // predicate. Once hashbrown gets updated to match the behaviour of std::drain_filter - // (0.8.2), the predicate will have to be reversed for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { stack_slot_users .stack_addr .drain_filter(|inst| { - !(stack_addr_load_insts_users + stack_addr_load_insts_users .get(inst) .map(|users| users.is_empty()) - .unwrap_or(true)) + .unwrap_or(true) }) .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, inst)); stack_slot_users .stack_load .drain_filter(|inst| { - !(stack_addr_load_insts_users + stack_addr_load_insts_users .get(inst) .map(|users| users.is_empty()) - .unwrap_or(true)) + .unwrap_or(true) }) .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, inst)); } From 217b3818b738eb1403e4664d186972c2ce00fe18 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 5 Sep 2020 10:38:49 +0200 Subject: [PATCH 1495/1566] Rustup to rustc 1.48.0-nightly (c59199efc 2020-09-04) --- Cargo.lock | 46 +++++++++++++++++++++++++++++++++++----- Cargo.toml | 1 + build_sysroot/Cargo.lock | 20 ++++++++--------- rust-toolchain | 2 +- src/abi/mod.rs | 20 ++++++++--------- src/base.rs | 46 ++++++++++++++++++++++------------------ src/common.rs | 6 +++--- src/debuginfo/mod.rs | 2 +- src/intrinsics/llvm.rs | 2 +- src/intrinsics/mod.rs | 12 +++++------ src/lib.rs | 1 - src/main_shim.rs | 8 +++---- src/num.rs | 10 ++++----- src/unsize.rs | 10 ++++----- src/value_and_place.rs | 14 ++++++------ 15 files changed, 120 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b072d9bd8c2ed..a6cde8fdea097 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,10 +1,16 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + [[package]] name = "ahash" -version = "0.3.8" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" +checksum = "6d66721683190aeea775c737eee925aea24719058d86d815e8ee121dd9f37d19" [[package]] name = "anyhow" @@ -182,6 +188,18 @@ dependencies = [ "libc", ] +[[package]] +name = "flate2" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" +dependencies = [ + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", +] + [[package]] name = "gcc" version = "0.3.55" @@ -203,10 +221,18 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" dependencies = [ - "ahash", "autocfg", ] +[[package]] +name = "hashbrown" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" +dependencies = [ + "ahash", +] + [[package]] name = "indexmap" version = "1.5.0" @@ -214,7 +240,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.8.1", ] [[package]] @@ -250,6 +276,15 @@ dependencies = [ "libc", ] +[[package]] +name = "miniz_oxide" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" +dependencies = [ + "adler", +] + [[package]] name = "object" version = "0.21.1" @@ -331,8 +366,9 @@ dependencies = [ "cranelift-module", "cranelift-object", "cranelift-simplejit", + "flate2", "gimli", - "hashbrown", + "hashbrown 0.9.0", "indexmap", "libloading", "object", diff --git a/Cargo.toml b/Cargo.toml index 187c75f6d5dc4..7466da7b8718d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } hashbrown = "0.9.0" +flate2 = "1.0.17" # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/wasmtime/"] diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index b4f5db535d07f..44f31b7cd9258 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -41,15 +41,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "cc" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" +checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" [[package]] name = "cfg-if" @@ -63,9 +63,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.32" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc4ac2c824d2bfc612cba57708198547e9a26943af0632aff033e0693074d5c" +checksum = "e3fcd8aba10d17504c87ef12d4f62ef404c6a4703d16682a9eb5543e6cf24455" dependencies = [ "rustc-std-workspace-core", ] @@ -142,18 +142,18 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.74" +version = "0.2.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" +checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3" dependencies = [ "rustc-std-workspace-core", ] [[package]] name = "miniz_oxide" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" dependencies = [ "adler", "compiler_builtins", diff --git a/rust-toolchain b/rust-toolchain index e3f84f1ce4d6b..1894600e31aa9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-08-23 +nightly-2020-09-05 diff --git a/src/abi/mod.rs b/src/abi/mod.rs index fa91fef9eeeda..d0215ba94dd05 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -20,14 +20,14 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx // FIXME(davidtwco,eddyb): A `ParamEnv` should be passed through to this function. let ty = instance.ty(tcx, ty::ParamEnv::reveal_all()); - match ty.kind { + match *ty.kind() { ty::FnDef(..) => { // HACK(davidtwco,eddyb): This is a workaround for polymorphization considering // parameters unused if they show up in the signature, but not in the `mir::Body` // (i.e. due to being inside a projection that got normalized, see // `src/test/ui/polymorphization/normalized_sig_types.rs`), and codegen not keeping // track of a polymorphization `ParamEnv` to allow normalizing later. - let mut sig = match ty.kind { + let mut sig = match *ty.kind() { ty::FnDef(def_id, substs) => tcx .normalize_erasing_regions(tcx.param_env(def_id), tcx.fn_sig(def_id)) .subst(tcx, substs), @@ -65,13 +65,13 @@ pub(crate) fn fn_sig_for_fn_abi<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx let env_region = ty::ReLateBound(ty::INNERMOST, ty::BrEnv); let env_ty = tcx.mk_mut_ref(tcx.mk_region(env_region), ty); - let pin_did = tcx.require_lang_item(rustc_hir::LangItem::PinTypeLangItem, None); + let pin_did = tcx.require_lang_item(rustc_hir::LangItem::Pin, None); let pin_adt_ref = tcx.adt_def(pin_did); let pin_substs = tcx.intern_substs(&[env_ty.into()]); let env_ty = tcx.mk_adt(pin_adt_ref, pin_substs); sig.map_bound(|sig| { - let state_did = tcx.require_lang_item(rustc_hir::LangItem::GeneratorStateLangItem, None); + let state_did = tcx.require_lang_item(rustc_hir::LangItem::GeneratorState, None); let state_adt_ref = tcx.adt_def(state_did); let state_substs = tcx.intern_substs(&[sig.yield_ty.into(), sig.return_ty.into()]); @@ -116,7 +116,7 @@ fn clif_sig_from_fn_sig<'tcx>( Abi::SysV64 => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()), Abi::RustCall => { assert_eq!(sig.inputs().len(), 2); - let extra_args = match sig.inputs().last().unwrap().kind { + let extra_args = match sig.inputs().last().unwrap().kind() { ty::Tuple(ref tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; @@ -307,7 +307,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { }) .unzip(); let return_layout = self.layout_of(return_ty); - let return_tys = if let ty::Tuple(tup) = return_ty.kind { + let return_tys = if let ty::Tuple(tup) = return_ty.kind() { tup.types().map(|ty| self.clif_type(ty).unwrap()).collect() } else { vec![self.clif_type(return_ty).unwrap()] @@ -379,7 +379,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( // to reconstruct it into a tuple local variable, from multiple // individual function arguments. - let tupled_arg_tys = match arg_ty.kind { + let tupled_arg_tys = match arg_ty.kind() { ty::Tuple(ref tys) => tys, _ => bug!("spread argument isn't a tuple?! but {:?}", arg_ty), }; @@ -500,7 +500,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb)); // Handle special calls like instrinsics and empty drop glue. - let instance = if let ty::FnDef(def_id, substs) = fn_ty.kind { + 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() .unwrap() @@ -553,7 +553,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let self_arg = trans_operand(fx, &args[0]); let pack_arg = trans_operand(fx, &args[1]); - let tupled_arguments = match pack_arg.layout().ty.kind { + let tupled_arguments = match pack_arg.layout().ty.kind() { ty::Tuple(ref tupled_arguments) => tupled_arguments, _ => bug!("argument to function with \"rust-call\" ABI is not a tuple"), }; @@ -715,7 +715,7 @@ pub(crate) fn codegen_drop<'tcx>( ); assert_eq!(fn_sig.output(), fx.tcx.mk_unit()); - match ty.kind { + match ty.kind() { ty::Dynamic(..) => { let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(); let ptr = ptr.get_addr(fx); diff --git a/src/base.rs b/src/base.rs index 01f7ecd86f49f..7aca709fba141 100644 --- a/src/base.rs +++ b/src/base.rs @@ -281,7 +281,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { let len = trans_operand(fx, len).load_scalar(fx); let index = trans_operand(fx, index).load_scalar(fx); args = [index, len, location]; - rustc_hir::lang_items::PanicBoundsCheckFnLangItem + rustc_hir::LangItem::PanicBoundsCheck } _ => { let msg_str = msg.description(); @@ -291,7 +291,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { .ins() .iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap()); args = [msg_ptr, msg_len, location]; - rustc_hir::lang_items::PanicFnLangItem + rustc_hir::LangItem::Panic } }; @@ -322,7 +322,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } => { let discr = trans_operand(fx, discr).load_scalar(fx); - if switch_ty.kind == fx.tcx.types.bool.kind { + if switch_ty.kind() == fx.tcx.types.bool.kind() { assert_eq!(targets.len(), 2); let then_block = fx.get_block(targets[0]); let else_block = fx.get_block(targets[1]); @@ -504,7 +504,7 @@ fn trans_stmt<'tcx>( let layout = operand.layout(); let val = operand.load_scalar(fx); let res = match un_op { - UnOp::Not => match layout.ty.kind { + UnOp::Not => match layout.ty.kind() { ty::Bool => { let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0); CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout) @@ -514,7 +514,7 @@ fn trans_stmt<'tcx>( } _ => unreachable!("un op Not for {:?}", layout.ty), }, - UnOp::Neg => match layout.ty.kind { + UnOp::Neg => match layout.ty.kind() { ty::Int(IntTy::I128) => { // FIXME remove this case once ineg.i128 works let zero = CValue::const_val(fx, layout, 0); @@ -530,7 +530,7 @@ fn trans_stmt<'tcx>( Rvalue::Cast(CastKind::Pointer(PointerCast::ReifyFnPointer), operand, to_ty) => { let from_ty = fx.monomorphize(&operand.ty(&fx.mir.local_decls, fx.tcx)); let to_layout = fx.layout_of(fx.monomorphize(to_ty)); - match from_ty.kind { + match *from_ty.kind() { ty::FnDef(def_id, substs) => { let func_ref = fx.get_function_ref( Instance::resolve_for_fn_ptr( @@ -585,10 +585,10 @@ fn trans_stmt<'tcx>( let (ptr, _extra) = operand.load_scalar_pair(fx); lval.write_cvalue(fx, CValue::by_val(ptr, dest_layout)) } - } else if let ty::Adt(adt_def, _substs) = from_ty.kind { + } else if let ty::Adt(adt_def, _substs) = from_ty.kind() { // enum -> discriminant value assert!(adt_def.is_enum()); - match to_ty.kind { + match to_ty.kind() { ty::Uint(_) | ty::Int(_) => {} _ => unreachable!("cast adt {} -> {}", from_ty, to_ty), } @@ -658,7 +658,7 @@ fn trans_stmt<'tcx>( _to_ty, ) => { let operand = trans_operand(fx, operand); - match operand.layout().ty.kind { + match *operand.layout().ty.kind() { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( fx.tcx, @@ -706,8 +706,6 @@ fn trans_stmt<'tcx>( lval.write_cvalue(fx, CValue::by_val(len, usize_layout)); } Rvalue::NullaryOp(NullOp::Box, content_ty) => { - use rustc_hir::lang_items::ExchangeMallocFnLangItem; - let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap(); let content_ty = fx.monomorphize(content_ty); let layout = fx.layout_of(content_ty); @@ -719,7 +717,11 @@ fn trans_stmt<'tcx>( let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty)); // Allocate space: - let def_id = match fx.tcx.lang_items().require(ExchangeMallocFnLangItem) { + let def_id = match fx + .tcx + .lang_items() + .require(rustc_hir::LangItem::ExchangeMalloc) + { Ok(id) => id, Err(s) => { fx.tcx @@ -868,7 +870,7 @@ fn codegen_array_len<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, place: CPlace<'tcx>, ) -> Value { - match place.layout().ty.kind { + match *place.layout().ty.kind() { ty::Array(_elem_ty, len) => { let len = fx .monomorphize(&len) @@ -907,11 +909,12 @@ pub(crate) fn trans_place<'tcx>( min_length: _, from_end, } => { + let offset: u64 = offset; let index = if !from_end { - fx.bcx.ins().iconst(fx.pointer_type, i64::from(offset)) + fx.bcx.ins().iconst(fx.pointer_type, offset as i64) } else { let len = codegen_array_len(fx, cplace); - fx.bcx.ins().iadd_imm(len, -i64::from(offset)) + fx.bcx.ins().iadd_imm(len, -(offset as i64)) }; cplace = cplace.place_index(fx, index); } @@ -919,13 +922,16 @@ pub(crate) fn trans_place<'tcx>( // These indices are generated by slice patterns. // slice[from:-to] in Python terms. - match cplace.layout().ty.kind { + let from: u64 = from; + let to: u64 = to; + + match cplace.layout().ty.kind() { ty::Array(elem_ty, _len) => { assert!(!from_end, "array subslices are never `from_end`"); let elem_layout = fx.layout_of(elem_ty); let ptr = cplace.to_ptr(); cplace = CPlace::for_ptr( - ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), + ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)), fx.layout_of(fx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))), ); } @@ -935,10 +941,8 @@ pub(crate) fn trans_place<'tcx>( let (ptr, len) = cplace.to_ptr_maybe_unsized(); let len = len.unwrap(); cplace = CPlace::for_ptr_with_extra( - ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * i64::from(from)), - fx.bcx - .ins() - .iadd_imm(len, -(i64::from(from) + i64::from(to))), + ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)), + fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)), cplace.layout(), ); } diff --git a/src/common.rs b/src/common.rs index 3c65e7aad2119..d4b5d660ba8d8 100644 --- a/src/common.rs +++ b/src/common.rs @@ -31,7 +31,7 @@ pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type { } fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option { - Some(match ty.kind { + Some(match ty.kind() { ty::Bool => types::I8, ty::Uint(size) => match size { UintTy::U8 => types::I8, @@ -88,7 +88,7 @@ fn clif_pair_type_from_ty<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, ) -> Option<(types::Type, types::Type)> { - Some(match ty.kind { + Some(match ty.kind() { ty::Tuple(substs) if substs.len() == 2 => { let mut types = substs.types(); let a = clif_type_from_ty(tcx, types.next().unwrap())?; @@ -279,7 +279,7 @@ pub(crate) fn type_min_max_value( } pub(crate) fn type_sign(ty: Ty<'_>) -> bool { - match ty.kind { + match ty.kind() { ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) | ty::Char | ty::Uint(..) | ty::Bool => false, ty::Int(..) => true, ty::Float(..) => false, // `signed` is unused for floats diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 04330b6de60ca..70e0cf1a9e4ef 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -170,7 +170,7 @@ impl<'tcx> DebugContext<'tcx> { let name = format!("{}", ty); let layout = self.tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap(); - let type_id = match ty.kind { + let type_id = match ty.kind() { ty::Bool => primitive(&mut self.dwarf, gimli::DW_ATE_boolean), ty::Char => primitive(&mut self.dwarf, gimli::DW_ATE_UTF), ty::Uint(_) => primitive(&mut self.dwarf, gimli::DW_ATE_unsigned), diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index c85daaa0e2e3d..ab1c888b4c00c 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -87,7 +87,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( }; simd_pair_for_each_lane(fx, x, y, ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { + let res_lane = match lane_layout.ty.kind() { ty::Float(_) => fx.bcx.ins().fcmp(flt_cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index e8bd3e4ac3efb..fd95c25b572d5 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -141,7 +141,7 @@ macro atomic_minmax($fx:expr, $cc:expr, <$T:ident> ($ptr:ident, $src:ident) -> $ } macro validate_atomic_type($fx:ident, $intrinsic:ident, $span:ident, $ty:expr) { - match $ty.kind { + match $ty.kind() { ty::Uint(_) | ty::Int(_) => {} _ => { $fx.tcx.sess.span_err( @@ -302,7 +302,7 @@ macro simd_cmp { $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { + let res_lane = match lane_layout.ty.kind() { ty::Uint(_) | ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; @@ -319,7 +319,7 @@ macro simd_cmp { $y, $ret, |fx, lane_layout, res_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { + let res_lane = match lane_layout.ty.kind() { ty::Uint(_) => fx.bcx.ins().icmp(IntCC::$cc_u, x_lane, y_lane), ty::Int(_) => fx.bcx.ins().icmp(IntCC::$cc_s, x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), @@ -341,7 +341,7 @@ macro simd_int_binop { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { + let res_lane = match lane_layout.ty.kind() { ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), @@ -363,7 +363,7 @@ macro simd_int_flt_binop { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { + let res_lane = match lane_layout.ty.kind() { ty::Uint(_) => fx.bcx.ins().$op_u(x_lane, y_lane), ty::Int(_) => fx.bcx.ins().$op_s(x_lane, y_lane), ty::Float(_) => fx.bcx.ins().$op_f(x_lane, y_lane), @@ -382,7 +382,7 @@ macro simd_flt_binop($fx:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { $y, $ret, |fx, lane_layout, ret_lane_layout, x_lane, y_lane| { - let res_lane = match lane_layout.ty.kind { + let res_lane = match lane_layout.ty.kind() { ty::Float(_) => fx.bcx.ins().$op(x_lane, y_lane), _ => unreachable!("{:?}", lane_layout.ty), }; diff --git a/src/lib.rs b/src/lib.rs index 249c58b90311e..03a1629c1431b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,6 @@ #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] -extern crate flate2; #[cfg(feature = "jit")] extern crate libc; #[macro_use] diff --git a/src/main_shim.rs b/src/main_shim.rs index c31657d5f0ca8..520a54b8e5333 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -1,3 +1,6 @@ +use rustc_hir::LangItem; +use rustc_session::config::EntryFnType; + use crate::prelude::*; /// Create the `main` function which will initialize the rust runtime and call @@ -7,9 +10,6 @@ pub(crate) fn maybe_create_entry_wrapper( module: &mut Module, unwind_context: &mut UnwindContext<'_>, ) { - use rustc_hir::lang_items::StartFnLangItem; - use rustc_session::config::EntryFnType; - let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) { Some((def_id, entry_ty)) => ( def_id.to_def_id(), @@ -88,7 +88,7 @@ pub(crate) fn maybe_create_entry_wrapper( let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); let call_inst = if use_start_lang_item { - let start_def_id = tcx.require_lang_item(StartFnLangItem, None); + let start_def_id = tcx.require_lang_item(LangItem::Start, None); let start_instance = Instance::resolve( tcx, ParamEnv::reveal_all(), diff --git a/src/num.rs b/src/num.rs index 60a4337111a8d..3c290026776d1 100644 --- a/src/num.rs +++ b/src/num.rs @@ -59,15 +59,15 @@ pub(crate) fn codegen_binop<'tcx>( ) -> CValue<'tcx> { match bin_op { BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => { - match in_lhs.layout().ty.kind { + match in_lhs.layout().ty.kind() { ty::Bool | ty::Uint(_) | ty::Int(_) | ty::Char => { let signed = type_sign(in_lhs.layout().ty); let lhs = in_lhs.load_scalar(fx); let rhs = in_rhs.load_scalar(fx); let (lhs, rhs) = if (bin_op == BinOp::Eq || bin_op == BinOp::Ne) - && (in_lhs.layout().ty.kind == fx.tcx.types.i8.kind - || in_lhs.layout().ty.kind == fx.tcx.types.i16.kind) + && (in_lhs.layout().ty.kind() == fx.tcx.types.i8.kind() + || in_lhs.layout().ty.kind() == fx.tcx.types.i16.kind()) { // FIXME(CraneStation/cranelift#896) icmp_imm.i8/i16 with eq/ne for signed ints is implemented wrong. ( @@ -86,7 +86,7 @@ pub(crate) fn codegen_binop<'tcx>( _ => {} } - match in_lhs.layout().ty.kind { + match in_lhs.layout().ty.kind() { ty::Bool => crate::num::trans_bool_binop(fx, bin_op, in_lhs, in_rhs), ty::Uint(_) | ty::Int(_) => crate::num::trans_int_binop(fx, bin_op, in_lhs, in_rhs), ty::Float(_) => crate::num::trans_float_binop(fx, bin_op, in_lhs, in_rhs), @@ -373,7 +373,7 @@ pub(crate) fn trans_float_binop<'tcx>( BinOp::Mul => b.fmul(lhs, rhs), BinOp::Div => b.fdiv(lhs, rhs), BinOp::Rem => { - let name = match in_lhs.layout().ty.kind { + let name = match in_lhs.layout().ty.kind() { ty::Float(FloatTy::F32) => "fmodf", ty::Float(FloatTy::F64) => "fmod", _ => bug!(), diff --git a/src/unsize.rs b/src/unsize.rs index affb36d7d3712..962fcaf48efc3 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -17,7 +17,7 @@ pub(crate) fn unsized_info<'tcx>( let (source, target) = fx.tcx .struct_lockstep_tails_erasing_lifetimes(source, target, ParamEnv::reveal_all()); - match (&source.kind, &target.kind) { + match (&source.kind(), &target.kind()) { (&ty::Array(_, len), &ty::Slice(_)) => fx.bcx.ins().iconst( fx.pointer_type, len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64, @@ -46,7 +46,7 @@ fn unsize_thin_ptr<'tcx>( src_layout: TyAndLayout<'tcx>, dst_layout: TyAndLayout<'tcx>, ) -> (Value, Value) { - match (&src_layout.ty.kind, &dst_layout.ty.kind) { + match (&src_layout.ty.kind(), &dst_layout.ty.kind()) { (&ty::Ref(_, a, _), &ty::Ref(_, b, _)) | (&ty::Ref(_, a, _), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) | (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => { @@ -105,7 +105,7 @@ pub(crate) fn coerce_unsized_into<'tcx>( }; dst.write_cvalue(fx, CValue::by_val_pair(base, info, dst.layout())); }; - match (&src_ty.kind, &dst_ty.kind) { + match (&src_ty.kind(), &dst_ty.kind()) { (&ty::Ref(..), &ty::Ref(..)) | (&ty::Ref(..), &ty::RawPtr(..)) | (&ty::RawPtr(..), &ty::RawPtr(..)) => coerce_ptr(), @@ -153,7 +153,7 @@ pub(crate) fn size_and_align_of_dst<'tcx>( .iconst(fx.pointer_type, layout.align.abi.bytes() as i64); return (size, align); } - match layout.ty.kind { + match layout.ty.kind() { ty::Dynamic(..) => { // load size/align from vtable ( @@ -199,7 +199,7 @@ pub(crate) fn size_and_align_of_dst<'tcx>( let size = fx.bcx.ins().iadd_imm(unsized_size, sized_size as i64); // Packed types ignore the alignment of their fields. - if let ty::Adt(def, _) = layout.ty.kind { + if let ty::Adt(def, _) = layout.ty.kind() { if def.repr.packed() { unsized_align = sized_align; } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 3e0d84387f3fd..765c482e83cdb 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -24,7 +24,7 @@ fn codegen_field<'tcx>( if !field_layout.is_unsized() { return simple(fx); } - match field_layout.ty.kind { + match field_layout.ty.kind() { ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(fx), ty::Adt(def, _) if def.repr.packed() => { assert_eq!(layout.align.abi.bytes(), 1); @@ -235,7 +235,7 @@ impl<'tcx> CValue<'tcx> { let clif_ty = fx.clif_type(layout.ty).unwrap(); - match layout.ty.kind { + match layout.ty.kind() { ty::Bool => { assert!( const_val == 0 || const_val == 1, @@ -246,7 +246,7 @@ impl<'tcx> CValue<'tcx> { _ => {} } - let val = match layout.ty.kind { + let val = match layout.ty.kind() { ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => { let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64); let msb = fx @@ -279,11 +279,11 @@ impl<'tcx> CValue<'tcx> { pub(crate) fn cast_pointer_to(self, layout: TyAndLayout<'tcx>) -> Self { assert!(matches!( - self.layout().ty.kind, + self.layout().ty.kind(), ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) )); assert!(matches!( - layout.ty.kind, + layout.ty.kind(), ty::Ref(..) | ty::RawPtr(..) | ty::FnPtr(..) )); assert_eq!(self.layout().abi, layout.abi); @@ -454,7 +454,7 @@ impl<'tcx> CPlace<'tcx> { from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, ) { - match (&from_ty.kind, &to_ty.kind) { + match (&from_ty.kind(), &to_ty.kind()) { (ty::Ref(_, a, _), ty::Ref(_, b, _)) | ( ty::RawPtr(TypeAndMut { ty: a, mutbl: _ }), @@ -716,7 +716,7 @@ impl<'tcx> CPlace<'tcx> { fx: &mut FunctionCx<'_, 'tcx, impl Backend>, index: Value, ) -> CPlace<'tcx> { - let (elem_layout, ptr) = match self.layout().ty.kind { + let (elem_layout, ptr) = match self.layout().ty.kind() { ty::Array(elem_ty, _) => (fx.layout_of(elem_ty), self.to_ptr()), ty::Slice(elem_ty) => (fx.layout_of(elem_ty), self.to_ptr_maybe_unsized().0), _ => bug!("place_index({:?})", self.layout().ty), From 4bb25c3e4ab45577cc14b7908ba9533f82a3a2e8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 5 Sep 2020 11:00:34 +0200 Subject: [PATCH 1496/1566] Fix dylib metadata writing Rustc switched from flate2 to snappy --- Cargo.lock | 28 ---------------------------- Cargo.toml | 1 - src/lib.rs | 1 + src/metadata.rs | 5 ++--- 4 files changed, 3 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6cde8fdea097..c824d2c6aed26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,11 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "adler" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" - [[package]] name = "ahash" version = "0.4.4" @@ -188,18 +182,6 @@ dependencies = [ "libc", ] -[[package]] -name = "flate2" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" -dependencies = [ - "cfg-if", - "crc32fast", - "libc", - "miniz_oxide", -] - [[package]] name = "gcc" version = "0.3.55" @@ -276,15 +258,6 @@ dependencies = [ "libc", ] -[[package]] -name = "miniz_oxide" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" -dependencies = [ - "adler", -] - [[package]] name = "object" version = "0.21.1" @@ -366,7 +339,6 @@ dependencies = [ "cranelift-module", "cranelift-object", "cranelift-simplejit", - "flate2", "gimli", "hashbrown 0.9.0", "indexmap", diff --git a/Cargo.toml b/Cargo.toml index 7466da7b8718d..187c75f6d5dc4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } hashbrown = "0.9.0" -flate2 = "1.0.17" # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/wasmtime/"] diff --git a/src/lib.rs b/src/lib.rs index 03a1629c1431b..10642ccd07fbb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,6 +11,7 @@ #[cfg(feature = "jit")] extern crate libc; +extern crate snap; #[macro_use] extern crate rustc_middle; extern crate rustc_ast; diff --git a/src/metadata.rs b/src/metadata.rs index 67137b0fa3bcb..9fdd372594097 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -63,8 +63,7 @@ pub(crate) fn write_metadata( tcx: TyCtxt<'_>, product: &mut P, ) -> EncodedMetadata { - use flate2::write::DeflateEncoder; - use flate2::Compression; + use snap::write::FrameEncoder; use std::io::Write; #[derive(PartialEq, Eq, PartialOrd, Ord)] @@ -101,7 +100,7 @@ pub(crate) fn write_metadata( assert!(kind == MetadataKind::Compressed); let mut compressed = tcx.metadata_encoding_version(); - DeflateEncoder::new(&mut compressed, Compression::fast()) + FrameEncoder::new(&mut compressed) .write_all(&metadata.raw_data) .unwrap(); From 171e159e640bbe47cecdd3ab86015d8392bbe7af Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 7 Sep 2020 21:16:35 +0200 Subject: [PATCH 1497/1566] Rustup to rustc 1.48.0-nightly (73dc675b9 2020-09-06) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 1894600e31aa9..50cc166fc4727 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-09-05 +nightly-2020-09-07 From 9c6921b4b6a136b89c07db59ef3fd243bc86df7b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 14 Sep 2020 10:32:37 +0200 Subject: [PATCH 1498/1566] Fix typo --- src/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base.rs b/src/base.rs index 7aca709fba141..7c43dc68deb2d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -105,7 +105,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( ); }); - // If the return block is not reachable, then the SSA builder may have inserted a `iconst.i128` + // If the return block is not reachable, then the SSA builder may have inserted an `iconst.i128` // instruction, which doesn't have an encoding. context.compute_cfg(); context.compute_domtree(); From 50e8f2218e94d15892a78f0b780ba103bf21647a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 14 Sep 2020 10:56:37 +0200 Subject: [PATCH 1499/1566] Rustup to rustc 1.48.0-nightly (7402a3944 2020-09-13) --- build_sysroot/Cargo.lock | 19 ++++++------------- rust-toolchain | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 44f31b7cd9258..15b985eb8b9a7 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -39,12 +39,6 @@ dependencies = [ "libc", ] -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - [[package]] name = "cc" version = "1.0.59" @@ -63,9 +57,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.35" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3fcd8aba10d17504c87ef12d4f62ef404c6a4703d16682a9eb5543e6cf24455" +checksum = "7cd0782e0a7da7598164153173e5a5d4d9b1da094473c98dce0ff91406112369" dependencies = [ "rustc-std-workspace-core", ] @@ -119,11 +113,10 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" +checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" dependencies = [ - "autocfg", "compiler_builtins", "rustc-std-workspace-alloc", "rustc-std-workspace-core", @@ -142,9 +135,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.76" +version = "0.2.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755456fae044e6fa1ebbbd1b3e902ae19e73097ed4ed87bb79934a867c007bc3" +checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" dependencies = [ "rustc-std-workspace-core", ] diff --git a/rust-toolchain b/rust-toolchain index 50cc166fc4727..a4fe30c924006 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-09-07 +nightly-2020-09-14 From bb59d616aa62217b8f4c56311766957710d9e984 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 14 Sep 2020 11:32:18 +0200 Subject: [PATCH 1500/1566] Use don't unroll loop in Rvalue::Repeat Fixes #1081 --- example/mini_core.rs | 19 +++++++++++++++++++ example/mini_core_hello_world.rs | 4 ++++ src/base.rs | 23 +++++++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 94336154748ab..a972beedaa387 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -58,6 +58,7 @@ unsafe impl Copy for char {} unsafe impl<'a, T: ?Sized> Copy for &'a T {} unsafe impl Copy for *const T {} unsafe impl Copy for *mut T {} +unsafe impl Copy for Option {} #[lang = "sync"] pub unsafe trait Sync {} @@ -336,6 +337,24 @@ impl PartialEq for *const T { } } +impl PartialEq for Option { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Some(lhs), Some(rhs)) => *lhs == *rhs, + (None, None) => true, + _ => false, + } + } + + fn ne(&self, other: &Self) -> bool { + match (self, other) { + (Some(lhs), Some(rhs)) => *lhs != *rhs, + (None, None) => false, + _ => true, + } + } +} + #[lang = "neg"] pub trait Neg { type Output; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index d79f9f5f79c5b..f1c037696d8b3 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -285,6 +285,10 @@ fn main() { let slice_ptr = &[] as *const [u8]; slice_ptr as *const u8; + let repeat = [Some(42); 2]; + assert_eq!(repeat[0], Some(42)); + assert_eq!(repeat[1], Some(42)); + #[cfg(not(jit))] test_tls(); diff --git a/src/base.rs b/src/base.rs index 7c43dc68deb2d..cae2115ab181b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -693,10 +693,29 @@ fn trans_stmt<'tcx>( .val .try_to_bits(fx.tcx.data_layout.pointer_size) .unwrap(); - for i in 0..times { - let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64); + if fx.clif_type(operand.layout().ty) == Some(types::I8) { + let times = fx.bcx.ins().iconst(fx.pointer_type, times as i64); + // FIXME use emit_small_memset where possible + let addr = lval.to_ptr().get_addr(fx); + let val = operand.load_scalar(fx); + fx.bcx.call_memset(fx.cx.module.target_config(), addr, val, times); + } else { + let loop_block = fx.bcx.create_block(); + let done_block = fx.bcx.create_block(); + let index = fx.bcx.append_block_param(loop_block, fx.pointer_type); + let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); + fx.bcx.ins().jump(loop_block, &[zero]); + + fx.bcx.switch_to_block(loop_block); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); + + let index = fx.bcx.ins().iadd_imm(index, 1); + let done = fx.bcx.ins().icmp_imm(IntCC::Equal, index, times as i64); + fx.bcx.ins().brz(done, loop_block, &[index]); + fx.bcx.ins().jump(done_block, &[]); + + fx.bcx.switch_to_block(done_block); } } Rvalue::Len(place) => { From 2d250ffa9756e85b963121697d4c8e7682a402a4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 14 Sep 2020 11:44:53 +0200 Subject: [PATCH 1501/1566] Fix miscompilation in previous commit --- src/base.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index cae2115ab181b..263b6c40a2054 100644 --- a/src/base.rs +++ b/src/base.rs @@ -701,19 +701,22 @@ fn trans_stmt<'tcx>( fx.bcx.call_memset(fx.cx.module.target_config(), addr, val, times); } else { let loop_block = fx.bcx.create_block(); + let loop_block2 = fx.bcx.create_block(); let done_block = fx.bcx.create_block(); let index = fx.bcx.append_block_param(loop_block, fx.pointer_type); let zero = fx.bcx.ins().iconst(fx.pointer_type, 0); fx.bcx.ins().jump(loop_block, &[zero]); fx.bcx.switch_to_block(loop_block); + let done = fx.bcx.ins().icmp_imm(IntCC::Equal, index, times as i64); + fx.bcx.ins().brnz(done, done_block, &[]); + fx.bcx.ins().jump(loop_block2, &[]); + + fx.bcx.switch_to_block(loop_block2); let to = lval.place_index(fx, index); to.write_cvalue(fx, operand); - let index = fx.bcx.ins().iadd_imm(index, 1); - let done = fx.bcx.ins().icmp_imm(IntCC::Equal, index, times as i64); - fx.bcx.ins().brz(done, loop_block, &[index]); - fx.bcx.ins().jump(done_block, &[]); + fx.bcx.ins().jump(loop_block, &[index]); fx.bcx.switch_to_block(done_block); } From 044470a7262e0b890181ba73c3ccf5160d2bff70 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 15 Sep 2020 21:00:04 +0200 Subject: [PATCH 1502/1566] Remove hashbrown usage drain_filter is now supported on nightly --- Cargo.lock | 18 +----------------- Cargo.toml | 1 - src/lib.rs | 3 ++- src/optimize/stack2reg.rs | 11 ++++------- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c824d2c6aed26..77d1fd0b40578 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,11 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "ahash" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d66721683190aeea775c737eee925aea24719058d86d815e8ee121dd9f37d19" - [[package]] name = "anyhow" version = "1.0.32" @@ -206,15 +200,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "hashbrown" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" -dependencies = [ - "ahash", -] - [[package]] name = "indexmap" version = "1.5.0" @@ -222,7 +207,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" dependencies = [ "autocfg", - "hashbrown 0.8.1", + "hashbrown", ] [[package]] @@ -340,7 +325,6 @@ dependencies = [ "cranelift-object", "cranelift-simplejit", "gimli", - "hashbrown 0.9.0", "indexmap", "libloading", "object", diff --git a/Cargo.toml b/Cargo.toml index 187c75f6d5dc4..e178e29925b03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ byteorder = "1.2.7" indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } -hashbrown = "0.9.0" # Uncomment to use local checkout of cranelift #[patch."https://github.com/bytecodealliance/wasmtime/"] diff --git a/src/lib.rs b/src/lib.rs index 10642ccd07fbb..24dd285fb018b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,8 @@ type_alias_impl_trait, associated_type_bounds, never_type, - try_blocks + try_blocks, + hash_drain_filter, )] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index b192a2ae832e6..8df33fd2fc72f 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -13,15 +13,12 @@ use std::collections::BTreeMap; use std::fmt; use std::ops::Not; -use rustc_data_structures::fx::{FxHashSet, FxHasher}; +use rustc_data_structures::fx::FxHashSet; use cranelift_codegen::cursor::{Cursor, FuncCursor}; use cranelift_codegen::ir::immediates::Offset32; use cranelift_codegen::ir::{InstructionData, Opcode, ValueDef}; -use hashbrown::HashSet; -use std::hash::BuildHasherDefault; - use crate::prelude::*; /// Workaround for `StackSlot` not implementing `Ord`. @@ -48,9 +45,9 @@ impl Ord for OrdStackSlot { #[derive(Debug, Default)] struct StackSlotUsage { - stack_addr: HashSet>, - stack_load: HashSet>, - stack_store: HashSet>, + stack_addr: FxHashSet, + stack_load: FxHashSet, + stack_store: FxHashSet, } impl StackSlotUsage { From 7285c134d101d441cddb9b62d33d4791d1b87dc0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Sep 2020 16:46:02 +0200 Subject: [PATCH 1503/1566] Reorganize scripts --- build_sysroot/build_sysroot.sh | 2 +- cargo.sh | 2 +- scripts/Readme.md | 2 ++ config.sh => scripts/config.sh | 1 - filter_profile.rs => scripts/filter_profile.rs | 6 ++++-- rustup.sh => scripts/rustup.sh | 0 test.sh | 3 ++- 7 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 scripts/Readme.md rename config.sh => scripts/config.sh (95%) rename filter_profile.rs => scripts/filter_profile.rs (97%) rename rustup.sh => scripts/rustup.sh (100%) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index b4b7c5e5e01e8..4404fb49238e9 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -6,7 +6,7 @@ set -e cd $(dirname "$0") pushd ../ >/dev/null -source ./config.sh +source ./scripts/config.sh popd >/dev/null # Cleanup for previous run diff --git a/cargo.sh b/cargo.sh index d5be7773d342b..ba4b7d6c942ba 100755 --- a/cargo.sh +++ b/cargo.sh @@ -5,7 +5,7 @@ export CHANNEL='release' fi pushd $(dirname "$0") >/dev/null -source config.sh +source scripts/config.sh # read nightly compiler from rust-toolchain file TOOLCHAIN=$(cat rust-toolchain) diff --git a/scripts/Readme.md b/scripts/Readme.md new file mode 100644 index 0000000000000..83cec9c6f3696 --- /dev/null +++ b/scripts/Readme.md @@ -0,0 +1,2 @@ +This directory is for scripts that are either never directly invoked or are not used very often. +Scripts that are frequently used should be kept at the project root. diff --git a/config.sh b/scripts/config.sh similarity index 95% rename from config.sh rename to scripts/config.sh index b47da434c647b..93db4a54a565a 100644 --- a/config.sh +++ b/scripts/config.sh @@ -38,7 +38,6 @@ if [[ `uname` == 'Darwin' ]]; then export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" fi -RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" export RUSTC_LOG=warn # display metadata load errors export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib" diff --git a/filter_profile.rs b/scripts/filter_profile.rs similarity index 97% rename from filter_profile.rs rename to scripts/filter_profile.rs index 82bf53934b847..75f2f61b21a5a 100755 --- a/filter_profile.rs +++ b/scripts/filter_profile.rs @@ -2,8 +2,10 @@ #![forbid(unsafe_code)]/* This line is ignored by bash # This block is ignored by rustc CHANNEL="release" -source ./config.sh -CG_CLIF_JIT=1 PROFILE=$1 OUTPUT=$2 exec $RUSTC $0 --crate-type bin -Cprefer-dynamic +pushd $(dirname "$0")/../ +source scripts/config.sh +popd +CG_CLIF_JIT=1 PROFILE=$1 OUTPUT=$2 exec rustc $RUSTFLAGS $0 --crate-type bin -Cprefer-dynamic #*/ //! This program filters away uninteresting samples and trims uninteresting frames for stackcollapse diff --git a/rustup.sh b/scripts/rustup.sh similarity index 100% rename from rustup.sh rename to scripts/rustup.sh diff --git a/test.sh b/test.sh index 230e464d2796f..67dd4d3aa0011 100755 --- a/test.sh +++ b/test.sh @@ -11,8 +11,9 @@ else fi # Config -source config.sh +source scripts/config.sh export CG_CLIF_INCR_CACHE_DISABLED=1 +RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" # Cleanup rm -r target/out || true From 55d4afd2ba93923fa91bb4099ac805de50f4dc6e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Sep 2020 16:54:58 +0200 Subject: [PATCH 1504/1566] Remove byteorder dependency --- Cargo.lock | 1 - Cargo.toml | 1 - src/vtable.rs | 19 ++++++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 77d1fd0b40578..9c669c87a734a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,7 +317,6 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar", - "byteorder", "cfg-if", "cranelift-codegen", "cranelift-frontend", diff --git a/Cargo.toml b/Cargo.toml index e178e29925b03..5962356beeaf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ gimli = { version = "0.21.0", default-features = false, features = ["write"]} object = { version = "0.21.1", default-features = false, features = ["read", "std", "write"] } ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } -byteorder = "1.2.7" indexmap = "1.0.2" cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } diff --git a/src/vtable.rs b/src/vtable.rs index d23b077148e59..c58b39c1c8244 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -168,18 +168,23 @@ fn build_vtable<'tcx>( } fn write_usize(tcx: TyCtxt<'_>, buf: &mut [u8], idx: usize, num: u64) { - use byteorder::{BigEndian, LittleEndian, WriteBytesExt}; - - let usize_size = tcx + let pointer_size = tcx .layout_of(ParamEnv::reveal_all().and(tcx.types.usize)) .unwrap() .size .bytes() as usize; - let mut target = &mut buf[idx * usize_size..(idx + 1) * usize_size]; + let target = &mut buf[idx * pointer_size..(idx + 1) * pointer_size]; match tcx.data_layout.endian { - rustc_target::abi::Endian::Little => target.write_uint::(num, usize_size), - rustc_target::abi::Endian::Big => target.write_uint::(num, usize_size), + rustc_target::abi::Endian::Little => match pointer_size { + 4 => target.copy_from_slice(&(num as u32).to_le_bytes()), + 8 => target.copy_from_slice(&(num as u64).to_le_bytes()), + _ => todo!("pointer size {} is not yet supported", pointer_size), + }, + rustc_target::abi::Endian::Big => match pointer_size { + 4 => target.copy_from_slice(&(num as u32).to_be_bytes()), + 8 => target.copy_from_slice(&(num as u64).to_be_bytes()), + _ => todo!("pointer size {} is not yet supported", pointer_size), + }, } - .unwrap() } From b8bbbe38d1b2dadae1b66efb49a36c713d5b6dfe Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Sep 2020 16:57:52 +0200 Subject: [PATCH 1505/1566] Remove cfg-if dependency --- Cargo.lock | 1 - Cargo.toml | 1 - src/debuginfo/unwind.rs | 49 +++++++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c669c87a734a..d522fc8da24c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,7 +317,6 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar", - "cfg-if", "cranelift-codegen", "cranelift-frontend", "cranelift-module", diff --git a/Cargo.toml b/Cargo.toml index 5962356beeaf1..6250dc8573be4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ object = { version = "0.21.1", default-features = false, features = ["read", "st ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } indexmap = "1.0.2" -cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } # Uncomment to use local checkout of cranelift diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 5fc68990b2a5b..4c23f75be699c 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -94,33 +94,34 @@ impl<'tcx> UnwindContext<'tcx> { // ======================================================================= // Everything after this line up to the end of the file is loosly based on // https://github.com/bytecodealliance/wasmtime/blob/4471a82b0c540ff48960eca6757ccce5b1b5c3e4/crates/jit/src/unwind/systemv.rs - cfg_if::cfg_if! { - if #[cfg(target_os = "macos")] { - // On macOS, `__register_frame` takes a pointer to a single FDE - let start = eh_frame.as_ptr(); - let end = start.add(eh_frame.len()); - let mut current = start; - - // Walk all of the entries in the frame table and register them - while current < end { - let len = std::ptr::read::(current as *const u32) as usize; - - // Skip over the CIE - if current != start { - __register_frame(current); - registrations.push(current as usize); - } - - // Move to the next table entry (+4 because the length itself is not inclusive) - current = current.add(len + 4); + #[cfg(target_os = "macos")] + { + // On macOS, `__register_frame` takes a pointer to a single FDE + let start = eh_frame.as_ptr(); + let end = start.add(eh_frame.len()); + let mut current = start; + + // Walk all of the entries in the frame table and register them + while current < end { + let len = std::ptr::read::(current as *const u32) as usize; + + // Skip over the CIE + if current != start { + __register_frame(current); + registrations.push(current as usize); } - } else { - // On other platforms, `__register_frame` will walk the FDEs until an entry of length 0 - let ptr = eh_frame.as_ptr(); - __register_frame(ptr); - registrations.push(ptr as usize); + + // Move to the next table entry (+4 because the length itself is not inclusive) + current = current.add(len + 4); } } + #[cfg(not(target_os = "macos"))] + { + // On other platforms, `__register_frame` will walk the FDEs until an entry of length 0 + let ptr = eh_frame.as_ptr(); + __register_frame(ptr); + registrations.push(ptr as usize); + } Some(UnwindRegistry { _frame_table: eh_frame, From 51f816f2a77c9ccca5f2dfe4db08d662400a89ac Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Sep 2020 16:58:58 +0200 Subject: [PATCH 1506/1566] Rustfmt --- src/base.rs | 3 ++- src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index 263b6c40a2054..b01fb8fe6493d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -698,7 +698,8 @@ fn trans_stmt<'tcx>( // FIXME use emit_small_memset where possible let addr = lval.to_ptr().get_addr(fx); let val = operand.load_scalar(fx); - fx.bcx.call_memset(fx.cx.module.target_config(), addr, val, times); + fx.bcx + .call_memset(fx.cx.module.target_config(), addr, val, times); } else { let loop_block = fx.bcx.create_block(); let loop_block2 = fx.bcx.create_block(); diff --git a/src/lib.rs b/src/lib.rs index 24dd285fb018b..64f4e490aed39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ associated_type_bounds, never_type, try_blocks, - hash_drain_filter, + hash_drain_filter )] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)] From a18a1948e04dcd619e5112724d37eb81b35a6687 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Sep 2020 17:17:57 +0200 Subject: [PATCH 1507/1566] Remove wasmparser dependency through object --- Cargo.lock | 7 ------- Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d522fc8da24c4..f54157234da63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,7 +251,6 @@ checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" dependencies = [ "crc32fast", "indexmap", - "wasmparser", ] [[package]] @@ -402,12 +401,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" -[[package]] -name = "wasmparser" -version = "0.57.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32fddd575d477c6e9702484139cf9f23dcd554b06d185ed0f56c857dd3a47aa6" - [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 6250dc8573be4..60f9a29960f63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", b cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } target-lexicon = "0.10.0" gimli = { version = "0.21.0", default-features = false, features = ["write"]} -object = { version = "0.21.1", default-features = false, features = ["read", "std", "write"] } +object = { version = "0.21.1", default-features = false, features = ["std", "read_core", "write", "coff", "elf", "macho", "pe"] } ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } indexmap = "1.0.2" From 552991e17e34ec971631e8dffdfb4a84c8d69eda Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Sep 2020 18:45:19 +0200 Subject: [PATCH 1508/1566] Replace FxHashMap with IndexVec for local_map Fixes #745 --- src/abi/mod.rs | 18 +++++++++--------- src/abi/returning.rs | 32 ++++++++++++++------------------ src/base.rs | 2 +- src/common.rs | 4 ++-- src/debuginfo/mod.rs | 8 +++++--- 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index d0215ba94dd05..7065eefe17066 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -325,7 +325,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } } -fn local_place<'tcx>( +fn make_local_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, layout: TyAndLayout<'tcx>, @@ -344,9 +344,7 @@ fn local_place<'tcx>( #[cfg(debug_assertions)] self::comments::add_local_place_comments(fx, place, local); - let prev_place = fx.local_map.insert(local, place); - debug_assert!(prev_place.is_none()); - fx.local_map[&local] + place } pub(crate) fn codegen_fn_prelude<'tcx>( @@ -358,7 +356,8 @@ pub(crate) fn codegen_fn_prelude<'tcx>( #[cfg(debug_assertions)] self::comments::add_args_header_comment(fx); - self::returning::codegen_return_param(fx, &ssa_analyzed, start_block); + let ret_place = self::returning::codegen_return_param(fx, &ssa_analyzed, start_block); + assert_eq!(fx.local_map.push(ret_place), RETURN_PLACE); // None means pass_mode == NoPass enum ArgKind<'tcx> { @@ -441,8 +440,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( #[cfg(debug_assertions)] self::comments::add_local_place_comments(fx, place, local); - let prev_place = fx.local_map.insert(local, place); - debug_assert!(prev_place.is_none()); + assert_eq!(fx.local_map.push(place), local); continue; } } @@ -450,7 +448,8 @@ pub(crate) fn codegen_fn_prelude<'tcx>( _ => {} } - let place = local_place(fx, local, layout, is_ssa); + let place = make_local_place(fx, local, layout, is_ssa); + assert_eq!(fx.local_map.push(place), local); match arg_kind { ArgKind::Normal(param) => { @@ -476,7 +475,8 @@ pub(crate) fn codegen_fn_prelude<'tcx>( let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa; - local_place(fx, local, layout, is_ssa); + let place = make_local_place(fx, local, layout, is_ssa); + assert_eq!(fx.local_map.push(place), local); } fx.bcx diff --git a/src/abi/returning.rs b/src/abi/returning.rs index dfb16b5fe4ca3..690f5cd5cba33 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -16,34 +16,28 @@ pub(crate) fn can_return_to_ssa_var<'tcx>( } } -pub(super) fn codegen_return_param( - fx: &mut FunctionCx<'_, '_, impl Backend>, +pub(super) fn codegen_return_param<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ssa_analyzed: &rustc_index::vec::IndexVec, start_block: Block, -) { +) -> CPlace<'tcx> { let ret_layout = return_layout(fx); let ret_pass_mode = get_pass_mode(fx.tcx, ret_layout); - let ret_param = match ret_pass_mode { - PassMode::NoPass => { - fx.local_map - .insert(RETURN_PLACE, CPlace::no_place(ret_layout)); - Empty - } + let (ret_place, ret_param) = match ret_pass_mode { + PassMode::NoPass => (CPlace::no_place(ret_layout), Empty), PassMode::ByVal(_) | PassMode::ByValPair(_, _) => { let is_ssa = ssa_analyzed[RETURN_PLACE] == crate::analyze::SsaKind::Ssa; - - super::local_place(fx, RETURN_PLACE, ret_layout, is_ssa); - - Empty + ( + super::make_local_place(fx, RETURN_PLACE, ret_layout, is_ssa), + Empty, + ) } PassMode::ByRef { size: Some(_) } => { let ret_param = fx.bcx.append_block_param(start_block, fx.pointer_type); - fx.local_map.insert( - RETURN_PLACE, + ( CPlace::for_ptr(Pointer::new(ret_param), ret_layout), - ); - - Single(ret_param) + Single(ret_param), + ) } PassMode::ByRef { size: None } => todo!(), }; @@ -61,6 +55,8 @@ pub(super) fn codegen_return_param( ret_pass_mode, ret_layout.ty, ); + + ret_place } pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( diff --git a/src/base.rs b/src/base.rs index b01fb8fe6493d..0d86a6010be6a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -47,7 +47,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( bcx, block_map, - local_map: FxHashMap::with_capacity_and_hasher(mir.local_decls.len(), Default::default()), + local_map: IndexVec::with_capacity(mir.local_decls.len()), caller_location: None, // set by `codegen_fn_prelude` cold_blocks: EntitySet::new(), diff --git a/src/common.rs b/src/common.rs index d4b5d660ba8d8..9ac82eaeb3df6 100644 --- a/src/common.rs +++ b/src/common.rs @@ -297,7 +297,7 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) bcx: FunctionBuilder<'clif>, pub(crate) block_map: IndexVec, - pub(crate) local_map: FxHashMap>, + pub(crate) local_map: IndexVec>, /// When `#[track_caller]` is used, the implicit caller location is stored in this variable. pub(crate) caller_location: Option>, @@ -383,7 +383,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } pub(crate) fn get_local_place(&mut self, local: Local) -> CPlace<'tcx> { - *self.local_map.get(&local).unwrap_or_else(|| { + *self.local_map.get(local).unwrap_or_else(|| { panic!("Local {:?} doesn't exist", local); }) } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 70e0cf1a9e4ef..8f7d21dfb4fcc 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -4,6 +4,8 @@ mod unwind; use crate::prelude::*; +use rustc_index::vec::IndexVec; + use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir::{StackSlots, ValueLabel, ValueLoc}; use cranelift_codegen::isa::TargetIsa; @@ -269,7 +271,7 @@ impl<'tcx> DebugContext<'tcx> { isa: &dyn TargetIsa, context: &Context, source_info_set: &indexmap::IndexSet, - local_map: FxHashMap>, + local_map: IndexVec>, ) { let symbol = func_id.as_u32() as usize; let mir = self.tcx.instance_mir(instance.def); @@ -390,7 +392,7 @@ fn place_location<'tcx>( isa: &dyn TargetIsa, symbol: usize, context: &Context, - local_map: &FxHashMap>, + local_map: &IndexVec>, #[allow(rustc::default_hash_types)] value_labels_ranges: &std::collections::HashMap< ValueLabel, Vec, @@ -399,7 +401,7 @@ fn place_location<'tcx>( ) -> AttributeValue { assert!(place.projection.is_empty()); // FIXME implement them - match local_map[&place.local].inner() { + match local_map[place.local].inner() { CPlaceInner::Var(_local, var) => { let value_label = cranelift_codegen::ir::ValueLabel::new(var.index()); if let Some(value_loc_ranges) = value_labels_ranges.get(&value_label) { From 2cd8ccbea17524d563a2120964ff5fe42dfba61b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 18 Sep 2020 14:45:52 +0200 Subject: [PATCH 1509/1566] Don't benchmark mod_bench anymore --- example/mod_bench.rs | 2 +- test.sh | 19 ++----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/example/mod_bench.rs b/example/mod_bench.rs index 95bcad2cd173e..bc65221362346 100644 --- a/example/mod_bench.rs +++ b/example/mod_bench.rs @@ -20,7 +20,7 @@ unsafe extern "C" fn _Unwind_Resume() { #[start] fn main(_argc: isize, _argv: *const *const u8) -> isize { - for i in 2..100_000_000 { + for i in 2..10_000_000 { black_box((i + 1) % i); } diff --git a/test.sh b/test.sh index 67dd4d3aa0011..055ebfd8c724f 100755 --- a/test.sh +++ b/test.sh @@ -73,8 +73,9 @@ echo "[AOT] track-caller-attribute" $RUSTC example/track-caller-attribute.rs --crate-type bin -Cpanic=abort --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/track-caller-attribute -echo "[BUILD] mod_bench" +echo "[AOT] mod_bench" $RUSTC example/mod_bench.rs --crate-type bin --target $TARGET_TRIPLE +$RUN_WRAPPER ./target/out/mod_bench pushd rand rm -r ./target || true @@ -116,19 +117,3 @@ diff -u res.txt examples/regexdna-output.txt echo "[TEST] rust-lang/regex tests" ../cargo.sh test --tests -- --exclude-should-panic --test-threads 1 -Zunstable-options popd - -echo -echo "[BENCH COMPILE] mod_bench" - -COMPILE_MOD_BENCH_INLINE="$RUSTC example/mod_bench.rs --crate-type bin -Zmir-opt-level=3 -O --crate-name mod_bench_inline" -COMPILE_MOD_BENCH_LLVM_0="rustc example/mod_bench.rs --crate-type bin -Copt-level=0 -o target/out/mod_bench_llvm_0 -Cpanic=abort" -COMPILE_MOD_BENCH_LLVM_1="rustc example/mod_bench.rs --crate-type bin -Copt-level=1 -o target/out/mod_bench_llvm_1 -Cpanic=abort" -COMPILE_MOD_BENCH_LLVM_2="rustc example/mod_bench.rs --crate-type bin -Copt-level=2 -o target/out/mod_bench_llvm_2 -Cpanic=abort" -COMPILE_MOD_BENCH_LLVM_3="rustc example/mod_bench.rs --crate-type bin -Copt-level=3 -o target/out/mod_bench_llvm_3 -Cpanic=abort" - -# Use 100 runs, because a single compilations doesn't take more than ~150ms, so it isn't very slow -hyperfine --runs ${COMPILE_RUNS:-100} "$COMPILE_MOD_BENCH_INLINE" "$COMPILE_MOD_BENCH_LLVM_0" "$COMPILE_MOD_BENCH_LLVM_1" "$COMPILE_MOD_BENCH_LLVM_2" "$COMPILE_MOD_BENCH_LLVM_3" - -echo -echo "[BENCH RUN] mod_bench" -hyperfine --runs ${RUN_RUNS:-10} ./target/out/mod_bench{,_inline} ./target/out/mod_bench_llvm_* From a2c2db9cd68ce89f1f3b30e3855b83115678de8c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 20 Sep 2020 16:25:14 +0200 Subject: [PATCH 1510/1566] Rustup to rustc 1.48.0-nightly (f68e08933 2020-09-19) --- build_sysroot/Cargo.lock | 4 ++-- rust-toolchain | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 15b985eb8b9a7..0a628b1aa21ba 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -41,9 +41,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66120af515773fb005778dc07c261bd201ec8ce50bd6e7144c927753fe013381" +checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" [[package]] name = "cfg-if" diff --git a/rust-toolchain b/rust-toolchain index a4fe30c924006..753ad9df5dd3b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-09-14 +nightly-2020-09-20 From bac34647572d490dbb37f1e343f244e576222679 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 21 Sep 2020 14:56:19 +0200 Subject: [PATCH 1511/1566] Fix debug build --- src/base.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/base.rs b/src/base.rs index 0d86a6010be6a..b5598cb5f1e6a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -270,6 +270,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.bcx.ins().jump(target, &[]); fx.bcx.switch_to_block(failure); + fx.bcx.ins().nop(); let location = fx .get_caller_location(bb_data.terminator().source_info.span) @@ -720,6 +721,7 @@ fn trans_stmt<'tcx>( fx.bcx.ins().jump(loop_block, &[index]); fx.bcx.switch_to_block(done_block); + fx.bcx.ins().nop(); } } Rvalue::Len(place) => { From 1add4323cf463e615a11c1c2ffd67bb6b9c9d701 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 21 Sep 2020 19:23:39 +0200 Subject: [PATCH 1512/1566] Update Cranelift --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 2 +- src/backend.rs | 7 ++----- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f54157234da63..55ea61170f24d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" [[package]] name = "cranelift-entity" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" [[package]] name = "cranelift-frontend" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "anyhow", "cranelift-codegen", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#693c6ea7715060950702d85f2dcf16627026b0da" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" dependencies = [ "cranelift-codegen", "cranelift-module", @@ -371,9 +371,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" +checksum = "fe2635952a442a01fd4cb53d98858b5e4bb461b02c0d111f22f31772e3e7a8b2" [[package]] name = "thiserror" diff --git a/Cargo.toml b/Cargo.toml index 60f9a29960f63..d57556ef1912b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", br cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true } cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } -target-lexicon = "0.10.0" +target-lexicon = "0.11.0" gimli = { version = "0.21.0", default-features = false, features = ["write"]} object = { version = "0.21.1", default-features = false, features = ["std", "read_core", "write", "coff", "elf", "macho", "pe"] } diff --git a/src/backend.rs b/src/backend.rs index 0d654aed160ca..bf4e8d6e02ea1 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -159,13 +159,10 @@ pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object target_lexicon::BinaryFormat::Elf => object::BinaryFormat::Elf, target_lexicon::BinaryFormat::Coff => object::BinaryFormat::Coff, target_lexicon::BinaryFormat::Macho => object::BinaryFormat::MachO, - target_lexicon::BinaryFormat::Wasm => sess.fatal("binary format wasm is unsupported"), - target_lexicon::BinaryFormat::Unknown => sess.fatal("binary format is unknown"), + binary_format => sess.fatal(&format!("binary format {} is unsupported", binary_format)), }; let architecture = match triple.architecture { - target_lexicon::Architecture::I386 - | target_lexicon::Architecture::I586 - | target_lexicon::Architecture::I686 => object::Architecture::I386, + target_lexicon::Architecture::X86_32(_) => object::Architecture::I386, target_lexicon::Architecture::X86_64 => object::Architecture::X86_64, target_lexicon::Architecture::Arm(_) => object::Architecture::Arm, target_lexicon::Architecture::Aarch64(_) => object::Architecture::Aarch64, From cb3101d178da4c291225d5a5e7489a0cac14b833 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 22 Sep 2020 12:36:03 +0200 Subject: [PATCH 1513/1566] Improve rust-analyzer configuration --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index a33e82a017f1b..9495cb64139ce 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,7 @@ { + // source for rustc_* is not included in the rust-src component; disable the errors about this + "rust-analyzer.diagnostics.disabled": ["unresolved-extern-crate"], + "rust-analyzer.cargo.loadOutDirsFromCheck": true, "rust-analyzer.linkedProjects": [ "./Cargo.toml", //"./build_sysroot/sysroot_src/src/libstd/Cargo.toml", From e5b2b1ba8101bc9d5da6fb05e669fc8f9d784368 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 22 Sep 2020 13:06:14 +0200 Subject: [PATCH 1514/1566] Misc changes --- example/mini_core_hello_world.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index f1c037696d8b3..376056e19383f 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -1,7 +1,5 @@ -// Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs - #![feature( - no_core, unboxed_closures, start, lang_items, box_syntax, never_type, linkage, + no_core, start, lang_items, box_syntax, never_type, linkage, extern_types, thread_local )] #![no_core] From 829a51cae31589f0f995c4d143a5057a6257a4ed Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 09:38:49 +0200 Subject: [PATCH 1515/1566] Shorten __alloc symbol names a bit --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index d1248110d06cd..458ace9675dc5 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -274,7 +274,7 @@ fn data_id_for_alloc_id( ) -> DataId { module .declare_data( - &format!("__alloc_{}", alloc_id.0), + &format!("__alloc_{:x}", alloc_id.0), Linkage::Local, mutability == rustc_hir::Mutability::Mut, false, From e5437b650b53385a52f4ef5077ccb708a8aa1f0a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 09:38:28 +0200 Subject: [PATCH 1516/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55ea61170f24d..8803bc223984b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" [[package]] name = "cranelift-entity" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" [[package]] name = "cranelift-frontend" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "anyhow", "cranelift-codegen", @@ -134,7 +134,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#32db4dcbe98098e5be2e457339d6d1946c73225c" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" dependencies = [ "cranelift-codegen", "cranelift-module", From a0f876525132d548bb051b44f9b683c4af3db11e Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 09:43:35 +0200 Subject: [PATCH 1517/1566] Add option to use a single section for each function --- Readme.md | 3 +++ src/backend.rs | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Readme.md b/Readme.md index 2448505825015..f5a38f0843bc2 100644 --- a/Readme.md +++ b/Readme.md @@ -70,6 +70,9 @@ function jit_calc() { object files when their content should have been changed by a change to cg_clif.
CG_CLIF_DISPLAY_CG_TIME
If "1", display the time it took to perform codegen for a crate
+
CG_CLIF_FUNCTION_SECTIONS
+
Use a single section for each function. This will often reduce the executable size at the + cost of making linking significantly slower.
## Not yet supported diff --git a/src/backend.rs b/src/backend.rs index bf4e8d6e02ea1..d9cb1d939f773 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -186,13 +186,17 @@ pub(crate) type Backend = impl cranelift_module::Backend; pub(crate) fn make_module(sess: &Session, name: String) -> Module { + let mut builder = ObjectBuilder::new( + crate::build_isa(sess, true), + name + ".o", + cranelift_module::default_libcall_names(), + ) + .unwrap(); + if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() { + builder.per_function_section(true); + } let module: Module = Module::new( - ObjectBuilder::new( - crate::build_isa(sess, true), - name + ".o", - cranelift_module::default_libcall_names(), - ) - .unwrap(), + builder, ); module } From 94f11cc3a886ef1a6b057463f300e96f1586ce78 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 10:00:09 +0200 Subject: [PATCH 1518/1566] Use pcrel pointers in .eh_frame Fixes #1055 --- src/backend.rs | 15 +++++++++--- src/debuginfo/emit.rs | 53 +++++++++++++++++++++++++++++++++++++++-- src/debuginfo/unwind.rs | 5 +++- 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index d9cb1d939f773..072fdc1f246da 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -68,8 +68,17 @@ impl WriteDebugInfo for ObjectProduct { .into_bytes(); let segment = self.object.segment_name(StandardSegment::Debug).to_vec(); - let section_id = self.object.add_section(segment, name, SectionKind::Debug); - self.object.section_mut(section_id).set_data(data, 1); + // FIXME use SHT_X86_64_UNWIND for .eh_frame + let section_id = self.object.add_section(segment, name.clone(), if id == SectionId::EhFrame { + SectionKind::ReadOnlyData + } else { + SectionKind::Debug + }); + self.object.section_mut(section_id).set_data(data, if id == SectionId::EhFrame { + 8 + } else { + 1 + }); let symbol_id = self.object.section_symbol(section_id); (section_id, symbol_id) } @@ -95,7 +104,7 @@ impl WriteDebugInfo for ObjectProduct { Relocation { offset: u64::from(reloc.offset), symbol, - kind: RelocationKind::Absolute, + kind: reloc.kind, encoding: RelocationEncoding::Generic, size: reloc.size * 8, addend: i64::try_from(symbol_offset).unwrap() + reloc.addend, diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 01cb6d3484db3..22e284b9df40d 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -46,6 +46,7 @@ pub(crate) struct DebugReloc { pub(crate) size: u8, pub(crate) name: DebugRelocName, pub(crate) addend: i64, + pub(crate) kind: object::RelocationKind, } #[derive(Clone)] @@ -122,14 +123,13 @@ impl Writer for WriterRelocate { size, name: DebugRelocName::Symbol(symbol), addend: addend as i64, + kind: object::RelocationKind::Absolute, }); self.write_udata(0, size) } } } - // TODO: implement write_eh_pointer - fn write_offset(&mut self, val: usize, section: SectionId, size: u8) -> Result<()> { let offset = self.len() as u32; self.relocs.push(DebugReloc { @@ -137,6 +137,7 @@ impl Writer for WriterRelocate { size, name: DebugRelocName::Section(section), addend: val as i64, + kind: object::RelocationKind::Absolute, }); self.write_udata(0, size) } @@ -153,7 +154,55 @@ impl Writer for WriterRelocate { size, name: DebugRelocName::Section(section), addend: val as i64, + kind: object::RelocationKind::Absolute, }); self.write_udata_at(offset, 0, size) } + + fn write_eh_pointer( + &mut self, + address: Address, + eh_pe: gimli::DwEhPe, + size: u8, + ) -> Result<()> { + match address { + // Address::Constant arm copied from gimli + Address::Constant(val) => { + // Indirect doesn't matter here. + let val = match eh_pe.application() { + gimli::DW_EH_PE_absptr => val, + gimli::DW_EH_PE_pcrel => { + // TODO: better handling of sign + let offset = self.len() as u64; + offset.wrapping_sub(val) + } + _ => { + return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); + } + }; + self.write_eh_pointer_data(val, eh_pe.format(), size) + } + Address::Symbol { symbol, addend } => { + match eh_pe.application() { + gimli::DW_EH_PE_pcrel => { + let size = match eh_pe.format() { + gimli::DW_EH_PE_sdata4 => 4, + _ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)), + }; + self.relocs.push(DebugReloc { + offset: self.len() as u32, + size, + name: DebugRelocName::Symbol(symbol), + addend, + kind: object::RelocationKind::Relative, + }); + self.write_udata(0, size) + } + _ => { + return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); + } + } + } + } + } } diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 4c23f75be699c..39a951e5eca47 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -16,7 +16,10 @@ impl<'tcx> UnwindContext<'tcx> { pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self { let mut frame_table = FrameTable::default(); - let cie_id = if let Some(cie) = isa.create_systemv_cie() { + let cie_id = if let Some(mut cie) = isa.create_systemv_cie() { + if isa.flags().is_pic() { + cie.fde_address_encoding = gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0); + } Some(frame_table.add_cie(cie)) } else { None From 934d56a6467c96c6f029dd9b4129c08b1b3117a9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 14:29:18 +0200 Subject: [PATCH 1519/1566] Also allow returning PassMode::ByValPair directly into an ssa var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Benchmark #1: ./raytracer_cg_clif_pre Time (mean ± σ): 8.251 s ± 0.021 s [User: 8.245 s, System: 0.005 s] Range (min … max): 8.225 s … 8.292 s 10 runs Benchmark #2: ./raytracer_cg_clif_post Time (mean ± σ): 8.206 s ± 0.043 s [User: 8.199 s, System: 0.007 s] Range (min … max): 8.168 s … 8.279 s 10 runs --- src/abi/returning.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 690f5cd5cba33..f56468d475555 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -10,9 +10,9 @@ pub(crate) fn can_return_to_ssa_var<'tcx>( dest_layout: TyAndLayout<'tcx>, ) -> bool { match get_pass_mode(tcx, dest_layout) { - PassMode::NoPass | PassMode::ByVal(_) => true, - // FIXME Make it possible to return ByValPair and ByRef to an ssa var. - PassMode::ByValPair(_, _) | PassMode::ByRef { size: _ } => false, + PassMode::NoPass | PassMode::ByVal(_) | PassMode::ByValPair(_, _) => true, + // FIXME Make it possible to return ByRef to an ssa var. + PassMode::ByRef { size: _ } => false, } } From c8699076f9d9078f401188e533283dd25de07439 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 15:13:49 +0200 Subject: [PATCH 1520/1566] Document almost all modules Fixes #1082 --- src/abi/comments.rs | 3 ++ src/abi/mod.rs | 3 ++ src/abi/pass_mode.rs | 5 ++ src/abi/returning.rs | 8 +++ src/allocator.rs | 11 +--- src/analyze.rs | 2 + src/archive.rs | 2 + src/backend.rs | 2 + src/base.rs | 2 + src/cast.rs | 2 + src/codegen_i128.rs | 2 +- src/common.rs | 2 +- src/constant.rs | 2 + src/debuginfo/emit.rs | 4 ++ src/debuginfo/line_info.rs | 2 + src/debuginfo/mod.rs | 2 + src/debuginfo/unwind.rs | 2 + src/discriminant.rs | 2 + src/driver/aot.rs | 3 ++ src/driver/jit.rs | 3 ++ src/driver/mod.rs | 3 ++ src/inline_asm.rs | 2 + src/intrinsics/cpuid.rs | 4 +- src/intrinsics/llvm.rs | 2 + src/intrinsics/mod.rs | 3 ++ src/intrinsics/simd.rs | 2 + src/metadata.rs | 2 + src/num.rs | 2 + src/optimize/mod.rs | 2 + src/pointer.rs | 4 ++ src/pretty_clif.rs | 108 ++++++++++++++++++------------------- src/toolchain.rs | 2 + src/trap.rs | 2 + src/unsize.rs | 4 ++ src/value_and_place.rs | 2 + src/vtable.rs | 3 ++ 36 files changed, 145 insertions(+), 66 deletions(-) diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 5d1a6c6ade50c..f63a4565a72a6 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -1,3 +1,6 @@ +//! Annotate the clif ir with comments describing how arguments are passed into the current function +//! and where all locals are stored. + use std::borrow::Cow; use rustc_middle::mir; diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 7065eefe17066..f55d94b0a0979 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -1,3 +1,5 @@ +//! Handling of everything related to the calling convention. Also fills `fx.local_map`. + #[cfg(debug_assertions)] mod comments; mod pass_mode; @@ -325,6 +327,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { } } +/// Make a [`CPlace`] capable of holding value of the specified type. fn make_local_place<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, local: Local, diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 49aaf22058d21..6033cd88da9f9 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -1,3 +1,5 @@ +//! Argument passing + use crate::prelude::*; pub(super) use EmptySinglePair::*; @@ -118,6 +120,7 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) } } +/// Get a set of values to be passed as function arguments. pub(super) fn adjust_arg_for_abi<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, arg: CValue<'tcx>, @@ -136,6 +139,8 @@ pub(super) fn adjust_arg_for_abi<'tcx>( } } +/// Create a [`CValue`] containing the value of a function parameter adding clif function parameters +/// as necessary. pub(super) fn cvalue_for_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_block: Block, diff --git a/src/abi/returning.rs b/src/abi/returning.rs index f56468d475555..4505caa67dd51 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -1,3 +1,5 @@ +//! Return value handling + use crate::abi::pass_mode::*; use crate::prelude::*; @@ -5,6 +7,7 @@ fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyAnd fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty)) } +/// Can the given type be returned into an ssa var or does it need to be returned on the stack. pub(crate) fn can_return_to_ssa_var<'tcx>( tcx: TyCtxt<'tcx>, dest_layout: TyAndLayout<'tcx>, @@ -16,6 +19,8 @@ pub(crate) fn can_return_to_ssa_var<'tcx>( } } +/// Return a place where the return value of the current function can be written to. If necessary +/// this adds an extra parameter pointing to where the return value needs to be stored. pub(super) fn codegen_return_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, ssa_analyzed: &rustc_index::vec::IndexVec, @@ -59,6 +64,8 @@ pub(super) fn codegen_return_param<'tcx>( ret_place } +/// Invokes the closure with if necessary a value representing the return pointer. When the closure +/// returns the call return value(s) if any are written to the correct place. pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( fx: &mut FunctionCx<'_, 'tcx, B>, fn_sig: FnSig<'tcx>, @@ -102,6 +109,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( (call_inst, meta) } +/// Codegen a return instruction with the right return value(s) if any. pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { match get_pass_mode(fx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { size: Some(_) } => { diff --git a/src/allocator.rs b/src/allocator.rs index 894e47dd439ca..95beb93f26f1d 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -1,12 +1,5 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +//! Allocator shim +// Adapted from rustc use crate::prelude::*; diff --git a/src/analyze.rs b/src/analyze.rs index 055b371f43c3c..06434bdf69c5a 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -1,3 +1,5 @@ +//! SSA analysis + use crate::prelude::*; use rustc_index::vec::IndexVec; diff --git a/src/archive.rs b/src/archive.rs index 60975c89af6fb..fe2c2f100eec8 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,3 +1,5 @@ +//! Creation of ar archives like for the lib and staticlib crate type + use std::collections::BTreeMap; use std::fs::File; use std::path::{Path, PathBuf}; diff --git a/src/backend.rs b/src/backend.rs index 072fdc1f246da..f6c06f7f88e24 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1,3 +1,5 @@ +//! Abstraction around the object writing crate + use std::convert::{TryFrom, TryInto}; use rustc_data_structures::fx::FxHashMap; diff --git a/src/base.rs b/src/base.rs index b5598cb5f1e6a..1bacfb3fe740c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -1,3 +1,5 @@ +//! Codegen of a single function + use rustc_index::vec::IndexVec; use rustc_middle::ty::adjustment::PointerCast; diff --git a/src/cast.rs b/src/cast.rs index 36e060496b1da..edfe6feb6c8a2 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -1,3 +1,5 @@ +//! Various number casting functions + use crate::prelude::*; pub(crate) fn clif_intcast( diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index cbce7d9d1287d..99bd526ad01a8 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -1,4 +1,4 @@ -//! Replaces 128-bit operators with lang item calls +//! Replaces 128-bit operators with lang item calls where necessary use crate::prelude::*; diff --git a/src/common.rs b/src/common.rs index 9ac82eaeb3df6..d1375c73a4b21 100644 --- a/src/common.rs +++ b/src/common.rs @@ -302,7 +302,7 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { /// When `#[track_caller]` is used, the implicit caller location is stored in this variable. pub(crate) caller_location: Option>, - /// See [crate::optimize::code_layout] for more information. + /// See [`crate::optimize::code_layout`] for more information. pub(crate) cold_blocks: EntitySet, pub(crate) clif_comments: crate::pretty_clif::CommentWriter, diff --git a/src/constant.rs b/src/constant.rs index 458ace9675dc5..c01256b7f74ba 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -1,3 +1,5 @@ +//! Handling of `static`s, `const`s and promoted allocations + use rustc_span::DUMMY_SP; use rustc_data_structures::fx::FxHashSet; diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 22e284b9df40d..0a887e8cb5932 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -1,3 +1,5 @@ +//! Write the debuginfo into an object file. + use rustc_data_structures::fx::FxHashMap; use gimli::write::{Address, AttributeValue, EndianVec, Result, Sections, Writer}; @@ -55,6 +57,7 @@ pub(crate) enum DebugRelocName { Symbol(usize), } +/// A [`Writer`] that collects all necessary relocations. #[derive(Clone)] pub(super) struct WriterRelocate { pub(super) relocs: Vec, @@ -69,6 +72,7 @@ impl WriterRelocate { } } + /// Perform the collected relocations to be usable for JIT usage. #[cfg(feature = "jit")] pub(super) fn relocate_for_jit( mut self, diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 798064b07a588..4de8485532896 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -1,3 +1,5 @@ +//! Line info generation (`.debug_line`) + use std::ffi::OsStr; use std::path::{Component, Path}; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 8f7d21dfb4fcc..9cad668e3f6aa 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -1,3 +1,5 @@ +//! Handling of everything related to debuginfo. + mod emit; mod line_info; mod unwind; diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 39a951e5eca47..fa1a9d44117fc 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -1,3 +1,5 @@ +//! Unwind info generation (`.eh_frame`) + use crate::prelude::*; use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa}; diff --git a/src/discriminant.rs b/src/discriminant.rs index 53a6acd7c858e..231802dfb859b 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -1,3 +1,5 @@ +//! Handling of enum discriminants +//! //! Adapted from https://github.com/rust-lang/rust/blob/d760df5aea483aae041c9a241e7acacf48f75035/src/librustc_codegen_ssa/mir/place.rs use rustc_target::abi::{Int, TagEncoding, Variants}; diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 2eecd8c3c0adb..2cf136ceb674b 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -1,3 +1,6 @@ +//! The AOT driver uses [`cranelift_object`] to write object files suitable for linking into a +//! standalone executable. + use std::path::PathBuf; use rustc_codegen_ssa::back::linker::LinkerInfo; diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 195cea02cde87..edeeb7670e9e1 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -1,3 +1,6 @@ +//! The JIT driver uses [`cranelift_simplejit`] to JIT execute programs without writing any object +//! files. + use std::ffi::CString; use std::os::raw::{c_char, c_int}; diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 304add6f60434..0224f929ac7f6 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,3 +1,6 @@ +//! Drivers are responsible for calling [`codegen_mono_items`] and performing any further actions +//! like JIT executing or writing object files. + use std::any::Any; use rustc_middle::middle::cstore::EncodedMetadata; diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 35b175917446c..e11ba4a4f6370 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -1,3 +1,5 @@ +//! Codegen of [`asm!`] invocations. + use crate::prelude::*; use std::fmt::Write; diff --git a/src/intrinsics/cpuid.rs b/src/intrinsics/cpuid.rs index 48891ab25452f..94c280ee0badb 100644 --- a/src/intrinsics/cpuid.rs +++ b/src/intrinsics/cpuid.rs @@ -1,6 +1,8 @@ +//! Emulation of a subset of the cpuid x86 instruction. + use crate::prelude::*; -/// Emulates a subset of the cpuid call. +/// Emulates a subset of the cpuid x86 instruction. /// /// This emulates an intel cpu with sse and sse2 support, but which doesn't support anything else. pub(crate) fn codegen_cpuid_call<'tcx>( diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index ab1c888b4c00c..cc919f97616a3 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -1,3 +1,5 @@ +//! Emulate LLVM intrinsics + use crate::intrinsics::*; use crate::prelude::*; diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index fd95c25b572d5..0b7cc7bee900c 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -1,3 +1,6 @@ +//! Codegen of intrinsics. This includes `extern "rust-intrinsic"`, `extern "platform-intrinsic"` +//! and LLVM intrinsics that have symbol names starting with `llvm.`. + mod cpuid; mod llvm; mod simd; diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index cb6e1d2098355..93724522e76b7 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -1,3 +1,5 @@ +//! Codegen `extern "platform-intrinsic"` intrinsics. + use super::*; use crate::prelude::*; diff --git a/src/metadata.rs b/src/metadata.rs index 9fdd372594097..93cff5711d937 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -1,3 +1,5 @@ +//! Reading and writing of the rustc metadata for rlibs and dylibs + use std::convert::TryFrom; use std::fs::File; use std::path::Path; diff --git a/src/num.rs b/src/num.rs index 3c290026776d1..4e3b79cd2d6f9 100644 --- a/src/num.rs +++ b/src/num.rs @@ -1,3 +1,5 @@ +//! Various operations on integer and floating-point numbers + use crate::prelude::*; pub(crate) fn bin_op_to_intcc(bin_op: BinOp, signed: bool) -> Option { diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index ae9692790896c..3ce7f8cd9a831 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -1,3 +1,5 @@ +//! Various optimizations specific to cg_clif + use crate::prelude::*; mod code_layout; diff --git a/src/pointer.rs b/src/pointer.rs index 5295b296cde5a..cd3f27c324777 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -1,9 +1,13 @@ +//! Defines [`Pointer`] which is used to improve the quality of the generated clif ir for pointer +//! operations. + use crate::prelude::*; use rustc_target::abi::Align; use cranelift_codegen::ir::immediates::Offset32; +/// A pointer pointing either to a certain address, a certain stack slot or nothing. #[derive(Copy, Clone, Debug)] pub(crate) struct Pointer { base: PointerBase, diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 6d8d085529c46..5c4d951bc5076 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -1,3 +1,57 @@ +//! This module provides the [CommentWriter] which makes it possible +//! to add comments to the written cranelift ir. +//! +//! # Example +//! +//! ```clif +//! test compile +//! target x86_64 +//! +//! function u0:0(i64, i64, i64) system_v { +//! ; symbol _ZN119_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$u27$a$u20$$RF$$u27$b$u20$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17he85059d5e6a760a0E +//! ; instance Instance { def: Item(DefId(0/0:29 ~ example[8787]::{{impl}}[0]::call_once[0])), substs: [ReErased, ReErased] } +//! ; sig ([IsNotEmpty, (&&[u16],)]; c_variadic: false)->(u8, u8) +//! +//! ; ssa {_2: NOT_SSA, _4: NOT_SSA, _0: NOT_SSA, _3: (empty), _1: NOT_SSA} +//! ; msg loc.idx param pass mode ssa flags ty +//! ; ret _0 = v0 ByRef NOT_SSA (u8, u8) +//! ; arg _1 = v1 ByRef NOT_SSA IsNotEmpty +//! ; arg _2.0 = v2 ByVal(types::I64) NOT_SSA &&[u16] +//! +//! ss0 = explicit_slot 0 ; _1: IsNotEmpty size=0 align=1,8 +//! ss1 = explicit_slot 8 ; _2: (&&[u16],) size=8 align=8,8 +//! ss2 = explicit_slot 8 ; _4: (&&[u16],) size=8 align=8,8 +//! sig0 = (i64, i64, i64) system_v +//! sig1 = (i64, i64, i64) system_v +//! fn0 = colocated u0:6 sig1 ; Instance { def: Item(DefId(0/0:31 ~ example[8787]::{{impl}}[1]::call_mut[0])), substs: [ReErased, ReErased] } +//! +//! block0(v0: i64, v1: i64, v2: i64): +//! v3 = stack_addr.i64 ss0 +//! v4 = stack_addr.i64 ss1 +//! store v2, v4 +//! v5 = stack_addr.i64 ss2 +//! jump block1 +//! +//! block1: +//! nop +//! ; _3 = &mut _1 +//! ; _4 = _2 +//! v6 = load.i64 v4 +//! store v6, v5 +//! ; +//! ; _0 = const mini_core::FnMut::call_mut(move _3, move _4) +//! v7 = load.i64 v5 +//! call fn0(v0, v3, v7) +//! jump block2 +//! +//! block2: +//! nop +//! ; +//! ; return +//! return +//! } +//! ``` + use std::fmt; use cranelift_codegen::{ @@ -10,60 +64,6 @@ use rustc_session::config::OutputType; use crate::prelude::*; -/// This module provides the [CommentWriter] which makes it possible -/// to add comments to the written cranelift ir. -/// -/// # Example -/// -/// ```clif -/// test compile -/// target x86_64 -/// -/// function u0:0(i64, i64, i64) system_v { -/// ; symbol _ZN119_$LT$example..IsNotEmpty$u20$as$u20$mini_core..FnOnce$LT$$LP$$RF$$u27$a$u20$$RF$$u27$b$u20$$u5b$u16$u5d$$C$$RP$$GT$$GT$9call_once17he85059d5e6a760a0E -/// ; instance Instance { def: Item(DefId(0/0:29 ~ example[8787]::{{impl}}[0]::call_once[0])), substs: [ReErased, ReErased] } -/// ; sig ([IsNotEmpty, (&&[u16],)]; c_variadic: false)->(u8, u8) -/// -/// ; ssa {_2: NOT_SSA, _4: NOT_SSA, _0: NOT_SSA, _3: (empty), _1: NOT_SSA} -/// ; msg loc.idx param pass mode ssa flags ty -/// ; ret _0 = v0 ByRef NOT_SSA (u8, u8) -/// ; arg _1 = v1 ByRef NOT_SSA IsNotEmpty -/// ; arg _2.0 = v2 ByVal(types::I64) NOT_SSA &&[u16] -/// -/// ss0 = explicit_slot 0 ; _1: IsNotEmpty size=0 align=1,8 -/// ss1 = explicit_slot 8 ; _2: (&&[u16],) size=8 align=8,8 -/// ss2 = explicit_slot 8 ; _4: (&&[u16],) size=8 align=8,8 -/// sig0 = (i64, i64, i64) system_v -/// sig1 = (i64, i64, i64) system_v -/// fn0 = colocated u0:6 sig1 ; Instance { def: Item(DefId(0/0:31 ~ example[8787]::{{impl}}[1]::call_mut[0])), substs: [ReErased, ReErased] } -/// -/// block0(v0: i64, v1: i64, v2: i64): -/// v3 = stack_addr.i64 ss0 -/// v4 = stack_addr.i64 ss1 -/// store v2, v4 -/// v5 = stack_addr.i64 ss2 -/// jump block1 -/// -/// block1: -/// nop -/// ; _3 = &mut _1 -/// ; _4 = _2 -/// v6 = load.i64 v4 -/// store v6, v5 -/// ; -/// ; _0 = const mini_core::FnMut::call_mut(move _3, move _4) -/// v7 = load.i64 v5 -/// call fn0(v0, v3, v7) -/// jump block2 -/// -/// block2: -/// nop -/// ; -/// ; return -/// return -/// } -/// ``` - #[derive(Debug)] pub(crate) struct CommentWriter { global_comments: Vec, diff --git a/src/toolchain.rs b/src/toolchain.rs index 121f4477b80e0..d1329d5de7e0c 100644 --- a/src/toolchain.rs +++ b/src/toolchain.rs @@ -1,3 +1,5 @@ +//! Locating various executables part of a C toolchain. + use std::path::PathBuf; use rustc_middle::bug; diff --git a/src/trap.rs b/src/trap.rs index e69e63e4d49e9..7ab3a4a88c26a 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -1,3 +1,5 @@ +//! Helpers used to print a message and abort in case of certain panics and some detected UB. + use crate::prelude::*; fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { diff --git a/src/unsize.rs b/src/unsize.rs index 962fcaf48efc3..441d2b5edd893 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -1,3 +1,7 @@ +//! Codegen of the [`PointerCast::Unsize`] operation. +//! +//! [`PointerCast::Unsize`]: `rustc_middle::ty::adjustment::PointerCast::Unsize` + use crate::prelude::*; // Adapted from https://github.com/rust-lang/rust/blob/2a663555ddf36f6b041445894a8c175cd1bc718c/src/librustc_codegen_ssa/base.rs#L159-L307 diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 765c482e83cdb..5e663425117f0 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -1,3 +1,5 @@ +//! Definition of [`CValue`] and [`CPlace`] + use crate::prelude::*; use cranelift_codegen::entity::EntityRef; diff --git a/src/vtable.rs b/src/vtable.rs index c58b39c1c8244..d6bb9c912b557 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -1,4 +1,7 @@ +//! Codegen vtables and vtable accesses. +//! //! See librustc_codegen_llvm/meth.rs for reference +// FIXME dedup this logic between miri, cg_llvm and cg_clif use crate::prelude::*; From 8a59808b24a728a7034bd697206c4921211569ba Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 16:44:02 +0200 Subject: [PATCH 1521/1566] Improve readme --- Readme.md | 18 ++---------------- docs/env_vars.md | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 docs/env_vars.md diff --git a/Readme.md b/Readme.md index f5a38f0843bc2..c4e55975541d3 100644 --- a/Readme.md +++ b/Readme.md @@ -2,7 +2,7 @@ > ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠ -The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). This has the potential to improve compilation times in debug mode. If your project doesn't use any of the things listed under "Not yet supported", it should probably work fine. If not please open an issue. +The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/master/cranelift). This has the potential to improve compilation times in debug mode. If your project doesn't use any of the things listed under "Not yet supported", it should work fine. If not please open an issue. ## Building @@ -59,21 +59,7 @@ function jit_calc() { ## Env vars -
-
CG_CLIF_JIT
-
Enable JIT mode to immediately run a program instead of writing an executable file.
-
CG_CLIF_JIT_ARGS
-
When JIT mode is enable pass these arguments to the program.
-
CG_CLIF_INCR_CACHE_DISABLED
-
Don't cache object files in the incremental cache. Useful during development of cg_clif - to make it possible to use incremental mode for all analyses performed by rustc without caching - object files when their content should have been changed by a change to cg_clif.
-
CG_CLIF_DISPLAY_CG_TIME
-
If "1", display the time it took to perform codegen for a crate
-
CG_CLIF_FUNCTION_SECTIONS
-
Use a single section for each function. This will often reduce the executable size at the - cost of making linking significantly slower.
-
+[see env_vars.md](docs/env_vars.md) ## Not yet supported diff --git a/docs/env_vars.md b/docs/env_vars.md new file mode 100644 index 0000000000000..3707909a97802 --- /dev/null +++ b/docs/env_vars.md @@ -0,0 +1,17 @@ +# List of env vars recognized by cg_clif + +
+
CG_CLIF_JIT
+
Enable JIT mode to immediately run a program instead of writing an executable file.
+
CG_CLIF_JIT_ARGS
+
When JIT mode is enable pass these arguments to the program.
+
CG_CLIF_INCR_CACHE_DISABLED
+
Don't cache object files in the incremental cache. Useful during development of cg_clif + to make it possible to use incremental mode for all analyses performed by rustc without caching + object files when their content should have been changed by a change to cg_clif.
+
CG_CLIF_DISPLAY_CG_TIME
+
If "1", display the time it took to perform codegen for a crate
+
CG_CLIF_FUNCTION_SECTIONS
+
Use a single section for each function. This will often reduce the executable size at the + cost of making linking significantly slower.
+
From d68b50efb306f102bb06f15c044facc3c287cd6c Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 23 Sep 2020 18:34:54 +0200 Subject: [PATCH 1522/1566] Small change to test script --- scripts/config.sh | 2 ++ test.sh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/config.sh b/scripts/config.sh index 93db4a54a565a..b6479e4f696fc 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -17,7 +17,9 @@ TARGET_TRIPLE=$HOST_TRIPLE linker='' RUN_WRAPPER='' +export JIT_SUPPORTED=1 if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then + export JIT_SUPPORTED=0 if [[ "$TARGET_TRIPLE" == "aarch64-unknown-linux-gnu" ]]; then # We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. linker='-Clinker=aarch64-linux-gnu-gcc' diff --git a/test.sh b/test.sh index 055ebfd8c724f..ef50a4fc729b4 100755 --- a/test.sh +++ b/test.sh @@ -26,7 +26,7 @@ $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --targ echo "[BUILD] example" $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE -if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then +if [[ "$JIT_SUPPORTED" = "1" ]]; then echo "[JIT] mini_core_hello_world" CG_CLIF_JIT=1 CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE else @@ -49,7 +49,7 @@ echo "[AOT] alloc_example" $RUSTC example/alloc_example.rs --crate-type bin --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/alloc_example -if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then +if [[ "$JIT_SUPPORTED" = "1" ]]; then echo "[JIT] std_example" CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs --target $HOST_TRIPLE else From 3ece9fa92a186f2e8a1281505b6d1d15666564f0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 26 Sep 2020 11:48:26 +0200 Subject: [PATCH 1523/1566] Remove dead code --- src/intrinsics/llvm.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index cc919f97616a3..8bd744dbc3541 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -12,22 +12,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( args: &[mir::Operand<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, ) { - let ret = match destination { - Some((place, _)) => place, - None => { - // Insert non returning intrinsics here - match intrinsic { - "abort" => { - trap_panic(fx, "Called intrinsic::abort."); - } - "unreachable" => { - trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); - } - _ => unimplemented!("unsupported instrinsic {}", intrinsic), - } - return; - } - }; + let ret = destination.unwrap().0; intrinsic_match! { fx, intrinsic, substs, args, From bcb0862703698810c67829511436133040210641 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 13:17:01 +0200 Subject: [PATCH 1524/1566] Enable incr comp for release mode in Cargo.toml --- Cargo.toml | 3 +++ test.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d57556ef1912b..86cc6c45019b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,9 @@ opt-level = 3 # Disabling optimizations for cg_clif itself makes compilation after a change faster. opt-level = 0 +[profile.release.package.rustc_codegen_cranelift] +incremental = true + # Disable optimizations and debuginfo of build scripts and some of the heavy build deps, as the # execution time of build scripts is so fast that optimizing them slows down the total build time. [profile.dev.build-override] diff --git a/test.sh b/test.sh index ef50a4fc729b4..3028f5955ed98 100755 --- a/test.sh +++ b/test.sh @@ -4,7 +4,7 @@ set -e # Build cg_clif if [[ "$1" == "--release" ]]; then export CHANNEL='release' - CARGO_INCREMENTAL=1 cargo rustc --release -- -Zrun_dsymutil=no + cargo rustc --release -- -Zrun_dsymutil=no else export CHANNEL='debug' cargo rustc -- -Zrun_dsymutil=no From c0507a63fb30a14ea7b819af8241b6555d4ffea8 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 13:22:01 +0200 Subject: [PATCH 1525/1566] Invoke panic handler instead of trap for assert_* intrinsics --- src/base.rs | 89 ++++++++++++++++++++++++++----------------- src/intrinsics/mod.rs | 22 ++++++++--- src/trap.rs | 8 ++-- 3 files changed, 75 insertions(+), 44 deletions(-) diff --git a/src/base.rs b/src/base.rs index 1bacfb3fe740c..d1b97420aa28d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -274,47 +274,26 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.bcx.switch_to_block(failure); fx.bcx.ins().nop(); - let location = fx - .get_caller_location(bb_data.terminator().source_info.span) - .load_scalar(fx); - - let args; - let lang_item = match msg { + match msg { AssertKind::BoundsCheck { ref len, ref index } => { let len = trans_operand(fx, len).load_scalar(fx); let index = trans_operand(fx, index).load_scalar(fx); - args = [index, len, location]; - rustc_hir::LangItem::PanicBoundsCheck + let location = fx + .get_caller_location(bb_data.terminator().source_info.span) + .load_scalar(fx); + + codegen_panic_inner( + fx, + rustc_hir::LangItem::PanicBoundsCheck, + &[index, len, location], + bb_data.terminator().source_info.span, + ); } _ => { let msg_str = msg.description(); - let msg_ptr = fx.anonymous_str("assert", msg_str); - let msg_len = fx - .bcx - .ins() - .iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap()); - args = [msg_ptr, msg_len, location]; - rustc_hir::LangItem::Panic + codegen_panic(fx, msg_str, bb_data.terminator().source_info.span); } - }; - - let def_id = fx.tcx.lang_items().require(lang_item).unwrap_or_else(|s| { - fx.tcx - .sess - .span_fatal(bb_data.terminator().source_info.span, &s) - }); - - let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); - let symbol_name = fx.tcx.symbol_name(instance).name; - - fx.lib_call( - &*symbol_name, - vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], - vec![], - &args, - ); - - crate::trap::trap_unreachable(fx, "panic lang item returned"); + } } TerminatorKind::SwitchInt { @@ -997,3 +976,45 @@ pub(crate) fn trans_operand<'tcx>( Operand::Constant(const_) => crate::constant::trans_constant(fx, const_), } } + +pub(crate) fn codegen_panic<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + msg_str: &str, + span: Span, +) { + let location = fx.get_caller_location(span).load_scalar(fx); + + let msg_ptr = fx.anonymous_str("assert", msg_str); + let msg_len = fx + .bcx + .ins() + .iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap()); + let args = [msg_ptr, msg_len, location]; + + codegen_panic_inner(fx, rustc_hir::LangItem::Panic, &args, span); +} + +pub(crate) fn codegen_panic_inner<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + lang_item: rustc_hir::LangItem, + 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 instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); + let symbol_name = fx.tcx.symbol_name(instance).name; + + fx.lib_call( + &*symbol_name, + vec![fx.pointer_type, fx.pointer_type, fx.pointer_type], + vec![], + args, + ); + + crate::trap::trap_unreachable(fx, "panic lang item returned"); +} diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 0b7cc7bee900c..e75e83b56d69e 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -413,13 +413,13 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( // Insert non returning intrinsics here match intrinsic { "abort" => { - trap_panic(fx, "Called intrinsic::abort."); + trap_abort(fx, "Called intrinsic::abort."); } "unreachable" => { trap_unreachable(fx, "[corruption] Called intrinsic::unreachable."); } "transmute" => { - trap_unreachable(fx, "[corruption] Transmuting to uninhabited type."); + crate::base::codegen_panic(fx, "Transmuting to uninhabited type.", span); } _ => unimplemented!("unsupported instrinsic {}", intrinsic), } @@ -819,17 +819,29 @@ pub(crate) fn codegen_intrinsic_call<'tcx>( assert_inhabited | assert_zero_valid | assert_uninit_valid, () { let layout = fx.layout_of(T); if layout.abi.is_uninhabited() { - crate::trap::trap_panic(fx, &format!("attempted to instantiate uninhabited type `{}`", T)); + crate::base::codegen_panic( + fx, + &format!("attempted to instantiate uninhabited type `{}`", T), + span, + ); return; } if intrinsic == "assert_zero_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ true).unwrap() { - crate::trap::trap_panic(fx, &format!("attempted to zero-initialize type `{}`, which is invalid", T)); + crate::base::codegen_panic( + fx, + &format!("attempted to zero-initialize type `{}`, which is invalid", T), + span, + ); return; } if intrinsic == "assert_uninit_valid" && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() { - crate::trap::trap_panic(fx, &format!("attempted to leave type `{}` uninitialized, which is invalid", T)); + crate::base::codegen_panic( + fx, + &format!("attempted to leave type `{}` uninitialized, which is invalid", T), + span, + ); return; } }; diff --git a/src/trap.rs b/src/trap.rs index 7ab3a4a88c26a..f3ce0ee4beb94 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -28,15 +28,13 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms fx.bcx.ins().call(puts, &[msg_ptr]); } -/// Use this when `rustc_codegen_llvm` would insert a call to the panic handler. -/// -/// Trap code: user0 -pub(crate) fn trap_panic( +/// Trap code: user1 +pub(crate) fn trap_abort( fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: impl AsRef, ) { codegen_print(fx, msg.as_ref()); - fx.bcx.ins().trap(TrapCode::User(0)); + fx.bcx.ins().trap(TrapCode::User(1)); } /// Use this for example when a function call should never return. This will fill the current block, From a9ec4de6f2f63b9d18e6c2b1eaa8fb9571cffb58 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 13:26:32 +0200 Subject: [PATCH 1526/1566] Silence rm warning when files are not existing --- build_sysroot/build_sysroot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 4404fb49238e9..0df05f5756394 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -11,7 +11,7 @@ popd >/dev/null # Cleanup for previous run # v Clean target dir except for build scripts and incremental cache -rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true +rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true rm -r sysroot/ 2>/dev/null || true # Build libs From 684c054e3180cee629bdbe465cb6d83af0964689 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 13:50:06 +0200 Subject: [PATCH 1527/1566] Rustup to rustc 1.48.0-nightly (fc2daaae6 2020-09-28) --- patches/0023-core-Ignore-failing-tests.patch | 5 ++++- rust-toolchain | 2 +- scripts/config.sh | 2 -- src/constant.rs | 7 +------ src/target_features_whitelist.rs | 1 - 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/patches/0023-core-Ignore-failing-tests.patch b/patches/0023-core-Ignore-failing-tests.patch index ff8cece212cc5..5d2c3049f60eb 100644 --- a/patches/0023-core-Ignore-failing-tests.patch +++ b/patches/0023-core-Ignore-failing-tests.patch @@ -38,11 +38,14 @@ index 4bc44e9..8e3c7a4 100644 // See note on above test for why `should_panic` is used. #[test] #[should_panic(expected = "test succeeded")] -@@ -332,3 +333,4 @@ fn array_map_drop_safety() { +@@ -332,6 +333,7 @@ fn array_map_drop_safety() { assert_eq!(DROPPED.load(Ordering::SeqCst), num_to_create); panic!("test succeeded") } +*/ + + #[test] + fn cell_allows_array_cycle() { diff --git a/library/core/tests/num/mod.rs b/library/core/tests/num/mod.rs index a17c094..5bb11d2 100644 --- a/library/core/tests/num/mod.rs diff --git a/rust-toolchain b/rust-toolchain index 753ad9df5dd3b..f0c20eb8efcef 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-09-20 +nightly-2020-09-29 diff --git a/scripts/config.sh b/scripts/config.sh index b6479e4f696fc..aaa2323abe3e5 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -40,8 +40,6 @@ if [[ `uname` == 'Darwin' ]]; then export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" fi -export RUSTC_LOG=warn # display metadata load errors - export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib" export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH diff --git a/src/constant.rs b/src/constant.rs index c01256b7f74ba..2c4d9b8f177b9 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -390,12 +390,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu .link_section .map(|s| s.as_str()); - let const_ = tcx.const_eval_poly(def_id).unwrap(); - - let alloc = match const_ { - ConstValue::ByRef { alloc, offset } if offset.bytes() == 0 => alloc, - _ => bug!("static const eval returned {:#?}", const_), - }; + let alloc = tcx.eval_static_initializer(def_id).unwrap(); let data_id = data_id_for_static(tcx, module, def_id, true); (data_id, alloc, section_name) diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs index 527522fca703d..2710cb4aff779 100644 --- a/src/target_features_whitelist.rs +++ b/src/target_features_whitelist.rs @@ -73,7 +73,6 @@ const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("fma", None), ("fxsr", None), ("lzcnt", None), - ("mmx", Some(sym::mmx_target_feature)), ("movbe", Some(sym::movbe_target_feature)), ("pclmulqdq", None), ("popcnt", None), From c046ad017f022b7e0308ab3665044860cb6412d5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 14:11:14 +0200 Subject: [PATCH 1528/1566] Fix panic --- scripts/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config.sh b/scripts/config.sh index aaa2323abe3e5..728667ec3672f 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -32,7 +32,7 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then fi fi -export RUSTFLAGS=$linker' -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' +export RUSTFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' export RUSTDOCFLAGS=$RUSTFLAGS # FIXME remove once the atomic shim is gone From 17a54ad62e217c1b6e3848efe522666f443809a2 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 14:43:34 +0200 Subject: [PATCH 1529/1566] Add custom driver --- scripts/config.sh | 9 ++++-- src/bin/cg_clif.rs | 77 ++++++++++++++++++++++++++++++++++++++++++++++ test.sh | 9 +++--- 3 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 src/bin/cg_clif.rs diff --git a/scripts/config.sh b/scripts/config.sh index 728667ec3672f..acd048893e948 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -32,15 +32,18 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then fi fi -export RUSTFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Cdebuginfo=2 -Zpanic-abort-tests -Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' -export RUSTDOCFLAGS=$RUSTFLAGS +export RUSTC=$(pwd)/"target/"$CHANNEL"/cg_clif" +export RUSTFLAGS=$linker +export RUSTDOCFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Zpanic-abort-tests '\ +'-Zcodegen-backend='$(pwd)'/target/'$CHANNEL'/librustc_codegen_cranelift.'$dylib_ext' --sysroot '$(pwd)'/build_sysroot/sysroot' # FIXME remove once the atomic shim is gone if [[ `uname` == 'Darwin' ]]; then export RUSTFLAGS="$RUSTFLAGS -Clink-arg=-undefined -Clink-arg=dynamic_lookup" fi -export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/$TARGET_TRIPLE/lib" +export LD_LIBRARY_PATH="$(pwd)/target/out:$(pwd)/build_sysroot/sysroot/lib/rustlib/"$TARGET_TRIPLE"/lib:\ +$(pwd)/target/"$CHANNEL":$(rustc --print sysroot)/lib" export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH export CG_CLIF_DISPLAY_CG_TIME=1 diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs new file mode 100644 index 0000000000000..49279f8b92188 --- /dev/null +++ b/src/bin/cg_clif.rs @@ -0,0 +1,77 @@ +#![feature(rustc_private)] + +extern crate rustc_data_structures; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate rustc_session; +extern crate rustc_target; + +use rustc_data_structures::profiling::print_time_passes_entry; +use rustc_interface::interface; +use rustc_session::config::ErrorOutputType; +use rustc_session::early_error; +use rustc_target::spec::PanicStrategy; + +#[derive(Default)] +pub struct TimePassesCallbacks { + time_passes: bool, +} + +impl rustc_driver::Callbacks for TimePassesCallbacks { + fn config(&mut self, config: &mut interface::Config) { + // If a --prints=... option has been given, we don't print the "total" + // time because it will mess up the --prints output. See #64339. + self.time_passes = config.opts.prints.is_empty() + && (config.opts.debugging_opts.time_passes || config.opts.debugging_opts.time); + + // FIXME workaround for an ICE + config.opts.debugging_opts.trim_diagnostic_paths = false; + + config.opts.cg.panic = Some(PanicStrategy::Abort); + config.opts.debugging_opts.panic_abort_tests = true; + config.opts.maybe_sysroot = Some( + std::env::current_exe() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap() + .join("build_sysroot") + .join("sysroot"), + ); + } +} + +fn main() { + let start = std::time::Instant::now(); + rustc_driver::init_rustc_env_logger(); + let mut callbacks = TimePassesCallbacks::default(); + rustc_driver::install_ice_hook(); + let exit_code = rustc_driver::catch_with_exit_code(|| { + let args = std::env::args_os() + .enumerate() + .map(|(i, arg)| { + arg.into_string().unwrap_or_else(|arg| { + early_error( + ErrorOutputType::default(), + &format!("Argument {} is not valid Unicode: {:?}", i, arg), + ) + }) + }) + .collect::>(); + rustc_driver::run_compiler( + &args, + &mut callbacks, + None, + None, + Some(Box::new(|_| { + rustc_codegen_cranelift::__rustc_codegen_backend() + })), + ) + }); + // The extra `\t` is necessary to align this label with the others. + print_time_passes_entry(callbacks.time_passes, "\ttotal", start.elapsed()); + std::process::exit(exit_code) +} diff --git a/test.sh b/test.sh index 3028f5955ed98..9b61a38ffe0f3 100755 --- a/test.sh +++ b/test.sh @@ -2,18 +2,19 @@ set -e # Build cg_clif +export RUSTFLAGS="-Zrun_dsymutil=no" if [[ "$1" == "--release" ]]; then export CHANNEL='release' - cargo rustc --release -- -Zrun_dsymutil=no + cargo build --release else export CHANNEL='debug' - cargo rustc -- -Zrun_dsymutil=no + cargo build --bin cg_clif fi # Config source scripts/config.sh export CG_CLIF_INCR_CACHE_DISABLED=1 -RUSTC="rustc $RUSTFLAGS -L crate=target/out --out-dir target/out" +RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo=2" # Cleanup rm -r target/out || true @@ -86,7 +87,7 @@ pushd simple-raytracer if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then echo "[BENCH COMPILE] ebobby/simple-raytracer" hyperfine --runs ${RUN_RUNS:-10} --warmup 1 --prepare "cargo clean" \ - "RUSTFLAGS='' cargo build" \ + "RUSTC=rustc RUSTFLAGS='' cargo build" \ "../cargo.sh build" echo "[BENCH RUN] ebobby/simple-raytracer" From b8b5a824a689aea09f46c2f7b2f58f5f8051ea1d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 15:28:48 +0200 Subject: [PATCH 1530/1566] Fix JIT --- src/driver/jit.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/driver/jit.rs b/src/driver/jit.rs index edeeb7670e9e1..fd3a628922d0b 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -11,21 +11,23 @@ use crate::prelude::*; pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; - // Rustc opens us without the RTLD_GLOBAL flag, so __cg_clif_global_atomic_mutex will not be - // exported. We fix this by opening ourself again as global. - // FIXME remove once atomic_shim is gone - let cg_dylib = std::ffi::OsString::from( - &tcx.sess - .opts - .debugging_opts - .codegen_backend - .as_ref() - .unwrap(), - ); - std::mem::forget( - libloading::os::unix::Library::open(Some(cg_dylib), libc::RTLD_NOW | libc::RTLD_GLOBAL) - .unwrap(), - ); + #[cfg(unix)] + unsafe { + // When not using our custom driver rustc will open us without the RTLD_GLOBAL flag, so + // __cg_clif_global_atomic_mutex will not be exported. We fix this by opening ourself again + // as global. + // FIXME remove once atomic_shim is gone + + let mut dl_info: libc::Dl_info = std::mem::zeroed(); + assert_ne!( + libc::dladdr(run_jit as *const libc::c_void, &mut dl_info), + 0 + ); + assert_ne!( + libc::dlopen(dl_info.dli_fname, libc::RTLD_NOW | libc::RTLD_GLOBAL), + std::ptr::null_mut(), + ); + } let imported_symbols = load_imported_symbols_for_jit(tcx); From 787d078fb6bdc425e71b5277fd7312b46beab165 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 17:51:52 +0200 Subject: [PATCH 1531/1566] Build build scripts for sysroot using cg_llvm There is not yet a cg_clif sysroot available when building the sysroot itself --- build_sysroot/build_sysroot.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 0df05f5756394..2f09453e0f7e8 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -14,8 +14,13 @@ popd >/dev/null rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true rm -r sysroot/ 2>/dev/null || true +# Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that +# build scripts are still compiled using cg_llvm. +export RUSTC=rustc +export RUSTFLAGS=$RUSTFLAGS" -Ztrim-diagnostic-paths=no -Zcodegen-backend=$(pwd)/../target/"$CHANNEL"/librustc_codegen_cranelift."$dylib_ext" --sysroot $(pwd)/sysroot" + # Build libs -export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked" +export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort" if [[ "$1" == "--release" ]]; then sysroot_channel='release' # FIXME Enable incremental again once rust-lang/rust#74946 is fixed From 838dd17a67b750bce9fcca149759db236f145eea Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 18:12:23 +0200 Subject: [PATCH 1532/1566] Don't read CG_CLIF_JIT from init_global_lock In preparation to moving away from an env var --- src/atomic_shim.rs | 12 ++++++++---- src/driver/aot.rs | 2 +- src/driver/jit.rs | 2 +- src/main_shim.rs | 5 ++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 2f9f9e3a4f744..f29e269c01ffc 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -10,10 +10,14 @@ use crate::prelude::*; pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; -pub(crate) fn init_global_lock(module: &mut Module, bcx: &mut FunctionBuilder<'_>) { - if std::env::var("CG_CLIF_JIT").is_ok() { +pub(crate) fn init_global_lock( + module: &mut Module, + bcx: &mut FunctionBuilder<'_>, + use_jit: bool, +) { + if use_jit { // When using JIT, dylibs won't find the __cg_clif_global_atomic_mutex data object defined here, - // so instead define it in the cg_clif dylib. + // so instead we define it in the cg_clif dylib. return; } @@ -80,7 +84,7 @@ pub(crate) fn init_global_lock_constructor( let block = bcx.create_block(); bcx.switch_to_block(block); - crate::atomic_shim::init_global_lock(module, &mut bcx); + crate::atomic_shim::init_global_lock(module, &mut bcx, false); bcx.ins().return_(&[]); bcx.seal_all_blocks(); diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 2cf136ceb674b..fc01398c40d9e 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -150,7 +150,7 @@ fn module_codegen(tcx: TyCtxt<'_>, cgu_name: rustc_span::Symbol) -> ModuleCodege super::codegen_mono_items(&mut cx, mono_items); let (mut module, global_asm, debug, mut unwind_context) = tcx.sess.time("finalize CodegenCx", || cx.finalize()); - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut unwind_context, false); let codegen_result = emit_module( tcx, diff --git a/src/driver/jit.rs b/src/driver/jit.rs index fd3a628922d0b..9f8426961ee74 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -76,7 +76,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { if !global_asm.is_empty() { tcx.sess.fatal("Global asm is not supported in JIT mode"); } - crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context); + crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context, true); crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context); jit_module.finalize_definitions(); diff --git a/src/main_shim.rs b/src/main_shim.rs index 520a54b8e5333..c4b21dcecd333 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -9,6 +9,7 @@ pub(crate) fn maybe_create_entry_wrapper( tcx: TyCtxt<'_>, module: &mut Module, unwind_context: &mut UnwindContext<'_>, + use_jit: bool, ) { let (main_def_id, use_start_lang_item) = match tcx.entry_fn(LOCAL_CRATE) { Some((def_id, entry_ty)) => ( @@ -32,6 +33,7 @@ pub(crate) fn maybe_create_entry_wrapper( unwind_context, main_def_id, use_start_lang_item, + use_jit, ); fn create_entry_fn( @@ -40,6 +42,7 @@ pub(crate) fn maybe_create_entry_wrapper( unwind_context: &mut UnwindContext<'_>, rust_main_def_id: DefId, use_start_lang_item: bool, + use_jit: bool, ) { let main_ret_ty = tcx.fn_sig(rust_main_def_id).output(); // Given that `main()` has no arguments, @@ -83,7 +86,7 @@ pub(crate) fn maybe_create_entry_wrapper( 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()); - crate::atomic_shim::init_global_lock(m, &mut bcx); + crate::atomic_shim::init_global_lock(m, &mut bcx, use_jit); let main_func_ref = m.declare_func_in_func(main_func_id, &mut bcx.func); From 426e55709cf6badbeb99cdae9587ab8ffb8a98ac Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 18:41:59 +0200 Subject: [PATCH 1533/1566] Replace CG_CLIF_JIT with --jit --- Readme.md | 21 +++++++++++++++++++-- cargo.sh | 9 ++++----- docs/env_vars.md | 2 -- scripts/filter_profile.rs | 2 +- src/bin/cg_clif.rs | 23 ++++++++++++++++++++--- src/driver/jit.rs | 2 +- src/driver/mod.rs | 12 ++++++++---- src/lib.rs | 17 ++++++++++++++--- test.sh | 4 ++-- 9 files changed, 69 insertions(+), 23 deletions(-) diff --git a/Readme.md b/Readme.md index c4e55975541d3..41159b66af8f0 100644 --- a/Readme.md +++ b/Readme.md @@ -36,7 +36,24 @@ If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./tes > You should prefer using the Cargo method. ```bash -$ rustc +$(cat $cg_clif_dir/rust-toolchain) -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs +$ $cg_clif_dir/target/release/cg_clif my_crate.rs +``` + +### Jit mode + +In jit mode cg_clif will immediately execute your code without creating an executable file. +This requires all dependencies to be available as dynamic library. +The easiest way to achieve this is by creating a new dylib crate that has all your dependencies as dependencies of itself. +Rustc will then link all your rlib dependencies into the dylib. + +```bash +$ $cg_clif_dir/cargo.sh jit +``` + +or + +```bash +$ $cg_clif_dir/target/release/cg_clif --jit my_crate.rs ``` ### Shell @@ -45,7 +62,7 @@ These are a few functions that allow you to easily run rust code from the shell ```bash function jit_naked() { - echo "$@" | CG_CLIF_JIT=1 rustc -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot - -Cprefer-dynamic + echo "$@" | $cg_clif_dir/target/release/cg_clif - --jit } function jit() { diff --git a/cargo.sh b/cargo.sh index ba4b7d6c942ba..cebc3e67363a8 100755 --- a/cargo.sh +++ b/cargo.sh @@ -12,12 +12,11 @@ TOOLCHAIN=$(cat rust-toolchain) popd >/dev/null -if [[ $(rustc -V) != $(rustc +${TOOLCHAIN} -V) ]]; then - echo "rustc_codegen_cranelift is build for $(rustc +${TOOLCHAIN} -V) but the default rustc version is $(rustc -V)." - echo "Using $(rustc +${TOOLCHAIN} -V)." -fi - cmd=$1 shift +if [[ "$cmd" = "jit" ]]; then +cargo +${TOOLCHAIN} rustc $@ -- --jit +else cargo +${TOOLCHAIN} $cmd $@ +fi diff --git a/docs/env_vars.md b/docs/env_vars.md index 3707909a97802..07b75622a58ef 100644 --- a/docs/env_vars.md +++ b/docs/env_vars.md @@ -1,8 +1,6 @@ # List of env vars recognized by cg_clif
-
CG_CLIF_JIT
-
Enable JIT mode to immediately run a program instead of writing an executable file.
CG_CLIF_JIT_ARGS
When JIT mode is enable pass these arguments to the program.
CG_CLIF_INCR_CACHE_DISABLED
diff --git a/scripts/filter_profile.rs b/scripts/filter_profile.rs index 75f2f61b21a5a..c70c3ec47f31f 100755 --- a/scripts/filter_profile.rs +++ b/scripts/filter_profile.rs @@ -5,7 +5,7 @@ CHANNEL="release" pushd $(dirname "$0")/../ source scripts/config.sh popd -CG_CLIF_JIT=1 PROFILE=$1 OUTPUT=$2 exec rustc $RUSTFLAGS $0 --crate-type bin -Cprefer-dynamic +PROFILE=$1 OUTPUT=$2 exec $RUSTC $RUSTFLAGS --jit $0 #*/ //! This program filters away uninteresting samples and trims uninteresting frames for stackcollapse diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index 49279f8b92188..8a39e9b0590ed 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -50,7 +50,9 @@ fn main() { let mut callbacks = TimePassesCallbacks::default(); rustc_driver::install_ice_hook(); let exit_code = rustc_driver::catch_with_exit_code(|| { - let args = std::env::args_os() + let mut use_jit = false; + + let mut args = std::env::args_os() .enumerate() .map(|(i, arg)| { arg.into_string().unwrap_or_else(|arg| { @@ -60,14 +62,29 @@ fn main() { ) }) }) + .filter(|arg| { + if arg == "--jit" { + use_jit = true; + false + } else { + true + } + }) .collect::>(); + if use_jit { + args.push("-Cprefer-dynamic".to_string()); + } rustc_driver::run_compiler( &args, &mut callbacks, None, None, - Some(Box::new(|_| { - rustc_codegen_cranelift::__rustc_codegen_backend() + Some(Box::new(move |_| { + Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { + config: rustc_codegen_cranelift::BackendConfig { + use_jit, + } + }) })), ) }); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 9f8426961ee74..5a899afb97ca4 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -87,7 +87,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); - println!("Rustc codegen cranelift will JIT run the executable, because the CG_CLIF_JIT env var is set"); + println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed"); let f: extern "C" fn(c_int, *const *const c_char) -> c_int = unsafe { ::std::mem::transmute(finalized_main) }; diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 0224f929ac7f6..881221c010541 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -16,15 +16,19 @@ pub(crate) fn codegen_crate( tcx: TyCtxt<'_>, metadata: EncodedMetadata, need_metadata_module: bool, + config: crate::BackendConfig, ) -> Box { tcx.sess.abort_if_errors(); - if std::env::var("CG_CLIF_JIT").is_ok() - && tcx + if config.use_jit { + let is_executable = tcx .sess .crate_types() - .contains(&rustc_session::config::CrateType::Executable) - { + .contains(&rustc_session::config::CrateType::Executable); + if !is_executable { + tcx.sess.fatal("can't jit non-executable crate"); + } + #[cfg(feature = "jit")] let _: ! = jit::run_jit(tcx); diff --git a/src/lib.rs b/src/lib.rs index 64f4e490aed39..52845b11da0e5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,7 +181,14 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } } -struct CraneliftCodegenBackend; +#[derive(Copy, Clone, Debug)] +pub struct BackendConfig { + pub use_jit: bool, +} + +pub struct CraneliftCodegenBackend { + pub config: BackendConfig, +} impl CodegenBackend for CraneliftCodegenBackend { fn init(&self, sess: &Session) { @@ -223,7 +230,7 @@ impl CodegenBackend for CraneliftCodegenBackend { metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box { - let res = driver::codegen_crate(tcx, metadata, need_metadata_module); + let res = driver::codegen_crate(tcx, metadata, need_metadata_module, self.config); rustc_symbol_mangling::test::report_symbol_names(tcx); @@ -345,5 +352,9 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box Box { - Box::new(CraneliftCodegenBackend) + Box::new(CraneliftCodegenBackend { + config: BackendConfig { + use_jit: false, + } + }) } diff --git a/test.sh b/test.sh index 9b61a38ffe0f3..0d2b5c6a392b2 100755 --- a/test.sh +++ b/test.sh @@ -29,7 +29,7 @@ $RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE if [[ "$JIT_SUPPORTED" = "1" ]]; then echo "[JIT] mini_core_hello_world" - CG_CLIF_JIT=1 CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --crate-type bin -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE + CG_CLIF_JIT_ARGS="abc bcd" $RUSTC --jit example/mini_core_hello_world.rs --cfg jit --target $HOST_TRIPLE else echo "[JIT] mini_core_hello_world (skipped)" fi @@ -52,7 +52,7 @@ $RUN_WRAPPER ./target/out/alloc_example if [[ "$JIT_SUPPORTED" = "1" ]]; then echo "[JIT] std_example" - CG_CLIF_JIT=1 $RUSTC --crate-type bin -Cprefer-dynamic example/std_example.rs --target $HOST_TRIPLE + $RUSTC --jit example/std_example.rs --target $HOST_TRIPLE else echo "[JIT] std_example (skipped)" fi From 9a513be11a2a828cffeb6f5a76f6ad528e2d3626 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 29 Sep 2020 19:50:03 +0200 Subject: [PATCH 1534/1566] Update readme --- Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 41159b66af8f0..680ff877656b0 100644 --- a/Readme.md +++ b/Readme.md @@ -42,9 +42,9 @@ $ $cg_clif_dir/target/release/cg_clif my_crate.rs ### Jit mode In jit mode cg_clif will immediately execute your code without creating an executable file. -This requires all dependencies to be available as dynamic library. -The easiest way to achieve this is by creating a new dylib crate that has all your dependencies as dependencies of itself. -Rustc will then link all your rlib dependencies into the dylib. + +> This requires all dependencies to be available as dynamic library. +> The jit mode will probably need cargo integration to make this possible. ```bash $ $cg_clif_dir/cargo.sh jit From 3b60cc4eb13d94c2cd7ee8aed20fc65aa6ede64d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 30 Sep 2020 09:15:02 +0200 Subject: [PATCH 1535/1566] Prevent usage of sccache It doesn't detect cg_clif as a rust compiler Fixes #1091 --- scripts/config.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/config.sh b/scripts/config.sh index acd048893e948..530b7f242a098 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -32,6 +32,13 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then fi fi +if echo "$RUSTC_WRAPPER" | grep sccache; then +echo +echo -e "\x1b[1;93m=== Warning: Unset RUSTC_WRAPPER to prevent interference with sccache ===\x1b[0m" +echo +export RUSTC_WRAPPER= +fi + export RUSTC=$(pwd)/"target/"$CHANNEL"/cg_clif" export RUSTFLAGS=$linker export RUSTDOCFLAGS=$linker' -Ztrim-diagnostic-paths=no -Cpanic=abort -Zpanic-abort-tests '\ From ab92638735b1902f7421b94d93826ac6921b9c10 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 2 Oct 2020 14:26:34 +0200 Subject: [PATCH 1536/1566] Rustup to rustc 1.48.0-nightly (8fe73e80d 2020-10-01) --- build_sysroot/Cargo.lock | 12 ++++++------ rust-toolchain | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 0a628b1aa21ba..0439917b548c5 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" dependencies = [ "compiler_builtins", "rustc-std-workspace-alloc", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" dependencies = [ "compiler_builtins", "libc", @@ -135,9 +135,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.77" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" +checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98" dependencies = [ "rustc-std-workspace-core", ] diff --git a/rust-toolchain b/rust-toolchain index f0c20eb8efcef..6de068d64c6af 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-09-29 +nightly-2020-10-02 From 3fc673d0a9f6065c7b1f6178426c60082b74f408 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Oct 2020 11:12:41 +0200 Subject: [PATCH 1537/1566] Rustup to rustc 1.49.0-nightly (beb5ae474 2020-10-04) --- build_sysroot/build_sysroot.sh | 3 +- rust-toolchain | 2 +- src/allocator.rs | 50 +++++++++- src/lib.rs | 5 +- src/target_features_whitelist.rs | 158 ------------------------------- 5 files changed, 53 insertions(+), 165 deletions(-) delete mode 100644 src/target_features_whitelist.rs diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 2f09453e0f7e8..930f3054b039c 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -24,7 +24,8 @@ export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort" if [[ "$1" == "--release" ]]; then sysroot_channel='release' # FIXME Enable incremental again once rust-lang/rust#74946 is fixed - CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=2" cargo build --target $TARGET_TRIPLE --release + # FIXME Enable -Zmir-opt-level=2 again once it doesn't ice anymore + CARGO_INCREMENTAL=0 RUSTFLAGS="$RUSTFLAGS" cargo build --target $TARGET_TRIPLE --release else sysroot_channel='debug' cargo build --target $TARGET_TRIPLE diff --git a/rust-toolchain b/rust-toolchain index 6de068d64c6af..c318446013829 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-02 +nightly-2020-10-05 diff --git a/src/allocator.rs b/src/allocator.rs index 95beb93f26f1d..2862a372dfe01 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -4,6 +4,7 @@ use crate::prelude::*; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; +use rustc_span::symbol::sym; /// Returns whether an allocator shim was created pub(crate) fn codegen( @@ -87,10 +88,9 @@ fn codegen_inner( .collect::>(); let callee_func_ref = module.declare_func_in_func(callee_func_id, &mut bcx.func); - let call_inst = bcx.ins().call(callee_func_ref, &args); - let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error + bcx.ins().return_(&results); bcx.seal_all_blocks(); bcx.finalize(); @@ -104,4 +104,50 @@ fn codegen_inner( .unwrap(); unwind_context.add_function(func_id, &ctx, module.isa()); } + + let sig = Signature { + call_conv: CallConv::triple_default(module.isa().triple()), + params: vec![AbiParam::new(usize_ty), AbiParam::new(usize_ty)], + returns: vec![], + }; + + let callee_name = kind.fn_name(sym::oom); + //eprintln!("Codegen allocator shim {} -> {} ({:?} -> {:?})", caller_name, callee_name, sig.params, sig.returns); + + let func_id = module + .declare_function("__rust_alloc_error_handler", Linkage::Export, &sig) + .unwrap(); + + let callee_func_id = module + .declare_function(&callee_name, Linkage::Import, &sig) + .unwrap(); + + let mut ctx = Context::new(); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); + { + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); + + let block = bcx.create_block(); + bcx.switch_to_block(block); + let args = (&[usize_ty, usize_ty]) + .into_iter() + .map(|&ty| bcx.append_block_param(block, ty)) + .collect::>(); + + let callee_func_ref = module.declare_func_in_func(callee_func_id, &mut bcx.func); + bcx.ins().call(callee_func_ref, &args); + + bcx.ins().trap(TrapCode::UnreachableCodeReached); + bcx.seal_all_blocks(); + bcx.finalize(); + } + module + .define_function( + func_id, + &mut ctx, + &mut cranelift_codegen::binemit::NullTrapSink {}, + ) + .unwrap(); + unwind_context.add_function(func_id, &ctx, module.isa()); } diff --git a/src/lib.rs b/src/lib.rs index 52845b11da0e5..e3a632fc465f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,7 +72,6 @@ mod num; mod optimize; mod pointer; mod pretty_clif; -mod target_features_whitelist; mod toolchain; mod trap; mod unsize; @@ -207,11 +206,11 @@ impl CodegenBackend for CraneliftCodegenBackend { if tcx.sess.opts.actually_rustdoc { // rustdoc needs to be able to document functions that use all the features, so // whitelist them all - target_features_whitelist::all_known_features() + rustc_codegen_ssa::target_features::all_known_features() .map(|(a, b)| (a.to_string(), b)) .collect() } else { - target_features_whitelist::supported_target_features(tcx.sess) + rustc_codegen_ssa::target_features::supported_target_features(tcx.sess) .iter() .map(|&(a, b)| (a.to_string(), b)) .collect() diff --git a/src/target_features_whitelist.rs b/src/target_features_whitelist.rs deleted file mode 100644 index 2710cb4aff779..0000000000000 --- a/src/target_features_whitelist.rs +++ /dev/null @@ -1,158 +0,0 @@ -#![rustfmt::skip] - -use rustc_span::symbol::{sym, Symbol}; - -use rustc_session::Session; - -// Copied from https://github.com/rust-lang/rust/blob/e7f6ed14d5de2199d0e8a3c1e41f80e43885cb5c/src/librustc_codegen_llvm/llvm_util.rs#L139-L275 - -// WARNING: the features after applying `to_llvm_feature` must be known -// to LLVM or the feature detection code will walk past the end of the feature -// array, leading to crashes. - -const ARM_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("aclass", Some(sym::arm_target_feature)), - ("mclass", Some(sym::arm_target_feature)), - ("rclass", Some(sym::arm_target_feature)), - ("dsp", Some(sym::arm_target_feature)), - ("neon", Some(sym::arm_target_feature)), - ("crc", Some(sym::arm_target_feature)), - ("crypto", Some(sym::arm_target_feature)), - ("v5te", Some(sym::arm_target_feature)), - ("v6", Some(sym::arm_target_feature)), - ("v6k", Some(sym::arm_target_feature)), - ("v6t2", Some(sym::arm_target_feature)), - ("v7", Some(sym::arm_target_feature)), - ("v8", Some(sym::arm_target_feature)), - ("vfp2", Some(sym::arm_target_feature)), - ("vfp3", Some(sym::arm_target_feature)), - ("vfp4", Some(sym::arm_target_feature)), - // This is needed for inline assembly, but shouldn't be stabilized as-is - // since it should be enabled per-function using #[instruction_set], not - // #[target_feature]. - ("thumb-mode", Some(sym::arm_target_feature)), -]; - -const AARCH64_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("fp", Some(sym::aarch64_target_feature)), - ("neon", Some(sym::aarch64_target_feature)), - ("sve", Some(sym::aarch64_target_feature)), - ("crc", Some(sym::aarch64_target_feature)), - ("crypto", Some(sym::aarch64_target_feature)), - ("ras", Some(sym::aarch64_target_feature)), - ("lse", Some(sym::aarch64_target_feature)), - ("rdm", Some(sym::aarch64_target_feature)), - ("fp16", Some(sym::aarch64_target_feature)), - ("rcpc", Some(sym::aarch64_target_feature)), - ("dotprod", Some(sym::aarch64_target_feature)), - ("tme", Some(sym::aarch64_target_feature)), - ("v8.1a", Some(sym::aarch64_target_feature)), - ("v8.2a", Some(sym::aarch64_target_feature)), - ("v8.3a", Some(sym::aarch64_target_feature)), -]; - -const X86_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("adx", Some(sym::adx_target_feature)), - ("aes", None), - ("avx", None), - ("avx2", None), - ("avx512bw", Some(sym::avx512_target_feature)), - ("avx512cd", Some(sym::avx512_target_feature)), - ("avx512dq", Some(sym::avx512_target_feature)), - ("avx512er", Some(sym::avx512_target_feature)), - ("avx512f", Some(sym::avx512_target_feature)), - ("avx512ifma", Some(sym::avx512_target_feature)), - ("avx512pf", Some(sym::avx512_target_feature)), - ("avx512vbmi", Some(sym::avx512_target_feature)), - ("avx512vl", Some(sym::avx512_target_feature)), - ("avx512vpopcntdq", Some(sym::avx512_target_feature)), - ("bmi1", None), - ("bmi2", None), - ("cmpxchg16b", Some(sym::cmpxchg16b_target_feature)), - ("f16c", Some(sym::f16c_target_feature)), - ("fma", None), - ("fxsr", None), - ("lzcnt", None), - ("movbe", Some(sym::movbe_target_feature)), - ("pclmulqdq", None), - ("popcnt", None), - ("rdrand", None), - ("rdseed", None), - ("rtm", Some(sym::rtm_target_feature)), - ("sha", None), - ("sse", None), - ("sse2", None), - ("sse3", None), - ("sse4.1", None), - ("sse4.2", None), - ("sse4a", Some(sym::sse4a_target_feature)), - ("ssse3", None), - ("tbm", Some(sym::tbm_target_feature)), - ("xsave", None), - ("xsavec", None), - ("xsaveopt", None), - ("xsaves", None), -]; - -const HEXAGON_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("hvx", Some(sym::hexagon_target_feature)), - ("hvx-length128b", Some(sym::hexagon_target_feature)), -]; - -const POWERPC_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("altivec", Some(sym::powerpc_target_feature)), - ("power8-altivec", Some(sym::powerpc_target_feature)), - ("power9-altivec", Some(sym::powerpc_target_feature)), - ("power8-vector", Some(sym::powerpc_target_feature)), - ("power9-vector", Some(sym::powerpc_target_feature)), - ("vsx", Some(sym::powerpc_target_feature)), -]; - -const MIPS_ALLOWED_FEATURES: &[(&str, Option)] = - &[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))]; - -const RISCV_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("m", Some(sym::riscv_target_feature)), - ("a", Some(sym::riscv_target_feature)), - ("c", Some(sym::riscv_target_feature)), - ("f", Some(sym::riscv_target_feature)), - ("d", Some(sym::riscv_target_feature)), - ("e", Some(sym::riscv_target_feature)), -]; - -const WASM_ALLOWED_FEATURES: &[(&str, Option)] = &[ - ("simd128", Some(sym::wasm_target_feature)), - ("atomics", Some(sym::wasm_target_feature)), - ("nontrapping-fptoint", Some(sym::wasm_target_feature)), -]; - -/// When rustdoc is running, provide a list of all known features so that all their respective -/// primitives may be documented. -/// -/// IMPORTANT: If you're adding another feature list above, make sure to add it to this iterator! -pub fn all_known_features() -> impl Iterator)> { - std::iter::empty() - .chain(ARM_ALLOWED_FEATURES.iter()) - .chain(AARCH64_ALLOWED_FEATURES.iter()) - .chain(X86_ALLOWED_FEATURES.iter()) - .chain(HEXAGON_ALLOWED_FEATURES.iter()) - .chain(POWERPC_ALLOWED_FEATURES.iter()) - .chain(MIPS_ALLOWED_FEATURES.iter()) - .chain(RISCV_ALLOWED_FEATURES.iter()) - .chain(WASM_ALLOWED_FEATURES.iter()) - .cloned() -} - -pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Option)] { - match &*sess.target.target.arch { - "arm" => ARM_ALLOWED_FEATURES, - "aarch64" => AARCH64_ALLOWED_FEATURES, - "x86" | "x86_64" => X86_ALLOWED_FEATURES, - "hexagon" => HEXAGON_ALLOWED_FEATURES, - "mips" | "mips64" => MIPS_ALLOWED_FEATURES, - "powerpc" | "powerpc64" => POWERPC_ALLOWED_FEATURES, - "riscv32" | "riscv64" => RISCV_ALLOWED_FEATURES, - "wasm32" => WASM_ALLOWED_FEATURES, - _ => &[], - } -} From 832b3117ccf6d1dd1701ce0fcede555febe72813 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Oct 2020 11:13:11 +0200 Subject: [PATCH 1538/1566] Install rustfmt by default when doing a rustup --- scripts/rustup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/rustup.sh b/scripts/rustup.sh index b911320f7a08d..38991d6d47dd0 100755 --- a/scripts/rustup.sh +++ b/scripts/rustup.sh @@ -9,6 +9,7 @@ case $1 in echo "=> Installing new nightly" rustup toolchain install --profile minimal nightly-${TOOLCHAIN} # Sanity check to see if the nightly exists echo nightly-${TOOLCHAIN} > rust-toolchain + rustup component add rustfmt || true echo "=> Uninstalling all old nighlies" for nightly in $(rustup toolchain list | grep nightly | grep -v $TOOLCHAIN | grep -v nightly-x86_64); do From cb2dd4b5e05443a950dcd30d54a98c4c1c07a339 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 5 Oct 2020 11:14:10 +0200 Subject: [PATCH 1539/1566] Update rust-analyzer config for changed path --- .vscode/settings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9495cb64139ce..288612be470b2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,10 +33,10 @@ ] }, { - "roots": ["./analyze_profile.rs"], + "roots": ["./scripts/analyze_profile.rs"], "crates": [ { - "root_module": "./analyze_profile.rs", + "root_module": "./scripts/analyze_profile.rs", "edition": "2018", "deps": [{ "crate": 1, "name": "std" }], "cfg": [], From 1cd63dc9b22fa748b9e3b14f0666874e595a4924 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 8 Oct 2020 13:37:02 +0200 Subject: [PATCH 1540/1566] Update sysroot miniz_oxide --- build_sysroot/Cargo.lock | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 0439917b548c5..48826ecaebf0d 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -39,6 +39,12 @@ dependencies = [ "libc", ] +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + [[package]] name = "cc" version = "1.0.60" @@ -144,11 +150,12 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7559a8a40d0f97e1edea3220f698f78b1c5ab67532e49f68fde3910323b722" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ "adler", + "autocfg", "compiler_builtins", "rustc-std-workspace-alloc", "rustc-std-workspace-core", From 0a5968dfd215a61445c30e0e586a387b938faa67 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 1 Oct 2020 10:38:23 +0200 Subject: [PATCH 1541/1566] Use the new cranelift-module interface This updates Cranelift to include bytecodealliance/wasmtime#2249 --- Cargo.lock | 51 ++++++++++++++++++++++------------------- Cargo.toml | 2 +- src/abi/comments.rs | 8 +++---- src/abi/mod.rs | 12 +++++----- src/abi/pass_mode.rs | 4 ++-- src/abi/returning.rs | 12 +++++----- src/allocator.rs | 4 ++-- src/analyze.rs | 2 +- src/atomic_shim.rs | 12 ++++------ src/backend.rs | 45 +++++++++++++----------------------- src/base.rs | 20 ++++++++-------- src/cast.rs | 4 ++-- src/codegen_i128.rs | 2 +- src/common.rs | 19 ++++++++------- src/constant.rs | 45 +++++++++++++++--------------------- src/debuginfo/emit.rs | 4 ++-- src/debuginfo/mod.rs | 2 ++ src/debuginfo/unwind.rs | 4 ++-- src/discriminant.rs | 4 ++-- src/driver/aot.rs | 20 ++++++++-------- src/driver/jit.rs | 11 ++++----- src/driver/mod.rs | 6 ++--- src/inline_asm.rs | 4 ++-- src/intrinsics/cpuid.rs | 2 +- src/intrinsics/llvm.rs | 2 +- src/intrinsics/mod.rs | 16 ++++++------- src/intrinsics/simd.rs | 2 +- src/lib.rs | 25 ++++++-------------- src/main_shim.rs | 4 ++-- src/num.rs | 14 +++++------ src/pointer.rs | 14 +++++------ src/pretty_clif.rs | 4 ++-- src/trap.rs | 12 +++++----- src/unsize.rs | 8 +++---- src/value_and_place.rs | 42 ++++++++++++++++----------------- src/vtable.rs | 31 +++++++++++++------------ 36 files changed, 220 insertions(+), 253 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8803bc223984b..e15ceaf95ebcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,16 +43,16 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "byteorder", "cranelift-bforest", @@ -69,8 +69,8 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -78,18 +78,18 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" [[package]] name = "cranelift-entity" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" [[package]] name = "cranelift-frontend" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "cranelift-codegen", "log", @@ -99,8 +99,8 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "anyhow", "cranelift-codegen", @@ -111,8 +111,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -121,26 +121,29 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "anyhow", "cranelift-codegen", "cranelift-module", + "log", "object", "target-lexicon", ] [[package]] name = "cranelift-simplejit" -version = "0.66.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#1fabb051b0436a38f794ca395601dcdcc31d3c18" +version = "0.67.0" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" dependencies = [ "cranelift-codegen", + "cranelift-entity", "cranelift-module", "cranelift-native", "errno", "libc", + "log", "region", "target-lexicon", "winapi", @@ -184,9 +187,9 @@ checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" [[package]] name = "gimli" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" dependencies = [ "indexmap", ] @@ -284,9 +287,9 @@ dependencies = [ [[package]] name = "regalloc" -version = "0.0.30" +version = "0.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2041c2d34f6ff346d6f428974f03d8bf12679b0c816bb640dc5eb1d48848d8d1" +checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", diff --git a/Cargo.toml b/Cargo.toml index 86cc6c45019b5..1c8e350d24297 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", bran cranelift-simplejit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true } cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } target-lexicon = "0.11.0" -gimli = { version = "0.21.0", default-features = false, features = ["write"]} +gimli = { version = "0.22.0", default-features = false, features = ["write"]} object = { version = "0.21.1", default-features = false, features = ["std", "read_core", "write", "coff", "elf", "macho", "pe"] } ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } diff --git a/src/abi/comments.rs b/src/abi/comments.rs index f63a4565a72a6..7bb00c8d46a4c 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -10,14 +10,14 @@ use cranelift_codegen::entity::EntityRef; use crate::abi::pass_mode::*; use crate::prelude::*; -pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.add_global_comment(format!( "kind loc.idx param pass mode ty" )); } pub(super) fn add_arg_comment<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, kind: &str, local: Option, local_field: Option, @@ -54,7 +54,7 @@ pub(super) fn add_arg_comment<'tcx>( )); } -pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) { fx.add_global_comment(String::new()); fx.add_global_comment(format!( "kind local ty size align (abi,pref)" @@ -62,7 +62,7 @@ pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Backend } pub(super) fn add_local_place_comments<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, place: CPlace<'tcx>, local: Local, ) { diff --git a/src/abi/mod.rs b/src/abi/mod.rs index f55d94b0a0979..8016912284317 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -238,7 +238,7 @@ pub(crate) fn get_function_name_and_sig<'tcx>( /// Instance must be monomorphized pub(crate) fn import_function<'tcx>( tcx: TyCtxt<'tcx>, - module: &mut Module, + module: &mut impl Module, inst: Instance<'tcx>, ) -> FuncId { let (name, sig) = get_function_name_and_sig(tcx, module.isa().triple(), inst, true); @@ -247,7 +247,7 @@ pub(crate) fn import_function<'tcx>( .unwrap() } -impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { +impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> { /// Instance must be monomorphized pub(crate) fn get_function_ref(&mut self, inst: Instance<'tcx>) -> FuncRef { let func_id = import_function(self.tcx, &mut self.cx.module, inst); @@ -329,7 +329,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { /// Make a [`CPlace`] capable of holding value of the specified type. fn make_local_place<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, local: Local, layout: TyAndLayout<'tcx>, is_ssa: bool, @@ -351,7 +351,7 @@ fn make_local_place<'tcx>( } pub(crate) fn codegen_fn_prelude<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, start_block: Block, ) { let ssa_analyzed = crate::analyze::analyze(fx); @@ -488,7 +488,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>( } pub(crate) fn codegen_terminator_call<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, span: Span, current_block: Block, func: &Operand<'tcx>, @@ -701,7 +701,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( } pub(crate) fn codegen_drop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, span: Span, drop_place: CPlace<'tcx>, ) { diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 6033cd88da9f9..8e3682c86c5fb 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -122,7 +122,7 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) /// Get a set of values to be passed as function arguments. pub(super) fn adjust_arg_for_abi<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, arg: CValue<'tcx>, ) -> EmptySinglePair { match get_pass_mode(fx.tcx, arg.layout()) { @@ -142,7 +142,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>( /// Create a [`CValue`] containing the value of a function parameter adding clif function parameters /// as necessary. pub(super) fn cvalue_for_param<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, start_block: Block, #[cfg_attr(not(debug_assertions), allow(unused_variables))] local: Option, #[cfg_attr(not(debug_assertions), allow(unused_variables))] local_field: Option, diff --git a/src/abi/returning.rs b/src/abi/returning.rs index 4505caa67dd51..f6d40c880d094 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -3,7 +3,7 @@ use crate::abi::pass_mode::*; use crate::prelude::*; -fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyAndLayout<'tcx> { +fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Module>) -> TyAndLayout<'tcx> { fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty)) } @@ -22,7 +22,7 @@ pub(crate) fn can_return_to_ssa_var<'tcx>( /// Return a place where the return value of the current function can be written to. If necessary /// this adds an extra parameter pointing to where the return value needs to be stored. pub(super) fn codegen_return_param<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, ssa_analyzed: &rustc_index::vec::IndexVec, start_block: Block, ) -> CPlace<'tcx> { @@ -66,11 +66,11 @@ pub(super) fn codegen_return_param<'tcx>( /// Invokes the closure with if necessary a value representing the return pointer. When the closure /// returns the call return value(s) if any are written to the correct place. -pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( - fx: &mut FunctionCx<'_, 'tcx, B>, +pub(super) fn codegen_with_call_return_arg<'tcx, M: Module, T>( + fx: &mut FunctionCx<'_, 'tcx, M>, fn_sig: FnSig<'tcx>, ret_place: Option>, - f: impl FnOnce(&mut FunctionCx<'_, 'tcx, B>, Option) -> (Inst, T), + f: impl FnOnce(&mut FunctionCx<'_, 'tcx, M>, Option) -> (Inst, T), ) -> (Inst, T) { let ret_layout = fx.layout_of(fn_sig.output()); @@ -110,7 +110,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>( } /// Codegen a return instruction with the right return value(s) if any. -pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Module>) { match get_pass_mode(fx.tcx, return_layout(fx)) { PassMode::NoPass | PassMode::ByRef { size: Some(_) } => { fx.bcx.ins().return_(&[]); diff --git a/src/allocator.rs b/src/allocator.rs index 2862a372dfe01..0735ad6f83299 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -9,7 +9,7 @@ use rustc_span::symbol::sym; /// Returns whether an allocator shim was created pub(crate) fn codegen( tcx: TyCtxt<'_>, - module: &mut Module, + module: &mut impl Module, unwind_context: &mut UnwindContext<'_>, ) -> bool { let any_dynamic_crate = tcx.dependency_formats(LOCAL_CRATE).iter().any(|(_, list)| { @@ -27,7 +27,7 @@ pub(crate) fn codegen( } fn codegen_inner( - module: &mut Module, + module: &mut impl Module, unwind_context: &mut UnwindContext<'_>, kind: AllocatorKind, ) { diff --git a/src/analyze.rs b/src/analyze.rs index 06434bdf69c5a..fd25b19a583aa 100644 --- a/src/analyze.rs +++ b/src/analyze.rs @@ -11,7 +11,7 @@ pub(crate) enum SsaKind { Ssa, } -pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> IndexVec { +pub(crate) fn analyze(fx: &FunctionCx<'_, '_, impl Module>) -> IndexVec { let mut flag_map = fx .mir .local_decls diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index f29e269c01ffc..11b5946b6aa40 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -11,7 +11,7 @@ pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; pub(crate) fn init_global_lock( - module: &mut Module, + module: &mut impl Module, bcx: &mut FunctionBuilder<'_>, use_jit: bool, ) { @@ -24,13 +24,13 @@ pub(crate) fn init_global_lock( let mut data_ctx = DataContext::new(); data_ctx.define_zeroinit(1024); // 1024 bytes should be big enough on all platforms. + data_ctx.set_align(16); let atomic_mutex = module .declare_data( "__cg_clif_global_atomic_mutex", Linkage::Export, true, false, - Some(16), ) .unwrap(); module.define_data(atomic_mutex, &data_ctx).unwrap(); @@ -67,7 +67,7 @@ pub(crate) fn init_global_lock( } pub(crate) fn init_global_lock_constructor( - module: &mut Module, + module: &mut impl Module, constructor_name: &str, ) -> FuncId { let sig = Signature::new(CallConv::SystemV); @@ -101,7 +101,7 @@ pub(crate) fn init_global_lock_constructor( init_func_id } -pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Module>) { let atomic_mutex = fx .cx .module @@ -110,7 +110,6 @@ pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { Linkage::Import, true, false, - None, ) .unwrap(); @@ -144,7 +143,7 @@ pub(crate) fn lock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { fx.bcx.ins().call(pthread_mutex_lock, &[atomic_mutex]); } -pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Module>) { let atomic_mutex = fx .cx .module @@ -153,7 +152,6 @@ pub(crate) fn unlock_global_lock(fx: &mut FunctionCx<'_, '_, impl Backend>) { Linkage::Import, true, false, - None, ) .unwrap(); diff --git a/src/backend.rs b/src/backend.rs index f6c06f7f88e24..c0df85f681c92 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -5,12 +5,12 @@ use std::convert::{TryFrom, TryInto}; use rustc_data_structures::fx::FxHashMap; use rustc_session::Session; -use cranelift_module::{FuncId, Module}; +use cranelift_module::FuncId; use object::write::*; use object::{RelocationEncoding, RelocationKind, SectionKind, SymbolFlags}; -use cranelift_object::{ObjectBackend, ObjectBuilder, ObjectProduct}; +use cranelift_object::{ObjectBuilder, ObjectModule, ObjectProduct}; use gimli::SectionId; @@ -71,16 +71,18 @@ impl WriteDebugInfo for ObjectProduct { let segment = self.object.segment_name(StandardSegment::Debug).to_vec(); // FIXME use SHT_X86_64_UNWIND for .eh_frame - let section_id = self.object.add_section(segment, name.clone(), if id == SectionId::EhFrame { - SectionKind::ReadOnlyData - } else { - SectionKind::Debug - }); - self.object.section_mut(section_id).set_data(data, if id == SectionId::EhFrame { - 8 - } else { - 1 - }); + let section_id = self.object.add_section( + segment, + name.clone(), + if id == SectionId::EhFrame { + SectionKind::ReadOnlyData + } else { + SectionKind::Debug + }, + ); + self.object + .section_mut(section_id) + .set_data(data, if id == SectionId::EhFrame { 8 } else { 1 }); let symbol_id = self.object.section_symbol(section_id); (section_id, symbol_id) } @@ -153,16 +155,6 @@ impl AddConstructor for ObjectProduct { } } -pub(crate) trait Emit { - fn emit(self) -> Vec; -} - -impl Emit for ObjectProduct { - fn emit(self) -> Vec { - self.object.write().unwrap() - } -} - pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec { let triple = crate::build_isa(sess, true).triple().clone(); @@ -193,10 +185,7 @@ pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object metadata_object.write().unwrap() } -pub(crate) type Backend = - impl cranelift_module::Backend; - -pub(crate) fn make_module(sess: &Session, name: String) -> Module { +pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule { let mut builder = ObjectBuilder::new( crate::build_isa(sess, true), name + ".o", @@ -206,8 +195,6 @@ pub(crate) fn make_module(sess: &Session, name: String) -> Module { if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() { builder.per_function_section(true); } - let module: Module = Module::new( - builder, - ); + let module = ObjectModule::new(builder); module } diff --git a/src/base.rs b/src/base.rs index d1b97420aa28d..9f558bc7520c2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -5,8 +5,8 @@ use rustc_middle::ty::adjustment::PointerCast; use crate::prelude::*; -pub(crate) fn trans_fn<'tcx, B: Backend + 'static>( - cx: &mut crate::CodegenCx<'tcx, B>, +pub(crate) fn trans_fn<'tcx>( + cx: &mut crate::CodegenCx<'tcx, impl Module>, instance: Instance<'tcx>, linkage: Linkage, ) { @@ -183,7 +183,7 @@ pub(crate) fn verify_func( }); } -fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { +fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { crate::constant::check_constants(fx); for (bb, bb_data) in fx.mir.basic_blocks().iter_enumerated() { @@ -417,7 +417,7 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } fn trans_stmt<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, #[allow(unused_variables)] cur_block: Block, stmt: &Statement<'tcx>, ) { @@ -543,7 +543,7 @@ fn trans_stmt<'tcx>( let to_ty = fx.monomorphize(to_ty); fn is_fat_ptr<'tcx>( - fx: &FunctionCx<'_, 'tcx, impl Backend>, + fx: &FunctionCx<'_, 'tcx, impl Module>, ty: Ty<'tcx>, ) -> bool { ty.builtin_deref(true) @@ -873,7 +873,7 @@ fn trans_stmt<'tcx>( } fn codegen_array_len<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, place: CPlace<'tcx>, ) -> Value { match *place.layout().ty.kind() { @@ -893,7 +893,7 @@ fn codegen_array_len<'tcx>( } pub(crate) fn trans_place<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, place: Place<'tcx>, ) -> CPlace<'tcx> { let mut cplace = fx.get_local_place(place.local); @@ -965,7 +965,7 @@ pub(crate) fn trans_place<'tcx>( } pub(crate) fn trans_operand<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, operand: &Operand<'tcx>, ) -> CValue<'tcx> { match operand { @@ -978,7 +978,7 @@ pub(crate) fn trans_operand<'tcx>( } pub(crate) fn codegen_panic<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, msg_str: &str, span: Span, ) { @@ -995,7 +995,7 @@ pub(crate) fn codegen_panic<'tcx>( } pub(crate) fn codegen_panic_inner<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, lang_item: rustc_hir::LangItem, args: &[Value], span: Span, diff --git a/src/cast.rs b/src/cast.rs index edfe6feb6c8a2..122a36b5bf741 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -3,7 +3,7 @@ use crate::prelude::*; pub(crate) fn clif_intcast( - fx: &mut FunctionCx<'_, '_, impl Backend>, + fx: &mut FunctionCx<'_, '_, impl Module>, val: Value, to: Type, signed: bool, @@ -51,7 +51,7 @@ pub(crate) fn clif_intcast( } pub(crate) fn clif_int_or_float_cast( - fx: &mut FunctionCx<'_, '_, impl Backend>, + fx: &mut FunctionCx<'_, '_, impl Module>, from: Value, from_signed: bool, to_ty: Type, diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 99bd526ad01a8..e998403dea6bb 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -3,7 +3,7 @@ use crate::prelude::*; pub(crate) fn maybe_codegen<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, checked: bool, lhs: CValue<'tcx>, diff --git a/src/common.rs b/src/common.rs index d1375c73a4b21..0f22f900ca7ae 100644 --- a/src/common.rs +++ b/src/common.rs @@ -131,7 +131,7 @@ pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { } pub(crate) fn codegen_icmp_imm( - fx: &mut FunctionCx<'_, '_, impl Backend>, + fx: &mut FunctionCx<'_, '_, impl Module>, intcc: IntCC, lhs: Value, rhs: i128, @@ -287,8 +287,8 @@ pub(crate) fn type_sign(ty: Ty<'_>) -> bool { } } -pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { - pub(crate) cx: &'clif mut crate::CodegenCx<'tcx, B>, +pub(crate) struct FunctionCx<'clif, 'tcx, M: Module> { + pub(crate) cx: &'clif mut crate::CodegenCx<'tcx, M>, pub(crate) tcx: TyCtxt<'tcx>, pub(crate) pointer_type: Type, // Cached from module @@ -314,7 +314,7 @@ pub(crate) struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub(crate) inline_asm_index: u32, } -impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { +impl<'tcx, M: Module> LayoutOf for FunctionCx<'_, 'tcx, M> { type Ty = Ty<'tcx>; type TyAndLayout = TyAndLayout<'tcx>; @@ -332,31 +332,31 @@ impl<'tcx, B: Backend> LayoutOf for FunctionCx<'_, 'tcx, B> { } } -impl<'tcx, B: Backend + 'static> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx, B> { +impl<'tcx, M: Module> layout::HasTyCtxt<'tcx> for FunctionCx<'_, 'tcx, M> { fn tcx<'b>(&'b self) -> TyCtxt<'tcx> { self.tcx } } -impl<'tcx, B: Backend + 'static> rustc_target::abi::HasDataLayout for FunctionCx<'_, 'tcx, B> { +impl<'tcx, M: Module> rustc_target::abi::HasDataLayout for FunctionCx<'_, 'tcx, M> { fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { &self.tcx.data_layout } } -impl<'tcx, B: Backend + 'static> layout::HasParamEnv<'tcx> for FunctionCx<'_, 'tcx, B> { +impl<'tcx, M: Module> layout::HasParamEnv<'tcx> for FunctionCx<'_, 'tcx, M> { fn param_env(&self) -> ParamEnv<'tcx> { ParamEnv::reveal_all() } } -impl<'tcx, B: Backend + 'static> HasTargetSpec for FunctionCx<'_, 'tcx, B> { +impl<'tcx, M: Module> HasTargetSpec for FunctionCx<'_, 'tcx, M> { fn target_spec(&self) -> &Target { &self.tcx.sess.target.target } } -impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { +impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> { pub(crate) fn monomorphize(&self, value: &T) -> T where T: TypeFoldable<'tcx> + Copy, @@ -430,7 +430,6 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { Linkage::Local, false, false, - None, ) .unwrap(); diff --git a/src/constant.rs b/src/constant.rs index 2c4d9b8f177b9..d6d38a4b3ad00 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -9,7 +9,6 @@ use rustc_middle::mir::interpret::{ read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Pointer, Scalar, }; use rustc_middle::ty::{Const, ConstKind}; -use rustc_target::abi::Align; use cranelift_codegen::ir::GlobalValueData; use cranelift_module::*; @@ -29,7 +28,7 @@ enum TodoItem { } impl ConstantCx { - pub(crate) fn finalize(mut self, tcx: TyCtxt<'_>, module: &mut Module) { + pub(crate) fn finalize(mut self, tcx: TyCtxt<'_>, module: &mut impl Module) { //println!("todo {:?}", self.todo); define_all_allocs(tcx, module, &mut self); //println!("done {:?}", self.done); @@ -37,7 +36,7 @@ impl ConstantCx { } } -pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Backend>) { +pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Module>) { for constant in &fx.mir.required_consts { let const_ = fx.monomorphize(&constant.literal); match const_.val { @@ -77,7 +76,7 @@ pub(crate) fn codegen_static(constants_cx: &mut ConstantCx, def_id: DefId) { } pub(crate) fn codegen_tls_ref<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { @@ -90,7 +89,7 @@ pub(crate) fn codegen_tls_ref<'tcx>( } fn codegen_static_ref<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, def_id: DefId, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { @@ -108,7 +107,7 @@ fn codegen_static_ref<'tcx>( } pub(crate) fn trans_constant<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, constant: &Constant<'tcx>, ) -> CValue<'tcx> { let const_ = fx.monomorphize(&constant.literal); @@ -156,7 +155,7 @@ pub(crate) fn trans_constant<'tcx>( } pub(crate) fn trans_const_value<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, const_val: ConstValue<'tcx>, ty: Ty<'tcx>, ) -> CValue<'tcx> { @@ -199,7 +198,6 @@ pub(crate) fn trans_const_value<'tcx>( let data_id = data_id_for_alloc_id( &mut fx.cx.module, ptr.alloc_id, - alloc.align, alloc.mutability, ); let local_data_id = @@ -254,12 +252,12 @@ pub(crate) fn trans_const_value<'tcx>( } fn pointer_for_allocation<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, alloc: &'tcx Allocation, ) -> crate::pointer::Pointer { let alloc_id = fx.tcx.create_memory_alloc(alloc); fx.cx.constants_cx.todo.push(TodoItem::Alloc(alloc_id)); - let data_id = data_id_for_alloc_id(&mut fx.cx.module, alloc_id, alloc.align, alloc.mutability); + let data_id = data_id_for_alloc_id(&mut fx.cx.module, alloc_id, alloc.mutability); let local_data_id = fx.cx.module.declare_data_in_func(data_id, &mut fx.bcx.func); #[cfg(debug_assertions)] @@ -268,10 +266,9 @@ fn pointer_for_allocation<'tcx>( crate::pointer::Pointer::new(global_ptr) } -fn data_id_for_alloc_id( - module: &mut Module, +fn data_id_for_alloc_id( + module: &mut impl Module, alloc_id: AllocId, - align: Align, mutability: rustc_hir::Mutability, ) -> DataId { module @@ -280,14 +277,13 @@ fn data_id_for_alloc_id( Linkage::Local, mutability == rustc_hir::Mutability::Mut, false, - Some(align.bytes() as u8), ) .unwrap() } fn data_id_for_static( tcx: TyCtxt<'_>, - module: &mut Module, + module: &mut impl Module, def_id: DefId, definition: bool, ) -> DataId { @@ -327,7 +323,6 @@ fn data_id_for_static( linkage, is_mutable, attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL), - Some(align.try_into().unwrap()), ) .unwrap(); @@ -342,15 +337,10 @@ fn data_id_for_static( let ref_name = format!("_rust_extern_with_linkage_{}", symbol_name); let ref_data_id = module - .declare_data( - &ref_name, - Linkage::Local, - true, - false, - Some(align.try_into().unwrap()), - ) + .declare_data(&ref_name, Linkage::Local, true, false) .unwrap(); let mut data_ctx = DataContext::new(); + data_ctx.set_align(align); let data = module.declare_data_in_data(data_id, &mut data_ctx); data_ctx.define( std::iter::repeat(0) @@ -370,7 +360,7 @@ fn data_id_for_static( } } -fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mut ConstantCx) { +fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut impl Module, cx: &mut ConstantCx) { while let Some(todo_item) = cx.todo.pop() { let (data_id, alloc, section_name) = match todo_item { TodoItem::Alloc(alloc_id) => { @@ -379,7 +369,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu GlobalAlloc::Memory(alloc) => alloc, GlobalAlloc::Function(_) | GlobalAlloc::Static(_) => unreachable!(), }; - let data_id = data_id_for_alloc_id(module, alloc_id, alloc.align, alloc.mutability); + let data_id = data_id_for_alloc_id(module, alloc_id, alloc.mutability); (data_id, alloc, None) } TodoItem::Static(def_id) => { @@ -403,6 +393,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu } let mut data_ctx = DataContext::new(); + data_ctx.set_align(alloc.align.bytes()); if let Some(section_name) = section_name { // FIXME set correct segment for Mach-O files @@ -436,7 +427,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu } GlobalAlloc::Memory(target_alloc) => { cx.todo.push(TodoItem::Alloc(reloc)); - data_id_for_alloc_id(module, reloc, target_alloc.align, target_alloc.mutability) + data_id_for_alloc_id(module, reloc, target_alloc.mutability) } GlobalAlloc::Static(def_id) => { if tcx @@ -469,7 +460,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut Module, cx: &mu } pub(crate) fn mir_operand_get_const_val<'tcx>( - fx: &FunctionCx<'_, 'tcx, impl Backend>, + fx: &FunctionCx<'_, 'tcx, impl Module>, operand: &Operand<'tcx>, ) -> Option<&'tcx Const<'tcx>> { match operand { diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 0a887e8cb5932..3ad52c2e873de 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -76,7 +76,7 @@ impl WriterRelocate { #[cfg(feature = "jit")] pub(super) fn relocate_for_jit( mut self, - jit_module: &mut cranelift_module::Module, + jit_product: &cranelift_simplejit::SimpleJITProduct, ) -> Vec { use std::convert::TryInto; @@ -84,7 +84,7 @@ impl WriterRelocate { match reloc.name { super::DebugRelocName::Section(_) => unreachable!(), super::DebugRelocName::Symbol(sym) => { - let addr = jit_module.get_finalized_function( + let addr = jit_product.lookup_func( cranelift_module::FuncId::from_u32(sym.try_into().unwrap()), ); let val = (addr as u64 as i64 + reloc.addend) as u64; diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index 9cad668e3f6aa..f33aa6683a726 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -336,6 +336,8 @@ impl<'tcx> DebugContext<'tcx> { | ArgumentPurpose::CalleeSaved => continue, ArgumentPurpose::VMContext | ArgumentPurpose::SignatureId + | ArgumentPurpose::CallerTLS + | ArgumentPurpose::CalleeTLS | ArgumentPurpose::StackLimit => unreachable!(), }; let name = format!("{}{}", base_name, i); diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index fa1a9d44117fc..f08dfb6076949 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -78,7 +78,7 @@ impl<'tcx> UnwindContext<'tcx> { #[cfg(feature = "jit")] pub(crate) unsafe fn register_jit( self, - jit_module: &mut Module, + jit_product: &cranelift_simplejit::SimpleJITProduct, ) -> Option { let mut eh_frame = EhFrame::from(super::emit::WriterRelocate::new(super::target_endian( self.tcx, @@ -89,7 +89,7 @@ impl<'tcx> UnwindContext<'tcx> { return None; } - let mut eh_frame = eh_frame.0.relocate_for_jit(jit_module); + let mut eh_frame = eh_frame.0.relocate_for_jit(jit_product); // GCC expects a terminating "empty" length, so write a 0 length at the end of the table. eh_frame.extend(&[0, 0, 0, 0]); diff --git a/src/discriminant.rs b/src/discriminant.rs index 231802dfb859b..d15bc36ad05ef 100644 --- a/src/discriminant.rs +++ b/src/discriminant.rs @@ -7,7 +7,7 @@ use rustc_target::abi::{Int, TagEncoding, Variants}; use crate::prelude::*; pub(crate) fn codegen_set_discriminant<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, place: CPlace<'tcx>, variant_index: VariantIdx, ) { @@ -57,7 +57,7 @@ pub(crate) fn codegen_set_discriminant<'tcx>( } pub(crate) fn codegen_get_discriminant<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, value: CValue<'tcx>, dest_layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { diff --git a/src/driver/aot.rs b/src/driver/aot.rs index fc01398c40d9e..2b3d1b7885d18 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -12,11 +12,13 @@ use rustc_middle::mir::mono::CodegenUnit; use rustc_session::cgu_reuse_tracker::CguReuse; use rustc_session::config::{DebugInfo, OutputType}; +use cranelift_object::{ObjectModule, ObjectProduct}; + use crate::prelude::*; -use crate::backend::{AddConstructor, Emit, WriteDebugInfo}; +use crate::backend::AddConstructor; -fn new_module(tcx: TyCtxt<'_>, name: String) -> Module { +fn new_module(tcx: TyCtxt<'_>, name: String) -> ObjectModule { let module = crate::backend::make_module(tcx.sess, name); assert_eq!(pointer_ty(tcx), module.target_config().pointer_type()); module @@ -30,19 +32,15 @@ impl HashStable for ModuleCodegenResult { } } -fn emit_module( +fn emit_module( tcx: TyCtxt<'_>, name: String, kind: ModuleKind, - mut module: Module, + module: ObjectModule, debug: Option>, unwind_context: UnwindContext<'_>, - map_product: impl FnOnce(B::Product) -> B::Product, -) -> ModuleCodegenResult -where - B::Product: AddConstructor + Emit + WriteDebugInfo, -{ - module.finalize_definitions(); + map_product: impl FnOnce(ObjectProduct) -> ObjectProduct, +) -> ModuleCodegenResult { let mut product = module.finish(); if let Some(mut debug) = debug { @@ -56,7 +54,7 @@ where let tmp_file = tcx .output_filenames(LOCAL_CRATE) .temp_path(OutputType::Object, Some(&name)); - let obj = product.emit(); + let obj = product.object.write().unwrap(); if let Err(err) = std::fs::write(&tmp_file, obj) { tcx.sess .fatal(&format!("error writing object file: {}", err)); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 5a899afb97ca4..611a70eae2bb0 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -9,7 +9,7 @@ use rustc_codegen_ssa::CrateInfo; use crate::prelude::*; pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { - use cranelift_simplejit::{SimpleJITBackend, SimpleJITBuilder}; + use cranelift_simplejit::{SimpleJITModule, SimpleJITBuilder}; #[cfg(unix)] unsafe { @@ -36,7 +36,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { cranelift_module::default_libcall_names(), ); jit_builder.symbols(imported_symbols); - let mut jit_module: Module = Module::new(jit_builder); + let mut jit_module = SimpleJITModule::new(jit_builder); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); let sig = Signature { @@ -79,13 +79,13 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context, true); crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context); - jit_module.finalize_definitions(); + let jit_product = jit_module.finish(); - let _unwind_register_guard = unsafe { unwind_context.register_jit(&mut jit_module) }; + let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_product) }; tcx.sess.abort_if_errors(); - let finalized_main: *const u8 = jit_module.get_finalized_function(main_func_id); + let finalized_main: *const u8 = jit_product.lookup_func(main_func_id); println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed"); @@ -105,7 +105,6 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { let ret = f(args.len() as c_int, argv.as_ptr()); - jit_module.finish(); std::process::exit(ret); } diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 881221c010541..c32c479251970 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -41,7 +41,7 @@ pub(crate) fn codegen_crate( } fn codegen_mono_items<'tcx>( - cx: &mut crate::CodegenCx<'tcx, impl Backend + 'static>, + cx: &mut crate::CodegenCx<'tcx, impl Module>, mono_items: Vec<(MonoItem<'tcx>, (RLinkage, Visibility))>, ) { cx.tcx.sess.time("predefine functions", || { @@ -68,8 +68,8 @@ fn codegen_mono_items<'tcx>( } } -fn trans_mono_item<'tcx, B: Backend + 'static>( - cx: &mut crate::CodegenCx<'tcx, B>, +fn trans_mono_item<'tcx, M: Module>( + cx: &mut crate::CodegenCx<'tcx, M>, mono_item: MonoItem<'tcx>, linkage: Linkage, ) { diff --git a/src/inline_asm.rs b/src/inline_asm.rs index e11ba4a4f6370..aa2edb2dfd4f7 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -9,7 +9,7 @@ use rustc_middle::mir::InlineAsmOperand; use rustc_target::asm::*; pub(crate) fn codegen_inline_asm<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, _span: Span, template: &[InlineAsmTemplatePiece], operands: &[InlineAsmOperand<'tcx>], @@ -203,7 +203,7 @@ fn generate_asm_wrapper( } fn call_inline_asm<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, asm_name: &str, slot_size: Size, inputs: Vec<(InlineAsmReg, Size, Value)>, diff --git a/src/intrinsics/cpuid.rs b/src/intrinsics/cpuid.rs index 94c280ee0badb..c1a1cdbe4eb7d 100644 --- a/src/intrinsics/cpuid.rs +++ b/src/intrinsics/cpuid.rs @@ -6,7 +6,7 @@ use crate::prelude::*; /// /// This emulates an intel cpu with sse and sse2 support, but which doesn't support anything else. pub(crate) fn codegen_cpuid_call<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, leaf: Value, _subleaf: Value, ) -> (Value, Value, Value, Value) { diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index 8bd744dbc3541..18d86f0c5f959 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -6,7 +6,7 @@ use crate::prelude::*; use rustc_middle::ty::subst::SubstsRef; pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, intrinsic: &str, substs: SubstsRef<'tcx>, args: &[mir::Operand<'tcx>], diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index e75e83b56d69e..9a3e4c7b56e9c 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -204,12 +204,12 @@ pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx } } -fn simd_for_each_lane<'tcx, B: Backend>( - fx: &mut FunctionCx<'_, 'tcx, B>, +fn simd_for_each_lane<'tcx, M: Module>( + fx: &mut FunctionCx<'_, 'tcx, M>, val: CValue<'tcx>, ret: CPlace<'tcx>, f: impl Fn( - &mut FunctionCx<'_, 'tcx, B>, + &mut FunctionCx<'_, 'tcx, M>, TyAndLayout<'tcx>, TyAndLayout<'tcx>, Value, @@ -231,13 +231,13 @@ fn simd_for_each_lane<'tcx, B: Backend>( } } -fn simd_pair_for_each_lane<'tcx, B: Backend>( - fx: &mut FunctionCx<'_, 'tcx, B>, +fn simd_pair_for_each_lane<'tcx, M: Module>( + fx: &mut FunctionCx<'_, 'tcx, M>, x: CValue<'tcx>, y: CValue<'tcx>, ret: CPlace<'tcx>, f: impl Fn( - &mut FunctionCx<'_, 'tcx, B>, + &mut FunctionCx<'_, 'tcx, M>, TyAndLayout<'tcx>, TyAndLayout<'tcx>, Value, @@ -263,7 +263,7 @@ fn simd_pair_for_each_lane<'tcx, B: Backend>( } fn bool_to_zero_or_max_uint<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, layout: TyAndLayout<'tcx>, val: Value, ) -> CValue<'tcx> { @@ -395,7 +395,7 @@ macro simd_flt_binop($fx:expr, $op:ident($x:ident, $y:ident) -> $ret:ident) { } pub(crate) fn codegen_intrinsic_call<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, instance: Instance<'tcx>, args: &[mir::Operand<'tcx>], destination: Option<(CPlace<'tcx>, BasicBlock)>, diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 93724522e76b7..e9d3cc8d25692 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -4,7 +4,7 @@ use super::*; use crate::prelude::*; pub(super) fn codegen_simd_intrinsic_call<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, instance: Instance<'tcx>, args: &[mir::Operand<'tcx>], ret: CPlace<'tcx>, diff --git a/src/lib.rs b/src/lib.rs index e3a632fc465f6..c10eeb7bf8849 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -108,9 +108,7 @@ mod prelude { pub(crate) use cranelift_codegen::isa::{self, CallConv}; pub(crate) use cranelift_codegen::Context; pub(crate) use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext, Variable}; - pub(crate) use cranelift_module::{ - self, Backend, DataContext, DataId, FuncId, Linkage, Module, - }; + pub(crate) use cranelift_module::{self, DataContext, DataId, FuncId, Linkage, Module}; pub(crate) use crate::abi::*; pub(crate) use crate::base::{trans_operand, trans_place}; @@ -131,9 +129,9 @@ impl String> Drop for PrintOnPanic { } } -struct CodegenCx<'tcx, B: Backend + 'static> { +struct CodegenCx<'tcx, M: Module> { tcx: TyCtxt<'tcx>, - module: Module, + module: M, global_asm: String, constants_cx: ConstantCx, cached_context: Context, @@ -142,8 +140,8 @@ struct CodegenCx<'tcx, B: Backend + 'static> { unwind_context: UnwindContext<'tcx>, } -impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { - fn new(tcx: TyCtxt<'tcx>, module: Module, debug_info: bool) -> Self { +impl<'tcx, M: Module> CodegenCx<'tcx, M> { + fn new(tcx: TyCtxt<'tcx>, module: M, debug_info: bool) -> Self { let unwind_context = UnwindContext::new(tcx, module.isa()); let debug_context = if debug_info { Some(DebugContext::new(tcx, module.isa())) @@ -162,14 +160,7 @@ impl<'tcx, B: Backend + 'static> CodegenCx<'tcx, B> { } } - fn finalize( - mut self, - ) -> ( - Module, - String, - Option>, - UnwindContext<'tcx>, - ) { + fn finalize(mut self) -> (M, String, Option>, UnwindContext<'tcx>) { self.constants_cx.finalize(self.tcx, &mut self.module); ( self.module, @@ -352,8 +343,6 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box Box { Box::new(CraneliftCodegenBackend { - config: BackendConfig { - use_jit: false, - } + config: BackendConfig { use_jit: false }, }) } diff --git a/src/main_shim.rs b/src/main_shim.rs index c4b21dcecd333..db34d89fe2be7 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -7,7 +7,7 @@ use crate::prelude::*; /// users main function. pub(crate) fn maybe_create_entry_wrapper( tcx: TyCtxt<'_>, - module: &mut Module, + module: &mut impl Module, unwind_context: &mut UnwindContext<'_>, use_jit: bool, ) { @@ -38,7 +38,7 @@ pub(crate) fn maybe_create_entry_wrapper( fn create_entry_fn( tcx: TyCtxt<'_>, - m: &mut Module, + m: &mut impl Module, unwind_context: &mut UnwindContext<'_>, rust_main_def_id: DefId, use_start_lang_item: bool, diff --git a/src/num.rs b/src/num.rs index 4e3b79cd2d6f9..b37826d71f4e0 100644 --- a/src/num.rs +++ b/src/num.rs @@ -41,7 +41,7 @@ pub(crate) fn bin_op_to_intcc(bin_op: BinOp, signed: bool) -> Option { } fn codegen_compare_bin_op<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, signed: bool, lhs: Value, @@ -54,7 +54,7 @@ fn codegen_compare_bin_op<'tcx>( } pub(crate) fn codegen_binop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -103,7 +103,7 @@ pub(crate) fn codegen_binop<'tcx>( } pub(crate) fn trans_bool_binop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -124,7 +124,7 @@ pub(crate) fn trans_bool_binop<'tcx>( } pub(crate) fn trans_int_binop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -197,7 +197,7 @@ pub(crate) fn trans_int_binop<'tcx>( } pub(crate) fn trans_checked_int_binop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -358,7 +358,7 @@ pub(crate) fn trans_checked_int_binop<'tcx>( } pub(crate) fn trans_float_binop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, @@ -403,7 +403,7 @@ pub(crate) fn trans_float_binop<'tcx>( } pub(crate) fn trans_ptr_binop<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, bin_op: BinOp, in_lhs: CValue<'tcx>, in_rhs: CValue<'tcx>, diff --git a/src/pointer.rs b/src/pointer.rs index cd3f27c324777..b2036d7bcd452 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -37,7 +37,7 @@ impl Pointer { } pub(crate) fn const_addr<'a, 'tcx>( - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'a, 'tcx, impl Module>, addr: i64, ) -> Self { let addr = fx.bcx.ins().iconst(fx.pointer_type, addr); @@ -59,7 +59,7 @@ impl Pointer { (self.base, self.offset) } - pub(crate) fn get_addr<'a, 'tcx>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Value { + pub(crate) fn get_addr<'a, 'tcx>(self, fx: &mut FunctionCx<'a, 'tcx, impl Module>) -> Value { match self.base { PointerBase::Addr(base_addr) => { let offset: i64 = self.offset.into(); @@ -83,7 +83,7 @@ impl Pointer { pub(crate) fn offset<'a, 'tcx>( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'a, 'tcx, impl Module>, extra_offset: Offset32, ) -> Self { self.offset_i64(fx, extra_offset.into()) @@ -91,7 +91,7 @@ impl Pointer { pub(crate) fn offset_i64<'a, 'tcx>( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'a, 'tcx, impl Module>, extra_offset: i64, ) -> Self { if let Some(new_offset) = self.offset.try_add_i64(extra_offset) { @@ -128,7 +128,7 @@ impl Pointer { pub(crate) fn offset_value<'a, 'tcx>( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'a, 'tcx, impl Module>, extra_offset: Value, ) -> Self { match self.base { @@ -161,7 +161,7 @@ impl Pointer { pub(crate) fn load<'a, 'tcx>( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'a, 'tcx, impl Module>, ty: Type, flags: MemFlags, ) -> Value { @@ -182,7 +182,7 @@ impl Pointer { pub(crate) fn store<'a, 'tcx>( self, - fx: &mut FunctionCx<'a, 'tcx, impl Backend>, + fx: &mut FunctionCx<'a, 'tcx, impl Module>, value: Value, flags: MemFlags, ) { diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 5c4d951bc5076..e99bec45a5efe 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -186,7 +186,7 @@ impl FuncWriter for &'_ CommentWriter { } #[cfg(debug_assertions)] -impl FunctionCx<'_, '_, B> { +impl FunctionCx<'_, '_, M> { pub(crate) fn add_global_comment>(&mut self, comment: S) { self.clif_comments.add_global_comment(comment); } @@ -264,7 +264,7 @@ pub(crate) fn write_clif_file<'tcx>( } } -impl fmt::Debug for FunctionCx<'_, '_, B> { +impl fmt::Debug for FunctionCx<'_, '_, M> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "{:?}", self.instance.substs)?; writeln!(f, "{:?}", self.local_map)?; diff --git a/src/trap.rs b/src/trap.rs index f3ce0ee4beb94..007b64656053c 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -2,7 +2,7 @@ use crate::prelude::*; -fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, msg: &str) { +fn codegen_print(fx: &mut FunctionCx<'_, '_, impl Module>, msg: &str) { let puts = fx .cx .module @@ -30,7 +30,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms /// Trap code: user1 pub(crate) fn trap_abort( - fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, + fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef, ) { codegen_print(fx, msg.as_ref()); @@ -42,7 +42,7 @@ pub(crate) fn trap_abort( /// /// Trap code: user65535 pub(crate) fn trap_unreachable( - fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, + fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef, ) { codegen_print(fx, msg.as_ref()); @@ -53,7 +53,7 @@ pub(crate) fn trap_unreachable( /// /// Trap code: user65535 pub(crate) fn trap_unreachable_ret_value<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, dest_layout: TyAndLayout<'tcx>, msg: impl AsRef, ) -> CValue<'tcx> { @@ -69,7 +69,7 @@ pub(crate) fn trap_unreachable_ret_value<'tcx>( /// /// Trap code: user65535 pub(crate) fn trap_unimplemented( - fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, + fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef, ) { codegen_print(fx, msg.as_ref()); @@ -81,7 +81,7 @@ pub(crate) fn trap_unimplemented( /// /// Trap code: user65535 pub(crate) fn trap_unimplemented_ret_value<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, dest_layout: TyAndLayout<'tcx>, msg: impl AsRef, ) -> CValue<'tcx> { diff --git a/src/unsize.rs b/src/unsize.rs index 441d2b5edd893..c77ff5d56ba62 100644 --- a/src/unsize.rs +++ b/src/unsize.rs @@ -13,7 +13,7 @@ use crate::prelude::*; /// in an upcast, where the new vtable for an object will be derived /// from the old one. pub(crate) fn unsized_info<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, source: Ty<'tcx>, target: Ty<'tcx>, old_info: Option, @@ -45,7 +45,7 @@ pub(crate) fn unsized_info<'tcx>( /// Coerce `src` to `dst_ty`. `src_ty` must be a thin pointer. fn unsize_thin_ptr<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, src: Value, src_layout: TyAndLayout<'tcx>, dst_layout: TyAndLayout<'tcx>, @@ -89,7 +89,7 @@ fn unsize_thin_ptr<'tcx>( /// Coerce `src`, which is a reference to a value of type `src_ty`, /// to a value of type `dst_ty` and store the result in `dst` pub(crate) fn coerce_unsized_into<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, src: CValue<'tcx>, dst: CPlace<'tcx>, ) { @@ -142,7 +142,7 @@ pub(crate) fn coerce_unsized_into<'tcx>( // Adapted from https://github.com/rust-lang/rust/blob/2a663555ddf36f6b041445894a8c175cd1bc718c/src/librustc_codegen_ssa/glue.rs pub(crate) fn size_and_align_of_dst<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, layout: TyAndLayout<'tcx>, info: Value, ) -> (Value, Value) { diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 5e663425117f0..5d513cb3ea022 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -6,7 +6,7 @@ use cranelift_codegen::entity::EntityRef; use cranelift_codegen::ir::immediates::Offset32; fn codegen_field<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, base: Pointer, extra: Option, layout: TyAndLayout<'tcx>, @@ -108,7 +108,7 @@ impl<'tcx> CValue<'tcx> { // FIXME remove pub(crate) fn force_stack( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, ) -> (Pointer, Option) { let layout = self.1; match self.0 { @@ -129,7 +129,7 @@ impl<'tcx> CValue<'tcx> { } /// Load a value with layout.abi of scalar - pub(crate) fn load_scalar(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value { + pub(crate) fn load_scalar(self, fx: &mut FunctionCx<'_, 'tcx, impl Module>) -> Value { let layout = self.1; match self.0 { CValueInner::ByRef(ptr, None) => { @@ -155,7 +155,7 @@ impl<'tcx> CValue<'tcx> { /// Load a value pair with layout.abi of scalar pair pub(crate) fn load_scalar_pair( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, ) -> (Value, Value) { let layout = self.1; match self.0 { @@ -183,7 +183,7 @@ impl<'tcx> CValue<'tcx> { pub(crate) fn value_field( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, field: mir::Field, ) -> CValue<'tcx> { let layout = self.1; @@ -221,7 +221,7 @@ impl<'tcx> CValue<'tcx> { pub(crate) fn unsize_value( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, dest: CPlace<'tcx>, ) { crate::unsize::coerce_unsized_into(fx, self, dest); @@ -229,7 +229,7 @@ impl<'tcx> CValue<'tcx> { /// If `ty` is signed, `const_val` must already be sign extended. pub(crate) fn const_val( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, layout: TyAndLayout<'tcx>, const_val: u128, ) -> CValue<'tcx> { @@ -325,7 +325,7 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn new_stack_slot( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { assert!(!layout.is_unsized()); @@ -345,7 +345,7 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn new_var( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, local: Local, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { @@ -359,7 +359,7 @@ impl<'tcx> CPlace<'tcx> { } pub(crate) fn new_var_pair( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, local: Local, layout: TyAndLayout<'tcx>, ) -> CPlace<'tcx> { @@ -395,7 +395,7 @@ impl<'tcx> CPlace<'tcx> { } } - pub(crate) fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CValue<'tcx> { + pub(crate) fn to_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Module>) -> CValue<'tcx> { let layout = self.layout(); match self.inner { CPlaceInner::Var(_local, var) => { @@ -448,11 +448,11 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn write_cvalue( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, from: CValue<'tcx>, ) { fn assert_assignable<'tcx>( - fx: &FunctionCx<'_, 'tcx, impl Backend>, + fx: &FunctionCx<'_, 'tcx, impl Module>, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>, ) { @@ -514,7 +514,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn write_cvalue_transmute( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, from: CValue<'tcx>, ) { self.write_cvalue_maybe_transmute(fx, from, "write_cvalue_transmute"); @@ -522,12 +522,12 @@ impl<'tcx> CPlace<'tcx> { fn write_cvalue_maybe_transmute( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, from: CValue<'tcx>, #[cfg_attr(not(debug_assertions), allow(unused_variables))] method: &'static str, ) { fn transmute_value<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, var: Variable, data: Value, dst_ty: Type, @@ -667,7 +667,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn place_field( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, field: mir::Field, ) -> CPlace<'tcx> { let layout = self.layout(); @@ -715,7 +715,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn place_index( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, index: Value, ) -> CPlace<'tcx> { let (elem_layout, ptr) = match self.layout().ty.kind() { @@ -732,7 +732,7 @@ impl<'tcx> CPlace<'tcx> { CPlace::for_ptr(ptr.offset_value(fx, offset), elem_layout) } - pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> CPlace<'tcx> { + pub(crate) fn place_deref(self, fx: &mut FunctionCx<'_, 'tcx, impl Module>) -> CPlace<'tcx> { let inner_layout = fx.layout_of(self.layout().ty.builtin_deref(true).unwrap().ty); if has_ptr_meta(fx.tcx, inner_layout.ty) { let (addr, extra) = self.to_cvalue(fx).load_scalar_pair(fx); @@ -747,7 +747,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn place_ref( self, - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, layout: TyAndLayout<'tcx>, ) -> CValue<'tcx> { if has_ptr_meta(fx.tcx, self.layout().ty) { @@ -764,7 +764,7 @@ impl<'tcx> CPlace<'tcx> { pub(crate) fn downcast_variant( self, - fx: &FunctionCx<'_, 'tcx, impl Backend>, + fx: &FunctionCx<'_, 'tcx, impl Module>, variant: VariantIdx, ) -> Self { assert!(!self.layout().is_unsized()); diff --git a/src/vtable.rs b/src/vtable.rs index d6bb9c912b557..bb3cf8b3f3a3a 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -15,7 +15,7 @@ fn vtable_memflags() -> MemFlags { flags } -pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { +pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Module>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -25,7 +25,7 @@ pub(crate) fn drop_fn_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: ) } -pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { +pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Module>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -35,7 +35,7 @@ pub(crate) fn size_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Val ) } -pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable: Value) -> Value { +pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Module>, vtable: Value) -> Value { let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize; fx.bcx.ins().load( pointer_ty(fx.tcx), @@ -46,7 +46,7 @@ pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, impl Backend>, vtable } pub(crate) fn get_ptr_and_method_ref<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, arg: CValue<'tcx>, idx: usize, ) -> (Value, Value) { @@ -68,7 +68,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>( } pub(crate) fn get_vtable<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> Value { @@ -85,7 +85,7 @@ pub(crate) fn get_vtable<'tcx>( } fn build_vtable<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Backend>, + fx: &mut FunctionCx<'_, 'tcx, impl Module>, layout: TyAndLayout<'tcx>, trait_ref: Option>, ) -> DataId { @@ -137,6 +137,16 @@ fn build_vtable<'tcx>( } } + data_ctx.set_align( + fx.tcx + .data_layout + .pointer_align + .pref + .bytes() + .try_into() + .unwrap(), + ); + let data_id = fx .cx .module @@ -153,15 +163,6 @@ fn build_vtable<'tcx>( Linkage::Local, false, false, - Some( - fx.tcx - .data_layout - .pointer_align - .pref - .bytes() - .try_into() - .unwrap(), - ), ) .unwrap(); From c352f91b40a3533d49cc1c1ef58f9e656409cce5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 9 Oct 2020 19:17:52 +0200 Subject: [PATCH 1542/1566] Rustfmt --- src/bin/cg_clif.rs | 4 +--- src/debuginfo/emit.rs | 50 +++++++++++++++++------------------------ src/debuginfo/unwind.rs | 3 ++- src/driver/jit.rs | 2 +- src/trap.rs | 15 +++---------- 5 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index 8a39e9b0590ed..8ff1bf271ef49 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -81,9 +81,7 @@ fn main() { None, Some(Box::new(move |_| { Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { - config: rustc_codegen_cranelift::BackendConfig { - use_jit, - } + config: rustc_codegen_cranelift::BackendConfig { use_jit }, }) })), ) diff --git a/src/debuginfo/emit.rs b/src/debuginfo/emit.rs index 3ad52c2e873de..cf8fee2b1d17c 100644 --- a/src/debuginfo/emit.rs +++ b/src/debuginfo/emit.rs @@ -84,9 +84,8 @@ impl WriterRelocate { match reloc.name { super::DebugRelocName::Section(_) => unreachable!(), super::DebugRelocName::Symbol(sym) => { - let addr = jit_product.lookup_func( - cranelift_module::FuncId::from_u32(sym.try_into().unwrap()), - ); + let addr = jit_product + .lookup_func(cranelift_module::FuncId::from_u32(sym.try_into().unwrap())); let val = (addr as u64 as i64 + reloc.addend) as u64; self.writer .write_udata_at(reloc.offset as usize, val, reloc.size) @@ -163,12 +162,7 @@ impl Writer for WriterRelocate { self.write_udata_at(offset, 0, size) } - fn write_eh_pointer( - &mut self, - address: Address, - eh_pe: gimli::DwEhPe, - size: u8, - ) -> Result<()> { + fn write_eh_pointer(&mut self, address: Address, eh_pe: gimli::DwEhPe, size: u8) -> Result<()> { match address { // Address::Constant arm copied from gimli Address::Constant(val) => { @@ -186,27 +180,25 @@ impl Writer for WriterRelocate { }; self.write_eh_pointer_data(val, eh_pe.format(), size) } - Address::Symbol { symbol, addend } => { - match eh_pe.application() { - gimli::DW_EH_PE_pcrel => { - let size = match eh_pe.format() { - gimli::DW_EH_PE_sdata4 => 4, - _ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)), - }; - self.relocs.push(DebugReloc { - offset: self.len() as u32, - size, - name: DebugRelocName::Symbol(symbol), - addend, - kind: object::RelocationKind::Relative, - }); - self.write_udata(0, size) - } - _ => { - return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); - } + Address::Symbol { symbol, addend } => match eh_pe.application() { + gimli::DW_EH_PE_pcrel => { + let size = match eh_pe.format() { + gimli::DW_EH_PE_sdata4 => 4, + _ => return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)), + }; + self.relocs.push(DebugReloc { + offset: self.len() as u32, + size, + name: DebugRelocName::Symbol(symbol), + addend, + kind: object::RelocationKind::Relative, + }); + self.write_udata(0, size) } - } + _ => { + return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)); + } + }, } } } diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index f08dfb6076949..61ebd931d2f14 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -20,7 +20,8 @@ impl<'tcx> UnwindContext<'tcx> { let cie_id = if let Some(mut cie) = isa.create_systemv_cie() { if isa.flags().is_pic() { - cie.fde_address_encoding = gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0); + cie.fde_address_encoding = + gimli::DwEhPe(gimli::DW_EH_PE_pcrel.0 | gimli::DW_EH_PE_sdata4.0); } Some(frame_table.add_cie(cie)) } else { diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 611a70eae2bb0..6f398d045b646 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -9,7 +9,7 @@ use rustc_codegen_ssa::CrateInfo; use crate::prelude::*; pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { - use cranelift_simplejit::{SimpleJITModule, SimpleJITBuilder}; + use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule}; #[cfg(unix)] unsafe { diff --git a/src/trap.rs b/src/trap.rs index 007b64656053c..67495c7414840 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -29,10 +29,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl Module>, msg: &str) { } /// Trap code: user1 -pub(crate) fn trap_abort( - fx: &mut FunctionCx<'_, '_, impl Module>, - msg: impl AsRef, -) { +pub(crate) fn trap_abort(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::User(1)); } @@ -41,10 +38,7 @@ pub(crate) fn trap_abort( /// so you can **not** add instructions to it afterwards. /// /// Trap code: user65535 -pub(crate) fn trap_unreachable( - fx: &mut FunctionCx<'_, '_, impl Module>, - msg: impl AsRef, -) { +pub(crate) fn trap_unreachable(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); } @@ -68,10 +62,7 @@ pub(crate) fn trap_unreachable_ret_value<'tcx>( /// to it afterwards. /// /// Trap code: user65535 -pub(crate) fn trap_unimplemented( - fx: &mut FunctionCx<'_, '_, impl Module>, - msg: impl AsRef, -) { +pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg: impl AsRef) { codegen_print(fx, msg.as_ref()); let true_ = fx.bcx.ins().iconst(types::I32, 1); fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); From faec12461f34db4145000a891c4ee5df2e8d4132 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 10 Oct 2020 16:41:31 +0200 Subject: [PATCH 1543/1566] Use custom driver for sysroot building too This required another custom driver to ensure that build scripts are built using cg_llvm instead of cg_clif. After this change only rustdoc still uses -Zcodegen-backend --- build_sysroot/build_sysroot.sh | 4 +- src/bin/cg_clif.rs | 6 +- src/bin/cg_clif_build_sysroot.rs | 112 +++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 src/bin/cg_clif_build_sysroot.rs diff --git a/build_sysroot/build_sysroot.sh b/build_sysroot/build_sysroot.sh index 930f3054b039c..04c82ca2a5128 100755 --- a/build_sysroot/build_sysroot.sh +++ b/build_sysroot/build_sysroot.sh @@ -16,8 +16,8 @@ rm -r sysroot/ 2>/dev/null || true # Use rustc with cg_clif as hotpluggable backend instead of the custom cg_clif driver so that # build scripts are still compiled using cg_llvm. -export RUSTC=rustc -export RUSTFLAGS=$RUSTFLAGS" -Ztrim-diagnostic-paths=no -Zcodegen-backend=$(pwd)/../target/"$CHANNEL"/librustc_codegen_cranelift."$dylib_ext" --sysroot $(pwd)/sysroot" +export RUSTC=$(pwd)/../"target/"$CHANNEL"/cg_clif_build_sysroot" +export RUSTFLAGS=$RUSTFLAGS" --clif" # Build libs export RUSTFLAGS="$RUSTFLAGS -Zforce-unstable-if-unmarked -Cpanic=abort" diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index 8ff1bf271ef49..b7524993ad77d 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -13,11 +13,11 @@ use rustc_session::early_error; use rustc_target::spec::PanicStrategy; #[derive(Default)] -pub struct TimePassesCallbacks { +pub struct CraneliftPassesCallbacks { time_passes: bool, } -impl rustc_driver::Callbacks for TimePassesCallbacks { +impl rustc_driver::Callbacks for CraneliftPassesCallbacks { fn config(&mut self, config: &mut interface::Config) { // If a --prints=... option has been given, we don't print the "total" // time because it will mess up the --prints output. See #64339. @@ -47,7 +47,7 @@ impl rustc_driver::Callbacks for TimePassesCallbacks { fn main() { let start = std::time::Instant::now(); rustc_driver::init_rustc_env_logger(); - let mut callbacks = TimePassesCallbacks::default(); + let mut callbacks = CraneliftPassesCallbacks::default(); rustc_driver::install_ice_hook(); let exit_code = rustc_driver::catch_with_exit_code(|| { let mut use_jit = false; diff --git a/src/bin/cg_clif_build_sysroot.rs b/src/bin/cg_clif_build_sysroot.rs new file mode 100644 index 0000000000000..fe8bcf8b79150 --- /dev/null +++ b/src/bin/cg_clif_build_sysroot.rs @@ -0,0 +1,112 @@ +//! The only difference between this and cg_clif.rs is that this binary defaults to using cg_llvm +//! instead of cg_clif and requires `--clif` to use cg_clif and that this binary doesn't have JIT +//! support. +//! This is necessary as with Cargo `RUSTC` applies to both target crates and host crates. The host +//! crates must be built with cg_llvm as we are currently building a sysroot for cg_clif. +//! `RUSTFLAGS` however is only applied to target crates, so `--clif` would only be passed to the +//! target crates. + +#![feature(rustc_private)] + +extern crate rustc_data_structures; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate rustc_session; +extern crate rustc_target; + +use std::path::PathBuf; + +use rustc_interface::interface; +use rustc_session::config::ErrorOutputType; +use rustc_session::early_error; +use rustc_target::spec::PanicStrategy; + +fn find_sysroot() -> String { + // Taken from https://github.com/Manishearth/rust-clippy/pull/911. + let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); + let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); + match (home, toolchain) { + (Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain), + _ => option_env!("RUST_SYSROOT") + .expect("need to specify RUST_SYSROOT env var or use rustup or multirust") + .to_owned(), + } +} + +pub struct CraneliftPassesCallbacks { + use_clif: bool, +} + +impl rustc_driver::Callbacks for CraneliftPassesCallbacks { + fn config(&mut self, config: &mut interface::Config) { + if !self.use_clif { + config.opts.maybe_sysroot = Some(PathBuf::from(find_sysroot())); + return; + } + + // FIXME workaround for an ICE + config.opts.debugging_opts.trim_diagnostic_paths = false; + + config.opts.cg.panic = Some(PanicStrategy::Abort); + config.opts.debugging_opts.panic_abort_tests = true; + config.opts.maybe_sysroot = Some( + std::env::current_exe() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap() + .parent() + .unwrap() + .join("build_sysroot") + .join("sysroot"), + ); + } +} + +fn main() { + rustc_driver::init_rustc_env_logger(); + rustc_driver::install_ice_hook(); + let exit_code = rustc_driver::catch_with_exit_code(|| { + let mut use_clif = false; + + let args = std::env::args_os() + .enumerate() + .map(|(i, arg)| { + arg.into_string().unwrap_or_else(|arg| { + early_error( + ErrorOutputType::default(), + &format!("Argument {} is not valid Unicode: {:?}", i, arg), + ) + }) + }) + .filter(|arg| { + if arg == "--clif" { + use_clif = true; + false + } else { + true + } + }) + .collect::>(); + + let mut callbacks = CraneliftPassesCallbacks { use_clif }; + + rustc_driver::run_compiler( + &args, + &mut callbacks, + None, + None, + if use_clif { + Some(Box::new(move |_| { + Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { + config: rustc_codegen_cranelift::BackendConfig { use_jit: false }, + }) + })) + } else { + None + }, + ) + }); + std::process::exit(exit_code) +} From 783c6771b3fbb98c15965abf7aea8a163a40fc23 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Oct 2020 10:58:26 +0200 Subject: [PATCH 1544/1566] Rustup to rustc 1.49.0-nightly (b1af43bc6 2020-10-10) --- build_sysroot/Cargo.lock | 16 ++++++++-------- rust-toolchain | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 48826ecaebf0d..d256e2526423c 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -47,9 +47,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "cc" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" +checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" [[package]] name = "cfg-if" @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" dependencies = [ "compiler_builtins", "libc", @@ -141,9 +141,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" dependencies = [ "rustc-std-workspace-core", ] @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" +checksum = "b2610b7f643d18c87dff3b489950269617e6601a51f1f05aa5daefee36f64f0b" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", diff --git a/rust-toolchain b/rust-toolchain index c318446013829..0ffc727a75129 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-05 +nightly-2020-10-11 From 9683c42cdec11f4b874d9bd86dec65eebf0c71ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Oct 2020 11:14:08 +0200 Subject: [PATCH 1545/1566] Update Cranelift --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e15ceaf95ebcd..f9d7f86d9accb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cranelift-bforest" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "cranelift-entity", ] @@ -52,7 +52,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "byteorder", "cranelift-bforest", @@ -70,7 +70,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "cranelift-codegen-shared", "cranelift-entity", @@ -79,17 +79,17 @@ dependencies = [ [[package]] name = "cranelift-codegen-shared" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" [[package]] name = "cranelift-entity" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" [[package]] name = "cranelift-frontend" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "cranelift-codegen", "log", @@ -100,7 +100,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "anyhow", "cranelift-codegen", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "cranelift-codegen", "raw-cpuid", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "cranelift-object" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "anyhow", "cranelift-codegen", @@ -135,7 +135,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.67.0" -source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#88d975d396defb47da85665054a98a16708ef6df" +source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#4fd90dccabb266e983740e1f5daf8bde9266b286" dependencies = [ "cranelift-codegen", "cranelift-entity", From 96d76eb8e478c4a9f82fa6bfc358294cd6942910 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Oct 2020 11:20:15 +0200 Subject: [PATCH 1546/1566] Update dependencies --- Cargo.lock | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9d7f86d9accb..6cfbed0a5e430 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "anyhow" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" +checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c" [[package]] name = "ar" @@ -13,9 +13,9 @@ source = "git+https://github.com/bjorn3/rust-ar.git?branch=do_not_remove_cg_clif [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bitflags" @@ -31,9 +31,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "cc" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" +checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" [[package]] name = "cfg-if" @@ -196,18 +196,15 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.8.1" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" -dependencies = [ - "autocfg", -] +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "indexmap" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ "autocfg", "hashbrown", @@ -215,16 +212,17 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.74" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" [[package]] name = "libloading" -version = "0.6.2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cadb8e769f070c45df05c78c7520eb4cd17061d4ab262e43cfc68b4d00ac71c" +checksum = "3557c9384f7f757f6d139cd3a4c62ef4e850696c16bf27924a5538c8a09717a1" dependencies = [ + "cfg-if", "winapi", ] @@ -258,9 +256,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.19" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] @@ -357,15 +355,15 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "smallvec" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f" +checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" [[package]] name = "syn" -version = "1.0.38" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" +checksum = "e03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fdd" dependencies = [ "proc-macro2", "quote", @@ -380,18 +378,18 @@ checksum = "fe2635952a442a01fd4cb53d98858b5e4bb461b02c0d111f22f31772e3e7a8b2" [[package]] name = "thiserror" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab" dependencies = [ "proc-macro2", "quote", From 6e8ea1c0490e125318c61bdc5918c1ee6137d146 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Oct 2020 11:31:36 +0200 Subject: [PATCH 1547/1566] Abort earlier when an error happens in jit mode --- src/driver/jit.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 6f398d045b646..b5bab3d9e1ed1 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -6,10 +6,14 @@ use std::os::raw::{c_char, c_int}; use rustc_codegen_ssa::CrateInfo; +use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule}; + use crate::prelude::*; pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { - use cranelift_simplejit::{SimpleJITBuilder, SimpleJITModule}; + if !tcx.sess.opts.output_types.should_codegen() { + tcx.sess.fatal("JIT mode doesn't work with `cargo check`."); + } #[cfg(unix)] unsafe { @@ -53,10 +57,6 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { .declare_function("main", Linkage::Import, &sig) .unwrap(); - if !tcx.sess.opts.output_types.should_codegen() { - tcx.sess.fatal("JIT mode doesn't work with `cargo check`."); - } - let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); let mono_items = cgus .iter() @@ -79,12 +79,12 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! { crate::main_shim::maybe_create_entry_wrapper(tcx, &mut jit_module, &mut unwind_context, true); crate::allocator::codegen(tcx, &mut jit_module, &mut unwind_context); + tcx.sess.abort_if_errors(); + let jit_product = jit_module.finish(); let _unwind_register_guard = unsafe { unwind_context.register_jit(&jit_product) }; - tcx.sess.abort_if_errors(); - let finalized_main: *const u8 = jit_product.lookup_func(main_func_id); println!("Rustc codegen cranelift will JIT run the executable, because --jit was passed"); From 8ebfc9142f4798f6183e8dfa637309d276dab874 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Oct 2020 13:19:04 +0200 Subject: [PATCH 1548/1566] Fix rust-analyzer.linkedProjects paths --- .vscode/settings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 288612be470b2..04ab5085c196c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,16 +33,16 @@ ] }, { - "roots": ["./scripts/analyze_profile.rs"], + "roots": ["./scripts/filter_profile.rs"], "crates": [ { - "root_module": "./scripts/analyze_profile.rs", + "root_module": "./scripts/filter_profile.rs", "edition": "2018", "deps": [{ "crate": 1, "name": "std" }], "cfg": [], }, { - "root_module": "./build_sysroot/sysroot_src/src/libstd/lib.rs", + "root_module": "./build_sysroot/sysroot_src/library/std/src/lib.rs", "edition": "2018", "deps": [], "cfg": [], From e0002c1892ae1efd420332e6786b96ad86969c98 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 11 Oct 2020 13:24:14 +0200 Subject: [PATCH 1549/1566] Remove MIR dump on panic I haven't used it for a long time and it adds a lot of noise to the panic print. --- src/driver/mod.rs | 21 --------------------- src/lib.rs | 1 - 2 files changed, 22 deletions(-) diff --git a/src/driver/mod.rs b/src/driver/mod.rs index c32c479251970..2fb353ca1628a 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -79,27 +79,6 @@ fn trans_mono_item<'tcx, M: Module>( let _inst_guard = crate::PrintOnPanic(|| format!("{:?} {}", inst, tcx.symbol_name(inst).name)); debug_assert!(!inst.substs.needs_infer()); - let _mir_guard = crate::PrintOnPanic(|| { - match inst.def { - InstanceDef::Item(_) - | InstanceDef::DropGlue(_, _) - | InstanceDef::Virtual(_, _) => { - let mut mir = ::std::io::Cursor::new(Vec::new()); - crate::rustc_mir::util::write_mir_pretty( - tcx, - Some(inst.def_id()), - &mut mir, - ) - .unwrap(); - String::from_utf8(mir.into_inner()).unwrap() - } - _ => { - // FIXME fix write_mir_pretty for these instances - format!("{:#?}", tcx.instance_mir(inst.def)) - } - } - }); - tcx.sess .time("codegen fn", || crate::base::trans_fn(cx, inst, linkage)); } diff --git a/src/lib.rs b/src/lib.rs index c10eeb7bf8849..2fa4f9e0eadaf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,6 @@ extern crate rustc_fs_util; extern crate rustc_hir; extern crate rustc_incremental; extern crate rustc_index; -extern crate rustc_mir; extern crate rustc_session; extern crate rustc_span; extern crate rustc_symbol_mangling; From cd2fc77b0ee166be15c71963b036dfc7a65df63d Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 12 Oct 2020 12:02:38 +0200 Subject: [PATCH 1550/1566] Make _rust_extern_with_linkage_* readonly --- src/constant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constant.rs b/src/constant.rs index d6d38a4b3ad00..94ecc3096b389 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -337,7 +337,7 @@ fn data_id_for_static( let ref_name = format!("_rust_extern_with_linkage_{}", symbol_name); let ref_data_id = module - .declare_data(&ref_name, Linkage::Local, true, false) + .declare_data(&ref_name, Linkage::Local, false, false) .unwrap(); let mut data_ctx = DataContext::new(); data_ctx.set_align(align); From 2f2d3b2fd4d38f1ea0c63eb8e880085a2ccf0987 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 12 Oct 2020 12:03:18 +0200 Subject: [PATCH 1551/1566] Avoid iadd for ptr const val with zero offset --- src/constant.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/constant.rs b/src/constant.rs index 94ecc3096b389..1b514958a4809 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -225,10 +225,13 @@ pub(crate) fn trans_const_value<'tcx>( } None => bug!("missing allocation {:?}", ptr.alloc_id), }; - let val = fx - .bcx - .ins() - .iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap()); + let val = if ptr.offset.bytes() != 0 { + fx.bcx + .ins() + .iadd_imm(base_addr, i64::try_from(ptr.offset.bytes()).unwrap()) + } else { + base_addr + }; return CValue::by_val(val, layout); } } From 6258b86c40b615fbba45d4e29412b6458500f5ca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 12 Oct 2020 14:23:36 +0200 Subject: [PATCH 1552/1566] Rustup to rustc 1.49.0-nightly (c71248b70 2020-10-11) --- rust-toolchain | 2 +- src/bin/cg_clif.rs | 18 +++++++----------- src/bin/cg_clif_build_sysroot.rs | 24 +++++++++--------------- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index 0ffc727a75129..d9e199b78ff3d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-11 +nightly-2020-10-12 diff --git a/src/bin/cg_clif.rs b/src/bin/cg_clif.rs index b7524993ad77d..590c9ef0ce191 100644 --- a/src/bin/cg_clif.rs +++ b/src/bin/cg_clif.rs @@ -74,17 +74,13 @@ fn main() { if use_jit { args.push("-Cprefer-dynamic".to_string()); } - rustc_driver::run_compiler( - &args, - &mut callbacks, - None, - None, - Some(Box::new(move |_| { - Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { - config: rustc_codegen_cranelift::BackendConfig { use_jit }, - }) - })), - ) + let mut run_compiler = rustc_driver::RunCompiler::new(&args, &mut callbacks); + run_compiler.set_make_codegen_backend(Some(Box::new(move |_| { + Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { + config: rustc_codegen_cranelift::BackendConfig { use_jit }, + }) + }))); + run_compiler.run() }); // The extra `\t` is necessary to align this label with the others. print_time_passes_entry(callbacks.time_passes, "\ttotal", start.elapsed()); diff --git a/src/bin/cg_clif_build_sysroot.rs b/src/bin/cg_clif_build_sysroot.rs index fe8bcf8b79150..c207d98d6c197 100644 --- a/src/bin/cg_clif_build_sysroot.rs +++ b/src/bin/cg_clif_build_sysroot.rs @@ -92,21 +92,15 @@ fn main() { let mut callbacks = CraneliftPassesCallbacks { use_clif }; - rustc_driver::run_compiler( - &args, - &mut callbacks, - None, - None, - if use_clif { - Some(Box::new(move |_| { - Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { - config: rustc_codegen_cranelift::BackendConfig { use_jit: false }, - }) - })) - } else { - None - }, - ) + let mut run_compiler = rustc_driver::RunCompiler::new(&args, &mut callbacks); + if use_clif { + run_compiler.set_make_codegen_backend(Some(Box::new(move |_| { + Box::new(rustc_codegen_cranelift::CraneliftCodegenBackend { + config: rustc_codegen_cranelift::BackendConfig { use_jit: false }, + }) + }))); + } + run_compiler.run() }); std::process::exit(exit_code) } From a233646dfcaf74bd99b97e950df724b03b878ed1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 10:34:13 +0200 Subject: [PATCH 1553/1566] Rustup to rustc 1.49.0-nightly (e160e5cb8 2020-10-14) --- ...022-core-Disable-not-compiling-tests.patch | 2 +- rust-toolchain | 2 +- src/base.rs | 24 +++++----- src/driver/aot.rs | 1 - src/lib.rs | 45 +++---------------- 5 files changed, 21 insertions(+), 53 deletions(-) diff --git a/patches/0022-core-Disable-not-compiling-tests.patch b/patches/0022-core-Disable-not-compiling-tests.patch index 009b2fed0f93a..ee8548783de65 100644 --- a/patches/0022-core-Disable-not-compiling-tests.patch +++ b/patches/0022-core-Disable-not-compiling-tests.patch @@ -112,7 +112,7 @@ index 6609bc3..241b497 100644 #[cfg(not(target_arch = "wasm32"))] fn sort_unstable() { @@ -1394,6 +1395,7 @@ fn partition_at_index() { - v.partition_at_index(0); + v.select_nth_unstable(0); assert!(v == [0xDEADBEEF]); } +*/ diff --git a/rust-toolchain b/rust-toolchain index d9e199b78ff3d..ab4c3c84c9659 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-12 +nightly-2020-10-15 diff --git a/src/base.rs b/src/base.rs index 9f558bc7520c2..fa9b8853d39e9 100644 --- a/src/base.rs +++ b/src/base.rs @@ -299,19 +299,19 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { TerminatorKind::SwitchInt { discr, switch_ty, - values, targets, } => { let discr = trans_operand(fx, discr).load_scalar(fx); if switch_ty.kind() == fx.tcx.types.bool.kind() { - assert_eq!(targets.len(), 2); - let then_block = fx.get_block(targets[0]); - let else_block = fx.get_block(targets[1]); - let test_zero = match **values { - [0] => true, - [1] => false, - _ => unreachable!("{:?}", values), + assert_eq!(targets.iter().count(), 1); + let (then_value, then_block) = targets.iter().next().unwrap(); + let then_block = fx.get_block(then_block); + let else_block = fx.get_block(targets.otherwise()); + let test_zero = match then_value { + 0 => true, + 1 => false, + _ => unreachable!("{:?}", targets), }; let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr); @@ -330,11 +330,11 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Module>) { } } else { let mut switch = ::cranelift_frontend::Switch::new(); - for (i, value) in values.iter().enumerate() { - let block = fx.get_block(targets[i]); - switch.set_entry(*value, block); + for (value, block) in targets.iter() { + let block = fx.get_block(block); + switch.set_entry(value, block); } - let otherwise_block = fx.get_block(targets[targets.len() - 1]); + let otherwise_block = fx.get_block(targets.otherwise()); switch.emit(&mut fx.bcx, discr, otherwise_block); } } diff --git a/src/driver/aot.rs b/src/driver/aot.rs index 2b3d1b7885d18..e7595abe1786e 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -302,7 +302,6 @@ pub(super) fn run_aot( modules, allocator_module, metadata_module, - crate_hash: tcx.crate_hash(LOCAL_CRATE), metadata, windows_subsystem: None, // Windows is not yet supported linker_info: LinkerInfo::new(tcx), diff --git a/src/lib.rs b/src/lib.rs index 2fa4f9e0eadaf..af359456e699b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,7 +37,7 @@ use std::any::Any; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_codegen_ssa::CodegenResults; use rustc_errors::ErrorReported; -use rustc_middle::dep_graph::{DepGraph, WorkProduct, WorkProductId}; +use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc_middle::ty::query::Providers; use rustc_session::config::OutputFilenames; @@ -190,23 +190,7 @@ impl CodegenBackend for CraneliftCodegenBackend { Box::new(crate::metadata::CraneliftMetadataLoader) } - fn provide(&self, providers: &mut Providers) { - providers.supported_target_features = |tcx, cnum| { - assert_eq!(cnum, LOCAL_CRATE); - if tcx.sess.opts.actually_rustdoc { - // rustdoc needs to be able to document functions that use all the features, so - // whitelist them all - rustc_codegen_ssa::target_features::all_known_features() - .map(|(a, b)| (a.to_string(), b)) - .collect() - } else { - rustc_codegen_ssa::target_features::supported_target_features(tcx.sess) - .iter() - .map(|&(a, b)| (a.to_string(), b)) - .collect() - } - }; - } + fn provide(&self, _providers: &mut Providers) {} fn provide_extern(&self, _providers: &mut Providers) {} fn target_features(&self, _sess: &Session) -> Vec { @@ -229,34 +213,21 @@ impl CodegenBackend for CraneliftCodegenBackend { fn join_codegen( &self, ongoing_codegen: Box, - sess: &Session, - dep_graph: &DepGraph, - ) -> Result, ErrorReported> { - let (codegen_results, work_products) = *ongoing_codegen + _sess: &Session, + ) -> Result<(CodegenResults, FxHashMap), ErrorReported> { + Ok(*ongoing_codegen .downcast::<(CodegenResults, FxHashMap)>() - .unwrap(); - - sess.time("serialize_work_products", move || { - rustc_incremental::save_work_product_index(sess, &dep_graph, work_products) - }); - - Ok(Box::new(codegen_results)) + .unwrap()) } fn link( &self, sess: &Session, - res: Box, + codegen_results: CodegenResults, outputs: &OutputFilenames, ) -> Result<(), ErrorReported> { use rustc_codegen_ssa::back::link::link_binary; - sess.abort_if_errors(); - - let codegen_results = *res - .downcast::() - .expect("Expected CraneliftCodegenBackend's CodegenResult, found Box"); - let _timer = sess.prof.generic_activity("link_crate"); sess.time("linking", || { @@ -270,8 +241,6 @@ impl CodegenBackend for CraneliftCodegenBackend { ); }); - rustc_incremental::finalize_session_directory(sess, codegen_results.crate_hash); - Ok(()) } } From fed612c75af364ae72eee3a8a087dcc33218df00 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 10:57:56 +0200 Subject: [PATCH 1554/1566] Output clif ir to output dir instead of hardcoded path This is necessary for reproducable builds. --- src/pretty_clif.rs | 23 +++++++++++++++-------- test.sh | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index e99bec45a5efe..a37a832a23123 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -226,14 +226,21 @@ pub(crate) fn write_clif_file<'tcx>( .expect("value location ranges") }); - let symbol_name = tcx.symbol_name(instance).name; - let clif_file_name = format!( - "{}/{}__{}.{}.clif", - concat!(env!("CARGO_MANIFEST_DIR"), "/target/out/clif"), - tcx.crate_name(LOCAL_CRATE), - symbol_name, - postfix, - ); + let clif_output_dir = tcx + .output_filenames(LOCAL_CRATE) + .with_extension("clif"); + + match std::fs::create_dir(&clif_output_dir) { + Ok(()) => {} + Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => {} + res @ Err(_) => res.unwrap(), + } + + let clif_file_name = clif_output_dir.join(format!( + "{}.{}.clif", + tcx.symbol_name(instance).name, + postfix + )); let mut clif = String::new(); cranelift_codegen::write::decorate_function( diff --git a/test.sh b/test.sh index 0d2b5c6a392b2..a1c4d9f287283 100755 --- a/test.sh +++ b/test.sh @@ -18,7 +18,6 @@ RUSTC=$RUSTC" "$RUSTFLAGS" -L crate=target/out --out-dir target/out -Cdebuginfo= # Cleanup rm -r target/out || true -mkdir -p target/out/clif # Perform all tests echo "[BUILD] mini_core" From 1c408407385b791c9c643e018ade22535e1203cb Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 15:39:06 +0200 Subject: [PATCH 1555/1566] Fix warning --- src/optimize/mod.rs | 2 +- src/optimize/stack2reg.rs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 3ce7f8cd9a831..1386e47ebfc04 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -19,7 +19,7 @@ pub(crate) fn optimize_function<'tcx>( if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No { return; // FIXME classify optimizations over opt levels } - self::stack2reg::optimize_function(ctx, clif_comments); + self::stack2reg::optimize_function(ctx); crate::pretty_clif::write_clif_file(tcx, "stack2reg", None, instance, &ctx, &*clif_comments); crate::base::verify_func(tcx, &*clif_comments, &ctx.func); } diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 8df33fd2fc72f..37056e94d3a31 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -182,10 +182,7 @@ impl<'a> OptimizeContext<'a> { } } -pub(super) fn optimize_function( - ctx: &mut Context, - clif_comments: &mut crate::pretty_clif::CommentWriter, -) { +pub(super) fn optimize_function(ctx: &mut Context) { combine_stack_addr_with_load_store(&mut ctx.func); let mut opt_ctx = OptimizeContext::for_context(ctx); From 7045b101cc9a69b012758bf72ecd4f2622f4cdbe Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 16:15:04 +0200 Subject: [PATCH 1556/1566] Use MetadataRef in the metadata loader to fix parallel rustc --- src/metadata.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/metadata.rs b/src/metadata.rs index 93cff5711d937..7ba6ec6d75084 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -5,8 +5,9 @@ use std::fs::File; use std::path::Path; use rustc_codegen_ssa::METADATA_FILENAME; -use rustc_data_structures::owning_ref::{self, OwningRef}; +use rustc_data_structures::owning_ref::OwningRef; use rustc_data_structures::rustc_erase_owner; +use rustc_data_structures::sync::MetadataRef; use rustc_middle::middle::cstore::{EncodedMetadata, MetadataLoader}; use rustc_middle::ty::TyCtxt; use rustc_session::config; @@ -17,11 +18,7 @@ use crate::backend::WriteMetadata; pub(crate) struct CraneliftMetadataLoader; impl MetadataLoader for CraneliftMetadataLoader { - fn get_rlib_metadata( - &self, - _target: &Target, - path: &Path, - ) -> Result, String> { + fn get_rlib_metadata(&self, _target: &Target, path: &Path) -> Result { let mut archive = ar::Archive::new(File::open(path).map_err(|e| format!("{:?}", e))?); // Iterate over all entries in the archive: while let Some(entry_result) = archive.next_entry() { @@ -38,14 +35,9 @@ impl MetadataLoader for CraneliftMetadataLoader { } Err("couldn't find metadata entry".to_string()) - //self.get_dylib_metadata(target, path) } - fn get_dylib_metadata( - &self, - _target: &Target, - path: &Path, - ) -> Result, String> { + fn get_dylib_metadata(&self, _target: &Target, path: &Path) -> Result { use object::{Object, ObjectSection}; let file = std::fs::read(path).map_err(|e| format!("read:{:?}", e))?; let file = object::File::parse(&file).map_err(|e| format!("parse: {:?}", e))?; From 1c272b1224fabfa307942fc76eb14b7b7bddd040 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 18:44:22 +0200 Subject: [PATCH 1557/1566] Fix a compilation error in debug mode --- src/optimize/mod.rs | 2 +- src/optimize/stack2reg.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 1386e47ebfc04..3ce7f8cd9a831 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -19,7 +19,7 @@ pub(crate) fn optimize_function<'tcx>( if tcx.sess.opts.optimize == rustc_session::config::OptLevel::No { return; // FIXME classify optimizations over opt levels } - self::stack2reg::optimize_function(ctx); + self::stack2reg::optimize_function(ctx, clif_comments); crate::pretty_clif::write_clif_file(tcx, "stack2reg", None, instance, &ctx, &*clif_comments); crate::base::verify_func(tcx, &*clif_comments, &ctx.func); } diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 37056e94d3a31..f368d65f7f8d8 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -182,7 +182,10 @@ impl<'a> OptimizeContext<'a> { } } -pub(super) fn optimize_function(ctx: &mut Context) { +pub(super) fn optimize_function( + ctx: &mut Context, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] clif_comments: &mut crate::pretty_clif::CommentWriter, +) { combine_stack_addr_with_load_store(&mut ctx.func); let mut opt_ctx = OptimizeContext::for_context(ctx); From 1c7c591cb8a656b08edd4dacf86323d0db5b8684 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 18:51:49 +0200 Subject: [PATCH 1558/1566] Fix compilation for non-unix systems --- src/atomic_shim.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atomic_shim.rs b/src/atomic_shim.rs index 11b5946b6aa40..92281fdacc941 100644 --- a/src/atomic_shim.rs +++ b/src/atomic_shim.rs @@ -5,7 +5,7 @@ use crate::prelude::*; -#[cfg(feature = "jit")] +#[cfg(all(feature = "jit", unix))] #[no_mangle] pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t = libc::PTHREAD_MUTEX_INITIALIZER; From 49710287756b85edb5a0d82a210ab26973aec746 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Oct 2020 09:35:48 +0200 Subject: [PATCH 1559/1566] Rustup to rustc 1.49.0-nightly (dd7fc54eb 2020-10-15) --- rust-toolchain | 2 +- src/archive.rs | 4 ++-- src/common.rs | 2 +- src/debuginfo/mod.rs | 2 +- src/driver/aot.rs | 4 ++-- src/lib.rs | 2 +- src/metadata.rs | 2 +- src/pretty_clif.rs | 4 +--- src/toolchain.rs | 8 ++++---- 9 files changed, 14 insertions(+), 16 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index ab4c3c84c9659..d9ac9c12a101d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-15 +nightly-2020-10-16 diff --git a/src/archive.rs b/src/archive.rs index fe2c2f100eec8..6382f8df3446b 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -63,9 +63,9 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { sess, dst: output.to_path_buf(), lib_search_paths: archive_search_paths(sess), - use_gnu_style_archive: sess.target.target.options.archive_format == "gnu", + use_gnu_style_archive: sess.target.options.archive_format == "gnu", // FIXME fix builtin ranlib on macOS - no_builtin_ranlib: sess.target.target.options.is_like_osx, + no_builtin_ranlib: sess.target.options.is_like_osx, src_archives, entries, diff --git a/src/common.rs b/src/common.rs index 0f22f900ca7ae..13c62add41a3b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -352,7 +352,7 @@ impl<'tcx, M: Module> layout::HasParamEnv<'tcx> for FunctionCx<'_, 'tcx, M> { impl<'tcx, M: Module> HasTargetSpec for FunctionCx<'_, 'tcx, M> { fn target_spec(&self) -> &Target { - &self.tcx.sess.target.target + &self.tcx.sess.target } } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index f33aa6683a726..cbf9522b1d774 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -50,7 +50,7 @@ impl<'tcx> DebugContext<'tcx> { // TODO: this should be configurable // macOS doesn't seem to support DWARF > 3 // 5 version is required for md5 file hash - version: if tcx.sess.target.target.options.is_like_osx { + version: if tcx.sess.target.options.is_like_osx { 3 } else { // FIXME change to version 5 once the gdb and lldb shipping with the latest debian diff --git a/src/driver/aot.rs b/src/driver/aot.rs index e7595abe1786e..ff0b994c9a9f4 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -320,8 +320,8 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { } if cfg!(not(feature = "inline_asm")) - || tcx.sess.target.target.options.is_like_osx - || tcx.sess.target.target.options.is_like_windows + || tcx.sess.target.options.is_like_osx + || tcx.sess.target.options.is_like_windows { if global_asm.contains("__rust_probestack") { return; diff --git a/src/lib.rs b/src/lib.rs index af359456e699b..fd00a2e00a6a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -246,7 +246,7 @@ impl CodegenBackend for CraneliftCodegenBackend { } fn target_triple(sess: &Session) -> target_lexicon::Triple { - sess.target.target.llvm_target.parse().unwrap() + sess.target.llvm_target.parse().unwrap() } fn build_isa(sess: &Session, enable_pic: bool) -> Box { diff --git a/src/metadata.rs b/src/metadata.rs index 7ba6ec6d75084..04369bf89fd2d 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -101,7 +101,7 @@ pub(crate) fn write_metadata( product.add_rustc_section( rustc_middle::middle::exported_symbols::metadata_symbol_name(tcx), compressed, - tcx.sess.target.target.options.is_like_osx, + tcx.sess.target.options.is_like_osx, ); metadata diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index a37a832a23123..26407e25bc6e8 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -226,9 +226,7 @@ pub(crate) fn write_clif_file<'tcx>( .expect("value location ranges") }); - let clif_output_dir = tcx - .output_filenames(LOCAL_CRATE) - .with_extension("clif"); + let clif_output_dir = tcx.output_filenames(LOCAL_CRATE).with_extension("clif"); match std::fs::create_dir(&clif_output_dir) { Ok(()) => {} diff --git a/src/toolchain.rs b/src/toolchain.rs index d1329d5de7e0c..463afaf7cc50c 100644 --- a/src/toolchain.rs +++ b/src/toolchain.rs @@ -91,10 +91,10 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { } else if stem == "link" || stem == "lld-link" { LinkerFlavor::Msvc } else if stem == "lld" || stem == "rust-lld" { - LinkerFlavor::Lld(sess.target.target.options.lld_flavor) + LinkerFlavor::Lld(sess.target.options.lld_flavor) } else { // fall back to the value in the target spec - sess.target.target.linker_flavor + sess.target.linker_flavor }; Some((linker, flavor)) @@ -115,8 +115,8 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { if let Some(ret) = infer_from( sess, - sess.target.target.options.linker.clone().map(PathBuf::from), - Some(sess.target.target.linker_flavor), + sess.target.options.linker.clone().map(PathBuf::from), + Some(sess.target.linker_flavor), ) { return ret; } From 0416f122aae296e7fa78cff64b5df683be1dfc2f Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Fri, 16 Oct 2020 14:03:29 +0200 Subject: [PATCH 1560/1566] Error on non-constant simd_insert/simd_extract index --- src/intrinsics/simd.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index e9d3cc8d25692..b4269f4fafa0b 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -121,12 +121,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.tcx.sess.span_warn( - fx.mir.span, - "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", + fx.tcx.sess.span_fatal( + span, + "Index argument for `simd_insert` is not a constant", ); - crate::trap::trap_unimplemented(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); - return; }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); @@ -145,13 +143,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) { idx_const } else { - fx.tcx.sess.span_warn( - fx.mir.span, - "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", + fx.tcx.sess.span_fatal( + span, + "Index argument for `simd_extract` is not a constant", ); - let val = crate::trap::trap_unimplemented_ret_value(fx, ret.layout(), "`#[rustc_arg_required_const(..)]` is not yet supported."); - ret.write_cvalue(fx, val); - return; }; let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const)); From 04091772bc561ec7bae2e02f7d70de6f32fcf6c4 Mon Sep 17 00:00:00 2001 From: Kitsu Date: Fri, 16 Oct 2020 17:19:22 +0300 Subject: [PATCH 1561/1566] Use architecture pointer size for AddConstructor (#1094) * Use architecture pointer size for AddConstructor * Update src/backend.rs Co-authored-by: bjorn3 --- src/backend.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backend.rs b/src/backend.rs index c0df85f681c92..8b900fd0dd0c8 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -132,10 +132,16 @@ impl AddConstructor for ObjectProduct { let init_array_section = self.object .add_section(segment.to_vec(), b".init_array".to_vec(), SectionKind::Data); + let address_size = self + .object + .architecture() + .address_size() + .expect("address_size must be known") + .bytes(); self.object.append_section_data( init_array_section, &std::iter::repeat(0) - .take(8 /*FIXME pointer size*/) + .take(address_size.into()) .collect::>(), 8, ); @@ -144,7 +150,7 @@ impl AddConstructor for ObjectProduct { init_array_section, object::write::Relocation { offset: 0, - size: 64, // FIXME pointer size + size: address_size * 8, kind: RelocationKind::Absolute, encoding: RelocationEncoding::Generic, symbol, From 8dc71a419e2db70daa8cb8c5e553bfb4376c4f6b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 22 Oct 2020 12:44:03 +0200 Subject: [PATCH 1562/1566] Rustup to rustc 1.49.0-nightly (1eaadebb3 2020-10-21) --- build_sysroot/Cargo.lock | 4 ++-- rust-toolchain | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index d256e2526423c..0144fb243ec54 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2610b7f643d18c87dff3b489950269617e6601a51f1f05aa5daefee36f64f0b" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", diff --git a/rust-toolchain b/rust-toolchain index d9ac9c12a101d..78dd1ec107f37 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-16 +nightly-2020-10-22 From d2b8406c200430fded9a981d46e08e415daa850a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 22 Oct 2020 12:44:53 +0200 Subject: [PATCH 1563/1566] Remove unused trap_unimplemented_ret_value --- src/trap.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/trap.rs b/src/trap.rs index 67495c7414840..37dca77bdbd09 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -68,14 +68,3 @@ pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg: fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); } -/// Like `trap_unimplemented` but returns a fake value of the specified type. -/// -/// Trap code: user65535 -pub(crate) fn trap_unimplemented_ret_value<'tcx>( - fx: &mut FunctionCx<'_, 'tcx, impl Module>, - dest_layout: TyAndLayout<'tcx>, - msg: impl AsRef, -) -> CValue<'tcx> { - trap_unimplemented(fx, msg); - CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout) -} From 8ec977e763baee45dbc6b3efd84e96a7e5dc3f91 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 25 Oct 2020 13:33:39 +0100 Subject: [PATCH 1564/1566] Replace write with write_all --- src/pretty_clif.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index 26407e25bc6e8..7f8ab953d7199 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -262,7 +262,7 @@ pub(crate) fn write_clif_file<'tcx>( writeln!(file, "set enable_simd")?; writeln!(file, "target {} haswell", target_triple)?; writeln!(file, "")?; - file.write(clif.as_bytes())?; + file.write_all(clif.as_bytes())?; }; if let Err(err) = res { tcx.sess.warn(&format!("err writing clif file: {}", err)); From 793d26047f994e23415f8f6bb5686ff25d3dda92 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 26 Oct 2020 09:51:48 +0100 Subject: [PATCH 1565/1566] Rustup to rustc 1.49.0-nightly (4760b8fb8 2020-10-25) --- build_sysroot/Cargo.lock | 4 ++-- rust-toolchain | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_sysroot/Cargo.lock b/build_sysroot/Cargo.lock index 0144fb243ec54..03ba5b53d2e40 100644 --- a/build_sysroot/Cargo.lock +++ b/build_sysroot/Cargo.lock @@ -141,9 +141,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.79" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" +checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" dependencies = [ "rustc-std-workspace-core", ] diff --git a/rust-toolchain b/rust-toolchain index 78dd1ec107f37..87e54719fdc76 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-10-22 +nightly-2020-10-26 From cf798c1ec65a5ec3491846777f9003fabb881b4a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 15 Oct 2020 14:23:43 +0200 Subject: [PATCH 1566/1566] Add support for using cg_clif to bootstrap rustc --- Cargo.toml | 1 + compiler/rustc_driver/src/lib.rs | 35 ++---- compiler/rustc_interface/src/util.rs | 135 ++++++++++++++++++++-- config.toml.example | 2 +- rustfmt.toml | 1 + src/bootstrap/bootstrap.py | 8 +- src/bootstrap/builder.rs | 37 +++++- src/bootstrap/check.rs | 68 ++++++++++- src/bootstrap/compile.rs | 165 +++++++++++++++++++++++++++ src/bootstrap/dist.rs | 14 +++ src/bootstrap/lib.rs | 4 + src/tools/tidy/src/lib.rs | 1 + 12 files changed, 432 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 02794d1028b50..c27e5c469cf4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ members = [ ] exclude = [ "build", + "compiler/rustc_codegen_cranelift", # HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`. "obj", ] diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index c7fb6a55d5ae0..a0edf55eeb298 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -22,7 +22,7 @@ use rustc_errors::registry::{InvalidErrorCode, Registry}; use rustc_errors::{ErrorReported, PResult}; use rustc_feature::{find_gated_cfg, UnstableFeatures}; use rustc_hir::def_id::LOCAL_CRATE; -use rustc_interface::util::{collect_crate_types, get_builtin_codegen_backend}; +use rustc_interface::util::{self, collect_crate_types, get_builtin_codegen_backend}; use rustc_interface::{interface, Queries}; use rustc_lint::LintStore; use rustc_metadata::locator; @@ -793,37 +793,24 @@ impl RustcDefaultCalls { } } -/// Returns a version string such as "0.12.0-dev". -fn release_str() -> Option<&'static str> { - option_env!("CFG_RELEASE") -} - -/// Returns the full SHA1 hash of HEAD of the Git repo from which rustc was built. -fn commit_hash_str() -> Option<&'static str> { - option_env!("CFG_VER_HASH") -} - -/// Returns the "commit date" of HEAD of the Git repo from which rustc was built as a static string. -fn commit_date_str() -> Option<&'static str> { - option_env!("CFG_VER_DATE") -} - /// Prints version information pub fn version(binary: &str, matches: &getopts::Matches) { let verbose = matches.opt_present("verbose"); - println!("{} {}", binary, option_env!("CFG_VERSION").unwrap_or("unknown version")); + println!("{} {}", binary, util::version_str().unwrap_or("unknown version")); if verbose { fn unw(x: Option<&str>) -> &str { x.unwrap_or("unknown") } println!("binary: {}", binary); - println!("commit-hash: {}", unw(commit_hash_str())); - println!("commit-date: {}", unw(commit_date_str())); + println!("commit-hash: {}", unw(util::commit_hash_str())); + println!("commit-date: {}", unw(util::commit_date_str())); println!("host: {}", config::host_triple()); - println!("release: {}", unw(release_str())); - get_builtin_codegen_backend("llvm")().print_version(); + println!("release: {}", unw(util::release_str())); + if cfg!(llvm) { + get_builtin_codegen_backend("llvm")().print_version(); + } } } @@ -1109,7 +1096,9 @@ pub fn handle_options(args: &[String]) -> Option { } if cg_flags.iter().any(|x| *x == "passes=list") { - get_builtin_codegen_backend("llvm")().print_passes(); + if cfg!(llvm) { + get_builtin_codegen_backend("llvm")().print_passes(); + } return None; } @@ -1237,7 +1226,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { format!("we would appreciate a bug report: {}", bug_report_url).into(), format!( "rustc {} running on {}", - option_env!("CFG_VERSION").unwrap_or("unknown_version"), + util::version_str().unwrap_or("unknown_version"), config::host_triple() ) .into(), diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index c1b359c7d0de5..7658ffb0e3d9b 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -24,11 +24,13 @@ use rustc_span::source_map::FileLoader; use rustc_span::symbol::{sym, Symbol}; use smallvec::SmallVec; use std::env; +use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; use std::io::{self, Write}; use std::lazy::SyncOnceCell; use std::mem; use std::ops::DerefMut; use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex, Once}; #[cfg(not(parallel_compiler))] use std::{panic, thread}; @@ -238,7 +240,19 @@ pub fn get_codegen_backend(sopts: &config::Options) -> Box { static mut LOAD: fn() -> Box = || unreachable!(); INIT.call_once(|| { - let codegen_name = sopts.debugging_opts.codegen_backend.as_deref().unwrap_or("llvm"); + #[cfg(feature = "llvm")] + const DEFAULT_CODEGEN_BACKEND: &'static str = "llvm"; + + #[cfg(not(feature = "llvm"))] + const DEFAULT_CODEGEN_BACKEND: &'static str = "cranelift"; + + let codegen_name = sopts + .debugging_opts + .codegen_backend + .as_ref() + .map(|name| &name[..]) + .unwrap_or(DEFAULT_CODEGEN_BACKEND); + let backend = match codegen_name { filename if filename.contains('.') => load_backend_from_dylib(filename.as_ref()), codegen_name => get_builtin_codegen_backend(codegen_name), @@ -367,15 +381,102 @@ fn sysroot_candidates() -> Vec { } pub fn get_builtin_codegen_backend(backend_name: &str) -> fn() -> Box { - #[cfg(feature = "llvm")] - { - if backend_name == "llvm" { - return rustc_codegen_llvm::LlvmCodegenBackend::new; + match backend_name { + #[cfg(feature = "llvm")] + "llvm" => rustc_codegen_llvm::LlvmCodegenBackend::new, + _ => get_codegen_sysroot(backend_name), + } +} + +pub fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box { + // For now we only allow this function to be called once as it'll dlopen a + // few things, which seems to work best if we only do that once. In + // general this assertion never trips due to the once guard in `get_codegen_backend`, + // but there's a few manual calls to this function in this file we protect + // against. + static LOADED: AtomicBool = AtomicBool::new(false); + assert!( + !LOADED.fetch_or(true, Ordering::SeqCst), + "cannot load the default codegen backend twice" + ); + + let target = session::config::host_triple(); + let sysroot_candidates = sysroot_candidates(); + + let sysroot = sysroot_candidates + .iter() + .map(|sysroot| { + let libdir = filesearch::relative_target_lib_path(&sysroot, &target); + sysroot.join(libdir).with_file_name("codegen-backends") + }) + .filter(|f| { + info!("codegen backend candidate: {}", f.display()); + f.exists() + }) + .next(); + let sysroot = sysroot.unwrap_or_else(|| { + let candidates = sysroot_candidates + .iter() + .map(|p| p.display().to_string()) + .collect::>() + .join("\n* "); + let err = format!( + "failed to find a `codegen-backends` folder \ + in the sysroot candidates:\n* {}", + candidates + ); + early_error(ErrorOutputType::default(), &err); + }); + info!("probing {} for a codegen backend", sysroot.display()); + + let d = sysroot.read_dir().unwrap_or_else(|e| { + let err = format!( + "failed to load default codegen backend, couldn't \ + read `{}`: {}", + sysroot.display(), + e + ); + early_error(ErrorOutputType::default(), &err); + }); + + let mut file: Option = None; + + let expected_name = + format!("rustc_codegen_{}-{}", backend_name, release_str().expect("CFG_RELEASE")); + for entry in d.filter_map(|e| e.ok()) { + let path = entry.path(); + let filename = match path.file_name().and_then(|s| s.to_str()) { + Some(s) => s, + None => continue, + }; + if !(filename.starts_with(DLL_PREFIX) && filename.ends_with(DLL_SUFFIX)) { + continue; } + let name = &filename[DLL_PREFIX.len()..filename.len() - DLL_SUFFIX.len()]; + if name != expected_name { + continue; + } + if let Some(ref prev) = file { + let err = format!( + "duplicate codegen backends found\n\ + first: {}\n\ + second: {}\n\ + ", + prev.display(), + path.display() + ); + early_error(ErrorOutputType::default(), &err); + } + file = Some(path.clone()); } - let err = format!("unsupported builtin codegen backend `{}`", backend_name); - early_error(ErrorOutputType::default(), &err); + match file { + Some(ref s) => load_backend_from_dylib(s), + None => { + let err = format!("unsupported builtin codegen backend `{}`", backend_name); + early_error(ErrorOutputType::default(), &err); + } + } } pub(crate) fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator { @@ -782,3 +883,23 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> { noop_visit_mac(mac, self) } } + +/// Returns a version string such as "rustc 1.46.0 (04488afe3 2020-08-24)" +pub fn version_str() -> Option<&'static str> { + option_env!("CFG_VERSION") +} + +/// Returns a version string such as "0.12.0-dev". +pub fn release_str() -> Option<&'static str> { + option_env!("CFG_RELEASE") +} + +/// Returns the full SHA1 hash of HEAD of the Git repo from which rustc was built. +pub fn commit_hash_str() -> Option<&'static str> { + option_env!("CFG_VER_HASH") +} + +/// Returns the "commit date" of HEAD of the Git repo from which rustc was built as a static string. +pub fn commit_date_str() -> Option<&'static str> { + option_env!("CFG_VER_DATE") +} diff --git a/config.toml.example b/config.toml.example index e7e37c679e545..8027d7a118fb4 100644 --- a/config.toml.example +++ b/config.toml.example @@ -478,7 +478,7 @@ changelog-seen = 2 # This is an array of the codegen backends that will be compiled for the rustc # that's being compiled. The default is to only build the LLVM codegen backend, -# and currently the only standard option supported is `"llvm"` +# and currently the only standard options supported are `"llvm"` and `"cranelift"`. #codegen-backends = ["llvm"] # Indicates whether LLD will be compiled and made available in the sysroot for diff --git a/rustfmt.toml b/rustfmt.toml index 26cdcfff2a316..2b1c516cf7720 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -16,6 +16,7 @@ ignore = [ # do not format submodules "library/backtrace", "library/stdarch", + "compiler/rustc_codegen_cranelift", "src/doc/book", "src/doc/edition-guide", "src/doc/embedded-book", diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index ce37adeb28c93..0e246b652c295 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -962,8 +962,12 @@ def ensure_vendored(self): # the rust git repository is updated. Normal development usually does # not use vendoring, so hopefully this isn't too much of a problem. if self.use_vendored_sources and not os.path.exists(vendor_dir): - run([self.cargo(), "vendor", "--sync=./src/tools/rust-analyzer/Cargo.toml"], - verbose=self.verbose, cwd=self.rust_root) + run([ + self.cargo(), + "vendor", + "--sync=./src/tools/rust-analyzer/Cargo.toml", + "--sync=./compiler/rustc_codegen_cranelift/Cargo.toml", + ], verbose=self.verbose, cwd=self.rust_root) def bootstrap(help_triggered): diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 707c1ff3efad9..dc4243a76d5da 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -344,6 +344,7 @@ impl<'a> Builder<'a> { Kind::Build => describe!( compile::Std, compile::Rustc, + compile::CodegenBackend, compile::StartupObjects, tool::BuildManifest, tool::Rustbook, @@ -370,9 +371,14 @@ impl<'a> Builder<'a> { tool::CargoMiri, native::Lld ), - Kind::Check | Kind::Clippy | Kind::Fix | Kind::Format => { - describe!(check::Std, check::Rustc, check::Rustdoc, check::Clippy, check::Bootstrap) - } + Kind::Check | Kind::Clippy | Kind::Fix | Kind::Format => describe!( + check::Std, + check::Rustc, + check::Rustdoc, + check::CodegenBackend, + check::Clippy, + check::Bootstrap + ), Kind::Test => describe!( crate::toolstate::ToolStateCheck, test::ExpandYamlAnchors, @@ -630,6 +636,10 @@ impl<'a> Builder<'a> { self.ensure(Libdir { compiler, target }) } + pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf { + self.sysroot_libdir(compiler, compiler.host).with_file_name("codegen-backends") + } + /// Returns the compiler's libdir where it stores the dynamic libraries that /// it itself links against. /// @@ -698,6 +708,15 @@ impl<'a> Builder<'a> { } } + /// Gets the paths to all of the compiler's codegen backends. + fn codegen_backends(&self, compiler: Compiler) -> impl Iterator { + fs::read_dir(self.sysroot_codegen_backends(compiler)) + .into_iter() + .flatten() + .filter_map(Result::ok) + .map(|entry| entry.path()) + } + pub fn rustdoc(&self, compiler: Compiler) -> PathBuf { self.ensure(tool::Rustdoc { compiler }) } @@ -762,6 +781,12 @@ impl<'a> Builder<'a> { let mut cargo = Command::new(&self.initial_cargo); let out_dir = self.stage_out(compiler, mode); + // Codegen backends are not yet tracked by -Zbinary-dep-depinfo, + // so we need to explicitly clear out if they've been updated. + for backend in self.codegen_backends(compiler) { + self.clear_if_dirty(&out_dir, &backend); + } + if cmd == "doc" || cmd == "rustdoc" { let my_out = match mode { // This is the intended out directory for compiler documentation. @@ -843,7 +868,7 @@ impl<'a> Builder<'a> { match mode { Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {} - Mode::Rustc | Mode::ToolRustc => { + Mode::Rustc | Mode::Codegen | Mode::ToolRustc => { // Build proc macros both for the host and the target if target != compiler.host && cmd != "check" { cargo.arg("-Zdual-proc-macros"); @@ -904,6 +929,8 @@ impl<'a> Builder<'a> { // problem, somehow -- not really clear why -- but we know that this // fixes things. Mode::ToolRustc => metadata.push_str("tool-rustc"), + // Same for codegen backends. + Mode::Codegen => metadata.push_str("codegen"), _ => {} } cargo.env("__CARGO_DEFAULT_LIB_METADATA", &metadata); @@ -1030,7 +1057,7 @@ impl<'a> Builder<'a> { } let debuginfo_level = match mode { - Mode::Rustc => self.config.rust_debuginfo_level_rustc, + Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc, Mode::Std => self.config.rust_debuginfo_level_std, Mode::ToolBootstrap | Mode::ToolStd | Mode::ToolRustc => { self.config.rust_debuginfo_level_tools diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 371631154f72d..443a490e342d5 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -1,8 +1,10 @@ //! Implementation of compiling the compiler and standard library, in "check"-based modes. -use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, std_cargo}; +use crate::cache::Interned; +use crate::compile::{add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo}; use crate::config::TargetSelection; use crate::tool::{prepare_tool_cargo, SourceType}; +use crate::INTERNER; use crate::{ builder::{Builder, Kind, RunConfig, ShouldRun, Step}, Subcommand, @@ -175,6 +177,57 @@ impl Step for Rustc { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct CodegenBackend { + pub target: TargetSelection, + pub backend: Interned, +} + +impl Step for CodegenBackend { + type Output = (); + const ONLY_HOSTS: bool = true; + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.paths(&["compiler/rustc_codegen_cranelift", "rustc_codegen_cranelift"]) + } + + fn make_run(run: RunConfig<'_>) { + for &backend in &[INTERNER.intern_str("cranelift")] { + run.builder.ensure(CodegenBackend { target: run.target, backend }); + } + } + + fn run(self, builder: &Builder<'_>) { + let compiler = builder.compiler(0, builder.config.build); + let target = self.target; + let backend = self.backend; + + builder.ensure(Rustc { target }); + + let mut cargo = builder.cargo( + compiler, + Mode::Codegen, + SourceType::Submodule, + target, + cargo_subcommand(builder.kind), + ); + cargo + .arg("--manifest-path") + .arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend))); + rustc_cargo_env(builder, &mut cargo, target); + + run_cargo( + builder, + cargo, + args(builder.kind), + &codegen_backend_stamp(builder, compiler, target, backend), + vec![], + true, + ); + } +} + macro_rules! tool_check_step { ($name:ident, $path:expr, $source_type:expr) => { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -281,3 +334,16 @@ fn libstd_test_stamp( fn librustc_stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> PathBuf { builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp") } + +/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular +/// compiler for the specified target and backend. +fn codegen_backend_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: TargetSelection, + backend: Interned, +) -> PathBuf { + builder + .cargo_out(compiler, Mode::Codegen, target) + .join(format!(".librustc_codegen_{}-check.stamp", backend)) +} diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 5215ab3dd4f9b..ed9b91085863f 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -640,6 +640,144 @@ impl Step for RustcLink { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct CodegenBackend { + pub target: TargetSelection, + pub compiler: Compiler, + pub backend: Interned, +} + +impl Step for CodegenBackend { + type Output = (); + const ONLY_HOSTS: bool = true; + // Only the backends specified in the `codegen-backends` entry of `config.toml` are built. + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("compiler/rustc_codegen_cranelift") + } + + fn make_run(run: RunConfig<'_>) { + for &backend in &run.builder.config.rust_codegen_backends { + if backend == "llvm" { + continue; // Already built as part of rustc + } + + run.builder.ensure(CodegenBackend { + target: run.target, + compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()), + backend, + }); + } + } + + fn run(self, builder: &Builder<'_>) { + let compiler = self.compiler; + let target = self.target; + let backend = self.backend; + + builder.ensure(Rustc { compiler, target }); + + if builder.config.keep_stage.contains(&compiler.stage) { + builder.info( + "Warning: Using a potentially old codegen backend. \ + This may not behave well.", + ); + // Codegen backends are linked separately from this step today, so we don't do + // anything here. + return; + } + + let compiler_to_use = builder.compiler_for(compiler.stage, compiler.host, target); + if compiler_to_use != compiler { + builder.ensure(CodegenBackend { compiler: compiler_to_use, target, backend }); + return; + } + + let out_dir = builder.cargo_out(compiler, Mode::Codegen, target); + + let mut cargo = + builder.cargo(compiler, Mode::Codegen, SourceType::Submodule, target, "build"); + cargo + .arg("--manifest-path") + .arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend))); + rustc_cargo_env(builder, &mut cargo, target); + + let tmp_stamp = out_dir.join(".tmp.stamp"); + + let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false); + if builder.config.dry_run { + return; + } + let mut files = files.into_iter().filter(|f| { + let filename = f.file_name().unwrap().to_str().unwrap(); + is_dylib(filename) && filename.contains("rustc_codegen_") + }); + let codegen_backend = match files.next() { + Some(f) => f, + None => panic!("no dylibs built for codegen backend?"), + }; + if let Some(f) = files.next() { + panic!( + "codegen backend built two dylibs:\n{}\n{}", + codegen_backend.display(), + f.display() + ); + } + let stamp = codegen_backend_stamp(builder, compiler, target, backend); + let codegen_backend = codegen_backend.to_str().unwrap(); + t!(fs::write(&stamp, &codegen_backend)); + } +} + +/// Creates the `codegen-backends` folder for a compiler that's about to be +/// assembled as a complete compiler. +/// +/// This will take the codegen artifacts produced by `compiler` and link them +/// into an appropriate location for `target_compiler` to be a functional +/// compiler. +fn copy_codegen_backends_to_sysroot( + builder: &Builder<'_>, + compiler: Compiler, + target_compiler: Compiler, +) { + let target = target_compiler.host; + + // Note that this step is different than all the other `*Link` steps in + // that it's not assembling a bunch of libraries but rather is primarily + // moving the codegen backend into place. The codegen backend of rustc is + // not linked into the main compiler by default but is rather dynamically + // selected at runtime for inclusion. + // + // Here we're looking for the output dylib of the `CodegenBackend` step and + // we're copying that into the `codegen-backends` folder. + let dst = builder.sysroot_codegen_backends(target_compiler); + t!(fs::create_dir_all(&dst)); + + if builder.config.dry_run { + return; + } + + for backend in builder.config.rust_codegen_backends.iter() { + if backend == "llvm" { + continue; // Already built as part of rustc + } + + let stamp = codegen_backend_stamp(builder, compiler, target, *backend); + let dylib = t!(fs::read_to_string(&stamp)); + let file = Path::new(&dylib); + let filename = file.file_name().unwrap().to_str().unwrap(); + // change `librustc_codegen_cranelift-xxxxxx.so` to + // `librustc_codegen_cranelift-release.so` + let target_filename = { + let dash = filename.find('-').unwrap(); + let dot = filename.find('.').unwrap(); + format!("{}-{}{}", &filename[..dash], builder.rust_release(), &filename[dot..]) + }; + builder.copy(&file, &dst.join(target_filename)); + } +} + /// Cargo's output path for the standard library in a given stage, compiled /// by a particular compiler for the specified target. pub fn libstd_stamp(builder: &Builder<'_>, compiler: Compiler, target: TargetSelection) -> PathBuf { @@ -656,6 +794,19 @@ pub fn librustc_stamp( builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc.stamp") } +/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular +/// compiler for the specified target and backend. +fn codegen_backend_stamp( + builder: &Builder<'_>, + compiler: Compiler, + target: TargetSelection, + backend: Interned, +) -> PathBuf { + builder + .cargo_out(compiler, Mode::Codegen, target) + .join(format!(".librustc_codegen_{}.stamp", backend)) +} + pub fn compiler_file( builder: &Builder<'_>, compiler: &Path, @@ -782,6 +933,18 @@ impl Step for Assemble { // when not performing a full bootstrap). builder.ensure(Rustc { compiler: build_compiler, target: target_compiler.host }); + for &backend in builder.config.rust_codegen_backends.iter() { + if backend == "llvm" { + continue; // Already built as part of rustc + } + + builder.ensure(CodegenBackend { + compiler: build_compiler, + target: target_compiler.host, + backend, + }); + } + let lld_install = if builder.config.lld_enabled { Some(builder.ensure(native::Lld { target: target_compiler.host })) } else { @@ -804,6 +967,8 @@ impl Step for Assemble { } } + copy_codegen_backends_to_sysroot(builder, build_compiler, target_compiler); + let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host); if let Some(lld_install) = lld_install { let src_exe = exe("lld", target_compiler.host); diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 1887b805da19b..3b7458351b14e 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -504,6 +504,19 @@ impl Step for Rustc { } } + // Copy over the codegen backends + let backends_src = builder.sysroot_codegen_backends(compiler); + let backends_rel = backends_src + .strip_prefix(&src) + .unwrap() + .strip_prefix(builder.sysroot_libdir_relative(compiler)) + .unwrap(); + // Don't use custom libdir here because ^lib/ will be resolved again with installer + let backends_dst = image.join("lib").join(&backends_rel); + + t!(fs::create_dir_all(&backends_dst)); + builder.cp_r(&backends_src, &backends_dst); + // Copy libLLVM.so to the lib dir as well, if needed. While not // technically needed by rustc itself it's needed by lots of other // components like the llvm tools and LLD. LLD is included below and @@ -1115,6 +1128,7 @@ impl Step for PlainSourceTarball { cmd.arg("vendor") .arg("--sync") .arg(builder.src.join("./src/tools/rust-analyzer/Cargo.toml")) + .arg(builder.src.join("./compiler/rustc_codegen_cranelift/Cargo.toml")) .current_dir(&plain_dst_src); builder.run(&mut cmd); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 22a8e828862f7..6880f6e816a4b 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -307,6 +307,9 @@ pub enum Mode { /// Build librustc, and compiler libraries, placing output in the "stageN-rustc" directory. Rustc, + /// Build a codegen backend for rustc, placing the output in the "stageN-codegen" directory. + Codegen, + /// Build a tool, placing output in the "stage0-bootstrap-tools" /// directory. This is for miscellaneous sets of tools that are built /// using the bootstrap stage0 compiler in its entirety (target libraries @@ -594,6 +597,7 @@ impl Build { let suffix = match mode { Mode::Std => "-std", Mode::Rustc => "-rustc", + Mode::Codegen => "-codegen", Mode::ToolBootstrap => "-bootstrap-tools", Mode::ToolStd | Mode::ToolRustc => "-tools", }; diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 19218cbd66a8a..cc4c43f0468ab 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -50,6 +50,7 @@ pub mod unstable_book; fn filter_dirs(path: &Path) -> bool { let skip = [ + "compiler/rustc_codegen_cranelift", "src/llvm-project", "library/backtrace", "library/stdarch",